implement spectator display on the table to check if spectators watching the current game (#196)

This commit is contained in:
doitux
2013-09-30 10:23:51 +02:00
parent 4f8028aa0b
commit 972ab5e2ee
8 changed files with 208 additions and 60 deletions
-20
View File
@@ -58,70 +58,50 @@ void ServerGuiWrapper::setSession(boost::shared_ptr<Session> 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*/) {}
@@ -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;
}
+155 -29
View File
@@ -2235,7 +2235,16 @@ p, li { white-space: pre-wrap; }
<string notr="true">QGroupBox {border-style:none;}</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
@@ -2306,15 +2315,24 @@ p, li { white-space: pre-wrap; }
</size>
</property>
<layout class="QGridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>3</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_gameNumber">
<property name="alignment">
@@ -2556,15 +2574,24 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<layout class="QGridLayout" name="grid2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>3</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QLabel" name="textLabel_Sets">
<property name="alignment">
@@ -3532,7 +3559,16 @@ p, li { white-space: pre-wrap; }
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -3582,7 +3618,16 @@ p, li { white-space: pre-wrap; }
</size>
</property>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item row="0" column="0">
@@ -3598,7 +3643,16 @@ p, li { white-space: pre-wrap; }
<string>Hands</string>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
@@ -3618,7 +3672,16 @@ p, li { white-space: pre-wrap; }
<string>Chat</string>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
@@ -3650,15 +3713,24 @@ p, li { white-space: pre-wrap; }
<string>Kick</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_100">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<property name="margin">
<number>5</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
@@ -3790,12 +3862,21 @@ p, li { white-space: pre-wrap; }
<string>Player info</string>
</attribute>
<layout class="QGridLayout" name="gridLayout4">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>3</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QPlainTextEdit" name="textEdit_tipInput">
<property name="focusPolicy">
@@ -3868,15 +3949,24 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="1" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
@@ -4026,7 +4116,7 @@ p, li { white-space: pre-wrap; }
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<width>0</width>
<height>0</height>
</size>
</property>
@@ -4039,7 +4129,7 @@ p, li { white-space: pre-wrap; }
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<width>0</width>
<height>0</height>
</size>
</property>
@@ -4069,7 +4159,16 @@ p, li { white-space: pre-wrap; }
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -4119,15 +4218,24 @@ p, li { white-space: pre-wrap; }
</size>
</property>
<layout class="QGridLayout">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<property name="horizontalSpacing">
<number>1</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="margin">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="MyRightTabWidget" name="tabWidget_Right">
<property name="focusPolicy">
@@ -4141,7 +4249,16 @@ p, li { white-space: pre-wrap; }
<string>Log</string>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
@@ -4251,7 +4368,16 @@ p, li { white-space: pre-wrap; }
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -4463,7 +4589,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>1024</width>
<height>26</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuView">
+45 -2
View File
@@ -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("<b>"+tr("Spectators")+":</b><br>");
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())+"<br>");
++i;
}
spectatorList.remove(spectatorList.size()-4,4);
spectatorIcon->setToolTip(spectatorList);
}
else {
spectatorIcon->setToolTip("");
spectatorIcon->clear();
}
}
+4
View File
@@ -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;
+2
View File
@@ -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);
+1
View File
@@ -60,6 +60,7 @@
<file>tab-new-background.png</file>
<file>loader.gif</file>
<file>text-x-log.png</file>
<file>spectator.png</file>
</qresource>
<qresource prefix="/cflags">
<file>cflags/ad.png</file>
+1
View File
@@ -60,6 +60,7 @@
<file>tab-new-background.png</file>
<file>tab-close.png</file>
<file>text-x-log.png</file>
<file>spectator.png</file>
</qresource>
<qresource prefix="/cflags">
<file>cflags/ad.png</file>