From a7f47b5caf11505c133484e773e0256810205264 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 26 Sep 2023 18:57:09 +0300 Subject: [PATCH 18/18] 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 b4053f5605..781fc0baaf 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -1408,6 +1408,7 @@ void mr_menu::setup_menus() menu_list.insert(ORDER_TRADEROUTE, 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"))); @@ -1613,7 +1614,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")); signal_help_mapper = new QSignalMapper(this); @@ -3681,6 +3733,102 @@ bool mr_menu::confirm_disruptive_selection() == QMessageBox::Ok); } +/**********************************************************************//** + 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); +} + /**********************************************************************//** Airlift unit type to city acity from each city ***************************************************************************/ diff --git a/client/gui-qt/menu.h b/client/gui-qt/menu.h index 2d6c22e164..7da82744f8 100644 --- a/client/gui-qt/menu.h +++ b/client/gui-qt/menu.h @@ -424,6 +424,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 1ba02ea369..9232a639a5 100644 --- a/data/helpdata.txt +++ b/data/helpdata.txt @@ -1799,7 +1799,7 @@ Editing Mode (GTK):\n\ Ctrl-E: toggle editing mode\n\ Ctrl-M: 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