summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-02-13 19:24:11 +0100
committerMichael Lutz <michi@icosahedron.de>2021-02-14 14:16:40 +0100
commit33099355b8f89e9a2e87f3f7797b7366fc68f330 (patch)
tree338b1501a7345def1793bea2be22bac1e0aa8278 /src
parent22f5aeab07cb1c67561b9e348e2c944740233607 (diff)
downloadopenttd-33099355b8f89e9a2e87f3f7797b7366fc68f330.tar.xz
Codechange: Re-init GUI zoom only when really changed.
Diffstat (limited to 'src')
-rw-r--r--src/settings_gui.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 8bf118e76..6abc4260f 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -538,24 +538,32 @@ struct GameOptionsWindow : Window {
}
break;
- case WID_GO_GUI_ZOOM_DROPDOWN:
- GfxClearSpriteCache();
- _gui_zoom_cfg = index > 0 ? ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
- UpdateGUIZoom();
- UpdateCursorSize();
- UpdateAllVirtCoords();
- FixTitleGameZoom();
- ReInitAllWindows();
+ case WID_GO_GUI_ZOOM_DROPDOWN: {
+ int8 new_zoom = index > 0 ? ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
+ if (new_zoom != _gui_zoom_cfg) {
+ GfxClearSpriteCache();
+ _gui_zoom_cfg = new_zoom;
+ UpdateGUIZoom();
+ UpdateCursorSize();
+ UpdateAllVirtCoords();
+ FixTitleGameZoom();
+ ReInitAllWindows();
+ }
break;
+ }
- case WID_GO_FONT_ZOOM_DROPDOWN:
- GfxClearSpriteCache();
- _font_zoom_cfg = index > 0 ? ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
- UpdateGUIZoom();
- ClearFontCache();
- LoadStringWidthTable();
- UpdateAllVirtCoords();
+ case WID_GO_FONT_ZOOM_DROPDOWN: {
+ int8 new_zoom = index > 0 ? ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
+ if (new_zoom != _font_zoom_cfg) {
+ GfxClearSpriteCache();
+ _font_zoom_cfg = new_zoom;
+ UpdateGUIZoom();
+ ClearFontCache();
+ LoadStringWidthTable();
+ UpdateAllVirtCoords();
+ }
break;
+ }
case WID_GO_BASE_GRF_DROPDOWN:
this->SetMediaSet<BaseGraphics>(index);