mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Refactor] Move attach and arrow previews from game logic into CardMenu
This commit is contained in:
parent
e34166ae85
commit
86e08db9ff
8 changed files with 28 additions and 30 deletions
|
|
@ -1417,14 +1417,6 @@ void PlayerActions::actSetPT(QList<CardItem *> selectedCards, const QString &pt)
|
||||||
player->getGame()->getGameEventHandler()->sendGameCommand(prepareGameCommand(commandList), playerid);
|
player->getGame()->getGameEventHandler()->sendGameCommand(prepareGameCommand(commandList), playerid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actDrawArrow()
|
|
||||||
{
|
|
||||||
auto *card = player->getGame()->getActiveCard();
|
|
||||||
if (card) {
|
|
||||||
card->drawArrow(Qt::red);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerActions::actIncP(QList<CardItem *> selectedCards)
|
void PlayerActions::actIncP(QList<CardItem *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, 1, 0);
|
actIncPT(selectedCards, 1, 0);
|
||||||
|
|
@ -1516,16 +1508,6 @@ void PlayerActions::actSetAnnotation(QList<CardItem *> selectedCards, const QStr
|
||||||
sendGameCommand(prepareGameCommand(commandList));
|
sendGameCommand(prepareGameCommand(commandList));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actAttach()
|
|
||||||
{
|
|
||||||
auto *card = player->getGame()->getActiveCard();
|
|
||||||
if (!card) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
card->drawAttachArrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerActions::actUnattach(QList<CardItem *> selectedCards)
|
void PlayerActions::actUnattach(QList<CardItem *> selectedCards)
|
||||||
{
|
{
|
||||||
QList<const ::google::protobuf::Message *> commandList;
|
QList<const ::google::protobuf::Message *> commandList;
|
||||||
|
|
|
||||||
|
|
@ -197,9 +197,7 @@ public slots:
|
||||||
void actRequestSetCardCounterDialog(QList<CardItem *> selectedCards, int counterId);
|
void actRequestSetCardCounterDialog(QList<CardItem *> selectedCards, int counterId);
|
||||||
void actSetCardCounter(QList<CardItem *> selectedCards, int counterId, const QString &counterValue);
|
void actSetCardCounter(QList<CardItem *> selectedCards, int counterId, const QString &counterValue);
|
||||||
void actIncrementAllCardCounters(QList<CardItem *> cardsToUpdate);
|
void actIncrementAllCardCounters(QList<CardItem *> cardsToUpdate);
|
||||||
void actAttach();
|
|
||||||
void actUnattach(QList<CardItem *> selectedCards);
|
void actUnattach(QList<CardItem *> selectedCards);
|
||||||
void actDrawArrow();
|
|
||||||
void actIncPT(QList<CardItem *> selectedCards, int deltaP, int deltaT);
|
void actIncPT(QList<CardItem *> selectedCards, int deltaP, int deltaT);
|
||||||
void actResetPT(QList<CardItem *> selectedCards);
|
void actResetPT(QList<CardItem *> selectedCards);
|
||||||
void actRequestSetPTDialog(QList<CardItem *> selectedCards);
|
void actRequestSetPTDialog(QList<CardItem *> selectedCards);
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ signals:
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
void cardZoneChanged(CardItem *card, bool sameZone);
|
void cardZoneChanged(CardItem *card, bool sameZone);
|
||||||
void requestCardMenuUpdate(const CardItem *card);
|
void requestCardMenuUpdate(CardItem *card);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Owning player instance. */
|
/** Owning player instance. */
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ signals:
|
||||||
/** @brief Emitted when the remote playmat (card/params) is updated from player properties. */
|
/** @brief Emitted when the remote playmat (card/params) is updated from player properties. */
|
||||||
void playmatChanged();
|
void playmatChanged();
|
||||||
void newCardAdded(AbstractCardItem *card);
|
void newCardAdded(AbstractCardItem *card);
|
||||||
void requestCardMenuUpdate(const CardItem *card);
|
void requestCardMenuUpdate(CardItem *card);
|
||||||
void counterAdded(CounterState *state);
|
void counterAdded(CounterState *state);
|
||||||
void counterRemoved(int counterId);
|
void counterRemoved(int counterId);
|
||||||
void rearrangeCounters();
|
void rearrangeCounters();
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ static QAction *makeAction(QObject *parent, Slot &&slot, bool checkable = false,
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _shortcutsActive)
|
CardMenu::CardMenu(PlayerGraphicsItem *_player, CardItem *_card, bool _shortcutsActive)
|
||||||
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
|
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
|
||||||
{
|
{
|
||||||
const QList<PlayerLogic *> &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
const QList<PlayerLogic *> &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
|
|
@ -108,15 +108,17 @@ CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _sho
|
||||||
aHide = makeAction(this, [actions, sel]() { actions->actHide(sel()); });
|
aHide = makeAction(this, [actions, sel]() { actions->actHide(sel()); });
|
||||||
aReduceLifeByPower = makeAction(this, [actions, sel]() { actions->actReduceLifeByPower(sel()); });
|
aReduceLifeByPower = makeAction(this, [actions, sel]() { actions->actReduceLifeByPower(sel()); });
|
||||||
|
|
||||||
// Actions that use activeCard, not selection — direct connection
|
// Actions bound to the card this menu was opened for
|
||||||
aAttach = new QAction(this);
|
aAttach = new QAction(this);
|
||||||
aDrawArrow = new QAction(this);
|
aDrawArrow = new QAction(this);
|
||||||
|
|
||||||
|
// Actions that use activeCard, not selection — direct connection
|
||||||
aSelectAll = new QAction(this);
|
aSelectAll = new QAction(this);
|
||||||
aSelectRow = new QAction(this);
|
aSelectRow = new QAction(this);
|
||||||
aSelectColumn = new QAction(this);
|
aSelectColumn = new QAction(this);
|
||||||
|
|
||||||
connect(aAttach, &QAction::triggered, actions, &PlayerActions::actAttach);
|
connect(aAttach, &QAction::triggered, this, &CardMenu::attachCard);
|
||||||
connect(aDrawArrow, &QAction::triggered, actions, &PlayerActions::actDrawArrow);
|
connect(aDrawArrow, &QAction::triggered, this, &CardMenu::drawArrow);
|
||||||
connect(aSelectAll, &QAction::triggered, actions, &PlayerActions::actSelectAll);
|
connect(aSelectAll, &QAction::triggered, actions, &PlayerActions::actSelectAll);
|
||||||
connect(aSelectRow, &QAction::triggered, actions, &PlayerActions::actSelectRow);
|
connect(aSelectRow, &QAction::triggered, actions, &PlayerActions::actSelectRow);
|
||||||
connect(aSelectColumn, &QAction::triggered, actions, &PlayerActions::actSelectColumn);
|
connect(aSelectColumn, &QAction::triggered, actions, &PlayerActions::actSelectColumn);
|
||||||
|
|
@ -501,6 +503,20 @@ void CardMenu::addRelatedCardActions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardMenu::attachCard()
|
||||||
|
{
|
||||||
|
if (card) {
|
||||||
|
card->drawAttachArrow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardMenu::drawArrow()
|
||||||
|
{
|
||||||
|
if (card) {
|
||||||
|
card->drawArrow(Qt::red);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CardMenu::retranslateUi()
|
void CardMenu::retranslateUi()
|
||||||
{
|
{
|
||||||
aSelectAll->setText(tr("&Select All"));
|
aSelectAll->setText(tr("&Select All"));
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ signals:
|
||||||
void cardInfoRequested(const CardRef &cardRef);
|
void cardInfoRequested(const CardRef &cardRef);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CardMenu(PlayerGraphicsItem *player, const CardItem *card, bool shortcutsActive);
|
explicit CardMenu(PlayerGraphicsItem *player, CardItem *card, bool shortcutsActive);
|
||||||
void removePlayer(PlayerLogic *playerToRemove);
|
void removePlayer(PlayerLogic *playerToRemove);
|
||||||
void createTableMenu(bool canModifyCard);
|
void createTableMenu(bool canModifyCard);
|
||||||
void createStackMenu(bool canModifyCard);
|
void createStackMenu(bool canModifyCard);
|
||||||
|
|
@ -53,11 +53,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerGraphicsItem *player;
|
||||||
const CardItem *card;
|
CardItem *card;
|
||||||
QList<QPair<QString, int>> playersInfo;
|
QList<QPair<QString, int>> playersInfo;
|
||||||
bool shortcutsActive;
|
bool shortcutsActive;
|
||||||
|
|
||||||
void addRelatedCardActions();
|
void addRelatedCardActions();
|
||||||
|
void attachCard();
|
||||||
|
void drawArrow();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void initContextualPlayersMenu(QMenu *menu, QAction *allPlayersAction);
|
void initContextualPlayersMenu(QMenu *menu, QAction *allPlayersAction);
|
||||||
void setShortcutsActive();
|
void setShortcutsActive();
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ void PlayerMenu::setMenusForGraphicItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
|
QMenu *PlayerMenu::updateCardMenu(CardItem *card)
|
||||||
{
|
{
|
||||||
if (!card) {
|
if (!card) {
|
||||||
emit cardMenuUpdated(nullptr);
|
emit cardMenuUpdated(nullptr);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setMenusForGraphicItems();
|
void setMenusForGraphicItems();
|
||||||
QMenu *updateCardMenu(const CardItem *card);
|
QMenu *updateCardMenu(CardItem *card);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshShortcuts();
|
void refreshShortcuts();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue