mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 09:33:57 -07:00
refactor(client): use ZoneNames constants in zone menu handlers
Update all zone-specific menu files to use ZoneNames:: constants for QAction data values and zone targeting. This covers context menus for cards, graveyard, hand, and exile (RFG) zones. No functional changes - purely mechanical string literal replacement.
This commit is contained in:
parent
cde9f838a5
commit
1316aa73dc
4 changed files with 24 additions and 18 deletions
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <libcockatrice/card/database/card_database_manager.h>
|
#include <libcockatrice/card/database/card_database_manager.h>
|
||||||
#include <libcockatrice/card/relation/card_relation.h>
|
#include <libcockatrice/card/relation/card_relation.h>
|
||||||
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive)
|
CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive)
|
||||||
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
|
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
|
||||||
|
|
@ -115,11 +116,12 @@ CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive
|
||||||
} else if (writeableCard) {
|
} else if (writeableCard) {
|
||||||
|
|
||||||
if (card->getZone()) {
|
if (card->getZone()) {
|
||||||
if (card->getZone()->getName() == "table") {
|
if (card->getZone()->getName() == ZoneNames::TABLE) {
|
||||||
createTableMenu();
|
createTableMenu();
|
||||||
} else if (card->getZone()->getName() == "stack") {
|
} else if (card->getZone()->getName() == ZoneNames::STACK) {
|
||||||
createStackMenu();
|
createStackMenu();
|
||||||
} else if (card->getZone()->getName() == "rfg" || card->getZone()->getName() == "grave") {
|
} else if (card->getZone()->getName() == ZoneNames::EXILE ||
|
||||||
|
card->getZone()->getName() == ZoneNames::GRAVE) {
|
||||||
createGraveyardOrExileMenu();
|
createGraveyardOrExileMenu();
|
||||||
} else {
|
} else {
|
||||||
createHandOrCustomZoneMenu();
|
createHandOrCustomZoneMenu();
|
||||||
|
|
@ -128,7 +130,7 @@ CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive
|
||||||
addMenu(new MoveMenu(player));
|
addMenu(new MoveMenu(player));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (card->getZone() && card->getZone()->getName() != "hand") {
|
if (card->getZone() && card->getZone()->getName() != ZoneNames::HAND) {
|
||||||
addAction(aDrawArrow);
|
addAction(aDrawArrow);
|
||||||
addSeparator();
|
addSeparator();
|
||||||
addRelatedCardView();
|
addRelatedCardView();
|
||||||
|
|
@ -285,7 +287,7 @@ void CardMenu::createHandOrCustomZoneMenu()
|
||||||
addMenu(new MoveMenu(player));
|
addMenu(new MoveMenu(player));
|
||||||
|
|
||||||
// actions that are really wonky when done from deck or sideboard
|
// actions that are really wonky when done from deck or sideboard
|
||||||
if (card->getZone()->getName() == "hand") {
|
if (card->getZone()->getName() == ZoneNames::HAND) {
|
||||||
addSeparator();
|
addSeparator();
|
||||||
addAction(aAttach);
|
addAction(aAttach);
|
||||||
addAction(aDrawArrow);
|
addAction(aDrawArrow);
|
||||||
|
|
@ -298,7 +300,7 @@ void CardMenu::createHandOrCustomZoneMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
addRelatedCardView();
|
addRelatedCardView();
|
||||||
if (card->getZone()->getName() == "hand") {
|
if (card->getZone()->getName() == ZoneNames::HAND) {
|
||||||
addRelatedCardActions();
|
addRelatedCardActions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
GraveyardMenu::GraveyardMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
GraveyardMenu::GraveyardMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
|
|
@ -39,16 +40,16 @@ void GraveyardMenu::createMoveActions()
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
aMoveGraveToTopLibrary = new QAction(this);
|
aMoveGraveToTopLibrary = new QAction(this);
|
||||||
aMoveGraveToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
|
aMoveGraveToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
|
|
||||||
aMoveGraveToBottomLibrary = new QAction(this);
|
aMoveGraveToBottomLibrary = new QAction(this);
|
||||||
aMoveGraveToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
|
aMoveGraveToBottomLibrary->setData(QList<QVariant>() << ZoneNames::DECK << -1);
|
||||||
|
|
||||||
aMoveGraveToHand = new QAction(this);
|
aMoveGraveToHand = new QAction(this);
|
||||||
aMoveGraveToHand->setData(QList<QVariant>() << "hand" << 0);
|
aMoveGraveToHand->setData(QList<QVariant>() << ZoneNames::HAND << 0);
|
||||||
|
|
||||||
aMoveGraveToRfg = new QAction(this);
|
aMoveGraveToRfg = new QAction(this);
|
||||||
aMoveGraveToRfg->setData(QList<QVariant>() << "rfg" << 0);
|
aMoveGraveToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0);
|
||||||
|
|
||||||
connect(aMoveGraveToTopLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
|
connect(aMoveGraveToTopLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
|
||||||
connect(aMoveGraveToBottomLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
|
connect(aMoveGraveToBottomLibrary, &QAction::triggered, grave, &PileZoneLogic::moveAllToZone);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player)
|
HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
|
|
@ -76,13 +77,13 @@ HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : T
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
aMoveHandToTopLibrary = new QAction(this);
|
aMoveHandToTopLibrary = new QAction(this);
|
||||||
aMoveHandToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
|
aMoveHandToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
aMoveHandToBottomLibrary = new QAction(this);
|
aMoveHandToBottomLibrary = new QAction(this);
|
||||||
aMoveHandToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
|
aMoveHandToBottomLibrary->setData(QList<QVariant>() << ZoneNames::DECK << -1);
|
||||||
aMoveHandToGrave = new QAction(this);
|
aMoveHandToGrave = new QAction(this);
|
||||||
aMoveHandToGrave->setData(QList<QVariant>() << "grave" << 0);
|
aMoveHandToGrave->setData(QList<QVariant>() << ZoneNames::GRAVE << 0);
|
||||||
aMoveHandToRfg = new QAction(this);
|
aMoveHandToRfg = new QAction(this);
|
||||||
aMoveHandToRfg->setData(QList<QVariant>() << "rfg" << 0);
|
aMoveHandToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0);
|
||||||
|
|
||||||
auto hand = player->getHandZone();
|
auto hand = player->getHandZone();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
#include "../player.h"
|
#include "../player.h"
|
||||||
#include "../player_actions.h"
|
#include "../player_actions.h"
|
||||||
|
|
||||||
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
RfgMenu::RfgMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
RfgMenu::RfgMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
createMoveActions();
|
createMoveActions();
|
||||||
|
|
@ -30,13 +32,13 @@ void RfgMenu::createMoveActions()
|
||||||
auto rfg = player->getRfgZone();
|
auto rfg = player->getRfgZone();
|
||||||
|
|
||||||
aMoveRfgToTopLibrary = new QAction(this);
|
aMoveRfgToTopLibrary = new QAction(this);
|
||||||
aMoveRfgToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
|
aMoveRfgToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
aMoveRfgToBottomLibrary = new QAction(this);
|
aMoveRfgToBottomLibrary = new QAction(this);
|
||||||
aMoveRfgToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
|
aMoveRfgToBottomLibrary->setData(QList<QVariant>() << ZoneNames::DECK << -1);
|
||||||
aMoveRfgToHand = new QAction(this);
|
aMoveRfgToHand = new QAction(this);
|
||||||
aMoveRfgToHand->setData(QList<QVariant>() << "hand" << 0);
|
aMoveRfgToHand->setData(QList<QVariant>() << ZoneNames::HAND << 0);
|
||||||
aMoveRfgToGrave = new QAction(this);
|
aMoveRfgToGrave = new QAction(this);
|
||||||
aMoveRfgToGrave->setData(QList<QVariant>() << "grave" << 0);
|
aMoveRfgToGrave->setData(QList<QVariant>() << ZoneNames::GRAVE << 0);
|
||||||
|
|
||||||
connect(aMoveRfgToTopLibrary, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
|
connect(aMoveRfgToTopLibrary, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
|
||||||
connect(aMoveRfgToBottomLibrary, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
|
connect(aMoveRfgToBottomLibrary, &QAction::triggered, rfg, &PileZoneLogic::moveAllToZone);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue