Improve visibility of slopes under trees in viewport map vegetation mode
Loosely based on tree slope brightness adjustment from https://github.com/nielsmh/OpenTTD/tree/tree-slope-brightness
This commit is contained in:
@@ -461,17 +461,30 @@ void GfxDetermineMainColours()
|
||||
}
|
||||
|
||||
/* Trees. */
|
||||
extern uint32 _vp_map_vegetation_tree_colours[5][MAX_TREE_COUNT_BY_LANDSCAPE];
|
||||
extern uint32 _vp_map_vegetation_tree_colours[16][5][MAX_TREE_COUNT_BY_LANDSCAPE];
|
||||
const uint base = _tree_base_by_landscape[_settings_game.game_creation.landscape];
|
||||
const uint count = _tree_count_by_landscape[_settings_game.game_creation.landscape];
|
||||
for (uint tg = 0; tg < 5; tg++) {
|
||||
for (uint i = base; i < base + count; i++) {
|
||||
_vp_map_vegetation_tree_colours[tg][i - base] = GetSpriteMainColour(_tree_sprites[i].sprite, _tree_sprites[i].pal);
|
||||
_vp_map_vegetation_tree_colours[0][tg][i - base] = GetSpriteMainColour(_tree_sprites[i].sprite, _tree_sprites[i].pal);
|
||||
}
|
||||
const int diff = MAX_TREE_COUNT_BY_LANDSCAPE - count;
|
||||
if (diff > 0) {
|
||||
for (uint i = count; i < MAX_TREE_COUNT_BY_LANDSCAPE; i++)
|
||||
_vp_map_vegetation_tree_colours[tg][i] = _vp_map_vegetation_tree_colours[tg][i - count];
|
||||
_vp_map_vegetation_tree_colours[0][tg][i] = _vp_map_vegetation_tree_colours[0][tg][i - count];
|
||||
}
|
||||
}
|
||||
for (int s = 1; s <= SLOPE_ELEVATED; ++s) {
|
||||
extern int GetSlopeTreeBrightnessAdjust(Slope slope);
|
||||
int brightness_adjust = (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 32) ? GetSlopeTreeBrightnessAdjust((Slope)s) * 2 : 0;
|
||||
if (brightness_adjust != 0) {
|
||||
for (uint tg = 0; tg < 5; tg++) {
|
||||
for (uint i = 0; i < MAX_TREE_COUNT_BY_LANDSCAPE; i++) {
|
||||
_vp_map_vegetation_tree_colours[s][tg][i] = Blitter_32bppBase::AdjustBrightness(Colour(_vp_map_vegetation_tree_colours[0][tg][i]), Blitter_32bppBase::DEFAULT_BRIGHTNESS + brightness_adjust).data;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memcpy(&(_vp_map_vegetation_tree_colours[s]), &(_vp_map_vegetation_tree_colours[0]), sizeof(_vp_map_vegetation_tree_colours[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -108,6 +108,7 @@
|
||||
#include "video/video_driver.hpp"
|
||||
#include "scope_info.h"
|
||||
#include "scope.h"
|
||||
#include "blitter/32bpp_base.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -2552,7 +2553,7 @@ void ViewportDrawPlans(const Viewport *vp)
|
||||
|
||||
/* Variables containing Colour if 32bpp or palette index if 8bpp. */
|
||||
uint32 _vp_map_vegetation_clear_colours[16][6][8]; ///< [Slope][ClearGround][Multi (see LoadClearGroundMainColours())]
|
||||
uint32 _vp_map_vegetation_tree_colours[5][MAX_TREE_COUNT_BY_LANDSCAPE]; ///< [TreeGround][max of _tree_count_by_landscape]
|
||||
uint32 _vp_map_vegetation_tree_colours[16][5][MAX_TREE_COUNT_BY_LANDSCAPE]; ///< [Slope][TreeGround][max of _tree_count_by_landscape]
|
||||
uint32 _vp_map_water_colour[5]; ///< [Slope]
|
||||
|
||||
static inline uint ViewportMapGetColourIndexMulti(const TileIndex tile, const ClearGround cg)
|
||||
@@ -2603,10 +2604,10 @@ static inline uint32 ViewportMapGetColourVegetation(const TileIndex tile, TileTy
|
||||
case MP_TREES: {
|
||||
const TreeGround tg = GetTreeGround(tile);
|
||||
const uint td = GetTreeDensity(tile);
|
||||
Slope slope = show_slope ? (Slope) (GetTileSlope(tile, nullptr) & 15) : SLOPE_FLAT;
|
||||
if (IsTransparencySet(TO_TREES)) {
|
||||
ClearGround cg = _treeground_to_clearground[tg];
|
||||
if (cg == CLEAR_SNOW && _settings_game.game_creation.landscape == LT_TROPIC) cg = CLEAR_DESERT;
|
||||
Slope slope = show_slope ? (Slope) (GetTileSlope(tile, nullptr) & 15) : SLOPE_FLAT;
|
||||
uint32 ground_colour = _vp_map_vegetation_clear_colours[slope][cg][td];
|
||||
|
||||
if (IsInvisibilitySet(TO_TREES)) {
|
||||
@@ -2624,10 +2625,10 @@ static inline uint32 ViewportMapGetColourVegetation(const TileIndex tile, TileTy
|
||||
}
|
||||
} else {
|
||||
if (tg == TREE_GROUND_SNOW_DESERT || tg == TREE_GROUND_ROUGH_SNOW) {
|
||||
return _vp_map_vegetation_clear_colours[colour_index][_settings_game.game_creation.landscape == LT_TROPIC ? CLEAR_DESERT : CLEAR_SNOW][td];
|
||||
return _vp_map_vegetation_clear_colours[colour_index ^ slope][_settings_game.game_creation.landscape == LT_TROPIC ? CLEAR_DESERT : CLEAR_SNOW][td];
|
||||
} else {
|
||||
const uint rnd = std::min<uint>(GetTreeCount(tile) ^ (((tile & 3) ^ (TileY(tile) & 3)) * td), MAX_TREE_COUNT_BY_LANDSCAPE - 1);
|
||||
return _vp_map_vegetation_tree_colours[tg][rnd];
|
||||
return _vp_map_vegetation_tree_colours[slope][tg][rnd];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5939,3 +5940,34 @@ void SetViewportCatchmentTown(const Town *t, bool sel)
|
||||
}
|
||||
if (_viewport_highlight_town != nullptr) SetWindowDirty(WC_TOWN_VIEW, _viewport_highlight_town->index);
|
||||
}
|
||||
|
||||
int GetSlopeTreeBrightnessAdjust(Slope slope)
|
||||
{
|
||||
switch (slope) {
|
||||
case SLOPE_NW:
|
||||
case SLOPE_STEEP_N:
|
||||
case SLOPE_STEEP_W:
|
||||
return 8;
|
||||
case SLOPE_N:
|
||||
case SLOPE_W:
|
||||
case SLOPE_ENW:
|
||||
case SLOPE_NWS:
|
||||
return 4;
|
||||
case SLOPE_SE:
|
||||
return -10;
|
||||
case SLOPE_STEEP_S:
|
||||
case SLOPE_STEEP_E:
|
||||
return -4;
|
||||
case SLOPE_NE:
|
||||
return -8;
|
||||
case SLOPE_SW:
|
||||
return -4;
|
||||
case SLOPE_S:
|
||||
case SLOPE_E:
|
||||
case SLOPE_SEN:
|
||||
case SLOPE_WSE:
|
||||
return -6;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user