add changeInternetGame dialog
This commit is contained in:
+4
-4
@@ -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 \
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>changeContentDialog</class>
|
||||
<widget class="QDialog" name="changeContentDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>209</width>
|
||||
<height>126</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>700</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Network Error</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_Message"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_lineLabel">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="maxLength">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>in der Konfiguration speichern!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>changeContentDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>changeContentDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,21 +24,23 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
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
|
||||
|
||||
@@ -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!"),
|
||||
|
||||
@@ -139,7 +139,6 @@ private:
|
||||
newGameDialogImpl *myNewGameDialog;
|
||||
settingsDialogImpl *mySettingsDialog;
|
||||
selectAvatarDialogImpl *mySelectAvatarDialog;
|
||||
changeHumanPlayerNameDialogImpl *myChangeHumanPlayerNameDialog;
|
||||
joinNetworkGameDialogImpl *myJoinNetworkGameDialog;
|
||||
connectToServerDialogImpl *myConnectToServerDialog;
|
||||
startNetworkGameDialogImpl *myStartNetworkGameDialog;
|
||||
|
||||
Reference in New Issue
Block a user