mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Refactor station covers to use ImageId
This commit is contained in:
@@ -41,8 +41,8 @@ void StationObject::Unload()
|
||||
gfx_object_free_images(BaseImageId, GetImageTable().GetCount());
|
||||
|
||||
NameStringId = 0;
|
||||
BaseImageId = 0;
|
||||
ShelterImageId = 0;
|
||||
BaseImageId = ImageIndexUndefined;
|
||||
ShelterImageId = ImageIndexUndefined;
|
||||
}
|
||||
|
||||
void StationObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../drawing/ImageId.hpp"
|
||||
#include "Object.h"
|
||||
|
||||
namespace STATION_OBJECT_FLAGS
|
||||
@@ -24,8 +25,8 @@ class StationObject final : public Object
|
||||
{
|
||||
public:
|
||||
rct_string_id NameStringId{};
|
||||
uint32_t BaseImageId{};
|
||||
uint32_t ShelterImageId{};
|
||||
ImageIndex BaseImageId = ImageIndexUndefined;
|
||||
ImageIndex ShelterImageId = ImageIndexUndefined;
|
||||
uint32_t Flags{};
|
||||
int32_t Height{};
|
||||
uint8_t ScrollingMode{};
|
||||
|
||||
@@ -796,23 +796,16 @@ bool track_paint_util_draw_station_covers_2(
|
||||
return false;
|
||||
}
|
||||
|
||||
auto baseImageIndex = stationObject->ShelterImageId;
|
||||
if (baseImageIndex == ImageIndexUndefined)
|
||||
return false;
|
||||
|
||||
static constexpr const int16_t heights[][2] = {
|
||||
{ 22, 0 },
|
||||
{ 30, 0 },
|
||||
{ 46, 0 },
|
||||
};
|
||||
|
||||
uint32_t imageId;
|
||||
uint32_t baseImageId = stationObject->ShelterImageId;
|
||||
if (stationObject->Flags & STATION_OBJECT_FLAGS::HAS_SECONDARY_COLOUR)
|
||||
{
|
||||
baseImageId |= IMAGE_TYPE_REMAP_2_PLUS;
|
||||
}
|
||||
if (stationObject->Flags & STATION_OBJECT_FLAGS::IS_TRANSPARENT)
|
||||
{
|
||||
baseImageId |= IMAGE_TYPE_TRANSPARENT;
|
||||
}
|
||||
|
||||
int32_t imageOffset = 0;
|
||||
CoordsXYZ bounds, boundsOffset;
|
||||
CoordsXYZ offset = CoordsXYZ(0, 0, height);
|
||||
@@ -840,38 +833,21 @@ bool track_paint_util_draw_station_covers_2(
|
||||
break;
|
||||
}
|
||||
|
||||
if (session->TrackColours[SCHEME_MISC] != IMAGE_TYPE_REMAP)
|
||||
{
|
||||
baseImageId &= 0x7FFFF;
|
||||
}
|
||||
|
||||
if (baseImageId <= 0x20)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stationVariant == STATION_VARIANT_TALL)
|
||||
{
|
||||
imageOffset += SPR_STATION_COVER_OFFSET_TALL;
|
||||
}
|
||||
|
||||
if (baseImageId & IMAGE_TYPE_TRANSPARENT)
|
||||
{
|
||||
imageId = (baseImageId & ~IMAGE_TYPE_TRANSPARENT) + imageOffset;
|
||||
PaintAddImageAsParent(session, imageId, offset, bounds, boundsOffset);
|
||||
|
||||
uint32_t edi = session->TrackColours[SCHEME_TRACK] & (0b11111 << 19);
|
||||
|
||||
// weird jump
|
||||
imageId = (baseImageId | edi) + ((1 << 23) | (1 << 24) | (1 << 25)) + imageOffset + 12;
|
||||
PaintAddImageAsChild(
|
||||
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), bounds.x, bounds.y,
|
||||
static_cast<int8_t>(bounds.z), offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z);
|
||||
return true;
|
||||
}
|
||||
|
||||
imageId = (baseImageId + imageOffset) | session->TrackColours[SCHEME_TRACK];
|
||||
auto imageTemplate = ImageId::FromUInt32(session->TrackColours[SCHEME_TRACK]);
|
||||
auto imageId = imageTemplate.WithIndex(baseImageIndex + imageOffset);
|
||||
PaintAddImageAsParent(session, imageId, offset, bounds, boundsOffset);
|
||||
|
||||
// Glass
|
||||
if (session->TrackColours[SCHEME_MISC] == IMAGE_TYPE_REMAP && (stationObject->Flags & STATION_OBJECT_FLAGS::IS_TRANSPARENT))
|
||||
{
|
||||
imageId = ImageId(baseImageIndex + imageOffset + 12).WithTransparancy(imageTemplate.GetPrimary());
|
||||
PaintAddImageAsChild(session, imageId, offset, bounds, boundsOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user