Allow UI scaling of 4 in Scenario Editor

dialog.cpp[cleaning]: remove unused code
This commit is contained in:
ALONSO Laurent
2021-10-06 13:47:57 +02:00
committed by Celtic Minstrel
parent 4ac9081bb3
commit cd6eebdebe
3 changed files with 21 additions and 16 deletions

View File

@@ -512,15 +512,6 @@ void cDialog::run(std::function<void(cDialog&)> 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;

View File

@@ -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<cLed&>(me["scaleui"]);
if(ui_scale.getState() == led_off)
std::string scale = dynamic_cast<cLedGroup&>(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<cLed&>(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<cLed&>(prefsDlog["scaleui"]).setState(ui_scale == 1.0 ? led_off : (ui_scale == 2.0 ? led_red : led_green));
cLedGroup& uiScale = dynamic_cast<cLedGroup&>(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<cLed&>(prefsDlog["nosound"]).setState(get_bool_pref("PlaySounds", true) ? led_off : led_red);
prefsDlog.run();