From a878827c84fc759f2dd3dd25f02ab470d86ea59d Mon Sep 17 00:00:00 2001 From: doitux Date: Wed, 17 Oct 2007 22:27:11 +0000 Subject: [PATCH] adds lobby stats information --- src/gui/qt/gamelobbydialog.ui | 44 +++++++++++++++++++ .../gamelobbydialog/gamelobbydialogimpl.cpp | 27 ++++++++++++ .../qt/gamelobbydialog/gamelobbydialogimpl.h | 3 ++ .../gamelobbydialog/lobbychat/lobbychat.cpp | 4 ++ 4 files changed, 78 insertions(+) diff --git a/src/gui/qt/gamelobbydialog.ui b/src/gui/qt/gamelobbydialog.ui index 56939f55..b69c288a 100644 --- a/src/gui/qt/gamelobbydialog.ui +++ b/src/gui/qt/gamelobbydialog.ui @@ -13,6 +13,12 @@ Internet Game Lobby + + 4 + + + 4 + @@ -459,6 +465,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index c596d87d..e540099b 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -237,6 +237,8 @@ void gameLobbyDialogImpl::updateGameItem(QTreeWidgetItem *item, unsigned gameId) if (info.isPasswordProtected) item->setIcon(3, QIcon(myAppDataPath+"gfx/gui/misc/lock.png")); + + refreshGameStats(); } void gameLobbyDialogImpl::addGame(unsigned gameId) @@ -275,6 +277,31 @@ void gameLobbyDialogImpl::removeGame(unsigned gameId) } ++it; } + + refreshGameStats(); +} + +void gameLobbyDialogImpl::refreshGameStats() { + + int runningGamesCounter = 0; + int openGamesCounter = 0; + + QTreeWidgetItemIterator it(treeWidget_GameList); + while (*it) { + if ((*it)->data(2, Qt::DisplayRole) == tr("running")) { runningGamesCounter++; } + if ((*it)->data(2, Qt::DisplayRole) == tr("open")) { openGamesCounter++; } + ++it; + } + + label_openGamesCounter->setText("| "+tr("running games: %1").arg(runningGamesCounter)); + label_runningGamesCounter->setText("| "+tr("open games: %1").arg(openGamesCounter)); + +} + +void gameLobbyDialogImpl::refreshPlayerStats() { + + label_nickListCounter->setText("| "+tr("nicks in chat: %1").arg(treeWidget_NickList->topLevelItemCount())); + label_connectedPlayersCounter->setText(tr("connected players: %1").arg(0)); } void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId) diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index dabff285..d62b4859 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -61,6 +61,9 @@ public slots: void removeGame(unsigned gameId); void gameAddPlayer(unsigned gameId, unsigned playerId); void gameRemovePlayer(unsigned gameId, unsigned playerId); + + void refreshGameStats(); + void refreshPlayerStats(); void setCurrentGameName ( const QString& theValue ) { currentGameName = theValue; } QString getCurrentGameName() const { return currentGameName; } diff --git a/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp b/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp index 4cae8f44..00026802 100644 --- a/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp +++ b/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp @@ -76,6 +76,8 @@ void LobbyChat::playerJoined(QString playerName) item->setData(0, Qt::DisplayRole, playerName); myLobby->treeWidget_NickList->sortItems(0, Qt::AscendingOrder); + + myLobby->refreshPlayerStats(); } void LobbyChat::playerChanged(QString oldNick, QString newNick) @@ -114,6 +116,8 @@ void LobbyChat::playerLeft(QString playerName) myLobby->treeWidget_NickList->takeTopLevelItem(myLobby->treeWidget_NickList->indexOfTopLevelItem(tmpList.front())); myLobby->treeWidget_NickList->sortItems(0, Qt::AscendingOrder); + + myLobby->refreshPlayerStats(); } void LobbyChat::displayMessage(QString playerName, QString message) {