From c4761e791054c3c5ac8bb21685e73d9389a9089e Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 26 Sep 2023 18:41:36 +0300 Subject: [PATCH 42/42] Qt: Add Battle Groups menu See osdn #48732 Signed-off-by: Marko Lindqvist --- client/gui-qt/menu.cpp | 148 +++++++++++++++++++++++++++++++++++++++++ client/gui-qt/menu.h | 12 ++++ data/helpdata.txt | 2 +- 3 files changed, 161 insertions(+), 1 deletion(-) diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index 0ba8dee2c6..90e7ef34c8 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -1374,6 +1374,7 @@ void mr_menu::setup_menus() menu_list.insert(ORDER_TRADE_ROUTE, act); connect(act, &QAction::triggered, this, &mr_menu::slot_build_road); + // Multiplayer Menu multiplayer_menu = this->addMenu(_("Multiplayer")); act = multiplayer_menu->addAction(_("Delayed Goto")); act->setShortcut(QKeySequence(tr("z"))); @@ -1580,6 +1581,57 @@ void mr_menu::setup_menus() menu_list.insert(ENDGAME, act); connect(act, &QAction::triggered, this, &mr_menu::slot_endgame); + // Battle Groups Menu + main_menu = this->addMenu(_("Battle Groups")); + + act = main_menu->addAction(_("Select Battle Group 1")); + act->setShortcut(QKeySequence(tr("Shift+F1"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg1select); + + act = main_menu->addAction(_("Assign Battle Group 1")); + act->setShortcut(QKeySequence(tr("Ctrl+F1"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg1assign); + + act = main_menu->addAction(_("Append Battle Group 1")); + act->setShortcut(QKeySequence(tr("Ctrl+Shift+F1"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg1append); + + act = main_menu->addAction(_("Select Battle Group 2")); + act->setShortcut(QKeySequence(tr("Shift+F2"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg2select); + + act = main_menu->addAction(_("Assign Battle Group 2")); + act->setShortcut(QKeySequence(tr("Ctrl+F2"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg2assign); + + act = main_menu->addAction(_("Append Battle Group 2")); + act->setShortcut(QKeySequence(tr("Ctrl+Shift+F2"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg2append); + + act = main_menu->addAction(_("Select Battle Group 3")); + act->setShortcut(QKeySequence(tr("Shift+F3"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg3select); + + act = main_menu->addAction(_("Assign Battle Group 3")); + act->setShortcut(QKeySequence(tr("Ctrl+F3"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg3assign); + + act = main_menu->addAction(_("Append Battle Group 3")); + act->setShortcut(QKeySequence(tr("Ctrl+Shift+F3"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg3append); + + act = main_menu->addAction(_("Select Battle Group 4")); + act->setShortcut(QKeySequence(tr("Shift+F4"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg4select); + + act = main_menu->addAction(_("Assign Battle Group 4")); + act->setShortcut(QKeySequence(tr("Ctrl+F4"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg4assign); + + act = main_menu->addAction(_("Append Battle Group 4")); + act->setShortcut(QKeySequence(tr("Ctrl+Shift+F4"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg4append); + // Help Menu main_menu = this->addMenu(_("Help")); @@ -3461,6 +3513,102 @@ void mr_menu::slot_traveler() send_report_request(REPORT_WONDERS_OF_THE_WORLD_LONG); } +/**********************************************************************//** + Select Battle Group 1 +**************************************************************************/ +void mr_menu::slot_bg1select() +{ + key_unit_select_battlegroup(0, FALSE); +} + +/**********************************************************************//** + Assign Battle Group 1 +**************************************************************************/ +void mr_menu::slot_bg1assign() +{ + key_unit_assign_battlegroup(0, FALSE); +} + +/**********************************************************************//** + Append Battle Group 1 +**************************************************************************/ +void mr_menu::slot_bg1append() +{ + key_unit_assign_battlegroup(0, TRUE); +} + +/**********************************************************************//** + Select Battle Group 2 +**************************************************************************/ +void mr_menu::slot_bg2select() +{ + key_unit_select_battlegroup(1, FALSE); +} + +/**********************************************************************//** + Assign Battle Group 2 +**************************************************************************/ +void mr_menu::slot_bg2assign() +{ + key_unit_assign_battlegroup(1, FALSE); +} + +/**********************************************************************//** + Append Battle Group 2 +**************************************************************************/ +void mr_menu::slot_bg2append() +{ + key_unit_assign_battlegroup(1, TRUE); +} + +/**********************************************************************//** + Select Battle Group 3 +**************************************************************************/ +void mr_menu::slot_bg3select() +{ + key_unit_select_battlegroup(2, FALSE); +} + +/**********************************************************************//** + Assign Battle Group 3 +**************************************************************************/ +void mr_menu::slot_bg3assign() +{ + key_unit_assign_battlegroup(2, FALSE); +} + +/**********************************************************************//** + Append Battle Group 3 +**************************************************************************/ +void mr_menu::slot_bg3append() +{ + key_unit_assign_battlegroup(2, TRUE); +} + +/**********************************************************************//** + Select Battle Group 4 +**************************************************************************/ +void mr_menu::slot_bg4select() +{ + key_unit_select_battlegroup(3, FALSE); +} + +/**********************************************************************//** + Assign Battle Group 4 +**************************************************************************/ +void mr_menu::slot_bg4assign() +{ + key_unit_assign_battlegroup(3, FALSE); +} + +/**********************************************************************//** + Append Battle Group 4 +**************************************************************************/ +void mr_menu::slot_bg4append() +{ + key_unit_assign_battlegroup(3, TRUE); +} + /**********************************************************************//** Shows rulesets to load **************************************************************************/ diff --git a/client/gui-qt/menu.h b/client/gui-qt/menu.h index b0e43cf9d5..904ef2bd62 100644 --- a/client/gui-qt/menu.h +++ b/client/gui-qt/menu.h @@ -416,6 +416,18 @@ private slots: void slot_endgame(); void slot_top_cities(); void slot_traveler(); + void slot_bg1select(); + void slot_bg1assign(); + void slot_bg1append(); + void slot_bg2select(); + void slot_bg2assign(); + void slot_bg2append(); + void slot_bg3select(); + void slot_bg3assign(); + void slot_bg3append(); + void slot_bg4select(); + void slot_bg4assign(); + void slot_bg4append(); private: struct tile *find_last_unit_pos(struct unit *punit, int pos); diff --git a/data/helpdata.txt b/data/helpdata.txt index dc037965c1..8f8bdc990d 100644 --- a/data/helpdata.txt +++ b/data/helpdata.txt @@ -1807,7 +1807,7 @@ Editing Mode (GTK):\n\ Ctrl-E: toggle editing mode\n\ Ctrl-Shift-W: toggle fog of war in editing mode\n\ "), _("\ -Battle Groups (GTK):\n\ +Battle Groups (GTK & Qt):\n\ ====================\n\ Four Battle Groups are supported, controlled by F1, F2, F3, and F4.\n\ Ctrl-F?: Assign selected units as a Battle Group\n\ -- 2.40.1