diff --git a/cockatrice/src/playerlistwidget.cpp b/cockatrice/src/playerlistwidget.cpp index c48f1759..6f0e27ed 100644 --- a/cockatrice/src/playerlistwidget.cpp +++ b/cockatrice/src/playerlistwidget.cpp @@ -137,13 +137,21 @@ void PlayerListWidget::updatePing(int playerId, int pingTime) twi->setIcon(0, QIcon(PingPixmapGenerator::generatePixmap(12, pingTime, 10))); } -void PlayerListWidget::setGameStarted(bool _gameStarted) +void PlayerListWidget::setGameStarted(bool _gameStarted, bool resuming) { gameStarted = _gameStarted; QMapIterator i(players); while (i.hasNext()) { 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); } } diff --git a/cockatrice/src/playerlistwidget.h b/cockatrice/src/playerlistwidget.h index 7d011387..dad5f82c 100644 --- a/cockatrice/src/playerlistwidget.h +++ b/cockatrice/src/playerlistwidget.h @@ -44,7 +44,7 @@ public: void setActivePlayer(int playerId); void updatePing(int playerId, int pingTime); void updatePlayerProperties(ServerInfo_PlayerProperties *prop); - void setGameStarted(bool _gameStarted); + void setGameStarted(bool _gameStarted, bool resuming); void showContextMenu(const QPoint &pos, const QModelIndex &index); }; diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 1d277252..d6e70b08 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -159,7 +159,7 @@ void DeckViewContainer::setDeck(DeckList *deck) } TabGame::TabGame(TabSupervisor *_tabSupervisor, QList &_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->hide(); @@ -486,7 +486,7 @@ void TabGame::sendCommandContainer(CommandContainer *cont, int playerId) client->sendCommandContainer(cont); } -void TabGame::startGame() +void TabGame::startGame(bool resuming) { currentPhase = -1; @@ -498,7 +498,13 @@ void TabGame::startGame() } mainLayout->removeItem(deckViewContainerLayout); - playerListWidget->setGameStarted(true); + if (!resuming) { + QMapIterator playerIterator(players); + while (playerIterator.hasNext()) + playerIterator.next().value()->setConceded(false); + } + + playerListWidget->setGameStarted(true, resuming); started = true; static_cast(gameView->scene())->rearrange(); gameView->show(); @@ -510,10 +516,6 @@ void TabGame::stopGame() currentPhase = -1; activePlayer = -1; - QMapIterator playerIterator(players); - while (playerIterator.hasNext()) - playerIterator.next().value()->setConceded(false); - QMapIterator i(deckViewContainers); while (i.hasNext()) { i.next(); @@ -522,7 +524,7 @@ void TabGame::stopGame() mainLayout->insertLayout(1, deckViewContainerLayout, 10); playerListWidget->setActivePlayer(-1); - playerListWidget->setGameStarted(false); + playerListWidget->setGameStarted(false, false); started = false; gameView->hide(); phasesToolbar->hide(); @@ -578,8 +580,8 @@ void TabGame::eventGameStateChanged(Event_GameStateChanged *event, GameEventCont } } if (event->getGameStarted() && !started) { - startGame(); - if (!resuming) + startGame(!gameStateKnown); + if (gameStateKnown) messageLog->logGameStart(); setActivePlayer(event->getActivePlayer()); setActivePhase(event->getActivePhase()); @@ -587,6 +589,7 @@ void TabGame::eventGameStateChanged(Event_GameStateChanged *event, GameEventCont stopGame(); scene->clearViews(); } + gameStateKnown = true; emit userEvent(); } diff --git a/cockatrice/src/tab_game.h b/cockatrice/src/tab_game.h index a5eb5db9..7013f70c 100644 --- a/cockatrice/src/tab_game.h +++ b/cockatrice/src/tab_game.h @@ -93,6 +93,7 @@ private: bool spectatorsCanTalk, spectatorsSeeEverything; QMap players; QMap spectators; + bool gameStateKnown; bool started; bool resuming; QStringList phasesList; @@ -120,7 +121,7 @@ private: Player *addPlayer(int playerId, ServerInfo_User *info); - void startGame(); + void startGame(bool resuming); void stopGame(); void eventSpectatorSay(Event_Say *event, GameEventContext *context);