possible fix for #136 (The lobby "display idle players" feature does not work after playing a game)
This commit is contained in:
@@ -475,7 +475,6 @@ void gameLobbyDialogImpl::refresh(int actionID)
|
|||||||
treeView_GameList->setColumnWidth(3,25);
|
treeView_GameList->setColumnWidth(3,25);
|
||||||
treeView_GameList->setColumnWidth(4,25);
|
treeView_GameList->setColumnWidth(4,25);
|
||||||
treeView_GameList->setColumnWidth(5,30);
|
treeView_GameList->setColumnWidth(5,30);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QStringList headerList2;
|
QStringList headerList2;
|
||||||
@@ -594,6 +593,16 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
|
|||||||
PlayerIdList::const_iterator end = info.players.end();
|
PlayerIdList::const_iterator end = info.players.end();
|
||||||
|
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
|
//mark players as active
|
||||||
|
int it1 = 0;
|
||||||
|
while (myNickListModel->item(it1)) {
|
||||||
|
if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == *i) {
|
||||||
|
myNickListModel->item(it1, 0)->setData("active", 34);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++it1;
|
||||||
|
}
|
||||||
|
|
||||||
if(myPlayerId == *i) {
|
if(myPlayerId == *i) {
|
||||||
itemList.at(0)->setData( "MeInThisGame", 16);
|
itemList.at(0)->setData( "MeInThisGame", 16);
|
||||||
itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127)));
|
itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127)));
|
||||||
@@ -677,6 +686,21 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
|
|||||||
|
|
||||||
treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") );
|
treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") );
|
||||||
refreshGameStats();
|
refreshGameStats();
|
||||||
|
|
||||||
|
//mark spactators as active
|
||||||
|
PlayerIdList::const_iterator s = info.spectators.begin();
|
||||||
|
PlayerIdList::const_iterator s_end = info.spectators.end();
|
||||||
|
|
||||||
|
while (s != s_end) {
|
||||||
|
int it2 = 0;
|
||||||
|
while (myNickListModel->item(it2)) {
|
||||||
|
if (myNickListModel->item(it2, 0)->data(Qt::UserRole) == *s) {
|
||||||
|
myNickListModel->item(it2, 0)->setData("active", 34);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++it2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameLobbyDialogImpl::addGame(unsigned gameId)
|
void gameLobbyDialogImpl::addGame(unsigned gameId)
|
||||||
@@ -693,7 +717,6 @@ void gameLobbyDialogImpl::addGame(unsigned gameId)
|
|||||||
myGameListModel->appendRow(itemList);
|
myGameListModel->appendRow(itemList);
|
||||||
|
|
||||||
updateGameItem(itemList, gameId);
|
updateGameItem(itemList, gameId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/)
|
void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/)
|
||||||
@@ -781,14 +804,15 @@ void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
|
|||||||
if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) {
|
if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) {
|
||||||
QList <QStandardItem*> itemList;
|
QList <QStandardItem*> itemList;
|
||||||
itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4) << myGameListModel->item(it, 5);
|
itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4) << myGameListModel->item(it, 5);
|
||||||
|
|
||||||
updateGameItem(itemList, gameId);
|
updateGameItem(itemList, gameId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//mark player as active
|
void gameLobbyDialogImpl::gameAddSpectator(unsigned /*gameId*/, unsigned playerId)
|
||||||
|
{
|
||||||
int it1 = 0;
|
int it1 = 0;
|
||||||
while (myNickListModel->item(it1)) {
|
while (myNickListModel->item(it1)) {
|
||||||
if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) {
|
if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) {
|
||||||
@@ -799,11 +823,6 @@ void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameLobbyDialogImpl::gameAddSpectator(unsigned, unsigned)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
|
void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
|
||||||
{
|
{
|
||||||
if (!inGame) {
|
if (!inGame) {
|
||||||
@@ -840,9 +859,17 @@ void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameLobbyDialogImpl::gameRemoveSpectator(unsigned, unsigned)
|
void gameLobbyDialogImpl::gameRemoveSpectator(unsigned, unsigned playerId)
|
||||||
{
|
{
|
||||||
|
//mark spectator as idle again
|
||||||
|
int it1 = 0;
|
||||||
|
while (myNickListModel->item(it1)) {
|
||||||
|
if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) {
|
||||||
|
myNickListModel->item(it1, 0)->setData("idle", 34);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++it1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameLobbyDialogImpl::updateStats(ServerStats /*stats*/)
|
void gameLobbyDialogImpl::updateStats(ServerStats /*stats*/)
|
||||||
@@ -1093,12 +1120,13 @@ void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName)
|
|||||||
myNickListModel->item(it1, 0)->setToolTip(getFullCountryString(countryString.toUpper()));
|
myNickListModel->item(it1, 0)->setToolTip(getFullCountryString(countryString.toUpper()));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
|
// unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
|
||||||
if(gameIdOfPlayer) {
|
// if(gameIdOfPlayer) {
|
||||||
myNickListModel->item(it1, 0)->setData("active", 34);
|
// myNickListModel->item(it1, 0)->setData("active", 34);
|
||||||
} else {
|
// } else {
|
||||||
myNickListModel->item(it1, 0)->setData("idle", 34);
|
// qDebug("updateplayer idle");
|
||||||
}
|
// myNickListModel->item(it1, 0)->setData("idle", 34);
|
||||||
|
// }
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1167,15 +1195,7 @@ void gameLobbyDialogImpl::playerJoinedLobby(unsigned playerId, QString /*playerN
|
|||||||
item->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString)));
|
item->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString)));
|
||||||
item->setToolTip(getFullCountryString(countryString.toUpper()));
|
item->setToolTip(getFullCountryString(countryString.toUpper()));
|
||||||
}
|
}
|
||||||
|
item->setData("idle", 34);
|
||||||
unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
|
|
||||||
if(gameIdOfPlayer) {
|
|
||||||
item->setData("active", 34);
|
|
||||||
} else {
|
|
||||||
item->setData("idle", 34);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
myNickListModel->appendRow(item);
|
myNickListModel->appendRow(item);
|
||||||
|
|
||||||
refreshPlayerStats();
|
refreshPlayerStats();
|
||||||
|
|||||||
Reference in New Issue
Block a user