Skip to content

Commit 2736f78

Browse files
committed
images: removed GROUP_OVERLAY_COLUMN from defines
1 parent c3174aa commit 2736f78

File tree

3 files changed

+35
-41
lines changed

3 files changed

+35
-41
lines changed

src/graphics/image_groups.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ extern const token_holder<e_pack, PACK_UNLOADED, PACK_MAX> e_pack_type_tokens;
169169
#define GROUP_OK_CANCEL_SCROLL_BUTTONS PACK_GENERAL, 96
170170
//#define GROUP_BUILDING_GRANARY PACK_GENERAL, 99
171171
//#define GROUP_BUILDING_FARMLAND PACK_GENERAL, 37 // 100
172-
#define GROUP_OVERLAY_COLUMN PACK_GENERAL, 103
172+
//#define GROUP_OVERLAY_COLUMN PACK_GENERAL, 103
173173
#define GROUP_SIDEBAR_UPPER_BUTTONS PACK_GENERAL, 110
174174
//#define GROUP_BUILDING_BEER_WORKSHOP PACK_GENERAL, 116 // 44
175175
#define GROUP_BUILDING_CHARIOT_MAKER PACK_GENERAL, 120 // 52

src/overlays/city_overlay.cpp

+29-34
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,16 @@ void config_load_city_overlays() {
5555
}
5656

5757
const char *caption = arch.r_string("caption");
58-
auto walkers = arch.r_array_num<e_figure_type>("walkers");
59-
auto buildings = arch.r_array_num<e_building_type>("buildings");
6058
int tooltip_base = arch.r_int("tooltip_base");
61-
e_column_type column_type = arch.r_type<e_column_type>("column_type");
62-
auto tooltips = arch.r_array_num("tooltips");
6359

6460
if (tooltip_base) { overlay->tooltip_base = tooltip_base; }
65-
if (buildings.size()) { overlay->buildings = buildings; }
6661
if (*caption) { overlay->caption = caption; }
67-
if (tooltips.size()) { overlay->tooltips = tooltips; }
68-
if (walkers.size()) { overlay->walkers = walkers; }
69-
if (column_type) { overlay->column_type = column_type; }
62+
63+
overlay->buildings = arch.r_array_num<e_building_type>("buildings");
64+
overlay->walkers = arch.r_array_num<e_figure_type>("walkers");
65+
overlay->column_type = arch.r_type<e_column_type>("column_type");
66+
overlay->tooltips = arch.r_array_num("tooltips");
67+
arch.r_anim("column_anim", overlay->anim);
7068
});
7169
}
7270

@@ -226,33 +224,29 @@ bool city_overlay::is_drawable_building_corner(tile2i tile, tile2i main, int siz
226224
return (offset_main == main);
227225
}
228226

