1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

Add option to see-through vehicles

This commit is contained in:
Kane
2021-08-02 00:12:57 +10:00
committed by Ted John
parent 99db07cfe0
commit 9f78c6f0ce
6 changed files with 46 additions and 14 deletions

View File

@@ -3659,6 +3659,7 @@ STR_6467 :Nausea: {COMMA2DP32}
STR_6468 :Not Yet Known
STR_6469 :Adjust smaller area of patrol area
STR_6470 :Adjust larger area of patrol area
STR_6471 :See-Through Vehicles
#############
# Scenarios #

View File

@@ -137,17 +137,18 @@ enum TopToolbarViewMenuDdidx
DDIDX_HIDE_VERTICAL = 3,
// separator
DDIDX_SEETHROUGH_RIDES = 5,
DDIDX_SEETHROUGH_SCENERY = 6,
DDIDX_SEETHROUGH_PATHS = 7,
DDIDX_INVISIBLE_SUPPORTS = 8,
DDIDX_INVISIBLE_PEEPS = 9,
DDIDX_SEETHROUGH_VEHICLES = 6,
DDIDX_SEETHROUGH_SCENERY = 7,
DDIDX_SEETHROUGH_PATHS = 8,
DDIDX_INVISIBLE_SUPPORTS = 9,
DDIDX_INVISIBLE_PEEPS = 10,
// separator
DDIDX_LAND_HEIGHTS = 11,
DDIDX_TRACK_HEIGHTS = 12,
DDIDX_PATH_HEIGHTS = 13,
DDIDX_LAND_HEIGHTS = 12,
DDIDX_TRACK_HEIGHTS = 13,
DDIDX_PATH_HEIGHTS = 14,
// separator
DDIDX_VIEW_CLIPPING = 15,
DDIDX_HIGHLIGHT_PATH_ISSUES = 16,
DDIDX_VIEW_CLIPPING = 16,
DDIDX_HIGHLIGHT_PATH_ISSUES = 17,
TOP_TOOLBAR_VIEW_MENU_COUNT,
};
@@ -3624,6 +3625,7 @@ static void TopToolbarInitViewMenu(rct_window* w, rct_widget* widget)
ToggleOption(DDIDX_HIDE_VERTICAL, STR_REMOVE_VERTICAL_FACES),
Separator(),
ToggleOption(DDIDX_SEETHROUGH_RIDES, STR_SEE_THROUGH_RIDES),
ToggleOption(DDIDX_SEETHROUGH_VEHICLES, STR_SEE_THROUGH_VEHICLES),
ToggleOption(DDIDX_SEETHROUGH_SCENERY, STR_SEE_THROUGH_SCENERY),
ToggleOption(DDIDX_SEETHROUGH_PATHS, STR_SEE_THROUGH_PATHS),
ToggleOption(DDIDX_INVISIBLE_SUPPORTS, STR_INVISIBLE_SUPPORTS),
@@ -3657,6 +3659,8 @@ static void TopToolbarInitViewMenu(rct_window* w, rct_widget* widget)
Dropdown::SetChecked(DDIDX_HIDE_VERTICAL, true);
if (mainViewport->flags & VIEWPORT_FLAG_SEETHROUGH_RIDES)
Dropdown::SetChecked(DDIDX_SEETHROUGH_RIDES, true);
if (mainViewport->flags & VIEWPORT_FLAG_SEETHROUGH_VEHICLES)
Dropdown::SetChecked(DDIDX_SEETHROUGH_VEHICLES, true);
if (mainViewport->flags & VIEWPORT_FLAG_SEETHROUGH_SCENERY)
Dropdown::SetChecked(DDIDX_SEETHROUGH_SCENERY, true);
if (mainViewport->flags & VIEWPORT_FLAG_SEETHROUGH_PATHS)
@@ -3712,6 +3716,9 @@ static void TopToolbarViewMenuDropdown(int16_t dropdownIndex)
case DDIDX_SEETHROUGH_RIDES:
w->viewport->flags ^= VIEWPORT_FLAG_SEETHROUGH_RIDES;
break;
case DDIDX_SEETHROUGH_VEHICLES:
w->viewport->flags ^= VIEWPORT_FLAG_SEETHROUGH_VEHICLES;
break;
case DDIDX_SEETHROUGH_SCENERY:
w->viewport->flags ^= VIEWPORT_FLAG_SEETHROUGH_SCENERY;
break;

View File

