adds lobby stats information
This commit is contained in:
@@ -13,6 +13,12 @@
|
||||
<string>Internet Game Lobby</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="bottomMargin" >
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="verticalSpacing" >
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item rowspan="3" row="0" column="0" >
|
||||
<widget class="QTreeWidget" name="treeWidget_NickList" >
|
||||
<property name="sizePolicy" >
|
||||
@@ -459,6 +465,44 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_connectedPlayersCounter" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_nickListCounter" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_runningGamesCounter" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_openGamesCounter" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user