Part of #9473: Create Vehicle::SetMapToolbar

Converted from vehicle_set_map_toolbar
This commit is contained in:
hdpoliveira 2020-04-19 02:17:53 -03:00
parent e8c95e6e3a
commit acc6b9f878
3 changed files with 10 additions and 10 deletions

View File

@ -82,7 +82,7 @@ int32_t viewport_interaction_get_item_left(const ScreenCoordsXY& screenCoords, v
case SPRITE_IDENTIFIER_VEHICLE:
vehicle = &(sprite->vehicle);
if (vehicle->ride_subtype != RIDE_ENTRY_INDEX_NULL)
vehicle_set_map_toolbar(vehicle);
vehicle->SetMapToolbar();
else
info->type = VIEWPORT_INTERACTION_ITEM_NONE;
break;

View File

@ -6170,25 +6170,25 @@ GForces vehicle_get_g_forces(const Vehicle* vehicle)
return { static_cast<int16_t>(gForceVert & 0xFFFF), static_cast<int16_t>(gForceLateral & 0xFFFF) };
}
void vehicle_set_map_toolbar(const Vehicle* vehicle)
void Vehicle::SetMapToolbar() const
{
auto ride = get_ride(vehicle->ride);
if (ride != nullptr)
auto curRide = get_ride(ride);
if (curRide != nullptr)
{
vehicle = vehicle->GetHead();
const Vehicle* vehicle = GetHead();
int32_t vehicleIndex;
for (vehicleIndex = 0; vehicleIndex < 32; vehicleIndex++)
if (ride->vehicles[vehicleIndex] == vehicle->sprite_index)
if (curRide->vehicles[vehicleIndex] == vehicle->sprite_index)
break;
auto ft = Formatter::MapTooltip();
ft.Add<rct_string_id>(STR_RIDE_MAP_TIP);
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_STRINGID);
ride->FormatNameTo(ft);
ft.Add<rct_string_id>(RideComponentNames[RideTypeDescriptors[ride->type].NameConvention.vehicle].capitalised);
curRide->FormatNameTo(ft);
ft.Add<rct_string_id>(RideComponentNames[RideTypeDescriptors[curRide->type].NameConvention.vehicle].capitalised);
ft.Add<uint16_t>(vehicleIndex + 1);
ride->FormatStatusTo(ft);
curRide->FormatStatusTo(ft);
}
}

View File

@ -307,6 +307,7 @@ struct Vehicle : SpriteBase
void UpdateSoundParams(std::vector<rct_vehicle_sound_params>& vehicleSoundParamsList) const;
bool DodgemsCarWouldCollideAt(const CoordsXY& coords, uint16_t* spriteId) const;
int32_t UpdateTrackMotion(int32_t* outStation);
void SetMapToolbar() const;
int32_t IsUsedInPairs() const;
rct_ride_entry_vehicle* Entry() const;
Vehicle* TrainHead() const;
@ -562,7 +563,6 @@ Vehicle* try_get_vehicle(uint16_t spriteIndex);
void vehicle_update_all();
void vehicle_sounds_update();
GForces vehicle_get_g_forces(const Vehicle* vehicle);
void vehicle_set_map_toolbar(const Vehicle* vehicle);
const rct_vehicle_info* vehicle_get_move_info(int32_t trackSubposition, int32_t typeAndDirection, int32_t offset);
uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDirection);