Add GUI setting for shading trees on slopes in viewports

Deafult on, only for non-map mode
(Slope shading is always on in map mode)
This commit is contained in:
Jonathan G Rennison
2021-02-26 18:03:00 +00:00
parent 4ef363422a
commit 93f2d5e056
5 changed files with 25 additions and 1 deletions

View File

@@ -637,9 +637,19 @@ static void DrawTile_Trees(TileInfo *ti, DrawTileProcParams params)
/* put the trees to draw in a list */
uint trees = GetTreeCount(ti->tile);
PaletteID palette_adjust = 0;
if (_settings_client.gui.shade_trees_on_slopes && ti->tileh != SLOPE_FLAT) {
extern int GetSlopeTreeBrightnessAdjust(Slope slope);
int adjust = GetSlopeTreeBrightnessAdjust(ti->tileh);
if (adjust != 0) {
SetBit(palette_adjust, PALETTE_BRIGHTNESS_MODIFY);
SB(palette_adjust, PALETTE_BRIGHTNESS_OFFSET, PALETTE_BRIGHTNESS_WIDTH, adjust & ((1 << PALETTE_BRIGHTNESS_WIDTH) - 1));
}
}
for (uint i = 0; i < trees; i++) {
SpriteID sprite = s[0].sprite + (i == trees - 1 ? GetTreeGrowth(ti->tile) : 3);
PaletteID pal = s[0].pal;
PaletteID pal = s[0].pal | palette_adjust;
te[i].sprite = sprite;
te[i].pal = pal;