From c4f62eb53f4920c95833bb418fa9ce7103b20865 Mon Sep 17 00:00:00 2001 From: doitux Date: Tue, 21 Aug 2007 23:31:09 +0000 Subject: [PATCH] adds createInternetGameDialog --- pokerth_game.pro | 5 + src/gui/qt/createinternetgamedialog.ui | 278 ++++++++++++++++++ .../createinternetgamedialogimpl.cpp | 80 +++++ .../createinternetgamedialogimpl.h | 50 ++++ src/gui/qt/createnetworkgamedialog.ui | 162 +++++----- .../createnetworkgamedialogimpl.cpp | 6 +- src/gui/qt/gamelobbydialog.ui | 16 - .../gamelobbydialog/gamelobbydialogimpl.cpp | 28 +- .../qt/gamelobbydialog/gamelobbydialogimpl.h | 4 + src/gui/qt/mainwindow/mainwindowimpl.cpp | 4 +- .../qt/settingsdialog/settingsdialogimpl.cpp | 20 +- 11 files changed, 528 insertions(+), 125 deletions(-) create mode 100644 src/gui/qt/createinternetgamedialog.ui create mode 100644 src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp create mode 100644 src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h diff --git a/pokerth_game.pro b/pokerth_game.pro index b3ec2aff..553a56d2 100644 --- a/pokerth_game.pro +++ b/pokerth_game.pro @@ -28,6 +28,7 @@ INCLUDEPATH += . \ src/gui/qt/mainwindow/chat \ src/gui/qt/aboutpokerth \ src/gui/qt/createnetworkgamedialog \ + src/gui/qt/createinternetgamedialog \ src/gui/qt/joinnetworkgamedialog \ src/gui/qt/newlocalgamedialog \ src/gui/qt/settingsdialog \ @@ -56,6 +57,7 @@ DEPENDPATH += . \ src/gui/qt/mainwindow/chat \ src/gui/qt/aboutpokerth \ src/gui/qt/connecttoserverdialog \ + src/gui/qt/createinternetgamedialog \ src/gui/qt/createnetworkgamedialog \ src/gui/qt/joinnetworkgamedialog \ src/gui/qt/qttools \ @@ -129,6 +131,7 @@ HEADERS += \ src/gui/qt/aboutpokerth/aboutpokerthimpl.h \ src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.h \ src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h \ + src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h \ src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.h \ src/gui/qt/newlocalgamedialog/newgamedialogimpl.h \ src/gui/qt/settingsdialog/settingsdialogimpl.h \ @@ -149,6 +152,7 @@ FORMS += \ src/gui/qt/aboutpokerth.ui \ src/gui/qt/connecttoserverdialog.ui \ src/gui/qt/createnetworkgamedialog.ui \ + src/gui/qt/createinternetgamedialog.ui \ src/gui/qt/joinnetworkgamedialog.ui \ src/gui/qt/newgamedialog.ui \ src/gui/qt/settingsdialog.ui \ @@ -173,6 +177,7 @@ SOURCES += \ src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp \ src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.cpp \ src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp \ + src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp \ src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.cpp \ src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp \ src/gui/qt/settingsdialog/settingsdialogimpl.cpp \ diff --git a/src/gui/qt/createinternetgamedialog.ui b/src/gui/qt/createinternetgamedialog.ui new file mode 100644 index 00000000..fb98c9a9 --- /dev/null +++ b/src/gui/qt/createinternetgamedialog.ui @@ -0,0 +1,278 @@ + + createInternetGameDialog + + + + 0 + 0 + 297 + 305 + + + + Create Game + + + + 9 + + + 6 + + + + + Game Settings + + + + 9 + + + 6 + + + + + Game Speed for computer opponents: + + + + + + + 1 + + + 9 + + + + + + + Hands before raise small blind: + + + + + + + Timeout for player action (sec): + + + + + + + 60 + + + 5 + + + 20 + + + + + + + 7 + + + 2 + + + 7 + + + + + + + 5000 + + + 1000 + + + 2000 + + + + + + + Maximum number of players: + + + + + + + Start Cash: + + + + + + + Small Blind: + + + + + + + 500 + + + 5 + + + 10 + + + + + + + 11 + + + 1 + + + 4 + + + + + + + 0 + + + 6 + + + + + Password: + + + + + + + false + + + + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 181 + 20 + + + + + + + + Create Game + + + + + + + Cancel + + + + + + + + + spinBox_quantityPlayers + spinBox_startCash + spinBox_smallBlind + spinBox_handsBeforeRaiseSmallBlind + spinBox_gameSpeed + spinBox_netTimeOutPlayerAction + pushButton_createGame + pushButton_cancel + + + + + pushButton_createGame + clicked() + createInternetGameDialog + accept() + + + 205 + 294 + + + 87 + 215 + + + + + pushButton_cancel + clicked() + createInternetGameDialog + reject() + + + 286 + 294 + + + 288 + 190 + + + + + checkBox_Password + toggled(bool) + lineEdit_Password + setEnabled(bool) + + + 76 + 239 + + + 146 + 235 + + + + + diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp new file mode 100644 index 00000000..7627c589 --- /dev/null +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp @@ -0,0 +1,80 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "createinternetgamedialogimpl.h" +#include "session.h" +#include "configfile.h" + +createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, ConfigFile *c) + : QDialog(parent), myConfig(c) +{ + + setupUi(this); + + fillFormular(); + + connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) ); + connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); + + //temporarely unused until ai is enabled in network +// label_5->hide(); +// spinBox_gameSpeed->hide(); + + +} + + +void createInternetGameDialogImpl::exec() { + + fillFormular(); + QDialog::exec(); +} + +void createInternetGameDialogImpl::createGame() { + +} + +void createInternetGameDialogImpl::cancel() { + +} + +void createInternetGameDialogImpl::fillFormular() { + + //Network Game Settings + spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); + spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); + spinBox_smallBlind->setValue(myConfig->readConfigInt("NetSmallBlind")); + spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("NetHandsBeforeRaiseSmallBlind")); + //temporarely unused until ai is enabled in network + spinBox_gameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed")); + spinBox_netTimeOutPlayerAction->setValue(myConfig->readConfigInt("NetTimeOutPlayerAction")); +} + +void createInternetGameDialogImpl::showDialog() { + + fillFormular(); + exec(); +} + +void createInternetGameDialogImpl::keyPressEvent ( QKeyEvent * event ) { + + + if (event->key() == 16777220) { pushButton_createGame->click(); } //ENTER + +} diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h new file mode 100644 index 00000000..8c1fb0ed --- /dev/null +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef CREATEINTERNETGAMEDIALOGIMPL_H +#define CREATEINTERNETGAMEDIALOGIMPL_H + +#include "ui_createinternetgamedialog.h" + +#include +#include + +class Session; +class ConfigFile; + +class createInternetGameDialogImpl: public QDialog, public Ui::createInternetGameDialog { +Q_OBJECT +public: + createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); + + void exec(); + +public slots: + + void createGame(); + void cancel(); + void fillFormular(); + void showDialog(); + void keyPressEvent ( QKeyEvent * event ); +private: + + ConfigFile *myConfig; +}; + +#endif diff --git a/src/gui/qt/createnetworkgamedialog.ui b/src/gui/qt/createnetworkgamedialog.ui index ec4aac9e..52e52d4e 100644 --- a/src/gui/qt/createnetworkgamedialog.ui +++ b/src/gui/qt/createnetworkgamedialog.ui @@ -5,8 +5,8 @@ 0 0 - 315 - 274 + 290 + 272 @@ -31,76 +31,34 @@ 6 - - - - 11 + + + + Game Speed for computer opponents: + + + + 1 - 4 + 9 - - - - 500 - - - 5 - - - 10 - - - - - + + - Small Blind: + Hands before raise small blind: - - + + - Start Cash: - - - - - - - Maximum number of players: - - - - - - - 5000 - - - 1000 - - - 2000 - - - - - - - 7 - - - 2 - - - 7 + Timeout for player action (sec): @@ -117,34 +75,76 @@ - - - - Timeout for player action (sec): + + + + 7 + + + 2 + + + 7 - - - - Hands before raise small blind: + + + + 5000 + + + 1000 + + + 2000 - - + + + + Maximum number of players: + + + + + + + Start Cash: + + + + + + + Small Blind: + + + + + + + 500 + + + 5 + + + 10 + + + + + + + 11 + 1 - 9 - - - - - - - Game Speed for computer opponents: + 4 @@ -209,8 +209,8 @@ accept() - 168 - 217 + 223 + 292 87 @@ -225,8 +225,8 @@ reject() - 278 - 230 + 304 + 292 288 diff --git a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp index 8a2ea31b..15e4c26d 100644 --- a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp +++ b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp @@ -33,8 +33,8 @@ createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, Config connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); //temporarely unused until ai is enabled in network - label_5->hide(); - spinBox_gameSpeed->hide(); +// label_5->hide(); +// spinBox_gameSpeed->hide(); } @@ -62,7 +62,7 @@ void createNetworkGameDialogImpl::fillFormular() { spinBox_smallBlind->setValue(myConfig->readConfigInt("NetSmallBlind")); spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("NetHandsBeforeRaiseSmallBlind")); //temporarely unused until ai is enabled in network -// spinBox_gameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed")); + spinBox_gameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed")); spinBox_netTimeOutPlayerAction->setValue(myConfig->readConfigInt("NetTimeOutPlayerAction")); } diff --git a/src/gui/qt/gamelobbydialog.ui b/src/gui/qt/gamelobbydialog.ui index 063773ba..3c60c44f 100644 --- a/src/gui/qt/gamelobbydialog.ui +++ b/src/gui/qt/gamelobbydialog.ui @@ -125,21 +125,5 @@ - - pushButton_CreateGame - clicked() - gameLobbyDialog - accept() - - - 271 - 193 - - - 125 - 188 - - - diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 56494b4e..b0318803 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -46,18 +46,24 @@ void gameLobbyDialogImpl::createGame() { assert(mySession); - // TODO: don't use hardcoded values - GameData gameData; - // Set Game Data - gameData.maxNumberOfPlayers = myConfig->readConfigInt("NumberOfPlayers"); - gameData.startMoney = myConfig->readConfigInt("StartCash"); - gameData.smallBlind = myConfig->readConfigInt("SmallBlind"); - gameData.handsBeforeRaise = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind"); - //Speeds - gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); - - mySession->clientCreateGame(gameData, myConfig->readConfigString("MyName") + "'s game", ""); + myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig); + myCreateInternetGameDialog->exec(); + + if (myCreateInternetGameDialog->result() == QDialog::Accepted ) { + + GameData gameData; + // Set Game Data + gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value(); + gameData.startMoney = myCreateInternetGameDialog->spinBox_startCash->value(); + gameData.smallBlind = myCreateInternetGameDialog->spinBox_smallBlind->value(); + gameData.handsBeforeRaise = myCreateInternetGameDialog->spinBox_handsBeforeRaiseSmallBlind->value(); + gameData.guiSpeed = myCreateInternetGameDialog->spinBox_gameSpeed->value(); + gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value(); + + mySession->clientCreateGame(gameData, myConfig->readConfigString("MyName") + "'s game", ""); + accept(); + } } void gameLobbyDialogImpl::joinGame() diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 865b3a8e..19a95913 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -17,6 +17,8 @@ #include #include +#include "createinternetgamedialogimpl.h" + class Session; class ConfigFile; @@ -48,6 +50,8 @@ private: ConfigFile *myConfig; Session *mySession; + + createInternetGameDialogImpl *myCreateInternetGameDialog; }; #endif diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 1a07d078..820568de 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -755,9 +755,7 @@ void mainWindowImpl::callCreateNetworkGameDialog() { gameData.startMoney = myCreateNetworkGameDialog->spinBox_startCash->value(); gameData.smallBlind = myCreateNetworkGameDialog->spinBox_smallBlind->value(); gameData.handsBeforeRaise = myCreateNetworkGameDialog->spinBox_handsBeforeRaiseSmallBlind->value(); - //temporarely static until ai is enabled in network -// gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value(); - gameData.guiSpeed = 4; + gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value(); gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value(); myStartNetworkGameDialog->setSession(&getSession()); diff --git a/src/gui/qt/settingsdialog/settingsdialogimpl.cpp b/src/gui/qt/settingsdialog/settingsdialogimpl.cpp index 33eafea2..cfff53fd 100644 --- a/src/gui/qt/settingsdialog/settingsdialogimpl.cpp +++ b/src/gui/qt/settingsdialog/settingsdialogimpl.cpp @@ -54,11 +54,11 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, ConfigFile *c, selectAva // connect( checkBox_showIntro, SIGNAL( clicked() ), this, SLOT( callSelectAvatarDialog()) ); //temporarely unused until ai is enabled in network - label_36->hide(); - spinBox_netGameSpeed->hide(); - - label_18->hide(); - comboBox_netEngineVersion->hide(); +// label_36->hide(); +// spinBox_netGameSpeed->hide(); +// +// label_18->hide(); +// comboBox_netEngineVersion->hide(); } void settingsDialogImpl::exec() { @@ -110,9 +110,8 @@ void settingsDialogImpl::exec() { spinBox_netStartCash->setValue(myConfig->readConfigInt("NetStartCash")); spinBox_netSmallBlind->setValue(myConfig->readConfigInt("NetSmallBlind")); spinBox_netHandsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("NetHandsBeforeRaiseSmallBlind")); - //temporarely unused until ai is enabled in network -// spinBox_netGameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed")); -// comboBox_netEngineVersion->setCurrentIndex(myConfig->readConfigInt("NetEngineVersion")); + spinBox_netGameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed")); + comboBox_netEngineVersion->setCurrentIndex(myConfig->readConfigInt("NetEngineVersion")); spinBox_netTimeOutPlayerAction->setValue(myConfig->readConfigInt("NetTimeOutPlayerAction")); spinBox_serverPort->setValue(myConfig->readConfigInt("ServerPort")); lineEdit_serverPassword->setText(QString::fromUtf8(myConfig->readConfigString("ServerPassword").c_str())); @@ -194,9 +193,8 @@ void settingsDialogImpl::isAccepted() { myConfig->writeConfigInt("NetStartCash", spinBox_netStartCash->value()); myConfig->writeConfigInt("NetSmallBlind", spinBox_netSmallBlind->value()); myConfig->writeConfigInt("NetHandsBeforeRaiseSmallBlind", spinBox_netHandsBeforeRaiseSmallBlind->value()); - //temporarely unused until ai is enabled in network -// myConfig->writeConfigInt("NetGameSpeed", spinBox_netGameSpeed->value()); -// myConfig->writeConfigInt("NetEngineVersion", comboBox_netEngineVersion->currentIndex()); + myConfig->writeConfigInt("NetGameSpeed", spinBox_netGameSpeed->value()); + myConfig->writeConfigInt("NetEngineVersion", comboBox_netEngineVersion->currentIndex()); myConfig->writeConfigInt("NetTimeOutPlayerAction", spinBox_netTimeOutPlayerAction->value()); myConfig->writeConfigInt("ServerPort", spinBox_serverPort->value()); myConfig->writeConfigString("ServerPassword", lineEdit_serverPassword->text().toUtf8().constData());