From 1cc2385ed78bbaf37ce2f2949f88ef03ce24ebd6 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 3 Sep 2025 18:47:27 +0200 Subject: [PATCH] Fix width calculation --- src/openrct2-ui/windows/Dropdown.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/Dropdown.cpp b/src/openrct2-ui/windows/Dropdown.cpp index 687c3d6852..5efa889e11 100644 --- a/src/openrct2-ui/windows/Dropdown.cpp +++ b/src/openrct2-ui/windows/Dropdown.cpp @@ -30,6 +30,8 @@ namespace OpenRCT2::Ui::Windows { constexpr int32_t kDropdownItemHeight = 12; constexpr int32_t kDropdownItemHeightTouch = 24; + // Padding to the left of an item, where a marker can be drawn. + static constexpr int32_t kDropdownItemLeftPadding = 10; static constexpr std::array kAppropriateImageDropdownItemsPerRow = { 1, 1, 1, 1, 2, 2, 3, 3, 4, 3, // 10 @@ -346,15 +348,17 @@ namespace OpenRCT2::Ui::Windows size_t prefRowsPerColumn) { // Calculate the longest string width - int32_t max_string_width = 0; + int32_t maxStringWidth = 0; for (size_t i = 0; i < num_items; i++) { - int32_t string_width = GfxGetStringWidth(gDropdown.items[i].text, FontStyle::Medium); - max_string_width = std::max(string_width, max_string_width); + int32_t stringWidth = GfxGetStringWidth(gDropdown.items[i].text, FontStyle::Medium); + if (gDropdown.items[i].type != Dropdown::ItemType::plain) + stringWidth += kDropdownItemLeftPadding; + maxStringWidth = std::max(stringWidth, maxStringWidth); } WindowDropdownShowTextCustomWidth( - screenPos, extray, colour, 0, flags, num_items, max_string_width + 3, prefRowsPerColumn); + screenPos, extray, colour, 0, flags, num_items, maxStringWidth + 3, prefRowsPerColumn); } void WindowDropdownShowText(