From d3709925c26a6af0b6bd705679039c0beb5b7edb Mon Sep 17 00:00:00 2001 From: doitux Date: Tue, 30 Mar 2010 22:12:47 +0000 Subject: [PATCH] GUI: try to fix refresh bug when player joined an invite-only-game --- .../gamelobbydialog/gamelobbydialogimpl.cpp | 20 +++++++++++++++---- .../qt/gamelobbydialog/gamelobbydialogimpl.h | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 025151f4..e928fd58 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -97,7 +97,7 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) connect( pushButton_StartGame, SIGNAL( clicked() ), this, SLOT( startGame() ) ); connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) ); connect( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) ); - connect( myGameListSelectionModel, SIGNAL( currentChanged (const QModelIndex &, const QModelIndex &) ), this, SLOT( gameSelected(const QModelIndex &, const QModelIndex &) ) ); + connect( myGameListSelectionModel, SIGNAL( currentChanged (const QModelIndex &, const QModelIndex &) ), this, SLOT( gameSelected(const QModelIndex &) ) ); connect( treeView_GameList, SIGNAL( doubleClicked (const QModelIndex &) ), this, SLOT( joinGame() ) ); connect( treeView_GameList->header(), SIGNAL( sortIndicatorChanged ( int , Qt::SortOrder )), this, SLOT( changeGameListSorting() ) ); connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) ); @@ -337,10 +337,10 @@ void gameLobbyDialogImpl::removedFromGame(int /*reason*/) leftGameDialogUpdate(); } -void gameLobbyDialogImpl::gameSelected(const QModelIndex &index, const QModelIndex &) +void gameLobbyDialogImpl::gameSelected(const QModelIndex &index, bool invitedRefreshHack) { - if (!inGame && index.isValid()) + if ((!inGame && index.isValid()) || (inGame && index.isValid() && invitedRefreshHack) ) { pushButton_JoinGame->setEnabled(true); @@ -760,6 +760,7 @@ void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerNam inGame = true; joinedGameDialogUpdate(); + myPlayerId = playerId; isGameAdministrator = isGameAdmin; addConnectedPlayer(playerId, playerName, isGameAdmin); @@ -770,6 +771,17 @@ void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerNam infoMsgToShowId = 2; showInfoMsgBoxTimer->start(1000); } + + if(!myGameListSelectionModel->hasSelection() && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY) { + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == mySession->getClientCurrentGameId()) { + gameSelected(treeView_GameList->model()->index(it,0), true); + break; + } + it++; + } + } } @@ -1317,7 +1329,7 @@ void gameLobbyDialogImpl::guestUserMode() void gameLobbyDialogImpl::showNickListContextMenu(QPoint p) { - if(treeWidget_NickList->topLevelItemCount()) { + if(treeWidget_NickList->topLevelItemCount() && !treeWidget_NickList->selectedItems().isEmpty()) { assert(mySession); diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 2c6ea3c3..702cb781 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -55,7 +55,7 @@ public slots: void createGame(); void joinGame(); void joinAnyGame(); - void gameSelected(const QModelIndex &, const QModelIndex &); + void gameSelected(const QModelIndex &, bool invitedRefreshHack = false); void updateGameItem(QList , unsigned gameId); void addGame(unsigned gameId); void updateGameMode(unsigned gameId, int newMode);