hopefully fixed yesterday's fix

This commit is contained in:
unknown 2011-09-13 15:34:46 +02:00
parent 3ed26e11ae
commit 4744cf7d0b
4 changed files with 26 additions and 14 deletions

View file

@ -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<int, QTreeWidgetItem *> 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);
}
}

View file

@ -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);
};

View file

@ -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)
: 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<int, Player *> playerIterator(players);
while (playerIterator.hasNext())
playerIterator.next().value()->setConceded(false);
}
playerListWidget->setGameStarted(true, resuming);
started = true;
static_cast<GameScene *>(gameView->scene())->rearrange();
gameView->show();
@ -510,10 +516,6 @@ void TabGame::stopGame()
currentPhase = -1;
activePlayer = -1;
QMapIterator<int, Player *> playerIterator(players);
while (playerIterator.hasNext())
playerIterator.next().value()->setConceded(false);
QMapIterator<int, DeckViewContainer *> 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();
}

View file

@ -93,6 +93,7 @@ private:
bool spectatorsCanTalk, spectatorsSeeEverything;
QMap<int, Player *> players;
QMap<int, QString> 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);