mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-02 11:33:55 -07:00
[Player] Pull handVisible out of player_info and let graphics_item just determine this on its own. (#6911)
Took 12 minutes Took 15 seconds Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
7a5b2e9f0e
commit
af2f888293
4 changed files with 9 additions and 20 deletions
|
|
@ -158,11 +158,11 @@ void PlayerGraphicsItem::rearrangeZones()
|
||||||
if (SettingsCache::instance().getHorizontalHand()) {
|
if (SettingsCache::instance().getHorizontalHand()) {
|
||||||
if (mirrored) {
|
if (mirrored) {
|
||||||
if (player->getHandZone()->contentsKnown()) {
|
if (player->getHandZone()->contentsKnown()) {
|
||||||
player->getPlayerInfo()->setHandVisible(true);
|
handVisible = true;
|
||||||
handZoneGraphicsItem->setPos(base);
|
handZoneGraphicsItem->setPos(base);
|
||||||
base += QPointF(0, handZoneGraphicsItem->boundingRect().height());
|
base += QPointF(0, handZoneGraphicsItem->boundingRect().height());
|
||||||
} else {
|
} else {
|
||||||
player->getPlayerInfo()->setHandVisible(false);
|
handVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
stackZoneGraphicsItem->setPos(base);
|
stackZoneGraphicsItem->setPos(base);
|
||||||
|
|
@ -176,16 +176,16 @@ void PlayerGraphicsItem::rearrangeZones()
|
||||||
base += QPointF(0, tableZoneGraphicsItem->boundingRect().height());
|
base += QPointF(0, tableZoneGraphicsItem->boundingRect().height());
|
||||||
|
|
||||||
if (player->getHandZone()->contentsKnown()) {
|
if (player->getHandZone()->contentsKnown()) {
|
||||||
player->getPlayerInfo()->setHandVisible(true);
|
handVisible = true;
|
||||||
handZoneGraphicsItem->setPos(base);
|
handZoneGraphicsItem->setPos(base);
|
||||||
} else {
|
} else {
|
||||||
player->getPlayerInfo()->setHandVisible(false);
|
handVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handZoneGraphicsItem->setWidth(tableZoneGraphicsItem->getWidth() +
|
handZoneGraphicsItem->setWidth(tableZoneGraphicsItem->getWidth() +
|
||||||
stackZoneGraphicsItem->boundingRect().width());
|
stackZoneGraphicsItem->boundingRect().width());
|
||||||
} else {
|
} else {
|
||||||
player->getPlayerInfo()->setHandVisible(true);
|
handVisible = true;
|
||||||
|
|
||||||
handZoneGraphicsItem->setPos(base);
|
handZoneGraphicsItem->setPos(base);
|
||||||
base += QPointF(handZoneGraphicsItem->boundingRect().width(), 0);
|
base += QPointF(handZoneGraphicsItem->boundingRect().width(), 0);
|
||||||
|
|
@ -195,7 +195,7 @@ void PlayerGraphicsItem::rearrangeZones()
|
||||||
|
|
||||||
tableZoneGraphicsItem->setPos(base);
|
tableZoneGraphicsItem->setPos(base);
|
||||||
}
|
}
|
||||||
handZoneGraphicsItem->setVisible(player->getPlayerInfo()->getHandVisible());
|
handZoneGraphicsItem->setVisible(handVisible);
|
||||||
handZoneGraphicsItem->updateOrientation();
|
handZoneGraphicsItem->updateOrientation();
|
||||||
tableZoneGraphicsItem->reorganizeCards();
|
tableZoneGraphicsItem->reorganizeCards();
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
|
@ -207,8 +207,7 @@ void PlayerGraphicsItem::updateBoundingRect()
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
qreal width = CardDimensions::HEIGHT_F + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width();
|
qreal width = CardDimensions::HEIGHT_F + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width();
|
||||||
if (SettingsCache::instance().getHorizontalHand()) {
|
if (SettingsCache::instance().getHorizontalHand()) {
|
||||||
qreal handHeight =
|
qreal handHeight = handVisible ? handZoneGraphicsItem->boundingRect().height() : 0;
|
||||||
player->getPlayerInfo()->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0;
|
|
||||||
bRect = QRectF(0, 0, width + tableZoneGraphicsItem->boundingRect().width(),
|
bRect = QRectF(0, 0, width + tableZoneGraphicsItem->boundingRect().width(),
|
||||||
tableZoneGraphicsItem->boundingRect().height() + handHeight);
|
tableZoneGraphicsItem->boundingRect().height() + handHeight);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ private:
|
||||||
HandZone *handZoneGraphicsItem;
|
HandZone *handZoneGraphicsItem;
|
||||||
QRectF bRect;
|
QRectF bRect;
|
||||||
bool mirrored;
|
bool mirrored;
|
||||||
|
bool handVisible = false;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "player_info.h"
|
#include "player_info.h"
|
||||||
|
|
||||||
PlayerInfo::PlayerInfo(const ServerInfo_User &info, int _id, bool _local, bool _judge)
|
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 = new ServerInfo_User;
|
||||||
userInfo->CopyFrom(info);
|
userInfo->CopyFrom(info);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ public:
|
||||||
int id;
|
int id;
|
||||||
bool local;
|
bool local;
|
||||||
bool judge;
|
bool judge;
|
||||||
bool handVisible;
|
|
||||||
|
|
||||||
int getId() const
|
int getId() const
|
||||||
{
|
{
|
||||||
|
|
@ -51,16 +50,6 @@ public:
|
||||||
return judge;
|
return judge;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHandVisible(bool _handVisible)
|
|
||||||
{
|
|
||||||
handVisible = _handVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getHandVisible() const
|
|
||||||
{
|
|
||||||
return handVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString getName() const
|
QString getName() const
|
||||||
{
|
{
|
||||||
return QString::fromStdString(userInfo->name());
|
return QString::fromStdString(userInfo->name());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue