diff --git a/src/gfx.cpp b/src/gfx.cpp index 493f87cbc5..75217f2803 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -2361,7 +2361,7 @@ void UpdateGUIZoom() * @returns true when the zoom level has changed, caller must call ReInitAllWindows(true) * after resizing the application's window/buffer. */ -bool AdjustGUIZoom(bool automatic) +bool AdjustGUIZoom(AdjustGUIZoomMode mode) { ZoomLevel old_zoom = _gui_zoom; int old_scale = _gui_scale; @@ -2373,14 +2373,14 @@ bool AdjustGUIZoom(bool automatic) GfxClearSpriteCache(); VideoDriver::GetInstance()->ClearSystemSprites(); UpdateCursorSize(); - UpdateRouteStepSpriteSize(); + if (mode != AGZM_STARTUP) UpdateRouteStepSpriteSize(); } ClearFontCache(); UpdateFontHeightCache(); LoadStringWidthTable(); UpdateAllVirtCoords(); - FixTitleGameZoom(); + if (mode != AGZM_STARTUP) FixTitleGameZoom(); extern void FlushDeparturesWindowTextCaches(); FlushDeparturesWindowTextCaches(); @@ -2389,7 +2389,7 @@ bool AdjustGUIZoom(bool automatic) to move around when the application is moved to a screen with different DPI. */ auto zoom_shift = old_zoom - _gui_zoom; for (Window *w : Window::IterateFromBack()) { - if (automatic) { + if (mode == AGZM_AUTOMATIC) { w->left = (w->left * _gui_scale) / old_scale; w->top = (w->top * _gui_scale) / old_scale; w->width = (w->width * _gui_scale) / old_scale; diff --git a/src/gfx_func.h b/src/gfx_func.h index f4203ccb18..85974f4d34 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -83,9 +83,15 @@ void ChangeGameSpeed(bool enable_fast_forward); void DrawMouseCursor(); void ScreenSizeChanged(); void GameSizeChanged(); -bool AdjustGUIZoom(bool automatic); void UndrawMouseCursor(); +enum AdjustGUIZoomMode { + AGZM_MANUAL, + AGZM_AUTOMATIC, + AGZM_STARTUP, +}; +bool AdjustGUIZoom(AdjustGUIZoomMode mode); + /** Size of the buffer used for drawing strings. */ static const int DRAW_STRING_BUFFER = 2048; diff --git a/src/openttd.cpp b/src/openttd.cpp index 58b529edfc..0376e7badb 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -941,7 +941,7 @@ int openttd_main(int argc, char *argv[]) _screen.zoom = ZOOM_LVL_NORMAL; /* The video driver is now selected, now initialise GUI zoom */ - AdjustGUIZoom(false); + AdjustGUIZoom(AGZM_STARTUP); NetworkStartUp(); // initialize network-core diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index db9843ec9d..3caaa96437 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -520,7 +520,7 @@ struct GameOptionsWindow : Window { } else { _gui_scale_cfg = -1; this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, true); - if (AdjustGUIZoom(false)) ReInitAllWindows(true); + if (AdjustGUIZoom(AGZM_MANUAL)) ReInitAllWindows(true); this->gui_scale = _gui_scale; } this->SetWidgetDirty(widget); @@ -564,7 +564,7 @@ struct GameOptionsWindow : Window { _gui_scale_cfg = this->gui_scale; - if (AdjustGUIZoom(false)) { + if (AdjustGUIZoom(AGZM_MANUAL)) { ReInitAllWindows(true); this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false); this->SetDirty(); diff --git a/src/video/cocoa/cocoa_wnd.mm b/src/video/cocoa/cocoa_wnd.mm index 2499a94c36..ab3c01f55c 100644 --- a/src/video/cocoa/cocoa_wnd.mm +++ b/src/video/cocoa/cocoa_wnd.mm @@ -1271,7 +1271,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel /** Screen the window is on changed. */ - (void)windowDidChangeBackingProperties:(NSNotification *)notification { - bool did_adjust = AdjustGUIZoom(true); + bool did_adjust = AdjustGUIZoom(AGZM_AUTOMATIC); /* Reallocate screen buffer if necessary. */ driver->AllocateBackingStore(); diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 7dd49b6345..4693634982 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -677,7 +677,7 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } case WM_DPICHANGED: { - auto did_adjust = AdjustGUIZoom(true); + auto did_adjust = AdjustGUIZoom(AGZM_AUTOMATIC); /* Resize the window to match the new DPI setting. */ RECT *prcNewWindow = (RECT *)lParam;