ingame chat is disbaled for guest, ignore context menu ingame
This commit is contained in:
@@ -3561,7 +3561,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>27</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuView">
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
using namespace std;
|
||||
|
||||
gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
|
||||
: QMainWindow(parent), myChat(NULL), myConfig(c), gameSpeed(0), myActionIsBet(0), myActionIsRaise(0), pushButtonBetRaiseIsChecked(FALSE), pushButtonCallCheckIsChecked(FALSE), pushButtonFoldIsChecked(FALSE), pushButtonAllInIsChecked(FALSE), myButtonsAreCheckable(FALSE), breakAfterCurrentHand(FALSE), currentGameOver(FALSE), betSliderChangedByInput(FALSE), myLastPreActionBetValue(0)
|
||||
: QMainWindow(parent), myChat(NULL), myConfig(c), gameSpeed(0), myActionIsBet(0), myActionIsRaise(0), pushButtonBetRaiseIsChecked(FALSE), pushButtonCallCheckIsChecked(FALSE), pushButtonFoldIsChecked(FALSE), pushButtonAllInIsChecked(FALSE), myButtonsAreCheckable(FALSE), breakAfterCurrentHand(FALSE), currentGameOver(FALSE), betSliderChangedByInput(FALSE), guestMode(FALSE), myLastPreActionBetValue(0)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -2867,6 +2867,12 @@ void gameTableImpl::networkGameModification() {
|
||||
|
||||
//restore saved windows geometry
|
||||
restoreGameTableGeometry();
|
||||
|
||||
if(myStartWindow->getSession()->getClientPlayerInfo(myStartWindow->getSession()->getClientUniquePlayerId()).isGuest) {
|
||||
guestUserMode();
|
||||
}
|
||||
else { registeredUserMode(); }
|
||||
|
||||
}
|
||||
|
||||
void gameTableImpl::mouseOverFlipCards(bool front) {
|
||||
@@ -3392,3 +3398,18 @@ void gameTableImpl::netClientPlayerLeft(unsigned playerId) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gameTableImpl::registeredUserMode()
|
||||
{
|
||||
lineEdit_ChatInput->clear();
|
||||
lineEdit_ChatInput->setEnabled(true);
|
||||
guestMode = false;
|
||||
}
|
||||
|
||||
|
||||
void gameTableImpl::guestUserMode()
|
||||
{
|
||||
lineEdit_ChatInput->setText("Chat is avaiable only for registered members");
|
||||
lineEdit_ChatInput->setDisabled(true);
|
||||
guestMode = true;
|
||||
}
|
||||
|
||||
@@ -59,14 +59,14 @@ public:
|
||||
~gameTableImpl();
|
||||
|
||||
boost::shared_ptr<Session> getSession();
|
||||
void setStartWindow(startWindowImpl* s) { myStartWindow = s; }
|
||||
|
||||
void setLog(Log* l) { myLog = l; }
|
||||
|
||||
SDLPlayer* getMySDLPlayer() const { return mySDLPlayer; }
|
||||
ChatTools* getMyChat() const { return myChat; }
|
||||
|
||||
ConfigFile* getMyConfig() const { return myConfig; }
|
||||
GameTableStyleReader* getMyGameTableStyle() const { return myGameTableStyle; }
|
||||
bool getGuestMode() const { return guestMode; }
|
||||
|
||||
void setStartWindow(startWindowImpl* s) { myStartWindow = s; }
|
||||
void setLog(Log* l) { myLog = l; }
|
||||
|
||||
void setSpeeds();
|
||||
|
||||
@@ -303,6 +303,9 @@ public slots:
|
||||
void restoreGameTableGeometry();
|
||||
|
||||
void netClientPlayerLeft(unsigned playerId);
|
||||
void registeredUserMode();
|
||||
void guestUserMode();
|
||||
|
||||
private:
|
||||
|
||||
boost::shared_ptr<GuiInterface> myServerGuiInterface;
|
||||
@@ -406,6 +409,7 @@ private:
|
||||
bool currentGameOver;
|
||||
bool flipHolecardsAllInAlreadyDone;
|
||||
bool betSliderChangedByInput;
|
||||
bool guestMode;
|
||||
|
||||
// statistic testing
|
||||
int statisticArray[15];
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "session.h"
|
||||
#include "playerinterface.h"
|
||||
#include "game.h"
|
||||
#include "mymessagedialogimpl.h"
|
||||
#include "chattools.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -23,10 +25,13 @@ MyAvatarLabel::MyAvatarLabel(QGroupBox* parent)
|
||||
{
|
||||
|
||||
myContextMenu = new QMenu;
|
||||
action_VoteForKick = new QAction(QIcon(":/gfx/list_remove_user.png"), tr("Start vote to kick this user"), myContextMenu);
|
||||
action_VoteForKick = new QAction(QIcon(":/gfx/list_remove_user.png"), tr("Start vote to kick this player"), myContextMenu);
|
||||
myContextMenu->addAction(action_VoteForKick);
|
||||
action_IgnorePlayer = new QAction(QIcon(":/gfx/im-ban-user.png"), tr("Ignore Player"), myContextMenu);
|
||||
myContextMenu->addAction(action_IgnorePlayer);
|
||||
|
||||
connect( action_VoteForKick, SIGNAL ( triggered() ), this, SLOT ( sendTriggerVoteOnKickSignal() ) );
|
||||
connect( action_IgnorePlayer, SIGNAL ( triggered() ), this, SLOT ( putPlayerOnIgnoreList() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +42,7 @@ MyAvatarLabel::~MyAvatarLabel()
|
||||
void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
|
||||
|
||||
assert(myW->getSession()->getCurrentGame());
|
||||
if (myW->getSession()->isNetworkClientRunning()) {
|
||||
if (myW->getSession()->isNetworkClientRunning() && !myW->getGuestMode()) {
|
||||
|
||||
PlayerListIterator it = myW->getSession()->getCurrentGame()->getSeatsList()->begin();
|
||||
//only active players are allowed to start a vote
|
||||
@@ -53,6 +58,17 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
|
||||
if(activePlayerCounter > 2 && !voteRunning ) setVoteOnKickContextMenuEnabled(TRUE);
|
||||
else setVoteOnKickContextMenuEnabled(FALSE);
|
||||
|
||||
action_IgnorePlayer->setEnabled(true);
|
||||
|
||||
int j=0;
|
||||
for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) {
|
||||
|
||||
if(myId == j && myW->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest) {
|
||||
action_IgnorePlayer->setDisabled(true);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
int i=0;
|
||||
for (it_c=currentGame->getSeatsList()->begin(); it_c!=currentGame->getSeatsList()->end(); it_c++) {
|
||||
|
||||
@@ -105,3 +121,40 @@ void MyAvatarLabel::paintEvent(QPaintEvent*) {
|
||||
painter.drawPixmap(0,0,myPixmap);
|
||||
}
|
||||
|
||||
bool MyAvatarLabel::playerIsOnIgnoreList(QString playerName) {
|
||||
|
||||
list<std::string> playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList");
|
||||
list<std::string>::iterator it1;
|
||||
for(it1= playerIgnoreList.begin(); it1 != playerIgnoreList.end(); it1++) {
|
||||
|
||||
if(playerName == QString::fromUtf8(it1->c_str())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MyAvatarLabel::putPlayerOnIgnoreList() {
|
||||
|
||||
QStringList list;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
for (it_c=myW->getSession()->getCurrentGame()->getSeatsList()->begin(); it_c!=myW->getSession()->getCurrentGame()->getSeatsList()->end(); it_c++) {
|
||||
list << QString::fromUtf8((*it_c)->getMyName().c_str());
|
||||
}
|
||||
|
||||
if(!playerIsOnIgnoreList(list.at(myId))) {
|
||||
|
||||
myMessageDialogImpl dialog(myW->getMyConfig(), this);
|
||||
if(dialog.exec(4, tr("You will no longer recieve chat messages or game invitations from this user.<br>Do you really want to put player <b>%1</b> on ignore list?").arg(list.at(myId)), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) {
|
||||
|
||||
std::list<std::string> playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList");
|
||||
playerIgnoreList.push_back(list.at(myId).toUtf8().constData());
|
||||
myW->getMyConfig()->writeConfigStringList("PlayerIgnoreList", playerIgnoreList);
|
||||
myW->getMyConfig()->writeBuffer();
|
||||
|
||||
myW->getMyChat()->refreshIgnoreList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,15 +37,18 @@ public slots:
|
||||
void setEnabledContextMenu(bool);
|
||||
void setVoteOnKickContextMenuEnabled(bool);
|
||||
void setVoteRunning ( bool theValue ) { voteRunning = theValue; }
|
||||
|
||||
void setPixmap ( const QPixmap &, const bool = FALSE);
|
||||
|
||||
void paintEvent(QPaintEvent*);
|
||||
void putPlayerOnIgnoreList();
|
||||
bool playerIsOnIgnoreList(QString playerName);
|
||||
|
||||
private:
|
||||
|
||||
gameTableImpl *myW;
|
||||
QMenu *myContextMenu;
|
||||
QAction *action_VoteForKick;
|
||||
QAction *action_IgnorePlayer;
|
||||
|
||||
QPixmap myPixmap;
|
||||
|
||||
int myId;
|
||||
|
||||
Reference in New Issue
Block a user