@@ -1319,7 +1319,8 @@ void viewport_set_visibility(uint8_t mode)
uint32_t mask = VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_SEETHROUGH_RIDES
| VIEWPORT_FLAG_SEETHROUGH_SCENERY | VIEWPORT_FLAG_SEETHROUGH_PATHS | VIEWPORT_FLAG_INVISIBLE_SUPPORTS
| VIEWPORT_FLAG_LAND_HEIGHTS | VIEWPORT_FLAG_TRACK_HEIGHTS | VIEWPORT_FLAG_PATH_HEIGHTS
| VIEWPORT_FLAG_INVISIBLE_PEEPS | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL;
| VIEWPORT_FLAG_INVISIBLE_PEEPS | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL
| VIEWPORT_FLAG_SEETHROUGH_VEHICLES;
invalidate += vp->flags & mask;
vp->flags &= ~mask;

View File

@@ -49,6 +49,7 @@ enum
VIEWPORT_FLAG_CLIP_VIEW = (1 << 17),
VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES = (1 << 18),
VIEWPORT_FLAG_TRANSPARENT_BACKGROUND = (1 << 19),
VIEWPORT_FLAG_SEETHROUGH_VEHICLES = (1 << 20),
};
enum class ViewportInteractionItem : uint8_t

View File

@@ -3928,6 +3928,8 @@ enum : uint16_t
STR_ADJUST_SMALLER_PATROL_AREA_TIP = 6469,
STR_ADJUST_LARGER_PATROL_AREA_TIP = 6470,
STR_SEE_THROUGH_VEHICLES = 6471,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
/* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings
};

View File

@@ -56,7 +56,7 @@ bool gPaintBlockedTiles;
static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t viewFlags);
static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y);
static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y);
static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem spriteType, uint32_t viewFlags);
static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem spriteType, EntityType entityType, uint32_t viewFlags);
static int32_t RemapPositionToQuadrant(const paint_struct& ps, uint8_t rotation)
{
@@ -482,6 +482,17 @@ void PaintSessionArrange(PaintSessionCore& session)
Guard::Assert(false);
}
static EntityType GetEntityTypeFromPaintSession(const paint_struct* ps)
{
auto entityType = EntityType::Null;
auto* entity = reinterpret_cast<const EntityBase*>(ps->tileElement);
if (entity != nullptr)
{
entityType = entity->Type;
}
return entityType;
}
static void PaintDrawStruct(paint_session& session, paint_struct* ps)
{
rct_drawpixelinfo* dpi = &session.DPI;
@@ -503,7 +514,8 @@ static void PaintDrawStruct(paint_session& session, paint_struct* ps)
}
}
auto imageId = PaintPSColourifyImage(ps->image_id, ps->sprite_type, session.ViewFlags);
auto entityType = GetEntityTypeFromPaintSession(ps);
auto imageId = PaintPSColourifyImage(ps->image_id, ps->sprite_type, entityType, session.ViewFlags);
if (gPaintBoundingBoxes && dpi->zoom_level == ZoomLevel{ 0 })
{
PaintPSImageWithBoundingBoxes(dpi, ps, imageId, x, y);
@@ -553,7 +565,8 @@ static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t v
{
auto screenCoords = ScreenCoordsXY{ attached_ps->x + ps->x, attached_ps->y + ps->y };
auto imageId = PaintPSColourifyImage(attached_ps->image_id, ps->sprite_type, viewFlags);
auto entityType = GetEntityTypeFromPaintSession(ps);
auto imageId = PaintPSColourifyImage(attached_ps->image_id, ps->sprite_type, entityType, viewFlags);
if (attached_ps->flags & PAINT_STRUCT_FLAG_IS_MASKED)
{
gfx_draw_sprite_raw_masked(dpi, screenCoords, imageId, attached_ps->colour_image_id);
@@ -661,7 +674,7 @@ static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId image
gfx_draw_sprite(dpi, imageId, { x, y });
}
static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem spriteType, uint32_t viewFlags)
static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem spriteType, EntityType entityType, uint32_t viewFlags)
{
auto seeThrough = imageId.WithTransparancy(FilterPaletteID::PaletteDarken1);
if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_RIDES)
@@ -671,6 +684,13 @@ static ImageId PaintPSColourifyImage(ImageId imageId, ViewportInteractionItem sp
return seeThrough;
}
}
if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_VEHICLES)
{
if (spriteType == ViewportInteractionItem::Entity && entityType == EntityType::Vehicle)
{
return seeThrough;
}
}
if (viewFlags & VIEWPORT_FLAG_UNDERGROUND_INSIDE)
{
if (spriteType == ViewportInteractionItem::Wall)