1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Merge pull request #25192 from FlyingThunder/flyingthunder-ridelist-ridetype

Added Ride Type filter to the dropdown in the Ride List window
This commit is contained in:
Michael Steenbeek
2025-10-23 22:01:37 +02:00
committed by GitHub
12 changed files with 47 additions and 25 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -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,

View File

@@ -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<StringId>(rideTypeName);
ft.Add<StringId>(stringId);

View File

@@ -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<StringId>(rideName.Name);
}
else

View File

@@ -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<RideObject>(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);

View File

@@ -23,6 +23,7 @@
#include <openrct2/interface/Colour.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/network/Network.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/RideManager.hpp>
#include <openrct2/ride/RideRatings.h>
#include <openrct2/ui/WindowManager.h>
@@ -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<uint16_t>(ridePtr->ratings.intensity);
}
break;
case INFORMATION_TYPE_RIDETYPE:
{
const auto rideTypeName = ridePtr->getTypeNaming().Name;
formatSecondary = STR_STRINGID;
ft.Add<StringId>(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;

View File

@@ -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;
}

View File

@@ -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<StringId>(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<StringId>(baseRideNaming.Name);
ft.Add<StringId>(rideEntry->naming.Name);

View File

@@ -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<StringId>(1).Add<StringId>(rideTypeName).Add<uint16_t>(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;

View File

@@ -403,6 +403,7 @@ public:
uint64_t getAvailableModes() const;
const RideTypeDescriptor& getRideTypeDescriptor() const;
RideNaming getTypeNaming() const;
OpenRCT2::TrackElement* getOriginElement(StationIndex stationIndex) const;
std::pair<RideMeasurement*, OpenRCT2String> getMeasurement();

View File

@@ -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);