From b081884d47b35b3c4b8f98c19424915282adcc76 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 20 Apr 2025 14:49:41 +0200 Subject: [PATCH 1/2] Fix glitchy initial map window dimensions --- src/openrct2-ui/windows/Map.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index eaaacf700b..03f513a7c6 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -240,7 +240,6 @@ namespace OpenRCT2::Ui::Windows flags |= WF_RESIZABLE; - WindowSetResize(*this, { WW, WH }, { WW, WH }); SetInitialWindowDimensions(); ResetMaxWindowDimensions(); ResizeMiniMap(); @@ -1210,13 +1209,15 @@ namespace OpenRCT2::Ui::Windows void ResetMaxWindowDimensions() { - max_width = std::clamp(getMiniMapWidth() + GetReservedRightSpace(), WW, ContextGetWidth()); - max_height = std::clamp( + auto newMaxWidth = std::clamp(getMiniMapWidth() + GetReservedRightSpace(), WW, ContextGetWidth()); + auto newMaxHeight = std::clamp( getMiniMapWidth() + kReservedTopSpace + GetReservedBottomSpace(), WH, ContextGetHeight() - 68); auto scrollbarSize = getMiniMapWidth() + GetReservedRightSpace() > ContextGetWidth() ? kScrollBarWidth : 2; - max_width += scrollbarSize; - max_height += scrollbarSize; + newMaxWidth += scrollbarSize; + newMaxHeight += scrollbarSize; + + WindowSetResize(*this, { WW, WH }, { newMaxWidth, newMaxHeight }); } void ResizeMiniMap() From 63bbc893ed9840cef6fb4347ed1d9cfeed50ddd2 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 20 Apr 2025 14:54:54 +0200 Subject: [PATCH 2/2] Tweak initial dimensions to account for optional scrollbars --- src/openrct2-ui/windows/Map.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 03f513a7c6..27d3b493c7 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1190,13 +1190,14 @@ namespace OpenRCT2::Ui::Windows void SetInitialWindowDimensions() { // The initial mini map size should be able to show a reasonably sized map - auto initSize = std::clamp(getPracticalMapSize(), 100, 254) * 2; - width = initSize + GetReservedRightSpace(); - height = initSize + kReservedTopSpace + GetReservedBottomSpace(); + auto initWidth = std::clamp(getPracticalMapSize(), 100, 254) * 2; + width = initWidth + GetReservedRightSpace(); - auto scrollbarSize = getPracticalMapSize() > 254 ? kScrollBarWidth : 2; - width += scrollbarSize; - height += scrollbarSize; + auto initHeight = std::clamp(getMiniMapWidth(), 100, 254) * 2; + height = initHeight + kReservedTopSpace + GetReservedBottomSpace(); + + width += getPracticalMapSize() > initWidth ? kScrollBarWidth : 2; + height += getMiniMapWidth() > initHeight ? kScrollBarWidth : 2; auto maxWindowHeight = ContextGetHeight() - 68; width = std::min(width, ContextGetWidth());