diff --git a/bin/data/cmclient-6.grf b/bin/data/cmclient-6.grf index a328db91cf..c3bc8eed3b 100644 Binary files a/bin/data/cmclient-6.grf and b/bin/data/cmclient-6.grf differ diff --git a/grf/cmclient/gencmclientgrf.py b/grf/cmclient/gencmclientgrf.py index 33bc9b269c..5e6d31e1ca 100644 --- a/grf/cmclient/gencmclientgrf.py +++ b/grf/cmclient/gencmclientgrf.py @@ -152,6 +152,15 @@ for p in TILEDATA: y += h + SPRITE_MARGIN +tileicon_png = grf.ImageFile('sprites/tileicons.png') +sprite = lambda name, *args, **kw: g.add(grf.FileSprite(tileicon_png, *args, name=name, **kw)) +sprite('icon_house_removed', 2, 2, 20, 20, xofs=-9, yofs=10) +sprite('icon_house_replaced', 24, 2, 20, 20, xofs=-9, yofs=10) +sprite('icon_house_new', 46, 2, 20, 20, xofs=-9, yofs=10) +sprite('icon_dead_end', 68, 2, 20, 20, xofs=-9, yofs=10) +sprite('icon_road', 90, 2, 20, 20, xofs=-9, yofs=10) +sprite('icon_house_denied', 112, 2, 20, 20, xofs=-9, yofs=10) + def gen_tint(tint, ratio): tint = grf.srgb_to_oklab(np.array(tint) * 255) diff --git a/src/citymania/cm_game.cpp b/src/citymania/cm_game.cpp index 6612c4afee..03880fd5d7 100644 --- a/src/citymania/cm_game.cpp +++ b/src/citymania/cm_game.cpp @@ -3,6 +3,7 @@ #include "cm_game.hpp" #include "../company_base.h" +#include "../timer/timer.h" #include "../safeguards.h" diff --git a/src/citymania/cm_highlight.cpp b/src/citymania/cm_highlight.cpp index 07bccd4b72..d1e4a3937c 100644 --- a/src/citymania/cm_highlight.cpp +++ b/src/citymania/cm_highlight.cpp @@ -2299,26 +2299,30 @@ TileHighlight GetTileHighlight(const TileInfo *ti, TileType tile_type) { switch (_game->get_town_growth_tile(ti->tile)) { // case TGTS_CB_HOUSE_REMOVED_NOGROW: case TownGrowthTileState::RH_REMOVED: - th.set_old_selection(CM_SPR_PALETTE_ZONING_LIGHT_BLUE); + th.set_icon(CM_SPR_TILE_ICON_HOUSE_REMOVED, CM_PALETTE_TINT_CYAN); + th.tint_ground(CM_PALETTE_TINT_CYAN); break; case TownGrowthTileState::RH_REBUILT: - th.set_old_selection(CM_SPR_PALETTE_ZONING_WHITE); - th.tint_structure(CM_PALETTE_TINT_WHITE); + th.set_icon(CM_SPR_TILE_ICON_HOUSE_REPLACED, CM_PALETTE_TINT_BLUE); + th.tint_ground(CM_PALETTE_TINT_BLUE); break; case TownGrowthTileState::NEW_HOUSE: - th.set_old_selection(CM_SPR_PALETTE_ZONING_GREEN); - th.tint_structure(CM_PALETTE_TINT_GREEN); + th.set_icon(CM_SPR_TILE_ICON_HOUSE_NEW, CM_PALETTE_TINT_GREEN); + th.tint_ground(CM_PALETTE_TINT_GREEN); break; case TownGrowthTileState::CS: - th.set_old_selection(CM_SPR_PALETTE_ZONING_ORANGE); + th.set_icon(CM_SPR_TILE_ICON_DEAD_END, CM_PALETTE_TINT_ORANGE); + th.tint_ground(CM_PALETTE_TINT_ORANGE); break; case TownGrowthTileState::HS: - th.set_old_selection(CM_SPR_PALETTE_ZONING_YELLOW); + th.set_icon(CM_SPR_TILE_ICON_ROAD, CM_PALETTE_TINT_YELLOW); + th.tint_ground(CM_PALETTE_TINT_YELLOW); break; case TownGrowthTileState::HR: - th.set_old_selection(CM_SPR_PALETTE_ZONING_RED); + th.set_icon(CM_SPR_TILE_ICON_HOUSE_DENIED, CM_PALETTE_TINT_RED); + th.tint_ground(CM_PALETTE_TINT_RED); break; - default: th.set_old_selection(PAL_NONE); + default: break; } } else if (_zoning.outer == CHECKBULUNSER) { if (IsTileType (ti->tile, MP_HOUSE)) { diff --git a/src/citymania/cm_highlight_type.hpp b/src/citymania/cm_highlight_type.hpp index 15c5460981..a9a2584fbf 100644 --- a/src/citymania/cm_highlight_type.hpp +++ b/src/citymania/cm_highlight_type.hpp @@ -48,7 +48,9 @@ class TileHighlight { public: SpriteID ground_pal = PAL_NONE; SpriteID structure_pal = PAL_NONE; - SpriteID structure_pal_prio = PAL_NONE; + SpriteID structure_pal_prio = PAL_NONE; // TODO rename as this is priority highlight not just structure + SpriteID icon = PAL_NONE; + SpriteID icon_pal = PAL_NONE; bool structure_hidden = false; SpriteID highlight_pal = PAL_NONE; SpriteID sprite = 0; @@ -70,6 +72,11 @@ public: return colour; } + SpriteID get_icon() { + if (this->structure_pal_prio != PAL_NONE) return PAL_NONE; + return this->icon; + } + void add_border(ZoningBorder border, SpriteID colour) { if (border == ZoningBorder::NONE || !colour) return; this->border[this->border_count] = border; @@ -98,6 +105,11 @@ public: this->highlight_pal = colour; } + void set_icon(SpriteID icon, SpriteID pal) { + this->icon = icon; + this->icon_pal = pal; + } + void clear_borders() { this->border_count = 0; } diff --git a/src/citymania/cm_main.cpp b/src/citymania/cm_main.cpp index 0d8cb15a5e..4ff7293d5a 100644 --- a/src/citymania/cm_main.cpp +++ b/src/citymania/cm_main.cpp @@ -14,6 +14,10 @@ namespace citymania { up _game = nullptr; +static IntervalTimer _event_new_month({TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [](auto) { + Emit(event::NewMonth{}); +}); + void ResetGame() { _game = make_up(); ResetEffectiveActionCounter(); diff --git a/src/citymania/cm_zoning_cmd.cpp b/src/citymania/cm_zoning_cmd.cpp index 6de38c97fc..052d22dee4 100644 --- a/src/citymania/cm_zoning_cmd.cpp +++ b/src/citymania/cm_zoning_cmd.cpp @@ -380,13 +380,6 @@ SpriteID GetTownZoneBorderColor(uint8 zone) { case 4: return CM_SPR_PALETTE_ZONING_ORANGE; // Tz3 case 5: return CM_SPR_PALETTE_ZONING_RED; // Tz4 - center }; - switch (zone) { - default: return CM_SPR_PALETTE_ZONING_LIGHT_BLUE; // Tz0 - case 2: return CM_SPR_PALETTE_ZONING_RED; // Tz1 - case 3: return CM_SPR_PALETTE_ZONING_YELLOW; // Tz2 - case 4: return CM_SPR_PALETTE_ZONING_GREEN; // Tz3 - case 5: return CM_SPR_PALETTE_ZONING_WHITE; // Tz4 - center - }; } diff --git a/src/table/sprites.h b/src/table/sprites.h index d8e16413f6..3b550b4313 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -338,8 +338,17 @@ static const SpriteID CM_SPR_INNER_HIGHLIGHT_COUNT = 30; static const SpriteID CM_SPR_BORDER_HIGHLIGHT_BASE = CM_SPR_INNER_HIGHLIGHT_BASE + CM_SPR_INNER_HIGHLIGHT_COUNT; static const SpriteID CM_SPR_BORDER_HIGHLIGHT_COUNT = 19 * 19; +static const SpriteID CM_SPR_TILE_ICON_BASE = CM_SPR_BORDER_HIGHLIGHT_BASE + CM_SPR_BORDER_HIGHLIGHT_COUNT; +static const SpriteID CM_SPR_TILE_ICON_HOUSE_REMOVED = CM_SPR_TILE_ICON_BASE; +static const SpriteID CM_SPR_TILE_ICON_HOUSE_REPLACED = CM_SPR_TILE_ICON_BASE + 1; +static const SpriteID CM_SPR_TILE_ICON_HOUSE_NEW = CM_SPR_TILE_ICON_BASE + 2; +static const SpriteID CM_SPR_TILE_ICON_DEAD_END = CM_SPR_TILE_ICON_BASE + 3; +static const SpriteID CM_SPR_TILE_ICON_ROAD = CM_SPR_TILE_ICON_BASE + 4; +static const SpriteID CM_SPR_TILE_ICON_HOUSE_DENIED = CM_SPR_TILE_ICON_BASE + 5; +static const SpriteID CM_SPR_TILE_ICON_COUNT = 6; + /* Tree shades */ -static const SpriteID CM_PALETTE_SHADE_BASE = CM_SPR_BORDER_HIGHLIGHT_BASE + CM_SPR_BORDER_HIGHLIGHT_COUNT; +static const SpriteID CM_PALETTE_SHADE_BASE = CM_SPR_TILE_ICON_BASE + CM_SPR_TILE_ICON_COUNT; static const SpriteID CM_PALETTE_SHADE_N = CM_PALETTE_SHADE_BASE; static const SpriteID CM_PALETTE_SHADE_NE = CM_PALETTE_SHADE_BASE + 1; static const SpriteID CM_PALETTE_SHADE_E = CM_PALETTE_SHADE_BASE + 2; diff --git a/src/viewport.cpp b/src/viewport.cpp index 921eb3ffd9..e69624a28d 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -63,6 +63,7 @@ #include "stdafx.h" #include "core/backup_type.hpp" #include "landscape.h" +#include "table/sprites.h" #include "viewport_func.h" #include "station_base.h" #include "waypoint_base.h" @@ -1348,10 +1349,20 @@ static void ViewportAddLandscape() _tile_type_procs[tile_type]->draw_tile_proc(&_cur_ti); + _vd.cm_highlight.structure_pal_prio = PAL_NONE; + _vd.cm_highlight.structure_hidden = false; + + auto icon = _vd.cm_highlight.get_icon(); + if (icon != PAL_NONE) { + _vd.cm_highlight.structure_pal = PAL_NONE; + AddSortableSpriteToDraw( + icon, + _vd.cm_highlight.icon_pal, _cur_ti.x, _cur_ti.y, 0x10, 0x10, 1, _cur_ti.z + 7 + ); + } + if (_cur_ti.tile != INVALID_TILE) { // CM TODO why is this check here? _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);