From a87144d669990119962d5ddef95055a312964751 Mon Sep 17 00:00:00 2001 From: OllieBechstein Date: Thu, 19 Jun 2025 21:57:00 +0200 Subject: [PATCH 1/2] Added a variable in settings_gui that can remember the previous gui scale that was set. This means that toggling the auto scale on and then off will revert the scale to it's previous value. --- src/settings_gui.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 94a073d904..8d981cb25f 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -424,6 +424,7 @@ struct GameOptionsWindow : Window { GameSettings *opt = nullptr; bool reload = false; int gui_scale = 0; + static inline int previous_gui_scale = 0; ///< Previous GUI scale. static inline WidgetID active_tab = WID_GO_TAB_GENERAL; GameOptionsWindow(WindowDesc &desc) : Window(desc), filter_editbox(50), gui_scale(_gui_scale) @@ -1072,9 +1073,12 @@ struct GameOptionsWindow : Window { case WID_GO_GUI_SCALE_AUTO: { if (_gui_scale_cfg == -1) { - _gui_scale_cfg = _gui_scale; + _gui_scale_cfg = previous_gui_scale; // Store the previous GUI scale value this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false); + if (AdjustGUIZoom(false)) ReInitAllWindows(true); + this->gui_scale = _gui_scale; } else { + previous_gui_scale = _gui_scale; // Set the previous GUI scale value as the current one _gui_scale_cfg = -1; this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, true); if (AdjustGUIZoom(false)) ReInitAllWindows(true); From 71ac8d508b2c63de073a838557069f2fa57fde1e Mon Sep 17 00:00:00 2001 From: OllieBechstein Date: Thu, 19 Jun 2025 22:34:08 +0200 Subject: [PATCH 2/2] Fix coding style to better conform to the guidelines --- src/settings_gui.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 90f8631911..4cea8487cb 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1069,7 +1069,8 @@ struct GameOptionsWindow : Window { if (_gui_scale_cfg == -1) { _gui_scale_cfg = previous_gui_scale; // Store the previous GUI scale value this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false); - if (AdjustGUIZoom(false)) ReInitAllWindows(true); + if (AdjustGUIZoom(false)) + ReInitAllWindows(true); this->gui_scale = _gui_scale; } else { previous_gui_scale = _gui_scale; // Set the previous GUI scale value as the current one