hopefully fixed yesterday's fix
This commit is contained in:
parent
3ed26e11ae
commit
4744cf7d0b
4 changed files with 26 additions and 14 deletions
|
@ -137,13 +137,21 @@ void PlayerListWidget::updatePing(int playerId, int pingTime)
|
||||||
twi->setIcon(0, QIcon(PingPixmapGenerator::generatePixmap(12, pingTime, 10)));
|
twi->setIcon(0, QIcon(PingPixmapGenerator::generatePixmap(12, pingTime, 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerListWidget::setGameStarted(bool _gameStarted)
|
void PlayerListWidget::setGameStarted(bool _gameStarted, bool resuming)
|
||||||
{
|
{
|
||||||
gameStarted = _gameStarted;
|
gameStarted = _gameStarted;
|
||||||
QMapIterator<int, QTreeWidgetItem *> i(players);
|
QMapIterator<int, QTreeWidgetItem *> i(players);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
QTreeWidgetItem *twi = i.next().value();
|
QTreeWidgetItem *twi = i.next().value();
|
||||||
twi->setIcon(2, gameStarted ? (twi->data(2, Qt::UserRole).toBool() ? concededIcon : QIcon()) : (twi->data(2, Qt::UserRole + 1).toBool() ? readyIcon : notReadyIcon));
|
if (gameStarted) {
|
||||||
|
if (resuming)
|
||||||
|
twi->setIcon(2, twi->data(2, Qt::UserRole).toBool() ? concededIcon : QIcon());
|
||||||
|
else {
|
||||||
|
twi->setData(2, Qt::UserRole, false);
|
||||||
|
twi->setIcon(2, QIcon());
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
twi->setIcon(2, notReadyIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
void setActivePlayer(int playerId);
|
void setActivePlayer(int playerId);
|
||||||
void updatePing(int playerId, int pingTime);
|
void updatePing(int playerId, int pingTime);
|
||||||
void updatePlayerProperties(ServerInfo_PlayerProperties *prop);
|
void updatePlayerProperties(ServerInfo_PlayerProperties *prop);
|
||||||
void setGameStarted(bool _gameStarted);
|
void setGameStarted(bool _gameStarted, bool resuming);
|
||||||
void showContextMenu(const QPoint &pos, const QModelIndex &index);
|
void showContextMenu(const QPoint &pos, const QModelIndex &index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ void DeckViewContainer::setDeck(DeckList *deck)
|
||||||
}
|
}
|
||||||
|
|
||||||
TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, int _gameId, const QString &_gameDescription, int _localPlayerId, ServerInfo_User *_userInfo, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming)
|
TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, int _gameId, const QString &_gameDescription, int _localPlayerId, ServerInfo_User *_userInfo, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming)
|
||||||
: Tab(_tabSupervisor), clients(_clients), gameId(_gameId), gameDescription(_gameDescription), localPlayerId(_localPlayerId), spectator(_spectator), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), started(false), resuming(_resuming), currentPhase(-1)
|
: Tab(_tabSupervisor), clients(_clients), gameId(_gameId), gameDescription(_gameDescription), localPlayerId(_localPlayerId), spectator(_spectator), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), gameStateKnown(false), started(false), resuming(_resuming), currentPhase(-1)
|
||||||
{
|
{
|
||||||
phasesToolbar = new PhasesToolbar;
|
phasesToolbar = new PhasesToolbar;
|
||||||
phasesToolbar->hide();
|
phasesToolbar->hide();
|
||||||
|
@ -486,7 +486,7 @@ void TabGame::sendCommandContainer(CommandContainer *cont, int playerId)
|
||||||
client->sendCommandContainer(cont);
|
client->sendCommandContainer(cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::startGame()
|
void TabGame::startGame(bool resuming)
|
||||||
{
|
{
|
||||||
currentPhase = -1;
|
currentPhase = -1;
|
||||||
|
|
||||||
|
@ -498,7 +498,13 @@ void TabGame::startGame()
|
||||||
}
|
}
|
||||||
mainLayout->removeItem(deckViewContainerLayout);
|
mainLayout->removeItem(deckViewContainerLayout);
|
||||||
|
|
||||||
playerListWidget->setGameStarted(true);
|
if (!resuming) {
|
||||||
|
QMapIterator<int, Player *> playerIterator(players);
|
||||||
|
while (playerIterator.hasNext())
|
||||||
|
playerIterator.next().value()->setConceded(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerListWidget->setGameStarted(true, resuming);
|
||||||
started = true;
|
started = true;
|
||||||
static_cast<GameScene *>(gameView->scene())->rearrange();
|
static_cast<GameScene *>(gameView->scene())->rearrange();
|
||||||
gameView->show();
|
gameView->show();
|
||||||
|
@ -510,10 +516,6 @@ void TabGame::stopGame()
|
||||||
currentPhase = -1;
|
currentPhase = -1;
|
||||||
activePlayer = -1;
|
activePlayer = -1;
|
||||||
|
|
||||||
QMapIterator<int, Player *> playerIterator(players);
|
|
||||||
while (playerIterator.hasNext())
|
|
||||||
playerIterator.next().value()->setConceded(false);
|
|
||||||
|
|
||||||
QMapIterator<int, DeckViewContainer *> i(deckViewContainers);
|
QMapIterator<int, DeckViewContainer *> i(deckViewContainers);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
|
@ -522,7 +524,7 @@ void TabGame::stopGame()
|
||||||
mainLayout->insertLayout(1, deckViewContainerLayout, 10);
|
mainLayout->insertLayout(1, deckViewContainerLayout, 10);
|
||||||
|
|
||||||
playerListWidget->setActivePlayer(-1);
|
playerListWidget->setActivePlayer(-1);
|
||||||
playerListWidget->setGameStarted(false);
|
playerListWidget->setGameStarted(false, false);
|
||||||
started = false;
|
started = false;
|
||||||
gameView->hide();
|
gameView->hide();
|
||||||
phasesToolbar->hide();
|
phasesToolbar->hide();
|
||||||
|
@ -578,8 +580,8 @@ void TabGame::eventGameStateChanged(Event_GameStateChanged *event, GameEventCont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event->getGameStarted() && !started) {
|
if (event->getGameStarted() && !started) {
|
||||||
startGame();
|
startGame(!gameStateKnown);
|
||||||
if (!resuming)
|
if (gameStateKnown)
|
||||||
messageLog->logGameStart();
|
messageLog->logGameStart();
|
||||||
setActivePlayer(event->getActivePlayer());
|
setActivePlayer(event->getActivePlayer());
|
||||||
setActivePhase(event->getActivePhase());
|
setActivePhase(event->getActivePhase());
|
||||||
|
@ -587,6 +589,7 @@ void TabGame::eventGameStateChanged(Event_GameStateChanged *event, GameEventCont
|
||||||
stopGame();
|
stopGame();
|
||||||
scene->clearViews();
|
scene->clearViews();
|
||||||
}
|
}
|
||||||
|
gameStateKnown = true;
|
||||||
emit userEvent();
|
emit userEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ private:
|
||||||
bool spectatorsCanTalk, spectatorsSeeEverything;
|
bool spectatorsCanTalk, spectatorsSeeEverything;
|
||||||
QMap<int, Player *> players;
|
QMap<int, Player *> players;
|
||||||
QMap<int, QString> spectators;
|
QMap<int, QString> spectators;
|
||||||
|
bool gameStateKnown;
|
||||||
bool started;
|
bool started;
|
||||||
bool resuming;
|
bool resuming;
|
||||||
QStringList phasesList;
|
QStringList phasesList;
|
||||||
|
@ -120,7 +121,7 @@ private:
|
||||||
|
|
||||||
Player *addPlayer(int playerId, ServerInfo_User *info);
|
Player *addPlayer(int playerId, ServerInfo_User *info);
|
||||||
|
|
||||||
void startGame();
|
void startGame(bool resuming);
|
||||||
void stopGame();
|
void stopGame();
|
||||||
|
|
||||||
void eventSpectatorSay(Event_Say *event, GameEventContext *context);
|
void eventSpectatorSay(Event_Say *event, GameEventContext *context);
|
||||||
|
|
Loading…
Reference in a new issue