1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Remove hardcoded ride type IDs in ride type dropdown

This commit is contained in:
Michael Steenbeek
2025-11-13 19:50:22 +01:00
committed by GitHub
parent f204d937ab
commit 9e36c7a2dc
3 changed files with 15 additions and 42 deletions

View File

@@ -32,12 +32,9 @@ STR_0027 :Dodgems
STR_0028 :Swinging Ship
STR_0029 :Swinging Inverter Ship
STR_0030 :Food Stall
STR_0031 :Unknown Stall (1D)
STR_0032 :Drink Stall
STR_0033 :Unknown Stall (1F)
STR_0034 :Shop
STR_0035 :Merry-Go-Round
STR_0036 :Unknown Stall (22)
STR_0037 :Information Kiosk
STR_0038 :Toilets
STR_0039 :Ferris Wheel
@@ -83,16 +80,10 @@ STR_0078 :Inverted Hairpin Coaster
STR_0079 :Magic Carpet
STR_0080 :Submarine Ride
STR_0081 :River Rafts
STR_0082 :Unknown Ride (50)
STR_0083 :Enterprise
STR_0084 :Unknown Ride (52)
STR_0085 :Unknown Ride (53)
STR_0086 :Unknown Ride (54)
STR_0087 :Unknown Ride (55)
STR_0088 :Inverted Impulse Coaster
STR_0089 :Mini Roller Coaster
STR_0090 :Mine Ride
STR_0091 :Unknown Ride (59)
STR_0092 :LIM Launched Roller Coaster
STR_0093 :Hybrid Coaster
STR_0094 :Single Rail Roller Coaster
@@ -3846,3 +3837,4 @@ STR_7004 :Force Redraw
STR_7005 :Drag an area of footpath
STR_7006 :Draw border around image buttons
STR_7007 :Ride Type
STR_7008 :Unknown ride type ({INT32})

View File

@@ -1574,15 +1574,7 @@ namespace OpenRCT2
STR_RIDE_MODE_NUMBER_OF_SWINGS_VALUE = 1771,
STR_RIDE_MODE_SPEED_VALUE = 1331,
STR_RIDE_MODE_TIME_LIMIT_VALUE = 1749,
STR_RIDE_NAME_1D = 31,
STR_RIDE_NAME_1F = 33,
STR_RIDE_NAME_22 = 36,
STR_RIDE_NAME_50 = 82,
STR_RIDE_NAME_52 = 84,
STR_RIDE_NAME_53 = 85,
STR_RIDE_NAME_54 = 86,
STR_RIDE_NAME_55 = 87,
STR_RIDE_NAME_59 = 91,
STR_RIDE_NAME_UNKNOWN_INT32 = 7008,
STR_RIDE_SECONDARY_PRICE_VALUE = 1799,
STR_RIDE_STATS_ALTITUDE = 1416,
STR_RIDE_STATS_ALTITUDE_FORMAT = 1420,

View File

@@ -45,6 +45,7 @@
#include <openrct2/entity/Staff.h>
#include <openrct2/localisation/Currency.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Formatting.h>
#include <openrct2/localisation/Localisation.Date.h>
#include <openrct2/localisation/LocalisationService.h>
#include <openrct2/network/Network.h>
@@ -624,7 +625,7 @@ namespace OpenRCT2::Ui::Windows
{
ride_type_t RideTypeId;
StringId LabelId;
u8string_view LabelString;
u8string LabelString;
};
// Used for sorting the vehicle type dropdown.
@@ -1877,29 +1878,12 @@ namespace OpenRCT2::Ui::Windows
static constexpr StringId GetRideTypeNameForDropdown(ride_type_t rideType)
{
switch (rideType)
auto stringId = GetRideTypeDescriptor(rideType).Naming.Name;
if (stringId == STR_UNKNOWN_RIDE)
{
case RIDE_TYPE_1D:
return STR_RIDE_NAME_1D;
case RIDE_TYPE_1F:
return STR_RIDE_NAME_1F;
case RIDE_TYPE_22:
return STR_RIDE_NAME_22;
case RIDE_TYPE_50:
return STR_RIDE_NAME_50;
case RIDE_TYPE_52:
return STR_RIDE_NAME_52;
case RIDE_TYPE_53:
return STR_RIDE_NAME_53;
case RIDE_TYPE_54:
return STR_RIDE_NAME_54;
case RIDE_TYPE_55:
return STR_RIDE_NAME_55;
case RIDE_TYPE_59:
return STR_RIDE_NAME_59;
default:
return GetRideTypeDescriptor(rideType).Naming.Name;
stringId = STR_RIDE_NAME_UNKNOWN_INT32;
}
return stringId;
}
void PopulateRideTypeDropdown()
@@ -1912,8 +1896,13 @@ namespace OpenRCT2::Ui::Windows
for (uint8_t i = 0; i < RIDE_TYPE_COUNT; i++)
{
// Will return the actual name for most rides, but a special string "Unknown Ride ({INT32})" for unknown ones.
// The placeholder will then be filled with the ID.
auto name = GetRideTypeNameForDropdown(i);
_rideDropdownData.push_back({ i, name, u8string_view{ ls.GetString(name) } });
auto ft = Formatter();
ft.Add<int32_t>(i);
auto label = FormatStringIDLegacy(name, ft.Data());
_rideDropdownData.push_back({ i, name, label });
}
std::sort(_rideDropdownData.begin(), _rideDropdownData.end(), [](auto& a, auto& b) {
@@ -1933,7 +1922,7 @@ namespace OpenRCT2::Ui::Windows
for (size_t i = 0; i < _rideDropdownData.size(); i++)
{
gDropdown.items[i] = Dropdown::MenuLabel(_rideDropdownData[i].LabelId);
gDropdown.items[i] = Dropdown::MenuLabel(_rideDropdownData[i].LabelString);
}
Widget* dropdownWidget = widget - 1;