From aa8fd339f6c039e0951b62514da89594aa99f20f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 25 Sep 2021 20:49:41 +0300 Subject: [PATCH 44/44] Show selected infratile on map canvas See osdn #42920 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/infradlg.c | 5 +++++ client/mapview_common.c | 27 +++++++++++++++++++++++++++ client/mapview_common.h | 2 ++ client/tilespec.c | 21 ++++++++++++++------- data/amplio/terrain1.spec | 2 +- data/amplio2/terrain1.spec | 2 +- data/hex2t/tiles.spec | 2 +- data/hexemplio/terrain.spec | 2 +- data/isophex/terrain1.spec | 2 +- data/isotrident/terrain1.spec | 2 +- data/trident/tiles.spec | 2 +- 11 files changed, 55 insertions(+), 14 deletions(-) diff --git a/client/gui-gtk-3.22/infradlg.c b/client/gui-gtk-3.22/infradlg.c index 0d56544142..1407773af3 100644 --- a/client/gui-gtk-3.22/infradlg.c +++ b/client/gui-gtk-3.22/infradlg.c @@ -27,6 +27,7 @@ /* client */ #include "client_main.h" #include "dialogs_g.h" +#include "mapview_common.h" /* client/gui-gtk3.22 */ #include "gui_main.h" @@ -62,6 +63,8 @@ static void infra_response_callback(GtkWidget *dlg, gint arg) points_label = NULL; infra_rows = 0; + client_infratile_set(NULL); + gtk_widget_destroy(dlg); } @@ -165,6 +168,8 @@ void infra_placement_set_tile(struct tile *ptile) return; } + client_infratile_set(ptile); + extra_type_iterate(pextra) { if (player_can_place_extra(pextra, client.conn.playing, ptile)) { GtkWidget *but = gtk_button_new_with_label(extra_name_translation(pextra)); diff --git a/client/mapview_common.c b/client/mapview_common.c index d9d93a1d5e..3f66dbe5b2 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -78,6 +78,8 @@ static bool frame_by_frame_animation = FALSE; struct tile *center_tile = NULL; +struct tile *infratile = NULL; + static void base_canvas_to_map_pos(int *map_x, int *map_y, float canvas_x, float canvas_y); @@ -4026,3 +4028,28 @@ void set_frame_by_frame_animation(void) { frame_by_frame_animation = TRUE; } + +/************************************************************************//** + Return currently selected infratile, if any +****************************************************************************/ +struct tile *client_infratile(void) +{ + return infratile; +} + +/************************************************************************//** + Select specific infratile +****************************************************************************/ +void client_infratile_set(struct tile *ptile) +{ + struct tile *old_tile = infratile; + + infratile = ptile; + + if (old_tile != NULL) { + refresh_tile_mapcanvas(old_tile, FALSE, TRUE); + } + if (ptile != NULL) { + refresh_tile_mapcanvas(ptile, FALSE, TRUE); + } +} diff --git a/client/mapview_common.h b/client/mapview_common.h index 30be5c73df..b5a534494e 100644 --- a/client/mapview_common.h +++ b/client/mapview_common.h @@ -59,6 +59,8 @@ bool mapdeco_is_gotoline_set(const struct tile *ptile, enum direction8 dir); void mapdeco_clear_gotoroutes(void); +struct tile *client_infratile(void); +void client_infratile_set(struct tile *ptile); extern struct view mapview; diff --git a/client/tilespec.c b/client/tilespec.c index bf06adaacd..10256828ce 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -318,6 +318,7 @@ struct named_sprites { } path; struct { struct sprite *attention; + struct sprite *infratile; } user; struct { struct sprite @@ -3192,6 +3193,7 @@ static void tileset_lookup_sprite_tags(struct tileset *t) t->max_upkeep_height = calculate_max_upkeep_height(t); SET_SPRITE(user.attention, "user.attention"); + SET_SPRITE(user.infratile, "user.infratile"); SET_SPRITE_OPT(path.s[GTS_MP_LEFT].specific, "path.normal"); SET_SPRITE_OPT(path.s[GTS_EXHAUSTED_MP].specific, "path.exhausted_mp"); @@ -6065,13 +6067,18 @@ int fill_sprite_array(struct tileset *t, break; case LAYER_INFRAWORK: - if (ptile != NULL && ptile->placing != NULL) { - const int id = extra_index(ptile->placing); - - if (t->sprites.extras[id].activity != NULL) { - ADD_SPRITE(t->sprites.extras[id].activity, - TRUE, FULL_TILE_X_OFFSET + t->activity_offset_x, - FULL_TILE_Y_OFFSET + t->activity_offset_y); + if (ptile != NULL) { + if (ptile->placing != NULL) { + const int id = extra_index(ptile->placing); + + if (t->sprites.extras[id].activity != NULL) { + ADD_SPRITE(t->sprites.extras[id].activity, + TRUE, FULL_TILE_X_OFFSET + t->activity_offset_x, + FULL_TILE_Y_OFFSET + t->activity_offset_y); + } + } + if (client_infratile() == ptile) { + ADD_SPRITE_SIMPLE(t->sprites.user.infratile); } } break; diff --git a/data/amplio/terrain1.spec b/data/amplio/terrain1.spec index dc81132bd9..e271bd5dfa 100644 --- a/data/amplio/terrain1.spec +++ b/data/amplio/terrain1.spec @@ -127,7 +127,7 @@ tiles = { "row", "column", "tag" 7, 0, "t.blend.arctic" ;ice over neighbors 15, 3, "t.blend.coast" 15, 3, "t.blend.lake" - 15, 4, "user.attention" + 15, 4, "user.attention", "user.infratile" 15, 5, "tx.fog" ;goto path sprites diff --git a/data/amplio2/terrain1.spec b/data/amplio2/terrain1.spec index 5bd351e13d..bf865b277e 100644 --- a/data/amplio2/terrain1.spec +++ b/data/amplio2/terrain1.spec @@ -129,7 +129,7 @@ tiles = { "row", "column", "tag" 7, 0, "t.blend.arctic" ;ice over neighbors 15, 3, "t.blend.coast" 15, 3, "t.blend.lake" - 15, 4, "user.attention" + 15, 4, "user.attention", "user.infratile" 15, 5, "tx.fog" ;goto path sprites diff --git a/data/hex2t/tiles.spec b/data/hex2t/tiles.spec index ab595f8023..2c313f87cd 100644 --- a/data/hex2t/tiles.spec +++ b/data/hex2t/tiles.spec @@ -144,7 +144,7 @@ tiles = { "row", "column","tag" 7, 2, "mask.tile" 7, 3, "t.coast_color" - 7, 4, "user.attention" + 7, 4, "user.attention", "user.infratile" 7, 5, "tx.fog" ; darkness diff --git a/data/hexemplio/terrain.spec b/data/hexemplio/terrain.spec index f598cd7883..215f807bba 100644 --- a/data/hexemplio/terrain.spec +++ b/data/hexemplio/terrain.spec @@ -118,7 +118,7 @@ tiles = { "row", "column","tag" 5, 0, "t.blend.floor" 5, 0, "t.blend.lake" 0, 4, "t.blend.arctic" ;[?] - 5, 3, "user.attention" ;[GS] + 5, 3, "user.attention", "user.infratile" ;[GS] 5, 4, "tx.fog" ; 5, 6, "t.l0.charcoal1" ;[?] ; 5, 7, "t.l0.compass1" ;[CA][PA] diff --git a/data/isophex/terrain1.spec b/data/isophex/terrain1.spec index 968903b289..8a3c002b07 100644 --- a/data/isophex/terrain1.spec +++ b/data/isophex/terrain1.spec @@ -134,7 +134,7 @@ tiles = { "row", "column","tag" 5, 0, "t.blend.ocean" 5, 1, "t.dither_tile" 5, 1, "tx.darkness" - 5, 3, "user.attention" + 5, 3, "user.attention", "user.infratile" 5, 4, "tx.fog" 5, 5, "mask.tile" diff --git a/data/isotrident/terrain1.spec b/data/isotrident/terrain1.spec index 8df8ece60e..64838fb21d 100644 --- a/data/isotrident/terrain1.spec +++ b/data/isotrident/terrain1.spec @@ -148,7 +148,7 @@ tiles = { "row", "column","tag" 0, 2, "t.unknown1" 0, 3, "t.blend.ocean" 0, 3, "t.blend.coast" - 0, 4, "user.attention" + 0, 4, "user.attention", "user.infratile" 0, 5, "tx.fog" 1, 0, "path.step" ; turn boundary within path diff --git a/data/trident/tiles.spec b/data/trident/tiles.spec index 9e59f2ec45..bcdc495d43 100644 --- a/data/trident/tiles.spec +++ b/data/trident/tiles.spec @@ -576,7 +576,7 @@ tiles = { "row", "column", "tag" 5, 16, "unit.tired" 5, 16, "unit.lowfuel" 5, 17, "unit.loaded" - 5, 18, "user.attention" ; Variously crosshair/red-square/arrows + 5, 18, "user.attention", "user.infratile" ; Variously crosshair/red-square/arrows 5, 19, "unit.stack" ; Goto path: -- 2.33.0