1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Create PlainMenuLabel overload for C strings

This commit is contained in:
Gymnasiast
2025-08-23 17:57:56 +02:00
parent ecd2cf0dfc
commit 2bd0fce142
4 changed files with 8 additions and 7 deletions

View File

@@ -156,6 +156,7 @@ namespace OpenRCT2::Dropdown
}
Item MenuLabel(const utf8* string);
Item PlainMenuLabel(const utf8* string);
/**
* Like MenuLabel, but shows a tick when selected.

View File

@@ -629,4 +629,9 @@ namespace OpenRCT2::Dropdown
{
return Item{ STR_OPTIONS_DROPDOWN_ITEM, reinterpret_cast<int64_t>(string) };
}
Item PlainMenuLabel(const utf8* string)
{
return Item{ STR_STRING, reinterpret_cast<int64_t>(string) };
}
} // namespace OpenRCT2::Dropdown

View File

@@ -190,16 +190,13 @@ namespace OpenRCT2::Ui::Windows
{
if (item.Kind == OpenRCT2::Scripting::CustomToolbarMenuItemKind::Toolbox)
{
// Add seperator
if (!hasCustomItems)
{
hasCustomItems = true;
gDropdown.items[i++] = Dropdown::Separator();
}
gDropdown.items[i].format = STR_STRING;
auto sz = item.Text.c_str();
std::memcpy(&gDropdown.items[i].args.generic, &sz, sizeof(const char*));
gDropdown.items[i] = Dropdown::PlainMenuLabel(item.Text.c_str());
i++;
}
}

View File

@@ -1180,9 +1180,7 @@ namespace OpenRCT2::Ui::Windows
{
if (item.Kind == OpenRCT2::Scripting::CustomToolbarMenuItemKind::Standard)
{
gDropdown.items[i].format = STR_STRING;
auto sz = item.Text.c_str();
std::memcpy(&gDropdown.items[i].args.generic, &sz, sizeof(const char*));
gDropdown.items[i] = Dropdown::PlainMenuLabel(item.Text.c_str());
i++;
}
}