From 2ced62738acc86860fe804bd26dd7b4de9eb32a4 Mon Sep 17 00:00:00 2001 From: Pavel Stupnikov Date: Mon, 3 Feb 2020 02:39:10 +0300 Subject: [PATCH] Tint unused industries red/orange in zonning --- bin/data/cmclient-2.grf | Bin 95266 -> 95528 bytes grf/cmclient.nml | 7 ++ grf/recolourgen.py | 62 ++++++++++ grf/ttd-newgrf-dos.gpl | 260 +++++++++++++++++++++++++++++++++++++++ src/citymania/zoning.cpp | 30 +++-- src/citymania/zoning.hpp | 3 +- src/industry_cmd.cpp | 9 +- src/rev.cpp | 2 +- src/table/sprites.h | 7 +- src/zoning_cmd.cpp | 14 +-- 10 files changed, 367 insertions(+), 27 deletions(-) create mode 100644 grf/recolourgen.py create mode 100644 grf/ttd-newgrf-dos.gpl diff --git a/bin/data/cmclient-2.grf b/bin/data/cmclient-2.grf index 53830b85b26ac456d5c69ff167b1db9b9fa24a48..821b54a529a61cf3cc82013b39ee242e3f538fda 100644 GIT binary patch delta 307 zcmZ4Vf_23!R#659_aL_>UM?vv1vv%=1{MYehW`^cikfpV7H;?>kt0WrfH{W`A8~LvZ~!C*r4BndIPBWxc=+()!+V?#I~+K0(D5*s+I?uxp2J7% zLCOyvJb3spn04TQql1IP0g$0!^Bkcn4jgoJIB?(qNF7-B0mpif!48g&hmVw$mX?*3 zl`ktPDap^zw<<3OImN-T{K%1AyLRmcInJRJB){y4gTqb`*u8uAp*?%|?ml#A56D`u z{&Gi0N2eo4j+B=zMFJq_9^M63zsF&x!+`^PL4I~9Ejv=iRC=VDO=3Hn1fxt00M1mG A=l}o! delta 48 zcmZ4SignQoR#659_aL_>UM?vvDOm;v1{MYehW`^bikfpV7HszA+Rxi8B)MHkl2I%M E05skU^8f$< diff --git a/grf/cmclient.nml b/grf/cmclient.nml index d1ec457806..cf1a72e742 100644 --- a/grf/cmclient.nml +++ b/grf/cmclient.nml @@ -454,6 +454,13 @@ replace border_highlight(10029, "sprites/borderhighlight.png") { 0x00: 0xa2; 0x01: 0xb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0xb7; 0xd4: 0xb7; 0xd5: 0xb6; 0xd6: 0xb4; 0xd7: 0xb5; 0xd8: 0xb5; 0xd9: 0xb5; 0xda: 0xb5; 0xdb: 0xb5; 0xdc: 0xb5; 0xdd: 0xb5; 0xde: 0xb5; 0xdf: 0xb5; 0xe0: 0xb5; 0xe1: 0xb5; 0xe2: 0xb5; 0xe3: 0x46; 0xe4: 0xb2; 0xe5: 0xb3; 0xe6: 0xb4; 0xe7: 0xb5; 0xe8: 0xb3; 0xe9: 0xb4; 0xea: 0xb4; 0xeb: 0xb4; 0xec: 0xb4; 0xed: 0xb4; 0xee: 0xb5; 0xef: 0x46; 0xf0: 0xb3; 0xf1: 0x46; 0xf2: 0x46; 0xf3: 0xb2; 0xf4: 0xb5; 0xf5: 0x28; 0xf6: 0x28; 0xf7: 0xb3; 0xf8: 0xb3; 0xf9: 0xb3; 0xfa: 0xb3; 0xfb: 0xb4; 0xfc: 0xb7; 0xfd: 0xb4; 0xfe: 0xb3; 0xff: 0xb8; diff --git a/grf/recolourgen.py b/grf/recolourgen.py new file mode 100644 index 0000000000..11b690745c --- /dev/null +++ b/grf/recolourgen.py @@ -0,0 +1,62 @@ +import math +import spectra + +# SAFE_COLORS = list(range(0xA0, 0xD8)) + [0xf5] +SAFE_COLORS = list(range(1, 0xD7)) +# f = open("ttd-noaction-nocomp.gpl") +f = open("ttd-newgrf-dos.gpl") + +while f.readline().strip() != "#": + pass + + +# def color_distance(c1, c2): +# rmean = (c1[0] + c2[0]) / 2. +# r = c1[0] - c2[0] +# g = c1[1] - c2[1] +# b = c1[2] - c2[2] +# return math.sqrt( +# (((512 + rmean) * r * r) / 256.) + +# 4 * g * g + +# (((767 - rmean) * b * b) / 256.)) + +def color_distance(c1, c2): + r = c1[0] - c2[0] + g = c1[1] - c2[1] + b = c1[2] - c2[2] + return math.sqrt(r*r + g*g + b*b) + + +def gen_recolor(tint, ratio): + print(" recolour_sprite {") + print(" ", end="") + for i, (r, g, b) in colors: + x = spectra.rgb(r / 255., g / 255., b / 255.) + x = x.blend(tint, ratio=ratio) + r, g, b = [int(q * 255) for q in x.clamped_rgb] + mj, md = 0, 1e100 + for j, c in colors: + if j not in SAFE_COLORS: + continue + d = color_distance((r, g, b), c) + if d < md: + mj, md = j, d + # mj = 0xa4 + print(f"0x{i:02x}: 0x{mj:02x};", end=" ") + print() + print(" }") + print() + + +colors = [] +for _ in range(256): + try: + r, g, b, _, i = f.readline().split() + except ValueError: + break + c = (int(r), int(g), int(b)) + # if c in SAFE_COLORS: + colors.append((int(i), c)) + +gen_recolor(spectra.rgb(1, 0, 0), 0.75) +gen_recolor(spectra.rgb(1.1, 0.6, 0), 0.6) diff --git a/grf/ttd-newgrf-dos.gpl b/grf/ttd-newgrf-dos.gpl new file mode 100644 index 0000000000..6b8160b6f3 --- /dev/null +++ b/grf/ttd-newgrf-dos.gpl @@ -0,0 +1,260 @@ +GIMP Palette +Name: ttd-newgrf-dos +Columns: 16 +# + 0 0 255 Index 0 + 16 16 16 Index 1 + 32 32 32 Index 2 + 48 48 48 Index 3 + 64 64 64 Index 4 + 80 80 80 Index 5 +100 100 100 Index 6 +116 116 116 Index 7 +132 132 132 Index 8 +148 148 148 Index 9 +168 168 168 Index 10 +184 184 184 Index 11 +200 200 200 Index 12 +216 216 216 Index 13 +232 232 232 Index 14 +252 252 252 Index 15 + 52 60 72 Index 16 + 68 76 92 Index 17 + 88 96 112 Index 18 +108 116 132 Index 19 +132 140 152 Index 20 +156 160 172 Index 21 +176 184 196 Index 22 +204 208 220 Index 23 + 48 44 4 Index 24 + 64 60 12 Index 25 + 80 76 20 Index 26 + 96 92 28 Index 27 +120 120 64 Index 28 +148 148 100 Index 29 +176 176 132 Index 30 +204 204 168 Index 31 + 72 44 4 Index 32 + 88 60 20 Index 33 +104 80 44 Index 34 +124 104 72 Index 35 +152 132 92 Index 36 +184 160 120 Index 37 +212 188 148 Index 38 +244 220 176 Index 39 + 64 0 4 Index 40 + 88 4 16 Index 41 +112 16 32 Index 42 +136 32 52 Index 43 +160 56 76 Index 44 +188 84 108 Index 45 +204 104 124 Index 46 +220 132 144 Index 47 +236 156 164 Index 48 +252 188 192 Index 49 +252 208 0 Index 50 +252 232 60 Index 51 +252 252 128 Index 52 + 76 40 0 Index 53 + 96 60 8 Index 54 +116 88 28 Index 55 +136 116 56 Index 56 +156 136 80 Index 57 +176 156 108 Index 58 +196 180 136 Index 59 + 68 24 0 Index 60 + 96 44 4 Index 61 +128 68 8 Index 62 +156 96 16 Index 63 +184 120 24 Index 64 +212 156 32 Index 65 +232 184 16 Index 66 +252 212 0 Index 67 +252 248 128 Index 68 +252 252 192 Index 69 + 32 4 0 Index 70 + 64 20 8 Index 71 + 84 28 16 Index 72 +108 44 28 Index 73 +128 56 40 Index 74 +148 72 56 Index 75 +168 92 76 Index 76 +184 108 88 Index 77 +196 128 108 Index 78 +212 148 128 Index 79 + 8 52 0 Index 80 + 16 64 0 Index 81 + 32 80 4 Index 82 + 48 96 4 Index 83 + 64 112 12 Index 84 + 84 132 20 Index 85 +104 148 28 Index 86 +128 168 44 Index 87 + 28 52 24 Index 88 + 44 68 32 Index 89 + 60 88 48 Index 90 + 80 104 60 Index 91 +104 124 76 Index 92 +128 148 92 Index 93 +152 176 108 Index 94 +180 204 124 Index 95 + 16 52 24 Index 96 + 32 72 44 Index 97 + 56 96 72 Index 98 + 76 116 88 Index 99 + 96 136 108 Index 100 +120 164 136 Index 101 +152 192 168 Index 102 +184 220 200 Index 103 + 32 24 0 Index 104 + 56 28 0 Index 105 + 72 40 4 Index 106 + 88 52 12 Index 107 +104 64 24 Index 108 +124 84 44 Index 109 +140 108 64 Index 110 +160 128 88 Index 111 + 76 40 16 Index 112 + 96 52 24 Index 113 +116 68 40 Index 114 +136 84 56 Index 115 +164 96 64 Index 116 +184 112 80 Index 117 +204 128 96 Index 118 +212 148 112 Index 119 +224 168 128 Index 120 +236 188 148 Index 121 + 80 28 4 Index 122 +100 40 20 Index 123 +120 56 40 Index 124 +140 76 64 Index 125 +160 100 96 Index 126 +184 136 136 Index 127 + 36 40 68 Index 128 + 48 52 84 Index 129 + 64 64 100 Index 130 + 80 80 116 Index 131 +100 100 136 Index 132 +132 132 164 Index 133 +172 172 192 Index 134 +212 212 224 Index 135 + 40 20 112 Index 136 + 64 44 144 Index 137 + 88 64 172 Index 138 +104 76 196 Index 139 +120 88 224 Index 140 +140 104 252 Index 141 +160 136 252 Index 142 +188 168 252 Index 143 + 0 24 108 Index 144 + 0 36 132 Index 145 + 0 52 160 Index 146 + 0 72 184 Index 147 + 0 96 212 Index 148 + 24 120 220 Index 149 + 56 144 232 Index 150 + 88 168 240 Index 151 +128 196 252 Index 152 +188 224 252 Index 153 + 16 64 96 Index 154 + 24 80 108 Index 155 + 40 96 120 Index 156 + 52 112 132 Index 157 + 80 140 160 Index 158 +116 172 192 Index 159 +156 204 220 Index 160 +204 240 252 Index 161 +172 52 52 Index 162 +212 52 52 Index 163 +252 52 52 Index 164 +252 100 88 Index 165 +252 144 124 Index 166 +252 184 160 Index 167 +252 216 200 Index 168 +252 244 236 Index 169 + 72 20 112 Index 170 + 92 44 140 Index 171 +112 68 168 Index 172 +140 100 196 Index 173 +168 136 224 Index 174 +200 176 248 Index 175 +208 184 255 Index 176 +232 208 252 Index 177 + 60 0 0 Index 178 + 92 0 0 Index 179 +128 0 0 Index 180 +160 0 0 Index 181 +196 0 0 Index 182 +224 0 0 Index 183 +252 0 0 Index 184 +252 80 0 Index 185 +252 108 0 Index 186 +252 136 0 Index 187 +252 164 0 Index 188 +252 192 0 Index 189 +252 220 0 Index 190 +252 252 0 Index 191 +204 136 8 Index 192 +228 144 4 Index 193 +252 156 0 Index 194 +252 176 48 Index 195 +252 196 100 Index 196 +252 216 152 Index 197 + 8 24 88 Index 198 + 12 36 104 Index 199 + 20 52 124 Index 200 + 28 68 140 Index 201 + 40 92 164 Index 202 + 56 120 188 Index 203 + 72 152 216 Index 204 +100 172 224 Index 205 + 92 156 52 Index 206 +108 176 64 Index 207 +124 200 76 Index 208 +144 224 92 Index 209 +224 244 252 Index 210 +200 236 248 Index 211 +180 220 236 Index 212 +132 188 216 Index 213 + 88 152 172 Index 214 +244 0 244 Index 215 +245 0 245 Index 216 +246 0 246 Index 217 +247 0 247 Index 218 +248 0 248 Index 219 +249 0 249 Index 220 +250 0 250 Index 221 +251 0 251 Index 222 +252 0 252 Index 223 +253 0 253 Index 224 +254 0 254 Index 225 +255 0 255 Index 226 + 76 24 8 Index 227 +108 44 24 Index 228 +144 72 52 Index 229 +176 108 84 Index 230 +210 146 126 Index 231 +252 60 0 Index 232 +252 84 0 Index 233 +252 104 0 Index 234 +252 124 0 Index 235 +252 148 0 Index 236 +252 172 0 Index 237 +252 196 0 Index 238 + 64 0 0 Index 239 +255 0 0 Index 240 + 48 48 0 Index 241 + 64 64 0 Index 242 + 80 80 0 Index 243 +255 255 0 Index 244 + 32 68 112 Index 245 + 36 72 116 Index 246 + 40 76 120 Index 247 + 44 80 124 Index 248 + 48 84 128 Index 249 + 72 100 144 Index 250 +100 132 168 Index 251 +216 244 252 Index 252 + 96 128 164 Index 253 + 68 96 140 Index 254 +255 255 255 Index 255 diff --git a/src/citymania/zoning.cpp b/src/citymania/zoning.cpp index 1da6755f05..0595536749 100644 --- a/src/citymania/zoning.cpp +++ b/src/citymania/zoning.cpp @@ -2,8 +2,9 @@ #include "zoning.hpp" -#include "../house.h" #include "../core/math_func.hpp" +#include "../house.h" +#include "../industry.h" #include "../town.h" #include "../tilearea_type.h" #include "../viewport_func.h" @@ -136,17 +137,30 @@ ZoningBorder GetAnyStationCatchmentBorder(TileIndex tile) { SpriteID GetTownTileZoningPalette(TileIndex tile) { if (_zoning.outer == CHECKBULUNSER) { - if (IsTileType (tile, MP_HOUSE)) { - StationFinder stations(TileArea(tile, 1, 1)); + StationFinder stations(TileArea(tile, 1, 1)); - if (!stations.GetStations()->empty()) { - return PAL_NONE; - } - return SPR_RECOLOR_RED; - } + if (stations.GetStations()->empty()) + return SPR_RECOLOUR_RED; } return PAL_NONE; } +SpriteID GetIndustryTileZoningPalette(TileIndex tile, Industry *ind) { + if (_zoning.outer == CHECKINDUNSER) { + auto n_produced = 0; + auto n_serviced = 0; + for (auto j = 0; j < INDUSTRY_NUM_OUTPUTS; j++) { + if (ind->produced_cargo[j] == CT_INVALID) continue; + if (ind->last_month_production[j] == 0 && ind->this_month_production[j] == 0) continue; + n_produced++; + if (ind->last_month_transported[j] > 0 || ind->last_month_transported[j] > 0) + n_serviced++; + } + if (n_serviced < n_produced) + return (n_serviced == 0 ? SPR_RECOLOUR_RED : SPR_RECOLOUR_ORANGE); + } + + return PAL_NONE; +} } // namespace citymania diff --git a/src/citymania/zoning.hpp b/src/citymania/zoning.hpp index 0a22f40ffe..6971087679 100644 --- a/src/citymania/zoning.hpp +++ b/src/citymania/zoning.hpp @@ -3,6 +3,7 @@ #include "../core/enum_type.hpp" #include "../gfx_type.h" +#include "../industry_type.h" #include "../tile_type.h" #include "../town_type.h" @@ -42,7 +43,7 @@ ZoningBorder GetAnyStationCatchmentBorder(TileIndex tlie); // std::pair GetTownAdvertisementBorder(TileIndex tile); // SpriteID GetTownTileZoningPalette(TileIndex tile); - +SpriteID GetIndustryTileZoningPalette(TileIndex tile, Industry *ind); } // namespace citymania #endif diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index ebf4f37c4d..90b9b6cf65 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -44,6 +44,8 @@ #include "table/industry_land.h" #include "table/build_industry.h" +#include "citymania/zoning.hpp" + #include "safeguards.h" IndustryPool _industry_pool("Industry"); @@ -348,12 +350,15 @@ static void DrawTile_Industry(TileInfo *ti) /* DrawFoundation() modifies ti->z and ti->tileh */ if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); + auto zoning_pal = citymania::GetIndustryTileZoningPalette(ti->tile, ind); + /* If the ground sprite is the default flat water sprite, draw also canal/river borders. * Do not do this if the tile's WaterClass is 'land'. */ if (image == SPR_FLAT_WATER_TILE && IsTileOnWater(ti->tile)) { DrawWaterClassGround(ti); } else { - DrawGroundSprite(image, GroundSpritePaletteTransform(image, dits->ground.pal, GENERAL_SPRITE_COLOUR(ind->random_colour))); + DrawGroundSprite(image, zoning_pal == PAL_NONE ? GroundSpritePaletteTransform(image, dits->ground.pal, GENERAL_SPRITE_COLOUR(ind->random_colour)) : zoning_pal); + // DrawGroundSprite(image, GroundSpritePaletteTransform(image, dits->ground.pal, GENERAL_SPRITE_COLOUR(ind->random_colour))); } /* If industries are transparent and invisible, do not draw the upper part */ @@ -362,7 +367,7 @@ static void DrawTile_Industry(TileInfo *ti) /* Add industry on top of the ground? */ image = dits->building.sprite; if (image != 0) { - AddSortableSpriteToDraw(image, SpriteLayoutPaletteTransform(image, dits->building.pal, GENERAL_SPRITE_COLOUR(ind->random_colour)), + AddSortableSpriteToDraw(image, zoning_pal == PAL_NONE ? SpriteLayoutPaletteTransform(image, dits->building.pal, GENERAL_SPRITE_COLOUR(ind->random_colour)) : zoning_pal, ti->x + dits->subtile_x, ti->y + dits->subtile_y, dits->width, diff --git a/src/rev.cpp b/src/rev.cpp index 8cedbce2b2..07939457f0 100644 --- a/src/rev.cpp +++ b/src/rev.cpp @@ -83,4 +83,4 @@ const byte _openttd_revision_tagged = 1; const uint32 _openttd_newgrf_version = 1 << 28 | 10 << 24 | 0 << 20 | 0 << 19 | 28004; -const char _citymania_version[] = "20200106-master-m248ef04353 02.02.20"; +const char _citymania_version[] = "!!VERSION!! !!DATE!!"; diff --git a/src/table/sprites.h b/src/table/sprites.h index cb0e903b1b..b7f9693bc7 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -317,10 +317,13 @@ static const SpriteID SPR_INNER_HIGHLIGHT_COUNT = 29; static const SpriteID SPR_BORDER_HIGHLIGHT_BASE = SPR_INNER_HIGHLIGHT_BASE + SPR_INNER_HIGHLIGHT_COUNT + 1; static const SpriteID SPR_BORDER_HIGHLIGHT_COUNT = 19 * 19; -static const SpriteID SPR_RECOLOR_RED = SPR_BORDER_HIGHLIGHT_BASE + SPR_BORDER_HIGHLIGHT_COUNT; +static const SpriteID SPR_RECOLOUR_BASE = SPR_BORDER_HIGHLIGHT_BASE + SPR_BORDER_HIGHLIGHT_COUNT; +static const SpriteID SPR_RECOLOUR_RED = SPR_RECOLOUR_BASE; +static const SpriteID SPR_RECOLOUR_ORANGE = SPR_RECOLOUR_BASE + 1; +static const SpriteID SPR_RECOLOUR_COUNT = 2; /* From where can we start putting NewGRFs? */ -static const SpriteID SPR_NEWGRFS_BASE = SPR_RECOLOR_RED + 1; +static const SpriteID SPR_NEWGRFS_BASE = SPR_RECOLOUR_BASE + SPR_RECOLOUR_COUNT; /* Manager face sprites */ static const SpriteID SPR_GRADIENT = 874; // background gradient behind manager face diff --git a/src/zoning_cmd.cpp b/src/zoning_cmd.cpp index 2a31181d6a..ecd443dacb 100644 --- a/src/zoning_cmd.cpp +++ b/src/zoning_cmd.cpp @@ -202,10 +202,6 @@ SpriteID TileZoneCheckBuildEvaluation(TileIndex tile, Owner owner) { if (IsTileType(tile, MP_STATION)){ return INVALID_SPRITE_ID; } - // For accepted goods - if (IsTileWithinAcceptanceZoneOfStation(tile)){ - return SPR_PALETTE_ZONING_LIGHT_BLUE; - } return INVALID_SPRITE_ID; } @@ -223,10 +219,6 @@ SpriteID TileZoneCheckUnservedBuildingsEvaluation(TileIndex tile) { if (!stations.GetStations()->empty()) { return INVALID_SPRITE_ID; } - // For accepted goods - if (IsTileWithinAcceptanceZoneOfStation(tile)){ - return SPR_PALETTE_ZONING_ORANGE; - } return SPR_PALETTE_ZONING_RED; } return INVALID_SPRITE_ID; @@ -243,10 +235,6 @@ SpriteID TileZoneCheckUnservedIndustriesEvaluation(TileIndex tile) { return INVALID_SPRITE_ID; } - // For accepted goods - if (IsAreaWithinAcceptanceZoneOfStation(ind->location)){ - return SPR_PALETTE_ZONING_ORANGE; - } return SPR_PALETTE_ZONING_RED; } return INVALID_SPRITE_ID; @@ -431,7 +419,7 @@ void DrawTileZoning(const TileInfo *ti) { if (p.first && p.second) { DrawBorderSprites(ti, p.first, GetTownZoneBorderColor(p.second)); } - } else if (_zoning.outer == CHECKBULUNSER) { + } else if (_zoning.outer == CHECKBULUNSER || _zoning.outer == CHECKINDUNSER) { // handled in house drawing } else if (_zoning.outer == CHECKSTACATCH) { auto b = citymania::GetAnyStationCatchmentBorder(ti->tile);