Refactor player menus into helper classes.

Took 2 hours 6 minutes


Took 11 minutes
This commit is contained in:
Lukas Brübach 2025-09-12 00:37:17 +02:00
parent ff7ce39841
commit cce6a9d663
16 changed files with 893 additions and 560 deletions

View file

@ -232,8 +232,13 @@ set(cockatrice_SOURCES
src/game/player/player_info.cpp src/game/player/player_info.cpp
src/game/player/player_list_widget.cpp src/game/player/player_list_widget.cpp
src/game/player/player_manager.cpp src/game/player/player_manager.cpp
src/game/player/player_menu.cpp
src/game/player/player_target.cpp src/game/player/player_target.cpp
src/game/player/player_menu/grave_menu.cpp
src/game/player/player_menu/hand_menu.cpp
src/game/player/player_menu/library_menu.cpp
src/game/player/player_menu/player_menu.cpp
src/game/player/player_menu/pt_menu.cpp
src/game/player/player_menu/rfg_menu.cpp
src/game/replay.cpp src/game/replay.cpp
src/game/zones/card_zone.cpp src/game/zones/card_zone.cpp
src/game/zones/hand_zone.cpp src/game/zones/hand_zone.cpp

View file

@ -42,7 +42,6 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, A
connect(this, &Player::activeChanged, graphicsItem, &PlayerGraphicsItem::onPlayerActiveChanged); connect(this, &Player::activeChanged, graphicsItem, &PlayerGraphicsItem::onPlayerActiveChanged);
connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::enableOpenInDeckEditorAction);
connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::populatePredefinedTokensMenu); connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::populatePredefinedTokensMenu);
connect(this, &Player::openDeckEditor, game->getTab(), &TabGame::openDeckEditor); connect(this, &Player::openDeckEditor, game->getTab(), &TabGame::openDeckEditor);

View file

@ -13,7 +13,7 @@
#include "player_event_handler.h" #include "player_event_handler.h"
#include "player_graphics_item.h" #include "player_graphics_item.h"
#include "player_info.h" #include "player_info.h"
#include "player_menu.h" #include "player_menu/player_menu.h"
#include <QInputDialog> #include <QInputDialog>
#include <QLoggingCategory> #include <QLoggingCategory>

View file

@ -172,7 +172,7 @@ void PlayerActions::actAlwaysRevealTopCard()
{ {
Command_ChangeZoneProperties cmd; Command_ChangeZoneProperties cmd;
cmd.set_zone_name("deck"); cmd.set_zone_name("deck");
cmd.set_always_reveal_top_card(player->getPlayerMenu()->isAlwaysRevealTopCardChecked()); cmd.set_always_reveal_top_card(player->getPlayerMenu()->getLibraryMenu()->isAlwaysRevealTopCardChecked());
sendGameCommand(cmd); sendGameCommand(cmd);
} }
@ -181,7 +181,7 @@ void PlayerActions::actAlwaysLookAtTopCard()
{ {
Command_ChangeZoneProperties cmd; Command_ChangeZoneProperties cmd;
cmd.set_zone_name("deck"); cmd.set_zone_name("deck");
cmd.set_always_look_at_top_card(player->getPlayerMenu()->isAlwaysLookAtTopCardChecked()); cmd.set_always_look_at_top_card(player->getPlayerMenu()->getLibraryMenu()->isAlwaysLookAtTopCardChecked());
sendGameCommand(cmd); sendGameCommand(cmd);
} }

View file

@ -0,0 +1,88 @@
#include "grave_menu.h"
#include "../player.h"
#include "../player_actions.h"
GraveyardMenu::GraveyardMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
{
createMoveActions();
createViewActions();
addAction(aViewGraveyard);
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
mRevealRandomGraveyardCard = addMenu(QString());
QAction *newAction = mRevealRandomGraveyardCard->addAction(QString());
newAction->setData(-1);
connect(newAction, &QAction::triggered, player->getPlayerActions(),
&PlayerActions::actRevealRandomGraveyardCard);
// allPlayersActions.append(newAction);
mRevealRandomGraveyardCard->addSeparator();
addSeparator();
moveGraveMenu = addTearOffMenu(QString());
moveGraveMenu->addAction(aMoveGraveToTopLibrary);
moveGraveMenu->addAction(aMoveGraveToBottomLibrary);
moveGraveMenu->addSeparator();
moveGraveMenu->addAction(aMoveGraveToHand);
moveGraveMenu->addSeparator();
moveGraveMenu->addAction(aMoveGraveToRfg);
}
retranslateUi();
}
void GraveyardMenu::createMoveActions()
{
auto grave = player->getGraveZone();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aMoveGraveToTopLibrary = new QAction(this);
aMoveGraveToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
aMoveGraveToBottomLibrary = new QAction(this);
aMoveGraveToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
aMoveGraveToHand = new QAction(this);
aMoveGraveToHand->setData(QList<QVariant>() << "hand" << 0);
aMoveGraveToRfg = new QAction(this);
aMoveGraveToRfg->setData(QList<QVariant>() << "rfg" << 0);
connect(aMoveGraveToTopLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
connect(aMoveGraveToBottomLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
connect(aMoveGraveToHand, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
connect(aMoveGraveToRfg, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
}
}
void GraveyardMenu::createViewActions()
{
PlayerActions *playerActions = player->getPlayerActions();
aViewGraveyard = new QAction(this);
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
}
void GraveyardMenu::retranslateUi()
{
aViewGraveyard->setText(tr("&View graveyard"));
if (player->getPlayerInfo()->getLocalOrJudge()) {
moveGraveMenu->setTitle(tr("&Move graveyard to..."));
aMoveGraveToTopLibrary->setText(tr("&Top of library"));
aMoveGraveToBottomLibrary->setText(tr("&Bottom of library"));
aMoveGraveToHand->setText(tr("&Hand"));
aMoveGraveToRfg->setText(tr("&Exile"));
mRevealRandomGraveyardCard->setTitle(tr("Reveal random card to..."));
}
}
void GraveyardMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewGraveyard->setShortcuts(shortcuts.getShortcut("Player/aViewGraveyard"));
}
void GraveyardMenu::setShortcutsInactive()
{
aViewGraveyard->setShortcut(QKeySequence());
}

View file

@ -0,0 +1,33 @@
#ifndef COCKATRICE_GRAVE_MENU_H
#define COCKATRICE_GRAVE_MENU_H
#include "../../../client/tearoff_menu.h"
#include <QAction>
#include <QMenu>
class Player;
class GraveyardMenu : public TearOffMenu {
Q_OBJECT
public:
explicit GraveyardMenu(Player* player, QWidget* parent = nullptr);
void createMoveActions();
void createViewActions();
void retranslateUi();
void setShortcutsActive();
void setShortcutsInactive();
QMenu * mRevealRandomGraveyardCard = nullptr;
QMenu* moveGraveMenu = nullptr;
QAction* aViewGraveyard = nullptr;
QAction* aMoveGraveToTopLibrary = nullptr;
QAction* aMoveGraveToBottomLibrary = nullptr;
QAction* aMoveGraveToHand = nullptr;
QAction* aMoveGraveToRfg = nullptr;
private:
Player* player;
};
#endif // COCKATRICE_GRAVE_MENU_H

View file

@ -0,0 +1,90 @@
#include "hand_menu.h"
#include "../player.h"
#include "../player_actions.h"
HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player)
{
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aViewHand = new QAction(this);
connect(aViewHand, &QAction::triggered, actions, &PlayerActions::actViewHand);
addAction(aViewHand);
aSortHand = new QAction(this);
connect(aSortHand, &QAction::triggered, actions, &PlayerActions::actSortHand);
addAction(aSortHand);
}
mRevealHand = addMenu(QString());
mRevealRandomHandCard = addMenu(QString());
addSeparator();
aMulligan = new QAction(this);
connect(aMulligan, &QAction::triggered, actions, &PlayerActions::actMulligan);
addAction(aMulligan);
addSeparator();
mMoveHandMenu = addTearOffMenu(QString());
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aMoveHandToTopLibrary = new QAction(this);
aMoveHandToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
aMoveHandToBottomLibrary = new QAction(this);
aMoveHandToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
aMoveHandToGrave = new QAction(this);
aMoveHandToGrave->setData(QList<QVariant>() << "grave" << 0);
aMoveHandToRfg = new QAction(this);
aMoveHandToRfg->setData(QList<QVariant>() << "rfg" << 0);
auto hand = player->getHandZone();
connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
connect(aMoveHandToGrave, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
connect(aMoveHandToRfg, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
mMoveHandMenu->addAction(aMoveHandToTopLibrary);
mMoveHandMenu->addAction(aMoveHandToBottomLibrary);
mMoveHandMenu->addSeparator();
mMoveHandMenu->addAction(aMoveHandToGrave);
mMoveHandMenu->addSeparator();
mMoveHandMenu->addAction(aMoveHandToRfg);
}
retranslateUi();
}
void HandMenu::retranslateUi()
{
if (player->getPlayerInfo()->getLocalOrJudge()) {
aViewHand->setText(tr("&View hand"));
aSortHand->setText(tr("&Sort hand"));
aMulligan->setText(tr("Take &mulligan"));
mMoveHandMenu->setTitle(tr("&Move hand to..."));
aMoveHandToTopLibrary->setText(tr("&Top of library"));
aMoveHandToBottomLibrary->setText(tr("&Bottom of library"));
aMoveHandToGrave->setText(tr("&Graveyard"));
aMoveHandToRfg->setText(tr("&Exile"));
mRevealHand->setTitle(tr("&Reveal hand to..."));
mRevealRandomHandCard->setTitle(tr("Reveal r&andom card to..."));
}
}
void HandMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewHand->setShortcuts(shortcuts.getShortcut("Player/aViewHand"));
aSortHand->setShortcuts(shortcuts.getShortcut("Player/aSortHand"));
aMulligan->setShortcuts(shortcuts.getShortcut("Player/aMulligan"));
}
void HandMenu::setShortcutsInactive()
{
aViewHand->setShortcut(QKeySequence());
aSortHand->setShortcut(QKeySequence());
aMulligan->setShortcut(QKeySequence());
}

View file

@ -0,0 +1,44 @@
#ifndef COCKATRICE_HAND_MENU_H
#define COCKATRICE_HAND_MENU_H
#include "../../../client/tearoff_menu.h"
#include <QAction>
#include <QMenu>
class Player;
class PlayerActions;
class HandMenu : public TearOffMenu
{
Q_OBJECT
public:
explicit HandMenu(Player* player, PlayerActions* actions, QWidget* parent = nullptr);
void retranslateUi();
void setShortcutsActive();
void setShortcutsInactive();
// expose useful actions/menus if PlayerMenu needs them
QMenu* revealHandMenu() const { return mRevealHand; }
QMenu* revealRandomHandCardMenu() const { return mRevealRandomHandCard; }
QMenu* moveHandMenu() const { return mMoveHandMenu; }
private:
Player *player;
QAction* aViewHand = nullptr;
QAction* aSortHand = nullptr;
QAction* aMulligan = nullptr;
QMenu* mRevealHand = nullptr;
QMenu* mRevealRandomHandCard = nullptr;
QMenu* mMoveHandMenu = nullptr;
QAction* aMoveHandToTopLibrary = nullptr;
QAction* aMoveHandToBottomLibrary = nullptr;
QAction* aMoveHandToGrave = nullptr;
QAction* aMoveHandToRfg = nullptr;
};
#endif // COCKATRICE_HAND_MENU_H

