From 3bacb3dd473a721ac638d739b552e589684b1dd6 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 27 Nov 2022 23:58:09 +0200 Subject: [PATCH 4/4] sdl/2: Fix Tile menu "Paradrop Here" See osdn #45981 Signed-off-by: Marko Lindqvist --- client/gui-sdl/dialogs.c | 35 +++++++++++++++++++++++------------ client/gui-sdl2/dialogs.c | 33 ++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/client/gui-sdl/dialogs.c b/client/gui-sdl/dialogs.c index 2c4337aa65..e9ab02b064 100644 --- a/client/gui-sdl/dialogs.c +++ b/client/gui-sdl/dialogs.c @@ -1583,22 +1583,33 @@ static int patrol_here_callback(struct widget *pwidget) /************************************************************************** Initiate paradrop to selected tile. **************************************************************************/ -static int paradrop_here_callback(struct widget *pWidget) +static int paradrop_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; -#endif - - popdown_advanced_terrain_dialog(); + int x = pwidget->data.cont->id0; + int y = pwidget->data.cont->id1; + struct tile *ptile; -#if 0 - /* may not work */ - do_unit_paradrop_to(get_unit_in_focus(), map_pos_to_tile(x, y)); -#endif + ptile = map_pos_to_tile(x, y); + + if (ptile != NULL) { + struct unit_list *punits = get_units_in_focus(); + + set_hover_state(punits, HOVER_PARADROP, ACTIVITY_LAST, NULL, + NO_TARGET, ACTION_NONE, ORDER_LAST); + update_unit_info_label(punits); + + unit_list_iterate(punits, punit) { + do_unit_paradrop_to(punit, ptile); + } unit_list_iterate_end; + + clear_hover_state(); + exit_goto_state(); + } + + popdown_advanced_terrain_dialog(); } + return -1; } diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index d10020cb19..be3aa11641 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -1591,22 +1591,33 @@ static int patrol_here_callback(struct widget *pwidget) /************************************************************************** Initiate paradrop to selected tile. **************************************************************************/ -static int paradrop_here_callback(struct widget *pWidget) +static int paradrop_here_callback(struct widget *pwidget) { if (PRESSED_EVENT(Main.event)) { -/* FIXME */ -#if 0 - int x = pWidget->data.cont->id0; - int y = pWidget->data.cont->id1; -#endif + int x = pwidget->data.cont->id0; + int y = pwidget->data.cont->id1; + struct tile *ptile; - popdown_advanced_terrain_dialog(); + ptile = map_pos_to_tile(x, y); -#if 0 - /* may not work */ - do_unit_paradrop_to(get_unit_in_focus(), map_pos_to_tile(x, y)); -#endif + if (ptile != NULL) { + struct unit_list *punits = get_units_in_focus(); + + set_hover_state(punits, HOVER_PARADROP, ACTIVITY_LAST, NULL, + NO_TARGET, ACTION_NONE, ORDER_LAST); + update_unit_info_label(punits); + + unit_list_iterate(punits, punit) { + do_unit_paradrop_to(punit, ptile); + } unit_list_iterate_end; + + clear_hover_state(); + exit_goto_state(); + } + + popdown_advanced_terrain_dialog(); } + return -1; } -- 2.35.1