Lots of todos but it compiles.

Took 3 hours 38 minutes

Took 11 seconds

Took 9 minutes

Took 2 minutes

Took 22 minutes

Took 43 minutes

Took 4 minutes

Took 31 minutes

Took 7 seconds

Took 1 minute

[Game][Player] Pull out graphics_items out of player_logic

Took 3 minutes

Took 24 seconds

Took 5 minutes

Took 19 minutes

Took 7 minutes

Took 32 seconds

Took 3 minutes

Took 14 minutes

Took 5 seconds

Took 28 minutes

Took 5 minutes

Took 28 minutes

Took 7 seconds

Took 12 minutes

Took 20 minutes

Took 2 minutes
This commit is contained in:
Lukas Brübach 2026-05-21 23:26:31 +02:00
parent 0f3e6fbe26
commit 0cfffdf9df
62 changed files with 789 additions and 699 deletions

View file

@ -44,7 +44,7 @@ static QAction *makeAction(QObject *parent, Slot &&slot, bool checkable = false,
return a;
}
CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _shortcutsActive)
CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardState *_card, bool _shortcutsActive)
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
{
const QList<PlayerLogic *> &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
@ -63,7 +63,7 @@ CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _sho
auto *gameScene = player->getGameScene();
// Single selection resolver used by all lambdas — called at trigger time
auto sel = [gameScene]() { return gameScene->selectedCards(); };
auto sel = [gameScene]() { return gameScene->selectedCardsAsStates(); };
// Unified dispatcher for card menu actions
auto invoke = [actions, sel](CardMenuActionType type) {
@ -314,7 +314,7 @@ void CardMenu::createHandOrCustomZoneMenu(bool canModifyCard)
initContextualPlayersMenu(revealMenu, aRevealToAll);
connect(revealMenu, &QMenu::triggered, this, [this](QAction *action) {
player->getLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCards(), action);
player->getLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCardsAsStates(), action);
});
addSeparator();

View file

@ -7,9 +7,12 @@
#ifndef COCKATRICE_CARD_MENU_H
#define COCKATRICE_CARD_MENU_H
#include "libcockatrice/utility/card_ref.h"
#include <QMenu>
#include <libcockatrice/utility/card_ref.h>
class CardState;
class CardItem;
class PlayerGraphicsItem;
class PlayerLogic;
@ -21,7 +24,7 @@ signals:
void cardInfoRequested(const CardRef &cardRef);
public:
explicit CardMenu(PlayerGraphicsItem *player, const CardItem *card, bool shortcutsActive);
explicit CardMenu(PlayerGraphicsItem *player, const CardState *card, bool shortcutsActive);
void removePlayer(PlayerLogic *playerToRemove);
void createTableMenu(bool canModifyCard);
void createStackMenu(bool canModifyCard);
@ -47,7 +50,7 @@ public:
private:
PlayerGraphicsItem *player;
const CardItem *card;
const CardState *card;
QList<QPair<QString, int>> playersInfo;
bool shortcutsActive;

View file

@ -25,7 +25,8 @@ MoveMenu::MoveMenu(PlayerGraphicsItem *player) : QMenu(tr("Move to"))
auto invoke = [player](CardMenuActionType type) {
return [type, player]() {
player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCards(), type);
player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCardsAsStates(),
type);
};
};

View file

@ -69,7 +69,7 @@ void PlayerMenu::setMenusForGraphicItems()
}
}
QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
QMenu *PlayerMenu::updateCardMenu(const CardState *card)
{
if (!card) {
emit cardMenuUpdated(nullptr);
@ -80,7 +80,7 @@ QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
// only update the menu if the card is actually selected
if ((player->getLogic()->getGame()->getPlayerManager()->isSpectator() &&
!player->getLogic()->getGame()->getPlayerManager()->isJudge()) ||
player->getLogic()->getGame()->getActiveCard() != card) {
player->getLogic()->getGame()->getActiveCard()->getState() != card) {
return nullptr;
}

View file

@ -21,7 +21,7 @@
#include <QMenu>
#include <QObject>
class CardItem;
class CardState;
class CardMenu;
class PlayerGraphicsItem;
class PlayerMenu : public QObject
@ -37,7 +37,7 @@ signals:
public slots:
void setMenusForGraphicItems();
QMenu *updateCardMenu(const CardItem *card);
QMenu *updateCardMenu(const CardState *card);
private slots:
void refreshShortcuts();

View file

@ -10,34 +10,35 @@ PtMenu::PtMenu(PlayerGraphicsItem *player) : QMenu(tr("Power / toughness"))
aIncP = new QAction(this);
connect(aIncP, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actIncP(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actIncP(player->getGameScene()->selectedCardsAsStates()); });
aDecP = new QAction(this);
connect(aDecP, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actDecP(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actDecP(player->getGameScene()->selectedCardsAsStates()); });
aIncT = new QAction(this);
connect(aIncT, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actIncT(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actIncT(player->getGameScene()->selectedCardsAsStates()); });
aDecT = new QAction(this);
connect(aDecT, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actDecT(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actDecT(player->getGameScene()->selectedCardsAsStates()); });
aIncPT = new QAction(this);
connect(aIncPT, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actIncPT(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actIncPT(player->getGameScene()->selectedCardsAsStates()); });
aDecPT = new QAction(this);
connect(aDecPT, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actDecPT(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actDecPT(player->getGameScene()->selectedCardsAsStates()); });
aFlowP = new QAction(this);
connect(aFlowP, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actFlowP(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actFlowP(player->getGameScene()->selectedCardsAsStates()); });
aFlowT = new QAction(this);
connect(aFlowT, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actFlowT(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actFlowT(player->getGameScene()->selectedCardsAsStates()); });
aSetPT = new QAction(this);
connect(aSetPT, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actRequestSetPTDialog(player->getGameScene()->selectedCards()); });
connect(aSetPT, &QAction::triggered, playerActions, [player, playerActions] {
playerActions->actRequestSetPTDialog(player->getGameScene()->selectedCardsAsStates());
});
aResetPT = new QAction(this);
connect(aResetPT, &QAction::triggered, playerActions,
[player, playerActions] { playerActions->actResetPT(player->getGameScene()->selectedCards()); });
[player, playerActions] { playerActions->actResetPT(player->getGameScene()->selectedCardsAsStates()); });
addAction(aIncP);
addAction(aDecP);

