forked from rosebudai/OpenRCT2-Web
Create enum and flagholder for StationObjectFlags
This commit is contained in:
1 parent
8e40456478
commit
c7bee6257d
13 files changed
+45
-44
No files matched your search
@@ -4241,7 +4241,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
int32_t HasTrackColour(const Ride& ride, int32_t trackColour)
|
||||
{
|
||||
// Get station flags (shops don't have them)
|
||||
auto stationObjFlags = 0;
|
||||
StationObjectFlags stationObjFlags{};
|
||||
if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility))
|
||||
{
|
||||
auto stationObj = ride.getStationObject();
|
||||
@@ -4251,16 +4251,16 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
if (stationObjFlags == 0 && ride.getRideEntry()->flags.has(RideEntryFlag::disableColourTab))
|
||||
if (stationObjFlags.isEmpty() && ride.getRideEntry()->flags.has(RideEntryFlag::disableColourTab))
|
||||
return 0;
|
||||
|
||||
switch (trackColour)
|
||||
{
|
||||
case 0:
|
||||
return (stationObjFlags & StationObjectFlags::hasPrimaryColour)
|
||||
return stationObjFlags.has(StationObjectFlag::hasPrimaryColour)
|
||||
|| ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrackColourMain);
|
||||
case 1:
|
||||
return (stationObjFlags & StationObjectFlags::hasSecondaryColour)
|
||||
return stationObjFlags.has(StationObjectFlag::hasSecondaryColour)
|
||||
|| ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrackColourAdditional);
|
||||
case 2:
|
||||
return ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrackColourSupports);
|
||||
@@ -5233,7 +5233,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
GfxDrawSprite(rt, frontImageId, { 34, 20 });
|
||||
|
||||
// Glass
|
||||
if (stationObj->Flags & StationObjectFlags::isTransparent)
|
||||
if (stationObj->Flags.has(StationObjectFlag::isTransparent))
|
||||
{
|
||||
auto glassImageId = ImageId(stationObj->entranceFrontGlassIndex).WithTransparency(trackColour.main);
|
||||
GfxDrawSprite(rt, glassImageId, { 34, 20 });
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace OpenRCT2
|
||||
exitBackIndex = entranceBackIndex + 8;
|
||||
exitFrontIndex = entranceBackIndex + 12;
|
||||
|
||||
if (!(Flags & StationObjectFlags::isTransparent))
|
||||
if (!Flags.has(StationObjectFlag::isTransparent))
|
||||
{
|
||||
if (numImages > iconOffset + 16)
|
||||
shelterIndex = entranceBackIndex + 16;
|
||||
@@ -126,7 +126,7 @@ namespace OpenRCT2
|
||||
// Draw back sprite
|
||||
auto backImageId = ImageId(entranceBackIndex, colour0, colour1);
|
||||
GfxDrawSprite(rt, backImageId, screenCoords);
|
||||
if (Flags & StationObjectFlags::isTransparent)
|
||||
if (Flags.has(StationObjectFlag::isTransparent))
|
||||
{
|
||||
auto tImageId = ImageId(entranceBackGlassIndex).WithTransparency(tcolour0);
|
||||
GfxDrawSprite(rt, tImageId, screenCoords);
|
||||
@@ -135,7 +135,7 @@ namespace OpenRCT2
|
||||
// Draw front sprite
|
||||
auto frontImageId = ImageId(entranceFrontIndex, colour0, colour1);
|
||||
GfxDrawSprite(rt, frontImageId, screenCoords);
|
||||
if (Flags & StationObjectFlags::isTransparent)
|
||||
if (Flags.has(StationObjectFlag::isTransparent))
|
||||
{
|
||||
auto frontGlassImageId = ImageId(entranceFrontGlassIndex).WithTransparency(tcolour0);
|
||||
GfxDrawSprite(rt, frontGlassImageId, screenCoords);
|
||||
@@ -167,14 +167,14 @@ namespace OpenRCT2
|
||||
{
|
||||
Height = Json::GetNumber<int32_t>(properties["height"]);
|
||||
ScrollingMode = Json::GetNumber<uint8_t>(properties["scrollingMode"], kScrollingModeNone);
|
||||
Flags = Json::GetFlags<uint32_t>(
|
||||
Flags = Json::GetFlagHolder<StationObjectFlags, StationObjectFlag>(
|
||||
properties,
|
||||
{
|
||||
{ "hasPrimaryColour", StationObjectFlags::hasPrimaryColour },
|
||||
{ "hasSecondaryColour", StationObjectFlags::hasSecondaryColour },
|
||||
{ "isTransparent", StationObjectFlags::isTransparent },
|
||||
{ "noPlatforms", StationObjectFlags::noPlatforms },
|
||||
{ "hasShelter", StationObjectFlags::hasShelter },
|
||||
{ "hasPrimaryColour", StationObjectFlag::hasPrimaryColour },
|
||||
{ "hasSecondaryColour", StationObjectFlag::hasSecondaryColour },
|
||||
{ "isTransparent", StationObjectFlag::isTransparent },
|
||||
{ "noPlatforms", StationObjectFlag::noPlatforms },
|
||||
{ "hasShelter", StationObjectFlag::hasShelter },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,14 +13,15 @@
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
namespace StationObjectFlags
|
||||
enum class StationObjectFlag : uint8_t
|
||||
{
|
||||
const uint32_t hasPrimaryColour = 1 << 0;
|
||||
const uint32_t hasSecondaryColour = 1 << 1;
|
||||
const uint32_t isTransparent = 1 << 2;
|
||||
const uint32_t noPlatforms = 1 << 3;
|
||||
const uint32_t hasShelter = 1 << 4;
|
||||
} // namespace StationObjectFlags
|
||||
hasPrimaryColour,
|
||||
hasSecondaryColour,
|
||||
isTransparent,
|
||||
noPlatforms,
|
||||
hasShelter,
|
||||
};
|
||||
using StationObjectFlags = FlagHolder<uint32_t, StationObjectFlag>;
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -57,7 +58,7 @@ namespace OpenRCT2
|
||||
|
||||
ImageIndex iconIndex = kImageIndexUndefined;
|
||||
|
||||
uint32_t Flags{};
|
||||
StationObjectFlags Flags{};
|
||||
int32_t Height{};
|
||||
uint8_t ScrollingMode{};
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ static void PaintRideEntranceExit(PaintSession& session, uint8_t direction, int3
|
||||
|
||||
PaintRideEntranceExitLightEffects(session, height, entranceEl);
|
||||
|
||||
auto hasGlass = (stationObj->Flags & StationObjectFlags::isTransparent) != 0;
|
||||
auto hasGlass = stationObj->Flags.has(StationObjectFlag::isTransparent);
|
||||
auto colourPrimary = ride->trackColours[0].main;
|
||||
auto imageTemplate = ImageId(0);
|
||||
ImageId glassImageTemplate;
|
||||
@@ -141,11 +141,11 @@ static void PaintRideEntranceExit(PaintSession& session, uint8_t direction, int3
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stationObj->Flags & StationObjectFlags::hasPrimaryColour)
|
||||
if (stationObj->Flags.has(StationObjectFlag::hasPrimaryColour))
|
||||
{
|
||||
imageTemplate = imageTemplate.WithPrimary(colourPrimary);
|
||||
}
|
||||
if (stationObj->Flags & StationObjectFlags::hasSecondaryColour)
|
||||
if (stationObj->Flags.has(StationObjectFlag::hasSecondaryColour))
|
||||
{
|
||||
auto colourSecondary = ride->trackColours[0].additional;
|
||||
imageTemplate = imageTemplate.WithSecondary(colourSecondary);
|
||||
|
||||
@@ -125,7 +125,7 @@ static void MultiDimensionRCTrackStation(
|
||||
const TrackElement& trackElement, SupportType supportType)
|
||||
{
|
||||
const auto* const stationObj = ride.getStationObject();
|
||||
const bool noPlatforms = stationObj != nullptr && stationObj->Flags & StationObjectFlags::noPlatforms;
|
||||
const bool noPlatforms = stationObj != nullptr && stationObj->Flags.has(StationObjectFlag::noPlatforms);
|
||||
|
||||
static constexpr uint32_t imageIds[2][kNumOrthogonalDirections][3] = {
|
||||
{
|
||||
@@ -157,7 +157,7 @@ static void MultiDimensionRCTrackStation(
|
||||
{ { 0, 3, height + 3 }, { 32, 26, 1 } });
|
||||
}
|
||||
|
||||
if (stationObj != nullptr && !(stationObj->Flags & StationObjectFlags::noPlatforms))
|
||||
if (stationObj != nullptr && !stationObj->Flags.has(StationObjectFlag::noPlatforms))
|
||||
{
|
||||
DrawSupportsSideBySide(session, direction, height, session.SupportColours, supportType.metal);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ static void PaintDodgems(
|
||||
|
||||
const StationObject* stationObject = ride.getStationObject();
|
||||
|
||||
if (stationObject != nullptr && !(stationObject->Flags & StationObjectFlags::noPlatforms))
|
||||
if (stationObject != nullptr && !stationObject->Flags.has(StationObjectFlag::noPlatforms))
|
||||
{
|
||||
auto imageId = session.SupportColours.WithIndex(SprDodgemsFloor);
|
||||
PaintAddImageAsParent(session, imageId, { 0, 0, height }, { { 1, 1, height }, { 30, 30, 1 } });
|
||||
|
||||
@@ -50,7 +50,7 @@ static void PaintFlyingSaucers(
|
||||
|
||||
const StationObject* stationObject = ride.getStationObject();
|
||||
|
||||
if (stationObject != nullptr && !(stationObject->Flags & StationObjectFlags::noPlatforms))
|
||||
if (stationObject != nullptr && !stationObject->Flags.has(StationObjectFlag::noPlatforms))
|
||||
{
|
||||
auto imageId = session.TrackColours.WithIndex(SprFlyingSaucersFloor);
|
||||
PaintAddImageAsParent(session, imageId, { 0, 0, height }, { { 1, 1, height }, { 30, 30, 1 } });
|
||||
|
||||
@@ -213,7 +213,7 @@ static void PaintSpiralSlide(
|
||||
// Base
|
||||
const StationObject* stationObject = ride.getStationObject();
|
||||
|
||||
if (stationObject != nullptr && !(stationObject->Flags & StationObjectFlags::noPlatforms))
|
||||
if (stationObject != nullptr && !stationObject->Flags.has(StationObjectFlag::noPlatforms))
|
||||
{
|
||||
auto imageId = session.SupportColours.WithIndex(
|
||||
rideEntry->Cars[0].baseImageId + ((direction & 1) ? SpiralSlideBaseB : SpiralSlideBaseA));
|
||||
|
||||
@@ -225,7 +225,7 @@ static void PaintMagicCarpet(
|
||||
DrawSupportsSideBySide(session, direction, height, session.SupportColours, MetalSupportType::tubes);
|
||||
const StationObject* stationObject = ride.getStationObject();
|
||||
|
||||
if (stationObject != nullptr && !(stationObject->Flags & StationObjectFlags::noPlatforms))
|
||||
if (stationObject != nullptr && !stationObject->Flags.has(StationObjectFlag::noPlatforms))
|
||||
{
|
||||
auto imageId = session.SupportColours.WithIndex(SPR_STATION_BASE_BORDERLESS);
|
||||
PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 32, 1 });
|
||||
|
||||
@@ -136,7 +136,7 @@ static void PaintSwingingInverterShip(
|
||||
{
|
||||
DrawSupportsSideBySide(session, direction, height, session.SupportColours, MetalSupportType::tubes);
|
||||
|
||||
if (stationObject != nullptr && !(stationObject->Flags & StationObjectFlags::noPlatforms))
|
||||
if (stationObject != nullptr && !stationObject->Flags.has(StationObjectFlag::noPlatforms))
|
||||
{
|
||||
ImageId imageId = session.SupportColours.WithIndex(SPR_STATION_BASE_BORDERLESS);
|
||||
PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 32, 1 });
|
||||
|
||||
@@ -171,7 +171,7 @@ static void PaintSwingingShip(
|
||||
else
|
||||
{
|
||||
DrawSupportsSideBySide(session, direction, height, session.SupportColours, MetalSupportType::tubes);
|
||||
if (stationObject != nullptr && !(stationObject->Flags & StationObjectFlags::noPlatforms))
|
||||
if (stationObject != nullptr && !stationObject->Flags.has(StationObjectFlag::noPlatforms))
|
||||
{
|
||||
ImageIndex base = (direction & 1) ? SPR_STATION_BASE_TALL_NW_SE : SPR_STATION_BASE_TALL_SW_NE;
|
||||
imageId = session.SupportColours.WithIndex(base);
|
||||
@@ -181,7 +181,7 @@ static void PaintSwingingShip(
|
||||
|
||||
PaintUtilSetSegmentSupportHeight(session, kSegmentsAll, 0xFFFF, 0);
|
||||
|
||||
if (stationObject != nullptr && !(stationObject->Flags & StationObjectFlags::noPlatforms))
|
||||
if (stationObject != nullptr && !stationObject->Flags.has(StationObjectFlag::noPlatforms))
|
||||
{
|
||||
if (direction & 1)
|
||||
{
|
||||
|
||||
@@ -5213,7 +5213,7 @@ namespace OpenRCT2
|
||||
bool RideHasStationShelter(const Ride& ride)
|
||||
{
|
||||
const auto* stationObj = ride.getStationObject();
|
||||
return stationObj != nullptr && (stationObj->Flags & StationObjectFlags::hasShelter);
|
||||
return stationObj != nullptr && stationObj->Flags.has(StationObjectFlag::hasShelter);
|
||||
}
|
||||
|
||||
bool RideHasRatings(const Ride& ride)
|
||||
|
||||
@@ -86,7 +86,7 @@ bool TrackPaintUtilHasFence(
|
||||
enum edge_t edge, const CoordsXY& position, const TrackElement& trackElement, const Ride& ride, uint8_t rotation)
|
||||
{
|
||||
const auto* stationObject = ride.getStationObject();
|
||||
if (stationObject != nullptr && stationObject->Flags & StationObjectFlags::noPlatforms)
|
||||
if (stationObject != nullptr && stationObject->Flags.has(StationObjectFlag::noPlatforms))
|
||||
return false;
|
||||
|
||||
TileCoordsXY offset;
|
||||
@@ -117,7 +117,7 @@ void TrackPaintUtilPaintFloor(
|
||||
PaintSession& session, uint8_t edges, ImageId colourFlags, uint16_t height, const uint32_t floorSprites[4],
|
||||
const StationObject* stationStyle)
|
||||
{
|
||||
if (stationStyle != nullptr && stationStyle->Flags & StationObjectFlags::noPlatforms)
|
||||
if (stationStyle != nullptr && stationStyle->Flags.has(StationObjectFlag::noPlatforms))
|
||||
return;
|
||||
|
||||
uint32_t imageId;
|
||||
@@ -217,7 +217,7 @@ static bool TrackPaintUtilDrawStationImpl(
|
||||
const auto* stationObj = ride.getStationObject();
|
||||
const bool hasGreenLight = trackElement.hasGreenLight();
|
||||
|
||||
if (stationObj != nullptr && stationObj->Flags & StationObjectFlags::noPlatforms)
|
||||
if (stationObj != nullptr && stationObj->Flags.has(StationObjectFlag::noPlatforms))
|
||||
return false;
|
||||
|
||||
bool hasFence;
|
||||
@@ -431,7 +431,7 @@ bool TrackPaintUtilDrawStationInverted(
|
||||
const auto* stationObj = ride.getStationObject();
|
||||
const bool hasGreenLight = trackElement.hasGreenLight();
|
||||
|
||||
if (stationObj != nullptr && stationObj->Flags & StationObjectFlags::noPlatforms)
|
||||
if (stationObj != nullptr && stationObj->Flags.has(StationObjectFlag::noPlatforms))
|
||||
return false;
|
||||
|
||||
auto colour = GetStationColourScheme(session, trackElement);
|
||||
@@ -698,16 +698,16 @@ bool TrackPaintUtilDrawStationCovers2(
|
||||
if (!session.TrackColours.IsRemap())
|
||||
{
|
||||
imageId = ImageId(shelterImageIndex + imageOffset);
|
||||
if (stationObject->Flags & StationObjectFlags::hasPrimaryColour)
|
||||
if (stationObject->Flags.has(StationObjectFlag::hasPrimaryColour))
|
||||
imageId = imageId.WithPrimary(session.TrackColours.GetPrimary());
|
||||
if (stationObject->Flags & StationObjectFlags::hasSecondaryColour)
|
||||
if (stationObject->Flags.has(StationObjectFlag::hasSecondaryColour))
|
||||
imageId = imageId.WithSecondary(session.TrackColours.GetSecondary());
|
||||
}
|
||||
|
||||
PaintAddImageAsParent(session, imageId, offset, boundBox);
|
||||
|
||||
// Glass
|
||||
if (colour == TrackStationColour && (stationObject->Flags & StationObjectFlags::isTransparent))
|
||||
if (colour == TrackStationColour && stationObject->Flags.has(StationObjectFlag::isTransparent))
|
||||
{
|
||||
auto shelterGlassImageIndex = stationObject->shelterGlassIndex;
|
||||
imageId = ImageId(shelterGlassImageIndex + imageOffset).WithTransparency(session.TrackColours.GetPrimary());
|
||||
@@ -722,7 +722,7 @@ bool TrackPaintUtilDrawNarrowStationPlatform(
|
||||
{
|
||||
CoordsXY position = session.MapPosition;
|
||||
const auto* stationObj = ride.getStationObject();
|
||||
if (stationObj != nullptr && stationObj->Flags & StationObjectFlags::noPlatforms)
|
||||
if (stationObj != nullptr && stationObj->Flags.has(StationObjectFlag::noPlatforms))
|
||||
return false;
|
||||
|
||||
auto colour = GetStationColourScheme(session, trackElement);
|
||||
@@ -779,7 +779,7 @@ void TrackPaintUtilDrawPier(
|
||||
PaintSession& session, const Ride& ride, const StationObject* stationObj, const CoordsXY& position, Direction direction,
|
||||
int32_t height, const TrackElement& trackElement, uint8_t rotation)
|
||||
{
|
||||
if (stationObj != nullptr && stationObj->Flags & StationObjectFlags::noPlatforms)
|
||||
if (stationObj != nullptr && stationObj->Flags.has(StationObjectFlag::noPlatforms))
|
||||
return;
|
||||
auto colour = GetStationColourScheme(session, trackElement);
|
||||
bool hasFence;
|
||||
|
||||
Reference in new issue
Block a user