From 972ab5e2ee04d314543da6c87e54a6985730cc8e Mon Sep 17 00:00:00 2001 From: doitux Date: Mon, 30 Sep 2013 10:23:51 +0200 Subject: [PATCH] implement spectator display on the table to check if spectators watching the current game (#196) --- src/gui/generic/serverguiwrapper.cpp | 20 -- .../gamelobbydialog/gamelobbydialogimpl.cpp | 9 - src/gui/qt/gametable.ui | 184 +++++++++++++++--- src/gui/qt/gametable/gametableimpl.cpp | 47 ++++- src/gui/qt/gametable/gametableimpl.h | 4 + src/gui/qt/guiwrapper.cpp | 2 + src/gui/qt/resources/pokerth.qrc | 1 + src/gui/qt/resources/pokerth_android.qrc | 1 + 8 files changed, 208 insertions(+), 60 deletions(-) diff --git a/src/gui/generic/serverguiwrapper.cpp b/src/gui/generic/serverguiwrapper.cpp index 3aeab28b..b0b1f535 100644 --- a/src/gui/generic/serverguiwrapper.cpp +++ b/src/gui/generic/serverguiwrapper.cpp @@ -58,70 +58,50 @@ void ServerGuiWrapper::setSession(boost::shared_ptr session) } void ServerGuiWrapper::refreshSet() const {} - void ServerGuiWrapper::refreshCash() const {} - void ServerGuiWrapper::refreshAction(int /*playerID*/, int /*playerAction*/) const {} - void ServerGuiWrapper::refreshChangePlayer() const {} - void ServerGuiWrapper::refreshAll() const {} - void ServerGuiWrapper::refreshPot() const {} void ServerGuiWrapper::refreshGroupbox(int /*playerID*/, int /*status*/) const {} void ServerGuiWrapper::refreshPlayerName() const {} void ServerGuiWrapper::refreshButton() const {} void ServerGuiWrapper::refreshGameLabels(GameState /*state*/) const {} - void ServerGuiWrapper::setPlayerAvatar(int /*myUniqueID*/, const std::string &/*myAvatar*/) const {}; - void ServerGuiWrapper::waitForGuiUpdateDone() const {} - void ServerGuiWrapper::dealBeRoCards(int /*myBeRoID*/) {} void ServerGuiWrapper::dealHoleCards() {} void ServerGuiWrapper::dealFlopCards() {} void ServerGuiWrapper::dealTurnCard() {} void ServerGuiWrapper::dealRiverCard() {} - void ServerGuiWrapper::nextPlayerAnimation() {} - void ServerGuiWrapper::beRoAnimation2(int /*myBeRoID*/) {} - void ServerGuiWrapper::preflopAnimation1() {} void ServerGuiWrapper::preflopAnimation2() {} - void ServerGuiWrapper::flopAnimation1() {} void ServerGuiWrapper::flopAnimation2() {} - void ServerGuiWrapper::turnAnimation1() {} void ServerGuiWrapper::turnAnimation2() {} - void ServerGuiWrapper::riverAnimation1() {} void ServerGuiWrapper::riverAnimation2() {} - void ServerGuiWrapper::postRiverAnimation1() {} void ServerGuiWrapper::postRiverRunAnimation1() {} void ServerGuiWrapper::flipHolecardsAllIn() {} - void ServerGuiWrapper::nextRoundCleanGui() {} - void ServerGuiWrapper::meInAction() {} void ServerGuiWrapper::disableMyButtons() {} void ServerGuiWrapper::updateMyButtonsState() {} void ServerGuiWrapper::startTimeoutAnimation(int /*playerNum*/, int /*timeoutSec*/) {} void ServerGuiWrapper::stopTimeoutAnimation(int /*playerNum*/) {} - void ServerGuiWrapper::startVoteOnKick(unsigned /*playerId*/, unsigned /*voteStarterPlayerId*/, int /*timeoutSec*/, int /*numVotesNeededToKick*/) {} void ServerGuiWrapper::changeVoteOnKickButtonsState(bool /*showHide*/) {} void ServerGuiWrapper::refreshVotesMonitor(int /*currentVotes*/, int /*numVotesNeededToKick*/) {} void ServerGuiWrapper::endVoteOnKick() {} - void ServerGuiWrapper::logPlayerActionMsg(string /*playerName*/, int /*action*/, int /*setValue*/) {} void ServerGuiWrapper::logNewGameHandMsg(int /*gameID*/, int /*handID*/) {} void ServerGuiWrapper::logPlayerWinsMsg(std::string /*playerName*/, int /*pot*/, bool /*main*/) {} void ServerGuiWrapper::logPlayerSitsOut(std::string /*playerName*/) {} void ServerGuiWrapper::logNewBlindsSetsMsg(int /*sbSet*/, int /*bbSet*/, std::string /*sbName*/, std::string /*bbName*/) {} - void ServerGuiWrapper::logDealBoardCardsMsg(int /*roundID*/, int /*card1*/, int /*card2*/, int /*card3*/, int /*card4*/, int /*card5*/) {} void ServerGuiWrapper::logFlipHoleCardsMsg(std::string /*playerName*/, int /*card1*/, int /*card2*/, int /*cardsValueInt*/, std::string /*showHas*/) {} void ServerGuiWrapper::logPlayerWinGame(std::string /*playerName*/, int /*gameID*/) {} diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 737e66e8..5c4de2e3 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -1120,15 +1120,6 @@ void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) myNickListModel->item(it1, 0)->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString))); myNickListModel->item(it1, 0)->setToolTip(getFullCountryString(countryString.toUpper())); } - -// unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId); -// if(gameIdOfPlayer) { -// myNickListModel->item(it1, 0)->setData("active", 34); -// } else { -// qDebug("updateplayer idle"); -// myNickListModel->item(it1, 0)->setData("idle", 34); -// } - break; } diff --git a/src/gui/qt/gametable.ui b/src/gui/qt/gametable.ui index 557211b5..fe723a76 100644 --- a/src/gui/qt/gametable.ui +++ b/src/gui/qt/gametable.ui @@ -2235,7 +2235,16 @@ p, li { white-space: pre-wrap; } QGroupBox {border-style:none;} - + + 0 + + + 0 + + + 0 + + 0 @@ -2306,15 +2315,24 @@ p, li { white-space: pre-wrap; } + + 0 + + + 0 + + + 0 + + + 0 + 3 2 - - 0 - @@ -2556,15 +2574,24 @@ p, li { white-space: pre-wrap; } + + 0 + + + 0 + + + 0 + + + 0 + 3 2 - - 0 - @@ -3532,7 +3559,16 @@ p, li { white-space: pre-wrap; } 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -3582,7 +3618,16 @@ p, li { white-space: pre-wrap; } - + + 4 + + + 4 + + + 4 + + 4 @@ -3598,7 +3643,16 @@ p, li { white-space: pre-wrap; } Hands - + + 0 + + + 0 + + + 0 + + 0 @@ -3618,7 +3672,16 @@ p, li { white-space: pre-wrap; } Chat - + + 0 + + + 0 + + + 0 + + 0 @@ -3650,15 +3713,24 @@ p, li { white-space: pre-wrap; } Kick + + 5 + + + 5 + + + 5 + + + 5 + 0 6 - - 5 - @@ -3790,12 +3862,21 @@ p, li { white-space: pre-wrap; } Player info + + 6 + + + 6 + + + 6 + + + 6 + 3 - - 6 - @@ -3868,15 +3949,24 @@ p, li { white-space: pre-wrap; } + + 0 + + + 0 + + + 0 + + + 0 + 0 1 - - 0 - @@ -4026,7 +4116,7 @@ p, li { white-space: pre-wrap; } - 20 + 0 0 @@ -4039,7 +4129,7 @@ p, li { white-space: pre-wrap; } - 20 + 0 0 @@ -4069,7 +4159,16 @@ p, li { white-space: pre-wrap; } 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -4119,15 +4218,24 @@ p, li { white-space: pre-wrap; } + + 4 + + + 4 + + + 4 + + + 4 + 1 2 - - 4 - @@ -4141,7 +4249,16 @@ p, li { white-space: pre-wrap; } Log - + + 0 + + + 0 + + + 0 + + 0 @@ -4251,7 +4368,16 @@ p, li { white-space: pre-wrap; } 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -4463,7 +4589,7 @@ p, li { white-space: pre-wrap; } 0 0 1024 - 26 + 19 diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index d72a5e95..1f0e7ae4 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -449,6 +449,8 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) pushButton_showMyCards->hide(); + spectatorIcon = new QLabel(this); + //style Game Table refreshGameTableStyle(); @@ -674,9 +676,9 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalStartVoteOnKick(unsigned, unsigned, int, int)), this, SLOT(startVoteOnKick(unsigned, unsigned, int, int))); connect(this, SIGNAL(signalChangeVoteOnKickButtonsState(bool)), this, SLOT(changeVoteOnKickButtonsState(bool))); connect(this, SIGNAL(signalEndVoteOnKick()), this, SLOT(endVoteOnKick())); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned)), this, SLOT(netClientPlayerLeft(unsigned))); connect(this, SIGNAL(signalNetClientSpectatorLeft(unsigned)), this, SLOT(netClientSpectatorLeft(unsigned))); + connect(this, SIGNAL(signalNetClientSpectatorJoined(unsigned)), this, SLOT(netClientSpectatorJoined(unsigned))); #ifdef GUI_800x480 connect( tabsButton, SIGNAL( clicked() ), this, SLOT( tabsButtonClicked() ) ); @@ -3260,6 +3262,9 @@ bool gameTableImpl::eventFilter(QObject *obj, QEvent *event) event->ignore(); closeGameTable(); return true; + } else if (event->type() == QEvent::Resize) { + refreshSpectatorsDisplay(); + return true; } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); @@ -3586,6 +3591,8 @@ void gameTableImpl::networkGameModification() myGameTableStyle->setBreakButtonStyle(pushButton_break,0); #endif blinkingStartButtonAnimationTimer->stop(); + + refreshSpectatorsDisplay(); } if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) { #ifdef GUI_800x480 @@ -3619,6 +3626,8 @@ void gameTableImpl::networkGameModification() //let the SoundEventHandler know that there is a new game mySoundEventHandler->newGameStarts(); + + //check if there are spectators } void gameTableImpl::mouseOverFlipCards(bool front) @@ -4303,9 +4312,14 @@ void gameTableImpl::netClientPlayerLeft(unsigned /*playerId*/) } } +void gameTableImpl::netClientSpectatorJoined(unsigned /*playerId*/) +{ + refreshSpectatorsDisplay(); +} + void gameTableImpl::netClientSpectatorLeft(unsigned /*playerId*/) { - // TODO + refreshSpectatorsDisplay(); } void gameTableImpl::registeredUserMode() @@ -4444,3 +4458,32 @@ void gameTableImpl::checkActionLabelPosition() } #endif } + +void gameTableImpl::refreshSpectatorsDisplay() +{ + assert(myStartWindow->getSession()); + GameInfo info(myStartWindow->getSession()->getClientGameInfo(myStartWindow->getSession()->getClientCurrentGameId())); + if(info.spectatorsDuringGame.size()) { + QPixmap spectatorPix(":/gfx/spectator.png"); + int iconX = this->centralWidget()->geometry().width() - spectatorPix.width() - 1; + int iconY = 2; + spectatorIcon->move(iconX,iconY); + spectatorIcon->setPixmap(spectatorPix); + + QString spectatorList = QString(""+tr("Spectators")+":
"); + PlayerIdList::const_iterator i = info.spectatorsDuringGame.begin(); + PlayerIdList::const_iterator end = info.spectatorsDuringGame.end(); + while (i != end) { + PlayerInfo playerInfo(myStartWindow->getSession()->getClientPlayerInfo(*i)); + spectatorList.append(QString::fromUtf8(playerInfo.playerName.c_str())+"
"); + ++i; + } + spectatorList.remove(spectatorList.size()-4,4); + spectatorIcon->setToolTip(spectatorList); + } + else { + spectatorIcon->setToolTip(""); + spectatorIcon->clear(); + } +} + diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index 71b6338e..cf53d0e2 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -173,6 +173,7 @@ signals: void signalEndVoteOnKick(); void signalNetClientPlayerLeft(unsigned playerId); void signalNetClientSpectatorLeft(unsigned playerId); + void signalNetClientSpectatorJoined(unsigned playerId); public slots: @@ -355,6 +356,7 @@ public slots: void netClientPlayerLeft(unsigned playerId); void netClientSpectatorLeft(unsigned playerId); + void netClientSpectatorJoined(unsigned playerId); void registeredUserMode(); void guestUserMode(); @@ -371,6 +373,7 @@ public slots: void tabsButtonClicked(); void tabsButtonClose(); #endif + void refreshSpectatorsDisplay(); private: @@ -437,6 +440,7 @@ private: QLabel *playerTipLabelArray[MAX_NUMBER_OF_PLAYERS]; QPixmap flipside; + QLabel *spectatorIcon; // Dialogs startWindowImpl *myStartWindow; diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 689e4d48..7c1d9cbc 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -364,6 +364,7 @@ void GuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &pl void GuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName) { myStartWindow->signalNetClientPlayerChanged(playerId, QString::fromUtf8(newPlayerName.c_str())); + myW->refreshSpectatorsDisplay(); } void GuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName, int removeReason) { @@ -376,6 +377,7 @@ void GuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &play void GuiWrapper::SignalNetClientSpectatorJoined(unsigned playerId, const string &playerName) { myStartWindow->signalNetClientSpectatorJoined(playerId, QString::fromUtf8(playerName.c_str())); + myW->signalNetClientSpectatorJoined(playerId); if (!playerName.empty() && playerName[0] != '#' && myW->isVisible()) { QString tmpName(QString::fromUtf8(playerName.c_str())); myGuiLog->signalLogSpectatorJoinedMsg(tmpName); diff --git a/src/gui/qt/resources/pokerth.qrc b/src/gui/qt/resources/pokerth.qrc index 5c8c2b5e..b7170b45 100644 --- a/src/gui/qt/resources/pokerth.qrc +++ b/src/gui/qt/resources/pokerth.qrc @@ -60,6 +60,7 @@ tab-new-background.png loader.gif text-x-log.png + spectator.png cflags/ad.png diff --git a/src/gui/qt/resources/pokerth_android.qrc b/src/gui/qt/resources/pokerth_android.qrc index 3feaea9c..861af7ea 100644 --- a/src/gui/qt/resources/pokerth_android.qrc +++ b/src/gui/qt/resources/pokerth_android.qrc @@ -60,6 +60,7 @@ tab-new-background.png tab-close.png text-x-log.png + spectator.png cflags/ad.png