changed lock icon, added sideboard locking, issue #15 fixed
This commit is contained in:
parent
0b51af888c
commit
b2b7242802
17 changed files with 336 additions and 122 deletions
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 316 KiB After Width: | Height: | Size: 34 KiB |
|
@ -166,7 +166,6 @@ void DeckViewCardContainer::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||||
painter->setPen(QColor(255, 255, 255, 100));
|
painter->setPen(QColor(255, 255, 255, 100));
|
||||||
painter->drawLine(QPointF(0, yUntilNow - paddingY / 2), QPointF(width, yUntilNow - paddingY / 2));
|
painter->drawLine(QPointF(0, yUntilNow - paddingY / 2), QPointF(width, yUntilNow - paddingY / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal thisRowHeight = CARD_HEIGHT * currentRowsAndCols[i].first;
|
qreal thisRowHeight = CARD_HEIGHT * currentRowsAndCols[i].first;
|
||||||
QRectF textRect(0, yUntilNow, totalTextWidth, thisRowHeight);
|
QRectF textRect(0, yUntilNow, totalTextWidth, thisRowHeight);
|
||||||
yUntilNow += thisRowHeight + paddingY;
|
yUntilNow += thisRowHeight + paddingY;
|
||||||
|
@ -268,22 +267,27 @@ void DeckViewCardContainer::setWidth(qreal _width)
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckViewScene::DeckViewScene(QObject *parent)
|
DeckViewScene::DeckViewScene(QObject *parent)
|
||||||
: QGraphicsScene(parent), locked(false), deck(0), optimalAspectRatio(1.0)
|
: QGraphicsScene(parent), locked(true), deck(0), optimalAspectRatio(1.0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckViewScene::~DeckViewScene()
|
DeckViewScene::~DeckViewScene()
|
||||||
{
|
{
|
||||||
|
clearContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckViewScene::clearContents()
|
||||||
|
{
|
||||||
|
QMapIterator<QString, DeckViewCardContainer *> i(cardContainers);
|
||||||
|
while (i.hasNext())
|
||||||
|
delete i.next().value();
|
||||||
|
cardContainers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckViewScene::setDeck(DeckList *_deck)
|
void DeckViewScene::setDeck(DeckList *_deck)
|
||||||
{
|
{
|
||||||
if (deck)
|
if (deck)
|
||||||
delete deck;
|
delete deck;
|
||||||
QMapIterator<QString, DeckViewCardContainer *> i(cardContainers);
|
|
||||||
while (i.hasNext())
|
|
||||||
delete i.next().value();
|
|
||||||
cardContainers.clear();
|
|
||||||
|
|
||||||
deck = _deck;
|
deck = _deck;
|
||||||
rebuildTree();
|
rebuildTree();
|
||||||
|
@ -293,6 +297,11 @@ void DeckViewScene::setDeck(DeckList *_deck)
|
||||||
|
|
||||||
void DeckViewScene::rebuildTree()
|
void DeckViewScene::rebuildTree()
|
||||||
{
|
{
|
||||||
|
clearContents();
|
||||||
|
|
||||||
|
if (!deck)
|
||||||
|
return;
|
||||||
|
|
||||||
InnerDecklistNode *listRoot = deck->getRoot();
|
InnerDecklistNode *listRoot = deck->getRoot();
|
||||||
for (int i = 0; i < listRoot->size(); i++) {
|
for (int i = 0; i < listRoot->size(); i++) {
|
||||||
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
|
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
|
||||||
|
@ -432,6 +441,12 @@ QList<MoveCard_ToZone> DeckViewScene::getSideboardPlan() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckViewScene::resetSideboardPlan()
|
||||||
|
{
|
||||||
|
rebuildTree();
|
||||||
|
rearrangeItems();
|
||||||
|
}
|
||||||
|
|
||||||
DeckView::DeckView(QWidget *parent)
|
DeckView::DeckView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
|
@ -463,3 +478,8 @@ void DeckView::setDeck(DeckList *_deck)
|
||||||
{
|
{
|
||||||
deckViewScene->setDeck(_deck);
|
deckViewScene->setDeck(_deck);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckView::resetSideboardPlan()
|
||||||
|
{
|
||||||
|
deckViewScene->resetSideboardPlan();
|
||||||
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ private:
|
||||||
DeckList *deck;
|
DeckList *deck;
|
||||||
QMap<QString, DeckViewCardContainer *> cardContainers;
|
QMap<QString, DeckViewCardContainer *> cardContainers;
|
||||||
qreal optimalAspectRatio;
|
qreal optimalAspectRatio;
|
||||||
|
void clearContents();
|
||||||
void rebuildTree();
|
void rebuildTree();
|
||||||
void applySideboardPlan(const QList<MoveCard_ToZone> &plan);
|
void applySideboardPlan(const QList<MoveCard_ToZone> &plan);
|
||||||
public:
|
public:
|
||||||
|
@ -93,6 +94,7 @@ public:
|
||||||
void rearrangeItems();
|
void rearrangeItems();
|
||||||
void updateContents();
|
void updateContents();
|
||||||
QList<MoveCard_ToZone> getSideboardPlan() const;
|
QList<MoveCard_ToZone> getSideboardPlan() const;
|
||||||
|
void resetSideboardPlan();
|
||||||
};
|
};
|
||||||
|
|
||||||
class DeckView : public QGraphicsView {
|
class DeckView : public QGraphicsView {
|
||||||
|
@ -111,6 +113,7 @@ public:
|
||||||
void setDeck(DeckList *_deck);
|
void setDeck(DeckList *_deck);
|
||||||
void setLocked(bool _locked) { deckViewScene->setLocked(_locked); }
|
void setLocked(bool _locked) { deckViewScene->setLocked(_locked); }
|
||||||
QList<MoveCard_ToZone> getSideboardPlan() const { return deckViewScene->getSideboardPlan(); }
|
QList<MoveCard_ToZone> getSideboardPlan() const { return deckViewScene->getSideboardPlan(); }
|
||||||
|
void resetSideboardPlan();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -98,6 +98,21 @@ void MessageLogWidget::logNotReadyStart(Player *player)
|
||||||
appendHtml(tr("%1 is not ready to start the game any more.", "male").arg(sanitizeHtml(player->getName())));
|
appendHtml(tr("%1 is not ready to start the game any more.", "male").arg(sanitizeHtml(player->getName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageLogWidget::logSetSideboardLock(Player *player, bool locked)
|
||||||
|
{
|
||||||
|
if (locked) {
|
||||||
|
if (isFemale(player))
|
||||||
|
appendHtml(tr("%1 has locked her sideboard.", "female").arg(sanitizeHtml(player->getName())));
|
||||||
|
else
|
||||||
|
appendHtml(tr("%1 has locked his sideboard.", "male").arg(sanitizeHtml(player->getName())));
|
||||||
|
} else {
|
||||||
|
if (isFemale(player))
|
||||||
|
appendHtml(tr("%1 has unlocked her sideboard.", "female").arg(sanitizeHtml(player->getName())));
|
||||||
|
else
|
||||||
|
appendHtml(tr("%1 has unlocked his sideboard.", "male").arg(sanitizeHtml(player->getName())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logConcede(Player *player)
|
void MessageLogWidget::logConcede(Player *player)
|
||||||
{
|
{
|
||||||
if (isFemale(player))
|
if (isFemale(player))
|
||||||
|
|
|
@ -50,6 +50,7 @@ public slots:
|
||||||
void logDeckSelect(Player *player, QString deckHash);
|
void logDeckSelect(Player *player, QString deckHash);
|
||||||
void logReadyStart(Player *player);
|
void logReadyStart(Player *player);
|
||||||
void logNotReadyStart(Player *player);
|
void logNotReadyStart(Player *player);
|
||||||
|
void logSetSideboardLock(Player *player, bool locked);
|
||||||
void logConcede(Player *player);
|
void logConcede(Player *player);
|
||||||
void logGameStart();
|
void logGameStart();
|
||||||
void logConnectionStateChanged(Player *player, bool connectionState);
|
void logConnectionStateChanged(Player *player, bool connectionState);
|
||||||
|
|
|
@ -55,6 +55,7 @@ PlayerListWidget::PlayerListWidget(TabSupervisor *_tabSupervisor, AbstractClient
|
||||||
concededIcon = QIcon(":/resources/icon_conceded.svg");
|
concededIcon = QIcon(":/resources/icon_conceded.svg");
|
||||||
playerIcon = QIcon(":/resources/icon_player.svg");
|
playerIcon = QIcon(":/resources/icon_player.svg");
|
||||||
spectatorIcon = QIcon(":/resources/icon_spectator.svg");
|
spectatorIcon = QIcon(":/resources/icon_spectator.svg");
|
||||||
|
lockIcon = QIcon(":/resources/lock.svg");
|
||||||
|
|
||||||
if (tabSupervisor) {
|
if (tabSupervisor) {
|
||||||
itemDelegate = new PlayerListItemDelegate(this);
|
itemDelegate = new PlayerListItemDelegate(this);
|
||||||
|
@ -115,6 +116,8 @@ void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties
|
||||||
player->setData(4, Qt::UserRole + 1, prop.player_id());
|
player->setData(4, Qt::UserRole + 1, prop.player_id());
|
||||||
if (prop.has_deck_hash())
|
if (prop.has_deck_hash())
|
||||||
player->setText(5, QString::fromStdString(prop.deck_hash()));
|
player->setText(5, QString::fromStdString(prop.deck_hash()));
|
||||||
|
if (prop.has_sideboard_locked())
|
||||||
|
player->setIcon(5, prop.sideboard_locked() ? lockIcon : QIcon());
|
||||||
if (prop.has_ping_seconds())
|
if (prop.has_ping_seconds())
|
||||||
player->setIcon(0, QIcon(PingPixmapGenerator::generatePixmap(12, prop.ping_seconds(), 10)));
|
player->setIcon(0, QIcon(PingPixmapGenerator::generatePixmap(12, prop.ping_seconds(), 10)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ private:
|
||||||
TabSupervisor *tabSupervisor;
|
TabSupervisor *tabSupervisor;
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
TabGame *game;
|
TabGame *game;
|
||||||
QIcon readyIcon, notReadyIcon, concededIcon, playerIcon, spectatorIcon;
|
QIcon readyIcon, notReadyIcon, concededIcon, playerIcon, spectatorIcon, lockIcon;
|
||||||
bool gameStarted;
|
bool gameStarted;
|
||||||
signals:
|
signals:
|
||||||
void openMessageDialog(const QString &userName, bool focus);
|
void openMessageDialog(const QString &userName, bool focus);
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "pb/command_deck_select.pb.h"
|
#include "pb/command_deck_select.pb.h"
|
||||||
#include "pb/command_ready_start.pb.h"
|
#include "pb/command_ready_start.pb.h"
|
||||||
#include "pb/command_set_sideboard_plan.pb.h"
|
#include "pb/command_set_sideboard_plan.pb.h"
|
||||||
|
#include "pb/command_set_sideboard_lock.pb.h"
|
||||||
#include "pb/command_leave_game.pb.h"
|
#include "pb/command_leave_game.pb.h"
|
||||||
#include "pb/command_game_say.pb.h"
|
#include "pb/command_game_say.pb.h"
|
||||||
#include "pb/command_set_active_phase.pb.h"
|
#include "pb/command_set_active_phase.pb.h"
|
||||||
|
@ -61,26 +62,26 @@
|
||||||
#include "pb/context_ping_changed.pb.h"
|
#include "pb/context_ping_changed.pb.h"
|
||||||
#include "get_pb_extension.h"
|
#include "get_pb_extension.h"
|
||||||
|
|
||||||
ReadyStartButton::ReadyStartButton(QWidget *parent)
|
ToggleButton::ToggleButton(QWidget *parent)
|
||||||
: QPushButton(parent), readyStart(false)
|
: QPushButton(parent), state(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadyStartButton::paintEvent(QPaintEvent *event)
|
void ToggleButton::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPushButton::paintEvent(event);
|
QPushButton::paintEvent(event);
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
if (readyStart)
|
if (state)
|
||||||
painter.setPen(QPen(Qt::green, 3));
|
painter.setPen(QPen(Qt::green, 3));
|
||||||
else
|
else
|
||||||
painter.setPen(QPen(Qt::red, 3));
|
painter.setPen(QPen(Qt::red, 3));
|
||||||
painter.drawRect(1.5, 1.5, width() - 3, height() - 3);
|
painter.drawRect(1.5, 1.5, width() - 3, height() - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadyStartButton::setReadyStart(bool _readyStart)
|
void ToggleButton::setState(bool _state)
|
||||||
{
|
{
|
||||||
readyStart = _readyStart;
|
state = _state;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,17 +90,21 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
|
||||||
{
|
{
|
||||||
loadLocalButton = new QPushButton;
|
loadLocalButton = new QPushButton;
|
||||||
loadRemoteButton = new QPushButton;
|
loadRemoteButton = new QPushButton;
|
||||||
readyStartButton = new ReadyStartButton;
|
readyStartButton = new ToggleButton;
|
||||||
readyStartButton->setEnabled(false);
|
readyStartButton->setEnabled(false);
|
||||||
|
sideboardLockButton = new ToggleButton;
|
||||||
|
sideboardLockButton->setEnabled(false);
|
||||||
|
|
||||||
connect(loadLocalButton, SIGNAL(clicked()), this, SLOT(loadLocalDeck()));
|
connect(loadLocalButton, SIGNAL(clicked()), this, SLOT(loadLocalDeck()));
|
||||||
connect(loadRemoteButton, SIGNAL(clicked()), this, SLOT(loadRemoteDeck()));
|
connect(loadRemoteButton, SIGNAL(clicked()), this, SLOT(loadRemoteDeck()));
|
||||||
connect(readyStartButton, SIGNAL(clicked()), this, SLOT(readyStart()));
|
connect(readyStartButton, SIGNAL(clicked()), this, SLOT(readyStart()));
|
||||||
|
connect(sideboardLockButton, SIGNAL(clicked()), this, SLOT(sideboardLockButtonClicked()));
|
||||||
|
|
||||||
QHBoxLayout *buttonHBox = new QHBoxLayout;
|
QHBoxLayout *buttonHBox = new QHBoxLayout;
|
||||||
buttonHBox->addWidget(loadLocalButton);
|
buttonHBox->addWidget(loadLocalButton);
|
||||||
buttonHBox->addWidget(loadRemoteButton);
|
buttonHBox->addWidget(loadRemoteButton);
|
||||||
buttonHBox->addWidget(readyStartButton);
|
buttonHBox->addWidget(readyStartButton);
|
||||||
|
buttonHBox->addWidget(sideboardLockButton);
|
||||||
buttonHBox->addStretch();
|
buttonHBox->addStretch();
|
||||||
deckView = new DeckView;
|
deckView = new DeckView;
|
||||||
connect(deckView, SIGNAL(newCardAdded(AbstractCardItem *)), this, SIGNAL(newCardAdded(AbstractCardItem *)));
|
connect(deckView, SIGNAL(newCardAdded(AbstractCardItem *)), this, SIGNAL(newCardAdded(AbstractCardItem *)));
|
||||||
|
@ -118,6 +123,7 @@ void DeckViewContainer::retranslateUi()
|
||||||
loadLocalButton->setText(tr("Load &local deck"));
|
loadLocalButton->setText(tr("Load &local deck"));
|
||||||
loadRemoteButton->setText(tr("Load d&eck from server"));
|
loadRemoteButton->setText(tr("Load d&eck from server"));
|
||||||
readyStartButton->setText(tr("Ready to s&tart"));
|
readyStartButton->setText(tr("Ready to s&tart"));
|
||||||
|
updateSideboardLockButtonText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckViewContainer::setButtonsVisible(bool _visible)
|
void DeckViewContainer::setButtonsVisible(bool _visible)
|
||||||
|
@ -125,6 +131,15 @@ void DeckViewContainer::setButtonsVisible(bool _visible)
|
||||||
loadLocalButton->setVisible(_visible);
|
loadLocalButton->setVisible(_visible);
|
||||||
loadRemoteButton->setVisible(_visible);
|
loadRemoteButton->setVisible(_visible);
|
||||||
readyStartButton->setVisible(_visible);
|
readyStartButton->setVisible(_visible);
|
||||||
|
sideboardLockButton->setVisible(_visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckViewContainer::updateSideboardLockButtonText()
|
||||||
|
{
|
||||||
|
if (sideboardLockButton->getState())
|
||||||
|
sideboardLockButton->setText(tr("S&ideboard unlocked"));
|
||||||
|
else
|
||||||
|
sideboardLockButton->setText(tr("S&ideboard locked"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckViewContainer::loadLocalDeck()
|
void DeckViewContainer::loadLocalDeck()
|
||||||
|
@ -168,14 +183,21 @@ void DeckViewContainer::deckSelectFinished(const Response &r)
|
||||||
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
|
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
|
||||||
DeckList *newDeck = new DeckList(QString::fromStdString(resp.deck()));
|
DeckList *newDeck = new DeckList(QString::fromStdString(resp.deck()));
|
||||||
db->cacheCardPixmaps(newDeck->getCardList());
|
db->cacheCardPixmaps(newDeck->getCardList());
|
||||||
deckView->setDeck(newDeck);
|
setDeck(newDeck);
|
||||||
readyStartButton->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckViewContainer::readyStart()
|
void DeckViewContainer::readyStart()
|
||||||
{
|
{
|
||||||
Command_ReadyStart cmd;
|
Command_ReadyStart cmd;
|
||||||
cmd.set_ready(!readyStartButton->getReadyStart());
|
cmd.set_ready(!readyStartButton->getState());
|
||||||
|
static_cast<TabGame *>(parent())->sendGameCommand(cmd, playerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckViewContainer::sideboardLockButtonClicked()
|
||||||
|
{
|
||||||
|
Command_SetSideboardLock cmd;
|
||||||
|
cmd.set_locked(sideboardLockButton->getState());
|
||||||
|
|
||||||
static_cast<TabGame *>(parent())->sendGameCommand(cmd, playerId);
|
static_cast<TabGame *>(parent())->sendGameCommand(cmd, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,14 +212,25 @@ void DeckViewContainer::sideboardPlanChanged()
|
||||||
|
|
||||||
void DeckViewContainer::setReadyStart(bool ready)
|
void DeckViewContainer::setReadyStart(bool ready)
|
||||||
{
|
{
|
||||||
readyStartButton->setReadyStart(ready);
|
readyStartButton->setState(ready);
|
||||||
deckView->setLocked(ready);
|
deckView->setLocked(ready || !sideboardLockButton->getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckViewContainer::setSideboardLocked(bool locked)
|
||||||
|
{
|
||||||
|
sideboardLockButton->setState(!locked);
|
||||||
|
updateSideboardLockButtonText();
|
||||||
|
deckView->setLocked(readyStartButton->getState() || !sideboardLockButton->getState());
|
||||||
|
if (locked)
|
||||||
|
deckView->resetSideboardPlan();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckViewContainer::setDeck(DeckList *deck)
|
void DeckViewContainer::setDeck(DeckList *deck)
|
||||||
{
|
{
|
||||||
deckView->setDeck(deck);
|
deckView->setDeck(deck);
|
||||||
readyStartButton->setEnabled(true);
|
readyStartButton->setEnabled(true);
|
||||||
|
sideboardLockButton->setState(false);
|
||||||
|
sideboardLockButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabGame::TabGame(GameReplay *_replay)
|
TabGame::TabGame(GameReplay *_replay)
|
||||||
|
@ -899,10 +932,15 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event, int /*e
|
||||||
playerListWidget->addPlayer(prop);
|
playerListWidget->addPlayer(prop);
|
||||||
}
|
}
|
||||||
player->processPlayerInfo(playerInfo);
|
player->processPlayerInfo(playerInfo);
|
||||||
if (player->getLocal() && playerInfo.has_deck_list()) {
|
if (player->getLocal()) {
|
||||||
DeckList *newDeck = new DeckList(QString::fromStdString(playerInfo.deck_list()));
|
DeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
|
||||||
db->cacheCardPixmaps(newDeck->getCardList());
|
if (playerInfo.has_deck_list()) {
|
||||||
deckViewContainers.value(playerId)->setDeck(newDeck);
|
DeckList *newDeck = new DeckList(QString::fromStdString(playerInfo.deck_list()));
|
||||||
|
db->cacheCardPixmaps(newDeck->getCardList());
|
||||||
|
deckViewContainer->setDeck(newDeck);
|
||||||
|
}
|
||||||
|
deckViewContainer->setReadyStart(prop.ready_start());
|
||||||
|
deckViewContainer->setSideboardLocked(prop.sideboard_locked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -938,12 +976,13 @@ void TabGame::eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &
|
||||||
Player *player = players.value(eventPlayerId, 0);
|
Player *player = players.value(eventPlayerId, 0);
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
playerListWidget->updatePlayerProperties(event.player_properties(), eventPlayerId);
|
const ServerInfo_PlayerProperties &prop = event.player_properties();
|
||||||
|
playerListWidget->updatePlayerProperties(prop, eventPlayerId);
|
||||||
|
|
||||||
const GameEventContext::ContextType contextType = static_cast<const GameEventContext::ContextType>(getPbExtension(context));
|
const GameEventContext::ContextType contextType = static_cast<const GameEventContext::ContextType>(getPbExtension(context));
|
||||||
switch (contextType) {
|
switch (contextType) {
|
||||||
case GameEventContext::READY_START: {
|
case GameEventContext::READY_START: {
|
||||||
bool ready = event.player_properties().ready_start();
|
bool ready = prop.ready_start();
|
||||||
if (player->getLocal())
|
if (player->getLocal())
|
||||||
deckViewContainers.value(player->getId())->setReadyStart(ready);
|
deckViewContainers.value(player->getId())->setReadyStart(ready);
|
||||||
if (ready)
|
if (ready)
|
||||||
|
@ -966,8 +1005,14 @@ void TabGame::eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &
|
||||||
messageLog->logDeckSelect(player, QString::fromStdString(context.GetExtension(Context_DeckSelect::ext).deck_hash()));
|
messageLog->logDeckSelect(player, QString::fromStdString(context.GetExtension(Context_DeckSelect::ext).deck_hash()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GameEventContext::SET_SIDEBOARD_LOCK: {
|
||||||
|
if (player->getLocal())
|
||||||
|
deckViewContainers.value(player->getId())->setSideboardLocked(prop.sideboard_locked());
|
||||||
|
messageLog->logSetSideboardLock(player, prop.sideboard_locked());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GameEventContext::CONNECTION_STATE_CHANGED: {
|
case GameEventContext::CONNECTION_STATE_CHANGED: {
|
||||||
messageLog->logConnectionStateChanged(player, event.player_properties().ping_seconds() != -1);
|
messageLog->logConnectionStateChanged(player, prop.ping_seconds() != -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: ;
|
default: ;
|
||||||
|
|
|
@ -55,14 +55,14 @@ class GameReplay;
|
||||||
class ServerInfo_User;
|
class ServerInfo_User;
|
||||||
class PendingCommand;
|
class PendingCommand;
|
||||||
|
|
||||||
class ReadyStartButton : public QPushButton {
|
class ToggleButton : public QPushButton {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
bool readyStart;
|
bool state;
|
||||||
public:
|
public:
|
||||||
ReadyStartButton(QWidget *parent = 0);
|
ToggleButton(QWidget *parent = 0);
|
||||||
bool getReadyStart() const { return readyStart; }
|
bool getState() const { return state; }
|
||||||
void setReadyStart(bool _readyStart);
|
void setState(bool _state);
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
};
|
};
|
||||||
|
@ -71,7 +71,7 @@ class DeckViewContainer : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QPushButton *loadLocalButton, *loadRemoteButton;
|
QPushButton *loadLocalButton, *loadRemoteButton;
|
||||||
ReadyStartButton *readyStartButton;
|
ToggleButton *readyStartButton, *sideboardLockButton;
|
||||||
DeckView *deckView;
|
DeckView *deckView;
|
||||||
int playerId;
|
int playerId;
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -80,6 +80,9 @@ private slots:
|
||||||
void readyStart();
|
void readyStart();
|
||||||
void deckSelectFinished(const Response &r);
|
void deckSelectFinished(const Response &r);
|
||||||
void sideboardPlanChanged();
|
void sideboardPlanChanged();
|
||||||
|
void sideboardLockButtonClicked();
|
||||||
|
private:
|
||||||
|
void updateSideboardLockButtonText();
|
||||||
signals:
|
signals:
|
||||||
void newCardAdded(AbstractCardItem *card);
|
void newCardAdded(AbstractCardItem *card);
|
||||||
public:
|
public:
|
||||||
|
@ -87,6 +90,7 @@ public:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void setButtonsVisible(bool _visible);
|
void setButtonsVisible(bool _visible);
|
||||||
void setReadyStart(bool ready);
|
void setReadyStart(bool ready);
|
||||||
|
void setSideboardLocked(bool locked);
|
||||||
void setDeck(DeckList *deck);
|
void setDeck(DeckList *deck);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ SET(PROTO_FILES
|
||||||
command_set_card_counter.proto
|
command_set_card_counter.proto
|
||||||
command_set_counter.proto
|
command_set_counter.proto
|
||||||
command_set_sideboard_plan.proto
|
command_set_sideboard_plan.proto
|
||||||
|
command_set_sideboard_lock.proto
|
||||||
command_shuffle.proto
|
command_shuffle.proto
|
||||||
commands.proto
|
commands.proto
|
||||||
command_stop_dump_zone.proto
|
command_stop_dump_zone.proto
|
||||||
|
@ -51,6 +52,7 @@ SET(PROTO_FILES
|
||||||
context_mulligan.proto
|
context_mulligan.proto
|
||||||
context_ping_changed.proto
|
context_ping_changed.proto
|
||||||
context_ready_start.proto
|
context_ready_start.proto
|
||||||
|
context_set_sideboard_lock.proto
|
||||||
context_undo_draw.proto
|
context_undo_draw.proto
|
||||||
event_add_to_list.proto
|
event_add_to_list.proto
|
||||||
event_attach_card.proto
|
event_attach_card.proto
|
||||||
|
|
7
common/pb/command_set_sideboard_lock.proto
Normal file
7
common/pb/command_set_sideboard_lock.proto
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import "game_commands.proto";
|
||||||
|
message Command_SetSideboardLock {
|
||||||
|
extend GameCommand {
|
||||||
|
optional Command_SetSideboardLock ext = 1030;
|
||||||
|
}
|
||||||
|
optional bool locked = 1;
|
||||||
|
}
|
7
common/pb/context_set_sideboard_lock.proto
Normal file
7
common/pb/context_set_sideboard_lock.proto
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import "game_event_context.proto";
|
||||||
|
|
||||||
|
message Context_SetSideboardLock {
|
||||||
|
extend GameEventContext {
|
||||||
|
optional Context_SetSideboardLock ext = 1008;
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,7 @@ message GameCommand {
|
||||||
MOVE_CARD = 1027;
|
MOVE_CARD = 1027;
|
||||||
SET_SIDEBOARD_PLAN = 1028;
|
SET_SIDEBOARD_PLAN = 1028;
|
||||||
DECK_SELECT = 1029;
|
DECK_SELECT = 1029;
|
||||||
|
SET_SIDEBOARD_LOCK = 1030;
|
||||||
}
|
}
|
||||||
extensions 100 to max;
|
extensions 100 to max;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ message GameEventContext {
|
||||||
MULLIGAN = 1005;
|
MULLIGAN = 1005;
|
||||||
PING_CHANGED = 1006;
|
PING_CHANGED = 1006;
|
||||||
CONNECTION_STATE_CHANGED = 1007;
|
CONNECTION_STATE_CHANGED = 1007;
|
||||||
|
SET_SIDEBOARD_LOCK = 1008;
|
||||||
}
|
}
|
||||||
extensions 100 to max;
|
extensions 100 to max;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,4 +8,5 @@ message ServerInfo_PlayerProperties {
|
||||||
optional bool ready_start = 5;
|
optional bool ready_start = 5;
|
||||||
optional string deck_hash = 6;
|
optional string deck_hash = 6;
|
||||||
optional sint32 ping_seconds = 7;
|
optional sint32 ping_seconds = 7;
|
||||||
|
optional bool sideboard_locked = 8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "pb/command_create_counter.pb.h"
|
#include "pb/command_create_counter.pb.h"
|
||||||
#include "pb/command_create_token.pb.h"
|
#include "pb/command_create_token.pb.h"
|
||||||
#include "pb/command_deck_select.pb.h"
|
#include "pb/command_deck_select.pb.h"
|
||||||
|
#include "pb/command_set_sideboard_lock.pb.h"
|
||||||
#include "pb/command_del_counter.pb.h"
|
#include "pb/command_del_counter.pb.h"
|
||||||
#include "pb/command_delete_arrow.pb.h"
|
#include "pb/command_delete_arrow.pb.h"
|
||||||
#include "pb/command_draw_cards.pb.h"
|
#include "pb/command_draw_cards.pb.h"
|
||||||
|
@ -70,6 +71,7 @@
|
||||||
#include "pb/context_connection_state_changed.pb.h"
|
#include "pb/context_connection_state_changed.pb.h"
|
||||||
#include "pb/context_concede.pb.h"
|
#include "pb/context_concede.pb.h"
|
||||||
#include "pb/context_deck_select.pb.h"
|
#include "pb/context_deck_select.pb.h"
|
||||||
|
#include "pb/context_set_sideboard_lock.pb.h"
|
||||||
#include "pb/context_move_card.pb.h"
|
#include "pb/context_move_card.pb.h"
|
||||||
#include "pb/context_mulligan.pb.h"
|
#include "pb/context_mulligan.pb.h"
|
||||||
#include "pb/context_undo_draw.pb.h"
|
#include "pb/context_undo_draw.pb.h"
|
||||||
|
@ -78,7 +80,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Server_Player::Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_AbstractUserInterface *_userInterface)
|
Server_Player::Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_AbstractUserInterface *_userInterface)
|
||||||
: game(_game), userInterface(_userInterface), userInfo(new ServerInfo_User(_userInfo)), deck(0), pingTime(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false)
|
: game(_game), userInterface(_userInterface), userInfo(new ServerInfo_User(_userInfo)), deck(0), pingTime(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false), sideboardLocked(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +259,7 @@ ServerInfo_PlayerProperties Server_Player::getProperties(bool withUserInfo)
|
||||||
result.mutable_user_info()->CopyFrom(*userInfo);
|
result.mutable_user_info()->CopyFrom(*userInfo);
|
||||||
result.set_spectator(spectator);
|
result.set_spectator(spectator);
|
||||||
result.set_conceded(conceded);
|
result.set_conceded(conceded);
|
||||||
|
result.set_sideboard_locked(sideboardLocked);
|
||||||
result.set_ready_start(readyStart);
|
result.set_ready_start(readyStart);
|
||||||
if (deck)
|
if (deck)
|
||||||
result.set_deck_hash(deck->getDeckHash().toStdString());
|
result.set_deck_hash(deck->getDeckHash().toStdString());
|
||||||
|
@ -645,8 +648,10 @@ Response::ResponseCode Server_Player::cmdDeckSelect(const Command_DeckSelect &cm
|
||||||
|
|
||||||
delete deck;
|
delete deck;
|
||||||
deck = newDeck;
|
deck = newDeck;
|
||||||
|
sideboardLocked = true;
|
||||||
|
|
||||||
Event_PlayerPropertiesChanged event;
|
Event_PlayerPropertiesChanged event;
|
||||||
|
event.mutable_player_properties()->set_sideboard_locked(true);
|
||||||
event.mutable_player_properties()->set_deck_hash(deck->getDeckHash().toStdString());
|
event.mutable_player_properties()->set_deck_hash(deck->getDeckHash().toStdString());
|
||||||
ges.enqueueGameEvent(event, playerId);
|
ges.enqueueGameEvent(event, playerId);
|
||||||
|
|
||||||
|
@ -669,6 +674,8 @@ Response::ResponseCode Server_Player::cmdSetSideboardPlan(const Command_SetSideb
|
||||||
return Response::RespContextError;
|
return Response::RespContextError;
|
||||||
if (!deck)
|
if (!deck)
|
||||||
return Response::RespContextError;
|
return Response::RespContextError;
|
||||||
|
if (sideboardLocked)
|
||||||
|
return Response::RespContextError;
|
||||||
|
|
||||||
QList<MoveCard_ToZone> sideboardPlan;
|
QList<MoveCard_ToZone> sideboardPlan;
|
||||||
for (int i = 0; i < cmd.move_list_size(); ++i)
|
for (int i = 0; i < cmd.move_list_size(); ++i)
|
||||||
|
@ -678,6 +685,29 @@ Response::ResponseCode Server_Player::cmdSetSideboardPlan(const Command_SetSideb
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Response::ResponseCode Server_Player::cmdSetSideboardLock(const Command_SetSideboardLock &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
||||||
|
{
|
||||||
|
if (spectator)
|
||||||
|
return Response::RespFunctionNotAllowed;
|
||||||
|
if (readyStart)
|
||||||
|
return Response::RespContextError;
|
||||||
|
if (!deck)
|
||||||
|
return Response::RespContextError;
|
||||||
|
if (sideboardLocked == cmd.locked())
|
||||||
|
return Response::RespContextError;
|
||||||
|
|
||||||
|
sideboardLocked = cmd.locked();
|
||||||
|
if (sideboardLocked)
|
||||||
|
deck->setCurrentSideboardPlan(QList<MoveCard_ToZone>());
|
||||||
|
|
||||||
|
Event_PlayerPropertiesChanged event;
|
||||||
|
event.mutable_player_properties()->set_sideboard_locked(sideboardLocked);
|
||||||
|
ges.enqueueGameEvent(event, playerId);
|
||||||
|
ges.setGameEventContext(Context_SetSideboardLock());
|
||||||
|
|
||||||
|
return Response::RespOk;
|
||||||
|
}
|
||||||
|
|
||||||
Response::ResponseCode Server_Player::cmdConcede(const Command_Concede & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
Response::ResponseCode Server_Player::cmdConcede(const Command_Concede & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
||||||
{
|
{
|
||||||
if (spectator)
|
if (spectator)
|
||||||
|
@ -1572,6 +1602,7 @@ Response::ResponseCode Server_Player::processGameCommand(const GameCommand &comm
|
||||||
case GameCommand::MOVE_CARD: return cmdMoveCard(command.GetExtension(Command_MoveCard::ext), rc, ges); break;
|
case GameCommand::MOVE_CARD: return cmdMoveCard(command.GetExtension(Command_MoveCard::ext), rc, ges); break;
|
||||||
case GameCommand::SET_SIDEBOARD_PLAN: return cmdSetSideboardPlan(command.GetExtension(Command_SetSideboardPlan::ext), rc, ges); break;
|
case GameCommand::SET_SIDEBOARD_PLAN: return cmdSetSideboardPlan(command.GetExtension(Command_SetSideboardPlan::ext), rc, ges); break;
|
||||||
case GameCommand::DECK_SELECT: return cmdDeckSelect(command.GetExtension(Command_DeckSelect::ext), rc, ges); break;
|
case GameCommand::DECK_SELECT: return cmdDeckSelect(command.GetExtension(Command_DeckSelect::ext), rc, ges); break;
|
||||||
|
case GameCommand::SET_SIDEBOARD_LOCK: return cmdSetSideboardLock(command.GetExtension(Command_SetSideboardLock::ext), rc, ges); break;
|
||||||
default: return Response::RespInvalidCommand;
|
default: return Response::RespInvalidCommand;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ class Command_RevealCards;
|
||||||
class Command_MoveCard;
|
class Command_MoveCard;
|
||||||
class Command_SetSideboardPlan;
|
class Command_SetSideboardPlan;
|
||||||
class Command_DeckSelect;
|
class Command_DeckSelect;
|
||||||
|
class Command_SetSideboardLock;
|
||||||
|
|
||||||
class Server_Player : public Server_ArrowTarget {
|
class Server_Player : public Server_ArrowTarget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -76,6 +77,7 @@ private:
|
||||||
int nextCardId;
|
int nextCardId;
|
||||||
bool readyStart;
|
bool readyStart;
|
||||||
bool conceded;
|
bool conceded;
|
||||||
|
bool sideboardLocked;
|
||||||
public:
|
public:
|
||||||
mutable QMutex playerMutex;
|
mutable QMutex playerMutex;
|
||||||
Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_AbstractUserInterface *_handler);
|
Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_AbstractUserInterface *_handler);
|
||||||
|
@ -127,6 +129,7 @@ public:
|
||||||
Response::ResponseCode cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode cmdSetSideboardPlan(const Command_SetSideboardPlan &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdSetSideboardPlan(const Command_SetSideboardPlan &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
|
Response::ResponseCode cmdSetSideboardLock(const Command_SetSideboardLock &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode cmdGameSay(const Command_GameSay &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdGameSay(const Command_GameSay &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode cmdShuffle(const Command_Shuffle &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdShuffle(const Command_Shuffle &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
|
|
Loading…
Reference in a new issue