From 84ff079a482178a00ef696efc200d2d046152db7 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 28 Oct 2022 19:58:53 +0300 Subject: [PATCH 33/33] Give paradrop a key distinct from cleaning pollution Qt-client not changed. Other clients now use 'j' (Jump) for paradrop. In case of gtk4-client this is first time paradrop functionality gets enabled. See osdn #45958 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/menu.c | 32 ++++++++++++++------------------ client/gui-gtk-3.22/menu.c | 31 ++++++++++++++----------------- client/gui-gtk-4.0/menu.c | 34 +++++++++++++++++++--------------- client/gui-sdl2/menu.c | 4 ++-- data/gtk3.22_menus.xml | 3 +++ data/gtk3_menus.xml | 3 +++ data/helpdata.txt | 2 +- 7 files changed, 56 insertions(+), 53 deletions(-) diff --git a/client/gui-gtk-3.0/menu.c b/client/gui-gtk-3.0/menu.c index 388888407a..7ac59d7643 100644 --- a/client/gui-gtk-3.0/menu.c +++ b/client/gui-gtk-3.0/menu.c @@ -242,6 +242,7 @@ static void clean_fallout_callback(GtkMenuItem *item, gpointer data); static void fortify_callback(GtkMenuItem *item, gpointer data); static void build_fortress_callback(GtkMenuItem *item, gpointer data); static void build_airbase_callback(GtkMenuItem *item, gpointer data); +static void do_paradrop_callback(GtkMenuItem *item, gpointer data); static void do_pillage_callback(GtkMenuItem *item, gpointer data); static void diplomat_action_callback(GtkMenuItem *item, gpointer data); @@ -526,6 +527,8 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(build_fortress_callback), MGROUP_UNIT }, { "BUILD_AIRBASE", N_("Build Airbase"), GDK_KEY_e, GDK_SHIFT_MASK, G_CALLBACK(build_airbase_callback), MGROUP_UNIT }, + { "DO_PARADROP", N_("P_aradrop"), GDK_KEY_j, 0, + G_CALLBACK(do_paradrop_callback), MGROUP_UNIT }, { "DO_PILLAGE", N_("_Pillage"), GDK_KEY_p, GDK_SHIFT_MASK, G_CALLBACK(do_pillage_callback), MGROUP_UNIT }, { "DIPLOMAT_ACTION", N_("_Do..."), GDK_KEY_d, 0, @@ -1696,8 +1699,6 @@ static void transform_terrain_callback(GtkMenuItem *action, gpointer data) static void clean_pollution_callback(GtkMenuItem *action, gpointer data) { unit_list_iterate(get_units_in_focus(), punit) { - /* FIXME: this can provide different actions for different units... - * not good! */ struct extra_type *pextra; pextra = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION, @@ -1705,10 +1706,6 @@ static void clean_pollution_callback(GtkMenuItem *action, gpointer data) if (pextra != NULL) { request_new_unit_activity_targeted(punit, ACTIVITY_POLLUTION, pextra); - } else if (can_unit_paradrop(punit)) { - /* FIXME: This is getting worse, we use a key_unit_*() function - * which assign the order for all units! Very bad! */ - key_unit_paradrop(); } } unit_list_iterate_end; } @@ -1747,6 +1744,14 @@ static void build_airbase_callback(GtkMenuItem *action, gpointer data) key_unit_airbase(); } +/************************************************************************//** + Action "DO_PARADROP" callback. +****************************************************************************/ +static void do_paradrop_callback(GtkMenuItem *action, gpointer data) +{ + key_unit_paradrop(); +} + /************************************************************************//** Action "DO_PILLAGE" callback. ****************************************************************************/ @@ -2317,12 +2322,13 @@ void real_menus_update(void) menu_entry_set_sensitive("BUILD_AIRBASE", can_units_do_base_gui(punits, BASE_GUI_AIRBASE)); menu_entry_set_sensitive("CLEAN_POLLUTION", - (can_units_do_activity(punits, ACTIVITY_POLLUTION) - || can_units_do(punits, can_unit_paradrop))); + can_units_do_activity(punits, ACTIVITY_POLLUTION)); menu_entry_set_sensitive("CLEAN_FALLOUT", can_units_do_activity(punits, ACTIVITY_FALLOUT)); menu_entry_set_sensitive("UNIT_SENTRY", can_units_do_activity(punits, ACTIVITY_SENTRY)); + menu_entry_set_sensitive("DO_PARADROP", + can_units_do(punits, can_unit_paradrop)); /* FIXME: should conditionally rename "Pillage" to "Pillage..." in cases where * selecting the command results in a dialog box listing options of what to pillage */ menu_entry_set_sensitive("DO_PILLAGE", @@ -2572,16 +2578,6 @@ void real_menus_update(void) menus_rename("BUILD_MINE", mintext); menus_rename("PLANT", plantext); menus_rename("TRANSFORM_TERRAIN", transtext); - - if (units_can_do_action_with_result(punits, ACTRES_PARADROP, TRUE) - || units_can_do_action_with_result(punits, ACTRES_PARADROP_CONQUER, - TRUE)) { - menus_rename("CLEAN_POLLUTION", - action_get_ui_name_mnemonic(ACTION_PARADROP, "_")); - } else { - menus_rename("CLEAN_POLLUTION", _("Clean _Pollution")); - } - menus_rename("UNIT_HOMECITY", action_get_ui_name_mnemonic(ACTION_HOME_CITY, "_")); } diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index d3aadd5694..659bca9e5a 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -245,6 +245,7 @@ static void clean_fallout_callback(GtkMenuItem *item, gpointer data); static void fortify_callback(GtkMenuItem *item, gpointer data); static void build_fortress_callback(GtkMenuItem *item, gpointer data); static void build_airbase_callback(GtkMenuItem *item, gpointer data); +static void do_paradrop_callback(GtkMenuItem *item, gpointer data); static void do_pillage_callback(GtkMenuItem *item, gpointer data); static void diplomat_action_callback(GtkMenuItem *item, gpointer data); @@ -533,6 +534,8 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(build_fortress_callback), MGROUP_UNIT }, { "BUILD_AIRBASE", N_("Build Airbase"), GDK_KEY_e, GDK_SHIFT_MASK, G_CALLBACK(build_airbase_callback), MGROUP_UNIT }, + { "DO_PARADROP", N_("P_aradrop"), GDK_KEY_j, 0, + G_CALLBACK(do_paradrop_callback), MGROUP_UNIT }, { "DO_PILLAGE", N_("_Pillage"), GDK_KEY_p, GDK_SHIFT_MASK, G_CALLBACK(do_pillage_callback), MGROUP_UNIT }, { "DIPLOMAT_ACTION", N_("_Do..."), GDK_KEY_d, 0, @@ -1719,8 +1722,6 @@ static void transform_terrain_callback(GtkMenuItem *action, gpointer data) static void clean_pollution_callback(GtkMenuItem *action, gpointer data) { unit_list_iterate(get_units_in_focus(), punit) { - /* FIXME: this can provide different actions for different units... - * not good! */ struct extra_type *pextra; pextra = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION, @@ -1728,10 +1729,6 @@ static void clean_pollution_callback(GtkMenuItem *action, gpointer data) if (pextra != NULL) { request_new_unit_activity_targeted(punit, ACTIVITY_POLLUTION, pextra); - } else if (can_unit_paradrop(punit)) { - /* FIXME: This is getting worse, we use a key_unit_*() function - * which assign the order for all units! Very bad! */ - key_unit_paradrop(); } } unit_list_iterate_end; } @@ -1770,6 +1767,14 @@ static void build_airbase_callback(GtkMenuItem *action, gpointer data) key_unit_airbase(); } +/************************************************************************//** + Action "DO_PARADROP" callback. +****************************************************************************/ +static void do_paradrop_callback(GtkMenuItem *action, gpointer data) +{ + key_unit_paradrop(); +} + /************************************************************************//** Action "DO_PILLAGE" callback. ****************************************************************************/ @@ -2342,12 +2347,13 @@ void real_menus_update(void) menu_entry_set_sensitive("BUILD_AIRBASE", can_units_do_base_gui(punits, BASE_GUI_AIRBASE)); menu_entry_set_sensitive("CLEAN_POLLUTION", - (can_units_do_activity(punits, ACTIVITY_POLLUTION) - || can_units_do(punits, can_unit_paradrop))); + can_units_do_activity(punits, ACTIVITY_POLLUTION)); menu_entry_set_sensitive("CLEAN_FALLOUT", can_units_do_activity(punits, ACTIVITY_FALLOUT)); menu_entry_set_sensitive("UNIT_SENTRY", can_units_do_activity(punits, ACTIVITY_SENTRY)); + menu_entry_set_sensitive("DO_PARADROP", + can_units_do(punits, can_unit_paradrop)); /* FIXME: should conditionally rename "Pillage" to "Pillage..." in cases where * selecting the command results in a dialog box listing options of what to pillage */ menu_entry_set_sensitive("DO_PILLAGE", @@ -2598,15 +2604,6 @@ void real_menus_update(void) menus_rename("PLANT", plantext); menus_rename("TRANSFORM_TERRAIN", transtext); - if (units_can_do_action_with_result(punits, ACTRES_PARADROP, TRUE) - || units_can_do_action_with_result(punits, ACTRES_PARADROP_CONQUER, - TRUE)) { - menus_rename("CLEAN_POLLUTION", - action_get_ui_name_mnemonic(ACTION_PARADROP, "_")); - } else { - menus_rename("CLEAN_POLLUTION", _("Clean _Pollution")); - } - menus_rename("UNIT_HOMECITY", action_get_ui_name_mnemonic(ACTION_HOME_CITY, "_")); } diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index 6335150405..59c4fa265f 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -343,6 +343,9 @@ static void plant_callback(GSimpleAction *action, GVariant *parameter, gpointer data); +static void paradrop_callback(GSimpleAction *action, + GVariant *parameter, + gpointer data); static void pillage_callback(GSimpleAction *action, GVariant *parameter, gpointer data); @@ -428,6 +431,8 @@ static struct menu_entry_info menu_entries[] = /* Combat menu */ { "FORTIFY", N_("Fortify"), "fortify", "f", MGROUP_UNIT }, + { "PARADROP", N_("P_aradrop"), + "paradrop", "j", MGROUP_UNIT }, { "PILLAGE", N_("_Pillage"), "pillage", "p", MGROUP_UNIT }, @@ -754,6 +759,7 @@ const GActionEntry acts[] = { { "plant", plant_callback }, { "fortify", fortify_callback }, + { "paradrop", paradrop_callback }, { "pillage", pillage_callback }, { "revolution", revolution_callback }, @@ -2030,8 +2036,6 @@ static void transform_terrain_callback(GtkMenuItem *action, gpointer data) static void clean_pollution_callback(GtkMenuItem *action, gpointer data) { unit_list_iterate(get_units_in_focus(), punit) { - /* FIXME: this can provide different actions for different units... - * not good! */ struct extra_type *pextra; pextra = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION, @@ -2039,10 +2043,6 @@ static void clean_pollution_callback(GtkMenuItem *action, gpointer data) if (pextra != NULL) { request_new_unit_activity_targeted(punit, ACTIVITY_POLLUTION, pextra); - } else if (can_unit_paradrop(punit)) { - /* FIXME: This is getting worse, we use a key_unit_*() function - * which assign the order for all units! Very bad! */ - key_unit_paradrop(); } } unit_list_iterate_end; } @@ -2072,6 +2072,16 @@ static void build_airbase_callback(GtkMenuItem *action, gpointer data) } #endif /* MENUS_GTK3 */ +/************************************************************************//** + Action "PARADROP" callback. +****************************************************************************/ +static void paradrop_callback(GSimpleAction *action, + GVariant *parameter, + gpointer data) +{ + key_unit_paradrop(); +} + /************************************************************************//** Action "PILLAGE" callback. ****************************************************************************/ @@ -2439,6 +2449,7 @@ static GMenu *setup_menus(GtkApplication *app) g_menu_append_submenu(menubar, _("_Combat"), G_MENU_MODEL(combat_menu)); + menu_entry_init(combat_menu, "PARADROP"); menu_entry_init(combat_menu, "PILLAGE"); gov_menu = g_menu_new(); @@ -3153,6 +3164,8 @@ void real_menus_update(void) menu_entry_set_sensitive(map, "FORTIFY", can_units_do_activity(punits, ACTIVITY_FORTIFYING)); + menu_entry_set_sensitive(map, "PARADROP", + can_units_do(punits, can_unit_paradrop)); menu_entry_set_sensitive(map, "PILLAGE", can_units_do_activity(punits, ACTIVITY_PILLAGE)); @@ -3418,15 +3431,6 @@ void real_menus_update(void) menus_rename("PLANT", plantext); menus_rename("TRANSFORM_TERRAIN", transtext); - if (units_can_do_action_with_result(punits, ACTRES_PARADROP, TRUE) - || units_can_do_action_with_result(punits, ACTRES_PARADROP_CONQUER, - TRUE)) { - menus_rename("CLEAN_POLLUTION", - action_get_ui_name_mnemonic(ACTION_PARADROP, "_")); - } else { - menus_rename("CLEAN_POLLUTION", _("Clean _Pollution")); - } - menus_rename("UNIT_HOMECITY", action_get_ui_name_mnemonic(ACTION_HOME_CITY, "_")); diff --git a/client/gui-sdl2/menu.c b/client/gui-sdl2/menu.c index 1dbd0971a4..ffa99ebb13 100644 --- a/client/gui-sdl2/menu.c +++ b/client/gui-sdl2/menu.c @@ -746,14 +746,14 @@ void create_units_order_widgets(void) /* Paradrop */ fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)", - action_id_name_translation(ACTION_PARADROP), "P"); + action_id_name_translation(ACTION_PARADROP), "J"); buf = create_themeicon(current_theme->o_paradrop_icon, main_data.gui, WF_HIDDEN | WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); - buf->key = SDLK_p; + buf->key = SDLK_j; add_to_gui_list(ID_UNIT_ORDER_PARADROP, buf); /* --------- */ diff --git a/data/gtk3.22_menus.xml b/data/gtk3.22_menus.xml index ca3e2abf42..b62c87f7e8 100644 --- a/data/gtk3.22_menus.xml +++ b/data/gtk3.22_menus.xml @@ -410,6 +410,9 @@ + + + diff --git a/data/gtk3_menus.xml b/data/gtk3_menus.xml index 9303f60a32..531ed54a34 100644 --- a/data/gtk3_menus.xml +++ b/data/gtk3_menus.xml @@ -404,6 +404,9 @@ + + + diff --git a/data/helpdata.txt b/data/helpdata.txt index d00aeced2f..737127bf61 100644 --- a/data/helpdata.txt +++ b/data/helpdata.txt @@ -1651,6 +1651,7 @@ Unit Orders:\n\ I: change terrain by cultivating\n\ Ctrl+I: connect current and target tile with (I)rrigation\n\ Ctrl+I: set an (I)rrigation waypoint (when connecting with irrigation)\n\ + j: drop paratrooper (paratroop units)\n\ l: (l)oad unit on transporter\n\ Ctrl+L: connect current and target tile with rai(L)\n\ Ctrl+L: set a rai(L) waypoint (when connecting with rail)\n\ @@ -1661,7 +1662,6 @@ Unit Orders:\n\ o: transf(o)rm terrain (engineer unit)\n\ O: c(O)nvert to another kind of unit\n\ p: clean (p)ollution (settler/worker units)\n\ - p: drop (p)aratrooper (paratroop units)\n\ P: (P)illage (destroy terrain alteration)\n\ q: patrol with unit (then left-click mouse to select other endpoint)\n\ q: add a patrol waypoint (when in patrol mode)\n\ -- 2.35.1