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