mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Refactor remaining object preview to ImageId
This commit is contained in:
@@ -51,31 +51,29 @@ void StationObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t h
|
||||
|
||||
auto colour0 = COLOUR_LIGHT_BLUE;
|
||||
auto colour1 = COLOUR_BORDEAUX_RED;
|
||||
auto tcolour0 = EnumValue(GlassPaletteIds[colour0]);
|
||||
auto tcolour0 = colour0;
|
||||
|
||||
uint32_t imageId = BaseImageId;
|
||||
uint32_t tImageId = BaseImageId + 16;
|
||||
auto imageId = ImageId(BaseImageId);
|
||||
auto tImageId = ImageId(BaseImageId + 16).WithTransparancy(tcolour0);
|
||||
if (Flags & STATION_OBJECT_FLAGS::HAS_PRIMARY_COLOUR)
|
||||
{
|
||||
imageId |= (colour0 << 19) | IMAGE_TYPE_REMAP;
|
||||
tImageId |= (EnumValue(GlassPaletteIds[tcolour0]) << 19) | IMAGE_TYPE_TRANSPARENT;
|
||||
imageId = imageId.WithPrimary(colour0);
|
||||
}
|
||||
if (Flags & STATION_OBJECT_FLAGS::HAS_SECONDARY_COLOUR)
|
||||
{
|
||||
imageId |= (colour1 << 24) | IMAGE_TYPE_REMAP_2_PLUS;
|
||||
tImageId |= (colour1 << 24) | IMAGE_TYPE_REMAP_2_PLUS;
|
||||
imageId = imageId.WithSecondary(colour1);
|
||||
}
|
||||
|
||||
gfx_draw_sprite(dpi, imageId + 0, screenCoords, 0);
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords);
|
||||
if (Flags & STATION_OBJECT_FLAGS::IS_TRANSPARENT)
|
||||
{
|
||||
gfx_draw_sprite(dpi, tImageId, screenCoords, 0);
|
||||
gfx_draw_sprite(dpi, tImageId, screenCoords);
|
||||
}
|
||||
|
||||
gfx_draw_sprite(dpi, imageId + 4, screenCoords, 0);
|
||||
gfx_draw_sprite(dpi, imageId.WithIndexOffset(4), screenCoords);
|
||||
if (Flags & STATION_OBJECT_FLAGS::IS_TRANSPARENT)
|
||||
{
|
||||
gfx_draw_sprite(dpi, tImageId + 4, screenCoords, 0);
|
||||
gfx_draw_sprite(dpi, tImageId.WithIndexOffset(4), screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ void TerrainEdgeObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32
|
||||
{
|
||||
auto screenCoords = ScreenCoordsXY{ width / 2, height / 2 };
|
||||
|
||||
uint32_t imageId = BaseImageId;
|
||||
gfx_draw_sprite(dpi, imageId + 5, screenCoords + ScreenCoordsXY{ 8, -8 }, 0);
|
||||
gfx_draw_sprite(dpi, imageId + 5, screenCoords + ScreenCoordsXY{ 8, 8 }, 0);
|
||||
auto imageId = ImageId(BaseImageId + 5);
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords + ScreenCoordsXY{ 8, -8 });
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords + ScreenCoordsXY{ 8, 8 });
|
||||
}
|
||||
|
||||
void TerrainEdgeObject::ReadJson(IReadObjectContext* context, json_t& root)
|
||||
|
||||
@@ -52,10 +52,10 @@ void TerrainSurfaceObject::Unload()
|
||||
|
||||
void TerrainSurfaceObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const
|
||||
{
|
||||
uint32_t imageId = GetImageId({}, 1, 0, 0, false, false);
|
||||
auto imageId = ImageId(GetImageId({}, 1, 0, 0, false, false));
|
||||
if (Colour != 255)
|
||||
{
|
||||
imageId |= SPRITE_ID_PALETTE_COLOUR_1(Colour);
|
||||
imageId = imageId.WithPrimary(Colour);
|
||||
}
|
||||
|
||||
ScreenCoordsXY screenCoords{};
|
||||
@@ -70,7 +70,7 @@ void TerrainSurfaceObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, in
|
||||
}
|
||||
for (int32_t j = 0; j < 4; j++)
|
||||
{
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords, 0);
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords);
|
||||
screenCoords.x += 64;
|
||||
}
|
||||
screenCoords.y += 16;
|
||||
|
||||
@@ -75,23 +75,22 @@ void WallObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t heig
|
||||
screenCoords.x += 14;
|
||||
screenCoords.y += (_legacyType.height * 2) + 16;
|
||||
|
||||
uint32_t imageId = 0x20D00000 | _legacyType.image;
|
||||
auto imageId = ImageId(_legacyType.image, COLOUR_BORDEAUX_RED);
|
||||
if (_legacyType.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR)
|
||||
{
|
||||
imageId |= 0x92000000;
|
||||
imageId = imageId.WithSecondary(COLOUR_YELLOW);
|
||||
}
|
||||
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords, 0);
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords);
|
||||
|
||||
if (_legacyType.flags & WALL_SCENERY_HAS_GLASS)
|
||||
{
|
||||
imageId = _legacyType.image + 0x44500006;
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords, 0);
|
||||
auto glassImageId = imageId.WithTransparancy(COLOUR_BORDEAUX_RED).WithIndexOffset(6);
|
||||
gfx_draw_sprite(dpi, glassImageId, screenCoords);
|
||||
}
|
||||
else if (_legacyType.flags & WALL_SCENERY_IS_DOOR)
|
||||
{
|
||||
imageId++;
|
||||
gfx_draw_sprite(dpi, imageId, screenCoords, 0);
|
||||
gfx_draw_sprite(dpi, imageId.WithIndexOffset(1), screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user