229-
void city_overlay::draw_overlay_column(vec2i pixel, int height, int column_style, painter &ctx) const {
230-
int image_id = image_id_from_group(GROUP_OVERLAY_COLUMN);
231-
switch (column_style) {
232-
case COLUMN_TYPE_RISK:
233-
if (height <= 5)
234-
image_id += COLUMN_COLOR_PLAIN;
235-
else if (height < 7)
236-
image_id += COLUMN_COLOR_YELLOW;
237-
else if (height < 9)
238-
image_id += COLUMN_COLOR_ORANGE;
239-
else
240-
image_id += COLUMN_COLOR_RED;
241-
break;
242-
243-
case COLUMN_TYPE_POSITIVE:
244-
image_id += COLUMN_COLOR_BLUE;
245-
break;
246-
247-
case COLUMN_TYPE_WATER_ACCESS:
248-
image_id += COLUMN_COLOR_BLUE;
249-
break;
227+
void city_overlay::draw_overlay_column(e_column_color color, vec2i pixel, int height, int column_style, painter &ctx) const {
228+
if (color == COLUMN_COLOR_NONE) {
229+
switch (column_style) {
230+
case COLUMN_TYPE_RISK:
231+
if (height <= 5) { color = COLUMN_COLOR_PLAIN; }
232+
else if (height < 7) { color = COLUMN_COLOR_YELLOW; }
233+
else if (height < 9) { color = COLUMN_COLOR_ORANGE; }
234+
else { color = COLUMN_COLOR_RED; }
235+
break;
236+
237+
case COLUMN_TYPE_POSITIVE:
238+
color = COLUMN_COLOR_BLUE;
239+
break;
240+
241+
case COLUMN_TYPE_WATER_ACCESS:
242+
color = COLUMN_COLOR_BLUE;
243+
break;
244+
}
250245
}
251246

252-
if (height > 10) {
253-
height = 10;
254-
}
247+
int image_id = anim.first_img() + color;
255248

249+
height = std::min(height, 10);
256250
int capital_height = image_get(image_id)->height;
257251
// base
258252
ImageDraw::img_generic(ctx, image_id + 2, pixel.x + 9, pixel.y - 8);
@@ -381,7 +375,8 @@ void city_overlay::draw_building_top(vec2i pixel, tile2i tile, painter &ctx) con
381375
}
382376

383377
int column_height = get_city_overlay()->get_column_height(b);
384-
if (column_height == NO_COLUMN) {
378+
e_column_color column_color = get_city_overlay()->get_column_color(b);
379+
if (column_height == COLUMN_TYPE_NONE) {
385380
return;
386381
}
387382

@@ -391,6 +386,6 @@ void city_overlay::draw_building_top(vec2i pixel, tile2i tile, painter &ctx) con
391386
}
392387

393388
if (draw) {
394-
draw_overlay_column(pixel, column_height, get_city_overlay()->column_type, ctx);
389+
draw_overlay_column(column_color, pixel, column_height, get_city_overlay()->column_type, ctx);
395390
}
396391
}

src/overlays/city_overlay.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include "core/svector.h"
99
#include "core/tokenum.h"
1010

11-
constexpr int NO_COLUMN = -1;
12-
1311
extern const token_holder<e_overlay, OVERLAY_NONE, OVERLAY_SIZE> e_overlay_tokens;
1412
extern const token_holder<e_column_type, COLUMN_TYPE_RISK, COLUMN_TYPE_SIZE> e_column_type_tokens;
1513

@@ -18,19 +16,20 @@ class building;
1816
struct painter;
1917

2018
inline bool show_figure_none(const figure *f) { return false; }
21-
inline int get_column_height_none(const building* b) { return NO_COLUMN; }
2219

2320
struct city_overlay {
2421
svector<int, 10> tooltips;
2522
svector<e_figure_type, 10> walkers;
2623
svector<e_building_type, 10> buildings;
27-
int column_type = -1;
24+
e_column_type column_type = COLUMN_TYPE_NONE;
25+
animation_t anim;
2826

2927
int tooltip_base;
3028
bstring64 caption;
3129

3230
virtual bool show_figure(const figure *f) const;
33-
virtual int get_column_height(const building *b) const { return NO_COLUMN; }
31+
virtual int get_column_height(const building *b) const { return COLUMN_TYPE_NONE; }
32+
virtual e_column_color get_column_color(const building *b) const { return COLUMN_COLOR_NONE; }
3433
virtual xstring get_tooltip_for_grid_offset(tooltip_context *c, int grid_offset) const { return {}; }
3534
virtual xstring get_tooltip_for_building(tooltip_context *c, const building *b) const { return {}; }
3635
virtual bool draw_custom_footprint(vec2i pixel, tile2i point, painter &ctx) const { return false; }
@@ -39,7 +38,7 @@ struct city_overlay {
3938
virtual e_overlay get_type() const { return OVERLAY_NONE; }
4039

4140
void draw_building_top(vec2i pixel, tile2i tile, painter &ctx) const;
42-
void draw_overlay_column(vec2i pixel, int height, int column_style, painter &ctx) const;
41+
void draw_overlay_column(e_column_color c, vec2i pixel, int height, int column_style, painter &ctx) const;
4342
void draw_building_footprint(painter &ctx, vec2i pos, tile2i tile, int image_offset) const;
4443
bool is_drawable_farm_corner(tile2i tile) const;
4544
bool is_drawable_building_corner(tile2i tile, tile2i main, int size) const;

0 commit comments

Comments
 (0)