1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-21 05:53:02 +01:00

Hide trees using colourify function

This commit is contained in:
Ted John
2022-03-04 01:48:01 +00:00
parent 8aafab2a70
commit 9794be6a09
2 changed files with 28 additions and 9 deletions

View File

@@ -19,6 +19,7 @@
#include "../paint/Painter.h"
#include "../profiling/Profiling.h"
#include "../util/Math.hpp"
#include "../world/SmallScenery.h"
#include "Paint.Entity.h"
#include "tile_element/Paint.TileElement.h"
@@ -664,6 +665,20 @@ static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId image
gfx_draw_sprite(dpi, imageId, { x, y });
}
static bool IsTileElementTree(const TileElement* tileElement)
{
auto sceneryItem = tileElement->AsSmallScenery();
if (sceneryItem != nullptr)
{
auto sceneryEntry = sceneryItem->GetEntry();
if (sceneryEntry != nullptr && sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE))
{
return true;
}
}
return false;
}
static ImageId PaintPSColourifyImage(
ImageId imageId, ViewportInteractionItem spriteType, uint32_t viewFlags, const TileElement* tileElement,
const EntityBase* entity)
@@ -707,6 +722,11 @@ static ImageId PaintPSColourifyImage(
switch (spriteType)
{
case ViewportInteractionItem::Scenery:
if (!IsTileElementTree(tileElement))
{
return (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY) ? ImageId() : seeThrough;
}
break;
case ViewportInteractionItem::LargeScenery:
case ViewportInteractionItem::Wall:
return (viewFlags & VIEWPORT_FLAG_INVISIBLE_SCENERY) ? ImageId() : seeThrough;
@@ -714,6 +734,13 @@ static ImageId PaintPSColourifyImage(
break;
}
}
if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_TREES)
{
if (spriteType == ViewportInteractionItem::Scenery && IsTileElementTree(tileElement))
{
return (viewFlags & VIEWPORT_FLAG_INVISIBLE_TREES) ? ImageId() : seeThrough;
}
}
return imageId;
}

View File

@@ -340,16 +340,8 @@ void PaintSmallScenery(paint_session& session, uint8_t direction, int32_t height
{
imageTemplate = ImageId().WithRemap(FilterPaletteID::Palette44);
}
else if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE) && (session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_TREES))
{
imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1);
}
if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE) || !((session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_TREES) && (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_TREES)))
{
PaintSmallSceneryBody(session, direction, height, sceneryElement, sceneryEntry, imageTemplate);
}
PaintSmallSceneryBody(session, direction, height, sceneryElement, sceneryEntry, imageTemplate);
PaintSmallScenerySupports(session, *sceneryEntry, sceneryElement, direction, height, imageTemplate);
SetSupportHeights(session, *sceneryEntry, sceneryElement, height);
}