View file

@ -0,0 +1,284 @@
#include "library_menu.h"
#include "../player.h"
#include "../player_actions.h"
LibraryMenu::LibraryMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
{
createDrawActions();
createShuffleActions();
createMoveActions();
createViewActions();
addAction(aDrawCard);
addAction(aDrawCards);
addAction(aUndoDraw);
addSeparator();
addAction(aShuffle);
addSeparator();
addAction(aViewLibrary);
addAction(aViewTopCards);
addAction(aViewBottomCards);
addSeparator();
// playerLists.append(mRevealLibrary = libraryMenu->addMenu(QString()));
mRevealLibrary = addMenu(QString());
// singlePlayerLists.append(mLendLibrary = libraryMenu->addMenu(QString()));
mLendLibrary = addMenu(QString());
// playerLists.append(mRevealTopCard = libraryMenu->addMenu(QString()));
mRevealTopCard = addMenu(QString());
addAction(aAlwaysRevealTopCard);
addAction(aAlwaysLookAtTopCard);
addSeparator();
topLibraryMenu = addTearOffMenu(QString());
bottomLibraryMenu = addTearOffMenu(QString());
addSeparator();
addAction(aOpenDeckInDeckEditor);
topLibraryMenu->addAction(aMoveTopToPlay);
topLibraryMenu->addAction(aMoveTopToPlayFaceDown);
topLibraryMenu->addAction(aMoveTopCardToBottom);
topLibraryMenu->addSeparator();
topLibraryMenu->addAction(aMoveTopCardToGraveyard);
topLibraryMenu->addAction(aMoveTopCardsToGraveyard);
topLibraryMenu->addAction(aMoveTopCardToExile);
topLibraryMenu->addAction(aMoveTopCardsToExile);
topLibraryMenu->addAction(aMoveTopCardsUntil);
topLibraryMenu->addSeparator();
topLibraryMenu->addAction(aShuffleTopCards);
bottomLibraryMenu->addAction(aDrawBottomCard);
bottomLibraryMenu->addAction(aDrawBottomCards);
bottomLibraryMenu->addSeparator();
bottomLibraryMenu->addAction(aMoveBottomToPlay);
bottomLibraryMenu->addAction(aMoveBottomToPlayFaceDown);
bottomLibraryMenu->addAction(aMoveBottomCardToTop);
bottomLibraryMenu->addSeparator();
bottomLibraryMenu->addAction(aMoveBottomCardToGraveyard);
bottomLibraryMenu->addAction(aMoveBottomCardsToGraveyard);
bottomLibraryMenu->addAction(aMoveBottomCardToExile);
bottomLibraryMenu->addAction(aMoveBottomCardsToExile);
bottomLibraryMenu->addSeparator();
bottomLibraryMenu->addAction(aShuffleBottomCards);
connect(player, &Player::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions);
connect(player, &Player::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction);
retranslateUi();
}
void LibraryMenu::enableOpenInDeckEditorAction() const
{
aOpenDeckInDeckEditor->setEnabled(true);
}
void LibraryMenu::resetTopCardMenuActions()
{
aAlwaysRevealTopCard->setChecked(false);
aAlwaysLookAtTopCard->setChecked(false);
}
void LibraryMenu::createDrawActions()
{
PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aDrawCard = new QAction(this);
connect(aDrawCard, &QAction::triggered, playerActions, &PlayerActions::actDrawCard);
aDrawCards = new QAction(this);
connect(aDrawCards, &QAction::triggered, playerActions, &PlayerActions::actDrawCards);
aUndoDraw = new QAction(this);
connect(aUndoDraw, &QAction::triggered, playerActions, &PlayerActions::actUndoDraw);
aDrawBottomCard = new QAction(this);
connect(aDrawBottomCard, &QAction::triggered, playerActions, &PlayerActions::actDrawBottomCard);
aDrawBottomCards = new QAction(this);
connect(aDrawBottomCards, &QAction::triggered, playerActions, &PlayerActions::actDrawBottomCards);
}
}
void LibraryMenu::createShuffleActions()
{
PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aShuffle = new QAction(this);
connect(aShuffle, &QAction::triggered, playerActions, &PlayerActions::actShuffle);
aShuffleTopCards = new QAction(this);
connect(aShuffleTopCards, &QAction::triggered, playerActions, &PlayerActions::actShuffleTop);
aShuffleBottomCards = new QAction(this);
connect(aShuffleBottomCards, &QAction::triggered, playerActions, &PlayerActions::actShuffleBottom);
}
}
void LibraryMenu::createMoveActions()
{
PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aMoveTopToPlay = new QAction(this);
connect(aMoveTopToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToPlay);
aMoveTopToPlayFaceDown = new QAction(this);
connect(aMoveTopToPlayFaceDown, &QAction::triggered, playerActions,
&PlayerActions::actMoveTopCardToPlayFaceDown);
aMoveTopCardToGraveyard = new QAction(this);
connect(aMoveTopCardToGraveyard, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToGrave);
aMoveTopCardToExile = new QAction(this);
connect(aMoveTopCardToExile, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToExile);
aMoveTopCardsToGraveyard = new QAction(this);
connect(aMoveTopCardsToGraveyard, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardsToGrave);
aMoveTopCardsToExile = new QAction(this);
connect(aMoveTopCardsToExile, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardsToExile);
aMoveTopCardsUntil = new QAction(this);
connect(aMoveTopCardsUntil, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardsUntil);
aMoveTopCardToBottom = new QAction(this);
connect(aMoveTopCardToBottom, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToBottom);
aMoveBottomToPlay = new QAction(this);
connect(aMoveBottomToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveBottomCardToPlay);
aMoveBottomToPlayFaceDown = new QAction(this);
connect(aMoveBottomToPlayFaceDown, &QAction::triggered, playerActions,
&PlayerActions::actMoveBottomCardToPlayFaceDown);
aMoveBottomCardToGraveyard = new QAction(this);
connect(aMoveBottomCardToGraveyard, &QAction::triggered, playerActions,
&PlayerActions::actMoveBottomCardToGrave);
aMoveBottomCardToExile = new QAction(this);
connect(aMoveBottomCardToExile, &QAction::triggered, playerActions, &PlayerActions::actMoveBottomCardToExile);
aMoveBottomCardsToGraveyard = new QAction(this);
connect(aMoveBottomCardsToGraveyard, &QAction::triggered, playerActions,
&PlayerActions::actMoveBottomCardsToGrave);
aMoveBottomCardsToExile = new QAction(this);
connect(aMoveBottomCardsToExile, &QAction::triggered, playerActions, &PlayerActions::actMoveBottomCardsToExile);
aMoveBottomCardToTop = new QAction(this);
connect(aMoveBottomCardToTop, &QAction::triggered, playerActions, &PlayerActions::actMoveBottomCardToTop);
}
}
void LibraryMenu::createViewActions()
{
PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aViewLibrary = new QAction(this);
connect(aViewLibrary, &QAction::triggered, playerActions, &PlayerActions::actViewLibrary);
aViewTopCards = new QAction(this);
connect(aViewTopCards, &QAction::triggered, playerActions, &PlayerActions::actViewTopCards);
aViewBottomCards = new QAction(this);
connect(aViewBottomCards, &QAction::triggered, playerActions, &PlayerActions::actViewBottomCards);
aAlwaysRevealTopCard = new QAction(this);
aAlwaysRevealTopCard->setCheckable(true);
connect(aAlwaysRevealTopCard, &QAction::triggered, playerActions, &PlayerActions::actAlwaysRevealTopCard);
aAlwaysLookAtTopCard = new QAction(this);
aAlwaysLookAtTopCard->setCheckable(true);
connect(aAlwaysLookAtTopCard, &QAction::triggered, playerActions, &PlayerActions::actAlwaysLookAtTopCard);
aOpenDeckInDeckEditor = new QAction(this);
aOpenDeckInDeckEditor->setEnabled(false);
connect(aOpenDeckInDeckEditor, &QAction::triggered, playerActions, &PlayerActions::actOpenDeckInDeckEditor);
}
}
void LibraryMenu::retranslateUi()
{
if (player->getPlayerInfo()->getLocalOrJudge()) {
aViewLibrary->setText(tr("&View library"));
aViewTopCards->setText(tr("View &top cards of library..."));
aViewBottomCards->setText(tr("View bottom cards of library..."));
mRevealLibrary->setTitle(tr("Reveal &library to..."));
mLendLibrary->setTitle(tr("Lend library to..."));
mRevealTopCard->setTitle(tr("Reveal &top cards to..."));
topLibraryMenu->setTitle(tr("&Top of library..."));
bottomLibraryMenu->setTitle(tr("&Bottom of library..."));
aAlwaysRevealTopCard->setText(tr("&Always reveal top card"));
aAlwaysLookAtTopCard->setText(tr("&Always look at top card"));
aOpenDeckInDeckEditor->setText(tr("&Open deck in deck editor"));
aDrawCard->setText(tr("&Draw card"));
aDrawCards->setText(tr("D&raw cards..."));
aUndoDraw->setText(tr("&Undo last draw"));
aShuffle->setText(tr("Shuffle"));
aMoveTopToPlay->setText(tr("&Play top card"));
aMoveTopToPlayFaceDown->setText(tr("Play top card &face down"));
aMoveTopCardToBottom->setText(tr("Put top card on &bottom"));
aMoveTopCardToGraveyard->setText(tr("Move top card to grave&yard"));
aMoveTopCardToExile->setText(tr("Move top card to e&xile"));
aMoveTopCardsToGraveyard->setText(tr("Move top cards to &graveyard..."));
aMoveTopCardsToExile->setText(tr("Move top cards to &exile..."));
aMoveTopCardsUntil->setText(tr("Put top cards on stack &until..."));
aShuffleTopCards->setText(tr("Shuffle top cards..."));
aDrawBottomCard->setText(tr("&Draw bottom card"));
aDrawBottomCards->setText(tr("D&raw bottom cards..."));
aMoveBottomToPlay->setText(tr("&Play bottom card"));
aMoveBottomToPlayFaceDown->setText(tr("Play bottom card &face down"));
aMoveBottomCardToGraveyard->setText(tr("Move bottom card to grave&yard"));
aMoveBottomCardToExile->setText(tr("Move bottom card to e&xile"));
aMoveBottomCardsToGraveyard->setText(tr("Move bottom cards to &graveyard..."));
aMoveBottomCardsToExile->setText(tr("Move bottom cards to &exile..."));
aMoveBottomCardToTop->setText(tr("Put bottom card on &top"));
aShuffleBottomCards->setText(tr("Shuffle bottom cards..."));
}
}
void LibraryMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewLibrary->setShortcuts(shortcuts.getShortcut("Player/aViewLibrary"));
aViewTopCards->setShortcuts(shortcuts.getShortcut("Player/aViewTopCards"));
aViewBottomCards->setShortcuts(shortcuts.getShortcut("Player/aViewBottomCards"));
aDrawCard->setShortcuts(shortcuts.getShortcut("Player/aDrawCard"));
aDrawCards->setShortcuts(shortcuts.getShortcut("Player/aDrawCards"));
aUndoDraw->setShortcuts(shortcuts.getShortcut("Player/aUndoDraw"));
aShuffle->setShortcuts(shortcuts.getShortcut("Player/aShuffle"));
aShuffleTopCards->setShortcuts(shortcuts.getShortcut("Player/aShuffleTopCards"));
aShuffleBottomCards->setShortcuts(shortcuts.getShortcut("Player/aShuffleBottomCards"));
aAlwaysRevealTopCard->setShortcuts(shortcuts.getShortcut("Player/aAlwaysRevealTopCard"));
aAlwaysLookAtTopCard->setShortcuts(shortcuts.getShortcut("Player/aAlwaysLookAtTopCard"));
aMoveTopToPlay->setShortcuts(shortcuts.getShortcut("Player/aMoveTopToPlay"));
aMoveTopToPlayFaceDown->setShortcuts(shortcuts.getShortcut("Player/aMoveTopToPlayFaceDown"));
aMoveTopCardToGraveyard->setShortcuts(shortcuts.getShortcut("Player/aMoveTopCardToGraveyard"));
aMoveTopCardsToGraveyard->setShortcuts(shortcuts.getShortcut("Player/aMoveTopCardsToGraveyard"));
aMoveTopCardToExile->setShortcuts(shortcuts.getShortcut("Player/aMoveTopCardToExile"));
aMoveTopCardsToExile->setShortcuts(shortcuts.getShortcut("Player/aMoveTopCardsToExile"));
aMoveTopCardsUntil->setShortcuts(shortcuts.getShortcut("Player/aMoveTopCardsUntil"));
aMoveTopCardToBottom->setShortcuts(shortcuts.getShortcut("Player/aMoveTopCardToBottom"));
aDrawBottomCard->setShortcuts(shortcuts.getShortcut("Player/aDrawBottomCard"));
aDrawBottomCards->setShortcuts(shortcuts.getShortcut("Player/aDrawBottomCards"));
aMoveBottomToPlay->setShortcuts(shortcuts.getShortcut("Player/aMoveBottomToPlay"));
aMoveBottomToPlayFaceDown->setShortcuts(shortcuts.getShortcut("Player/aMoveBottomToPlayFaceDown"));
aMoveBottomCardToGraveyard->setShortcuts(shortcuts.getShortcut("Player/aMoveBottomCardToGrave"));
aMoveBottomCardsToGraveyard->setShortcuts(shortcuts.getShortcut("Player/aMoveBottomCardsToGrave"));
aMoveBottomCardToExile->setShortcuts(shortcuts.getShortcut("Player/aMoveBottomCardToExile"));
aMoveBottomCardsToExile->setShortcuts(shortcuts.getShortcut("Player/aMoveBottomCardsToExile"));
aMoveBottomCardToTop->setShortcuts(shortcuts.getShortcut("Player/aMoveBottomCardToTop"));
}
void LibraryMenu::setShortcutsInactive()
{
aViewLibrary->setShortcut(QKeySequence());
aViewTopCards->setShortcut(QKeySequence());
aViewBottomCards->setShortcut(QKeySequence());
aDrawCard->setShortcut(QKeySequence());
aDrawCards->setShortcut(QKeySequence());
aUndoDraw->setShortcut(QKeySequence());
aShuffle->setShortcut(QKeySequence());
aShuffleTopCards->setShortcut(QKeySequence());
aShuffleBottomCards->setShortcut(QKeySequence());
aAlwaysRevealTopCard->setShortcut(QKeySequence());
aAlwaysLookAtTopCard->setShortcut(QKeySequence());
aMoveTopToPlay->setShortcut(QKeySequence());
aMoveTopToPlayFaceDown->setShortcut(QKeySequence());
aMoveTopCardToGraveyard->setShortcut(QKeySequence());
aMoveTopCardsToGraveyard->setShortcut(QKeySequence());
aMoveTopCardToExile->setShortcut(QKeySequence());
aMoveTopCardsToExile->setShortcut(QKeySequence());
aMoveTopCardsUntil->setShortcut(QKeySequence());
aDrawBottomCard->setShortcut(QKeySequence());
aDrawBottomCards->setShortcut(QKeySequence());
aMoveBottomToPlay->setShortcut(QKeySequence());
aMoveBottomToPlayFaceDown->setShortcut(QKeySequence());
aMoveBottomCardToGraveyard->setShortcut(QKeySequence());
aMoveBottomCardsToGraveyard->setShortcut(QKeySequence());
aMoveBottomCardToExile->setShortcut(QKeySequence());
aMoveBottomCardsToExile->setShortcut(QKeySequence());
}

