diff --git a/cockatrice/src/client/tabs/tab_game.cpp b/cockatrice/src/client/tabs/tab_game.cpp index c4a505ee5..dd92e2be4 100644 --- a/cockatrice/src/client/tabs/tab_game.cpp +++ b/cockatrice/src/client/tabs/tab_game.cpp @@ -766,13 +766,13 @@ void TabGame::createZoneForPlayer(Player *newPlayer, int playerId) for (int i = 1; i <= game->getPlayerManager()->getPlayerCount(); ++i) { bool aPlayerHasThisZone = false; for (auto &player : game->getPlayerManager()->getPlayers()) { - if (player->getPlayerInfo()->getZoneId() == i) { + if (player->getZoneId() == i) { aPlayerHasThisZone = true; break; } } if (!aPlayerHasThisZone) { - newPlayer->getPlayerInfo()->setZoneId(i); + newPlayer->setZoneId(i); break; } } diff --git a/cockatrice/src/game/player/player.cpp b/cockatrice/src/game/player/player.cpp index 0323a0092..58c5ed5f7 100644 --- a/cockatrice/src/game/player/player.cpp +++ b/cockatrice/src/game/player/player.cpp @@ -32,7 +32,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, Game *_parent) : QObject(_parent), game(_parent), playerInfo(new PlayerInfo(info, _id, _local, _judge)), playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), active(false), - conceded(false), deck(nullptr), dialogSemaphore(false) + conceded(false), deck(nullptr), zoneId(0), dialogSemaphore(false) { initializeZones(); @@ -44,7 +44,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, G connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::enableOpenInDeckEditorAction); connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::populatePredefinedTokensMenu); - // connect(this, &Player::openDeckEditor, game, &TabGame::openDeckEditor); + connect(this, &Player::openDeckEditor, game->getTab(), &TabGame::openDeckEditor); } void Player::initializeZones() @@ -109,6 +109,12 @@ void Player::setConceded(bool _conceded) } } +void Player::setZoneId(int _zoneId) +{ + zoneId = _zoneId; + graphicsItem->getPlayerArea()->setPlayerZoneId(zoneId); +} + void Player::processPlayerInfo(const ServerInfo_Player &info) { static QSet builtinZones{/* PileZones */ diff --git a/cockatrice/src/game/player/player.h b/cockatrice/src/game/player/player.h index 058e2c252..6382eb79b 100644 --- a/cockatrice/src/game/player/player.h +++ b/cockatrice/src/game/player/player.h @@ -217,6 +217,13 @@ public: dialogSemaphore = _active; } + int getZoneId() const + { + return zoneId; + } + + void setZoneId(int _zoneId); + private: Game *game; PlayerInfo *playerInfo; @@ -230,6 +237,7 @@ private: DeckLoader *deck; + int zoneId; QMap zones; QMap counters; QMap arrows; diff --git a/cockatrice/src/game/player/player_actions.cpp b/cockatrice/src/game/player/player_actions.cpp index 553cf8c5f..bb96ecb67 100644 --- a/cockatrice/src/game/player/player_actions.cpp +++ b/cockatrice/src/game/player/player_actions.cpp @@ -146,7 +146,6 @@ void PlayerActions::actViewTopCards() { int deckSize = player->getDeckZone()->getCards().size(); bool ok; - // TODO: Signal this int number = QInputDialog::getInt(player->getGame()->getTab(), tr("View top cards of library"), tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1, deckSize, 1, &ok); diff --git a/cockatrice/src/game/player/player_graphics_item.h b/cockatrice/src/game/player/player_graphics_item.h index 2d6d80c86..dc4dba237 100644 --- a/cockatrice/src/game/player/player_graphics_item.h +++ b/cockatrice/src/game/player/player_graphics_item.h @@ -53,6 +53,11 @@ public: return player; } + PlayerArea *getPlayerArea() const + { + return playerArea; + } + PlayerTarget *getPlayerTarget() const { return playerTarget; diff --git a/cockatrice/src/game/player/player_info.cpp b/cockatrice/src/game/player/player_info.cpp index 389b90d37..8507f75eb 100644 --- a/cockatrice/src/game/player/player_info.cpp +++ b/cockatrice/src/game/player/player_info.cpp @@ -1,15 +1,8 @@ #include "player_info.h" PlayerInfo::PlayerInfo(const ServerInfo_User &info, int _id, bool _local, bool _judge) - : id(_id), local(_local), judge(_judge), handVisible(false), zoneId(0) + : id(_id), local(_local), judge(_judge), handVisible(false) { userInfo = new ServerInfo_User; userInfo->CopyFrom(info); -} - -void PlayerInfo::setZoneId(int _zoneId) -{ - // TODO: deal with this - zoneId = _zoneId; - // playerArea->setPlayerZoneId(_zoneId); } \ No newline at end of file diff --git a/cockatrice/src/game/player/player_info.h b/cockatrice/src/game/player/player_info.h index 610a76d7b..3f7c0e85f 100644 --- a/cockatrice/src/game/player/player_info.h +++ b/cockatrice/src/game/player/player_info.h @@ -22,14 +22,6 @@ public: bool local; bool judge; bool handVisible; - int zoneId; - - int getZoneId() const - { - return zoneId; - } - - void setZoneId(int _zoneId); int getId() const { diff --git a/cockatrice/src/game/player/player_menu.cpp b/cockatrice/src/game/player/player_menu.cpp index 2b2cb325c..0c2b56514 100644 --- a/cockatrice/src/game/player/player_menu.cpp +++ b/cockatrice/src/game/player/player_menu.cpp @@ -519,8 +519,7 @@ void PlayerMenu::playerListActionTriggered() } else if (menu == mRevealTopCard) { int deckSize = player->getDeckZone()->getCards().size(); bool ok; - // TODO: Correctly parent this - int number = QInputDialog::getInt(/* player->getGame() */ nullptr, tr("Reveal top cards of library"), + int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Reveal top cards of library"), tr("Number of cards: (max. %1)").arg(deckSize), /* defaultNumberTopCards */ 1, 1, deckSize, 1, &ok); if (ok) { @@ -822,9 +821,9 @@ void PlayerMenu::addRelatedCardView(const CardItem *card, QMenu *cardMenu) CardRef cardRef = {relatedCardName, exactCard.getPrinting().getUuid()}; QAction *viewCard = viewRelatedCards->addAction(relatedCardName); Q_UNUSED(viewCard); - // TODO: Signal this - /*connect(viewCard, &QAction::triggered, player->getGame(), - [this, cardRef] { player->getGame()->viewCardInfo(cardRef); });*/ + + connect(viewCard, &QAction::triggered, player->getGame(), + [this, cardRef] { player->getGame()->getTab()->viewCardInfo(cardRef); }); } } diff --git a/cockatrice/src/game/zones/hand_zone.cpp b/cockatrice/src/game/zones/hand_zone.cpp index 7bd3af130..298926ff5 100644 --- a/cockatrice/src/game/zones/hand_zone.cpp +++ b/cockatrice/src/game/zones/hand_zone.cpp @@ -62,8 +62,7 @@ QRectF HandZone::boundingRect() const void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { - QBrush brush = - themeManager->getExtraBgBrush(ThemeManager::Hand, getLogic()->getPlayer()->getPlayerInfo()->getZoneId()); + QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Hand, getLogic()->getPlayer()->getZoneId()); painter->fillRect(boundingRect(), brush); } diff --git a/cockatrice/src/game/zones/stack_zone.cpp b/cockatrice/src/game/zones/stack_zone.cpp index 1a94945c9..3c940366b 100644 --- a/cockatrice/src/game/zones/stack_zone.cpp +++ b/cockatrice/src/game/zones/stack_zone.cpp @@ -32,8 +32,7 @@ QRectF StackZone::boundingRect() const void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { - QBrush brush = - themeManager->getExtraBgBrush(ThemeManager::Stack, getLogic()->getPlayer()->getPlayerInfo()->getZoneId()); + QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Stack, getLogic()->getPlayer()->getZoneId()); painter->fillRect(boundingRect(), brush); } diff --git a/cockatrice/src/game/zones/table_zone.cpp b/cockatrice/src/game/zones/table_zone.cpp index bc5f29c04..8505825f8 100644 --- a/cockatrice/src/game/zones/table_zone.cpp +++ b/cockatrice/src/game/zones/table_zone.cpp @@ -58,8 +58,7 @@ bool TableZone::isInverted() const void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { - QBrush brush = - themeManager->getExtraBgBrush(ThemeManager::Table, getLogic()->getPlayer()->getPlayerInfo()->getZoneId()); + QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Table, getLogic()->getPlayer()->getZoneId()); painter->fillRect(boundingRect(), brush); if (active) {