From 472ab1996a5bfec77552854c2069cb1653bc76ad Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Mon, 24 Mar 2025 18:42:05 +0100 Subject: [PATCH] Order custom menus consistently by label text (#24067) --- distribution/changelog.txt | 1 + src/openrct2-ui/scripting/ScUi.hpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index a5b8aefb32..befb65aad8 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -4,6 +4,7 @@ - Feature: [#23876] New park save files now contain a preview image, shown in the load/save window. - Change: [#23932] The land rights window now checks “Land Owned” by default. - Change: [#23936] The ‘guests prefer less/more intense rides’ settings have been turned into a dropdown. +- Change: [#24067] [Plugin] Registered menu items are now listed alphabetically. - Fix: [#4225] Ride Construction window offers non-existent banked sloped to level curve (original bug). - Fix: [#5281] Missing supports on miniature railways built backwards. - Fix: [#10379] Banners outside the park can be renamed and modified (original bug). diff --git a/src/openrct2-ui/scripting/ScUi.hpp b/src/openrct2-ui/scripting/ScUi.hpp index 85f2be5ca8..2bc30d5805 100644 --- a/src/openrct2-ui/scripting/ScUi.hpp +++ b/src/openrct2-ui/scripting/ScUi.hpp @@ -18,6 +18,7 @@ #include "ScViewport.hpp" #include "ScWindow.hpp" + #include #include #include #include @@ -324,6 +325,7 @@ namespace OpenRCT2::Scripting auto& execInfo = _scriptEngine.GetExecInfo(); auto owner = execInfo.GetCurrentPlugin(); CustomMenuItems.emplace_back(owner, CustomToolbarMenuItemKind::Standard, text, callback); + std::ranges::sort(CustomMenuItems, [](auto&& a, auto&& b) { return a.Text < b.Text; }); } void registerToolboxMenuItem(const std::string& text, DukValue callback) @@ -333,6 +335,7 @@ namespace OpenRCT2::Scripting if (owner->GetMetadata().Type == PluginType::Intransient) { CustomMenuItems.emplace_back(owner, CustomToolbarMenuItemKind::Toolbox, text, callback); + std::ranges::sort(CustomMenuItems, [](auto&& a, auto&& b) { return a.Text < b.Text; }); } else {