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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user