GUI: ignore player function added (list in settings - remove button will follow)

This commit is contained in:
doitux
2010-03-30 17:30:33 +00:00
parent 5239f496f3
commit 0771aabfb0
10 changed files with 1970 additions and 1872 deletions
+3 -1
View File
@@ -48,7 +48,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
myQtToolsInterface = CreateQtToolsWrapper();
// !!!! Revisionsnummer der Configdefaults !!!!!
configRev = 82;
configRev = 83;
//standard defaults
logOnOffDefault = "1";
@@ -271,6 +271,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
configList.push_back(ConfigInfo("InternetLoginPassword", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("InternetSavePassword", CONFIG_TYPE_INT, "0"));
configList.push_back(ConfigInfo("IfInfoMessageShowList", CONFIG_TYPE_STRING_LIST, "Msg"));
configList.push_back(ConfigInfo("PlayerIgnoreList", CONFIG_TYPE_STRING_LIST, "Player"));
//fill tempList firstTime
configBufferList = configList;
@@ -719,3 +720,4 @@ void ConfigFile::writeConfigStringList(string varName, list<string> varCont)
if (configBufferList[i].name == varName) { configBufferList[i].defaultListValue = varCont; }
}
}
+8
View File
@@ -94,6 +94,8 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
}
}
myTextBrowser->append(playerName + ": " + tempMsg);
}
}
@@ -187,3 +189,9 @@ void ChatTools::setChatTextEdited() {
nickAutoCompletitionCounter = 0;
}
void ChatTools::refreshIgnoreList()
{
}
+1
View File
@@ -62,6 +62,7 @@ public slots:
QString getMyNick () { return myNick; }
void setMyStyle ( GameTableStyleReader* theValue ) { myStyle = theValue; }
void refreshIgnoreList();
private:
@@ -21,6 +21,8 @@
#include <net/socket_msg.h>
#include "mymessagedialogimpl.h"
using namespace std;
gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
: QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), myCurrentGameId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0), inviteDialogIsCurrentlyShown(false)
{
@@ -86,6 +88,8 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
nickListContextMenu = new QMenu();
nickListInviteAction = new QAction(QIcon(":/gfx/list_add_user.png"), tr("Invite player"), nickListContextMenu);
nickListContextMenu->addAction(nickListInviteAction);
nickListIgnorePlayerAction = new QAction(QIcon(":/gfx/im-ban-user.png"), tr("Ignore player"), nickListContextMenu);
nickListContextMenu->addAction(nickListIgnorePlayerAction);
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
@@ -106,6 +110,7 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int)));
connect( treeWidget_NickList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( showNickListContextMenu(QPoint) ) );
connect( nickListInviteAction, SIGNAL(triggered()), this, SLOT( invitePlayerToCurrentGame() ));
connect( nickListIgnorePlayerAction, SIGNAL(triggered()), this, SLOT( putPlayerOnIgnoreList() ));
lineEdit_ChatInput->installEventFilter(this);
@@ -1317,8 +1322,17 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p)
assert(mySession);
if(inGame && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY && treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt() != mySession->getClientUniquePlayerId()) {
nickListContextMenu->popup(treeWidget_NickList->mapToGlobal(p));
nickListInviteAction->setEnabled(true);
nickListInviteAction->setText(tr("Invite player %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt()).playerName.c_str())));
}
else {
nickListInviteAction->setText(tr("Invite player ..."));
nickListInviteAction->setEnabled(true);
}
nickListContextMenu->popup(treeWidget_NickList->mapToGlobal(p));
}
}
@@ -1365,13 +1379,14 @@ void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerI
}
void gameLobbyDialogImpl::chatInfoPlayerInviation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom)
void gameLobbyDialogImpl::chatInfoPlayerInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom)
{
textBrowser_ChatDisplay->append(tr("<span style='color:blue;'>Player %1 has been invited to %2 by %3.</span>").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdWho).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())));
}
void gameLobbyDialogImpl::chatInfoPlayerRejectedInviation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason)
void gameLobbyDialogImpl::chatInfoPlayerRejectedInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason)
{
QString string;
if(reason == DENY_GAME_INVITATION_NO) string = tr("<span style='color:red;'>Player %1 has rejected intivation to %2.</span>");
@@ -1380,3 +1395,34 @@ void gameLobbyDialogImpl::chatInfoPlayerRejectedInviation(unsigned gameId, unsig
textBrowser_ChatDisplay->append(string.arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdWho).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())));
}
bool gameLobbyDialogImpl::playerIsOnIgnoreList(unsigned playerId) {
list<std::string> playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList");
list<std::string>::iterator it1;
for(it1= playerIgnoreList.begin(); it1 != playerIgnoreList.end(); it1++) {
QString tmpString = QString::fromUtf8(it1->c_str());
if(QString("%1").arg(playerId) == tmpString.split(",").at(0)) {
return true;
}
}
return false;
}
void gameLobbyDialogImpl::putPlayerOnIgnoreList(unsigned playerId) {
if(!playerIsOnIgnoreList(playerId)) {
list<std::string> playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList");
playerIgnoreList.push_back(QString("%1,%2").arg(playerId).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())).toUtf8().constData());
myConfig->writeConfigStringList("PlayerIgnoreList", playerIgnoreList);
myConfig->writeBuffer();
myChat->refreshIgnoreList();
}
}
@@ -106,8 +106,10 @@ public slots:
void invitePlayerToCurrentGame();
void showInfoMsgBox();
void showInvitationDialog(unsigned gameId, unsigned playerIdFrom);
void chatInfoPlayerInviation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom);
void chatInfoPlayerRejectedInviation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason);
void chatInfoPlayerInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom);
void chatInfoPlayerRejectedInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason);
void putPlayerOnIgnoreList(unsigned playerid);
bool playerIsOnIgnoreList(unsigned playerid);
private:
@@ -140,7 +142,7 @@ private:
MyGameListSortFilterProxyModel *myGameListSortFilterProxyModel;
QMenu *nickListContextMenu;
QAction *nickListInviteAction;
QAction *ignorePlayerAction;
QAction *nickListIgnorePlayerAction;
int infoMsgToShowId;
int currentInvitationGameId;
bool inviteDialogIsCurrentlyShown;
Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

