Blink industries on the minimap with similar colour

This commit is contained in:
dP
2025-07-04 02:05:13 +05:00
parent ff94d155cf
commit 9998060ffa
2 changed files with 19 additions and 6 deletions

View File

@@ -2,11 +2,22 @@
#define CM_COLOUR_HPP
#include "../blitter/32bpp_base.hpp"
#include "../palette_func.h" // PC_WHITE, PC_BLACK
#include <cstdint>
namespace citymania {
extern const uint8_t RGB_TO_M[];
// ', '.join(["true" if grf.srgb_color_distance(c, (255, 255, 255)) > grf.srgb_color_distance(c, (0, 0, 0)) else "false" for c in grf.PALETTE])
constexpr std::array<bool, 256> IS_M_CLOSER_TO_BLACK = { true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, true, true, true, true, false, false, false, false, true, true, true, true, true, false, false, false, true, true, true, true, true, false, false, false, true, true, true, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, false, false, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, true, true, true, true, true, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, true, true, true, true, false, true, true, true, true, true, false, false, false, true, true, true, true, false, false, false, false, true, true, true, true, true, true, false, false, false, false, true, true, true, true, false, false, false, false, true, true, true, false, false, false, false, false, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true, true, false, false, false, false, false, true, false, false, false, false, false, true, true, true, true, true, true, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, false, true, true, true, false, false, false, false, true, true, true, true, true, false, true, true, true, true, true, true, false, false, false, true, false };
constexpr std::array<uint8_t, 256> BLINK_COLOUR = { 141, 7, 9, 10, 11, 12, 13, 14, 2, 2, 3, 4, 5, 6, 6, 8, 22, 22, 135, 210, 2, 3, 16, 18, 29, 30, 59, 31, 69, 24, 25, 26, 37, 38, 38, 39, 104, 32, 33, 35, 77, 47, 166, 166, 49, 49, 41, 41, 42, 125, 55, 85, 86, 37, 120, 65, 69, 104, 24, 25, 78, 120, 121, 197, 60, 54, 55, 27, 85, 28, 126, 78, 79, 79, 167, 167, 167, 178, 71, 72, 94, 94, 95, 95, 95, 209, 80, 81, 101, 102, 31, 103, 69, 80, 81, 82, 101, 102, 103, 103, 69, 96, 97, 98, 36, 111, 37, 120, 121, 121, 39, 105, 79, 120, 167, 167, 167, 178, 122, 122, 61, 108, 79, 79, 167, 167, 168, 71, 133, 134, 134, 177, 177, 128, 16, 18, 142, 142, 143, 143, 143, 136, 136, 171, 150, 150, 151, 151, 152, 152, 144, 200, 154, 156, 213, 213, 212, 153, 128, 154, 155, 157, 166, 166, 180, 180, 180, 124, 35, 7, 174, 143, 176, 176, 170, 130, 131, 132, 77, 166, 166, 166, 165, 165, 180, 180, 180, 180, 62, 63, 27, 65, 53, 61, 62, 62, 55, 55, 204, 151, 151, 152, 152, 152, 198, 154, 80, 81, 83, 84, 19, 157, 156, 154, 154, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 78, 79, 167, 168, 72, 180, 180, 180, 180, 62, 62, 63, 77, 181, 29, 30, 95, 86, 152, 152, 152, 152, 152, 153, 128, 19, 161, 153, 8 };
static inline uint8_t GetBlinkColour(uint8_t m) {
return BLINK_COLOUR[m];
}
static inline uint8_t GetMForRGB(uint8_t r, uint8_t g, uint8_t b) {
return RGB_TO_M[((uint)(r & 0xf0) >> 4) | ((uint)g & 0xf0) | ((uint)(b & 0xf0) << 4)];
}
@@ -27,8 +38,6 @@ static inline Colour Remap32RGBA(uint r, uint g, uint b, uint a, Colour current,
return Remap32RGBANoCheck(r, g, b, a, current, remap);
}
} // namespace citymania
#endif

View File

@@ -28,6 +28,7 @@
#include <bitset>
#include "cm_colour.hpp"
#include "cm_hotkeys.hpp"
#include "cm_minimap.hpp"
@@ -854,10 +855,12 @@ inline uint32 SmallMapWindow::GetTileColours(const TileArea &ta) const
* This has the highest priority above any value in _tiletype_importance. */
IndustryType type = Industry::GetByTile(ti)->type;
if (_legend_from_industries[_industry_to_list_pos[type]].show_on_map) {
if (type == _smallmap_industry_highlight) {
if (_smallmap_industry_highlight_state) return MKCOLOUR_XXXX(PC_WHITE);
auto map_colour = GetIndustrySpec(type)->map_colour;
if (type == _smallmap_industry_highlight && _smallmap_industry_highlight_state) {
Debug(misc, 0, "BLINK {}", map_colour);
return MKCOLOUR_XXXX(GetBlinkColour(map_colour));
} else {
return GetIndustrySpec(type)->map_colour * 0x01010101;
return map_colour * 0x01010101;
}
}
/* Otherwise make it disappear */
@@ -1431,7 +1434,8 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
SetDParam(0, tbl->legend);
SetDParam(1, Industry::GetIndustryTypeCount(tbl->type));
if (tbl->show_on_map && tbl->type == _smallmap_industry_highlight) {
legend_colour = _smallmap_industry_highlight_state ? PC_WHITE : PC_BLACK;
auto mc = GetIndustrySpec(tbl->type)->map_colour;
legend_colour = _smallmap_industry_highlight_state ? GetBlinkColour(mc) : mc;
}
[[ fallthrough ]];