From 3ed26e11ae281489a7846bb80796de3bef12bbe1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2011 16:32:55 +0200 Subject: [PATCH] fix: don't show conceded players, fix: compute multicolumn layout correctly when dealing with odd number of players --- cockatrice/src/gamescene.cpp | 3 +-- cockatrice/src/player.cpp | 2 ++ cockatrice/src/playerlistwidget.cpp | 4 +++- cockatrice/src/tab_game.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/gamescene.cpp b/cockatrice/src/gamescene.cpp index 5cb1d29b4..86e2c3b6b 100644 --- a/cockatrice/src/gamescene.cpp +++ b/cockatrice/src/gamescene.cpp @@ -64,7 +64,6 @@ void GameScene::rearrange() const int playersCount = playersPlaying.size(); const int columns = playersCount < settingsCache->getMinPlayersForMultiColumnLayout() ? 1 : 2; const int rows = ceil((qreal) playersCount / columns); - qreal sceneHeight = 0, sceneWidth = -playerAreaSpacing; QList columnWidth; int firstPlayerOfColumn = firstPlayer; @@ -72,7 +71,7 @@ void GameScene::rearrange() playersByColumn.append(QList()); columnWidth.append(0); qreal thisColumnHeight = -playerAreaSpacing; - const int rowsInColumn = rows - (playersCount % columns); + const int rowsInColumn = rows - (playersCount % columns) * col; // only correct for max. 2 cols for (int j = 0; j < rowsInColumn; ++j) { Player *player = playersPlaying[(firstPlayerOfColumn + j) % playersCount]; if (col == 0) diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index fc794bd3f..539e4068a 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -1123,6 +1123,8 @@ void Player::processPlayerInfo(ServerInfo_Player *info) QList al = info->getArrowList(); for (int i = 0; i < al.size(); ++i) addArrow(al.at(i)); + + setConceded(info->getProperties()->getConceded()); } void Player::processCardAttachment(ServerInfo_Player *info) diff --git a/cockatrice/src/playerlistwidget.cpp b/cockatrice/src/playerlistwidget.cpp index a43b2e33a..c48f1759e 100644 --- a/cockatrice/src/playerlistwidget.cpp +++ b/cockatrice/src/playerlistwidget.cpp @@ -88,6 +88,8 @@ void PlayerListWidget::updatePlayerProperties(ServerInfo_PlayerProperties *prop) player->setIcon(1, prop->getSpectator() ? spectatorIcon : playerIcon); player->setData(1, Qt::UserRole, !prop->getSpectator()); + player->setData(2, Qt::UserRole, prop->getConceded()); + player->setData(2, Qt::UserRole + 1, prop->getReadyStart()); player->setIcon(2, gameStarted ? (prop->getConceded() ? concededIcon : QIcon()) : (prop->getReadyStart() ? readyIcon : notReadyIcon)); player->setData(3, Qt::UserRole, prop->getUserInfo()->getUserLevel()); player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, prop->getUserInfo()->getUserLevel()))); @@ -141,7 +143,7 @@ void PlayerListWidget::setGameStarted(bool _gameStarted) QMapIterator i(players); while (i.hasNext()) { QTreeWidgetItem *twi = i.next().value(); - twi->setIcon(2, gameStarted ? QIcon() : notReadyIcon); + twi->setIcon(2, gameStarted ? (twi->data(2, Qt::UserRole).toBool() ? concededIcon : QIcon()) : (twi->data(2, Qt::UserRole + 1).toBool() ? readyIcon : notReadyIcon)); } } diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 9b15e0deb..1d277252c 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -498,10 +498,6 @@ void TabGame::startGame() } mainLayout->removeItem(deckViewContainerLayout); - QMapIterator playerIterator(players); - while (playerIterator.hasNext()) - playerIterator.next().value()->setConceded(false); - playerListWidget->setGameStarted(true); started = true; static_cast(gameView->scene())->rearrange(); @@ -514,6 +510,10 @@ 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();