View file

@ -38,7 +38,7 @@ UtilityMenu::UtilityMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu
aIncrementAllCardCounters = new QAction(this);
connect(aIncrementAllCardCounters, &QAction::triggered, playerActions, [this]() {
player->getLogic()->getPlayerActions()->actIncrementAllCardCounters(
player->getGameScene()->selectedCards());
player->getGameScene()->selectedCardsAsStates());
});
createPredefinedTokenMenu = new QMenu(QString());

View file

@ -8,6 +8,7 @@
#define COCKATRICE_UTILITY_MENU_H
#include "abstract_player_component.h"
#include "libcockatrice/card/card_info.h"
#include <QMenu>
#include <libcockatrice/card/card_info.h>

View file

@ -241,14 +241,14 @@ void PlayerDialogs::onMoveCardXCardsFromTopDialogRequested(int defaultNumberTopC
number -= 1; // indexes start at 0
if (ok) {
playerActions->actMoveCardXCardsFromTop(player->getGameScene()->selectedCards(), number);
playerActions->actMoveCardXCardsFromTop(player->getGameScene()->selectedCardsAsStates(), number);
}
}
void PlayerDialogs::onSetPTDialogRequested(const QString &oldPT)
{
bool ok;
auto cards = player->getGameScene()->selectedCards();
auto cards = player->getGameScene()->selectedCardsAsStates();
emit requestDialogSemaphore(true);
QString pt = getTextWithMax(dialogParent(), tr("Change power/toughness"), tr("Change stats to:"), QLineEdit::Normal,
oldPT, &ok);
@ -263,7 +263,7 @@ void PlayerDialogs::onSetPTDialogRequested(const QString &oldPT)
void PlayerDialogs::onSetAnnotationDialogRequested(const QString &oldAnnotation)
{
auto cards = player->getGameScene()->selectedCards();
auto cards = player->getGameScene()->selectedCardsAsStates();
emit requestDialogSemaphore(true);
AnnotationDialog *dialog = new AnnotationDialog(dialogParent());
dialog->setOptions(QInputDialog::UsePlainTextEditForTextInput);
@ -281,7 +281,7 @@ void PlayerDialogs::onSetAnnotationDialogRequested(const QString &oldAnnotation)
void PlayerDialogs::onSetCardCounterDialogRequested(int counterId, const QString &oldValueForDlg)
{
auto cards = player->getGameScene()->selectedCards();
auto cards = player->getGameScene()->selectedCardsAsStates();
emit requestDialogSemaphore(true);
auto &cardCounterSettings = SettingsCache::instance().cardCounters();

View file

@ -126,12 +126,19 @@ void PlayerGraphicsItem::initializeZones()
connect(handCounter, &HandCounter::showContextMenu, handZoneGraphicsItem, &HandZone::showContextMenu);
zoneGraphicsItems.insert(player->getDeckZone()->getName(), deckZoneGraphicsItem);
connect(deckZoneGraphicsItem, &CardZone::cardItemAdded, this, &PlayerGraphicsItem::cardItemAdded);
zoneGraphicsItems.insert(player->getGraveZone()->getName(), graveyardZoneGraphicsItem);
connect(graveyardZoneGraphicsItem, &CardZone::cardItemAdded, this, &PlayerGraphicsItem::cardItemAdded);
zoneGraphicsItems.insert(player->getRfgZone()->getName(), rfgZoneGraphicsItem);
connect(rfgZoneGraphicsItem, &CardZone::cardItemAdded, this, &PlayerGraphicsItem::cardItemAdded);
zoneGraphicsItems.insert(player->getSideboardZone()->getName(), sideboardGraphicsItem);
connect(sideboardGraphicsItem, &CardZone::cardItemAdded, this, &PlayerGraphicsItem::cardItemAdded);
zoneGraphicsItems.insert(player->getTableZone()->getName(), tableZoneGraphicsItem);
connect(tableZoneGraphicsItem, &CardZone::cardItemAdded, this, &PlayerGraphicsItem::cardItemAdded);
zoneGraphicsItems.insert(player->getStackZone()->getName(), stackZoneGraphicsItem);
connect(stackZoneGraphicsItem, &CardZone::cardItemAdded, this, &PlayerGraphicsItem::cardItemAdded);
zoneGraphicsItems.insert(player->getHandZone()->getName(), handZoneGraphicsItem);
connect(handZoneGraphicsItem, &CardZone::cardItemAdded, this, &PlayerGraphicsItem::cardItemAdded);
}
void PlayerGraphicsItem::onCustomZoneAdded(QString customZoneName)

View file

@ -126,6 +126,7 @@ signals:
void playerCountChanged();
void mirroredChanged(bool isMirrored);
void cardInfoRequested(const CardRef &cardRef);
void cardItemAdded(CardItem *added);
private:
PlayerLogic *player;