From 065931be4490d436d19c375a7912e418a5d1480c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 22 Oct 2022 04:08:50 +0300 Subject: [PATCH 8/8] sdl/2: Fix Tile menu "Patrol Here" See osdn #45925 Signed-off-by: Marko Lindqvist --- client/gui-sdl/dialogs.c | 33 +++++++++++++++++---------------- client/gui-sdl2/dialogs.c | 29 +++++++++++++++-------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/client/gui-sdl/dialogs.c b/client/gui-sdl/dialogs.c index 1648f210d6..2c4337aa65 100644 --- a/client/gui-sdl/dialogs.c +++ b/client/gui-sdl/dialogs.c @@ -1554,28 +1554,29 @@ static int goto_here_callback(struct widget *pWidget) /************************************************************************** Initiate patrol to selected tile. **************************************************************************/ -static int patrol_here_callback(struct widget *pWidget) +static int patrol_here_callback(struct widget *pwidget) { if (Main.event.button.button == SDL_BUTTON_LEFT) { - -/* FIXME */ -#if 0 - int x = pWidget->data.cont->id0; - int y = pWidget->data.cont->id1; - struct unit *pUnit = head_of_units_in_focus(); -#endif + int x = pwidget->data.cont->id0; + int y = pwidget->data.cont->id1; + struct tile *ptile; - popdown_advanced_terrain_dialog(); - -#if 0 - if(pUnit) { - enter_goto_state(pUnit); - /* may not work */ - do_unit_patrol_to(pUnit, map_pos_to_tile(x, y)); + ptile = map_pos_to_tile(x, y); + + if (ptile != NULL) { + struct unit_list *punits = get_units_in_focus(); + + set_hover_state(punits, HOVER_PATROL, ACTIVITY_LAST, NULL, + ORDER_LAST); + update_unit_info_label(punits); + enter_goto_state(punits); + do_unit_patrol_to(ptile); exit_goto_state(); } -#endif /* 0 */ + + popdown_advanced_terrain_dialog(); } + return -1; } diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index 7782c542f6..d10020cb19 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -1562,28 +1562,29 @@ static int goto_here_callback(struct widget *pWidget) /************************************************************************** Initiate patrol to selected tile. **************************************************************************/ -static int patrol_here_callback(struct widget *pWidget) +static int patrol_here_callback(struct widget *pwidget) { if (PRESSED_EVENT(Main.event)) { + int x = pwidget->data.cont->id0; + int y = pwidget->data.cont->id1; + struct tile *ptile; -/* FIXME */ -#if 0 - int x = pWidget->data.cont->id0; - int y = pWidget->data.cont->id1; - struct unit *pUnit = head_of_units_in_focus(); -#endif + ptile = map_pos_to_tile(x, y); - popdown_advanced_terrain_dialog(); + if (ptile != NULL) { + struct unit_list *punits = get_units_in_focus(); -#if 0 - if (pUnit) { - enter_goto_state(pUnit); - /* may not work */ - do_unit_patrol_to(pUnit, map_pos_to_tile(x, y)); + set_hover_state(punits, HOVER_PATROL, ACTIVITY_LAST, NULL, + ORDER_LAST); + update_unit_info_label(punits); + enter_goto_state(punits); + do_unit_patrol_to(ptile); exit_goto_state(); } -#endif /* 0 */ + + popdown_advanced_terrain_dialog(); } + return -1; } -- 2.35.1