mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
move cardMenu saving to TabGame
This commit is contained in:
parent
fc6b3de1a3
commit
a433ce3082
4 changed files with 26 additions and 20 deletions
|
|
@ -261,6 +261,10 @@ void TabGame::retranslateUi()
|
|||
sayLabel->setText(tr("&Say:"));
|
||||
}
|
||||
|
||||
if (aCardMenu) {
|
||||
aCardMenu->setText(tr("Selected cards"));
|
||||
}
|
||||
|
||||
viewMenu->setTitle(tr("&View"));
|
||||
cardInfoDockMenu->setTitle(tr("Card Info"));
|
||||
messageLayoutDockMenu->setTitle(tr("Messages"));
|
||||
|
|
@ -576,6 +580,7 @@ Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
|
|||
scene->addPlayer(newPlayer);
|
||||
|
||||
connect(newPlayer, &Player::newCardAdded, this, &TabGame::newCardAdded);
|
||||
connect(newPlayer, &Player::cardMenuUpdated, this, &TabGame::setCardMenu);
|
||||
messageLog->connectToPlayer(newPlayer);
|
||||
|
||||
if (local && !spectator) {
|
||||
|
|
@ -1232,6 +1237,18 @@ void TabGame::updateCardMenu(AbstractCardItem *card)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param menu The menu to set. Pass in nullptr to set the menu to empty.
|
||||
*/
|
||||
void TabGame::setCardMenu(QMenu *menu)
|
||||
{
|
||||
if (menu) {
|
||||
aCardMenu->setMenu(menu);
|
||||
} else {
|
||||
aCardMenu->setMenu(new QMenu);
|
||||
}
|
||||
}
|
||||
|
||||
void TabGame::createMenuItems()
|
||||
{
|
||||
aNextPhase = new QAction(this);
|
||||
|
|
@ -1285,6 +1302,11 @@ void TabGame::createMenuItems()
|
|||
gameMenu->addAction(aConcede);
|
||||
gameMenu->addAction(aFocusChat);
|
||||
gameMenu->addAction(aLeaveGame);
|
||||
|
||||
gameMenu->addSeparator();
|
||||
|
||||
aCardMenu = gameMenu->addMenu(new QMenu(this));
|
||||
|
||||
addTabMenu(gameMenu);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ private:
|
|||
*aPlayerListDockVisible, *aPlayerListDockFloating, *aReplayDockVisible, *aReplayDockFloating;
|
||||
QAction *aFocusChat;
|
||||
QList<QAction *> phaseActions;
|
||||
QAction *aCardMenu;
|
||||
|
||||
Player *addPlayer(int playerId, const ServerInfo_User &info);
|
||||
|
||||
|
|
@ -172,6 +173,7 @@ private slots:
|
|||
void adminLockChanged(bool lock);
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
void updateCardMenu(AbstractCardItem *card);
|
||||
void setCardMenu(QMenu *menu);
|
||||
|
||||
void actGameInfo();
|
||||
void actConcede();
|
||||
|
|
|
|||
|
|
@ -449,11 +449,6 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
|||
initSayMenu();
|
||||
}
|
||||
|
||||
aCardMenu = new QAction(this);
|
||||
aCardMenu->setEnabled(false);
|
||||
playerMenu->addSeparator();
|
||||
playerMenu->addAction(aCardMenu);
|
||||
|
||||
if (local || judge) {
|
||||
|
||||
for (auto &playerList : playerLists) {
|
||||
|
|
@ -870,8 +865,6 @@ void Player::retranslateUi()
|
|||
}
|
||||
}
|
||||
|
||||
aCardMenu->setText(tr("Selec&ted cards"));
|
||||
|
||||
if (local) {
|
||||
sayMenu->setTitle(tr("S&ay"));
|
||||
}
|
||||
|
|
@ -4233,23 +4226,13 @@ QMenu *Player::updateCardMenu(const CardItem *card)
|
|||
{
|
||||
QMenu *menu = createCardMenu(card);
|
||||
|
||||
aCardMenu->setEnabled(menu != nullptr);
|
||||
if (menu) {
|
||||
aCardMenu->setMenu(menu);
|
||||
emit cardMenuUpdated(menu);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
QMenu *Player::getCardMenu() const
|
||||
{
|
||||
if (aCardMenu != nullptr) {
|
||||
return aCardMenu->menu();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
QString Player::getName() const
|
||||
{
|
||||
return QString::fromStdString(userInfo->name());
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ signals:
|
|||
|
||||
void sizeChanged();
|
||||
void playerCountChanged();
|
||||
void cardMenuUpdated(QMenu *cardMenu);
|
||||
public slots:
|
||||
void actUntapAll();
|
||||
void actRollDie();
|
||||
|
|
@ -271,7 +272,6 @@ private:
|
|||
*aMoveBottomToPlayFaceDown, *aMoveBottomCardToTop, *aMoveBottomCardToGraveyard, *aMoveBottomCardToExile,
|
||||
*aMoveBottomCardsToGraveyard, *aMoveBottomCardsToExile, *aDrawBottomCard, *aDrawBottomCards;
|
||||
|
||||
QAction *aCardMenu;
|
||||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||
QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aResetPT,
|
||||
*aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aFlowP, *aFlowT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
|
||||
|
|
@ -487,7 +487,6 @@ public:
|
|||
return arrows;
|
||||
}
|
||||
QMenu *updateCardMenu(const CardItem *card);
|
||||
QMenu *getCardMenu() const;
|
||||
QMenu *createCardMenu(const CardItem *card);
|
||||
bool getActive() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue