From 95859c85de4745d85d0af0cf260c758386224020 Mon Sep 17 00:00:00 2001 From: doitux Date: Wed, 17 Jan 2007 20:59:34 +0000 Subject: [PATCH] --- pokerth.pro | 4 +- src/gui/qt/configfile.cpp | 146 +++++++++ src/gui/qt/configfile.h | 39 +++ src/gui/qt/mainwindowimpl.cpp | 4 + src/gui/qt/settingsdialog.ui | 555 ++++++++++++++++++++-------------- src/pokerth.cpp | 9 - 6 files changed, 526 insertions(+), 231 deletions(-) create mode 100644 src/gui/qt/configfile.cpp create mode 100644 src/gui/qt/configfile.h diff --git a/pokerth.pro b/pokerth.pro index 56cd8b30..31ea3069 100755 --- a/pokerth.pro +++ b/pokerth.pro @@ -14,6 +14,7 @@ HEADERS += mainwindowimpl.h \ newgamedialogimpl.h \ aboutpokerthimpl.h \ settingsdialogimpl.h \ + configfile.h \ log.h \ guiinterface.h \ guiwrapper.h \ @@ -36,13 +37,14 @@ HEADERS += mainwindowimpl.h \ turninterface.h \ riverinterface.h \ enginefactory.h \ - localenginefactory.h + localenginefactory.h SOURCES += pokerth.cpp \ mainwindowimpl.cpp \ newgamedialogimpl.cpp \ aboutpokerthimpl.cpp \ settingsdialogimpl.cpp \ + configfile.cpp \ log.cpp \ guiinterface.cpp \ guiwrapper.cpp \ diff --git a/src/gui/qt/configfile.cpp b/src/gui/qt/configfile.cpp new file mode 100644 index 00000000..f2517528 --- /dev/null +++ b/src/gui/qt/configfile.cpp @@ -0,0 +1,146 @@ +/*************************************************************************** + * Copyright (C) 2006 by Felix Hammer * + * f.hammer@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 "configfile.h" + +ConfigFile::ConfigFile() +{ +} + + +ConfigFile::~ConfigFile() +{ +} + + +QString ConfigFile::readConfig(QString varName, QString defaultvalue) +{ + + QDir configDir; + configDir.setPath(QDir::home().absPath()+"/.pokerth/config/"); + + QFile configFile (configDir.absPath()+"/pokerth.conf"); + + if ( !configFile.exists() ) { + configFile.open( QIODevice::WriteOnly ); + QTextStream stream( &configFile ); + stream << "##################################################################################### \n"; + stream << "# # \n"; + stream << "# This is the config-file for Pokerth - Please do not edit # \n"; + stream << "# # \n"; + stream << "##################################################################################### \n"; + stream << "\n"; + stream << "numberofplayers=5\n"; + stream << "startcash=2000\n"; + stream << "smallblind=2000\n"; + stream << "gamespeed=4\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"; + configFile.close(); + } + + QString tempstring; + QString line; + int foundvarname(0); + + configFile.open( QIODevice::ReadOnly ); + QTextStream readStream( &configFile ); + while ( !readStream.atEnd() ) { + line = readStream.readLine(); + if ( line.section( "=", 0, 0 ) == varName ) { + tempstring = line.section( "=", 1, 1 ); + foundvarname++; + } + } + configFile.close(); + + if (foundvarname == 0) { + + QDir configDir; + configDir.setPath(QDir::home().absPath()+"/.pokerth/config/"); + + QFile configFile (configDir.absPath()+"/pokerth.conf"); + + QStringList lines; + QString line; + QString listtemp; + + if ( configFile.open( QIODevice::ReadOnly ) ) { + QTextStream stream( &configFile ); + while ( !stream.atEnd() ) { + line = stream.readLine(); + lines += line; + + } + configFile.close(); + } + + if ( configFile.open( QIODevice::WriteOnly ) ) { + + QTextStream stream( &configFile ); + + for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { + stream << *it << "\n"; + } + stream << varName+"="+defaultvalue+"\n"; + configFile.close(); + } + + tempstring = defaultvalue; + + } + + return tempstring; + + } + +void ConfigFile::writeConfig(QString setVarName, QString setVarCont) + { + QDir configDir; + configDir.setPath(QDir::home().absPath()+"/.pokerth/config/"); + QFile configFile (configDir.absPath()+"/pokerth.conf"); + + QStringList lines; + QString line; + QString listtemp; + + if ( configFile.open( QIODevice::ReadOnly ) ) { + QTextStream stream( &configFile ); + while ( !stream.atEnd() ) { + line = stream.readLine(); + lines += line; + } + configFile.close(); + } + + listtemp = lines.grep(QRegExp("^"+setVarName)).join(""); + lines.gres(listtemp,setVarName+"="+setVarCont); + + if ( configFile.open( QIODevice::WriteOnly ) ) { + QTextStream stream( &configFile ); + for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { + stream << *it << "\n"; + } + configFile.close(); + } + +} diff --git a/src/gui/qt/configfile.h b/src/gui/qt/configfile.h new file mode 100644 index 00000000..ab4818cd --- /dev/null +++ b/src/gui/qt/configfile.h @@ -0,0 +1,39 @@ +/*************************************************************************** + * Copyright (C) 2006 by Felix Hammer * + * f.hammer@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 CONFIGFILE_H +#define CONFIGFILE_H + +#include "QtCore" + +class ConfigFile{ +public: + ConfigFile(); + + ~ConfigFile(); + + void writeConfig(QString setVarName, QString setVarCont); + QString readConfig(QString varName, QString defaultvalue); + +private: + + +}; + +#endif diff --git a/src/gui/qt/mainwindowimpl.cpp b/src/gui/qt/mainwindowimpl.cpp index 09a1ae8e..6b8d2363 100755 --- a/src/gui/qt/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindowimpl.cpp @@ -46,6 +46,10 @@ using namespace std; mainWindowImpl::mainWindowImpl(QMainWindow *parent, const char *name) : QMainWindow(parent, name), actualGame(0), actualHand(0), mySession(0), maxQuantityPlayers(maxQuantityPlayersConst), gameSpeed(0), debugMode(0), breakAfterActualHand(FALSE) { +// Schriftart laden + QFontDatabase::addApplicationFont ("src/gui/qt/n019003l.pfb"); + QFont tmpFont("Nimbus Sans L",9); + QApplication::setFont(tmpFont); setupUi(this); diff --git a/src/gui/qt/settingsdialog.ui b/src/gui/qt/settingsdialog.ui index d49f304a..60f1ba0c 100644 --- a/src/gui/qt/settingsdialog.ui +++ b/src/gui/qt/settingsdialog.ui @@ -12,236 +12,349 @@ PokerTH - Settings - - - 9 + + + + 9 + 9 + 150 + 279 + - - 6 + + + 150 + 16777215 + - - - - 0 - - - - - 9 - - - 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 - - - - - - - - + + + Game Settings + - - - - - 150 - 16777215 - + + + Log + + + + + Player Nicks + + + + + + + 9 + 294 + 469 + 16 + + + + Qt::Horizontal + + + + + + 9 + 303 + 469 + 27 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + 165 + 9 + 313 + 256 + + + + 0 + + + + + 9 - - - Game Settings - + + 6 + + + + + Qt::Vertical + + + + 20 + 40 + + + - - - Log - + + + + show game settings dialog on every new game + + - - - - - - Qt::Horizontal + + + + 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 - - - - - - Qt::Horizontal + + 6 - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + 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 + + + + + + + diff --git a/src/pokerth.cpp b/src/pokerth.cpp index 8fbfb318..5f023a89 100755 --- a/src/pokerth.cpp +++ b/src/pokerth.cpp @@ -22,8 +22,6 @@ /////// can be removed for non-qt-guis //////////// #include -#include -#include /////////////////////////////////////////////////// #include "session.h" @@ -39,13 +37,6 @@ int main( int argc, char **argv ) /////// can be removed for non-qt-guis //////////// QApplication a( argc, argv ); - - //Schriftart laden - QFontDatabase::addApplicationFont ("src/gui/qt/n019003l.pfb"); - QFont tmpFont("Nimbus Sans L",9); - QApplication::setFont(tmpFont); - - Q_INIT_RESOURCE(deck); ///////////////////////////////////////////////////