View file

@ -0,0 +1,89 @@
#ifndef COCKATRICE_LIBRARY_MENU_H
#define COCKATRICE_LIBRARY_MENU_H
#include "../../../client/tearoff_menu.h"
#include <QAction>
#include <QMenu>
class Player;
class PlayerActions;
class LibraryMenu : public TearOffMenu
{
Q_OBJECT
public slots:
void enableOpenInDeckEditorAction() const;
void resetTopCardMenuActions();
public:
LibraryMenu(Player *player, QWidget *parent = nullptr);
void createDrawActions();
void createShuffleActions();
void createMoveActions();
void createViewActions();
void retranslateUi();
void setShortcutsActive();
void setShortcutsInactive();
[[nodiscard]] bool isAlwaysRevealTopCardChecked() const
{
return aAlwaysRevealTopCard->isChecked();
}
[[nodiscard]] bool isAlwaysLookAtTopCardChecked() const
{
return aAlwaysLookAtTopCard->isChecked();
}
// expose useful actions/menus if PlayerMenu needs them
QMenu* revealLibrary() const { return mRevealLibrary; }
QMenu* lendLibraryMenu() const { return mLendLibrary; }
QMenu* revealTopCardMenu() const { return mRevealTopCard; }
QMenu *topLibraryMenu = nullptr;
QMenu *bottomLibraryMenu = nullptr;
// Expose submenus that PlayerMenu tracks in its lists
QMenu *mRevealLibrary = nullptr;
QMenu *mLendLibrary = nullptr;
QMenu *mRevealTopCard = nullptr;
QAction *aDrawCard = nullptr;
QAction *aDrawCards = nullptr;
QAction *aUndoDraw = nullptr;
QAction *aShuffle = nullptr;
QAction *aViewLibrary = nullptr;
QAction *aViewTopCards = nullptr;
QAction *aViewBottomCards = nullptr;
QAction *aAlwaysRevealTopCard = nullptr;
QAction *aAlwaysLookAtTopCard = nullptr;
QAction *aOpenDeckInDeckEditor = nullptr;
QAction *aMoveTopToPlay = nullptr;
QAction *aMoveTopToPlayFaceDown = nullptr;
QAction *aMoveTopCardToBottom = nullptr;
QAction *aMoveTopCardToGraveyard = nullptr;
QAction *aMoveTopCardToExile = nullptr;
QAction *aMoveTopCardsToGraveyard = nullptr;
QAction *aMoveTopCardsToExile = nullptr;
QAction *aMoveTopCardsUntil = nullptr;
QAction *aShuffleTopCards = nullptr;
QAction *aDrawBottomCard = nullptr;
QAction *aDrawBottomCards = nullptr;
QAction *aMoveBottomToPlay = nullptr;
QAction *aMoveBottomToPlayFaceDown = nullptr;
QAction *aMoveBottomCardToTop = nullptr;
QAction *aMoveBottomCardToGraveyard = nullptr;
QAction *aMoveBottomCardToExile = nullptr;
QAction *aMoveBottomCardsToGraveyard = nullptr;
QAction *aMoveBottomCardsToExile = nullptr;
QAction *aShuffleBottomCards = nullptr;
private:
Player *player;
};
#endif // COCKATRICE_LIBRARY_MENU_H

View file

@ -1,14 +1,16 @@
#include "player_menu.h" #include "player_menu.h"
#include "../../../client/tabs/tab_game.h"
#include "../../../common/pb/command_reveal_cards.pb.h" #include "../../../common/pb/command_reveal_cards.pb.h"
#include "../../client/tabs/tab_game.h" #include "../../../settings/card_counter_settings.h"
#include "../../settings/card_counter_settings.h" #include "../../board/card_item.h"
#include "../board/card_item.h" #include "../../cards/card_database_manager.h"
#include "../cards/card_database_manager.h" #include "../../zones/hand_zone.h"
#include "../zones/hand_zone.h" #include "../../zones/logic/view_zone_logic.h"
#include "../zones/logic/view_zone_logic.h" #include "../card_menu_action_type.h"
#include "card_menu_action_type.h" #include "../player_actions.h"
#include "player_actions.h" #include "hand_menu.h"
#include "pt_menu.h"
PlayerMenu::PlayerMenu(Player *_player) : player(_player) PlayerMenu::PlayerMenu(Player *_player) : player(_player)
{ {
@ -25,112 +27,27 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
PlayerActions *playerActions = player->getPlayerActions(); PlayerActions *playerActions = player->getPlayerActions();
createDrawActions();
createShuffleActions();
createMoveActions();
createViewActions(); createViewActions();
playerMenu = new TearOffMenu(); playerMenu = new TearOffMenu();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) { if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
handMenu = playerMenu->addTearOffMenu(QString()); handMenu = new HandMenu(player, player->getPlayerActions(), playerMenu);
handMenu->addAction(aViewHand); playerMenu->addMenu(handMenu);
handMenu->addAction(aSortHand); /*playerLists.append(mRevealHand = handMenu->addMenu(QString()));
playerLists.append(mRevealHand = handMenu->addMenu(QString())); playerLists.append(mRevealRandomHandCard = handMenu->addMenu(QString()));*/
playerLists.append(mRevealRandomHandCard = handMenu->addMenu(QString()));
handMenu->addSeparator();
handMenu->addAction(aMulligan);
handMenu->addSeparator();
moveHandMenu = handMenu->addTearOffMenu(QString());
moveHandMenu->addAction(aMoveHandToTopLibrary);
moveHandMenu->addAction(aMoveHandToBottomLibrary);
moveHandMenu->addSeparator();
moveHandMenu->addAction(aMoveHandToGrave);
moveHandMenu->addSeparator();
moveHandMenu->addAction(aMoveHandToRfg);
libraryMenu = playerMenu->addTearOffMenu(QString()); libraryMenu = new LibraryMenu(player, playerMenu);
libraryMenu->addAction(aDrawCard); playerMenu->addMenu(libraryMenu);
libraryMenu->addAction(aDrawCards);
libraryMenu->addAction(aUndoDraw);
libraryMenu->addSeparator();
libraryMenu->addAction(aShuffle);
libraryMenu->addSeparator();
libraryMenu->addAction(aViewLibrary);
libraryMenu->addAction(aViewTopCards);
libraryMenu->addAction(aViewBottomCards);
libraryMenu->addSeparator();
playerLists.append(mRevealLibrary = libraryMenu->addMenu(QString()));
singlePlayerLists.append(mLendLibrary = libraryMenu->addMenu(QString()));
playerLists.append(mRevealTopCard = libraryMenu->addMenu(QString()));
libraryMenu->addAction(aAlwaysRevealTopCard);
libraryMenu->addAction(aAlwaysLookAtTopCard);
libraryMenu->addSeparator();
topLibraryMenu = libraryMenu->addTearOffMenu(QString());
bottomLibraryMenu = libraryMenu->addTearOffMenu(QString());
libraryMenu->addSeparator();
libraryMenu->addAction(aOpenDeckInDeckEditor);
topLibraryMenu->addAction(aMoveTopToPlay);
topLibraryMenu->addAction(aMoveTopToPlayFaceDown);
topLibraryMenu->addAction(aMoveTopCardToBottom);
topLibraryMenu->addSeparator();
topLibraryMenu->addAction(aMoveTopCardToGraveyard);
topLibraryMenu->addAction(aMoveTopCardsToGraveyard);
topLibraryMenu->addAction(aMoveTopCardToExile);
topLibraryMenu->addAction(aMoveTopCardsToExile);
topLibraryMenu->addAction(aMoveTopCardsUntil);
topLibraryMenu->addSeparator();
topLibraryMenu->addAction(aShuffleTopCards);
bottomLibraryMenu->addAction(aDrawBottomCard);
bottomLibraryMenu->addAction(aDrawBottomCards);
bottomLibraryMenu->addSeparator();
bottomLibraryMenu->addAction(aMoveBottomToPlay);
bottomLibraryMenu->addAction(aMoveBottomToPlayFaceDown);
bottomLibraryMenu->addAction(aMoveBottomCardToTop);
bottomLibraryMenu->addSeparator();
bottomLibraryMenu->addAction(aMoveBottomCardToGraveyard);
bottomLibraryMenu->addAction(aMoveBottomCardsToGraveyard);
bottomLibraryMenu->addAction(aMoveBottomCardToExile);
bottomLibraryMenu->addAction(aMoveBottomCardsToExile);
bottomLibraryMenu->addSeparator();
bottomLibraryMenu->addAction(aShuffleBottomCards);
} }
graveMenu = playerMenu->addTearOffMenu(QString()); graveMenu = new GraveyardMenu(player, playerMenu);
graveMenu->addAction(aViewGraveyard); playerMenu->addMenu(graveMenu);
rfgMenu = new RfgMenu(player, playerMenu);
playerMenu->addMenu(rfgMenu);
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) { if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
mRevealRandomGraveyardCard = graveMenu->addMenu(QString());
QAction *newAction = mRevealRandomGraveyardCard->addAction(QString());
newAction->setData(-1);
connect(newAction, &QAction::triggered, playerActions, &PlayerActions::actRevealRandomGraveyardCard);
allPlayersActions.append(newAction);
mRevealRandomGraveyardCard->addSeparator();
}
rfgMenu = playerMenu->addTearOffMenu(QString());
rfgMenu->addAction(aViewRfg);
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
graveMenu->addSeparator();
moveGraveMenu = graveMenu->addTearOffMenu(QString());
moveGraveMenu->addAction(aMoveGraveToTopLibrary);
moveGraveMenu->addAction(aMoveGraveToBottomLibrary);
moveGraveMenu->addSeparator();
moveGraveMenu->addAction(aMoveGraveToHand);
moveGraveMenu->addSeparator();
moveGraveMenu->addAction(aMoveGraveToRfg);
rfgMenu->addSeparator();
moveRfgMenu = rfgMenu->addTearOffMenu(QString());
moveRfgMenu->addAction(aMoveRfgToTopLibrary);
moveRfgMenu->addAction(aMoveRfgToBottomLibrary);
moveRfgMenu->addSeparator();
moveRfgMenu->addAction(aMoveRfgToHand);
moveRfgMenu->addSeparator();
moveRfgMenu->addAction(aMoveRfgToGrave);
sbMenu = playerMenu->addMenu(QString()); sbMenu = playerMenu->addMenu(QString());
sbMenu->addAction(aViewSideboard); sbMenu->addAction(aViewSideboard);
@ -200,73 +117,14 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
createPredefinedTokenMenu = nullptr; createPredefinedTokenMenu = nullptr;
aIncrementAllCardCounters = nullptr; aIncrementAllCardCounters = nullptr;
mCardCounters = nullptr; mCardCounters = nullptr;
moveHandMenu = nullptr;
aMoveHandToTopLibrary = nullptr;
aMoveHandToBottomLibrary = nullptr;
aMoveHandToGrave = nullptr;
aMoveHandToRfg = nullptr;
moveGraveMenu = nullptr;
aMoveGraveToTopLibrary = nullptr;
aMoveGraveToBottomLibrary = nullptr;
aMoveGraveToHand = nullptr;
aMoveGraveToRfg = nullptr;
moveRfgMenu = nullptr;
aMoveRfgToTopLibrary = nullptr;
aMoveRfgToBottomLibrary = nullptr;
aMoveRfgToHand = nullptr;
aMoveRfgToGrave = nullptr;
aViewLibrary = nullptr;
aViewHand = nullptr;
aSortHand = nullptr;
aViewTopCards = nullptr;
aViewBottomCards = nullptr;
mRevealLibrary = nullptr;
mLendLibrary = nullptr;
mRevealTopCard = nullptr;
topLibraryMenu = nullptr;
bottomLibraryMenu = nullptr;
aAlwaysRevealTopCard = nullptr;
aAlwaysLookAtTopCard = nullptr;
aOpenDeckInDeckEditor = nullptr;
aViewSideboard = nullptr; aViewSideboard = nullptr;
aDrawCard = nullptr;
aDrawCards = nullptr;
aUndoDraw = nullptr;
aMulligan = nullptr;
aShuffle = nullptr;
aMoveTopToPlay = nullptr;
aMoveTopToPlayFaceDown = nullptr;
aMoveTopCardToBottom = nullptr;
aMoveTopCardToGraveyard = nullptr;
aMoveTopCardToExile = nullptr;
aMoveTopCardsToGraveyard = nullptr;
aMoveTopCardsToExile = nullptr;
aMoveTopCardsUntil = nullptr;
aShuffleTopCards = nullptr;
aDrawBottomCard = nullptr;
aDrawBottomCards = nullptr;
aMoveBottomToPlay = nullptr;
aMoveBottomToPlayFaceDown = nullptr;
aMoveBottomCardToGraveyard = nullptr;
aMoveBottomCardToExile = nullptr;
aMoveBottomCardsToGraveyard = nullptr;
aMoveBottomCardsToExile = nullptr;
aMoveBottomCardToTop = nullptr;
aShuffleBottomCards = nullptr;
handMenu = nullptr; handMenu = nullptr;
mRevealHand = nullptr;
mRevealRandomHandCard = nullptr;
mRevealRandomGraveyardCard = nullptr;
sbMenu = nullptr; sbMenu = nullptr;
libraryMenu = nullptr; libraryMenu = nullptr;
countersMenu = nullptr;
mCustomZones = nullptr; aUntapAll = nullptr;
aRollDie = nullptr;
} }
aTap = new QAction(this); aTap = new QAction(this);
@ -281,26 +139,6 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
connect(aUnattach, &QAction::triggered, playerActions, &PlayerActions::actUnattach); connect(aUnattach, &QAction::triggered, playerActions, &PlayerActions::actUnattach);
aDrawArrow = new QAction(this); aDrawArrow = new QAction(this);
connect(aDrawArrow, &QAction::triggered, playerActions, &PlayerActions::actDrawArrow); connect(aDrawArrow, &QAction::triggered, playerActions, &PlayerActions::actDrawArrow);
aIncP = new QAction(this);
connect(aIncP, &QAction::triggered, playerActions, &PlayerActions::actIncP);
aDecP = new QAction(this);
connect(aDecP, &QAction::triggered, playerActions, &PlayerActions::actDecP);
aIncT = new QAction(this);
connect(aIncT, &QAction::triggered, playerActions, &PlayerActions::actIncT);
aDecT = new QAction(this);
connect(aDecT, &QAction::triggered, playerActions, &PlayerActions::actDecT);
aIncPT = new QAction(this);
connect(aIncPT, &QAction::triggered, playerActions, [playerActions] { playerActions->actIncPT(); });
aDecPT = new QAction(this);
connect(aDecPT, &QAction::triggered, playerActions, &PlayerActions::actDecPT);
aFlowP = new QAction(this);
connect(aFlowP, &QAction::triggered, playerActions, &PlayerActions::actFlowP);
aFlowT = new QAction(this);
connect(aFlowT, &QAction::triggered, playerActions, &PlayerActions::actFlowT);
aSetPT = new QAction(this);
connect(aSetPT, &QAction::triggered, playerActions, &PlayerActions::actSetPT);
aResetPT = new QAction(this);
connect(aResetPT, &QAction::triggered, playerActions, &PlayerActions::actResetPT);
aSetAnnotation = new QAction(this); aSetAnnotation = new QAction(this);
connect(aSetAnnotation, &QAction::triggered, playerActions, &PlayerActions::actSetAnnotation); connect(aSetAnnotation, &QAction::triggered, playerActions, &PlayerActions::actSetAnnotation);
aFlip = new QAction(this); aFlip = new QAction(this);
@ -366,7 +204,6 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
connect(player, &Player::clearCustomZonesMenu, this, &PlayerMenu::clearCustomZonesMenu); connect(player, &Player::clearCustomZonesMenu, this, &PlayerMenu::clearCustomZonesMenu);
connect(player, &Player::addViewCustomZoneActionToCustomZoneMenu, this, connect(player, &Player::addViewCustomZoneActionToCustomZoneMenu, this,
&PlayerMenu::addViewCustomZoneActionToCustomZoneMenu); &PlayerMenu::addViewCustomZoneActionToCustomZoneMenu);
connect(player, &Player::resetTopCardMenuActions, this, &PlayerMenu::resetTopCardMenuActions);
retranslateUi(); retranslateUi();
} }
@ -374,172 +211,22 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
void PlayerMenu::setMenusForGraphicItems() void PlayerMenu::setMenusForGraphicItems()
{ {
player->getGraphicsItem()->getTableZoneGraphicsItem()->setMenu(playerMenu); player->getGraphicsItem()->getTableZoneGraphicsItem()->setMenu(playerMenu);
player->getGraphicsItem()->getGraveyardZoneGraphicsItem()->setMenu(graveMenu, aViewGraveyard); //player->getGraphicsItem()->getGraveyardZoneGraphicsItem()->setMenu(graveMenu, aViewGraveyard);
player->getGraphicsItem()->getRfgZoneGraphicsItem()->setMenu(rfgMenu, aViewRfg); //player->getGraphicsItem()->getRfgZoneGraphicsItem()->setMenu(rfgMenu, aViewRfg);
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) { if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
player->getGraphicsItem()->getHandZoneGraphicsItem()->setMenu(handMenu); player->getGraphicsItem()->getHandZoneGraphicsItem()->setMenu(handMenu);
player->getGraphicsItem()->getDeckZoneGraphicsItem()->setMenu(libraryMenu, aDrawCard); // player->getGraphicsItem()->getDeckZoneGraphicsItem()->setMenu(libraryMenu, aDrawCard);
player->getGraphicsItem()->getSideboardZoneGraphicsItem()->setMenu(sbMenu); player->getGraphicsItem()->getSideboardZoneGraphicsItem()->setMenu(sbMenu);
} }
} }
void PlayerMenu::createDrawActions()
{
PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aDrawCard = new QAction(this);
connect(aDrawCard, &QAction::triggered, playerActions, &PlayerActions::actDrawCard);
aDrawCards = new QAction(this);
connect(aDrawCards, &QAction::triggered, playerActions, &PlayerActions::actDrawCards);
aUndoDraw = new QAction(this);
connect(aUndoDraw, &QAction::triggered, playerActions, &PlayerActions::actUndoDraw);
aMulligan = new QAction(this);
connect(aMulligan, &QAction::triggered, playerActions, &PlayerActions::actMulligan);
aDrawBottomCard = new QAction(this);
connect(aDrawBottomCard, &QAction::triggered, playerActions, &PlayerActions::actDrawBottomCard);
aDrawBottomCards = new QAction(this);
connect(aDrawBottomCards, &QAction::triggered, playerActions, &PlayerActions::actDrawBottomCards);
}
}
void PlayerMenu::createShuffleActions()
{
PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aShuffle = new QAction(this);
connect(aShuffle, &QAction::triggered, playerActions, &PlayerActions::actShuffle);
aShuffleTopCards = new QAction(this);
connect(aShuffleTopCards, &QAction::triggered, playerActions, &PlayerActions::actShuffleTop);
aShuffleBottomCards = new QAction(this);
connect(aShuffleBottomCards, &QAction::triggered, playerActions, &PlayerActions::actShuffleBottom);
}
}
void PlayerMenu::createMoveActions()
{
PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aMoveHandToTopLibrary = new QAction(this);
aMoveHandToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
aMoveHandToBottomLibrary = new QAction(this);
aMoveHandToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
aMoveHandToGrave = new QAction(this);
aMoveHandToGrave->setData(QList<QVariant>() << "grave" << 0);
aMoveHandToRfg = new QAction(this);
aMoveHandToRfg->setData(QList<QVariant>() << "rfg" << 0);
auto hand = player->getHandZone();
auto grave = player->getGraveZone();
auto rfg = player->getRfgZone();
connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
connect(aMoveHandToGrave, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
connect(aMoveHandToRfg, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
aMoveGraveToTopLibrary = new QAction(this);
aMoveGraveToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
aMoveGraveToBottomLibrary = new QAction(this);
aMoveGraveToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
aMoveGraveToHand = new QAction(this);
aMoveGraveToHand->setData(QList<QVariant>() << "hand" << 0);
aMoveGraveToRfg = new QAction(this);
aMoveGraveToRfg->setData(QList<QVariant>() << "rfg" << 0);
connect(aMoveGraveToTopLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
connect(aMoveGraveToBottomLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
connect(aMoveGraveToHand, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
connect(aMoveGraveToRfg, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
aMoveRfgToTopLibrary = new QAction(this);
aMoveRfgToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
aMoveRfgToBottomLibrary = new QAction(this);
aMoveRfgToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
aMoveRfgToHand = new QAction(this);
aMoveRfgToHand->setData(QList<QVariant>() << "hand" << 0);
aMoveRfgToGrave = new QAction(this);
aMoveRfgToGrave->setData(QList<QVariant>() << "grave" << 0);
connect(aMoveRfgToTopLibrary, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
connect(aMoveRfgToBottomLibrary, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
connect(aMoveRfgToHand, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
connect(aMoveRfgToGrave, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
aMoveTopToPlay = new QAction(this);
connect(aMoveTopToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToPlay);
aMoveTopToPlayFaceDown = new QAction(this);
connect(aMoveTopToPlayFaceDown, &QAction::triggered, playerActions,
&PlayerActions::actMoveTopCardToPlayFaceDown);
aMoveTopCardToGraveyard = new QAction(this);
connect(aMoveTopCardToGraveyard, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToGrave);
aMoveTopCardToExile = new QAction(this);
connect(aMoveTopCardToExile, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToExile);
aMoveTopCardsToGraveyard = new QAction(this);
connect(aMoveTopCardsToGraveyard, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardsToGrave);
aMoveTopCardsToExile = new QAction(this);
connect(aMoveTopCardsToExile, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardsToExile);
aMoveTopCardsUntil = new QAction(this);
connect(aMoveTopCardsUntil, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardsUntil);
aMoveTopCardToBottom = new QAction(this);
connect(aMoveTopCardToBottom, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToBottom);
aMoveBottomToPlay = new QAction(this);
connect(aMoveBottomToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveBottomCardToPlay);
aMoveBottomToPlayFaceDown = new QAction(this);
connect(aMoveBottomToPlayFaceDown, &QAction::triggered, playerActions,
&PlayerActions::actMoveBottomCardToPlayFaceDown);
aMoveBottomCardToGraveyard = new QAction(this);
connect(aMoveBottomCardToGraveyard, &QAction::triggered, playerActions,
&PlayerActions::actMoveBottomCardToGrave);
aMoveBottomCardToExile = new QAction(this);
connect(aMoveBottomCardToExile, &QAction::triggered, playerActions, &PlayerActions::actMoveBottomCardToExile);
aMoveBottomCardsToGraveyard = new QAction(this);
connect(aMoveBottomCardsToGraveyard, &QAction::triggered, playerActions,
&PlayerActions::actMoveBottomCardsToGrave);
aMoveBottomCardsToExile = new QAction(this);
connect(aMoveBottomCardsToExile, &QAction::triggered, playerActions, &PlayerActions::actMoveBottomCardsToExile);
aMoveBottomCardToTop = new QAction(this);
connect(aMoveBottomCardToTop, &QAction::triggered, playerActions, &PlayerActions::actMoveBottomCardToTop);
}
}
void PlayerMenu::createViewActions() void PlayerMenu::createViewActions()
{ {
PlayerActions *playerActions = player->getPlayerActions(); PlayerActions *playerActions = player->getPlayerActions();
aViewGraveyard = new QAction(this);
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
aViewRfg = new QAction(this);
connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg);
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) { if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aViewLibrary = new QAction(this);
connect(aViewLibrary, &QAction::triggered, playerActions, &PlayerActions::actViewLibrary);
aViewSideboard = new QAction(this); aViewSideboard = new QAction(this);
connect(aViewSideboard, &QAction::triggered, playerActions, &PlayerActions::actViewSideboard); connect(aViewSideboard, &QAction::triggered, playerActions, &PlayerActions::actViewSideboard);
aViewHand = new QAction(this);
connect(aViewHand, &QAction::triggered, playerActions, &PlayerActions::actViewHand);
aSortHand = new QAction(this);
connect(aSortHand, &QAction::triggered, playerActions, &PlayerActions::actSortHand);
aViewTopCards = new QAction(this);
connect(aViewTopCards, &QAction::triggered, playerActions, &PlayerActions::actViewTopCards);
aViewBottomCards = new QAction(this);
connect(aViewBottomCards, &QAction::triggered, playerActions, &PlayerActions::actViewBottomCards);
aAlwaysRevealTopCard = new QAction(this);
aAlwaysRevealTopCard->setCheckable(true);
connect(aAlwaysRevealTopCard, &QAction::triggered, playerActions, &PlayerActions::actAlwaysRevealTopCard);
aAlwaysLookAtTopCard = new QAction(this);
aAlwaysLookAtTopCard->setCheckable(true);
connect(aAlwaysLookAtTopCard, &QAction::triggered, playerActions, &PlayerActions::actAlwaysLookAtTopCard);
aOpenDeckInDeckEditor = new QAction(this);
aOpenDeckInDeckEditor->setEnabled(false);
connect(aOpenDeckInDeckEditor, &QAction::triggered, playerActions, &PlayerActions::actOpenDeckInDeckEditor);
} }
} }
@ -616,10 +303,10 @@ void PlayerMenu::playerListActionTriggered()
cmd.set_player_id(otherPlayerId); cmd.set_player_id(otherPlayerId);
} }
if (menu == mRevealLibrary || menu == mLendLibrary) { if (menu == libraryMenu->revealLibrary() || menu == libraryMenu->lendLibraryMenu()) {
cmd.set_zone_name("deck"); cmd.set_zone_name("deck");
cmd.set_grant_write_access(menu == mLendLibrary); cmd.set_grant_write_access(menu == libraryMenu->lendLibraryMenu());
} else if (menu == mRevealTopCard) { } else if (menu == libraryMenu->revealTopCardMenu()) {
int deckSize = player->getDeckZone()->getCards().size(); int deckSize = player->getDeckZone()->getCards().size();
bool ok; bool ok;
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Reveal top cards of library"), int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Reveal top cards of library"),
@ -632,9 +319,9 @@ void PlayerMenu::playerListActionTriggered()
cmd.add_card_id(0); cmd.add_card_id(0);
// defaultNumberTopCards = number; // defaultNumberTopCards = number;
} }
} else if (menu == mRevealHand) { } else if (menu == handMenu->revealHandMenu()) {
cmd.set_zone_name("hand"); cmd.set_zone_name("hand");
} else if (menu == mRevealRandomHandCard) { } else if (menu == handMenu->revealRandomHandCardMenu()) {
cmd.set_zone_name("hand"); cmd.set_zone_name("hand");
cmd.add_card_id(PlayerActions::RANDOM_CARD_FROM_ZONE); cmd.add_card_id(PlayerActions::RANDOM_CARD_FROM_ZONE);
} else { } else {
@ -719,7 +406,7 @@ QMenu *PlayerMenu::createCardMenu(const CardItem *card)
} }
cardMenu->addAction(aDrawArrow); cardMenu->addAction(aDrawArrow);
cardMenu->addSeparator(); cardMenu->addSeparator();
cardMenu->addMenu(createPtMenu()); cardMenu->addMenu(new PtMenu(player));
cardMenu->addAction(aSetAnnotation); cardMenu->addAction(aSetAnnotation);
cardMenu->addSeparator(); cardMenu->addSeparator();
cardMenu->addAction(aClone); cardMenu->addAction(aClone);
@ -865,25 +552,6 @@ QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
return menu; return menu;
} }
QMenu *PlayerMenu::createPtMenu() const
{
QMenu *ptMenu = new QMenu(tr("Power / toughness"));
ptMenu->addAction(aIncP);
ptMenu->addAction(aDecP);
ptMenu->addAction(aFlowP);
ptMenu->addSeparator();
ptMenu->addAction(aIncT);
ptMenu->addAction(aDecT);
ptMenu->addAction(aFlowT);
ptMenu->addSeparator();
ptMenu->addAction(aIncPT);
ptMenu->addAction(aDecPT);
ptMenu->addSeparator();
ptMenu->addAction(aSetPT);
ptMenu->addAction(aResetPT);
return ptMenu;
}
QMenu *PlayerMenu::createMoveMenu() const QMenu *PlayerMenu::createMoveMenu() const
{ {
QMenu *moveMenu = new QMenu(tr("Move to")); QMenu *moveMenu = new QMenu(tr("Move to"));
@ -1054,91 +722,18 @@ void PlayerMenu::populatePredefinedTokensMenu()
} }
} }
void PlayerMenu::enableOpenInDeckEditorAction() const
{
aOpenDeckInDeckEditor->setEnabled(true);
}
void PlayerMenu::resetTopCardMenuActions()
{
aAlwaysRevealTopCard->setChecked(false);
aAlwaysLookAtTopCard->setChecked(false);
}
void PlayerMenu::retranslateUi() void PlayerMenu::retranslateUi()
{ {
aViewGraveyard->setText(tr("&View graveyard"));
aViewRfg->setText(tr("&View exile"));
playerMenu->setTitle(tr("Player \"%1\"").arg(player->getPlayerInfo()->getName())); playerMenu->setTitle(tr("Player \"%1\"").arg(player->getPlayerInfo()->getName()));
graveMenu->setTitle(tr("&Graveyard")); graveMenu->setTitle(tr("&Graveyard"));
rfgMenu->setTitle(tr("&Exile")); rfgMenu->setTitle(tr("&Exile"));
if (player->getPlayerInfo()->getLocalOrJudge()) { if (player->getPlayerInfo()->getLocalOrJudge()) {
moveHandMenu->setTitle(tr("&Move hand to..."));
aMoveHandToTopLibrary->setText(tr("&Top of library"));
aMoveHandToBottomLibrary->setText(tr("&Bottom of library"));
aMoveHandToGrave->setText(tr("&Graveyard"));
aMoveHandToRfg->setText(tr("&Exile"));
moveGraveMenu->setTitle(tr("&Move graveyard to..."));
aMoveGraveToTopLibrary->setText(tr("&Top of library"));
aMoveGraveToBottomLibrary->setText(tr("&Bottom of library"));
aMoveGraveToHand->setText(tr("&Hand"));
aMoveGraveToRfg->setText(tr("&Exile"));
moveRfgMenu->setTitle(tr("&Move exile to..."));
aMoveRfgToTopLibrary->setText(tr("&Top of library"));
aMoveRfgToBottomLibrary->setText(tr("&Bottom of library"));
aMoveRfgToHand->setText(tr("&Hand"));
aMoveRfgToGrave->setText(tr("&Graveyard"));
aViewLibrary->setText(tr("&View library"));
aViewHand->setText(tr("&View hand"));
aSortHand->setText(tr("&Sort hand"));
aViewTopCards->setText(tr("View &top cards of library..."));
aViewBottomCards->setText(tr("View bottom cards of library..."));
mRevealLibrary->setTitle(tr("Reveal &library to..."));
mLendLibrary->setTitle(tr("Lend library to..."));
mRevealTopCard->setTitle(tr("Reveal &top cards to..."));
topLibraryMenu->setTitle(tr("&Top of library..."));
bottomLibraryMenu->setTitle(tr("&Bottom of library..."));
aAlwaysRevealTopCard->setText(tr("&Always reveal top card"));
aAlwaysLookAtTopCard->setText(tr("&Always look at top card"));
aOpenDeckInDeckEditor->setText(tr("&Open deck in deck editor"));
aViewSideboard->setText(tr("&View sideboard")); aViewSideboard->setText(tr("&View sideboard"));
aDrawCard->setText(tr("&Draw card"));
aDrawCards->setText(tr("D&raw cards..."));
aUndoDraw->setText(tr("&Undo last draw"));
aMulligan->setText(tr("Take &mulligan"));
aShuffle->setText(tr("Shuffle"));
aMoveTopToPlay->setText(tr("&Play top card"));
aMoveTopToPlayFaceDown->setText(tr("Play top card &face down"));
aMoveTopCardToBottom->setText(tr("Put top card on &bottom"));
aMoveTopCardToGraveyard->setText(tr("Move top card to grave&yard"));
aMoveTopCardToExile->setText(tr("Move top card to e&xile"));
aMoveTopCardsToGraveyard->setText(tr("Move top cards to &graveyard..."));
aMoveTopCardsToExile->setText(tr("Move top cards to &exile..."));
aMoveTopCardsUntil->setText(tr("Put top cards on stack &until..."));
aShuffleTopCards->setText(tr("Shuffle top cards..."));
aDrawBottomCard->setText(tr("&Draw bottom card"));
aDrawBottomCards->setText(tr("D&raw bottom cards..."));
aMoveBottomToPlay->setText(tr("&Play bottom card"));
aMoveBottomToPlayFaceDown->setText(tr("Play bottom card &face down"));
aMoveBottomCardToGraveyard->setText(tr("Move bottom card to grave&yard"));
aMoveBottomCardToExile->setText(tr("Move bottom card to e&xile"));
aMoveBottomCardsToGraveyard->setText(tr("Move bottom cards to &graveyard..."));
aMoveBottomCardsToExile->setText(tr("Move bottom cards to &exile..."));
aMoveBottomCardToTop->setText(tr("Put bottom card on &top"));
aShuffleBottomCards->setText(tr("Shuffle bottom cards..."));
handMenu->setTitle(tr("&Hand")); handMenu->setTitle(tr("&Hand"));
mRevealHand->setTitle(tr("&Reveal hand to..."));
mRevealRandomHandCard->setTitle(tr("Reveal r&andom card to..."));
mRevealRandomGraveyardCard->setTitle(tr("Reveal random card to..."));
sbMenu->setTitle(tr("&Sideboard")); sbMenu->setTitle(tr("&Sideboard"));
libraryMenu->setTitle(tr("&Library")); libraryMenu->setTitle(tr("&Library"));
countersMenu->setTitle(tr("&Counters")); countersMenu->setTitle(tr("&Counters"));
@ -1185,16 +780,6 @@ void PlayerMenu::retranslateUi()
aAttach->setText(tr("Attac&h to card...")); aAttach->setText(tr("Attac&h to card..."));
aUnattach->setText(tr("Unattac&h")); aUnattach->setText(tr("Unattac&h"));
aDrawArrow->setText(tr("&Draw arrow...")); aDrawArrow->setText(tr("&Draw arrow..."));
aIncP->setText(tr("&Increase power"));
aDecP->setText(tr("&Decrease power"));
aIncT->setText(tr("I&ncrease toughness"));
aDecT->setText(tr("D&ecrease toughness"));
aIncPT->setText(tr("In&crease power and toughness"));
aDecPT->setText(tr("Dec&rease power and toughness"));
aFlowP->setText(tr("Increase power and decrease toughness"));
aFlowT->setText(tr("Decrease power and increase toughness"));
aSetPT->setText(tr("Set &power and toughness..."));
aResetPT->setText(tr("Reset p&ower and toughness"));
aSetAnnotation->setText(tr("&Set annotation...")); aSetAnnotation->setText(tr("&Set annotation..."));
auto &cardCounterSettings = SettingsCache::instance().cardCounters(); auto &cardCounterSettings = SettingsCache::instance().cardCounters();
@ -1246,23 +831,12 @@ void PlayerMenu::setShortcutsActive()
setShortcutIfItExists(aAttach, shortcuts.getShortcut("Player/aAttach")); setShortcutIfItExists(aAttach, shortcuts.getShortcut("Player/aAttach"));
setShortcutIfItExists(aUnattach, shortcuts.getShortcut("Player/aUnattach")); setShortcutIfItExists(aUnattach, shortcuts.getShortcut("Player/aUnattach"));
setShortcutIfItExists(aDrawArrow, shortcuts.getShortcut("Player/aDrawArrow")); setShortcutIfItExists(aDrawArrow, shortcuts.getShortcut("Player/aDrawArrow"));
setShortcutIfItExists(aIncP, shortcuts.getShortcut("Player/aIncP"));
setShortcutIfItExists(aDecP, shortcuts.getShortcut("Player/aDecP"));
setShortcutIfItExists(aIncT, shortcuts.getShortcut("Player/aIncT"));
setShortcutIfItExists(aDecT, shortcuts.getShortcut("Player/aDecT"));
setShortcutIfItExists(aIncPT, shortcuts.getShortcut("Player/aIncPT"));
setShortcutIfItExists(aDecPT, shortcuts.getShortcut("Player/aDecPT"));
setShortcutIfItExists(aFlowP, shortcuts.getShortcut("Player/aFlowP"));
setShortcutIfItExists(aFlowT, shortcuts.getShortcut("Player/aFlowT"));
setShortcutIfItExists(aSetPT, shortcuts.getShortcut("Player/aSetPT"));
setShortcutIfItExists(aResetPT, shortcuts.getShortcut("Player/aResetPT"));
setShortcutIfItExists(aSetAnnotation, shortcuts.getShortcut("Player/aSetAnnotation")); setShortcutIfItExists(aSetAnnotation, shortcuts.getShortcut("Player/aSetAnnotation"));
setShortcutIfItExists(aMoveToTopLibrary, shortcuts.getShortcut("Player/aMoveToTopLibrary")); setShortcutIfItExists(aMoveToTopLibrary, shortcuts.getShortcut("Player/aMoveToTopLibrary"));
setShortcutIfItExists(aMoveToBottomLibrary, shortcuts.getShortcut("Player/aMoveToBottomLibrary")); setShortcutIfItExists(aMoveToBottomLibrary, shortcuts.getShortcut("Player/aMoveToBottomLibrary"));
setShortcutIfItExists(aMoveToHand, shortcuts.getShortcut("Player/aMoveToHand")); setShortcutIfItExists(aMoveToHand, shortcuts.getShortcut("Player/aMoveToHand"));
setShortcutIfItExists(aMoveToGraveyard, shortcuts.getShortcut("Player/aMoveToGraveyard")); setShortcutIfItExists(aMoveToGraveyard, shortcuts.getShortcut("Player/aMoveToGraveyard"));
setShortcutIfItExists(aMoveToExile, shortcuts.getShortcut("Player/aMoveToExile")); setShortcutIfItExists(aMoveToExile, shortcuts.getShortcut("Player/aMoveToExile"));
setShortcutIfItExists(aSortHand, shortcuts.getShortcut("Player/aSortHand"));
setShortcutIfItExists(aSelectAll, shortcuts.getShortcut("Player/aSelectAll")); setShortcutIfItExists(aSelectAll, shortcuts.getShortcut("Player/aSelectAll"));
setShortcutIfItExists(aSelectRow, shortcuts.getShortcut("Player/aSelectRow")); setShortcutIfItExists(aSelectRow, shortcuts.getShortcut("Player/aSelectRow"));
@ -1282,41 +856,10 @@ void PlayerMenu::setShortcutsActive()
setShortcutIfItExists(aIncrementAllCardCounters, shortcuts.getShortcut("Player/aIncrementAllCardCounters")); setShortcutIfItExists(aIncrementAllCardCounters, shortcuts.getShortcut("Player/aIncrementAllCardCounters"));
setShortcutIfItExists(aViewSideboard, shortcuts.getShortcut("Player/aViewSideboard")); setShortcutIfItExists(aViewSideboard, shortcuts.getShortcut("Player/aViewSideboard"));
setShortcutIfItExists(aViewLibrary, shortcuts.getShortcut("Player/aViewLibrary"));
setShortcutIfItExists(aViewHand, shortcuts.getShortcut("Player/aViewHand"));
setShortcutIfItExists(aViewTopCards, shortcuts.getShortcut("Player/aViewTopCards"));
setShortcutIfItExists(aViewBottomCards, shortcuts.getShortcut("Player/aViewBottomCards"));
setShortcutIfItExists(aViewGraveyard, shortcuts.getShortcut("Player/aViewGraveyard"));
setShortcutIfItExists(aDrawCard, shortcuts.getShortcut("Player/aDrawCard"));
setShortcutIfItExists(aDrawCards, shortcuts.getShortcut("Player/aDrawCards"));
setShortcutIfItExists(aUndoDraw, shortcuts.getShortcut("Player/aUndoDraw"));
setShortcutIfItExists(aMulligan, shortcuts.getShortcut("Player/aMulligan"));
setShortcutIfItExists(aShuffle, shortcuts.getShortcut("Player/aShuffle"));
setShortcutIfItExists(aShuffleTopCards, shortcuts.getShortcut("Player/aShuffleTopCards"));
setShortcutIfItExists(aShuffleBottomCards, shortcuts.getShortcut("Player/aShuffleBottomCards"));
setShortcutIfItExists(aUntapAll, shortcuts.getShortcut("Player/aUntapAll")); setShortcutIfItExists(aUntapAll, shortcuts.getShortcut("Player/aUntapAll"));
setShortcutIfItExists(aRollDie, shortcuts.getShortcut("Player/aRollDie")); setShortcutIfItExists(aRollDie, shortcuts.getShortcut("Player/aRollDie"));
setShortcutIfItExists(aCreateToken, shortcuts.getShortcut("Player/aCreateToken")); setShortcutIfItExists(aCreateToken, shortcuts.getShortcut("Player/aCreateToken"));
setShortcutIfItExists(aCreateAnotherToken, shortcuts.getShortcut("Player/aCreateAnotherToken")); setShortcutIfItExists(aCreateAnotherToken, shortcuts.getShortcut("Player/aCreateAnotherToken"));
setShortcutIfItExists(aAlwaysRevealTopCard, shortcuts.getShortcut("Player/aAlwaysRevealTopCard"));
setShortcutIfItExists(aAlwaysLookAtTopCard, shortcuts.getShortcut("Player/aAlwaysLookAtTopCard"));
setShortcutIfItExists(aMoveTopToPlay, shortcuts.getShortcut("Player/aMoveTopToPlay"));
setShortcutIfItExists(aMoveTopToPlayFaceDown, shortcuts.getShortcut("Player/aMoveTopToPlayFaceDown"));
setShortcutIfItExists(aMoveTopCardToGraveyard, shortcuts.getShortcut("Player/aMoveTopCardToGraveyard"));
setShortcutIfItExists(aMoveTopCardsToGraveyard, shortcuts.getShortcut("Player/aMoveTopCardsToGraveyard"));
setShortcutIfItExists(aMoveTopCardToExile, shortcuts.getShortcut("Player/aMoveTopCardToExile"));
setShortcutIfItExists(aMoveTopCardsToExile, shortcuts.getShortcut("Player/aMoveTopCardsToExile"));
setShortcutIfItExists(aMoveTopCardsUntil, shortcuts.getShortcut("Player/aMoveTopCardsUntil"));
setShortcutIfItExists(aMoveTopCardToBottom, shortcuts.getShortcut("Player/aMoveTopCardToBottom"));
setShortcutIfItExists(aDrawBottomCard, shortcuts.getShortcut("Player/aDrawBottomCard"));
setShortcutIfItExists(aDrawBottomCards, shortcuts.getShortcut("Player/aDrawBottomCards"));
setShortcutIfItExists(aMoveBottomToPlay, shortcuts.getShortcut("Player/aMoveBottomToPlay"));
setShortcutIfItExists(aMoveBottomToPlayFaceDown, shortcuts.getShortcut("Player/aMoveBottomToPlayFaceDown"));
setShortcutIfItExists(aMoveBottomCardToGraveyard, shortcuts.getShortcut("Player/aMoveBottomCardToGrave"));
setShortcutIfItExists(aMoveBottomCardsToGraveyard, shortcuts.getShortcut("Player/aMoveBottomCardsToGrave"));
setShortcutIfItExists(aMoveBottomCardToExile, shortcuts.getShortcut("Player/aMoveBottomCardToExile"));
setShortcutIfItExists(aMoveBottomCardsToExile, shortcuts.getShortcut("Player/aMoveBottomCardsToExile"));
setShortcutIfItExists(aMoveBottomCardToTop, shortcuts.getShortcut("Player/aMoveBottomCardToTop"));
setShortcutIfItExists(aPlayFacedown, shortcuts.getShortcut("Player/aPlayFacedown")); setShortcutIfItExists(aPlayFacedown, shortcuts.getShortcut("Player/aPlayFacedown"));
setShortcutIfItExists(aPlay, shortcuts.getShortcut("Player/aPlay")); setShortcutIfItExists(aPlay, shortcuts.getShortcut("Player/aPlay"));
@ -1334,41 +877,11 @@ void PlayerMenu::setShortcutsInactive()
shortcutsActive = false; shortcutsActive = false;
clearShortcutIfItExists(aViewSideboard); clearShortcutIfItExists(aViewSideboard);
clearShortcutIfItExists(aViewLibrary);
clearShortcutIfItExists(aViewHand);
clearShortcutIfItExists(aViewTopCards);
clearShortcutIfItExists(aViewBottomCards);
clearShortcutIfItExists(aViewGraveyard);
clearShortcutIfItExists(aDrawCard);
clearShortcutIfItExists(aDrawCards);
clearShortcutIfItExists(aUndoDraw);
clearShortcutIfItExists(aMulligan);
clearShortcutIfItExists(aShuffle);
clearShortcutIfItExists(aShuffleTopCards);
clearShortcutIfItExists(aShuffleBottomCards);
clearShortcutIfItExists(aUntapAll); clearShortcutIfItExists(aUntapAll);
clearShortcutIfItExists(aRollDie); clearShortcutIfItExists(aRollDie);
clearShortcutIfItExists(aCreateToken); clearShortcutIfItExists(aCreateToken);
clearShortcutIfItExists(aCreateAnotherToken); clearShortcutIfItExists(aCreateAnotherToken);
clearShortcutIfItExists(aAlwaysRevealTopCard);
clearShortcutIfItExists(aAlwaysLookAtTopCard);
clearShortcutIfItExists(aMoveTopToPlay);
clearShortcutIfItExists(aMoveTopToPlayFaceDown);
clearShortcutIfItExists(aMoveTopCardToGraveyard);
clearShortcutIfItExists(aMoveTopCardsToGraveyard);
clearShortcutIfItExists(aMoveTopCardToExile);
clearShortcutIfItExists(aMoveTopCardsToExile);
clearShortcutIfItExists(aMoveTopCardsUntil);
clearShortcutIfItExists(aDrawBottomCard);
clearShortcutIfItExists(aDrawBottomCards);
clearShortcutIfItExists(aMoveBottomToPlay);
clearShortcutIfItExists(aMoveBottomToPlayFaceDown);
clearShortcutIfItExists(aMoveBottomCardToGraveyard);
clearShortcutIfItExists(aMoveBottomCardsToGraveyard);
clearShortcutIfItExists(aMoveBottomCardToExile);
clearShortcutIfItExists(aMoveBottomCardsToExile);
clearShortcutIfItExists(aIncrementAllCardCounters); clearShortcutIfItExists(aIncrementAllCardCounters);
clearShortcutIfItExists(aSortHand);
QMapIterator<int, AbstractCounter *> counterIterator(player->getCounters()); QMapIterator<int, AbstractCounter *> counterIterator(player->getCounters());
while (counterIterator.hasNext()) { while (counterIterator.hasNext()) {

View file

@ -1,8 +1,12 @@
#ifndef COCKATRICE_PLAYER_MENU_H #ifndef COCKATRICE_PLAYER_MENU_H
#define COCKATRICE_PLAYER_MENU_H #define COCKATRICE_PLAYER_MENU_H
#include "../../client/tearoff_menu.h" #include "../../../client/tearoff_menu.h"
#include "player.h" #include "../player.h"
#include "grave_menu.h"
#include "hand_menu.h"
#include "library_menu.h"
#include "rfg_menu.h"
#include <QMenu> #include <QMenu>
#include <QObject> #include <QObject>
@ -15,9 +19,7 @@ signals:
void cardMenuUpdated(QMenu *cardMenu); void cardMenuUpdated(QMenu *cardMenu);
public slots: public slots:
QMenu *createPtMenu() const;
QMenu *createMoveMenu() const; QMenu *createMoveMenu() const;
void enableOpenInDeckEditorAction() const;
void populatePredefinedTokensMenu(); void populatePredefinedTokensMenu();
void setMenusForGraphicItems(); void setMenusForGraphicItems();
@ -28,13 +30,9 @@ private slots:
void refreshShortcuts(); void refreshShortcuts();
void clearCustomZonesMenu(); void clearCustomZonesMenu();
void addViewCustomZoneActionToCustomZoneMenu(QString zoneName); void addViewCustomZoneActionToCustomZoneMenu(QString zoneName);
void resetTopCardMenuActions();
public: public:
PlayerMenu(Player *player); PlayerMenu(Player *player);
void createDrawActions();
void createShuffleActions();
void createMoveActions();
void createViewActions(); void createViewActions();
void retranslateUi(); void retranslateUi();
@ -59,16 +57,6 @@ public:
return predefinedTokens; return predefinedTokens;
} }
[[nodiscard]] bool isAlwaysRevealTopCardChecked()
{
return aAlwaysRevealTopCard->isChecked();
}
[[nodiscard]] bool isAlwaysLookAtTopCardChecked()
{
return aAlwaysLookAtTopCard->isChecked();
}
[[nodiscard]] QMenu *getPlayerMenu() const [[nodiscard]] QMenu *getPlayerMenu() const
{ {
return playerMenu; return playerMenu;
@ -79,6 +67,11 @@ public:
return countersMenu; return countersMenu;
} }
[[nodiscard]] LibraryMenu *getLibraryMenu() const
{
return libraryMenu;
}
bool getShortcutsActive() const bool getShortcutsActive() const
{ {
return shortcutsActive; return shortcutsActive;
@ -91,30 +84,23 @@ public:
private: private:
Player *player; Player *player;
QMenu *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu, *mRevealLibrary, *mLendLibrary, *mRevealTopCard, QMenu *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu, *mCustomZones,
*mRevealHand, *mRevealRandomHandCard, *mRevealRandomGraveyardCard, *mCustomZones, *mCardCounters; *mCardCounters;
TearOffMenu *moveGraveMenu, *moveRfgMenu, *graveMenu, *moveHandMenu, *handMenu, *libraryMenu, *topLibraryMenu, HandMenu *handMenu;
*bottomLibraryMenu, *rfgMenu, *playerMenu; LibraryMenu *libraryMenu;
GraveyardMenu *graveMenu;
RfgMenu *rfgMenu;
TearOffMenu *playerMenu;
QList<QMenu *> playerLists; QList<QMenu *> playerLists;
QList<QMenu *> singlePlayerLists; QList<QMenu *> singlePlayerLists;
QList<QAction *> allPlayersActions; QList<QAction *> allPlayersActions;
QList<QPair<QString, int>> playersInfo; QList<QPair<QString, int>> playersInfo;
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg, QAction *aViewSideboard, *aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken;
*aMoveGraveToTopLibrary, *aMoveGraveToBottomLibrary, *aMoveGraveToHand, *aMoveGraveToRfg, *aMoveRfgToTopLibrary,
*aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave, *aViewHand, *aViewLibrary, *aViewTopCards,
*aViewBottomCards, *aAlwaysRevealTopCard, *aAlwaysLookAtTopCard, *aOpenDeckInDeckEditor,
*aMoveTopCardToGraveyard, *aMoveTopCardToExile, *aMoveTopCardsToGraveyard, *aMoveTopCardsToExile,
*aMoveTopCardsUntil, *aMoveTopCardToBottom, *aViewGraveyard, *aViewRfg, *aViewSideboard, *aDrawCard,
*aDrawCards, *aUndoDraw, *aMulligan, *aShuffle, *aShuffleTopCards, *aShuffleBottomCards, *aMoveTopToPlay,
*aMoveTopToPlayFaceDown, *aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken, *aMoveBottomToPlay,
*aMoveBottomToPlayFaceDown, *aMoveBottomCardToTop, *aMoveBottomCardToGraveyard, *aMoveBottomCardToExile,
*aMoveBottomCardsToGraveyard, *aMoveBottomCardsToExile, *aDrawBottomCard, *aDrawBottomCards;
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter; QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aResetPT, QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetAnnotation, *aFlip, *aPeek, *aClone,
*aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aFlowP, *aFlowT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile, *aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile,
*aMoveToXfromTopOfLibrary, *aSelectAll, *aSelectRow, *aSelectColumn, *aSortHand, *aIncrementAllCardCounters; *aMoveToXfromTopOfLibrary, *aSelectAll, *aSelectRow, *aSelectColumn, *aIncrementAllCardCounters;
bool shortcutsActive; bool shortcutsActive;
QStringList predefinedTokens; QStringList predefinedTokens;

View file

@ -0,0 +1,76 @@
#include "pt_menu.h"
#include "../player.h"
#include "../player_actions.h"
PtMenu::PtMenu(Player *player) : QMenu(tr("Power / toughness"))
{
PlayerActions *playerActions = player->getPlayerActions();
aIncP = new QAction(this);
connect(aIncP, &QAction::triggered, playerActions, &PlayerActions::actIncP);
aDecP = new QAction(this);
connect(aDecP, &QAction::triggered, playerActions, &PlayerActions::actDecP);
aIncT = new QAction(this);
connect(aIncT, &QAction::triggered, playerActions, &PlayerActions::actIncT);
aDecT = new QAction(this);
connect(aDecT, &QAction::triggered, playerActions, &PlayerActions::actDecT);
aIncPT = new QAction(this);
connect(aIncPT, &QAction::triggered, playerActions, [playerActions] { playerActions->actIncPT(); });
aDecPT = new QAction(this);
connect(aDecPT, &QAction::triggered, playerActions, &PlayerActions::actDecPT);
aFlowP = new QAction(this);
connect(aFlowP, &QAction::triggered, playerActions, &PlayerActions::actFlowP);
aFlowT = new QAction(this);
connect(aFlowT, &QAction::triggered, playerActions, &PlayerActions::actFlowT);
aSetPT = new QAction(this);
connect(aSetPT, &QAction::triggered, playerActions, &PlayerActions::actSetPT);
aResetPT = new QAction(this);
connect(aResetPT, &QAction::triggered, playerActions, &PlayerActions::actResetPT);
addAction(aIncP);
addAction(aDecP);
addAction(aFlowP);
addSeparator();
addAction(aIncT);
addAction(aDecT);
addAction(aFlowT);
addSeparator();
addAction(aIncPT);
addAction(aDecPT);
addSeparator();
addAction(aSetPT);
addAction(aResetPT);
retranslateUi();
}
void PtMenu::retranslateUi()
{
aIncP->setText(tr("&Increase power"));
aDecP->setText(tr("&Decrease power"));
aIncT->setText(tr("I&ncrease toughness"));
aDecT->setText(tr("D&ecrease toughness"));
aIncPT->setText(tr("In&crease power and toughness"));
aDecPT->setText(tr("Dec&rease power and toughness"));
aFlowP->setText(tr("Increase power and decrease toughness"));
aFlowT->setText(tr("Decrease power and increase toughness"));
aSetPT->setText(tr("Set &power and toughness..."));
aResetPT->setText(tr("Reset p&ower and toughness"));
}
void PtMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aIncP->setShortcuts(shortcuts.getShortcut("Player/aIncP"));
aDecP->setShortcuts(shortcuts.getShortcut("Player/aDecP"));
aIncT->setShortcuts(shortcuts.getShortcut("Player/aIncT"));
aDecT->setShortcuts(shortcuts.getShortcut("Player/aDecT"));
aIncPT->setShortcuts(shortcuts.getShortcut("Player/aIncPT"));
aDecPT->setShortcuts(shortcuts.getShortcut("Player/aDecPT"));
aFlowP->setShortcuts(shortcuts.getShortcut("Player/aFlowP"));
aFlowT->setShortcuts(shortcuts.getShortcut("Player/aFlowT"));
aSetPT->setShortcuts(shortcuts.getShortcut("Player/aSetPT"));
aResetPT->setShortcuts(shortcuts.getShortcut("Player/aResetPT"));
}

View file

@ -0,0 +1,29 @@
#ifndef COCKATRICE_PT_MENU_H
#define COCKATRICE_PT_MENU_H
#include <QMenu>
class Player;
class PtMenu : public QMenu {
Q_OBJECT
public:
explicit PtMenu(Player *player);
void retranslateUi();
void setShortcutsActive();
QAction *aIncP = nullptr;
QAction *aDecP = nullptr;
QAction *aFlowP = nullptr;
QAction *aIncT = nullptr;
QAction *aDecT = nullptr;
QAction *aFlowT = nullptr;
QAction *aIncPT = nullptr;
QAction *aDecPT = nullptr;
QAction *aSetPT = nullptr;
QAction *aResetPT = nullptr;
};
#endif // COCKATRICE_PT_MENU_H

View file

@ -0,0 +1,67 @@
#include "rfg_menu.h"
#include "../player.h"
#include "../player_actions.h"
RfgMenu::RfgMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
{
createMoveActions();
createViewActions();
addAction(aViewRfg);
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
addSeparator();
moveRfgMenu = addTearOffMenu(QString());
moveRfgMenu->addAction(aMoveRfgToTopLibrary);
moveRfgMenu->addAction(aMoveRfgToBottomLibrary);
moveRfgMenu->addSeparator();
moveRfgMenu->addAction(aMoveRfgToHand);
moveRfgMenu->addSeparator();
moveRfgMenu->addAction(aMoveRfgToGrave);
}
retranslateUi();
}
void RfgMenu::createMoveActions()
{
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
auto rfg = player->getRfgZone();
aMoveRfgToTopLibrary = new QAction(this);
aMoveRfgToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
aMoveRfgToBottomLibrary = new QAction(this);
aMoveRfgToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
aMoveRfgToHand = new QAction(this);
aMoveRfgToHand->setData(QList<QVariant>() << "hand" << 0);
aMoveRfgToGrave = new QAction(this);
aMoveRfgToGrave->setData(QList<QVariant>() << "grave" << 0);
connect(aMoveRfgToTopLibrary, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
connect(aMoveRfgToBottomLibrary, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
connect(aMoveRfgToHand, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
connect(aMoveRfgToGrave, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
}
}
void RfgMenu::createViewActions()
{
PlayerActions *playerActions = player->getPlayerActions();
aViewRfg = new QAction(this);
connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg);
}
void RfgMenu::retranslateUi()
{
aViewRfg->setText(tr("&View exile"));
if (player->getPlayerInfo()->getLocalOrJudge()) {
moveRfgMenu->setTitle(tr("&Move exile to..."));
aMoveRfgToTopLibrary->setText(tr("&Top of library"));
aMoveRfgToBottomLibrary->setText(tr("&Bottom of library"));
aMoveRfgToHand->setText(tr("&Hand"));
aMoveRfgToGrave->setText(tr("&Graveyard"));
}
}

View file

@ -0,0 +1,30 @@
#ifndef COCKATRICE_RFG_MENU_H
#define COCKATRICE_RFG_MENU_H
#include "../../../client/tearoff_menu.h"
#include <QAction>
#include <QMenu>
class Player;
class RfgMenu : public TearOffMenu {
Q_OBJECT
public:
explicit RfgMenu(Player* player, QWidget* parent = nullptr);
void createMoveActions();
void createViewActions();
void retranslateUi();
QMenu * moveRfgMenu = nullptr;
QAction* aViewRfg = nullptr;
QAction* aMoveRfgToTopLibrary = nullptr;
QAction* aMoveRfgToBottomLibrary = nullptr;
QAction* aMoveRfgToHand = nullptr;
QAction* aMoveRfgToGrave = nullptr;
private:
Player* player;
};
#endif // COCKATRICE_RFG_MENU_H