From 6da08cb39e29c032bdd5a805fd68c3dd8bf2d791 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Thu, 21 Aug 2025 21:50:45 +0200 Subject: [PATCH] Create new methods for dropdowns --- src/openrct2-ui/interface/Dropdown.h | 7 +++++++ src/openrct2-ui/windows/Dropdown.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/openrct2-ui/interface/Dropdown.h b/src/openrct2-ui/interface/Dropdown.h index 4d232483d7..43d760d309 100644 --- a/src/openrct2-ui/interface/Dropdown.h +++ b/src/openrct2-ui/interface/Dropdown.h @@ -13,6 +13,7 @@ #include #include #include +#include struct ImageId; @@ -39,9 +40,15 @@ namespace OpenRCT2::Ui::Windows void WindowDropdownShowText( const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t flags, size_t num_items, size_t prefRowsPerColumn = 0); + void WindowDropdownShowText( + const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t flags, + std::span items, size_t prefRowsPerColumn = 0); void WindowDropdownShowTextCustomWidth( const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t custom_height, uint8_t flags, size_t num_items, int32_t width, size_t prefRowsPerColumn = 0); + void WindowDropdownShowTextCustomWidth( + const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t custom_height, uint8_t flags, + std::span items, int32_t width, size_t prefRowsPerColumn = 0); void WindowDropdownShowImage( int32_t x, int32_t y, int32_t extray, ColourWithFlags colour, uint8_t flags, int32_t numItems, int32_t itemWidth, diff --git a/src/openrct2-ui/windows/Dropdown.cpp b/src/openrct2-ui/windows/Dropdown.cpp index 0831efaf82..218a587465 100644 --- a/src/openrct2-ui/windows/Dropdown.cpp +++ b/src/openrct2-ui/windows/Dropdown.cpp @@ -310,6 +310,14 @@ namespace OpenRCT2::Ui::Windows } }; + static void copyItemsToGlobal(std::span items) + { + for (size_t i = 0; i < items.size(); i++) + { + gDropdownItems[i] = items[i]; + } + } + /** * Shows a text dropdown menu. * rct2: 0x006ECFB9 @@ -340,6 +348,14 @@ namespace OpenRCT2::Ui::Windows screenPos, extray, colour, 0, flags, num_items, max_string_width + 3, prefRowsPerColumn); } + void WindowDropdownShowText( + const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t flags, + std::span items, size_t prefRowsPerColumn) + { + copyItemsToGlobal(items); + WindowDropdownShowText(screenPos, extray, colour, flags, items.size(), prefRowsPerColumn); + } + /** * Shows a text dropdown menu. * rct2: 0x006ECFB9, although 0x006ECE50 is real version @@ -373,6 +389,15 @@ namespace OpenRCT2::Ui::Windows } } + void WindowDropdownShowTextCustomWidth( + const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t custom_height, uint8_t flags, + std::span items, int32_t width, size_t prefRowsPerColumn) + { + copyItemsToGlobal(items); + WindowDropdownShowTextCustomWidth( + screenPos, extray, colour, custom_height, flags, items.size(), width, prefRowsPerColumn); + } + /** * Shows an image dropdown menu. * rct2: 0x006ECFB9