Add stay on table animation for inactive network players which doent leave the table. some vote kick fixes.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user