mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 02:23:55 -07:00
[Game][Menus] Make Menus accept PlayerGraphicsItem instead of PlayerLogic (#6945)
* [Game][Player] Split Player into PlayerLogic/PlayerGraphicsItem Took 4 minutes Took 58 seconds Took 2 minutes * [Game][Menus] Make Menus accept PlayerGraphicsItem instead of PlayerLogic Took 7 minutes Took 4 minutes Took 9 seconds Took 2 minutes Took 5 minutes Took 58 seconds --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
90a49936d7
commit
f80b43139d
15 changed files with 93 additions and 78 deletions
|
|
@ -480,6 +480,7 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::RightButton && owner != nullptr) {
|
if (event->button() == Qt::RightButton && owner != nullptr) {
|
||||||
emit rightClicked(this, event->screenPos());
|
emit rightClicked(this, event->screenPos());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if ((event->modifiers() != Qt::AltModifier) && (event->button() == Qt::LeftButton) &&
|
if ((event->modifiers() != Qt::AltModifier) && (event->button() == Qt::LeftButton) &&
|
||||||
(!SettingsCache::instance().getDoubleClickToPlay())) {
|
(!SettingsCache::instance().getDoubleClickToPlay())) {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../../zones/view_zone_logic.h"
|
#include "../../zones/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 "../player_graphics_item.h"
|
||||||
#include "../player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "move_menu.h"
|
#include "move_menu.h"
|
||||||
#include "pt_menu.h"
|
#include "pt_menu.h"
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,14 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
GraveyardMenu::GraveyardMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
GraveyardMenu::GraveyardMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
createMoveActions();
|
createMoveActions();
|
||||||
createViewActions();
|
createViewActions();
|
||||||
|
|
||||||
addAction(aViewGraveyard);
|
addAction(aViewGraveyard);
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||||
mRevealRandomGraveyardCard = addMenu(QString());
|
mRevealRandomGraveyardCard = addMenu(QString());
|
||||||
connect(mRevealRandomGraveyardCard, &QMenu::aboutToShow, this,
|
connect(mRevealRandomGraveyardCard, &QMenu::aboutToShow, this,
|
||||||
&GraveyardMenu::populateRevealRandomMenuWithActivePlayers);
|
&GraveyardMenu::populateRevealRandomMenuWithActivePlayers);
|
||||||
|
|
@ -36,9 +36,9 @@ GraveyardMenu::GraveyardMenu(PlayerLogic *_player, QWidget *parent) : TearOffMen
|
||||||
|
|
||||||
void GraveyardMenu::createMoveActions()
|
void GraveyardMenu::createMoveActions()
|
||||||
{
|
{
|
||||||
auto grave = player->getGraveZone();
|
auto grave = player->getLogic()->getGraveZone();
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||||
aMoveGraveToTopLibrary = new QAction(this);
|
aMoveGraveToTopLibrary = new QAction(this);
|
||||||
aMoveGraveToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
aMoveGraveToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ void GraveyardMenu::createMoveActions()
|
||||||
|
|
||||||
void GraveyardMenu::createViewActions()
|
void GraveyardMenu::createViewActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getPlayerActions();
|
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
||||||
|
|
||||||
aViewGraveyard = new QAction(this);
|
aViewGraveyard = new QAction(this);
|
||||||
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
|
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
|
||||||
|
|
@ -76,9 +76,9 @@ void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealRandomGraveyardCard->addSeparator();
|
mRevealRandomGraveyardCard->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player) {
|
if (other == player->getLogic()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealRandomGraveyardCard->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealRandomGraveyardCard->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -90,7 +90,7 @@ void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
|
||||||
void GraveyardMenu::onRevealRandomTriggered()
|
void GraveyardMenu::onRevealRandomTriggered()
|
||||||
{
|
{
|
||||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||||
player->getPlayerActions()->actRevealRandomGraveyardCard(a->data().toInt());
|
player->getLogic()->getPlayerActions()->actRevealRandomGraveyardCard(a->data().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +100,7 @@ void GraveyardMenu::retranslateUi()
|
||||||
|
|
||||||
aViewGraveyard->setText(tr("&View graveyard"));
|
aViewGraveyard->setText(tr("&View graveyard"));
|
||||||
|
|
||||||
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
moveGraveMenu->setTitle(tr("&Move graveyard to..."));
|
moveGraveMenu->setTitle(tr("&Move graveyard to..."));
|
||||||
aMoveGraveToTopLibrary->setText(tr("&Top of library"));
|
aMoveGraveToTopLibrary->setText(tr("&Top of library"));
|
||||||
aMoveGraveToBottomLibrary->setText(tr("&Bottom of library"));
|
aMoveGraveToBottomLibrary->setText(tr("&Bottom of library"));
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerLogic;
|
class PlayerGraphicsItem;
|
||||||
class GraveyardMenu : public TearOffMenu, public AbstractPlayerComponent
|
class GraveyardMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -21,7 +21,7 @@ signals:
|
||||||
void newPlayerActionCreated(QAction *action);
|
void newPlayerActionCreated(QAction *action);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GraveyardMenu(PlayerLogic *player, QWidget *parent = nullptr);
|
explicit GraveyardMenu(PlayerGraphicsItem *player, QWidget *parent = nullptr);
|
||||||
void createMoveActions();
|
void createMoveActions();
|
||||||
void createViewActions();
|
void createViewActions();
|
||||||
void populateRevealRandomMenuWithActivePlayers();
|
void populateRevealRandomMenuWithActivePlayers();
|
||||||
|
|
@ -40,7 +40,7 @@ public:
|
||||||
QAction *aMoveGraveToRfg = nullptr;
|
QAction *aMoveGraveToRfg = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerGraphicsItem *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_GRAVE_MENU_H
|
#endif // COCKATRICE_GRAVE_MENU_H
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,20 @@
|
||||||
#include "../../../game_graphics/zones/hand_zone.h"
|
#include "../../../game_graphics/zones/hand_zone.h"
|
||||||
#include "../../abstract_game.h"
|
#include "../../abstract_game.h"
|
||||||
#include "../player_actions.h"
|
#include "../player_actions.h"
|
||||||
|
#include "../player_graphics_item.h"
|
||||||
#include "../player_logic.h"
|
#include "../player_logic.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
HandMenu::HandMenu(PlayerLogic *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player)
|
HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
auto *actions = player->getLogic()->getPlayerActions();
|
||||||
|
|
||||||
|
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||||
aViewHand = new QAction(this);
|
aViewHand = new QAction(this);
|
||||||
|
|
||||||
connect(aViewHand, &QAction::triggered, actions, &PlayerActions::actViewHand);
|
connect(aViewHand, &QAction::triggered, actions, &PlayerActions::actViewHand);
|
||||||
addAction(aViewHand);
|
addAction(aViewHand);
|
||||||
|
|
||||||
|
|
@ -75,7 +79,7 @@ HandMenu::HandMenu(PlayerLogic *_player, PlayerActions *actions, QWidget *parent
|
||||||
|
|
||||||
mMoveHandMenu = addTearOffMenu(QString());
|
mMoveHandMenu = addTearOffMenu(QString());
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||||
aMoveHandToTopLibrary = new QAction(this);
|
aMoveHandToTopLibrary = new QAction(this);
|
||||||
aMoveHandToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
aMoveHandToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
aMoveHandToBottomLibrary = new QAction(this);
|
aMoveHandToBottomLibrary = new QAction(this);
|
||||||
|
|
@ -85,7 +89,7 @@ HandMenu::HandMenu(PlayerLogic *_player, PlayerActions *actions, QWidget *parent
|
||||||
aMoveHandToRfg = new QAction(this);
|
aMoveHandToRfg = new QAction(this);
|
||||||
aMoveHandToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0);
|
aMoveHandToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0);
|
||||||
|
|
||||||
auto hand = player->getHandZone();
|
auto hand = player->getLogic()->getHandZone();
|
||||||
|
|
||||||
connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
|
connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
|
||||||
connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
|
connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
|
||||||
|
|
@ -107,7 +111,7 @@ void HandMenu::retranslateUi()
|
||||||
{
|
{
|
||||||
setTitle(tr("&Hand"));
|
setTitle(tr("&Hand"));
|
||||||
|
|
||||||
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
aViewHand->setText(tr("&View hand"));
|
aViewHand->setText(tr("&View hand"));
|
||||||
|
|
||||||
mSortHand->setTitle(tr("Sort hand by..."));
|
mSortHand->setTitle(tr("Sort hand by..."));
|
||||||
|
|
@ -166,9 +170,9 @@ void HandMenu::populateRevealHandMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealHand->addSeparator();
|
mRevealHand->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player) {
|
if (other == player->getLogic()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealHand->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealHand->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -185,9 +189,9 @@ void HandMenu::populateRevealRandomHandCardMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealRandomHandCard->addSeparator();
|
mRevealRandomHandCard->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player) {
|
if (other == player->getLogic()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealRandomHandCard->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealRandomHandCard->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -204,7 +208,7 @@ void HandMenu::onRevealHandTriggered()
|
||||||
}
|
}
|
||||||
|
|
||||||
const int targetId = action->data().toInt();
|
const int targetId = action->data().toInt();
|
||||||
player->getPlayerActions()->actRevealHand(targetId);
|
player->getLogic()->getPlayerActions()->actRevealHand(targetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandMenu::onRevealRandomHandCardTriggered()
|
void HandMenu::onRevealRandomHandCardTriggered()
|
||||||
|
|
@ -215,5 +219,5 @@ void HandMenu::onRevealRandomHandCardTriggered()
|
||||||
}
|
}
|
||||||
|
|
||||||
const int targetId = action->data().toInt();
|
const int targetId = action->data().toInt();
|
||||||
player->getPlayerActions()->actRevealRandomHandCard(targetId);
|
player->getLogic()->getPlayerActions()->actRevealRandomHandCard(targetId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerLogic;
|
class PlayerGraphicsItem;
|
||||||
class PlayerActions;
|
class PlayerActions;
|
||||||
|
|
||||||
class HandMenu : public TearOffMenu, public AbstractPlayerComponent
|
class HandMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||||
|
|
@ -21,7 +21,7 @@ class HandMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HandMenu(PlayerLogic *player, PlayerActions *actions, QWidget *parent = nullptr);
|
HandMenu(PlayerGraphicsItem *player, QWidget *parent = nullptr);
|
||||||
|
|
||||||
QMenu *revealHandMenu() const
|
QMenu *revealHandMenu() const
|
||||||
{
|
{
|
||||||
|
|
@ -43,7 +43,7 @@ private slots:
|
||||||
void onRevealRandomHandCardTriggered();
|
void onRevealRandomHandCardTriggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerGraphicsItem *player;
|
||||||
|
|
||||||
QAction *aViewHand = nullptr;
|
QAction *aViewHand = nullptr;
|
||||||
QAction *aMulligan = nullptr;
|
QAction *aMulligan = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,10 @@
|
||||||
#include "../player_logic.h"
|
#include "../player_logic.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QGraphicsView>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
LibraryMenu::LibraryMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
LibraryMenu::LibraryMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
createDrawActions();
|
createDrawActions();
|
||||||
createShuffleActions();
|
createShuffleActions();
|
||||||
|
|
@ -75,8 +76,8 @@ LibraryMenu::LibraryMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(pa
|
||||||
bottomLibraryMenu->addSeparator();
|
bottomLibraryMenu->addSeparator();
|
||||||
bottomLibraryMenu->addAction(aShuffleBottomCards);
|
bottomLibraryMenu->addAction(aShuffleBottomCards);
|
||||||
|
|
||||||
connect(player, &PlayerLogic::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions);
|
connect(player->getLogic(), &PlayerLogic::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions);
|
||||||
connect(player, &PlayerLogic::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction);
|
connect(player->getLogic(), &PlayerLogic::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
@ -94,9 +95,9 @@ void LibraryMenu::resetTopCardMenuActions()
|
||||||
|
|
||||||
void LibraryMenu::createDrawActions()
|
void LibraryMenu::createDrawActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getPlayerActions();
|
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||||
aDrawCard = new QAction(this);
|
aDrawCard = new QAction(this);
|
||||||
connect(aDrawCard, &QAction::triggered, playerActions, &PlayerActions::actDrawCard);
|
connect(aDrawCard, &QAction::triggered, playerActions, &PlayerActions::actDrawCard);
|
||||||
aDrawCards = new QAction(this);
|
aDrawCards = new QAction(this);
|
||||||
|
|
@ -112,9 +113,9 @@ void LibraryMenu::createDrawActions()
|
||||||
|
|
||||||
void LibraryMenu::createShuffleActions()
|
void LibraryMenu::createShuffleActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getPlayerActions();
|
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||||
aShuffle = new QAction(this);
|
aShuffle = new QAction(this);
|
||||||
connect(aShuffle, &QAction::triggered, playerActions, &PlayerActions::actShuffle);
|
connect(aShuffle, &QAction::triggered, playerActions, &PlayerActions::actShuffle);
|
||||||
aShuffleTopCards = new QAction(this);
|
aShuffleTopCards = new QAction(this);
|
||||||
|
|
@ -126,9 +127,9 @@ void LibraryMenu::createShuffleActions()
|
||||||
|
|
||||||
void LibraryMenu::createMoveActions()
|
void LibraryMenu::createMoveActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getPlayerActions();
|
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||||
aMoveTopToPlay = new QAction(this);
|
aMoveTopToPlay = new QAction(this);
|
||||||
connect(aMoveTopToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToPlay);
|
connect(aMoveTopToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToPlay);
|
||||||
aMoveTopToPlayFaceDown = new QAction(this);
|
aMoveTopToPlayFaceDown = new QAction(this);
|
||||||
|
|
@ -181,9 +182,9 @@ void LibraryMenu::createMoveActions()
|
||||||
|
|
||||||
void LibraryMenu::createViewActions()
|
void LibraryMenu::createViewActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getPlayerActions();
|
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
||||||
|
|
||||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
||||||
aViewLibrary = new QAction(this);
|
aViewLibrary = new QAction(this);
|
||||||
connect(aViewLibrary, &QAction::triggered, playerActions, &PlayerActions::actViewLibrary);
|
connect(aViewLibrary, &QAction::triggered, playerActions, &PlayerActions::actViewLibrary);
|
||||||
|
|
||||||
|
|
@ -207,7 +208,7 @@ void LibraryMenu::retranslateUi()
|
||||||
{
|
{
|
||||||
setTitle(tr("&Library"));
|
setTitle(tr("&Library"));
|
||||||
|
|
||||||
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
aViewLibrary->setText(tr("&View library"));
|
aViewLibrary->setText(tr("&View library"));
|
||||||
aViewTopCards->setText(tr("View &top cards of library..."));
|
aViewTopCards->setText(tr("View &top cards of library..."));
|
||||||
aViewBottomCards->setText(tr("View bottom cards of library..."));
|
aViewBottomCards->setText(tr("View bottom cards of library..."));
|
||||||
|
|
@ -263,9 +264,9 @@ void LibraryMenu::populateRevealLibraryMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealLibrary->addSeparator();
|
mRevealLibrary->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player) {
|
if (other == player->getLogic()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealLibrary->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealLibrary->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -278,9 +279,9 @@ void LibraryMenu::populateLendLibraryMenuWithActivePlayers()
|
||||||
{
|
{
|
||||||
mLendLibrary->clear();
|
mLendLibrary->clear();
|
||||||
|
|
||||||
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player) {
|
if (other == player->getLogic()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mLendLibrary->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mLendLibrary->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -299,9 +300,9 @@ void LibraryMenu::populateRevealTopCardMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealTopCard->addSeparator();
|
mRevealTopCard->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player) {
|
if (other == player->getLogic()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealTopCard->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealTopCard->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -313,27 +314,33 @@ void LibraryMenu::populateRevealTopCardMenuWithActivePlayers()
|
||||||
void LibraryMenu::onRevealLibraryTriggered()
|
void LibraryMenu::onRevealLibraryTriggered()
|
||||||
{
|
{
|
||||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||||
player->getPlayerActions()->actRevealLibrary(a->data().toInt());
|
player->getLogic()->getPlayerActions()->actRevealLibrary(a->data().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryMenu::onLendLibraryTriggered()
|
void LibraryMenu::onLendLibraryTriggered()
|
||||||
{
|
{
|
||||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||||
player->getPlayerActions()->actLendLibrary(a->data().toInt());
|
player->getLogic()->getPlayerActions()->actLendLibrary(a->data().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryMenu::onRevealTopCardTriggered()
|
void LibraryMenu::onRevealTopCardTriggered()
|
||||||
{
|
{
|
||||||
|
QWidget *parent = nullptr;
|
||||||
|
if (auto *view = player->scene() ? player->scene()->views().value(0) : nullptr) {
|
||||||
|
parent = view->window();
|
||||||
|
}
|
||||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||||
int deckSize = player->getDeckZone()->getCards().size();
|
|
||||||
bool ok;
|
int deckSize = player->getLogic()->getDeckZone()->getCards().size();
|
||||||
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Reveal top cards of library"),
|
bool ok = true;
|
||||||
|
int number = QInputDialog::getInt(parent, tr("Reveal top cards of library"),
|
||||||
tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1,
|
tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1,
|
||||||
deckSize, 1, &ok);
|
deckSize, 1, &ok);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
player->getPlayerActions()->actRevealTopCards(a->data().toInt(), number);
|
player->getLogic()->getPlayerActions()->actRevealTopCards(a->data().toInt(), number);
|
||||||
defaultNumberTopCards = number;
|
defaultNumberTopCards = number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
class PlayerGraphicsItem;
|
||||||
class PlayerLogic;
|
class PlayerLogic;
|
||||||
class PlayerActions;
|
class PlayerActions;
|
||||||
|
|
||||||
|
|
@ -24,7 +25,7 @@ public slots:
|
||||||
void resetTopCardMenuActions();
|
void resetTopCardMenuActions();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LibraryMenu(PlayerLogic *player, QWidget *parent = nullptr);
|
LibraryMenu(PlayerGraphicsItem *player, QWidget *parent = nullptr);
|
||||||
void createDrawActions();
|
void createDrawActions();
|
||||||
void createShuffleActions();
|
void createShuffleActions();
|
||||||
void createMoveActions();
|
void createMoveActions();
|
||||||
|
|
@ -111,7 +112,7 @@ public:
|
||||||
int defaultNumberTopCards = 1;
|
int defaultNumberTopCards = 1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerGraphicsItem *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_LIBRARY_MENU_H
|
#endif // COCKATRICE_LIBRARY_MENU_H
|
||||||
|
|
|
||||||
|
|
@ -18,18 +18,18 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_
|
||||||
playerMenu = new TearOffMenu();
|
playerMenu = new TearOffMenu();
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
handMenu = addManagedMenu<HandMenu>(player->getLogic(), player->getLogic()->getPlayerActions(), playerMenu);
|
handMenu = addManagedMenu<HandMenu>(player, playerMenu);
|
||||||
libraryMenu = addManagedMenu<LibraryMenu>(player->getLogic(), playerMenu);
|
libraryMenu = addManagedMenu<LibraryMenu>(player, playerMenu);
|
||||||
} else {
|
} else {
|
||||||
handMenu = nullptr;
|
handMenu = nullptr;
|
||||||
libraryMenu = nullptr;
|
libraryMenu = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
graveMenu = addManagedMenu<GraveyardMenu>(player->getLogic(), playerMenu);
|
graveMenu = addManagedMenu<GraveyardMenu>(player, playerMenu);
|
||||||
rfgMenu = addManagedMenu<RfgMenu>(player->getLogic(), playerMenu);
|
rfgMenu = addManagedMenu<RfgMenu>(player, playerMenu);
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
sideboardMenu = addManagedMenu<SideboardMenu>(player->getLogic(), playerMenu);
|
sideboardMenu = addManagedMenu<SideboardMenu>(player, playerMenu);
|
||||||
customZonesMenu = addManagedMenu<CustomZoneMenu>(player);
|
customZonesMenu = addManagedMenu<CustomZoneMenu>(player);
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocal()) {
|
if (player->getLogic()->getPlayerInfo()->getLocal()) {
|
||||||
sayMenu = addManagedMenu<SayMenu>(player->getLogic());
|
sayMenu = addManagedMenu<SayMenu>(player);
|
||||||
} else {
|
} else {
|
||||||
sayMenu = nullptr;
|
sayMenu = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@
|
||||||
|
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
RfgMenu::RfgMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
RfgMenu::RfgMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
createMoveActions();
|
createMoveActions();
|
||||||
createViewActions();
|
createViewActions();
|
||||||
|
|
||||||
addAction(aViewRfg);
|
addAction(aViewRfg);
|
||||||
|
|
||||||
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
addSeparator();
|
addSeparator();
|
||||||
moveRfgMenu = addTearOffMenu(QString());
|
moveRfgMenu = addTearOffMenu(QString());
|
||||||
moveRfgMenu->addAction(aMoveRfgToTopLibrary);
|
moveRfgMenu->addAction(aMoveRfgToTopLibrary);
|
||||||
|
|
@ -28,8 +28,8 @@ RfgMenu::RfgMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), p
|
||||||
|
|
||||||
void RfgMenu::createMoveActions()
|
void RfgMenu::createMoveActions()
|
||||||
{
|
{
|
||||||
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
auto rfg = player->getRfgZone();
|
auto rfg = player->getLogic()->getRfgZone();
|
||||||
|
|
||||||
aMoveRfgToTopLibrary = new QAction(this);
|
aMoveRfgToTopLibrary = new QAction(this);
|
||||||
aMoveRfgToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
aMoveRfgToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
|
|
@ -49,7 +49,7 @@ void RfgMenu::createMoveActions()
|
||||||
|
|
||||||
void RfgMenu::createViewActions()
|
void RfgMenu::createViewActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getPlayerActions();
|
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
||||||
|
|
||||||
aViewRfg = new QAction(this);
|
aViewRfg = new QAction(this);
|
||||||
connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg);
|
connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg);
|
||||||
|
|
@ -61,7 +61,7 @@ void RfgMenu::retranslateUi()
|
||||||
|
|
||||||
aViewRfg->setText(tr("&View exile"));
|
aViewRfg->setText(tr("&View exile"));
|
||||||
|
|
||||||
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
moveRfgMenu->setTitle(tr("&Move exile to..."));
|
moveRfgMenu->setTitle(tr("&Move exile to..."));
|
||||||
aMoveRfgToTopLibrary->setText(tr("&Top of library"));
|
aMoveRfgToTopLibrary->setText(tr("&Top of library"));
|
||||||
aMoveRfgToBottomLibrary->setText(tr("&Bottom of library"));
|
aMoveRfgToBottomLibrary->setText(tr("&Bottom of library"));
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerLogic;
|
class PlayerGraphicsItem;
|
||||||
class RfgMenu : public TearOffMenu, public AbstractPlayerComponent
|
class RfgMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit RfgMenu(PlayerLogic *player, QWidget *parent = nullptr);
|
explicit RfgMenu(PlayerGraphicsItem *player, QWidget *parent = nullptr);
|
||||||
void createMoveActions();
|
void createMoveActions();
|
||||||
void createViewActions();
|
void createViewActions();
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
|
|
@ -38,7 +38,7 @@ public:
|
||||||
QAction *aMoveRfgToGrave = nullptr;
|
QAction *aMoveRfgToGrave = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerGraphicsItem *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_RFG_MENU_H
|
#endif // COCKATRICE_RFG_MENU_H
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "../player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../player_logic.h"
|
#include "../player_logic.h"
|
||||||
|
|
||||||
SayMenu::SayMenu(PlayerLogic *_player) : player(_player)
|
SayMenu::SayMenu(PlayerGraphicsItem *_player) : player(_player)
|
||||||
{
|
{
|
||||||
connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu);
|
connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu);
|
||||||
initSayMenu();
|
initSayMenu();
|
||||||
|
|
@ -44,7 +44,7 @@ void SayMenu::initSayMenu()
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
|
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
|
||||||
connect(newAction, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actSayMessage);
|
connect(newAction, &QAction::triggered, player->getLogic()->getPlayerActions(), &PlayerActions::actSayMessage);
|
||||||
addAction(newAction);
|
addAction(newAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerLogic;
|
class PlayerGraphicsItem;
|
||||||
class SayMenu : public QMenu, public AbstractPlayerComponent
|
class SayMenu : public QMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SayMenu(PlayerLogic *player);
|
explicit SayMenu(PlayerGraphicsItem *player);
|
||||||
|
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
void setShortcutsActive() override;
|
void setShortcutsActive() override;
|
||||||
|
|
@ -26,7 +26,7 @@ private slots:
|
||||||
void initSayMenu();
|
void initSayMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerGraphicsItem *player;
|
||||||
bool shortcutsActive = false;
|
bool shortcutsActive = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
#include "../player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../player_logic.h"
|
#include "../player_logic.h"
|
||||||
|
|
||||||
SideboardMenu::SideboardMenu(PlayerLogic *player, QMenu *playerMenu) : QMenu(playerMenu)
|
SideboardMenu::SideboardMenu(PlayerGraphicsItem *player, QMenu *playerMenu) : QMenu(playerMenu)
|
||||||
{
|
{
|
||||||
aViewSideboard = new QAction(this);
|
aViewSideboard = new QAction(this);
|
||||||
connect(aViewSideboard, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actViewSideboard);
|
connect(aViewSideboard, &QAction::triggered, player->getLogic()->getPlayerActions(),
|
||||||
|
&PlayerActions::actViewSideboard);
|
||||||
|
|
||||||
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
addAction(aViewSideboard);
|
addAction(aViewSideboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,19 @@
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerLogic;
|
class PlayerGraphicsItem;
|
||||||
class SideboardMenu : public QMenu, public AbstractPlayerComponent
|
class SideboardMenu : public QMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SideboardMenu(PlayerLogic *player, QMenu *playerMenu);
|
explicit SideboardMenu(PlayerGraphicsItem *player, QMenu *playerMenu);
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
void setShortcutsActive() override;
|
void setShortcutsActive() override;
|
||||||
void setShortcutsInactive() override;
|
void setShortcutsInactive() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerGraphicsItem *player;
|
||||||
|
|
||||||
QAction *aViewSideboard;
|
QAction *aViewSideboard;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue