GUI: invitation refresh game infos bugfix, comeback from game into lobby refresh nicks with flag bugfix, implementd ingore function chat and invitation, adds infomessage

This commit is contained in:
doitux
2010-03-31 12:33:00 +00:00
parent d3709925c2
commit 2e76454af7
11 changed files with 103 additions and 57 deletions
+13 -3
View File
@@ -31,6 +31,7 @@ using namespace std;
ChatTools::ChatTools(QLineEdit* l, ConfigFile *c, ChatType ct, QTextBrowser *b, QTreeWidget *t, gameLobbyDialogImpl *lo) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL), myTextBrowser(b), myChatType(ct), myConfig(c), myNick(""), myLobby(lo)
{
myNick = QString::fromUtf8(myConfig->readConfigString("MyName").c_str());
ignoreList = myConfig->readConfigStringList("PlayerIgnoreList");
}
ChatTools::~ChatTools()
@@ -95,8 +96,18 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
}
bool nickFoundOnIgnoreList = false;
list<std::string>::iterator it1;
for(it1=ignoreList.begin(); it1 != ignoreList.end(); it1++) {
myTextBrowser->append(playerName + ": " + tempMsg);
if(playerName == QString::fromUtf8(it1->c_str())) {
nickFoundOnIgnoreList = true;
}
}
if(!nickFoundOnIgnoreList) {
myTextBrowser->append(playerName + ": " + tempMsg);
}
}
}
@@ -192,6 +203,5 @@ void ChatTools::setChatTextEdited() {
void ChatTools::refreshIgnoreList()
{
ignoreList = myConfig->readConfigStringList("PlayerIgnoreList");
}
+2
View File
@@ -84,6 +84,8 @@ private:
GameTableStyleReader *myStyle;
gameLobbyDialogImpl *myLobby;
std::list<std::string> ignoreList;
};
#endif
@@ -24,7 +24,7 @@
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)
: QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0), inviteDialogIsCurrentlyShown(false)
{
#ifdef __APPLE__
@@ -234,7 +234,7 @@ void gameLobbyDialogImpl::createGame()
break;
}
hideShowGameDescription(TRUE);
showGameDescription(TRUE);
label_SmallBlind->setText(QString("%L1").arg(gameData.firstSmallBlind));
label_StartCash->setText(QString("%L1").arg(gameData.startMoney));
@@ -259,7 +259,6 @@ void gameLobbyDialogImpl::joinGame()
if (!inGame && selection->hasSelection())
{
unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt();
myCurrentGameId = gameId;
GameInfo info(mySession->getClientGameInfo(gameId));
bool ok = true;
QString password;
@@ -337,10 +336,10 @@ void gameLobbyDialogImpl::removedFromGame(int /*reason*/)
leftGameDialogUpdate();
}
void gameLobbyDialogImpl::gameSelected(const QModelIndex &index, bool invitedRefreshHack)
void gameLobbyDialogImpl::gameSelected(const QModelIndex &index)
{
if ((!inGame && index.isValid()) || (inGame && index.isValid() && invitedRefreshHack) )
if (!inGame && index.isValid() )
{
pushButton_JoinGame->setEnabled(true);
@@ -375,7 +374,7 @@ void gameLobbyDialogImpl::gameSelected(const QModelIndex &index, bool invitedRef
break;
}
hideShowGameDescription(TRUE);
showGameDescription(TRUE);
label_SmallBlind->setText(QString("%L1").arg(info.data.firstSmallBlind));
label_StartCash->setText(QString("%L1").arg(info.data.startMoney));
// label_MaximumNumberOfPlayers->setText(QString::number(info.data.maxNumberOfPlayers));s
@@ -644,7 +643,7 @@ void gameLobbyDialogImpl::clearDialog()
header->setText(0, tr("Connected players"));
header->setData(0, Qt::UserRole, 0);
hideShowGameDescription(FALSE);
showGameDescription(FALSE);
label_typeIcon->setText(" ");
label_typeText->setText(" ");
label_SmallBlind->setText("");
@@ -689,7 +688,7 @@ void gameLobbyDialogImpl::clearDialog()
isGameAdministrator = false;
myPlayerId = 0;
hideShowGameDescription(FALSE);
showGameDescription(FALSE);
label_nickListCounter->setText("| "+tr("players in chat: %1").arg(0));
label_connectedPlayersCounter->setText(tr("connected players: %1").arg(0));
@@ -772,16 +771,16 @@ void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerNam
showInfoMsgBoxTimer->start(1000);
}
if(!myGameListSelectionModel->hasSelection() && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY) {
int it = 0;
while (myGameListModel->item(it)) {
if (myGameListModel->item(it, 0)->data(Qt::UserRole) == mySession->getClientCurrentGameId()) {
gameSelected(treeView_GameList->model()->index(it,0), true);
break;
}
it++;
}
}
// if(!myGameListSelectionModel->hasSelection() && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY) {
// int it = 0;
// while (myGameListModel->item(it)) {
// if (myGameListModel->item(it, 0)->data(Qt::UserRole) == mySession->getClientCurrentGameId()) {
// gameSelected(treeView_GameList->model()->index(it,0), true);
// break;
// }
// it++;
// }
// }
}
@@ -888,6 +887,7 @@ void gameLobbyDialogImpl::playerJoinedLobby(unsigned playerId, QString /*playerN
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_NickList, 0);
item->setData(0, Qt::DisplayRole, QString::fromUtf8(playerInfo.playerName.c_str()));
item->setData(0, Qt::UserRole, playerId);
item->setIcon(0, QIcon(QString(":/cflags/cflags/%1.png").arg("de")));
treeWidget_NickList->sortItems(0, Qt::AscendingOrder);
refreshPlayerStats();
@@ -944,6 +944,41 @@ void gameLobbyDialogImpl::joinedGameDialogUpdate() {
pushButton_JoinGame->hide();
pushButton_joinAnyGame->hide();
pushButton_Leave->show();
//this was added to show game infos even if no game was selected (e.g. invite only game)
assert(mySession);
GameInfo info(mySession->getClientGameInfo(mySession->getClientCurrentGameId()));
groupBox_GameInfo->setTitle(tr("Game Info") + " - " + QString::fromUtf8(info.name.c_str()));
switch (info.data.gameType) {
case GAME_TYPE_NORMAL: {
label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png"));
label_typeText->setText(tr("Standard"));
}
break;
case GAME_TYPE_REGISTERED_ONLY: {
label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png"));
label_typeText->setText(tr("Registered players only"));
}
break;
case GAME_TYPE_INVITE_ONLY: {
label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png"));
label_typeText->setText(tr("Invited players only"));
}
break;
case GAME_TYPE_RANKING: {
label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png"));
label_typeText->setText(tr("Ranking game"));
}
break;
}
showGameDescription(TRUE);
label_SmallBlind->setText(QString("%L1").arg(info.data.firstSmallBlind));
label_StartCash->setText(QString("%L1").arg(info.data.startMoney));
updateDialogBlinds(info.data);
label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec));
}
void gameLobbyDialogImpl::leftGameDialogUpdate() {
@@ -959,7 +994,7 @@ void gameLobbyDialogImpl::leftGameDialogUpdate() {
header->setText(0, tr("Connected players"));
header->setData(0, Qt::UserRole, 0);
hideShowGameDescription(FALSE);
showGameDescription(FALSE);
label_typeIcon->setText(" ");
label_typeText->setText(" ");
label_SmallBlind->setText("");
@@ -1090,7 +1125,7 @@ bool gameLobbyDialogImpl::event ( QEvent * event ) {
return QDialog::event(event);
}
void gameLobbyDialogImpl::hideShowGameDescription(bool show) {
void gameLobbyDialogImpl::showGameDescription(bool show) {
if(show) {
label_gameType->show();
@@ -1382,7 +1417,11 @@ void gameLobbyDialogImpl::showInfoMsgBox()
void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerIdFrom)
{
if(!inviteDialogIsCurrentlyShown) {
if(inviteDialogIsCurrentlyShown || playerIsOnIgnoreList(playerIdFrom)) {
mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_BUSY);
}
else {
inviteDialogIsCurrentlyShown = true;
@@ -1397,9 +1436,6 @@ void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerI
inviteDialogIsCurrentlyShown = false;
}
}
else {
mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_BUSY);
}
}
@@ -1426,13 +1462,10 @@ bool gameLobbyDialogImpl::playerIsOnIgnoreList(unsigned playerId) {
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)) {
if(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str()) == QString::fromUtf8(it1->c_str())) {
return true;
}
}
return false;
}
@@ -1445,12 +1478,16 @@ void gameLobbyDialogImpl::putPlayerOnIgnoreList() {
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();
myMessageDialogImpl dialog(myConfig, 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(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) {
myChat->refreshIgnoreList();
list<std::string> playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList");
playerIgnoreList.push_back(QString("%1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())).toUtf8().constData());
myConfig->writeConfigStringList("PlayerIgnoreList", playerIgnoreList);
myConfig->writeBuffer();
myChat->refreshIgnoreList();
}
}
}
}
@@ -55,7 +55,7 @@ public slots:
void createGame();
void joinGame();
void joinAnyGame();
void gameSelected(const QModelIndex &, bool invitedRefreshHack = false);
void gameSelected(const QModelIndex &);
void updateGameItem(QList <QStandardItem*>, unsigned gameId);
void addGame(unsigned gameId);
void updateGameMode(unsigned gameId, int newMode);
@@ -91,7 +91,7 @@ public slots:
void clearDialog();
void keyPressEvent(QKeyEvent * keyEvent);
bool event(QEvent * event);
void hideShowGameDescription(bool show);
void showGameDescription(bool show);
void showWaitStartGameMsgBox();
void joinAnyGameButtonRefresh();
void reject();
@@ -120,7 +120,6 @@ private:
createInternetGameDialogImpl *myCreateInternetGameDialog;
QString currentGameName;
unsigned myPlayerId;
unsigned myCurrentGameId;
bool isGameAdministrator;
bool inGame;
bool guestMode;
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

+1
View File
@@ -45,6 +45,7 @@
<file>system_help_64.png</file>
<file>list_add_user_64.png</file>
<file>im-ban-user.png</file>
<file>im-ban-user_64.png</file>
</qresource>
<qresource prefix="/cflags">
<file>cflags/ad.png</file>
+1 -14
View File
@@ -1805,21 +1805,8 @@ p, li { white-space: pre-wrap; }
</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">
<widget class="QPushButton" name="pushButton_internetGameRemoveIgnoredPlayer">
<property name="text">
<string>Remove Player</string>
</property>
@@ -116,6 +116,8 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, ConfigFile *c, selectAva
connect( listWidget_cardDeckStyles, SIGNAL( currentItemChanged(QListWidgetItem*, QListWidgetItem*) ), this, SLOT ( showCurrentCardDeckStylePreview() ));
connect( pushButton_addCardDeckStyle, SIGNAL( clicked() ), this, SLOT( addCardDeckStyle()) );
connect( pushButton_removeCardDeckStyle, SIGNAL( clicked() ), this, SLOT( removeCardDeckStyle()) );
connect( pushButton_internetGameRemoveIgnoredPlayer, SIGNAL( clicked()), this, SLOT( removePlayerFromIgnoredPlayersList()));
}
void settingsDialogImpl::exec() {
@@ -215,8 +217,7 @@ void settingsDialogImpl::exec() {
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) );
item->setText(0, QString::fromUtf8(it5->c_str()));
}
//Interface
@@ -543,7 +544,7 @@ void settingsDialogImpl::isAccepted() {
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());
playerIgnoreList.push_back(QString("%1").arg(treeWidget_internetGameIgnoredPlayers->topLevelItem(k)->text(0)).toUtf8().constData());
}
myConfig->writeConfigStringList("PlayerIgnoreList", playerIgnoreList);
@@ -1141,3 +1142,10 @@ void settingsDialogImpl::removeCardDeckStyle()
listWidget_cardDeckStyles->takeItem(listWidget_cardDeckStyles->currentRow());
}
}
void settingsDialogImpl::removePlayerFromIgnoredPlayersList()
{
if(treeWidget_internetGameIgnoredPlayers->selectedItems().count()) {
treeWidget_internetGameIgnoredPlayers->takeTopLevelItem(treeWidget_internetGameIgnoredPlayers->currentIndex().row());
}
}
@@ -90,6 +90,7 @@ public slots:
void showCurrentCardDeckStylePreview();
void addCardDeckStyle();
void removeCardDeckStyle();
void removePlayerFromIgnoredPlayersList();
private:
@@ -150,7 +150,6 @@ startWindowImpl::startWindowImpl(ConfigFile *c)
connect(this, SIGNAL(signalNetClientShowTimeoutDialog(int, unsigned)), this, SLOT(showTimeoutDialog(int, unsigned)));
connect(this, SIGNAL(signalLobbyPlayerJoined(unsigned, QString)), myGameLobbyDialog, SLOT(playerJoinedLobby(unsigned, QString)));
// connect(this, SIGNAL(signalLobbyPlayerKicked(QString, QString, QString)), myGameLobbyDialog, SLOT(playerKicked(QString, QString, QString)));
connect(this, SIGNAL(signalLobbyPlayerLeft(unsigned)), myGameLobbyDialog, SLOT(playerLeftLobby(unsigned)));