From cd6eebdebe6acd9e7fe3e0ed5f6c93bc6d0e07ca Mon Sep 17 00:00:00 2001 From: ALONSO Laurent Date: Wed, 6 Oct 2021 13:47:57 +0200 Subject: [PATCH] Allow UI scaling of 4 in Scenario Editor dialog.cpp[cleaning]: remove unused code --- rsrc/dialogs/pref-scenario.xml | 12 +++++++++--- src/dialogxml/dialogs/dialog.cpp | 9 --------- src/scenedit/scen.main.cpp | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/rsrc/dialogs/pref-scenario.xml b/rsrc/dialogs/pref-scenario.xml index 63f09175..7189b519 100644 --- a/rsrc/dialogs/pref-scenario.xml +++ b/rsrc/dialogs/pref-scenario.xml @@ -6,8 +6,14 @@ BoE Scenario Editor Preferences No Sounds - Apply UI scaling - - + Scale UI: + + 1 + 2 + 4 + other + + + diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 8a8cf6a5..77146d07 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -512,15 +512,6 @@ void cDialog::run(std::function onopen){ currentFocus = iter->first; } } -#if 0 - // Sometimes it seems like the Cocoa menu handling clobbers the active rendering context. - // For whatever reason, delaying 100 milliseconds appears to fix this. - sf::sleep(sf::milliseconds(100)); - // So this little section of code is a real-life valley of dying things. - // Instantiating a window and then closing it seems to fix the update error, because magic. - win.create(sf::VideoMode(1,1),""); - win.close(); -#endif if (ui_scale<=0) { ui_scale = get_float_pref("UIScale", 1.0); if (ui_scale < 0.1) ui_scale = 1.0; diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 1ad69d35..0fa272db 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -28,6 +28,7 @@ #include "button.hpp" #include "keycodes.hpp" #include "led.hpp" +#include "ledgroup.hpp" #include "prefs.hpp" #include "framerate_limiter.hpp" #include "event_listener.hpp" @@ -679,11 +680,13 @@ bool prefs_event_filter (cDialog& me, std::string id, eKeyMod) { } if(!did_cancel) { - cLed& ui_scale = dynamic_cast(me["scaleui"]); - if(ui_scale.getState() == led_off) + std::string scale = dynamic_cast(me["scaleui"]).getSelected(); + if(scale == "1") set_pref("UIScale", 1.0); - else if(ui_scale.getState() == led_red) + else if(scale == "2") set_pref("UIScale", 2.0); + else if(scale == "4") + set_pref("UIScale", 4.0); set_pref("PlaySounds", dynamic_cast(me["nosound"]).getState() == led_off); } save_prefs(); @@ -697,7 +700,12 @@ void pick_preferences() { prefsDlog.attachClickHandlers(&prefs_event_filter, {"okay", "cancel"}); float ui_scale = get_float_pref("UIScale", 1.0); - dynamic_cast(prefsDlog["scaleui"]).setState(ui_scale == 1.0 ? led_off : (ui_scale == 2.0 ? led_red : led_green)); + cLedGroup& uiScale = dynamic_cast(prefsDlog["scaleui"]); + if (ui_scale>0.95 && ui_scale<1.05) uiScale.setSelected("1"); + else if (ui_scale>1.95 && ui_scale<2.05) uiScale.setSelected("2"); + else if (ui_scale>3.95 && ui_scale<4.05) uiScale.setSelected("4"); + else uiScale.setSelected("other"); + dynamic_cast(prefsDlog["nosound"]).setState(get_bool_pref("PlaySounds", true) ? led_off : led_red); prefsDlog.run();