GUI: guest restrictions and gametype settings in

createinternetgamedialog
This commit is contained in:
doitux
2010-03-25 10:36:51 +00:00
parent d8ea018ffc
commit e6dfce38c4
4 changed files with 48 additions and 17 deletions
@@ -34,12 +34,12 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, Conf
myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl; myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl;
fillFormular();
connect( radioButton_changeBlindsSettings, SIGNAL( clicked(bool) ), this, SLOT( callChangeBlindsDialog(bool) ) ); connect( radioButton_changeBlindsSettings, SIGNAL( clicked(bool) ), this, SLOT( callChangeBlindsDialog(bool) ) );
connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) ); connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) );
connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
connect( checkBox_Password, SIGNAL( toggled(bool) ), this, SLOT( clearGamePassword(bool)) ); 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 //temporarely unused until ai is enabled in network
// label_5->hide(); // label_5->hide();
// spinBox_gameSpeed->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(); QDialog::exec();
} }
@@ -62,7 +62,7 @@ void createInternetGameDialogImpl::cancel() {
} }
void createInternetGameDialogImpl::fillFormular() { void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerName) {
//Network Game Settings //Network Game Settings
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
@@ -99,14 +99,21 @@ void createInternetGameDialogImpl::fillFormular() {
myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue")); myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue"));
myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind")); myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind"));
comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType")); if(guestMode) {
lineEdit_gameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); comboBox_gameType->setCurrentIndex(0);
} comboBox_gameType->setDisabled(true);
lineEdit_gameName->setText(tr("%1's game").arg(playerName));
lineEdit_gameName->setDisabled(true);
void createInternetGameDialogImpl::showDialog() { }
else {
fillFormular(); comboBox_gameType->setDisabled(false);
exec(); 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 ) { 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;
}
}
@@ -34,17 +34,17 @@ Q_OBJECT
public: public:
createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0);
void exec(); void exec(bool guestMode, QString playerName);
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; }
public slots: public slots:
void createGame(); void createGame();
void cancel(); void cancel();
void fillFormular(); void fillFormular(bool guestMode, QString playerName);
void showDialog();
void keyPressEvent ( QKeyEvent * event ); void keyPressEvent ( QKeyEvent * event );
void clearGamePassword(bool); void clearGamePassword(bool);
void gameTypeChanged();
void callChangeBlindsDialog(bool); void callChangeBlindsDialog(bool);
private: private:
@@ -20,7 +20,7 @@
#include <net/socket_msg.h> #include <net/socket_msg.h>
gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) 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__ #ifdef __APPLE__
@@ -145,7 +145,8 @@ void gameLobbyDialogImpl::createGame()
assert(mySession); assert(mySession);
myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig); 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 ) { if (myCreateInternetGameDialog->result() == QDialog::Accepted ) {
@@ -1188,6 +1189,7 @@ void gameLobbyDialogImpl::registeredUserMode()
{ {
lineEdit_ChatInput->clear(); lineEdit_ChatInput->clear();
lineEdit_ChatInput->setEnabled(true); 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->setText("Chat is avaiable only for registered members");
lineEdit_ChatInput->setDisabled(true); lineEdit_ChatInput->setDisabled(true);
guestMode = true;
} }
@@ -130,6 +130,7 @@ private:
unsigned myCurrentGameId; unsigned myCurrentGameId;
bool isAdmin; bool isAdmin;
bool inGame; bool inGame;
bool guestMode;
QString myAppDataPath; QString myAppDataPath;
QMessageBox *waitStartGameMsgBox; QMessageBox *waitStartGameMsgBox;