mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Refactor ride window to use ImageId
This commit is contained in:
@@ -1047,17 +1047,16 @@ static void WindowRideDrawTabVehicle(rct_drawpixelinfo* dpi, rct_window* w)
|
||||
|
||||
auto vehicleId = ((ride->colour_scheme_type & 3) == VEHICLE_COLOUR_SCHEME_PER_VEHICLE) ? rideEntry->tab_vehicle : 0;
|
||||
VehicleColour vehicleColour = ride_get_vehicle_colour(ride, vehicleId);
|
||||
int32_t spriteIndex = 32;
|
||||
if (w->page == WINDOW_RIDE_PAGE_VEHICLE)
|
||||
spriteIndex += w->frame_no;
|
||||
spriteIndex /= (rideVehicleEntry->flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES) ? 4 : 2;
|
||||
spriteIndex &= rideVehicleEntry->rotation_frame_mask;
|
||||
spriteIndex *= rideVehicleEntry->base_num_frames;
|
||||
spriteIndex += rideVehicleEntry->base_image_id;
|
||||
spriteIndex |= (vehicleColour.Trim << 24) | (vehicleColour.Body << 19);
|
||||
spriteIndex |= IMAGE_TYPE_REMAP_2_PLUS;
|
||||
|
||||
gfx_draw_sprite(&clipDPI, ImageId::FromUInt32(spriteIndex, vehicleColour.Ternary), screenCoords);
|
||||
auto imageIndex = 32;
|
||||
if (w->page == WINDOW_RIDE_PAGE_VEHICLE)
|
||||
imageIndex += w->frame_no;
|
||||
imageIndex /= (rideVehicleEntry->flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES) ? 4 : 2;
|
||||
imageIndex &= rideVehicleEntry->rotation_frame_mask;
|
||||
imageIndex *= rideVehicleEntry->base_num_frames;
|
||||
imageIndex += rideVehicleEntry->base_image_id;
|
||||
auto imageId = ImageId(imageIndex, vehicleColour.Body, vehicleColour.Trim, vehicleColour.Ternary);
|
||||
gfx_draw_sprite(&clipDPI, imageId, screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3013,8 +3012,7 @@ struct VehicleDrawInfo
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int32_t sprite_index;
|
||||
int32_t tertiary_colour;
|
||||
ImageId imageId;
|
||||
};
|
||||
|
||||
static VehicleDrawInfo _sprites_to_draw[144];
|
||||
@@ -3073,20 +3071,18 @@ static void WindowRideVehicleScrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
||||
}
|
||||
VehicleColour vehicleColour = ride_get_vehicle_colour(ride, vehicleColourIndex);
|
||||
|
||||
int32_t spriteIndex = 16;
|
||||
ImageIndex imageIndex = 16;
|
||||
if (rideVehicleEntry->flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES)
|
||||
spriteIndex /= 2;
|
||||
imageIndex /= 2;
|
||||
imageIndex &= rideVehicleEntry->rotation_frame_mask;
|
||||
imageIndex *= rideVehicleEntry->base_num_frames;
|
||||
imageIndex += rideVehicleEntry->base_image_id;
|
||||
|
||||
spriteIndex &= rideVehicleEntry->rotation_frame_mask;
|
||||
spriteIndex *= rideVehicleEntry->base_num_frames;
|
||||
spriteIndex += rideVehicleEntry->base_image_id;
|
||||
spriteIndex |= (vehicleColour.Trim << 24) | (vehicleColour.Body << 19);
|
||||
spriteIndex |= IMAGE_TYPE_REMAP_2_PLUS;
|
||||
auto imageId = ImageId(imageIndex, vehicleColour.Body, vehicleColour.Trim, vehicleColour.Ternary);
|
||||
|
||||
nextSpriteToDraw->x = x;
|
||||
nextSpriteToDraw->y = y;
|
||||
nextSpriteToDraw->sprite_index = spriteIndex;
|
||||
nextSpriteToDraw->tertiary_colour = vehicleColour.Ternary;
|
||||
nextSpriteToDraw->imageId = imageId;
|
||||
nextSpriteToDraw++;
|
||||
|
||||
x += rideVehicleEntry->spacing / 17432;
|
||||
@@ -3102,7 +3098,7 @@ static void WindowRideVehicleScrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
||||
|
||||
VehicleDrawInfo* current = nextSpriteToDraw;
|
||||
while (--current >= _sprites_to_draw)
|
||||
gfx_draw_sprite(dpi, current->sprite_index, { current->x, current->y }, current->tertiary_colour);
|
||||
gfx_draw_sprite(dpi, current->imageId, { current->x, current->y });
|
||||
|
||||
startX += 36;
|
||||
}
|
||||
@@ -4886,24 +4882,21 @@ static void WindowRideColourPaint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
auto stationObj = ride_get_station_object(ride);
|
||||
if (stationObj != nullptr && stationObj->BaseImageId != 0)
|
||||
{
|
||||
int32_t terniaryColour = 0;
|
||||
if (stationObj->Flags & STATION_OBJECT_FLAGS::IS_TRANSPARENT)
|
||||
{
|
||||
terniaryColour = IMAGE_TYPE_TRANSPARENT | (EnumValue(GlassPaletteIds[trackColour.main]) << 19);
|
||||
}
|
||||
|
||||
int32_t spriteIndex = SPRITE_ID_PALETTE_COLOUR_2(trackColour.main, trackColour.additional);
|
||||
spriteIndex += stationObj->BaseImageId;
|
||||
auto imageTemplate = ImageId(trackColour.main, trackColour.additional);
|
||||
auto imageId = imageTemplate.WithIndex(stationObj->BaseImageId);
|
||||
|
||||
// Back
|
||||
gfx_draw_sprite(&clippedDpi, spriteIndex, { 34, 20 }, terniaryColour);
|
||||
gfx_draw_sprite(&clippedDpi, imageId, { 34, 20 });
|
||||
|
||||
// Front
|
||||
gfx_draw_sprite(&clippedDpi, spriteIndex + 4, { 34, 20 }, terniaryColour);
|
||||
gfx_draw_sprite(&clippedDpi, imageId.WithIndexOffset(4), { 34, 20 });
|
||||
|
||||
// Glass
|
||||
if (terniaryColour != 0)
|
||||
gfx_draw_sprite(&clippedDpi, ((spriteIndex + 20) & 0x7FFFF) + terniaryColour, { 34, 20 }, terniaryColour);
|
||||
if (stationObj->Flags & STATION_OBJECT_FLAGS::IS_TRANSPARENT)
|
||||
{
|
||||
auto glassImageId = ImageId(stationObj->BaseImageId + 20).WithTransparancy(trackColour.main);
|
||||
gfx_draw_sprite(&clippedDpi, glassImageId, { 34, 20 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4944,14 +4937,13 @@ static void WindowRideColourScrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
|
||||
screenCoords.y += rideVehicleEntry->tab_height;
|
||||
|
||||
// Draw the coloured spinning vehicle
|
||||
uint32_t spriteIndex = (rideVehicleEntry->flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES) ? w->frame_no / 4
|
||||
: w->frame_no / 2;
|
||||
spriteIndex &= rideVehicleEntry->rotation_frame_mask;
|
||||
spriteIndex *= rideVehicleEntry->base_num_frames;
|
||||
spriteIndex += rideVehicleEntry->base_image_id;
|
||||
spriteIndex |= (vehicleColour.Trim << 24) | (vehicleColour.Body << 19);
|
||||
spriteIndex |= IMAGE_TYPE_REMAP_2_PLUS;
|
||||
gfx_draw_sprite(dpi, ImageId::FromUInt32(spriteIndex, vehicleColour.Ternary), screenCoords);
|
||||
ImageIndex imageIndex = (rideVehicleEntry->flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES) ? w->frame_no / 4
|
||||
: w->frame_no / 2;
|
||||
imageIndex &= rideVehicleEntry->rotation_frame_mask;
|
||||
imageIndex *= rideVehicleEntry->base_num_frames;
|
||||
imageIndex += rideVehicleEntry->base_image_id;
|
||||
auto imageId = ImageId(imageIndex, vehicleColour.Body, vehicleColour.Trim, vehicleColour.Ternary);
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
Reference in New Issue
Block a user