Add stay on table animation for inactive network players which doent leave the table. some vote kick fixes.

This commit is contained in:
doitux
2009-04-22 22:32:45 +00:00
parent a75abcbb6a
commit c9615e264c
16 changed files with 262 additions and 80 deletions
+4 -2
View File
@@ -193,7 +193,8 @@ HEADERS += src/game.h \
src/gui/qt/gametable/mychancelabel.h \ src/gui/qt/gametable/mychancelabel.h \
src/gui/qt/serverlistdialog/serverlistdialogimpl.h \ src/gui/qt/serverlistdialog/serverlistdialogimpl.h \
src/gui/qt/gametable/mymenubar.h \ src/gui/qt/gametable/mymenubar.h \
src/gui/qt/gametable/mytimeoutlabel.h src/gui/qt/gametable/mytimeoutlabel.h \
src/gui/qt/gametable/mynamelabel.h
FORMS += src/gui/qt/gametable.ui \ FORMS += src/gui/qt/gametable.ui \
src/gui/qt/aboutpokerth.ui \ src/gui/qt/aboutpokerth.ui \
src/gui/qt/connecttoserverdialog.ui \ src/gui/qt/connecttoserverdialog.ui \
@@ -256,7 +257,8 @@ SOURCES += src/pokerth.cpp \
src/gui/qt/gametable/mychancelabel.cpp \ src/gui/qt/gametable/mychancelabel.cpp \
src/gui/qt/serverlistdialog/serverlistdialogimpl.cpp \ src/gui/qt/serverlistdialog/serverlistdialogimpl.cpp \
src/gui/qt/gametable/mymenubar.cpp \ src/gui/qt/gametable/mymenubar.cpp \
src/gui/qt/gametable/mytimeoutlabel.cpp src/gui/qt/gametable/mytimeoutlabel.cpp \
src/gui/qt/gametable/mynamelabel.cpp
TRANSLATIONS = ts/pokerth_bg.ts \ TRANSLATIONS = ts/pokerth_bg.ts \
ts/pokerth_de.ts \ ts/pokerth_de.ts \
ts/pokerth_dk.ts \ ts/pokerth_dk.ts \
+1 -1
View File
@@ -850,7 +850,7 @@ static const RoundData FlopValues[] =
#define NUM_FLOP_VALUES (sizeof(FlopValues)/sizeof(RoundData)) #define NUM_FLOP_VALUES (sizeof(FlopValues)/sizeof(RoundData))
LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
: PlayerInterface(), myConfig(c), currentHand(0), currentBoard(b), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), lastMoneyWon(0), sBluff(0), sBluffStatus(0) : PlayerInterface(), myConfig(c), currentHand(0), currentBoard(b), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(1), myTurn(0), myRoundStartCash(0), lastMoneyWon(0), sBluff(0), sBluffStatus(0)
{ {
// !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!! // !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!
+4
View File
@@ -77,6 +77,9 @@ public:
void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; } void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; }
bool getMyActiveStatus() const { return myActiveStatus; } bool getMyActiveStatus() const { return myActiveStatus; }
void setMyStayOnTableStatus(bool theValue) { myStayOnTableStatus = theValue; }
bool getMyStayOnTableStatus() const { return myStayOnTableStatus; }
void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; } void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; }
void getMyCards(int* theValue) const { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; } void getMyCards(int* theValue) const { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; }
@@ -210,6 +213,7 @@ private:
int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin
int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big
bool myActiveStatus; // 0 = inactive, 1 = active bool myActiveStatus; // 0 = inactive, 1 = active
bool myStayOnTableStatus; // 0 = left, 1 = stay
bool myTurn; // 0 = no, 1 = yes bool myTurn; // 0 = no, 1 = yes
bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped, bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
int myRoundStartCash; int myRoundStartCash;
+15 -1
View File
@@ -23,7 +23,7 @@ using namespace std;
ClientPlayer::ClientPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) ClientPlayer::ClientPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
: PlayerInterface(), myConfig(c), currentHand(0), currentBoard(b), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), sBluff(0), sBluffStatus(0) : PlayerInterface(), myConfig(c), currentHand(0), currentBoard(b), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(1), myTurn(0), myRoundStartCash(0), sBluff(0), sBluffStatus(0)
{ {
} }
@@ -206,6 +206,20 @@ ClientPlayer::getMyActiveStatus() const
return myActiveStatus; return myActiveStatus;
} }
void
ClientPlayer::setMyStayOnTableStatus(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myStayOnTableStatus = theValue;
}
bool
ClientPlayer::getMyStayOnTableStatus() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myStayOnTableStatus;
}
void void
ClientPlayer::setMyCards(int* theValue) ClientPlayer::setMyCards(int* theValue)
{ {
+4
View File
@@ -71,6 +71,9 @@ public:
void setMyActiveStatus(bool theValue); void setMyActiveStatus(bool theValue);
bool getMyActiveStatus() const; bool getMyActiveStatus() const;
void setMyStayOnTableStatus(bool theValue);
bool getMyStayOnTableStatus() const;
void setMyCards(int* theValue); void setMyCards(int* theValue);
void getMyCards(int* theValue) const; void getMyCards(int* theValue) const;
@@ -163,6 +166,7 @@ private:
int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin
int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big
bool myActiveStatus; // 0 = inactive, 1 = active bool myActiveStatus; // 0 = inactive, 1 = active
bool myStayOnTableStatus; // 0 = left, 1 = stay
bool myTurn; // 0 = no, 1 = yes bool myTurn; // 0 = no, 1 = yes
bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped, bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
int myRoundStartCash; int myRoundStartCash;
+3
View File
@@ -68,6 +68,9 @@ public:
virtual void setMyActiveStatus(bool theValue) =0; virtual void setMyActiveStatus(bool theValue) =0;
virtual bool getMyActiveStatus() const =0; virtual bool getMyActiveStatus() const =0;
virtual void setMyStayOnTableStatus(bool theValue) =0;
virtual bool getMyStayOnTableStatus() const =0;
virtual void setMyCards(int* theValue) =0; virtual void setMyCards(int* theValue) =0;
virtual void getMyCards(int* theValue) const =0; virtual void getMyCards(int* theValue) const =0;
-4
View File
@@ -104,7 +104,6 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
} }
(*runningPlayerList) = (*activePlayerList); (*runningPlayerList) = (*activePlayerList);
} }
currentBoard->setPlayerLists(seatsList, activePlayerList, runningPlayerList); currentBoard->setPlayerLists(seatsList, activePlayerList, runningPlayerList);
@@ -191,13 +190,10 @@ void Game::initHand()
dealerPosition = (*it_c)->getMyUniqueID(); dealerPosition = (*it_c)->getMyUniqueID();
break; break;
} }
} }
if(!nextDealerFound) { if(!nextDealerFound) {
throw LocalException(__FILE__, __LINE__, ERR_NEXT_DEALER_NOT_FOUND); throw LocalException(__FILE__, __LINE__, ERR_NEXT_DEALER_NOT_FOUND);
} }
} }
void Game::startHand() void Game::startHand()
+1 -7
View File
@@ -55,11 +55,10 @@ public:
virtual void refreshGameLabels(GameState state) const=0; virtual void refreshGameLabels(GameState state) const=0;
virtual void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const=0; virtual void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const=0;
virtual void waitForGuiUpdateDone() const=0; virtual void waitForGuiUpdateDone() const=0;
// Karten-Funktionen
virtual void dealBeRoCards(int) =0; virtual void dealBeRoCards(int) =0;
// // Karten-Funktionen
virtual void dealHoleCards()=0; virtual void dealHoleCards()=0;
virtual void dealFlopCards()=0; virtual void dealFlopCards()=0;
virtual void dealTurnCard()=0; virtual void dealTurnCard()=0;
@@ -83,14 +82,9 @@ public:
virtual void postRiverAnimation1()=0; virtual void postRiverAnimation1()=0;
virtual void postRiverRunAnimation1()=0; virtual void postRiverRunAnimation1()=0;
// virtual void postRiverAnimation2()=0;
virtual void flipHolecardsAllIn()=0; virtual void flipHolecardsAllIn()=0;
// virtual void startNewHand() const=0;
virtual void nextRoundCleanGui()=0; virtual void nextRoundCleanGui()=0;
//
// virtual void userWidgetsBackgroudColor() const=0;
// virtual void timerBlockerFalse() const=0;
virtual void meInAction()=0; virtual void meInAction()=0;
virtual void updateMyButtonsState()=0; virtual void updateMyButtonsState()=0;
virtual void disableMyButtons()=0; virtual void disableMyButtons()=0;
+15 -10
View File
@@ -108,7 +108,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName3"> <widget class="MyNameLabel" name="label_PlayerName3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -326,7 +326,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName2"> <widget class="MyNameLabel" name="label_PlayerName2">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -551,7 +551,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName4"> <widget class="MyNameLabel" name="label_PlayerName4">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -756,7 +756,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName5"> <widget class="MyNameLabel" name="label_PlayerName5">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -961,7 +961,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName6"> <widget class="MyNameLabel" name="label_PlayerName6">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -1186,7 +1186,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName7"> <widget class="MyNameLabel" name="label_PlayerName7">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -1404,7 +1404,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName8"> <widget class="MyNameLabel" name="label_PlayerName8">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -2061,7 +2061,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName1"> <widget class="MyNameLabel" name="label_PlayerName1">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -2266,7 +2266,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName0"> <widget class="MyNameLabel" name="label_PlayerName0">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -2471,7 +2471,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_PlayerName9"> <widget class="MyNameLabel" name="label_PlayerName9">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
@@ -3742,6 +3742,11 @@
<extends>QLabel</extends> <extends>QLabel</extends>
<header>mytimeoutlabel.h</header> <header>mytimeoutlabel.h</header>
</customwidget> </customwidget>
<customwidget>
<class>MyNameLabel</class>
<extends>QLabel</extends>
<header>mynamelabel.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="resources/pokerth.qrc"/> <include location="resources/pokerth.qrc"/>
+46 -1
View File
@@ -508,6 +508,8 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
connect(this, SIGNAL(signalChangeVoteOnKickButtonsState(bool)), this, SLOT(changeVoteOnKickButtonsState(bool))); connect(this, SIGNAL(signalChangeVoteOnKickButtonsState(bool)), this, SLOT(changeVoteOnKickButtonsState(bool)));
connect(this, SIGNAL(signalEndVoteOnKick()), this, SLOT(endVoteOnKick())); connect(this, SIGNAL(signalEndVoteOnKick()), this, SLOT(endVoteOnKick()));
connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned)), this, SLOT(netClientPlayerLeft(unsigned)));
} }
gameTableImpl::~gameTableImpl() { gameTableImpl::~gameTableImpl() {
@@ -772,6 +774,7 @@ void gameTableImpl::refreshButton() {
void gameTableImpl::refreshPlayerName() { void gameTableImpl::refreshPlayerName() {
if(myStartWindow->getSession()->getCurrentGame()) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
@@ -780,14 +783,26 @@ void gameTableImpl::refreshPlayerName() {
playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str())); playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str()));
} else { } else {
if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK)) {
if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) {
playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str()), TRUE);
}
else {
playerNameLabelArray[(*it_c)->getMyID()]->setText(""); playerNameLabelArray[(*it_c)->getMyID()]->setText("");
}
}
else {
playerNameLabelArray[(*it_c)->getMyID()]->setText("");
}
}
} }
} }
} }
void gameTableImpl::refreshPlayerAvatar() { void gameTableImpl::refreshPlayerAvatar() {
if(myStartWindow->getSession()->getCurrentGame()) {
QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png"));
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
@@ -803,10 +818,26 @@ void gameTableImpl::refreshPlayerAvatar() {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str())))); playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))));
} }
} }
else {
if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK)) {
if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) {
if((*it_c)->getMyAvatar() == "" || !QFile::QFile(QString::fromUtf8((*it_c)->getMyAvatar().c_str())).exists()) {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())), TRUE);
}
else {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))), TRUE);
}
}
else { else {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix);
} }
} }
else {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix);
}
}
}
}
} }
void gameTableImpl::setPlayerAvatar(int myID, QString myAvatar) { void gameTableImpl::setPlayerAvatar(int myID, QString myAvatar) {
@@ -3323,3 +3354,17 @@ void gameTableImpl::restoreGameTableGeometry()
} }
} }
} }
void gameTableImpl::netClientPlayerLeft(unsigned playerId) {
assert(myStartWindow->getSession()->getCurrentGame());
if (myStartWindow->getSession()->isNetworkClientRunning()) {
boost::shared_ptr<PlayerInterface> tmpPlayer = myStartWindow->getSession()->getCurrentGame()->getPlayerByUniqueId(playerId);
if (tmpPlayer.get()) {
tmpPlayer->setMyStayOnTableStatus(0);
refreshPlayerAvatar();
refreshPlayerName();
}
}
}
+4 -3
View File
@@ -87,7 +87,6 @@ signals:
void signalRefreshGameLabels(int); void signalRefreshGameLabels(int);
void signalSetPlayerAvatar(int, QString); void signalSetPlayerAvatar(int, QString);
void signalGuiUpdateDone(); void signalGuiUpdateDone();
void signalMeInAction(); void signalMeInAction();
@@ -126,6 +125,8 @@ signals:
void signalChangeVoteOnKickButtonsState(bool showHide); void signalChangeVoteOnKickButtonsState(bool showHide);
void signalEndVoteOnKick(); void signalEndVoteOnKick();
void signalNetClientPlayerLeft(unsigned playerId);
public slots: public slots:
void initGui(int speed); void initGui(int speed);
@@ -301,6 +302,7 @@ public slots:
void saveGameTableGeometry(); void saveGameTableGeometry();
void restoreGameTableGeometry(); void restoreGameTableGeometry();
void netClientPlayerLeft(unsigned playerId);
private: private:
boost::shared_ptr<GuiInterface> myServerGuiInterface; boost::shared_ptr<GuiInterface> myServerGuiInterface;
@@ -354,7 +356,7 @@ private:
QLabel *cashTopLabelArray[MAX_NUMBER_OF_PLAYERS]; QLabel *cashTopLabelArray[MAX_NUMBER_OF_PLAYERS];
MySetLabel *setLabelArray[MAX_NUMBER_OF_PLAYERS]; MySetLabel *setLabelArray[MAX_NUMBER_OF_PLAYERS];
QLabel *actionLabelArray[MAX_NUMBER_OF_PLAYERS]; QLabel *actionLabelArray[MAX_NUMBER_OF_PLAYERS];
QLabel *playerNameLabelArray[MAX_NUMBER_OF_PLAYERS]; MyNameLabel *playerNameLabelArray[MAX_NUMBER_OF_PLAYERS];
MyAvatarLabel *playerAvatarLabelArray[MAX_NUMBER_OF_PLAYERS]; MyAvatarLabel *playerAvatarLabelArray[MAX_NUMBER_OF_PLAYERS];
MyTimeoutLabel *timeoutLabelArray[MAX_NUMBER_OF_PLAYERS]; MyTimeoutLabel *timeoutLabelArray[MAX_NUMBER_OF_PLAYERS];
@@ -371,7 +373,6 @@ private:
SDLPlayer *mySDLPlayer; SDLPlayer *mySDLPlayer;
QString myAppDataPath; QString myAppDataPath;
int distributePotAnimCounter; int distributePotAnimCounter;
int playingMode; int playingMode;
+32 -3
View File
@@ -9,7 +9,7 @@
// Copyright: See COPYING file that comes with this distribution // Copyright: See COPYING file that comes with this distribution
// //
// //
#include "mysetlabel.h" #include "myavatarlabel.h"
#include "gametableimpl.h" #include "gametableimpl.h"
#include "session.h" #include "session.h"
@@ -19,7 +19,7 @@
using namespace std; using namespace std;
MyAvatarLabel::MyAvatarLabel(QGroupBox* parent) MyAvatarLabel::MyAvatarLabel(QGroupBox* parent)
: QLabel(parent), voteRunning(FALSE) : QLabel(parent), voteRunning(FALSE), transparent(FALSE)
{ {
myContextMenu = new QMenu; myContextMenu = new QMenu;
@@ -36,6 +36,12 @@ MyAvatarLabel::~MyAvatarLabel()
void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) { void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
assert(myW->getSession()->getCurrentGame());
if (myW->getSession()->isNetworkClientRunning()) {
PlayerListIterator it = myW->getSession()->getCurrentGame()->getSeatsList()->begin();
//only active players are allowed to start a vote
if((*it)->getMyActiveStatus()) {
Game *currentGame = myW->getSession()->getCurrentGame(); Game *currentGame = myW->getSession()->getCurrentGame();
@@ -50,12 +56,15 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
int i=0; int i=0;
for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) { for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) {
if(myContextMenuEnabled && myId != 0 && myId == i && (*it_c)->getMyActiveStatus() ) //also inactive player which stays on table can be voted to kick
if(myContextMenuEnabled && myId != 0 && myId == i && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER && ( (*it_c)->getMyActiveStatus() || (*it_c)->getMyStayOnTableStatus() ) )
showContextMenu(event->globalPos()); showContextMenu(event->globalPos());
i++; i++;
} }
} }
}
}
void MyAvatarLabel::showContextMenu(const QPoint &pos) { void MyAvatarLabel::showContextMenu(const QPoint &pos) {
@@ -76,3 +85,23 @@ void MyAvatarLabel::setVoteOnKickContextMenuEnabled(bool b)
{ {
action_VoteForKick->setEnabled(b); action_VoteForKick->setEnabled(b);
} }
void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans) {
myPixmap = pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
transparent = trans;
update();
}
void MyAvatarLabel::paintEvent(QPaintEvent*) {
QPainter painter(this);
if(transparent)
painter.setOpacity(0.4);
else
painter.setOpacity(1.0);
painter.drawPixmap(0,0,myPixmap);
}
+5 -1
View File
@@ -36,18 +36,22 @@ public slots:
void sendTriggerVoteOnKickSignal(); void sendTriggerVoteOnKickSignal();
void setEnabledContextMenu(bool); void setEnabledContextMenu(bool);
void setVoteOnKickContextMenuEnabled(bool); void setVoteOnKickContextMenuEnabled(bool);
void setVoteRunning ( bool theValue ) { voteRunning = theValue; } void setVoteRunning ( bool theValue ) { voteRunning = theValue; }
void setPixmap ( const QPixmap &, const bool = FALSE);
void paintEvent(QPaintEvent*);
private: private:
gameTableImpl *myW; gameTableImpl *myW;
QMenu *myContextMenu; QMenu *myContextMenu;
QAction *action_VoteForKick; QAction *action_VoteForKick;
QPixmap myPixmap;
int myId; int myId;
bool myContextMenuEnabled; bool myContextMenuEnabled;
bool voteRunning; bool voteRunning;
bool transparent;
}; };
#endif #endif
+42
View File
@@ -0,0 +1,42 @@
//
// C++ Implementation: mycardspixmaplabel
//
// Description:
//
//
// Author: FThauer FHammer <f.thauer@web.de>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "mynamelabel.h"
MyNameLabel::MyNameLabel(QGroupBox* parent)
: QLabel(parent), transparent(FALSE)
{
}
MyNameLabel::~MyNameLabel()
{
}
void MyNameLabel::setText ( const QString &text, const bool trans) {
myText = text;
transparent = trans;
update();
}
void MyNameLabel::paintEvent(QPaintEvent*) {
QPainter painter(this);
if(transparent)
painter.setOpacity(0.4);
else
painter.setOpacity(1.0);
painter.drawText(0,11,myText);
}
+38
View File
@@ -0,0 +1,38 @@
//
// C++ Interface: mycardspixmaplabel
//
// Description:
//
//
// Author: FThauer FHammer <f.thauer@web.de>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef MYNAMELABEL_H
#define MYNAMELABEL_H
#include <iostream>
#include <QtGui>
#include <QtCore>
class MyNameLabel : public QLabel
{
Q_OBJECT
public:
MyNameLabel(QGroupBox*);
~MyNameLabel();
public slots:
void setText ( const QString &, const bool = FALSE);
void paintEvent(QPaintEvent*);
private:
QString myText;
bool transparent;
};
#endif
+1
View File
@@ -144,6 +144,7 @@ void GuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &play
{ {
QString tmpName(QString::fromUtf8(playerName.c_str())); QString tmpName(QString::fromUtf8(playerName.c_str()));
myStartWindow->signalNetClientPlayerLeft(playerId, tmpName); myStartWindow->signalNetClientPlayerLeft(playerId, tmpName);
myW->signalNetClientPlayerLeft(playerId);
if (!playerName.empty() && playerName[0] != '#') if (!playerName.empty() && playerName[0] != '#')
myLog->signalLogPlayerLeftMsg(tmpName, removeReason == NTF_NET_REMOVED_KICKED); myLog->signalLogPlayerLeftMsg(tmpName, removeReason == NTF_NET_REMOVED_KICKED);
} }