mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Use C++ strings in WindowNewRideListVehiclesFor()
This commit is contained in:
committed by
GitHub
parent
c334c7a176
commit
323138ebd6
@@ -38,13 +38,13 @@
|
||||
using namespace OpenRCT2::TrackMetaData;
|
||||
|
||||
static constexpr const rct_string_id WINDOW_TITLE = STR_NONE;
|
||||
constexpr size_t AVAILABILITY_STRING_SIZE = 256;
|
||||
static constexpr const int32_t WH = 382;
|
||||
static constexpr const int32_t WW = 601;
|
||||
|
||||
static uint8_t _windowNewRideCurrentTab;
|
||||
static RideSelection _windowNewRideHighlightedItem[6];
|
||||
static RideSelection _windowNewRideListItems[384];
|
||||
static u8string _vehicleAvailability = {};
|
||||
|
||||
#pragma region Ride type view order
|
||||
|
||||
@@ -222,7 +222,7 @@ static void WindowNewRideScrollmouseover(rct_window *w, int32_t scrollIndex, con
|
||||
static void WindowNewRideInvalidate(rct_window *w);
|
||||
static void WindowNewRidePaint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
static void WindowNewRideScrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
||||
static void WindowNewRideListVehiclesFor(uint8_t rideType, const rct_ride_entry* rideEntry, char* buffer, size_t bufferLen);
|
||||
static void WindowNewRideUpdateVehicleAvailability(ObjectEntryIndex rideType);
|
||||
|
||||
// 0x0098E354
|
||||
static rct_window_event_list window_new_ride_events([](auto& events)
|
||||
@@ -903,14 +903,12 @@ static void WindowNewRidePaintRideInformation(
|
||||
ft.Add<rct_string_id>(rideNaming.Description);
|
||||
DrawTextWrapped(dpi, screenPos, width, STR_NEW_RIDE_NAME_AND_DESCRIPTION, ft);
|
||||
|
||||
char availabilityString[AVAILABILITY_STRING_SIZE];
|
||||
WindowNewRideListVehiclesFor(item.Type, rideEntry, availabilityString, sizeof(availabilityString));
|
||||
WindowNewRideUpdateVehicleAvailability(item.Type);
|
||||
|
||||
if (availabilityString[0] != 0)
|
||||
if (!_vehicleAvailability.empty())
|
||||
{
|
||||
const char* drawString = availabilityString;
|
||||
ft = Formatter();
|
||||
ft.Add<const char*>(drawString);
|
||||
ft.Add<const utf8*>(_vehicleAvailability.c_str());
|
||||
DrawTextEllipsised(dpi, screenPos + ScreenCoordsXY{ 0, 39 }, WW - 2, STR_AVAILABLE_VEHICLES, ft);
|
||||
}
|
||||
|
||||
@@ -984,9 +982,9 @@ static void WindowNewRideSelect(rct_window* w)
|
||||
ride_construct_new(item);
|
||||
}
|
||||
|
||||
static void WindowNewRideListVehiclesFor(uint8_t rideType, const rct_ride_entry* rideEntry, char* buffer, size_t bufferLen)
|
||||
static void WindowNewRideUpdateVehicleAvailability(ObjectEntryIndex rideType)
|
||||
{
|
||||
std::fill_n(buffer, bufferLen, 0);
|
||||
_vehicleAvailability.clear();
|
||||
if (GetRideTypeDescriptor(rideType).HasFlag(RIDE_TYPE_FLAG_LIST_VEHICLES_SEPARATELY))
|
||||
{
|
||||
return;
|
||||
@@ -1006,12 +1004,12 @@ static void WindowNewRideListVehiclesFor(uint8_t rideType, const rct_ride_entry*
|
||||
// Append comma if not the first iteration
|
||||
if (!isFirst)
|
||||
{
|
||||
safe_strcat(buffer, ", ", bufferLen);
|
||||
_vehicleAvailability += u8", ";
|
||||
}
|
||||
|
||||
// Append vehicle name
|
||||
auto vehicleName = language_get_string(currentRideEntry->naming.Name);
|
||||
safe_strcat(buffer, vehicleName, bufferLen);
|
||||
_vehicleAvailability += vehicleName;
|
||||
|
||||
isFirst = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user