From af2f8882935fc2576e3c31f467b7404fd0510718 Mon Sep 17 00:00:00 2001 From: BruebachL <44814898+BruebachL@users.noreply.github.com> Date: Tue, 19 May 2026 12:10:19 +0200 Subject: [PATCH] [Player] Pull handVisible out of player_info and let graphics_item just determine this on its own. (#6911) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 12 minutes Took 15 seconds Co-authored-by: Lukas BrĂ¼bach --- .../src/game/player/player_graphics_item.cpp | 15 +++++++-------- cockatrice/src/game/player/player_graphics_item.h | 1 + cockatrice/src/game/player/player_info.cpp | 2 +- cockatrice/src/game/player/player_info.h | 11 ----------- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/cockatrice/src/game/player/player_graphics_item.cpp b/cockatrice/src/game/player/player_graphics_item.cpp index a4f515274..52aa231db 100644 --- a/cockatrice/src/game/player/player_graphics_item.cpp +++ b/cockatrice/src/game/player/player_graphics_item.cpp @@ -158,11 +158,11 @@ void PlayerGraphicsItem::rearrangeZones() if (SettingsCache::instance().getHorizontalHand()) { if (mirrored) { if (player->getHandZone()->contentsKnown()) { - player->getPlayerInfo()->setHandVisible(true); + handVisible = true; handZoneGraphicsItem->setPos(base); base += QPointF(0, handZoneGraphicsItem->boundingRect().height()); } else { - player->getPlayerInfo()->setHandVisible(false); + handVisible = false; } stackZoneGraphicsItem->setPos(base); @@ -176,16 +176,16 @@ void PlayerGraphicsItem::rearrangeZones() base += QPointF(0, tableZoneGraphicsItem->boundingRect().height()); if (player->getHandZone()->contentsKnown()) { - player->getPlayerInfo()->setHandVisible(true); + handVisible = true; handZoneGraphicsItem->setPos(base); } else { - player->getPlayerInfo()->setHandVisible(false); + handVisible = false; } } handZoneGraphicsItem->setWidth(tableZoneGraphicsItem->getWidth() + stackZoneGraphicsItem->boundingRect().width()); } else { - player->getPlayerInfo()->setHandVisible(true); + handVisible = true; handZoneGraphicsItem->setPos(base); base += QPointF(handZoneGraphicsItem->boundingRect().width(), 0); @@ -195,7 +195,7 @@ void PlayerGraphicsItem::rearrangeZones() tableZoneGraphicsItem->setPos(base); } - handZoneGraphicsItem->setVisible(player->getPlayerInfo()->getHandVisible()); + handZoneGraphicsItem->setVisible(handVisible); handZoneGraphicsItem->updateOrientation(); tableZoneGraphicsItem->reorganizeCards(); updateBoundingRect(); @@ -207,8 +207,7 @@ void PlayerGraphicsItem::updateBoundingRect() prepareGeometryChange(); qreal width = CardDimensions::HEIGHT_F + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width(); if (SettingsCache::instance().getHorizontalHand()) { - qreal handHeight = - player->getPlayerInfo()->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0; + qreal handHeight = handVisible ? 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_graphics_item.h b/cockatrice/src/game/player/player_graphics_item.h index cba664dd9..fd4c469e7 100644 --- a/cockatrice/src/game/player/player_graphics_item.h +++ b/cockatrice/src/game/player/player_graphics_item.h @@ -121,6 +121,7 @@ private: HandZone *handZoneGraphicsItem; QRectF bRect; bool mirrored; + bool handVisible = false; private slots: void updateBoundingRect(); 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 2e9b49d6d..36cb2a8bc 100644 --- a/cockatrice/src/game/player/player_info.h +++ b/cockatrice/src/game/player/player_info.h @@ -22,7 +22,6 @@ public: int id; bool local; bool judge; - bool handVisible; int getId() const { @@ -51,16 +50,6 @@ public: return judge; } - void setHandVisible(bool _handVisible) - { - handVisible = _handVisible; - } - - bool getHandVisible() const - { - return handVisible; - } - QString getName() const { return QString::fromStdString(userInfo->name());