From f0a827d25841b7497e432a31618d0053d786abb5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 26 Sep 2023 18:44:59 +0300 Subject: [PATCH 31/31] Qt: Add Battle Groups menu See osdn #48732 Signed-off-by: Marko Lindqvist --- client/gui-qt/menu.cpp | 150 ++++++++++++++++++++++++++++++++++++++++- client/gui-qt/menu.h | 12 ++++ data/helpdata.txt | 2 +- 3 files changed, 162 insertions(+), 2 deletions(-) diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index 106e7829fa..ba5328966a 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -1392,6 +1392,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"))); @@ -1597,7 +1598,58 @@ void mr_menu::setup_menus() menu_list.insert(ENDGAME, act); connect(act, &QAction::triggered, this, &mr_menu::slot_endgame); - /* Help Menu */ + // Battle Groups Menu + menu = this->addMenu(_("Battle Groups")); + + act = menu->addAction(_("Select Battle Group 1")); + act->setShortcut(QKeySequence(tr("Shift+F1"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg1select); + + act = menu->addAction(_("Assign Battle Group 1")); + act->setShortcut(QKeySequence(tr("Ctrl+F1"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg1assign); + + act = menu->addAction(_("Append Battle Group 1")); + act->setShortcut(QKeySequence(tr("Ctrl+Shift+F1"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg1append); + + act = menu->addAction(_("Select Battle Group 2")); + act->setShortcut(QKeySequence(tr("Shift+F2"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg2select); + + act = menu->addAction(_("Assign Battle Group 2")); + act->setShortcut(QKeySequence(tr("Ctrl+F2"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg2assign); + + act = menu->addAction(_("Append Battle Group 2")); + act->setShortcut(QKeySequence(tr("Ctrl+Shift+F2"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg2append); + + act = menu->addAction(_("Select Battle Group 3")); + act->setShortcut(QKeySequence(tr("Shift+F3"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg3select); + + act = menu->addAction(_("Assign Battle Group 3")); + act->setShortcut(QKeySequence(tr("Ctrl+F3"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg3assign); + + act = menu->addAction(_("Append Battle Group 3")); + act->setShortcut(QKeySequence(tr("Ctrl+Shift+F3"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg3append); + + act = menu->addAction(_("Select Battle Group 4")); + act->setShortcut(QKeySequence(tr("Shift+F4"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg4select); + + act = menu->addAction(_("Assign Battle Group 4")); + act->setShortcut(QKeySequence(tr("Ctrl+F4"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg4assign); + + act = menu->addAction(_("Append Battle Group 4")); + act->setShortcut(QKeySequence(tr("Ctrl+Shift+F4"))); + connect(act, &QAction::triggered, this, &mr_menu::slot_bg4append); + + // Help Menu menu = this->addMenu(_("Help")); act = menu->addAction(Q_(HELP_OVERVIEW_ITEM)); @@ -3473,6 +3525,102 @@ void mr_menu::slot_traveler() send_report_request(REPORT_WONDERS_OF_THE_WORLD); } +/**********************************************************************//** + 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 c08ea5be54..820072057f 100644 --- a/client/gui-qt/menu.h +++ b/client/gui-qt/menu.h @@ -415,6 +415,18 @@ private slots: void slot_endgame(); void slot_top_five(); 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 c9089bc8b8..31c443c4b2 100644 --- a/data/helpdata.txt +++ b/data/helpdata.txt @@ -1806,7 +1806,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