From e6dfce38c4ea6d85ee480eb39600f2b1fa8043ef Mon Sep 17 00:00:00 2001 From: doitux Date: Thu, 25 Mar 2010 10:36:51 +0000 Subject: [PATCH] GUI: guest restrictions and gametype settings in createinternetgamedialog --- .../createinternetgamedialogimpl.cpp | 51 ++++++++++++++----- .../createinternetgamedialogimpl.h | 6 +-- .../gamelobbydialog/gamelobbydialogimpl.cpp | 7 ++- .../qt/gamelobbydialog/gamelobbydialogimpl.h | 1 + 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp index a680966b..09d7b882 100644 --- a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp @@ -34,12 +34,12 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, Conf myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl; - fillFormular(); - connect( radioButton_changeBlindsSettings, SIGNAL( clicked(bool) ), this, SLOT( callChangeBlindsDialog(bool) ) ); connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) ); connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); connect( checkBox_Password, SIGNAL( toggled(bool) ), this, SLOT( clearGamePassword(bool)) ); + connect( comboBox_gameType, SIGNAL(currentIndexChanged(int)), this, SLOT( gameTypeChanged() ) ); + //temporarely unused until ai is enabled in network // label_5->hide(); // spinBox_gameSpeed->hide(); @@ -48,9 +48,9 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, Conf } -void createInternetGameDialogImpl::exec() { +void createInternetGameDialogImpl::exec(bool guestMode, QString playerName) { - fillFormular(); + fillFormular(guestMode, playerName); QDialog::exec(); } @@ -62,7 +62,7 @@ void createInternetGameDialogImpl::cancel() { } -void createInternetGameDialogImpl::fillFormular() { +void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerName) { //Network Game Settings spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); @@ -99,14 +99,21 @@ void createInternetGameDialogImpl::fillFormular() { myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue")); myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind")); - comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType")); - lineEdit_gameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); -} + if(guestMode) { + comboBox_gameType->setCurrentIndex(0); + comboBox_gameType->setDisabled(true); + lineEdit_gameName->setText(tr("%1's game").arg(playerName)); + lineEdit_gameName->setDisabled(true); -void createInternetGameDialogImpl::showDialog() { - - fillFormular(); - exec(); + } + else { + comboBox_gameType->setDisabled(false); + comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType")); + lineEdit_gameName->setDisabled(false); + lineEdit_gameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); + } + + gameTypeChanged(); } void createInternetGameDialogImpl::keyPressEvent ( QKeyEvent * event ) { @@ -132,3 +139,23 @@ void createInternetGameDialogImpl::callChangeBlindsDialog(bool show) { } } + +void createInternetGameDialogImpl::gameTypeChanged() { + + switch (comboBox_gameType->currentIndex()) { + + case 0: { checkBox_Password->setDisabled(FALSE); } + break; + case 1: { checkBox_Password->setDisabled(FALSE); } + break; + case 2: { checkBox_Password->setChecked(FALSE); + checkBox_Password->setDisabled(TRUE); + } + break; + case 3: { checkBox_Password->setChecked(FALSE); + checkBox_Password->setDisabled(TRUE); + } + break; + } + +} diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h index b3315cfd..44e0ac14 100644 --- a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h @@ -34,17 +34,17 @@ Q_OBJECT public: createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); - void exec(); + void exec(bool guestMode, QString playerName); changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } public slots: void createGame(); void cancel(); - void fillFormular(); - void showDialog(); + void fillFormular(bool guestMode, QString playerName); void keyPressEvent ( QKeyEvent * event ); void clearGamePassword(bool); + void gameTypeChanged(); void callChangeBlindsDialog(bool); private: diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 3f4bd40f..bce8cc8f 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -20,7 +20,7 @@ #include gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) - : QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), myCurrentGameId(0), isAdmin(false), inGame(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0) + : QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), myCurrentGameId(0), isAdmin(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0) { #ifdef __APPLE__ @@ -145,7 +145,8 @@ void gameLobbyDialogImpl::createGame() assert(mySession); myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig); - myCreateInternetGameDialog->exec(); + PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); + myCreateInternetGameDialog->exec(guestMode, QString::fromUtf8(playerInfo.playerName.c_str())); if (myCreateInternetGameDialog->result() == QDialog::Accepted ) { @@ -1188,6 +1189,7 @@ void gameLobbyDialogImpl::registeredUserMode() { lineEdit_ChatInput->clear(); lineEdit_ChatInput->setEnabled(true); + guestMode = false; } @@ -1195,4 +1197,5 @@ void gameLobbyDialogImpl::guestUserMode() { lineEdit_ChatInput->setText("Chat is avaiable only for registered members"); lineEdit_ChatInput->setDisabled(true); + guestMode = true; } diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 31454f63..1bc1a234 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -130,6 +130,7 @@ private: unsigned myCurrentGameId; bool isAdmin; bool inGame; + bool guestMode; QString myAppDataPath; QMessageBox *waitStartGameMsgBox;