From 26ec3e1920f1b001293cf12a847aad4396f9ea70 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 5 Nov 2022 01:40:06 +0200 Subject: [PATCH 25/25] Qt: Separate paradrop from clean pollution See osdn #46025 Signed-off-by: Marko Lindqvist --- client/gui-qt/menu.cpp | 53 +++++++++++++++++++++---------------- client/gui-qt/menu.h | 22 ++++++++------- client/gui-qt/shortcuts.cpp | 9 ++++--- client/gui-qt/shortcuts.h | 7 ++--- 4 files changed, 51 insertions(+), 40 deletions(-) diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index a3385b7f02..01aafc379a 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -1279,6 +1279,11 @@ void mr_menu::setup_menus() connect(act, &QAction::triggered, this, &mr_menu::slot_unit_airbase); bases_menu = main_menu->addMenu(_("Build Base")); main_menu->addSeparator(); + act = main_menu->addAction(_("Paradrop")); + menu_list.insert(PARADROP, act); + act->setShortcut(QKeySequence(shortcut_to_string( + fc_shortcuts::sc()->get_shortcut(SC_PARADROP)))); + connect(act, &QAction::triggered, this, &mr_menu::slot_paradrop); act = main_menu->addAction(_("Pillage")); menu_list.insert(PILLAGE, act); act->setShortcut(QKeySequence(tr("shift+p"))); @@ -1350,9 +1355,9 @@ void mr_menu::setup_menus() fc_shortcuts::sc()->get_shortcut(SC_TRANSFORM)))); connect(act, &QAction::triggered, this, &mr_menu::slot_transform); act = main_menu->addAction(_("Clean Pollution")); - menu_list.insert(POLLUTION, act); + menu_list.insert(CLEAN, act); act->setShortcut(QKeySequence(shortcut_to_string( - fc_shortcuts::sc()->get_shortcut(SC_PARADROP)))); + fc_shortcuts::sc()->get_shortcut(SC_CLEAN)))); connect(act, &QAction::triggered, this, &mr_menu::slot_clean_pollution); act = main_menu->addAction(_("Clean Nuclear Fallout")); menu_list.insert(FALLOUT, act); @@ -2330,22 +2335,10 @@ void mr_menu::menus_sensitive() } break; - case POLLUTION: - if (can_units_do_activity(punits, ACTIVITY_POLLUTION) - || can_units_do(punits, can_unit_paradrop)) { + case CLEAN: + if (can_units_do_activity(punits, ACTIVITY_POLLUTION)) { i.value()->setEnabled(true); } - if (units_can_do_action_with_result(punits, ACTRES_PARADROP, - true) - || units_can_do_action_with_result(punits, - ACTRES_PARADROP_CONQUER, - true)) { - i.value()->setText( - QString(action_id_name_translation(ACTION_PARADROP)) - .replace("&", "&&")); - } else { - i.value()->setText(_("Clean Pollution")); - } break; case FALLOUT: @@ -2360,6 +2353,14 @@ void mr_menu::menus_sensitive() } break; + case PARADROP: + if (can_units_do(punits, can_unit_paradrop)) { + i.value()->setEnabled(true); + i.value()->setText(QString(action_id_name_translation(ACTION_PARADROP)) + .replace("&", "&&")); + } + break; + case PILLAGE: if (can_units_do_activity(punits, ACTIVITY_PILLAGE)) { i.value()->setEnabled(true); @@ -2574,23 +2575,17 @@ void mr_menu::slot_clean_fallout() } /**********************************************************************//** - Action "CLEAN POLLUTION and PARADROP" + Action "CLEAN POLLUTION" **************************************************************************/ void mr_menu::slot_clean_pollution() { 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, unit_owner(punit), punit); 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; } @@ -2665,6 +2660,18 @@ void mr_menu::slot_transform() key_unit_transform(); } +/**********************************************************************//** + Action "PARADROP" +**************************************************************************/ +void mr_menu::slot_paradrop() +{ + unit_list_iterate(get_units_in_focus(), punit) { + if (can_unit_paradrop(punit)) { + key_unit_paradrop(); + } + } unit_list_iterate_end; +} + /**********************************************************************//** Action "PILLAGE" **************************************************************************/ diff --git a/client/gui-qt/menu.h b/client/gui-qt/menu.h index 09b80eb21f..3495372d2b 100644 --- a/client/gui-qt/menu.h +++ b/client/gui-qt/menu.h @@ -49,13 +49,14 @@ enum munit { IRRIGATION, CULTIVATE, TRANSFORM, + PARADROP, PILLAGE, BUILD, ROAD, FORTIFY, FORTRESS, AIRBASE, - POLLUTION, + CLEAN, FALLOUT, SENTRY, HOMECITY, @@ -291,7 +292,7 @@ public: bool quick_airlifting; Unit_type_id airlift_type_id; private slots: - // game menu + // Game menu void local_options(); void shortcut_options(); void server_options(); @@ -306,10 +307,10 @@ private slots: bool confirm_disruptive_selection(); void quit_game(); - // help menu + // Help menu void slot_help(const QString &topic); - // used by work menu + // Used by work menu void slot_build_path(int id); void slot_build_base(int id); void slot_build_city(); @@ -326,7 +327,7 @@ private slots: void slot_clean_pollution(); void slot_clean_fallout(); - // used by unit menu + // Used by unit menu void slot_unit_sentry(); void slot_unit_explore(); void slot_unit_goto(); @@ -342,14 +343,15 @@ private slots: void slot_convert(); void slot_disband(); - // used by combat menu + // Used by combat menu void slot_unit_fortify(); void slot_unit_fortress(); void slot_unit_airbase(); + void slot_paradrop(); void slot_pillage(); void slot_action(); - // used by view menu + // Used by view menu void slot_center_view(); void slot_minimap_view(); void slot_show_new_turn_text(); @@ -373,7 +375,7 @@ private slots: void zoom_reset(); void zoom_out(); - // used by select menu + // Used by select menu void slot_select_one(); void slot_select_all_tile(); void slot_select_same_tile(); @@ -383,7 +385,7 @@ private slots: void slot_wait(); void slot_unit_filter(); - // used by multiplayer menu + // Used by multiplayer menu void slot_orders_clear(); void slot_execute_orders(); void slot_delayed_goto(); @@ -398,7 +400,7 @@ private slots: void slot_action_vs_unit(); void slot_action_vs_city(); - // used by civilization menu + // Used by civilization menu void slot_show_map(); void calc_trade_routes(); void slot_popup_tax_rates(); diff --git a/client/gui-qt/shortcuts.cpp b/client/gui-qt/shortcuts.cpp index f34a5e784f..51f79efd98 100644 --- a/client/gui-qt/shortcuts.cpp +++ b/client/gui-qt/shortcuts.cpp @@ -148,8 +148,8 @@ fc_shortcut default_shortcuts[] = { | Qt::ShiftModifier, _("Lock/unlock interface") }, {SC_AUTOMATE, Qt::Key_A, Qt::AllButtons, Qt::NoModifier, _("Auto worker") }, - {SC_PARADROP, Qt::Key_P, Qt::AllButtons, Qt::NoModifier, - _("Paradrop/clean pollution") }, + {SC_CLEAN, Qt::Key_P, Qt::AllButtons, Qt::NoModifier, + _("Clean pollution") }, {SC_POPUP_COMB_INF, Qt::Key_F1, Qt::AllButtons, Qt::ControlModifier, _("Popup combat information") }, {SC_RELOAD_THEME, Qt::Key_F5, Qt::AllButtons, Qt::ControlModifier @@ -173,10 +173,11 @@ fc_shortcut default_shortcuts[] = { {SC_GOJOINCITY, Qt::Key_J, Qt::AllButtons, Qt::ShiftModifier, _("Go And Join City") }, {SC_STACK_SIZE, Qt::Key_Plus, Qt::AllButtons, Qt::ControlModifier, - _("Unit Stack Size") } + _("Unit Stack Size") }, + {SC_PARADROP, Qt::Key_J, Qt::AllButtons, Qt::NoModifier, + _("Paradrop") } }; - /**********************************************************************//** Returns shortcut as string (eg. for menu) **************************************************************************/ diff --git a/client/gui-qt/shortcuts.h b/client/gui-qt/shortcuts.h index 884ebe78f2..3520a56bdc 100644 --- a/client/gui-qt/shortcuts.h +++ b/client/gui-qt/shortcuts.h @@ -79,7 +79,7 @@ enum shortcut_id { SC_BUY_MAP = 45, SC_IFACE_LOCK = 46, SC_AUTOMATE = 47, - SC_PARADROP = 48, + SC_CLEAN = 48, SC_POPUP_COMB_INF = 49, SC_RELOAD_THEME = 50, SC_RELOAD_TILESET = 51, @@ -91,10 +91,11 @@ enum shortcut_id { SC_ZOOM_RESET = 57, SC_GOBUILDCITY = 58, SC_GOJOINCITY = 59, - SC_STACK_SIZE = 60 + SC_STACK_SIZE = 60, + SC_PARADROP = 61 }; -#define SC_NUM_SHORTCUTS 60 +#define SC_NUM_SHORTCUTS 61 /************************************************************************** -- 2.35.1