+1
View File
@@ -44,6 +44,7 @@
<file>ktip.png</file>
<file>system_help_64.png</file>
<file>list_add_user_64.png</file>
<file>im-ban-user.png</file>
</qresource>
<qresource prefix="/cflags">
<file>cflags/ad.png</file>
+104 -82
View File
@@ -125,7 +125,7 @@
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>5</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_8">
@@ -1464,32 +1464,23 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="0" colspan="2">
<widget class="Line" name="line_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_43">
<property name="text">
<string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot;font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Note: Default &lt;/span&gt;&lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;Game Settings&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt; like &quot;Maximum number of players&quot;, &quot;Start Cash&quot; and &quot;Small Blind&quot; will be used &lt;/span&gt;&lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;from Network Game Settings.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<item row="2" column="0" colspan="2">
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Internet Server</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Server</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_18">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_automaticServerConfig">
<property name="title">
@@ -1499,12 +1490,6 @@ p, li { white-space: pre-wrap; }
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="topMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
@@ -1536,12 +1521,6 @@ p, li { white-space: pre-wrap; }
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="topMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_41">
<property name="text">
@@ -1661,8 +1640,25 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Game</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_43">
<property name="text">
<string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot;font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Note: Default &lt;/span&gt;&lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;Game Settings&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt; like &quot;Maximum number of players&quot;, &quot;Start Cash&quot; and &quot;Small Blind&quot; will be used &lt;/span&gt;&lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;from Network Game Settings.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_23">
@@ -1676,7 +1672,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="5" column="0">
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_17">
@@ -1733,7 +1729,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="6" column="0">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
@@ -1761,22 +1757,91 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="7" column="0">
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_UseLobbyChat">
<property name="text">
<string>Show lobby chat</string>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer>
<item row="5" column="0">
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>437</width>
<height>16</height>
<height>72</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Ignored Players</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_19">
<item row="0" column="0">
<widget class="QTreeWidget" name="treeWidget_internetGameIgnoredPlayers">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="indentation">
<number>5</number>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Player</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1" rowspan="2">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>256</width>
<height>218</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Remove Player</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/list-remove.png</normaloff>:/gfx/list-remove.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>121</height>
</size>
</property>
</spacer>
@@ -3452,17 +3517,6 @@ p, li { white-space: pre-wrap; }
<tabstop>spinBox_serverPort</tabstop>
<tabstop>checkBox_useIpv6</tabstop>
<tabstop>checkBox_useSctp</tabstop>
<tabstop>groupBox_automaticServerConfig</tabstop>
<tabstop>lineEdit_InternetServerListAddress</tabstop>
<tabstop>groupBox_manualServerConfig</tabstop>
<tabstop>lineEdit_InternetServerAddress</tabstop>
<tabstop>spinBox_InternetServerPort</tabstop>
<tabstop>checkBox_useAvatarServer</tabstop>
<tabstop>lineEdit_avatarServerAddress</tabstop>
<tabstop>checkBox_InternetServerUseIpv6</tabstop>
<tabstop>checkBox_InternetServerUseSctp</tabstop>
<tabstop>checkBox_UseInternetGamePassword</tabstop>
<tabstop>lineEdit_InternetGamePassword</tabstop>
<tabstop>pushButton_HumanPlayerAvatar</tabstop>
<tabstop>lineEdit_HumanPlayerName</tabstop>
<tabstop>pushButton_Opponent1Avatar</tabstop>
@@ -3526,22 +3580,6 @@ p, li { white-space: pre-wrap; }
</hint>
</hints>
</connection>
<connection>
<sender>checkBox_UseInternetGamePassword</sender>
<signal>toggled(bool)</signal>
<receiver>lineEdit_InternetGamePassword</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>402</x>
<y>434</y>
</hint>
<hint type="destinationlabel">
<x>774</x>
<y>436</y>
</hint>
</hints>
</connection>
<connection>
<sender>horizontalSlider_soundVolume</sender>
<signal>valueChanged(int)</signal>
@@ -3590,22 +3628,6 @@ p, li { white-space: pre-wrap; }
</hint>
</hints>
</connection>
<connection>
<sender>checkBox_useAvatarServer</sender>
<signal>toggled(bool)</signal>
<receiver>lineEdit_avatarServerAddress</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>314</x>
<y>318</y>
</hint>
<hint type="destinationlabel">
<x>366</x>
<y>320</y>
</hint>
</hints>
</connection>
<connection>
<sender>radioButton_flipsideOwn</sender>
<signal>toggled(bool)</signal>
@@ -211,6 +211,14 @@ void settingsDialogImpl::exec() {
comboBox_internetGameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType"));
lineEdit_internetGameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str()));
std::list<std::string> playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList");
std::list<std::string>::iterator it5;
for(it5= playerIgnoreList.begin(); it5 != playerIgnoreList.end(); it5++) {
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_internetGameIgnoredPlayers);
item->setText(0, QString::fromUtf8(it5->c_str()).split(",").at(1) );
item->setData(0, Qt::UserRole, QString::fromUtf8(it5->c_str()).split(",").at(0) );
}
//Interface
comboBox_switchLanguage->setCurrentIndex(comboBox_switchLanguage->findData(QString::fromUtf8(myConfig->readConfigString("Language").c_str()).section('_', 0, 0)));
checkBox_showLeftToolbox->setChecked(myConfig->readConfigInt("ShowLeftToolBox"));
@@ -532,6 +540,14 @@ void settingsDialogImpl::isAccepted() {
myConfig->writeConfigInt("InternetGameType", comboBox_internetGameType->currentIndex());
myConfig->writeConfigString("InternetGameName", lineEdit_internetGameName->text().toUtf8().constData());
int k;
std::list<std::string> playerIgnoreList;
for(k=0; k<treeWidget_internetGameIgnoredPlayers->topLevelItemCount(); k++) {
playerIgnoreList.push_back(QString("%1,%2").arg(treeWidget_internetGameIgnoredPlayers->topLevelItem(k)->data(0,Qt::UserRole).toUInt()).arg(treeWidget_internetGameIgnoredPlayers->topLevelItem(k)->text(0)).toUtf8().constData());
}
myConfig->writeConfigStringList("PlayerIgnoreList", playerIgnoreList);
// Interface
myConfig->writeConfigString("Language", comboBox_switchLanguage->itemData(comboBox_switchLanguage->currentIndex()).toString().toUtf8().constData());
myConfig->writeConfigInt("ShowLeftToolBox", checkBox_showLeftToolbox->isChecked());
+2 -2
View File
@@ -162,8 +162,8 @@ startWindowImpl::startWindowImpl(ConfigFile *c)
connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr<Game>)), this, SLOT(networkStart(boost::shared_ptr<Game>)));
connect(this, SIGNAL(signalSelfGameInvitation(unsigned, unsigned)), myGameLobbyDialog, SLOT(showInvitationDialog(unsigned, unsigned)));
connect(this, SIGNAL(signalPlayerGameInvitation(unsigned, unsigned, unsigned)), myGameLobbyDialog, SLOT(chatInfoPlayerInviation(unsigned, unsigned, unsigned)));
connect(this, SIGNAL(signalRejectedGameInvitation(unsigned, unsigned, DenyGameInvitationReason)), myGameLobbyDialog, SLOT(chatInfoPlayerRejectedInviation(unsigned, unsigned, DenyGameInvitationReason)));
connect(this, SIGNAL(signalPlayerGameInvitation(unsigned, unsigned, unsigned)), myGameLobbyDialog, SLOT(chatInfoPlayerInvitation(unsigned, unsigned, unsigned)));
connect(this, SIGNAL(signalRejectedGameInvitation(unsigned, unsigned, DenyGameInvitationReason)), myGameLobbyDialog, SLOT(chatInfoPlayerRejectedInvitation(unsigned, unsigned, DenyGameInvitationReason)));
this->show();