diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index cbe0880891..d2587b4103 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3845,3 +3845,4 @@ STR_7003 :Audio file ‘{STRING}’ is truncated. Expected sample {INT32}, bu STR_7004 :Force Redraw STR_7005 :Drag an area of footpath STR_7006 :Draw border around image buttons +STR_7007 :Ride Type diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 1b2cec1cdd..d0b2c660a2 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -34,6 +34,7 @@ - Feature: [#25218] `sprite exportobject` command, which allows extracting images from an object. - Feature: [#25274] New title sequence (see https://github.com/OpenRCT2/title-sequences/releases/tag/v0.4.26 for credits). - Improved: [#2296, #2307] The land tool now takes sloped track and paths into account when modifying land. +- Improved: [#25192] Ride List now allows sorting by ride type. - Change: [#25111] Frozen guests no longer finish consuming any food or drink they are carrying. - Change: [#25161] Revert to the ‘fair ride price’ calculation of vanilla RCT2. - Change: [#25201] Ride List: put unknown popularity and satisfaction last when sorting. diff --git a/src/openrct2-ui/UiStringIds.h b/src/openrct2-ui/UiStringIds.h index d71305cba3..39d72a38f9 100644 --- a/src/openrct2-ui/UiStringIds.h +++ b/src/openrct2-ui/UiStringIds.h @@ -1787,6 +1787,7 @@ namespace OpenRCT2 STR_RIDE_LIST_INFORMATION_TYPE_TIP = 1844, STR_RIDE_LIST_INTENSITY = 6464, STR_RIDE_LIST_NAUSEA = 6466, + STR_RIDE_LIST_RIDETYPE = 7007, STR_RIDE_LIST_RUNNING_COST = 5771, STR_RIDE_LIST_RUNNING_COST_LABEL = 5780, STR_RIDE_LIST_RUNNING_COST_UNKNOWN = 5781, diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index 2d11d1dee8..039a9516c8 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -110,8 +110,7 @@ namespace OpenRCT2::Ui::Windows if (researchItem.type == Research::EntryType::ride && !GetRideTypeDescriptor(researchItem.baseRideType).HasFlag(RtdFlag::listVehiclesSeparately)) { - const StringId rideTypeName = GetRideNaming( - researchItem.baseRideType, *GetRideEntryByIndex(researchItem.entryIndex)) + const StringId rideTypeName = GetRideNaming(researchItem.baseRideType, GetRideEntryByIndex(researchItem.entryIndex)) .Name; // Draw group name @@ -419,8 +418,7 @@ namespace OpenRCT2::Ui::Windows && !GetRideTypeDescriptor(researchItem->baseRideType).HasFlag(RtdFlag::listVehiclesSeparately)) { drawString = STR_WINDOW_COLOUR_2_STRINGID_STRINGID; - StringId rideTypeName = GetRideNaming( - researchItem->baseRideType, *GetRideEntryByIndex(researchItem->entryIndex)) + StringId rideTypeName = GetRideNaming(researchItem->baseRideType, GetRideEntryByIndex(researchItem->entryIndex)) .Name; ft.Add(rideTypeName); ft.Add(stringId); diff --git a/src/openrct2-ui/windows/InstallTrack.cpp b/src/openrct2-ui/windows/InstallTrack.cpp index f3aa90db43..c6e21afbb5 100644 --- a/src/openrct2-ui/windows/InstallTrack.cpp +++ b/src/openrct2-ui/windows/InstallTrack.cpp @@ -201,7 +201,7 @@ namespace OpenRCT2::Ui::Windows if (objectEntry != nullptr) { auto groupIndex = ObjectManagerGetLoadedObjectEntryIndex(objectEntry); - auto rideName = GetRideNaming(td.trackAndVehicle.rtdIndex, *GetRideEntryByIndex(groupIndex)); + auto rideName = GetRideNaming(td.trackAndVehicle.rtdIndex, GetRideEntryByIndex(groupIndex)); ft.Add(rideName.Name); } else diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index cb61925d52..12be00ecf7 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -763,7 +763,7 @@ namespace OpenRCT2::Ui::Windows bool IsFilterInRideType(const RideObjectEntry& rideEntry) { - auto rideTypeName = GetRideNaming(rideEntry.ride_type[0], rideEntry).Name; + auto rideTypeName = GetRideNaming(rideEntry.ride_type[0], &rideEntry).Name; return String::contains(u8string_view(LanguageGetString(rideTypeName)), _filter, true); } @@ -921,7 +921,7 @@ namespace OpenRCT2::Ui::Windows auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); const auto* rideObj = objMgr.GetLoadedObject(item.EntryIndex); const auto& rideEntry = rideObj->GetEntry(); - RideNaming rideNaming = GetRideNaming(item.Type, rideEntry); + RideNaming rideNaming = GetRideNaming(item.Type, &rideEntry); auto ft = Formatter(); UpdateVehicleAvailability(item.Type); diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index c013567713..5ff8dd4bb1 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -86,6 +87,7 @@ namespace OpenRCT2::Ui::Windows enum InformationType { INFORMATION_TYPE_STATUS, + INFORMATION_TYPE_RIDETYPE, INFORMATION_TYPE_POPULARITY, INFORMATION_TYPE_SATISFACTION, INFORMATION_TYPE_PROFIT, @@ -109,6 +111,7 @@ namespace OpenRCT2::Ui::Windows static constexpr StringId ride_info_type_string_mapping[DROPDOWN_LIST_COUNT] = { STR_STATUS, + STR_RIDE_LIST_RIDETYPE, STR_POPULARITY, STR_SATISFACTION, STR_PROFIT, @@ -137,6 +140,7 @@ namespace OpenRCT2::Ui::Windows static constexpr bool ride_info_type_money_mapping[DROPDOWN_LIST_COUNT] = { false, // Status + false, // Ride Type false, // Popularity false, // Satisfaction true, // Profit @@ -833,6 +837,13 @@ namespace OpenRCT2::Ui::Windows ft.Add(ridePtr->ratings.intensity); } break; + case INFORMATION_TYPE_RIDETYPE: + { + const auto rideTypeName = ridePtr->getTypeNaming().Name; + formatSecondary = STR_STRINGID; + ft.Add(rideTypeName); + break; + } case INFORMATION_TYPE_NAUSEA: formatSecondary = STR_RATING_UKNOWN_LABEL; if (RideHasRatings(*ridePtr)) @@ -1085,6 +1096,19 @@ namespace OpenRCT2::Ui::Windows return leftValue < rightValue; }); break; + case INFORMATION_TYPE_RIDETYPE: + SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool { + auto* ridePtrLhs = GetRide(thisRide.id); + auto* ridePtrRhs = GetRide(otherRide.id); + if (!ridePtrLhs || !ridePtrRhs) + return ridePtrLhs != nullptr; + + auto rideTypeNameLhs = LanguageGetString(ridePtrLhs->getTypeNaming().Name); + auto rideTypeNameRhs = LanguageGetString(ridePtrRhs->getTypeNaming().Name); + + return String::logicalCmp(rideTypeNameLhs, rideTypeNameRhs) > 0; + }); + break; case INFORMATION_TYPE_NAUSEA: SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool { const auto leftValue = thisRide.ratings.isNull() ? RideRating::kUndefined : thisRide.ratings.nausea; diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 7dca9b78d1..0fbd25fad6 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -383,7 +383,7 @@ namespace OpenRCT2::Ui::Windows if (entry != nullptr) { - RideNaming rideName = GetRideNaming(_window_track_list_item.Type, *entry); + RideNaming rideName = GetRideNaming(_window_track_list_item.Type, entry); stringId = rideName.Name; } diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index db8734d274..45c194ff1d 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -253,7 +253,7 @@ void ResearchFinishItem(const ResearchItem& researchItem) if (GetRideTypeDescriptor(base_ride_type).HasFlag(RtdFlag::listVehiclesSeparately) || researchItem.flags & RESEARCH_ENTRY_FLAG_FIRST_OF_TYPE) { - RideNaming naming = GetRideNaming(base_ride_type, *rideEntry); + RideNaming naming = GetRideNaming(base_ride_type, rideEntry); availabilityString = STR_NEWS_ITEM_RESEARCH_NEW_RIDE_AVAILABLE; ft.Add(naming.Name); } @@ -262,7 +262,7 @@ void ResearchFinishItem(const ResearchItem& researchItem) else { availabilityString = STR_NEWS_ITEM_RESEARCH_NEW_VEHICLE_AVAILABLE; - RideNaming baseRideNaming = GetRideNaming(base_ride_type, *rideEntry); + RideNaming baseRideNaming = GetRideNaming(base_ride_type, rideEntry); ft.Add(baseRideNaming.Name); ft.Add(rideEntry->naming.Name); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 5a1fb4ecf7..069de94afc 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -4410,15 +4410,15 @@ void Ride::setNameToDefault() /** * This will return the name of the ride, as seen in the New Ride window. */ -RideNaming GetRideNaming(const ride_type_t rideType, const RideObjectEntry& rideEntry) +RideNaming GetRideNaming(const ride_type_t rideType, const RideObjectEntry* rideEntry) { const auto& rtd = GetRideTypeDescriptor(rideType); - if (!rtd.HasFlag(RtdFlag::listVehiclesSeparately)) + if (rtd.HasFlag(RtdFlag::listVehiclesSeparately) && rideEntry != nullptr) { - return rtd.Naming; + return rideEntry->naming; } - return rideEntry.naming; + return rtd.Naming; } /* @@ -5800,16 +5800,7 @@ void Ride::formatNameTo(Formatter& ft) const } else { - const auto& rtd = getRideTypeDescriptor(); - auto rideTypeName = rtd.Naming.Name; - if (rtd.HasFlag(RtdFlag::listVehiclesSeparately)) - { - auto rideEntry = getRideEntry(); - if (rideEntry != nullptr) - { - rideTypeName = rideEntry->naming.Name; - } - } + const auto rideTypeName = getTypeNaming().Name; ft.Add(1).Add(rideTypeName).Add(defaultNameNumber); } } @@ -5827,6 +5818,11 @@ const RideTypeDescriptor& Ride::getRideTypeDescriptor() const return ::GetRideTypeDescriptor(type); } +RideNaming Ride::getTypeNaming() const +{ + return GetRideNaming(type, getRideEntry()); +} + uint8_t Ride::getNumShelteredSections() const { return numShelteredSections & ShelteredSectionsBits::kNumShelteredSectionsMask; diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 21da95f2c7..0f99b87900 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -403,6 +403,7 @@ public: uint64_t getAvailableModes() const; const RideTypeDescriptor& getRideTypeDescriptor() const; + RideNaming getTypeNaming() const; OpenRCT2::TrackElement* getOriginElement(StationIndex stationIndex) const; std::pair getMeasurement(); diff --git a/src/openrct2/ride/RideEntry.h b/src/openrct2/ride/RideEntry.h index d64ef7f3de..f2ce9ddea0 100644 --- a/src/openrct2/ride/RideEntry.h +++ b/src/openrct2/ride/RideEntry.h @@ -99,4 +99,4 @@ struct RideObjectEntry } }; -RideNaming GetRideNaming(const ride_type_t rideType, const RideObjectEntry& rideEntry); +RideNaming GetRideNaming(const ride_type_t rideType, const RideObjectEntry* rideEntry);