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
+15 -10
View File
@@ -108,7 +108,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName3">
<widget class="MyNameLabel" name="label_PlayerName3">
<property name="geometry">
<rect>
<x>70</x>
@@ -326,7 +326,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName2">
<widget class="MyNameLabel" name="label_PlayerName2">
<property name="geometry">
<rect>
<x>70</x>
@@ -551,7 +551,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName4">
<widget class="MyNameLabel" name="label_PlayerName4">
<property name="geometry">
<rect>
<x>70</x>
@@ -756,7 +756,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName5">
<widget class="MyNameLabel" name="label_PlayerName5">
<property name="geometry">
<rect>
<x>70</x>
@@ -961,7 +961,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName6">
<widget class="MyNameLabel" name="label_PlayerName6">
<property name="geometry">
<rect>
<x>70</x>
@@ -1186,7 +1186,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName7">
<widget class="MyNameLabel" name="label_PlayerName7">
<property name="geometry">
<rect>
<x>70</x>
@@ -1404,7 +1404,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName8">
<widget class="MyNameLabel" name="label_PlayerName8">
<property name="geometry">
<rect>
<x>70</x>
@@ -2061,7 +2061,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName1">
<widget class="MyNameLabel" name="label_PlayerName1">
<property name="geometry">
<rect>
<x>70</x>
@@ -2266,7 +2266,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName0">
<widget class="MyNameLabel" name="label_PlayerName0">
<property name="geometry">
<rect>
<x>70</x>
@@ -2471,7 +2471,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_PlayerName9">
<widget class="MyNameLabel" name="label_PlayerName9">
<property name="geometry">
<rect>
<x>70</x>
@@ -3742,6 +3742,11 @@
<extends>QLabel</extends>
<header>mytimeoutlabel.h</header>
</customwidget>
<customwidget>
<class>MyNameLabel</class>
<extends>QLabel</extends>
<header>mynamelabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources/pokerth.qrc"/>
+72 -27
View File
@@ -508,6 +508,8 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
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)));
}
gameTableImpl::~gameTableImpl() {
@@ -772,41 +774,70 @@ void gameTableImpl::refreshButton() {
void gameTableImpl::refreshPlayerName() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
if(myStartWindow->getSession()->getCurrentGame()) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str()));
} else {
playerNameLabelArray[(*it_c)->getMyID()]->setText("");
}
}
PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().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) {
playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str()), TRUE);
}
else {
playerNameLabelArray[(*it_c)->getMyID()]->setText("");
}
}
else {
playerNameLabelArray[(*it_c)->getMyID()]->setText("");
}
}
}
}
}
void gameTableImpl::refreshPlayerAvatar() {
QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png"));
if(myStartWindow->getSession()->getCurrentGame()) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png"));
PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
if((*it_c)->getMyAvatar() == "" || !QFile::QFile(QString::fromUtf8((*it_c)->getMyAvatar().c_str())).exists()) {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())));
}
else {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))));
}
}
else {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix);
}
}
PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
if((*it_c)->getMyAvatar() == "" || !QFile::QFile(QString::fromUtf8((*it_c)->getMyAvatar().c_str())).exists()) {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())));
}
else {
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 {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix);
}
}
else {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix);
}
}
}
}
}
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 signalSetPlayerAvatar(int, QString);
void signalGuiUpdateDone();
void signalMeInAction();
@@ -126,6 +125,8 @@ signals:
void signalChangeVoteOnKickButtonsState(bool showHide);
void signalEndVoteOnKick();
void signalNetClientPlayerLeft(unsigned playerId);
public slots:
void initGui(int speed);
@@ -301,6 +302,7 @@ public slots:
void saveGameTableGeometry();
void restoreGameTableGeometry();
void netClientPlayerLeft(unsigned playerId);
private:
boost::shared_ptr<GuiInterface> myServerGuiInterface;
@@ -354,7 +356,7 @@ private:
QLabel *cashTopLabelArray[MAX_NUMBER_OF_PLAYERS];
MySetLabel *setLabelArray[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];
MyTimeoutLabel *timeoutLabelArray[MAX_NUMBER_OF_PLAYERS];
@@ -371,7 +373,6 @@ private:
SDLPlayer *mySDLPlayer;
QString myAppDataPath;
int distributePotAnimCounter;
int playingMode;
+49 -20
View File
@@ -9,7 +9,7 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#include "mysetlabel.h"
#include "myavatarlabel.h"
#include "gametableimpl.h"
#include "session.h"
@@ -19,7 +19,7 @@
using namespace std;
MyAvatarLabel::MyAvatarLabel(QGroupBox* parent)
: QLabel(parent), voteRunning(FALSE)
: QLabel(parent), voteRunning(FALSE), transparent(FALSE)
{
myContextMenu = new QMenu;
@@ -36,25 +36,34 @@ MyAvatarLabel::~MyAvatarLabel()
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 && !voteRunning ) setVoteOnKickContextMenuEnabled(TRUE);
else setVoteOnKickContextMenuEnabled(FALSE);
assert(myW->getSession()->getCurrentGame());
if (myW->getSession()->isNetworkClientRunning()) {
int i=0;
for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) {
if(myContextMenuEnabled && myId != 0 && myId == i && (*it_c)->getMyActiveStatus() )
showContextMenu(event->globalPos());
PlayerListIterator it = myW->getSession()->getCurrentGame()->getSeatsList()->begin();
//only active players are allowed to start a vote
if((*it)->getMyActiveStatus()) {
i++;
}
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 && !voteRunning ) setVoteOnKickContextMenuEnabled(TRUE);
else setVoteOnKickContextMenuEnabled(FALSE);
int i=0;
for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) {
//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());
i++;
}
}
}
}
void MyAvatarLabel::showContextMenu(const QPoint &pos) {
@@ -75,4 +84,24 @@ void MyAvatarLabel::setEnabledContextMenu(bool b)
void MyAvatarLabel::setVoteOnKickContextMenuEnabled(bool 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);
}
+6 -2
View File
@@ -36,18 +36,22 @@ public slots:
void sendTriggerVoteOnKickSignal();
void setEnabledContextMenu(bool);
void setVoteOnKickContextMenuEnabled(bool);
void setVoteRunning ( bool theValue ) { voteRunning = theValue; }
void setPixmap ( const QPixmap &, const bool = FALSE);
void paintEvent(QPaintEvent*);
private:
gameTableImpl *myW;
QMenu *myContextMenu;
QAction *action_VoteForKick;
QPixmap myPixmap;
int myId;
bool myContextMenuEnabled;
bool voteRunning;
bool transparent;
};
#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()));
myStartWindow->signalNetClientPlayerLeft(playerId, tmpName);
myW->signalNetClientPlayerLeft(playerId);
if (!playerName.empty() && playerName[0] != '#')
myLog->signalLogPlayerLeftMsg(tmpName, removeReason == NTF_NET_REMOVED_KICKED);
}