From fe09fb94dddb07b9f9b843731aa5684a073f4409 Mon Sep 17 00:00:00 2001 From: doitux Date: Thu, 15 Jul 2010 10:55:09 +0000 Subject: [PATCH] =?UTF-8?q?add=20"player=20yxz=20is=20playing=20in=20game?= =?UTF-8?q?=20yxz"=20info=20to=20player=20context=20men=C3=BC=20in=20the?= =?UTF-8?q?=20lobby?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gamelobbydialog/gamelobbydialogimpl.cpp | 24 +++++++++++++++---- .../qt/gamelobbydialog/gamelobbydialogimpl.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index d991bf54..440e9cd4 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -90,6 +90,8 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) nickListContextMenu->addAction(nickListInviteAction); nickListIgnorePlayerAction = new QAction(QIcon(":/gfx/im-ban-user.png"), tr("Ignore player"), nickListContextMenu); nickListContextMenu->addAction(nickListIgnorePlayerAction); + nickListPlayerInGameInfo = new QAction(nickListContextMenu); + nickListContextMenu->addAction(nickListPlayerInGameInfo); connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) ); @@ -1369,12 +1371,14 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p) { if(treeWidget_NickList->topLevelItemCount() && !treeWidget_NickList->selectedItems().isEmpty()) { - assert(mySession); - if(inGame && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY && treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt() != mySession->getClientUniquePlayerId() && !mySession->getClientPlayerInfo(treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt()).isGuest) { + assert(mySession); + int playerUid = treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt(); + + if(inGame && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY && playerUid != mySession->getClientUniquePlayerId() && !mySession->getClientPlayerInfo(playerUid).isGuest) { nickListInviteAction->setEnabled(true); - nickListInviteAction->setText(tr("Invite player %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt()).playerName.c_str()))); + nickListInviteAction->setText(tr("Invite player %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()))); } else { @@ -1382,10 +1386,10 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p) nickListInviteAction->setEnabled(false); } - if(treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt() != mySession->getClientUniquePlayerId() && !mySession->getClientPlayerInfo(treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt()).isGuest) { + if(playerUid != mySession->getClientUniquePlayerId() && !mySession->getClientPlayerInfo(playerUid).isGuest) { nickListIgnorePlayerAction->setEnabled(true); - nickListIgnorePlayerAction->setText(tr("Ignore player %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt()).playerName.c_str()))); + nickListIgnorePlayerAction->setText(tr("Ignore player %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()))); } else { @@ -1394,6 +1398,16 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p) } + unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerUid); + QString playerInGameInfoString; + if(gameIdOfPlayer) { + playerInGameInfoString = tr("Player %1 is playing in \"%2\".").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameIdOfPlayer).name.c_str())); + } + else { + playerInGameInfoString = tr("Player %1 is not playing at the moment.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())); + } + nickListPlayerInGameInfo->setText(playerInGameInfoString); + nickListContextMenu->popup(treeWidget_NickList->mapToGlobal(p)); } } diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 1815da9a..072985ab 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -142,6 +142,7 @@ private: QMenu *nickListContextMenu; QAction *nickListInviteAction; QAction *nickListIgnorePlayerAction; + QAction *nickListPlayerInGameInfo; int infoMsgToShowId; int currentInvitationGameId; bool inviteDialogIsCurrentlyShown;