This commit is contained in:
doitux
2007-01-17 20:59:34 +00:00
parent 997af59e67
commit 95859c85de
6 changed files with 526 additions and 231 deletions
+2
View File
@@ -14,6 +14,7 @@ HEADERS += mainwindowimpl.h \
newgamedialogimpl.h \
aboutpokerthimpl.h \
settingsdialogimpl.h \
configfile.h \
log.h \
guiinterface.h \
guiwrapper.h \
@@ -43,6 +44,7 @@ SOURCES += pokerth.cpp \
newgamedialogimpl.cpp \
aboutpokerthimpl.cpp \
settingsdialogimpl.cpp \
configfile.cpp \
log.cpp \
guiinterface.cpp \
guiwrapper.cpp \
+146
View File
@@ -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();
}
}
+39
View File
@@ -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
+4
View File
@@ -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);
+144 -31
View File
@@ -12,15 +12,75 @@
<property name="windowTitle" >
<string>PokerTH - Settings</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
<widget class="QListWidget" name="listWidget" >
<property name="geometry" >
<rect>
<x>9</x>
<y>9</y>
<width>150</width>
<height>279</height>
</rect>
</property>
<property name="spacing" >
<number>6</number>
<property name="maximumSize" >
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<item row="0" column="1" >
<item>
<property name="text" >
<string>Game Settings</string>
</property>
</item>
<item>
<property name="text" >
<string>Log</string>
</property>
</item>
<item>
<property name="text" >
<string>Player Nicks</string>
</property>
</item>
</widget>
<widget class="Line" name="line" >
<property name="geometry" >
<rect>
<x>9</x>
<y>294</y>
<width>469</width>
<height>16</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="geometry" >
<rect>
<x>9</x>
<y>303</y>
<width>469</width>
<height>27</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QStackedWidget" name="stackedWidget" >
<property name="geometry" >
<rect>
<x>165</x>
<y>9</y>
<width>313</width>
<height>256</height>
</rect>
</property>
<property name="currentIndex" >
<number>0</number>
</property>
@@ -200,49 +260,102 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_4" />
<widget class="QWidget" name="page_2" />
<widget class="QWidget" name="page_4" >
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="label_7" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Player Nicks</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QListWidget" name="listWidget" >
<property name="maximumSize" >
<item row="7" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>150</width>
<height>16777215</height>
<width>295</width>
<height>51</height>
</size>
</property>
<item>
<property name="text" >
<string>Game Settings</string>
</property>
</spacer>
</item>
<item>
<item row="2" column="0" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<string>Log</string>
<string>Human Player:</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_10" >
<property name="text" >
<string>Opponent 2:</string>
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="label_12" >
<property name="text" >
<string>Opponent 4:</string>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label_11" >
<property name="text" >
<string>Opponent 3:</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_9" >
<property name="text" >
<string>Opponent 1:</string>
</property>
</widget>
</item>
<item row="6" column="1" >
<widget class="QLineEdit" name="lineEdit_3" />
</item>
<item row="5" column="1" >
<widget class="QLineEdit" name="lineEdit_5" />
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="lineEdit_4" />
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="lineEdit_2" />
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="lineEdit" />
</item>
<item row="1" column="0" colspan="2" >
<widget class="Line" name="line" >
<widget class="Line" name="line_4" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2" />
</widget>
</widget>
<resources/>
<connections>
<connection>
-9
View File
@@ -22,8 +22,6 @@
/////// can be removed for non-qt-guis ////////////
#include <qapplication.h>
#include <QFont>
#include <QFontDatabase>
///////////////////////////////////////////////////
#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);
///////////////////////////////////////////////////