From 15d934e5b8a39019737200bce743a955720327ae Mon Sep 17 00:00:00 2001 From: doitux Date: Sun, 7 Dec 2008 21:47:53 +0000 Subject: [PATCH] show votekick starter nick, disable kick contextmenu for only 2 players --- src/gui/generic/serverguiwrapper.cpp | 2 +- src/gui/generic/serverguiwrapper.h | 2 +- src/gui/guiinterface.h | 2 +- src/gui/qt/gametable.ui | 85 ++++++++++++++++++-------- src/gui/qt/gametable/gametableimpl.cpp | 9 ++- src/gui/qt/gametable/gametableimpl.h | 4 +- src/gui/qt/gametable/myavatarlabel.cpp | 9 ++- src/gui/qt/guiwrapper.cpp | 2 +- src/gui/qt/guiwrapper.h | 2 +- src/net/common/clientthread.cpp | 2 +- 10 files changed, 84 insertions(+), 35 deletions(-) diff --git a/src/gui/generic/serverguiwrapper.cpp b/src/gui/generic/serverguiwrapper.cpp index cb25da6e..19460cf6 100644 --- a/src/gui/generic/serverguiwrapper.cpp +++ b/src/gui/generic/serverguiwrapper.cpp @@ -101,7 +101,7 @@ void ServerGuiWrapper::updateMyButtonsState() {} void ServerGuiWrapper::startTimeoutAnimation(int /*playerNum*/, int /*timeoutSec*/) {} void ServerGuiWrapper::stopTimeoutAnimation(int /*playerNum*/) {} -void ServerGuiWrapper::startVoteOnKick(unsigned /*playerId*/, int /*timeoutSec*/, int /*numVotesNeededToKick*/) {} +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() {} diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index b7b6528e..84ab5028 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -88,7 +88,7 @@ public: void startTimeoutAnimation(int playerNum, int timeoutSec); void stopTimeoutAnimation(int playerNum); - void startVoteOnKick(unsigned playerId, int timeoutSec, int numVotesNeededToKick); + void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); void changeVoteOnKickButtonsState(bool showHide); void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); void endVoteOnKick(); diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 16c11420..4e202afd 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -97,7 +97,7 @@ public: virtual void startTimeoutAnimation(int playerNum, int timeoutSec) =0; virtual void stopTimeoutAnimation(int playerNum) =0; - virtual void startVoteOnKick(unsigned playerId, int timeoutSec, int numVotesNeededToKick) =0; + virtual void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) =0; virtual void changeVoteOnKickButtonsState(bool showHide) =0; virtual void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) =0; virtual void endVoteOnKick() =0; diff --git a/src/gui/qt/gametable.ui b/src/gui/qt/gametable.ui index ac657c03..58fe68ab 100644 --- a/src/gui/qt/gametable.ui +++ b/src/gui/qt/gametable.ui @@ -1780,28 +1780,65 @@ Kick - + - + + + 0 + - - - Vote Timeout: + + + 5 - + + + + Vote started by: + + + + + + + + 0 + 0 + + + + + + + + - - - - 0 - 0 - + + + 5 - - - - + + + + Vote Timeout: + + + + + + + + 0 + 0 + + + + + + + + @@ -1836,6 +1873,13 @@ + + + + + + + @@ -1849,13 +1893,6 @@ - - - - - - - @@ -2976,7 +3013,7 @@ 0 0 1000 - 22 + 28 diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index b4f8cc7a..e5631d3c 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -401,6 +401,8 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) label_kickVoteTimeout->setStyleSheet("QLabel { color: #99D500;}"); label_kickUser->setStyleSheet("QLabel { color: #99D500;}"); label_votesMonitor->setStyleSheet("QLabel { color: #99D500;}"); + label_voteStarterNick->setStyleSheet("QLabel { color: #99D500;}"); + label_votestartedby->setStyleSheet("QLabel { color: #99D500;}"); statusbar->setStyleSheet(" QStatusBar { "+ font1String +" font-size: 12px; color: #B7FF00; }"); @@ -589,7 +591,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalPostRiverRunAnimation1()), this, SLOT(postRiverRunAnimation1())); connect(this, SIGNAL(signalFlipHolecardsAllIn()), this, SLOT(flipHolecardsAllIn())); connect(this, SIGNAL(signalNextRoundCleanGui()), this, SLOT(nextRoundCleanGui())); - connect(this, SIGNAL(signalStartVoteOnKick(unsigned, int, int)), this, SLOT(startVoteOnKick(unsigned, int, int))); + 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())); @@ -3114,7 +3116,7 @@ void gameTableImpl::triggerVoteOnKick(int id) { } } -void gameTableImpl::startVoteOnKick(unsigned playerId, int timeoutSec, int numVotesNeededToKick) +void gameTableImpl::startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) { if(tabWidget_Left->widget(2) != tab_Kick) tabWidget_Left->insertTab(2, tab_Kick, QString(tr("Kick"))); @@ -3127,6 +3129,9 @@ void gameTableImpl::startVoteOnKick(unsigned playerId, int timeoutSec, int numVo playerAboutToBeKickedId = playerId; refreshVotesMonitor(1, numVotesNeededToKick); + PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(voteStarterPlayerId)); + label_voteStarterNick->setText(QString::fromUtf8(info.playerName.c_str())); + startVoteOnKickTimeout(); int i; diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index f2fc9e78..be0ce908 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -119,7 +119,7 @@ signals: void signalNextRoundCleanGui(); - void signalStartVoteOnKick(unsigned playerId, int timeoutSec, int numVotesNeededToKick); + void signalStartVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); void signalChangeVoteOnKickButtonsState(bool showHide); void signalEndVoteOnKick(); @@ -283,7 +283,7 @@ public slots: void showMaximized (); void closeGameTable(); - void startVoteOnKick(unsigned playerId, int timeoutSec, int numVotesNeededToKick); + void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); void changeVoteOnKickButtonsState(bool showHide); void endVoteOnKick(); void voteOnKickYes(); diff --git a/src/gui/qt/gametable/myavatarlabel.cpp b/src/gui/qt/gametable/myavatarlabel.cpp index 8194359c..aa93d963 100644 --- a/src/gui/qt/gametable/myavatarlabel.cpp +++ b/src/gui/qt/gametable/myavatarlabel.cpp @@ -38,8 +38,15 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) { Game *currentGame = myW->getSession()->getCurrentGame(); - + PlayerListConstIterator it_c; + int activePlayerCounter=0; + for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) { + if((*it_c)->getMyActiveStatus()) activePlayerCounter++; + } + if(activePlayerCounter > 2) setVoteOnKickContextMenuEnabled(TRUE); + else setVoteOnKickContextMenuEnabled(FALSE); + int i=0; for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) { diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 27833c23..ffec492d 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -107,7 +107,7 @@ void GuiWrapper::disableMyButtons() { myW->signalDisableMyButtons(); } void GuiWrapper::startTimeoutAnimation(int playerNum, int timeoutSec) { myW->signalStartTimeoutAnimation(playerNum, timeoutSec); } void GuiWrapper::stopTimeoutAnimation(int playerNum) { myW->signalStopTimeoutAnimation(playerNum); } -void GuiWrapper::startVoteOnKick(unsigned playerId, int timeoutSec, int numVotesNeededToKick) { myW->signalStartVoteOnKick(playerId, timeoutSec, numVotesNeededToKick); } +void GuiWrapper::startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) { myW->signalStartVoteOnKick(playerId, voteStarterPlayerId, timeoutSec, numVotesNeededToKick); } void GuiWrapper::changeVoteOnKickButtonsState(bool showHide) { myW->signalChangeVoteOnKickButtonsState(showHide); } void GuiWrapper::refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) { myW->refreshVotesMonitor(currentVotes, numVotesNeededToKick); } void GuiWrapper::endVoteOnKick() { myW->signalEndVoteOnKick(); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 9d3f8ce9..524cead5 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -96,7 +96,7 @@ public: void startTimeoutAnimation(int playerNum, int timeoutSec); void stopTimeoutAnimation(int playerNum); - void startVoteOnKick(unsigned playerId, int timeoutSec, int numVotesNeededToKick); + void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); void changeVoteOnKickButtonsState(bool showHide); void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); void endVoteOnKick(); diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index e9dbc2a0..dd00377d 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -1029,7 +1029,7 @@ ClientThread::StartPetition(unsigned petitionId, unsigned proposingPlayerId, uns boost::mutex::scoped_lock lock(m_curPetitionIdMutex); m_curPetitionId = petitionId; } - GetGui().startVoteOnKick(kickPlayerId, timeoutSec, numVotesToKick); + GetGui().startVoteOnKick(kickPlayerId, proposingPlayerId, timeoutSec, numVotesToKick); if (GetGuiPlayerId() != kickPlayerId && GetGuiPlayerId() != proposingPlayerId) {