From 5dc992b30a91bb57393ae13279de144364f29e14 Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 26 Apr 2021 20:06:22 +0100 Subject: [PATCH] Fix scenery window auto-height resize --- src/openrct2-ui/windows/Scenery.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index a5d64ecfbd..562f209607 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -728,10 +728,13 @@ static void window_scenery_update(rct_window* w) } else { - int32_t windowHeight = std::min(463, w->scrolls[0].v_bottom + 62); - if (context_get_height() < 600) - windowHeight = std::min(374, windowHeight); - windowHeight = std::max(WINDOW_SCENERY_HEIGHT, windowHeight); + const auto& listWidget = w->widgets[WIDX_SCENERY_LIST]; + auto nonListHeight = w->height - listWidget.height() + 2; + + auto numRows = static_cast(window_scenery_count_rows(w)); + auto maxContentHeight = numRows * SCENERY_BUTTON_HEIGHT; + auto maxWindowHeight = maxContentHeight + nonListHeight; + auto windowHeight = std::clamp(maxWindowHeight, WINDOW_SCENERY_HEIGHT, 463); w->min_width = WINDOW_SCENERY_WIDTH; w->max_width = WINDOW_SCENERY_WIDTH;