Take hand visibility into account when calculating bounding boxes.

Took 34 minutes

Took 7 minutes

Took 8 seconds
This commit is contained in:
Lukas Brübach 2025-09-11 21:59:04 +02:00
parent 1cce0df0fa
commit 631903d605
4 changed files with 35 additions and 8 deletions

View file

@ -30,10 +30,12 @@
#include <QtConcurrent>
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), handVisible(false), deck(nullptr), zoneId(0), dialogSemaphore(false)
: QObject(_parent), game(_parent), playerEventHandler(new PlayerEventHandler(this)),
playerActions(new PlayerActions(this)), active(false), conceded(false), handVisible(_local), deck(nullptr),
zoneId(0), dialogSemaphore(false)
{
playerInfo = new PlayerInfo(info, _id, _local, _judge);
initializeZones();
playerMenu = new PlayerMenu(this);

View file

@ -54,10 +54,19 @@ void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
QRectF HandZone::boundingRect() const
{
if (SettingsCache::instance().getHorizontalHand())
return QRectF(0, 0, width, CARD_HEIGHT + 10);
else
return QRectF(0, 0, 100, zoneHeight);
if (SettingsCache::instance().getHorizontalHand()) {
if (getLogic()->getPlayer()->getHandVisible()) {
return QRectF(0, 0, width, CARD_HEIGHT + 10);
} else {
return QRectF(0, 0, width, 0);
}
} else {
if (getLogic()->getPlayer()->getHandVisible()) {
return QRectF(0, 0, 100, zoneHeight);
} else {
return QRectF(0, 0, 0, zoneHeight);
}
}
}
void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)

View file

@ -30,7 +30,13 @@ TableZone::TableZone(TableZoneLogic *_logic, QGraphicsItem *parent) : SelectZone
updateBg();
height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT + (TABLEROWS - 1) * PADDING_Y;
connect(getLogic()->getPlayer(), &Player::handVisibleChanged, this, &TableZone::updateHeight);
if (getLogic()->getPlayer()->getHandVisible()) {
height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT + (TABLEROWS - 1) * PADDING_Y;
} else {
height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT * PADDING_Y;
}
width = MIN_WIDTH;
currentMinimumWidth = width;
@ -43,6 +49,15 @@ void TableZone::updateBg()
update();
}
void TableZone::updateHeight()
{
if (getLogic()->getPlayer()->getHandVisible()) {
height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT + (TABLEROWS - 1) * PADDING_Y;
} else {
height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT * PADDING_Y;
}
}
QRectF TableZone::boundingRect() const
{
return QRectF(0, 0, width, height);

View file

@ -85,6 +85,7 @@ private slots:
Loads in any found custom background and updates
*/
void updateBg();
void updateHeight();
public slots:
/**