mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
Folds in the closed #7410 (Move AnnotationDialog from game/ logic to game_graphics/) now that layers 1-2 are closed and this stack bottoms on master directly: - Add game_graphics/dialogs/dlg_annotation.{h,cpp} and move the QInputDialog subclass there; game/ no longer declares any widget type. - Add game/player/token_info.h and game/player/move_top_cards_until_options.h. - Move CardMenuActionType to game/player/card_menu_action_type.h. - Graphics dialog headers include the new game/ headers instead of defining the structs themselves. No behavior change. Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
84 lines
3.3 KiB
C++
84 lines
3.3 KiB
C++
#include "move_menu.h"
|
|
|
|
#include "../../../client/settings/cache_settings.h"
|
|
#include "../../../client/settings/shortcuts_settings.h"
|
|
#include "../../../game/player/card_menu_action_type.h"
|
|
#include "../../game/player/player_actions.h"
|
|
#include "../../game/player/player_logic.h"
|
|
#include "../../game_scene.h"
|
|
#include "../player_graphics_item.h"
|
|
|
|
#include <QAction>
|
|
|
|
MoveMenu::MoveMenu(PlayerGraphicsItem *player) : QMenu(tr("Move to"))
|
|
{
|
|
aMoveToTopLibrary = new QAction(this);
|
|
aMoveToTopLibrary->setData(cmMoveToTopLibrary);
|
|
aMoveToBottomLibrary = new QAction(this);
|
|
aMoveToBottomLibrary->setData(cmMoveToBottomLibrary);
|
|
aMoveToXfromTopOfLibrary = new QAction(this);
|
|
aMoveToTable = new QAction(this);
|
|
aMoveToTable->setData(cmMoveToTable);
|
|
aMoveToGraveyard = new QAction(this);
|
|
aMoveToHand = new QAction(this);
|
|
aMoveToHand->setData(cmMoveToHand);
|
|
aMoveToGraveyard->setData(cmMoveToGraveyard);
|
|
aMoveToExile = new QAction(this);
|
|
aMoveToExile->setData(cmMoveToExile);
|
|
|
|
auto *actions = player->getLogic()->getPlayerActions();
|
|
|
|
auto invoke = [player](CardMenuActionType type) {
|
|
return [type, player]() {
|
|
player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCards(), type);
|
|
};
|
|
};
|
|
|
|
connect(aMoveToTopLibrary, &QAction::triggered, actions, invoke(cmMoveToTopLibrary));
|
|
connect(aMoveToBottomLibrary, &QAction::triggered, actions, invoke(cmMoveToBottomLibrary));
|
|
connect(aMoveToXfromTopOfLibrary, &QAction::triggered, actions,
|
|
&PlayerActions::actRequestMoveCardXCardsFromTopDialog);
|
|
connect(aMoveToTable, &QAction::triggered, actions, invoke(cmMoveToTable));
|
|
connect(aMoveToHand, &QAction::triggered, actions, invoke(cmMoveToHand));
|
|
connect(aMoveToGraveyard, &QAction::triggered, actions, invoke(cmMoveToGraveyard));
|
|
connect(aMoveToExile, &QAction::triggered, actions, invoke(cmMoveToExile));
|
|
|
|
addAction(aMoveToTopLibrary);
|
|
addAction(aMoveToXfromTopOfLibrary);
|
|
addAction(aMoveToBottomLibrary);
|
|
addSeparator();
|
|
addAction(aMoveToTable);
|
|
addSeparator();
|
|
addAction(aMoveToHand);
|
|
addSeparator();
|
|
addAction(aMoveToGraveyard);
|
|
addSeparator();
|
|
addAction(aMoveToExile);
|
|
|
|
setShortcutsActive();
|
|
|
|
retranslateUi();
|
|
}
|
|
|
|
void MoveMenu::setShortcutsActive()
|
|
{
|
|
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
|
|
|
|
aMoveToTopLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToTopLibrary"));
|
|
aMoveToBottomLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToBottomLibrary"));
|
|
aMoveToTable->setShortcuts(shortcuts.getShortcut("Player/aMoveToTable"));
|
|
aMoveToHand->setShortcuts(shortcuts.getShortcut("Player/aMoveToHand"));
|
|
aMoveToGraveyard->setShortcuts(shortcuts.getShortcut("Player/aMoveToGraveyard"));
|
|
aMoveToExile->setShortcuts(shortcuts.getShortcut("Player/aMoveToExile"));
|
|
}
|
|
|
|
void MoveMenu::retranslateUi()
|
|
{
|
|
aMoveToTopLibrary->setText(tr("&Top of library in random order"));
|
|
aMoveToXfromTopOfLibrary->setText(tr("X cards from the top of library..."));
|
|
aMoveToBottomLibrary->setText(tr("&Bottom of library in random order"));
|
|
aMoveToTable->setText(tr("T&able"));
|
|
aMoveToHand->setText(tr("&Hand"));
|
|
aMoveToGraveyard->setText(tr("&Graveyard"));
|
|
aMoveToExile->setText(tr("&Exile"));
|
|
}
|