diff --git a/pokerth_game.pro b/pokerth_game.pro
index 97d115e4..b5f76140 100644
--- a/pokerth_game.pro
+++ b/pokerth_game.pro
@@ -55,7 +55,7 @@ INCLUDEPATH += . \
src/gui/qt/startwindow \
src/gui/qt/serverlistdialog \
src/gui/qt/styles \
- src/gui/qt/changehumanplayernamedialog \
+ src/gui/qt/changecontentdialog \
src/gui/qt/changecompleteblindsdialog \
src/gui/qt/internetgamelogindialog \
src/gui/qt/mymessagedialog \
@@ -94,7 +94,7 @@ DEPENDPATH += . \
src/gui/qt/startwindow \
src/gui/qt/serverlistdialog \
src/gui/qt/styles \
- src/gui/qt/changehumanplayernamedialog \
+ src/gui/qt/changecontentdialog \
src/gui/qt/internetgamelogindialog \
src/gui/qt/changecompleteblindsdialog \
src/gui/qt/mymessagedialog \
@@ -177,7 +177,7 @@ HEADERS += src/game.h \
src/gui/qt/startwindow/startwindowimpl.h \
src/gui/qt/styles/gametablestylereader.h \
src/gui/qt/styles/carddeckstylereader.h \
- src/gui/qt/changehumanplayernamedialog/changehumanplayernamedialogimpl.h \
+ src/gui/qt/changecontentdialog/changecontentdialogimpl.h \
src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h \
src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h \
src/gui/qt/gamelobbydialog/mygamelisttreewidget.h \
@@ -246,7 +246,7 @@ SOURCES += src/pokerth.cpp \
src/gui/qt/startwindow/startwindowimpl.cpp \
src/gui/qt/styles/gametablestylereader.cpp \
src/gui/qt/styles/carddeckstylereader.cpp \
- src/gui/qt/changehumanplayernamedialog/changehumanplayernamedialogimpl.cpp \
+ src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp \
src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp \
src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp \
src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp \
diff --git a/src/gui/qt/changecontentdialog.ui b/src/gui/qt/changecontentdialog.ui
new file mode 100644
index 00000000..59b6d7f2
--- /dev/null
+++ b/src/gui/qt/changecontentdialog.ui
@@ -0,0 +1,105 @@
+
+
+ changeContentDialog
+
+
+
+ 0
+ 0
+ 209
+ 126
+
+
+
+
+ 700
+ 300
+
+
+
+ Network Error
+
+
+ -
+
+
+ -
+
+
-
+
+
+ Name:
+
+
+ lineEdit
+
+
+
+ -
+
+
+ 12
+
+
+
+
+
+ -
+
+
+ in der Konfiguration speichern!
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Save
+
+
+
+
+
+
+ lineEdit
+ buttonBox
+
+
+
+
+ buttonBox
+ accepted()
+ changeContentDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ changeContentDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp
index a7b7aa65..0b442848 100644
--- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp
+++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp
@@ -14,31 +14,85 @@
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
+ * Free Software Foundation, Inc.,
+ *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "changecontentdialogimpl.h"
// #include "session.h"
#include "configfile.h"
-changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *config)
- : QDialog(parent), myConfig(config)
+changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t)
+ : QDialog(parent), myConfig(config), myType(t)
{
#ifdef __APPLE__
- setWindowModality(Qt::ApplicationModal);
- setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
+ setWindowModality(Qt::ApplicationModal);
+ setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
#endif
- setupUi(this);
+ setupUi(this);
- lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
+ switch (myType) {
+ case CHANGE_HUMAN_PLAYER_NAME: {
- connect(this, SIGNAL(accepted ()), this, SLOT(savePlayerName()));
+ label_Message->setText(tr("You cannot join Internet-Game-Lobby with \"Human Player\" as nickname.\nPlease choose another one."));
+ label_lineLabel->setText(tr("Nick name:"));
+ lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
+ checkBox->hide();
+ this->setGeometry(this->x(), this->y(), this->width(), this->height()-20 );
+ }
+ break;
+ case CHANGE_NICK_ALREADY_IN_USE: {
+ label_Message->setText(tr("Your player name is already used by another player.\nPlease choose a different name."));
+ label_lineLabel->setText(tr("Nick name:"));
+ lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
+ }
+ break;
+ case CHANGE_NICK_INVALID: {
+ label_Message->setText(tr("The player name is too short, too long or invalid. Please choose another one."));
+ label_lineLabel->setText(tr("Nick name:"));
+ lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
+ }
+ break;
+ case CHANGE_INET_GAME_NAME: {
+ label_Message->setText(tr("There is already a game with your choosen game name.\nPlease choose another one!"));
+ label_lineLabel->setText(tr("Game name:"));
+ lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str()));
+ }
+ break;
+ }
+
+ connect(this, SIGNAL(accepted ()), this, SLOT(saveContent()));
}
void changeContentDialogImpl::saveContent() {
- myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData());
- //write buffer to disc
- myConfig->writeBuffer();
+ switch (myType) {
+ case CHANGE_HUMAN_PLAYER_NAME: {
+ myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData());
+ }
+ break;
+ case CHANGE_NICK_ALREADY_IN_USE: {
+ if(checkBox->isChecked()) {
+ myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData());
+ }
+ }
+ break;
+ case CHANGE_NICK_INVALID: {
+ if(checkBox->isChecked()) {
+ myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData());
+ }
+ }
+ break;
+ case CHANGE_INET_GAME_NAME: {
+ if(checkBox->isChecked()) {
+ myConfig->writeConfigString("InternetGameName", lineEdit->text().toUtf8().constData());
+ }
+ }
+ break;
+ }
+
+ //write buffer to disc
+ myConfig->writeBuffer();
}
+
diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.h b/src/gui/qt/changecontentdialog/changecontentdialogimpl.h
index 3c0f573c..a45d4f81 100644
--- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.h
+++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.h
@@ -24,21 +24,23 @@
#include
+enum DialogType { CHANGE_HUMAN_PLAYER_NAME=0, CHANGE_NICK_ALREADY_IN_USE, CHANGE_NICK_INVALID, CHANGE_INET_GAME_NAME };
+
class ConfigFile;
class changeContentDialogImpl: public QDialog, public Ui::changeContentDialog {
-Q_OBJECT
+ Q_OBJECT
public:
- changeContentDialogImpl(QWidget *parent = 0, ConfigFile *config = 0);
+ changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t);
public slots:
- void saveContent();
+ void saveContent();
private:
+ ConfigFile *myConfig;
+ DialogType myType;
- ConfigFile *myConfig;
-
};
#endif
diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp
index 3a92a0b7..3fbda328 100644
--- a/src/gui/qt/startwindow/startwindowimpl.cpp
+++ b/src/gui/qt/startwindow/startwindowimpl.cpp
@@ -42,7 +42,7 @@
#include "connecttoserverdialogimpl.h"
#include "createnetworkgamedialogimpl.h"
#include "startnetworkgamedialogimpl.h"
-#include "changehumanplayernamedialogimpl.h"
+#include "changecontentdialogimpl.h"
#include "changecompleteblindsdialogimpl.h"
#include "gamelobbydialogimpl.h"
#include "timeoutmsgboximpl.h"
@@ -83,7 +83,6 @@ startWindowImpl::startWindowImpl(ConfigFile *c)
myNewGameDialog = new newGameDialogImpl(this, myConfig);
mySelectAvatarDialog = new selectAvatarDialogImpl(this, myConfig);
mySettingsDialog = new settingsDialogImpl(this, myConfig, mySelectAvatarDialog);
- myChangeHumanPlayerNameDialog = new changeHumanPlayerNameDialogImpl(this, myConfig);
myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this, myConfig);
myConnectToServerDialog = new connectToServerDialogImpl(this);
myStartNetworkGameDialog = new startNetworkGameDialogImpl(this, myConfig);
@@ -299,10 +298,9 @@ void startWindowImpl::callGameLobbyDialog() {
//Avoid join Lobby with "Human Player" nick
if(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) == QString("Human Player")) {
- myChangeHumanPlayerNameDialog->label_Message->setText(tr("You cannot join Internet-Game-Lobby with \"Human Player\" as nickname.\nPlease choose another one."));
- myChangeHumanPlayerNameDialog->exec();
-
- if(myChangeHumanPlayerNameDialog->result() == QDialog::Accepted) {
+ changeContentDialogImpl dialog(this, myConfig, CHANGE_HUMAN_PLAYER_NAME);
+ dialog.exec();
+ if(dialog.result() == QDialog::Accepted) {
joinGameLobby();
}
}
@@ -716,12 +714,10 @@ void startWindowImpl::networkError(int errorID, int /*osErrorID*/) {
QMessageBox::Close); }
break;
case ERR_NET_PLAYER_NAME_IN_USE:
- { myChangeHumanPlayerNameDialog->label_Message->setText(tr("Your player name is already used by another player.\nPlease choose a different name."));
- myChangeHumanPlayerNameDialog->exec(); }
+ { changeContentDialogImpl dialog(this, myConfig, CHANGE_NICK_ALREADY_IN_USE); dialog.exec(); }
break;
case ERR_NET_INVALID_PLAYER_NAME:
- { myChangeHumanPlayerNameDialog->label_Message->setText(tr("The player name is too short, too long or invalid. Please choose another one."));
- myChangeHumanPlayerNameDialog->exec(); }
+ { changeContentDialogImpl dialog(this, myConfig, CHANGE_NICK_INVALID); dialog.exec(); }
break;
case ERR_NET_INVALID_GAME_NAME:
{ QMessageBox::warning(this, tr("Network Error"),
@@ -845,6 +841,19 @@ void startWindowImpl::networkNotification(int notificationId)
tr("Unable to join - the server has already started the game."),
QMessageBox::Close); }
break;
+ case NTF_NET_JOIN_NOT_INVITED:
+ { QMessageBox::warning(this, tr("Network Notification"),
+ tr("This game is invite-only. You cannot join this game without being invited."),
+ QMessageBox::Close); }
+ break;
+ case NTF_NET_JOIN_GAME_NAME_IN_USE:
+ { changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_GAME_NAME);
+ dialog.exec();
+ if(dialog.result() == QDialog::Accepted) {
+ myGameLobbyDialog->pushButton_CreateGame->click();
+ }
+ }
+ break;
case NTF_NET_REMOVED_TIMEOUT:
{ QMessageBox::warning(this, tr("Network Notification"),
tr("Your admin state timed out due to inactivity. Feel free to create a new game!"),
diff --git a/src/gui/qt/startwindow/startwindowimpl.h b/src/gui/qt/startwindow/startwindowimpl.h
index 525302fb..d6c9f2cc 100644
--- a/src/gui/qt/startwindow/startwindowimpl.h
+++ b/src/gui/qt/startwindow/startwindowimpl.h
@@ -139,7 +139,6 @@ private:
newGameDialogImpl *myNewGameDialog;
settingsDialogImpl *mySettingsDialog;
selectAvatarDialogImpl *mySelectAvatarDialog;
- changeHumanPlayerNameDialogImpl *myChangeHumanPlayerNameDialog;
joinNetworkGameDialogImpl *myJoinNetworkGameDialog;
connectToServerDialogImpl *myConnectToServerDialog;
startNetworkGameDialogImpl *myStartNetworkGameDialog;