diff --git a/cockatrice/src/game/player/player.cpp b/cockatrice/src/game/player/player.cpp index e9a1b52c8..cd8cc70d5 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, AbstractGame *_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), zoneId(0), dialogSemaphore(false) + conceded(false), handVisible(false), deck(nullptr), zoneId(0), dialogSemaphore(false) { initializeZones(); @@ -41,6 +41,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, A playerMenu->setMenusForGraphicItems(); connect(this, &Player::activeChanged, graphicsItem, &PlayerGraphicsItem::onPlayerActiveChanged); + connect(this, &Player::handVisibleChanged, getHandZone(), &CardZoneLogic::setGraphicsVisibility); connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::enableOpenInDeckEditorAction); connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::populatePredefinedTokensMenu); diff --git a/cockatrice/src/game/player/player.h b/cockatrice/src/game/player/player.h index cd7d3f818..efc336d1c 100644 --- a/cockatrice/src/game/player/player.h +++ b/cockatrice/src/game/player/player.h @@ -69,6 +69,7 @@ signals: void clearCustomZonesMenu(); void addViewCustomZoneActionToCustomZoneMenu(QString zoneName); void resetTopCardMenuActions(); + void handVisibleChanged(bool visible); public slots: void setActive(bool _active); @@ -223,6 +224,17 @@ public: void setZoneId(int _zoneId); + void setHandVisible(bool _handVisible) + { + handVisible = _handVisible; + emit handVisibleChanged(handVisible); + } + + bool getHandVisible() const + { + return handVisible; + } + private: AbstractGame *game; PlayerInfo *playerInfo; @@ -233,6 +245,7 @@ private: bool active; bool conceded; + bool handVisible; DeckLoader *deck; diff --git a/cockatrice/src/game/player/player_graphics_item.cpp b/cockatrice/src/game/player/player_graphics_item.cpp index d4f7d47e3..e883b51d7 100644 --- a/cockatrice/src/game/player/player_graphics_item.cpp +++ b/cockatrice/src/game/player/player_graphics_item.cpp @@ -78,6 +78,10 @@ void PlayerGraphicsItem::initializeZones() handZoneGraphicsItem = new HandZone(player->getHandZone(), static_cast(tableZoneGraphicsItem->boundingRect().height()), this); + if (!player->getHandVisible()) { + player->getHandZone()->setGraphicsVisibility(false); + } + connect(handZoneGraphicsItem->getLogic(), &HandZoneLogic::cardCountChanged, handCounter, &HandCounter::updateNumber); connect(handCounter, &HandCounter::showContextMenu, handZoneGraphicsItem, &HandZone::showContextMenu); @@ -151,11 +155,11 @@ void PlayerGraphicsItem::rearrangeZones() if (SettingsCache::instance().getHorizontalHand()) { if (mirrored) { if (player->getHandZone()->contentsKnown()) { - player->getPlayerInfo()->setHandVisible(true); + player->setHandVisible(true); handZoneGraphicsItem->setPos(base); base += QPointF(0, handZoneGraphicsItem->boundingRect().height()); } else { - player->getPlayerInfo()->setHandVisible(false); + player->setHandVisible(false); } stackZoneGraphicsItem->setPos(base); @@ -169,16 +173,16 @@ void PlayerGraphicsItem::rearrangeZones() base += QPointF(0, tableZoneGraphicsItem->boundingRect().height()); if (player->getHandZone()->contentsKnown()) { - player->getPlayerInfo()->setHandVisible(true); + player->setHandVisible(true); handZoneGraphicsItem->setPos(base); } else { - player->getPlayerInfo()->setHandVisible(false); + player->setHandVisible(false); } } handZoneGraphicsItem->setWidth(tableZoneGraphicsItem->getWidth() + stackZoneGraphicsItem->boundingRect().width()); } else { - player->getPlayerInfo()->setHandVisible(true); + player->setHandVisible(true); handZoneGraphicsItem->setPos(base); base += QPointF(handZoneGraphicsItem->boundingRect().width(), 0); @@ -188,7 +192,6 @@ void PlayerGraphicsItem::rearrangeZones() tableZoneGraphicsItem->setPos(base); } - handZoneGraphicsItem->setVisible(player->getPlayerInfo()->getHandVisible()); handZoneGraphicsItem->updateOrientation(); tableZoneGraphicsItem->reorganizeCards(); updateBoundingRect(); @@ -200,8 +203,7 @@ void PlayerGraphicsItem::updateBoundingRect() prepareGeometryChange(); qreal width = CARD_HEIGHT + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width(); if (SettingsCache::instance().getHorizontalHand()) { - qreal handHeight = - player->getPlayerInfo()->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0; + qreal handHeight = player->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0; bRect = QRectF(0, 0, width + tableZoneGraphicsItem->boundingRect().width(), tableZoneGraphicsItem->boundingRect().height() + handHeight); } else { diff --git a/cockatrice/src/game/player/player_info.cpp b/cockatrice/src/game/player/player_info.cpp index 8507f75eb..c4debde0f 100644 --- a/cockatrice/src/game/player/player_info.cpp +++ b/cockatrice/src/game/player/player_info.cpp @@ -1,7 +1,7 @@ #include "player_info.h" PlayerInfo::PlayerInfo(const ServerInfo_User &info, int _id, bool _local, bool _judge) - : id(_id), local(_local), judge(_judge), handVisible(false) + : id(_id), local(_local), judge(_judge) { userInfo = new ServerInfo_User; userInfo->CopyFrom(info); diff --git a/cockatrice/src/game/player/player_info.h b/cockatrice/src/game/player/player_info.h index a8759b151..13f3ac1d4 100644 --- a/cockatrice/src/game/player/player_info.h +++ b/cockatrice/src/game/player/player_info.h @@ -21,7 +21,6 @@ public: int id; bool local; bool judge; - bool handVisible; int getId() const { @@ -50,16 +49,6 @@ public: return judge; } - void setHandVisible(bool _handVisible) - { - handVisible = _handVisible; - } - - bool getHandVisible() const - { - return handVisible; - } - QString getName() const { return QString::fromStdString(userInfo->name()); diff --git a/cockatrice/src/game/player/player_menu.cpp b/cockatrice/src/game/player/player_menu.cpp index 92330899d..bbfec538e 100644 --- a/cockatrice/src/game/player/player_menu.cpp +++ b/cockatrice/src/game/player/player_menu.cpp @@ -267,6 +267,8 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player) libraryMenu = nullptr; countersMenu = nullptr; mCustomZones = nullptr; + + aUntapAll = nullptr; } aTap = new QAction(this); diff --git a/cockatrice/src/game/zones/card_zone.cpp b/cockatrice/src/game/zones/card_zone.cpp index 0c189cd2b..a357da2a3 100644 --- a/cockatrice/src/game/zones/card_zone.cpp +++ b/cockatrice/src/game/zones/card_zone.cpp @@ -11,11 +11,18 @@ CardZone::CardZone(CardZoneLogic *_logic, QGraphicsItem *parent) { connect(logic, &CardZoneLogic::retranslateUi, this, &CardZone::retranslateUi); connect(logic, &CardZoneLogic::cardAdded, this, &CardZone::onCardAdded); - connect(logic, &CardZoneLogic::setGraphicsVisibility, this, [this](bool v) { this->setVisible(v); }); + connect(logic, &CardZoneLogic::setGraphicsVisibility, this, &CardZone::onGraphicsVisibilityChanged); connect(logic, &CardZoneLogic::updateGraphics, this, [this]() { update(); }); connect(logic, &CardZoneLogic::reorganizeCards, this, &CardZone::reorganizeCards); } +void CardZone::onGraphicsVisibilityChanged(bool _visible) +{ + setVisible(_visible); + qInfo() << "Visibility changed to " << _visible; + update(); +} + void CardZone::onCardAdded(CardItem *addedCard) { addedCard->setParentItem(this); diff --git a/cockatrice/src/game/zones/card_zone.h b/cockatrice/src/game/zones/card_zone.h index 1034c4668..7f1b21ec8 100644 --- a/cockatrice/src/game/zones/card_zone.h +++ b/cockatrice/src/game/zones/card_zone.h @@ -48,6 +48,7 @@ public: virtual void handleDropEvent(const QList &dragItem, CardZoneLogic *startZone, const QPoint &dropPoint) = 0; CardZone(CardZoneLogic *logic, QGraphicsItem *parent = nullptr); + void onGraphicsVisibilityChanged(bool _visible); void retranslateUi(); CardZoneLogic *getLogic() const