mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 00:12:15 -07:00
Emit handVisibleChanged() and move the attribute from player_info to player since it is dynamic.
Took 50 minutes Took 7 seconds Took 2 minutes
This commit is contained in:
parent
93c15c8151
commit
0bd1f78391
8 changed files with 37 additions and 22 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@ void PlayerGraphicsItem::initializeZones()
|
|||
handZoneGraphicsItem =
|
||||
new HandZone(player->getHandZone(), static_cast<int>(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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -267,6 +267,8 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
|
|||
libraryMenu = nullptr;
|
||||
countersMenu = nullptr;
|
||||
mCustomZones = nullptr;
|
||||
|
||||
aUntapAll = nullptr;
|
||||
}
|
||||
|
||||
aTap = new QAction(this);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public:
|
|||
virtual void
|
||||
handleDropEvent(const QList<CardDragItem *> &dragItem, CardZoneLogic *startZone, const QPoint &dropPoint) = 0;
|
||||
CardZone(CardZoneLogic *logic, QGraphicsItem *parent = nullptr);
|
||||
void onGraphicsVisibilityChanged(bool _visible);
|
||||
void retranslateUi();
|
||||
|
||||
CardZoneLogic *getLogic() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue