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)
|
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)),
|
: QObject(_parent), game(_parent), playerInfo(new PlayerInfo(info, _id, _local, _judge)),
|
||||||
playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), active(false),
|
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();
|
initializeZones();
|
||||||
|
|
||||||
|
|
@ -41,6 +41,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, A
|
||||||
playerMenu->setMenusForGraphicItems();
|
playerMenu->setMenusForGraphicItems();
|
||||||
|
|
||||||
connect(this, &Player::activeChanged, graphicsItem, &PlayerGraphicsItem::onPlayerActiveChanged);
|
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::enableOpenInDeckEditorAction);
|
||||||
connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::populatePredefinedTokensMenu);
|
connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::populatePredefinedTokensMenu);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ signals:
|
||||||
void clearCustomZonesMenu();
|
void clearCustomZonesMenu();
|
||||||
void addViewCustomZoneActionToCustomZoneMenu(QString zoneName);
|
void addViewCustomZoneActionToCustomZoneMenu(QString zoneName);
|
||||||
void resetTopCardMenuActions();
|
void resetTopCardMenuActions();
|
||||||
|
void handVisibleChanged(bool visible);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setActive(bool _active);
|
void setActive(bool _active);
|
||||||
|
|
@ -223,6 +224,17 @@ public:
|
||||||
|
|
||||||
void setZoneId(int _zoneId);
|
void setZoneId(int _zoneId);
|
||||||
|
|
||||||
|
void setHandVisible(bool _handVisible)
|
||||||
|
{
|
||||||
|
handVisible = _handVisible;
|
||||||
|
emit handVisibleChanged(handVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getHandVisible() const
|
||||||
|
{
|
||||||
|
return handVisible;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractGame *game;
|
AbstractGame *game;
|
||||||
PlayerInfo *playerInfo;
|
PlayerInfo *playerInfo;
|
||||||
|
|
@ -233,6 +245,7 @@ private:
|
||||||
|
|
||||||
bool active;
|
bool active;
|
||||||
bool conceded;
|
bool conceded;
|
||||||
|
bool handVisible;
|
||||||
|
|
||||||
DeckLoader *deck;
|
DeckLoader *deck;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,10 @@ void PlayerGraphicsItem::initializeZones()
|
||||||
handZoneGraphicsItem =
|
handZoneGraphicsItem =
|
||||||
new HandZone(player->getHandZone(), static_cast<int>(tableZoneGraphicsItem->boundingRect().height()), this);
|
new HandZone(player->getHandZone(), static_cast<int>(tableZoneGraphicsItem->boundingRect().height()), this);
|
||||||
|
|
||||||
|
if (!player->getHandVisible()) {
|
||||||
|
player->getHandZone()->setGraphicsVisibility(false);
|
||||||
|
}
|
||||||
|
|
||||||
connect(handZoneGraphicsItem->getLogic(), &HandZoneLogic::cardCountChanged, handCounter,
|
connect(handZoneGraphicsItem->getLogic(), &HandZoneLogic::cardCountChanged, handCounter,
|
||||||
&HandCounter::updateNumber);
|
&HandCounter::updateNumber);
|
||||||
connect(handCounter, &HandCounter::showContextMenu, handZoneGraphicsItem, &HandZone::showContextMenu);
|
connect(handCounter, &HandCounter::showContextMenu, handZoneGraphicsItem, &HandZone::showContextMenu);
|
||||||
|
|
@ -151,11 +155,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);
|
player->setHandVisible(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);
|
player->setHandVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
stackZoneGraphicsItem->setPos(base);
|
stackZoneGraphicsItem->setPos(base);
|
||||||
|
|
@ -169,16 +173,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);
|
player->setHandVisible(true);
|
||||||
handZoneGraphicsItem->setPos(base);
|
handZoneGraphicsItem->setPos(base);
|
||||||
} else {
|
} else {
|
||||||
player->getPlayerInfo()->setHandVisible(false);
|
player->setHandVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handZoneGraphicsItem->setWidth(tableZoneGraphicsItem->getWidth() +
|
handZoneGraphicsItem->setWidth(tableZoneGraphicsItem->getWidth() +
|
||||||
stackZoneGraphicsItem->boundingRect().width());
|
stackZoneGraphicsItem->boundingRect().width());
|
||||||
} else {
|
} else {
|
||||||
player->getPlayerInfo()->setHandVisible(true);
|
player->setHandVisible(true);
|
||||||
|
|
||||||
handZoneGraphicsItem->setPos(base);
|
handZoneGraphicsItem->setPos(base);
|
||||||
base += QPointF(handZoneGraphicsItem->boundingRect().width(), 0);
|
base += QPointF(handZoneGraphicsItem->boundingRect().width(), 0);
|
||||||
|
|
@ -188,7 +192,6 @@ void PlayerGraphicsItem::rearrangeZones()
|
||||||
|
|
||||||
tableZoneGraphicsItem->setPos(base);
|
tableZoneGraphicsItem->setPos(base);
|
||||||
}
|
}
|
||||||
handZoneGraphicsItem->setVisible(player->getPlayerInfo()->getHandVisible());
|
|
||||||
handZoneGraphicsItem->updateOrientation();
|
handZoneGraphicsItem->updateOrientation();
|
||||||
tableZoneGraphicsItem->reorganizeCards();
|
tableZoneGraphicsItem->reorganizeCards();
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
|
@ -200,8 +203,7 @@ void PlayerGraphicsItem::updateBoundingRect()
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
qreal width = CARD_HEIGHT + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width();
|
qreal width = CARD_HEIGHT + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width();
|
||||||
if (SettingsCache::instance().getHorizontalHand()) {
|
if (SettingsCache::instance().getHorizontalHand()) {
|
||||||
qreal handHeight =
|
qreal handHeight = player->getHandVisible() ? 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 {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ public:
|
||||||
int id;
|
int id;
|
||||||
bool local;
|
bool local;
|
||||||
bool judge;
|
bool judge;
|
||||||
bool handVisible;
|
|
||||||
|
|
||||||
int getId() const
|
int getId() const
|
||||||
{
|
{
|
||||||
|
|
@ -50,16 +49,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());
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,8 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
|
||||||
libraryMenu = nullptr;
|
libraryMenu = nullptr;
|
||||||
countersMenu = nullptr;
|
countersMenu = nullptr;
|
||||||
mCustomZones = nullptr;
|
mCustomZones = nullptr;
|
||||||
|
|
||||||
|
aUntapAll = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
aTap = new QAction(this);
|
aTap = new QAction(this);
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,18 @@ CardZone::CardZone(CardZoneLogic *_logic, QGraphicsItem *parent)
|
||||||
{
|
{
|
||||||
connect(logic, &CardZoneLogic::retranslateUi, this, &CardZone::retranslateUi);
|
connect(logic, &CardZoneLogic::retranslateUi, this, &CardZone::retranslateUi);
|
||||||
connect(logic, &CardZoneLogic::cardAdded, this, &CardZone::onCardAdded);
|
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::updateGraphics, this, [this]() { update(); });
|
||||||
connect(logic, &CardZoneLogic::reorganizeCards, this, &CardZone::reorganizeCards);
|
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)
|
void CardZone::onCardAdded(CardItem *addedCard)
|
||||||
{
|
{
|
||||||
addedCard->setParentItem(this);
|
addedCard->setParentItem(this);
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ public:
|
||||||
virtual void
|
virtual void
|
||||||
handleDropEvent(const QList<CardDragItem *> &dragItem, CardZoneLogic *startZone, const QPoint &dropPoint) = 0;
|
handleDropEvent(const QList<CardDragItem *> &dragItem, CardZoneLogic *startZone, const QPoint &dropPoint) = 0;
|
||||||
CardZone(CardZoneLogic *logic, QGraphicsItem *parent = nullptr);
|
CardZone(CardZoneLogic *logic, QGraphicsItem *parent = nullptr);
|
||||||
|
void onGraphicsVisibilityChanged(bool _visible);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
||||||
CardZoneLogic *getLogic() const
|
CardZoneLogic *getLogic() const
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue