From 37c8ed55d559bc7719d7056ffc40929ff56b6fa2 Mon Sep 17 00:00:00 2001 From: doitux Date: Wed, 17 Jan 2007 23:57:41 +0000 Subject: [PATCH] --- src/gui/qt/configfile.cpp | 15 +- src/gui/qt/mainwindowimpl.cpp | 8 + src/gui/qt/newgamedialogimpl.cpp | 13 + src/gui/qt/settingsdialog.ui | 648 ++++++++++++++---------------- src/gui/qt/settingsdialogimpl.cpp | 49 +++ src/gui/qt/settingsdialogimpl.h | 4 + 6 files changed, 392 insertions(+), 345 deletions(-) diff --git a/src/gui/qt/configfile.cpp b/src/gui/qt/configfile.cpp index f2517528..646b5ea5 100644 --- a/src/gui/qt/configfile.cpp +++ b/src/gui/qt/configfile.cpp @@ -33,7 +33,7 @@ QString ConfigFile::readConfig(QString varName, QString defaultvalue) { QDir configDir; - configDir.setPath(QDir::home().absPath()+"/.pokerth/config/"); + configDir.setPath(QDir::home().absPath()+"/.pokerth/"); QFile configFile (configDir.absPath()+"/pokerth.conf"); @@ -48,13 +48,14 @@ QString ConfigFile::readConfig(QString varName, QString defaultvalue) stream << "\n"; stream << "numberofplayers=5\n"; stream << "startcash=2000\n"; - stream << "smallblind=2000\n"; + stream << "smallblind=10\n"; stream << "gamespeed=4\n"; + stream << "showgamesettingsdialogonnewgame=1\n"; stream << "myname=Human Player\n"; - stream << "player1=Player 1\n"; - stream << "player2=Player 2\n"; - stream << "player3=Player 3\n"; - stream << "player4=Player 4\n"; + stream << "oppponent1name=Player 1\n"; + stream << "oppponent2name=Player 2\n"; + stream << "oppponent3name=Player 3\n"; + stream << "oppponent4name=Player 4\n"; configFile.close(); } @@ -116,7 +117,7 @@ QString ConfigFile::readConfig(QString varName, QString defaultvalue) void ConfigFile::writeConfig(QString setVarName, QString setVarCont) { QDir configDir; - configDir.setPath(QDir::home().absPath()+"/.pokerth/config/"); + configDir.setPath(QDir::home().absPath()+"/.pokerth/"); QFile configFile (configDir.absPath()+"/pokerth.conf"); QStringList lines; diff --git a/src/gui/qt/mainwindowimpl.cpp b/src/gui/qt/mainwindowimpl.cpp index 6b8d2363..df61a4f3 100755 --- a/src/gui/qt/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindowimpl.cpp @@ -51,6 +51,14 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent, const char *name) QFont tmpFont("Nimbus Sans L",9); QApplication::setFont(tmpFont); + // Programmverzeichnis erstellen + QDir progDir1; + QDir progDir2; + progDir1.setPath(QDir::home().absPath()+"/.pokerth/"); + + if ( !progDir1.exists() ) { progDir1.mkdir(progDir1.absPath()); } + + setupUi(this); int i; diff --git a/src/gui/qt/newgamedialogimpl.cpp b/src/gui/qt/newgamedialogimpl.cpp index ff030281..e0e2cc2d 100755 --- a/src/gui/qt/newgamedialogimpl.cpp +++ b/src/gui/qt/newgamedialogimpl.cpp @@ -18,6 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "newgamedialogimpl.h" +#include "configfile.h" newGameDialogImpl::newGameDialogImpl(QWidget *parent, const char *name) : QDialog(parent, name) @@ -25,5 +26,17 @@ newGameDialogImpl::newGameDialogImpl(QWidget *parent, const char *name) setupUi(this); + //Formulare Füllen + ConfigFile config; + + bool ok=TRUE; + + //Game Settings + spinBox_quantityPlayers->setValue(config.readConfig("numberofplayers", "5").toInt(&ok,10)); + spinBox_startCash->setValue(config.readConfig("startcash", "2000").toInt(&ok,10)); + spinBox_smallBlind->setValue(config.readConfig("smallblind", "10").toInt(&ok,10)); + spinBox_gameSpeed->setValue(config.readConfig("gamespeed", "4").toInt(&ok,10)); + + } diff --git a/src/gui/qt/settingsdialog.ui b/src/gui/qt/settingsdialog.ui index 60f1ba0c..7198533b 100644 --- a/src/gui/qt/settingsdialog.ui +++ b/src/gui/qt/settingsdialog.ui @@ -12,349 +12,321 @@ PokerTH - Settings - - - - 9 - 9 - 150 - 279 - + + + 9 - - - 150 - 16777215 - + + 6 - - - Game Settings - + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + - - - Log - + + + + + 150 + 16777215 + + + + + Game Settings + + + + + Log + + + + + Player Nicks + + + - - - Player Nicks - + + + + 0 + + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + show game settings dialog on every new game + + + + + + + Start Cash + + + + + + + 500 + + + 5 + + + + + + + Game-Speed + + + + + + + 5000 + + + 1000 + + + + + + + Small Blind + + + + + + + 11 + + + 1 + + + 1 + + + + + + + 5 + + + 2 + + + + + + + Number of Players + + + + + + + Qt::Horizontal + + + + + + + + 75 + true + + + + Game Settings + + + + + + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + + + + + 75 + true + + + + Log Settings + + + + + + + + + 9 + + + 6 + + + + + + 75 + true + + + + Player Nicks + + + + + + + Qt::Vertical + + + + 295 + 51 + + + + + + + + Human Player: + + + + + + + Opponent 2: + + + + + + + Opponent 4: + + + + + + + Opponent 3: + + + + + + + Opponent 1: + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + - - - - - 9 - 294 - 469 - 16 - - - - Qt::Horizontal - - - - - - 9 - 303 - 469 - 27 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok - - - - - - 165 - 9 - 313 - 256 - - - - 0 - - - - - 9 + + + + Qt::Horizontal - - 6 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - show game settings dialog on every new game - - - - - - - Start Cash - - - - - - - 500 - - - 5 - - - 10 - - - - - - - Game-Speed - - - - - - - 5000 - - - 1000 - - - 2000 - - - - - - - Small Blind - - - - - - - 11 - - - 1 - - - 1 - - - 4 - - - - - - - 5 - - - 2 - - - 5 - - - - - - - Number of Players - - - - - - - Qt::Horizontal - - - - - - - - 75 - true - - - - Default Game Settings - - - - - - - - - 9 - - - 6 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - - - - - - 75 - true - - - - Log Settings - - - - - - - - - 9 - - - 6 - - - - - - 75 - true - - - - Player Nicks - - - - - - - Qt::Vertical - - - - 295 - 51 - - - - - - - - Human Player: - - - - - - - Opponent 2: - - - - - - - Opponent 4: - - - - - - - Opponent 3: - - - - - - - Opponent 1: - - - - - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - - - - - + + + @@ -362,7 +334,7 @@ buttonBox accepted() settingsDialog - accept() + hide() 227 diff --git a/src/gui/qt/settingsdialogimpl.cpp b/src/gui/qt/settingsdialogimpl.cpp index 56558c62..7fae1219 100644 --- a/src/gui/qt/settingsdialogimpl.cpp +++ b/src/gui/qt/settingsdialogimpl.cpp @@ -18,11 +18,60 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "settingsdialogimpl.h" +#include "configfile.h" +#include + settingsDialogImpl::settingsDialogImpl(QWidget *parent, const char *name) : QDialog(parent, name) { setupUi(this); + + //Formulare Füllen + ConfigFile config; + + bool ok=TRUE; + + //Player Nicks + lineEdit_humanPlayerName->setText(config.readConfig("myname", "Human Player")); + lineEdit_Opponent1Name->setText(config.readConfig("oppponent1name", "Player 1")); + lineEdit_Opponent2Name->setText(config.readConfig("oppponent2name", "Player 2")); + lineEdit_Opponent3Name->setText(config.readConfig("oppponent3name", "Player 3")); + lineEdit_Opponent4Name->setText(config.readConfig("oppponent4name", "Player 4")); + + //Game Settings + spinBox_quantityPlayers->setValue(config.readConfig("numberofplayers", "5").toInt(&ok,10)); + spinBox_startCash->setValue(config.readConfig("startcash", "2000").toInt(&ok,10)); + spinBox_smallBlind->setValue(config.readConfig("smallblind", "10").toInt(&ok,10)); + spinBox_gameSpeed->setValue(config.readConfig("gamespeed", "4").toInt(&ok,10)); + checkBox_showGameSettingsDialogOnNewGame->setChecked(config.readConfig("showgamesettingsdialogonnewgame", "1").toInt(&ok,10)); + + connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); + +} + + +void settingsDialogImpl::accept() { + + std::cout << "wursst" << "\n"; + + //Daten speichern + ConfigFile config; + + //Player Nicks + config.writeConfig("myname", lineEdit_humanPlayerName->text()); + config.writeConfig("oppponent1name", lineEdit_Opponent1Name->text()); + config.writeConfig("oppponent2name", lineEdit_Opponent2Name->text()); + config.writeConfig("oppponent3name", lineEdit_Opponent3Name->text()); + config.writeConfig("oppponent4name", lineEdit_Opponent4Name->text()); + + //Game Settings + config.writeConfig("numberofplayers", QString::number(spinBox_quantityPlayers->value(),10)); + config.writeConfig("startcash", QString::number(spinBox_startCash->value(),10)); + config.writeConfig("smallblind", QString::number(spinBox_smallBlind->value(),10)); + config.writeConfig("gamespeed", QString::number(spinBox_gameSpeed->value(),10)); + config.writeConfig("showgamesettingsdialogonnewgame", QString::number(checkBox_showGameSettingsDialogOnNewGame->isChecked(),10)); + } diff --git a/src/gui/qt/settingsdialogimpl.h b/src/gui/qt/settingsdialogimpl.h index 36d6a254..3663ec2f 100644 --- a/src/gui/qt/settingsdialogimpl.h +++ b/src/gui/qt/settingsdialogimpl.h @@ -27,6 +27,10 @@ class settingsDialogImpl: public QDialog, public Ui::settingsDialog { Q_OBJECT public: settingsDialogImpl(QWidget *parent = 0, const char *name = 0); + +public slots: + + void accept(); }; #endif