Implement palette mixing in highlights

This commit is contained in:
dP
2025-11-29 01:19:34 +05:00
parent f356de80b1
commit e4ac251f42
9 changed files with 112 additions and 77 deletions
+8 -8
View File
@@ -622,7 +622,7 @@ void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32_t x, int32_t y, int
{
/* Switch to first foundation part, if no foundation was drawn */
if (_vd.foundation_part == FOUNDATION_PART_NONE) _vd.foundation_part = FOUNDATION_PART_NORMAL;
if (_vd.cm_highlight.ground_pal) pal = _vd.cm_highlight.ground_pal;
pal = _vd.cm_highlight.pick_ground_pal(pal);
if (_vd.foundation[_vd.foundation_part] != -1) {
Point pt = RemapCoords(x, y, z);
AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, pt.x + extra_offs_x * ZOOM_LVL_BASE, pt.y + extra_offs_y * ZOOM_LVL_BASE);
@@ -731,14 +731,14 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
assert((image & SPRITE_MASK) < MAX_SPRITES);
if (!ignore_highlight_pal) {
if (_vd.cm_highlight.structure_pal) pal = _vd.cm_highlight.structure_pal;
}
/* make the sprites transparent with the right palette */
if (transparent) {
SetBit(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (!ignore_highlight_pal) {
auto [draw, new_pal] = _vd.cm_highlight.get_structure_pal();
if (!draw) return;
if (new_pal != PAL_NONE) pal = new_pal;
}
if (_vd.combine_sprites == SPRITE_COMBINE_ACTIVE) {
@@ -747,7 +747,6 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
}
_vd.last_child = nullptr;
if (!ignore_highlight_pal && pal == CM_PALETTE_HIDE_SPRITE) return;
Point pt = RemapCoords(x, y, z);
int tmp_left, tmp_top, tmp_x = pt.x, tmp_y = pt.y;
@@ -1350,8 +1349,9 @@ static void ViewportAddLandscape()
_tile_type_procs[tile_type]->draw_tile_proc(&_cur_ti);
if (_cur_ti.tile != INVALID_TILE) { // CM TODO why is this check here?
_vd.cm_highlight.ground_pal = _vd.cm_highlight.highlight_ground_pal;
_vd.cm_highlight.structure_pal = _vd.cm_highlight.highlight_structure_pal;
_vd.cm_highlight.structure_pal = _vd.cm_highlight.highlight_pal;
_vd.cm_highlight.structure_pal_prio = PAL_NONE;
_vd.cm_highlight.structure_hidden = false;
citymania::DrawTileZoning(&_cur_ti); // old zoning patch
citymania::DrawTileZoning(&_cur_ti, _vd.cm_highlight, tile_type);
DrawTileSelection(&_cur_ti);