Back to rev. 347

This commit is contained in:
lotodore
2007-04-20 23:14:08 +00:00
parent 57927b7d73
commit a8cce94d3b
32 changed files with 315 additions and 333 deletions
+6 -14
View File
@@ -15,8 +15,6 @@ DEPENDPATH += . \
src/engine/local_engine \ src/engine/local_engine \
src/gui/qt \ src/gui/qt \
src/net/common \ src/net/common \
src/gui/qt/qttools \
src/gui/qt/qttools/appdirpath \
src/gui/qt/mainwindow \ src/gui/qt/mainwindow \
src/gui/qt/mainwindow/startsplash \ src/gui/qt/mainwindow/startsplash \
src/gui/qt/aboutpokerth \ src/gui/qt/aboutpokerth \
@@ -24,7 +22,7 @@ DEPENDPATH += . \
src/gui/qt/createnetworkgamedialog \ src/gui/qt/createnetworkgamedialog \
src/gui/qt/joinnetworkgamedialog \ src/gui/qt/joinnetworkgamedialog \
src/gui/qt/log \ src/gui/qt/log \
src/gui/qt/defaultconfig \ src/gui/qt/qthelper \
src/gui/qt/newlocalgamedialog \ src/gui/qt/newlocalgamedialog \
src/gui/qt/settingsdialog \ src/gui/qt/settingsdialog \
src/gui/qt/startnetworkgamedialog \ src/gui/qt/startnetworkgamedialog \
@@ -39,11 +37,9 @@ INCLUDEPATH += . \
src/core/tinyxml \ src/core/tinyxml \
src/gui/qt \ src/gui/qt \
src/gui/qt/log \ src/gui/qt/log \
src/gui/qt/defaultconfig \ src/gui/qt/qthelper \
src/gui/qt/connecttoserverdialog \ src/gui/qt/connecttoserverdialog \
src/core \ src/core \
src/gui/qt/qttools \
src/gui/qt/qttools/appdirpath \
src/gui/qt/mainwindow \ src/gui/qt/mainwindow \
src/gui/qt/mainwindow/startsplash \ src/gui/qt/mainwindow/startsplash \
src/gui/qt/aboutpokerth \ src/gui/qt/aboutpokerth \
@@ -68,7 +64,6 @@ HEADERS += src/game.h \
src/engine/riverinterface.h \ src/engine/riverinterface.h \
src/engine/turninterface.h \ src/engine/turninterface.h \
src/gui/guiinterface.h \ src/gui/guiinterface.h \
src/gui/qttoolsinterface.h \
src/net/clientcallback.h \ src/net/clientcallback.h \
src/net/clientcontext.h \ src/net/clientcontext.h \
src/net/clientexception.h \ src/net/clientexception.h \
@@ -94,8 +89,6 @@ HEADERS += src/game.h \
src/engine/local_engine/localriver.h \ src/engine/local_engine/localriver.h \
src/engine/local_engine/localturn.h \ src/engine/local_engine/localturn.h \
src/engine/local_engine/tools.h \ src/engine/local_engine/tools.h \
src/gui/qt/qttools/qttoolswrapper.h \
src/gui/qt/qttools/appdirpath/appdirpath.h \
src/gui/qt/mainwindow/mainwindowimpl.h \ src/gui/qt/mainwindow/mainwindowimpl.h \
src/gui/qt/mainwindow/mycardspixmaplabel.h \ src/gui/qt/mainwindow/mycardspixmaplabel.h \
src/gui/qt/mainwindow/startsplash/startsplash.h \ src/gui/qt/mainwindow/startsplash/startsplash.h \
@@ -108,7 +101,8 @@ HEADERS += src/game.h \
src/gui/qt/newlocalgamedialog/newgamedialogimpl.h \ src/gui/qt/newlocalgamedialog/newgamedialogimpl.h \
src/gui/qt/settingsdialog/settingsdialogimpl.h \ src/gui/qt/settingsdialog/settingsdialogimpl.h \
src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h \ src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h \
src/gui/qt/waitforservertostartgamedialog/waitforservertostartgamedialogimpl.h src/gui/qt/waitforservertostartgamedialog/waitforservertostartgamedialogimpl.h \
src/gui/qt/qthelper/qthelper.h
FORMS += src/gui/qt/mainwindow.ui \ FORMS += src/gui/qt/mainwindow.ui \
src/gui/qt/aboutpokerth.ui \ src/gui/qt/aboutpokerth.ui \
src/gui/qt/connecttoserverdialog.ui \ src/gui/qt/connecttoserverdialog.ui \
@@ -131,7 +125,6 @@ SOURCES += src/game.cpp \
src/engine/riverinterface.cpp \ src/engine/riverinterface.cpp \
src/engine/turninterface.cpp \ src/engine/turninterface.cpp \
src/gui/guiinterface.cpp \ src/gui/guiinterface.cpp \
src/gui/qttoolsinterface.cpp \
src/core/common/thread.cpp \ src/core/common/thread.cpp \
src/core/tinyxml/tinystr.cpp \ src/core/tinyxml/tinystr.cpp \
src/core/tinyxml/tinyxml.cpp \ src/core/tinyxml/tinyxml.cpp \
@@ -169,8 +162,6 @@ SOURCES += src/game.cpp \
src/net/common/netexception.cpp \ src/net/common/netexception.cpp \
src/net/common/receiverhelper.cpp \ src/net/common/receiverhelper.cpp \
src/gui/qt/guiwrapper.cpp \ src/gui/qt/guiwrapper.cpp \
src/gui/qt/qttools/qttoolswrapper.cpp \
src/gui/qt/qttools/appdirpath/appdirpath.cpp \
src/gui/qt/mainwindow/mainwindowimpl.cpp \ src/gui/qt/mainwindow/mainwindowimpl.cpp \
src/gui/qt/mainwindow/mycardspixmaplabel.cpp \ src/gui/qt/mainwindow/mycardspixmaplabel.cpp \
src/gui/qt/mainwindow/startsplash/startsplash.cpp \ src/gui/qt/mainwindow/startsplash/startsplash.cpp \
@@ -182,7 +173,8 @@ SOURCES += src/game.cpp \
src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp \ src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp \
src/gui/qt/settingsdialog/settingsdialogimpl.cpp \ src/gui/qt/settingsdialog/settingsdialogimpl.cpp \
src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp \ src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp \
src/gui/qt/waitforservertostartgamedialog/waitforservertostartgamedialogimpl.cpp src/gui/qt/waitforservertostartgamedialog/waitforservertostartgamedialogimpl.cpp \
src/gui/qt/qthelper/qthelper.cpp
RESOURCES += src/gui/qt/resources.qrc RESOURCES += src/gui/qt/resources.qrc
TEMPLATE = vcapp TEMPLATE = vcapp
+71 -44
View File
@@ -32,60 +32,88 @@
using namespace std; using namespace std;
ConfigFile::ConfigFile(std::string path) ConfigFile::ConfigFile()
: myPath(path) {
{
// !!!! Revisionsnummer der Configdefaults !!!!! // !!!! Revisionsnummer der Configdefaults !!!!!
configRev = 17; configRev = 17;
// Pfad und Dateinamen setzen
#ifdef _WIN32 #ifdef _WIN32
//Programmordner erstellen const char *appDataPath = getenv("AppData");
myPath += "\\pokerth\\"; if (appDataPath && appDataPath[0] != 0) {
mkdir(myPath.c_str()); configFileName = appDataPath;
}
else {
const int MaxPathSize = 1024;
char curDir[MaxPathSize + 1];
curDir[0] = 0;
_getcwd(curDir, MaxPathSize);
curDir[MaxPathSize] = 0;
configFileName = curDir;
// Testen ob das Verzeichnis beschreibbar ist
ofstream tmpFile;
const char *tmpFileName = "pokerth_test.tmp";
tmpFile.open((configFileName + "\\" + tmpFileName).c_str());
if (tmpFile) {
// Erfolgreich, Verzeichnis beschreibbar.
// Datei wieder loeschen.
tmpFile.close();
remove((configFileName + "\\" + tmpFileName).c_str());
}
else {
// Fehlgeschlagen, Verzeichnis nicht beschreibbar
curDir[0] = 0;
GetTempPathA(MaxPathSize, curDir);
curDir[MaxPathSize] = 0;
configFileName = curDir;
}
}
//Programmordner erstellen
configFileName += "\\pokerth\\";
mkdir(configFileName.c_str());
//Log-File Ordner auch erstellen //Log-File Ordner auch erstellen
logDir = myPath; logDir = configFileName;
logDir += "log-files\\"; logDir += "log-files\\";
mkdir(logDir.c_str()); mkdir(logDir.c_str());
//data Ordner auch erstellen //data Ordner auch erstellen
dataDir = myPath; dataDir = configFileName;
dataDir += "data\\"; dataDir += "data\\";
mkdir(dataDir.c_str()); mkdir(dataDir.c_str());
#else #else
//Programmordner erstellen //Programmordner erstellen
myPath += "/.pokerth/"; const char *homePath = getenv("HOME");
mkdir(myPath.c_str(), MODUS) ; if(homePath) {
//Log-File Ordner auch erstellen configFileName = homePath;
logDir = myPath; configFileName += "/.pokerth/";
logDir += "log-files/"; mkdir(configFileName.c_str(), MODUS) ;
mkdir(logDir.c_str(), MODUS); //Log-File Ordner auch erstellen
//data Ordner auch erstellen logDir = configFileName;
dataDir = myPath; logDir += "log-files/";
dataDir += "data/"; mkdir(logDir.c_str(), MODUS);
mkdir(dataDir.c_str(), MODUS); //data Ordner auch erstellen
dataDir = configFileName;
dataDir += "data/";
mkdir(dataDir.c_str(), MODUS);
}
#endif #endif
configFileName += "config.xml";
myPath += "config.xml";
//Prüfen ob Configfile existiert --> sonst anlegen //Prüfen ob Configfile existiert --> sonst anlegen
TiXmlDocument doc(configFileName);
TiXmlDocument doc(myPath);
if(!doc.LoadFile()){ createDefaultConfig(); } if(!doc.LoadFile()){ createDefaultConfig(); }
else { else {
//Prüfen ob die Revision stimmt ansonsten löschen und neue anlegen //Prüfen ob die Revision stimmt ansonsten löschen und neue anlegen
int temp = 0; int temp = 0;
TiXmlHandle docHandle( &doc ); TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement();
if ( conf ) { conf->QueryIntAttribute("value", &temp ); } if ( conf ) { conf->QueryIntAttribute("value", &temp ); }
if (temp < configRev) { /*löschen()*/ createDefaultConfig() ;} if (temp < configRev) { /*löschen()*/ createDefaultConfig() ;}
} }
} }
ConfigFile::~ConfigFile() ConfigFile::~ConfigFile()
{ {
} }
@@ -243,17 +271,16 @@ void ConfigFile::createDefaultConfig() {
config->LinkEndChild( confElement31 ); config->LinkEndChild( confElement31 );
confElement31->SetAttribute("value", dataDir); confElement31->SetAttribute("value", dataDir);
doc.SaveFile( myPath ); doc.SaveFile( configFileName );
} }
string ConfigFile::readConfigString(string varName) string ConfigFile::readConfigString(string varName)
{ {
string tempString(""); string tempString("");
TiXmlDocument doc(myPath.c_str()); TiXmlDocument doc(configFileName);
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << myPath << "\n"; } if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; }
TiXmlHandle docHandle( &doc ); TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement();
@@ -267,7 +294,7 @@ string ConfigFile::readConfigString(string varName)
TiXmlElement * confElement1 = new TiXmlElement( varName ); TiXmlElement * confElement1 = new TiXmlElement( varName );
config->LinkEndChild( confElement1 ); config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", defaultValue); confElement1->SetAttribute("value", defaultValue);
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; } if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
return readConfigString(varName, defaultValue); return readConfigString(varName, defaultValue);
} }
@@ -280,8 +307,8 @@ int ConfigFile::readConfigInt(string varName)
{ {
int tempInt=0; int tempInt=0;
// cout << varName << " : " << tempInt << "\n"; // cout << varName << " : " << tempInt << "\n";
TiXmlDocument doc(myPath.c_str()); TiXmlDocument doc(configFileName);
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << myPath << "\n"; } if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; }
TiXmlHandle docHandle( &doc ); TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement();
@@ -296,7 +323,7 @@ int ConfigFile::readConfigInt(string varName)
TiXmlElement * confElement1 = new TiXmlElement( varName ); TiXmlElement * confElement1 = new TiXmlElement( varName );
config->LinkEndChild( confElement1 ); config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", defaultValue); confElement1->SetAttribute("value", defaultValue);
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; } if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
return readConfigInt(varName, defaultValue); return readConfigInt(varName, defaultValue);
} }
@@ -309,14 +336,14 @@ int ConfigFile::readConfigInt(string varName)
void ConfigFile::writeConfigInt(string varName, int varCont) void ConfigFile::writeConfigInt(string varName, int varCont)
{ {
TiXmlDocument doc(myPath.c_str()); TiXmlDocument doc(configFileName);
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << myPath << "\n"; } if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; }
TiXmlHandle docHandle( &doc ); TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement();
if ( conf ) { if ( conf ) {
conf->SetAttribute("value", varCont ); conf->SetAttribute("value", varCont );
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; } if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
} else { } else {
//Wenn nicht gefunden eines neues Anlegen //Wenn nicht gefunden eines neues Anlegen
TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement(); TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement();
@@ -327,17 +354,17 @@ void ConfigFile::writeConfigInt(string varName, int varCont)
config->LinkEndChild( confElement1 ); config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", varCont); confElement1->SetAttribute("value", varCont);
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; } if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
} }
} }
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; } if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
} }
void ConfigFile::writeConfigString(string varName, string varCont) void ConfigFile::writeConfigString(string varName, string varCont)
{ {
TiXmlDocument doc(myPath.c_str()); TiXmlDocument doc(configFileName);
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << myPath << "\n"; } if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; }
TiXmlHandle docHandle( &doc ); TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement();
@@ -350,10 +377,10 @@ void ConfigFile::writeConfigString(string varName, string varCont)
TiXmlElement * confElement1 = new TiXmlElement( varName ); TiXmlElement * confElement1 = new TiXmlElement( varName );
config->LinkEndChild( confElement1 ); config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", varCont); confElement1->SetAttribute("value", varCont);
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; } if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
} }
} }
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; } if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
} }
+6 -5
View File
@@ -25,7 +25,7 @@
class ConfigFile{ class ConfigFile{
public: public:
ConfigFile(std::string); ConfigFile();
~ConfigFile(); ~ConfigFile();
@@ -37,12 +37,13 @@ public:
int readConfigInt(std::string varName); int readConfigInt(std::string varName);
void writeConfigInt(std::string varName, int varCont); void writeConfigInt(std::string varName, int varCont);
private:
std::string myPath; private:
std::string logDir; std::string configFileName;
std::string dataDir; std::string logDir;
std::string dataDir;
int configRev; int configRev;
}; };
#endif #endif
+1 -2
View File
@@ -27,7 +27,6 @@
#include "flopinterface.h" #include "flopinterface.h"
#include "turninterface.h" #include "turninterface.h"
#include "riverinterface.h" #include "riverinterface.h"
#include "session.h"
class EngineFactory{ class EngineFactory{
@@ -37,7 +36,7 @@ public:
virtual HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) =0; virtual HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) =0;
virtual BoardInterface* createBoard() =0; virtual BoardInterface* createBoard() =0;
virtual PlayerInterface* createPlayer(Session*s, BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB) =0; virtual PlayerInterface* createPlayer(BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB) =0;
virtual PreflopInterface* createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) =0; virtual PreflopInterface* createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) =0;
virtual FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB) =0; virtual FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB) =0;
virtual TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB) =0; virtual TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB) =0;
@@ -35,7 +35,7 @@ HandInterface* LocalEngineFactory::createHand(EngineFactory *f, GuiInterface *g,
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; } BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
PlayerInterface* LocalEngineFactory::createPlayer(Session *s, BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB) { return new LocalPlayer(s, b, id, name, avatar, sC, aS, mB); } PlayerInterface* LocalEngineFactory::createPlayer(BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB) { return new LocalPlayer(b, id, name, avatar, sC, aS, mB); }
PreflopInterface* LocalEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalPreflop(hi, id, aP, dP, sB); } PreflopInterface* LocalEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalPreflop(hi, id, aP, dP, sB); }
+1 -2
View File
@@ -29,7 +29,6 @@
#include "localflop.h" #include "localflop.h"
#include "localturn.h" #include "localturn.h"
#include "localriver.h" #include "localriver.h"
#include "session.h"
class LocalEngineFactory : public EngineFactory class LocalEngineFactory : public EngineFactory
{ {
@@ -40,7 +39,7 @@ public:
HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC); HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC);
BoardInterface* createBoard(); BoardInterface* createBoard();
PlayerInterface* createPlayer(Session *s, BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB); PlayerInterface* createPlayer(BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB);
PreflopInterface* createPreflop(HandInterface* hi, int id, int aP, int dP, int sB); PreflopInterface* createPreflop(HandInterface* hi, int id, int aP, int dP, int sB);
FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB); FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB);
TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB); TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB);
+13 -11
View File
@@ -23,7 +23,7 @@
using namespace std; using namespace std;
LocalPlayer::LocalPlayer(Session *s, BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB) : PlayerInterface(), mySession(s), actualHand(0), actualBoard(b), myCardsValue(0), myConfig(0), myID(id), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), sBluff(0), sBluffStatus(0) LocalPlayer::LocalPlayer(BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB) : PlayerInterface(), actualHand(0), actualBoard(b), myCardsValue(0), myID(id), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), sBluff(0), sBluffStatus(0)
{ {
// for statistic development // for statistic development
@@ -32,9 +32,7 @@ LocalPlayer::LocalPlayer(Session *s, BoardInterface *b, int id, std::string name
// myCash=0; // myCash=0;
// } // }
//////////////////////////// ////////////////////////////
myConfig = new ConfigFile(mySession->getConfigPath());
// myBestHandPosition mit -1 initialisieren // myBestHandPosition mit -1 initialisieren
int i; int i;
for(i=0; i<5; i++) { for(i=0; i<5; i++) {
@@ -85,11 +83,12 @@ void LocalPlayer::setHand(HandInterface* br) { actualHand = br; }
void LocalPlayer::action() { void LocalPlayer::action() {
ConfigFile myConfig;
switch(actualHand->getActualRound()) { switch(actualHand->getActualRound()) {
case 0: { case 0: {
if(myConfig->readConfigInt("EngineVersion")) preflopEngine3(); if(myConfig.readConfigInt("EngineVersion")) preflopEngine3();
else preflopEngine(); else preflopEngine();
actualBoard->collectSets(); actualBoard->collectSets();
@@ -98,7 +97,7 @@ void LocalPlayer::action() {
} break; } break;
case 1: { case 1: {
if(myConfig->readConfigInt("EngineVersion")) flopEngine3(); if(myConfig.readConfigInt("EngineVersion")) flopEngine3();
else flopEngine(); else flopEngine();
actualBoard->collectSets(); actualBoard->collectSets();
@@ -107,7 +106,7 @@ void LocalPlayer::action() {
} break; } break;
case 2: { case 2: {
if(myConfig->readConfigInt("EngineVersion")) turnEngine3(); if(myConfig.readConfigInt("EngineVersion")) turnEngine3();
else turnEngine(); else turnEngine();
actualBoard->collectSets(); actualBoard->collectSets();
@@ -116,7 +115,7 @@ void LocalPlayer::action() {
} break; } break;
case 3: { case 3: {
if(myConfig->readConfigInt("EngineVersion")) riverEngine3(); if(myConfig.readConfigInt("EngineVersion")) riverEngine3();
else riverEngine(); else riverEngine();
actualBoard->collectSets(); actualBoard->collectSets();
@@ -810,6 +809,7 @@ void LocalPlayer::flopEngine() {
void LocalPlayer::turnEngine() { void LocalPlayer::turnEngine() {
ConfigFile myConfig;
// int tempArray[6]; // int tempArray[6];
// int boardCards[5]; // int boardCards[5];
@@ -1056,6 +1056,7 @@ void LocalPlayer::turnEngine() {
void LocalPlayer::riverEngine() { void LocalPlayer::riverEngine() {
ConfigFile myConfig;
// int tempArray[6]; // int tempArray[6];
// int boardCards[5]; // int boardCards[5];
@@ -2056,6 +2057,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
void LocalPlayer::readFile() { void LocalPlayer::readFile() {
ConfigFile myConfig;
int handCode; int handCode;
switch(actualHand->getActualRound()) { switch(actualHand->getActualRound()) {
@@ -2064,7 +2066,7 @@ void LocalPlayer::readFile() {
handCode = preflopCardsValue(myCards); handCode = preflopCardsValue(myCards);
std::string fileName = myConfig->readConfigString("DataDir")+"preflopValues"; std::string fileName = myConfig.readConfigString("DataDir")+"preflopValues";
ifstream fin; ifstream fin;
@@ -2118,7 +2120,7 @@ void LocalPlayer::readFile() {
// cout << "\t" << handCode << endl; // cout << "\t" << handCode << endl;
std::string fileName = myConfig->readConfigString("DataDir")+"flopValues"; std::string fileName = myConfig.readConfigString("DataDir")+"flopValues";
ifstream fin; ifstream fin;
+2 -4
View File
@@ -25,7 +25,6 @@
#include "cardsvalue.h" #include "cardsvalue.h"
#include "configfile.h" #include "configfile.h"
#include "session.h"
#include <string> #include <string>
#include <fstream> #include <fstream>
@@ -37,7 +36,7 @@ class BoardInterface;
class LocalPlayer : public PlayerInterface{ class LocalPlayer : public PlayerInterface{
public: public:
LocalPlayer(Session*, BoardInterface*, int, std::string, std::string, int, bool, int); LocalPlayer(BoardInterface*, int, std::string, std::string, int, bool, int);
~LocalPlayer(); ~LocalPlayer();
@@ -141,11 +140,10 @@ public:
private: private:
Session *mySession;
HandInterface *actualHand; HandInterface *actualHand;
BoardInterface *actualBoard; BoardInterface *actualBoard;
CardsValue *myCardsValue; CardsValue *myCardsValue;
ConfigFile *myConfig;
// Konstanten // Konstanten
int myID; int myID;
+2 -5
View File
@@ -28,16 +28,13 @@
#include "handinterface.h" #include "handinterface.h"
#include "configfile.h" #include "configfile.h"
#include "session.h"
using namespace std; using namespace std;
Game::Game(Session* s, GuiInterface* g, int qP, int sC, int sB, int gId) : mySession(s), myConfig(0), myGui(g), actualHand(0), actualBoard(0), startQuantityPlayers(qP), startCash(sC), startSmallBlind(sB), myGameID(gId), actualQuantityPlayers(qP), actualSmallBlind(sB), actualHandID(0), dealerPosition(0) Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB, int gId) : myConfig(c), myGui(g), actualHand(0), actualBoard(0), startQuantityPlayers(qP), startCash(sC), startSmallBlind(sB), myGameID(gId), actualQuantityPlayers(qP), actualSmallBlind(sB), actualHandID(0), dealerPosition(0)
{ {
// cout << "Create Game Object" << "\n"; // cout << "Create Game Object" << "\n";
int i; int i;
myConfig = new ConfigFile(mySession->getConfigPath());
actualHandID = 0; actualHandID = 0;
@@ -72,7 +69,7 @@ Game::Game(Session* s, GuiInterface* g, int qP, int sC, int sB, int gId) : mySes
else { myAvatar << "Opponent" << i << "Avatar"; } else { myAvatar << "Opponent" << i << "Avatar"; }
//PlayerObjekte erzeugen //PlayerObjekte erzeugen
tempPlayer = myFactory->createPlayer(mySession, actualBoard, i, myConfig->readConfigString(myName.str()), myConfig->readConfigString(myAvatar.str()), startCash, startQuantityPlayers > i, 0); tempPlayer = myFactory->createPlayer(actualBoard, i, myConfig->readConfigString(myName.str()), myConfig->readConfigString(myAvatar.str()), startCash, startQuantityPlayers > i, 0);
playerArray[i] = tempPlayer; playerArray[i] = tempPlayer;
} }
actualBoard->setPlayer(playerArray); actualBoard->setPlayer(playerArray);
+1 -4
View File
@@ -32,14 +32,12 @@ class PlayerInterface;
class BoardInterface; class BoardInterface;
class EngineFactory; class EngineFactory;
class ConfigFile; class ConfigFile;
class Session;
class Game { class Game {
public: public:
Game(Session*, GuiInterface*, int, int, int, int); Game(ConfigFile*, GuiInterface*, int, int, int, int);
~Game(); ~Game();
@@ -84,7 +82,6 @@ public:
private: private:
EngineFactory *myFactory; EngineFactory *myFactory;
Session *mySession;
ConfigFile *myConfig; ConfigFile *myConfig;
GuiInterface *myGui; GuiInterface *myGui;
+3 -1
View File
@@ -90,11 +90,13 @@ public:
// virtual void timerBlockerFalse() const=0; // virtual void timerBlockerFalse() const=0;
virtual void meInAction() const=0; virtual void meInAction() const=0;
//log.cpp //log.cpp
virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0; virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0;
virtual void logNewGameHandMsg(int gameID, int HandID) =0; virtual void logNewGameHandMsg(int gameID, int HandID) =0;
//qthelper.cpp
virtual std::string stringToUtf8(const std::string &) =0;
}; };
@@ -21,13 +21,11 @@
#include "session.h" #include "session.h"
#include "configfile.h" #include "configfile.h"
createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, std::string path) createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent)
: QDialog(parent), myConfig(0) : QDialog(parent)
{ {
myConfig = new ConfigFile(path); setupUi(this);
setupUi(this);
fillFormular(); fillFormular();
@@ -48,13 +46,14 @@ void createNetworkGameDialogImpl::cancel() {
void createNetworkGameDialogImpl::fillFormular() { void createNetworkGameDialogImpl::fillFormular() {
//Formulare Füllen //Formulare Füllen
ConfigFile myConfig;
//Network Game Settings //Network Game Settings
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NetNumberOfPlayers"));
spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); spinBox_startCash->setValue(myConfig.readConfigInt("NetStartCash"));
spinBox_smallBlind->setValue(myConfig->readConfigInt("NetSmallBlind")); spinBox_smallBlind->setValue(myConfig.readConfigInt("NetSmallBlind"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("NetHandsBeforeRaiseSmallBlind")); spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("NetHandsBeforeRaiseSmallBlind"));
spinBox_gameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed")); spinBox_gameSpeed->setValue(myConfig.readConfigInt("NetGameSpeed"));
} }
void createNetworkGameDialogImpl::showDialog() { void createNetworkGameDialogImpl::showDialog() {
@@ -23,18 +23,15 @@
#include "ui_createnetworkgamedialog.h" #include "ui_createnetworkgamedialog.h"
#include <iostream> #include <iostream>
#include <string>
#include <QtGui> #include <QtGui>
#include <QtCore> #include <QtCore>
class Session; class Session;
class ConfigFile;
class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog { class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog {
Q_OBJECT Q_OBJECT
public: public:
createNetworkGameDialogImpl(QWidget *parent = 0, std::string = ""); createNetworkGameDialogImpl(QWidget *parent = 0);
public slots: public slots:
@@ -43,10 +40,6 @@ public slots:
void fillFormular(); void fillFormular();
void showDialog(); void showDialog();
void keyPressEvent ( QKeyEvent * event ); void keyPressEvent ( QKeyEvent * event );
private:
ConfigFile *myConfig;
}; };
#endif #endif
+9 -3
View File
@@ -24,13 +24,16 @@
using namespace std; using namespace std;
GuiWrapper::GuiWrapper(Session *session) : myLog(0), myW(0) GuiWrapper::GuiWrapper() : myLog(0), myW(0)
{ {
myW = new mainWindowImpl(session);
myW = new mainWindowImpl;
myW->show(); myW->show();
myLog = new Log(myW); myLog = new Log(myW);
myConfig = new ConfigFile;
} }
@@ -85,6 +88,9 @@ void GuiWrapper::meInAction() const { myW->meInAction(); }
void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->logPlayerActionMsg(playerName, action, setValue); } void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->logPlayerActionMsg(playerName, action, setValue); }
void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->logNewGameHandMsg(gameID, handID); } void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->logNewGameHandMsg(gameID, handID); }
std::string GuiWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); }
void GuiWrapper::SignalNetClientConnect(int actionID) { myW->SignalNetClientConnect(actionID); } void GuiWrapper::SignalNetClientConnect(int actionID) { myW->SignalNetClientConnect(actionID); }
void GuiWrapper::SignalNetClientGameInfo(int actionID) { myW->SignalNetClientGameInfo(actionID); } void GuiWrapper::SignalNetClientGameInfo(int actionID) { myW->SignalNetClientGameInfo(actionID); }
void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->SignalNetClientError(errorID, osErrorID); } void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->SignalNetClientError(errorID, osErrorID); }
+6 -1
View File
@@ -25,6 +25,7 @@
#include "log.h" #include "log.h"
#include "mainwindowimpl.h" #include "mainwindowimpl.h"
#include "connecttoserverdialogimpl.h" #include "connecttoserverdialogimpl.h"
#include "qthelper.h"
#include "configfile.h" #include "configfile.h"
#include <string> #include <string>
@@ -38,7 +39,7 @@
class GuiWrapper : public GuiInterface class GuiWrapper : public GuiInterface
{ {
public: public:
GuiWrapper(Session*); GuiWrapper();
~GuiWrapper(); ~GuiWrapper();
@@ -88,6 +89,8 @@ public:
void logPlayerActionMsg(std::string playerName, int action, int setValue) ; void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
void logNewGameHandMsg(int gameID, int handID) ; void logNewGameHandMsg(int gameID, int handID) ;
std::string stringToUtf8(const std::string &);
void SignalNetClientConnect(int actionID); void SignalNetClientConnect(int actionID);
void SignalNetClientGameInfo(int actionID); void SignalNetClientGameInfo(int actionID);
void SignalNetClientError(int errorID, int osErrorID); void SignalNetClientError(int errorID, int osErrorID);
@@ -100,6 +103,8 @@ private:
Log *myLog; Log *myLog;
mainWindowImpl *myW; mainWindowImpl *myW;
ConfigFile *myConfig;
QtHelper *myQtHelper;
}; };
@@ -24,12 +24,11 @@
using namespace std; using namespace std;
joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent, std::string path) joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent)
: QDialog(parent), myConfig(0) : QDialog(parent)
{ {
myConfig = new ConfigFile(path);
setupUi(this);
setupUi(this);
//Profile Name darf nicht mit einer Zahl beginnen --> XML konform //Profile Name darf nicht mit einer Zahl beginnen --> XML konform
QRegExp rx("[A-Z|a-z]+[A-Z|a-z|\\d]*"); QRegExp rx("[A-Z|a-z]+[A-Z|a-z|\\d]*");
@@ -40,7 +39,7 @@ joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent, std::strin
lineEdit_ipAddress->setFocus(); lineEdit_ipAddress->setFocus();
myServerProfilesFile = myConfig->readConfigString("DataDir")+"serverprofiles.xml"; myServerProfilesFile = myConfig.readConfigString("DataDir")+"serverprofiles.xml";
//Anlegen wenn noch nicht existiert! //Anlegen wenn noch nicht existiert!
QFile serverProfilesfile(QString::fromUtf8(myServerProfilesFile.c_str())); QFile serverProfilesfile(QString::fromUtf8(myServerProfilesFile.c_str()));
@@ -24,6 +24,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "configfile.h"
#include <QtGui> #include <QtGui>
#include <QtCore> #include <QtCore>
@@ -33,9 +34,9 @@ class ConfigFile;
class joinNetworkGameDialogImpl: public QDialog, public Ui::joinNetworkGameDialog { class joinNetworkGameDialogImpl: public QDialog, public Ui::joinNetworkGameDialog {
Q_OBJECT Q_OBJECT
public: public:
joinNetworkGameDialogImpl(QWidget *parent = 0, std::string = ""); joinNetworkGameDialogImpl(QWidget *parent = 0);
ConfigFile myConfig;
std::string myServerProfilesFile; std::string myServerProfilesFile;
public slots: public slots:
@@ -46,9 +47,6 @@ public slots:
void saveServerProfile(); void saveServerProfile();
void deleteServerProfile(); void deleteServerProfile();
void keyPressEvent ( QKeyEvent * event ); void keyPressEvent ( QKeyEvent * event );
private:
ConfigFile *myConfig;
}; };
#endif #endif
+1 -3
View File
@@ -21,7 +21,6 @@
#include "mainwindowimpl.h" #include "mainwindowimpl.h"
#include <game_defs.h> #include <game_defs.h>
#include "session.h"
using namespace std; using namespace std;
@@ -29,8 +28,7 @@ Log::Log(mainWindowImpl* w) : myW(w)
{ {
myW->setLog(this); myW->setLog(this);
myConfig = new ConfigFile(myW->getSession()->getConfigPath()); myConfig = new ConfigFile;
if(myConfig->readConfigString("LogDir") != "" && QDir::QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())).exists()) { if(myConfig->readConfigString("LogDir") != "" && QDir::QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())).exists()) {
#ifdef _WIN32 #ifdef _WIN32
+1
View File
@@ -30,6 +30,7 @@
class mainWindowImpl; class mainWindowImpl;
class Log{ class Log{
public: public:
Log(mainWindowImpl*); Log(mainWindowImpl*);
+9 -12
View File
@@ -39,8 +39,6 @@
#include "log.h" #include "log.h"
#include "configfile.h" #include "configfile.h"
#include "appdirpath.h"
#include <net/socket_msg.h> #include <net/socket_msg.h>
@@ -50,8 +48,8 @@
using namespace std; using namespace std;
mainWindowImpl::mainWindowImpl(Session* s, QMainWindow *parent) mainWindowImpl::mainWindowImpl(QMainWindow *parent)
: QMainWindow(parent), actualGame(0), actualHand(0), mySession(s), gameSpeed(0), debugMode(0), breakAfterActualHand(FALSE) : QMainWindow(parent), actualGame(0), actualHand(0), mySession(0), gameSpeed(0), debugMode(0), breakAfterActualHand(FALSE)
{ {
int i; int i;
@@ -61,8 +59,7 @@ mainWindowImpl::mainWindowImpl(Session* s, QMainWindow *parent)
} }
//////////////////////////// ////////////////////////////
AppDirPath myAppDirPath; myConfig = new ConfigFile;
myConfig = new ConfigFile(myAppDirPath.getMyPath());
// Resourcen abladen // Resourcen abladen
QFile preflopValuesFile(":data/resources/data/preflopValues"); QFile preflopValuesFile(":data/resources/data/preflopValues");
@@ -482,10 +479,10 @@ mainWindowImpl::mainWindowImpl(Session* s, QMainWindow *parent)
} }
//Dialoge //Dialoge
myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this, mySession->getConfigPath()); myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this);
myConnectToServerDialog = new connectToServerDialogImpl(this); myConnectToServerDialog = new connectToServerDialogImpl(this);
myStartNetworkGameDialog = new startNetworkGameDialogImpl(this); myStartNetworkGameDialog = new startNetworkGameDialogImpl(this);
myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, mySession->getConfigPath()); myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this);
myWaitingForServerGameDialog = new waitForServerToStartGameDialogImpl(this); myWaitingForServerGameDialog = new waitForServerToStartGameDialogImpl(this);
//Connects //Connects
@@ -557,7 +554,7 @@ void mainWindowImpl::callNewGameDialog() {
//wenn Dialogfenster gezeigt werden soll //wenn Dialogfenster gezeigt werden soll
if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){
newGameDialogImpl *v = new newGameDialogImpl(this, mySession->getConfigPath()); newGameDialogImpl *v = new newGameDialogImpl(this);
v->exec(); v->exec();
if (v->result() == QDialog::Accepted ) { startNewLocalGame(v); } if (v->result() == QDialog::Accepted ) { startNewLocalGame(v); }
// else { startNewLocalGame(); } // else { startNewLocalGame(); }
@@ -688,7 +685,7 @@ void mainWindowImpl::callJoinNetworkGameDialog() {
void mainWindowImpl::callSettingsDialog() { void mainWindowImpl::callSettingsDialog() {
settingsDialogImpl *v = new settingsDialogImpl(this, mySession->getConfigPath()); settingsDialogImpl *v = new settingsDialogImpl(this);
v->exec(); v->exec();
@@ -829,7 +826,7 @@ void mainWindowImpl::refreshPlayerAvatar() {
if(actualHand->getPlayerArray()[i]->getMyActiveStatus()) { if(actualHand->getPlayerArray()[i]->getMyActiveStatus()) {
if(!i) { if(!i) {
if(actualHand->getPlayerArray()[0]->getMyAvatar() == ""/* || !QDir::QDir(QString::fromUtf8(actualHand->getPlayerArray()[0]->getMyAvatar().c_str())).exists()*/) { if(actualHand->getPlayerArray()[0]->getMyAvatar() == "") {
playerAvatarLabelArray[0]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png")); playerAvatarLabelArray[0]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png"));
} }
else { else {
@@ -837,7 +834,7 @@ void mainWindowImpl::refreshPlayerAvatar() {
} }
} }
else { else {
if(actualHand->getPlayerArray()[i]->getMyAvatar() == ""/* || !QDir::QDir(QString::fromUtf8(actualHand->getPlayerArray()[i]->getMyAvatar().c_str())).exists()*/) { if(actualHand->getPlayerArray()[i]->getMyAvatar() == "") {
playerAvatarLabelArray[i]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png")); playerAvatarLabelArray[i]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png"));
} }
else { else {
+1 -2
View File
@@ -53,14 +53,13 @@ class mainWindowImpl: public QMainWindow, public Ui::mainWindow {
Q_OBJECT Q_OBJECT
public: public:
mainWindowImpl(Session* = 0, QMainWindow *parent = 0 ); mainWindowImpl(QMainWindow *parent = 0 );
~mainWindowImpl(); ~mainWindowImpl();
void setGame(Game*); void setGame(Game*);
void setHand(HandInterface*); void setHand(HandInterface*);
void setSession(Session*); void setSession(Session*);
Session* getSession() { return mySession; }
void setLog(Log*); void setLog(Log*);
void setActualHand(HandInterface* theValue) { actualHand = theValue;} void setActualHand(HandInterface* theValue) { actualHand = theValue;}
@@ -20,22 +20,22 @@
#include "newgamedialogimpl.h" #include "newgamedialogimpl.h"
#include "configfile.h" #include "configfile.h"
newGameDialogImpl::newGameDialogImpl(QWidget *parent, std::string path) newGameDialogImpl::newGameDialogImpl(QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
setupUi(this); setupUi(this);
//Formulare Füllen //Formulare Füllen
myConfig = new ConfigFile(path); ConfigFile myConfig;
//Game Settings //Game Settings
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NumberOfPlayers")); spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers"));
spinBox_startCash->setValue(myConfig->readConfigInt("StartCash")); spinBox_startCash->setValue(myConfig.readConfigInt("StartCash"));
spinBox_smallBlind->setValue(myConfig->readConfigInt("SmallBlind")); spinBox_smallBlind->setValue(myConfig.readConfigInt("SmallBlind"));
spinBox_gameSpeed->setValue(myConfig->readConfigInt("GameSpeed")); spinBox_gameSpeed->setValue(myConfig.readConfigInt("GameSpeed"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("HandsBeforeRaiseSmallBlind")); spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("HandsBeforeRaiseSmallBlind"));
} }
@@ -23,22 +23,17 @@
#include "ui_newgamedialog.h" #include "ui_newgamedialog.h"
#include <iostream> #include <iostream>
#include <string>
#include <QtGui> #include <QtGui>
#include <QtCore> #include <QtCore>
class ConfigFile;
class newGameDialogImpl: public QDialog, public Ui::newGameDialog { class newGameDialogImpl: public QDialog, public Ui::newGameDialog {
Q_OBJECT Q_OBJECT
public: public:
newGameDialogImpl(QWidget *parent = 0, std::string = ""); newGameDialogImpl(QWidget *parent = 0);
public slots: public slots:
private:
ConfigFile *myConfig;
}; };
#endif #endif
+30
View File
@@ -0,0 +1,30 @@
//
// C++ Implementation: qthelper
//
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "qthelper.h"
QtHelper::QtHelper()
{
}
QtHelper::~QtHelper()
{
}
std::string QtHelper::stringToUtf8(const std::string &myString) {
QString tmpString = QString::fromStdString(myString);
std::string myUtf8String = tmpString.toUtf8().constData();
return myUtf8String;
}
+29
View File
@@ -0,0 +1,29 @@
//
// C++ Interface: qthelper
//
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef QTHELPER_H
#define QTHELPER_H
#include <QtCore>
/**
@author FThauer FHammer <webmaster@pokerth.net>
*/
class QtHelper{
public:
QtHelper();
~QtHelper();
std::string stringToUtf8(const std::string &);
};
#endif
@@ -22,10 +22,9 @@
#include <iostream> #include <iostream>
settingsDialogImpl::settingsDialogImpl(QWidget *parent, std::string path) settingsDialogImpl::settingsDialogImpl(QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
myConfig = new ConfigFile(path);
setupUi(this); setupUi(this);
@@ -36,64 +35,64 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, std::string path)
playerNickIsChanged = FALSE; playerNickIsChanged = FALSE;
//Formulare Füllen //Formulare Füllen
ConfigFile myConfig;
//Player Nicks //Player Nicks
lineEdit_humanPlayerName->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); lineEdit_humanPlayerName->setText(QString::fromUtf8(myConfig.readConfigString("MyName").c_str()));
lineEdit_humanPlayerAvatar->setText(QString::fromUtf8(myConfig->readConfigString("MyAvatar").c_str())); lineEdit_humanPlayerAvatar->setText(QString::fromUtf8(myConfig.readConfigString("MyAvatar").c_str()));
lineEdit_Opponent1Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent1Name").c_str())); lineEdit_Opponent1Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent1Name").c_str()));
lineEdit_Opponent1Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent1Avatar").c_str())); lineEdit_Opponent1Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent1Avatar").c_str()));
lineEdit_Opponent2Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent2Name").c_str())); lineEdit_Opponent2Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent2Name").c_str()));
lineEdit_Opponent2Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent2Avatar").c_str())); lineEdit_Opponent2Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent2Avatar").c_str()));
lineEdit_Opponent3Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent3Name").c_str())); lineEdit_Opponent3Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent3Name").c_str()));
lineEdit_Opponent3Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent3Avatar").c_str())); lineEdit_Opponent3Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent3Avatar").c_str()));
lineEdit_Opponent4Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent4Name").c_str())); lineEdit_Opponent4Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent4Name").c_str()));
lineEdit_Opponent4Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent4Avatar").c_str())); lineEdit_Opponent4Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent4Avatar").c_str()));
lineEdit_Opponent5Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent5Name").c_str())); lineEdit_Opponent5Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent5Name").c_str()));
lineEdit_Opponent5Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent5Avatar").c_str())); lineEdit_Opponent5Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent5Avatar").c_str()));
lineEdit_Opponent6Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent6Name").c_str())); lineEdit_Opponent6Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent6Name").c_str()));
lineEdit_Opponent6Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent6Avatar").c_str())); lineEdit_Opponent6Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent6Avatar").c_str()));
//Local Game Settings //Local Game Settings
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NumberOfPlayers")); spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers"));
spinBox_startCash->setValue(myConfig->readConfigInt("StartCash")); spinBox_startCash->setValue(myConfig.readConfigInt("StartCash"));
spinBox_smallBlind->setValue(myConfig->readConfigInt("SmallBlind")); spinBox_smallBlind->setValue(myConfig.readConfigInt("SmallBlind"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("HandsBeforeRaiseSmallBlind")); spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("HandsBeforeRaiseSmallBlind"));
spinBox_gameSpeed->setValue(myConfig->readConfigInt("GameSpeed")); spinBox_gameSpeed->setValue(myConfig.readConfigInt("GameSpeed"));
checkBox_pauseBetweenHands->setChecked(myConfig->readConfigInt("PauseBetweenHands")); checkBox_pauseBetweenHands->setChecked(myConfig.readConfigInt("PauseBetweenHands"));
checkBox_showGameSettingsDialogOnNewGame->setChecked(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")); checkBox_showGameSettingsDialogOnNewGame->setChecked(myConfig.readConfigInt("ShowGameSettingsDialogOnNewGame"));
comboBox_engineVersion->setCurrentIndex(myConfig->readConfigInt("EngineVersion")); comboBox_engineVersion->setCurrentIndex(myConfig.readConfigInt("EngineVersion"));
//Network Game Settings //Network Game Settings
spinBox_netQuantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); spinBox_netQuantityPlayers->setValue(myConfig.readConfigInt("NetNumberOfPlayers"));
spinBox_netStartCash->setValue(myConfig->readConfigInt("NetStartCash")); spinBox_netStartCash->setValue(myConfig.readConfigInt("NetStartCash"));
spinBox_netSmallBlind->setValue(myConfig->readConfigInt("NetSmallBlind")); spinBox_netSmallBlind->setValue(myConfig.readConfigInt("NetSmallBlind"));
spinBox_netHandsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("NetHandsBeforeRaiseSmallBlind")); spinBox_netHandsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("NetHandsBeforeRaiseSmallBlind"));
spinBox_netGameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed")); spinBox_netGameSpeed->setValue(myConfig.readConfigInt("NetGameSpeed"));
comboBox_netEngineVersion->setCurrentIndex(myConfig->readConfigInt("NetEngineVersion")); comboBox_netEngineVersion->setCurrentIndex(myConfig.readConfigInt("NetEngineVersion"));
spinBox_serverPort->setValue(myConfig->readConfigInt("ServerPort")); spinBox_serverPort->setValue(myConfig.readConfigInt("ServerPort"));
lineEdit_serverPassword->setText(QString::fromUtf8(myConfig->readConfigString("ServerPassword").c_str())); lineEdit_serverPassword->setText(QString::fromUtf8(myConfig.readConfigString("ServerPassword").c_str()));
checkBox_useIpv6->setChecked(myConfig->readConfigInt("ServerUseIpv6")); checkBox_useIpv6->setChecked(myConfig.readConfigInt("ServerUseIpv6"));
//Interface //Interface
checkBox_showLeftToolbox->setChecked(myConfig->readConfigInt("ShowLeftToolBox")); checkBox_showLeftToolbox->setChecked(myConfig.readConfigInt("ShowLeftToolBox"));
checkBox_showRightToolbox->setChecked(myConfig->readConfigInt("ShowRightToolBox")); checkBox_showRightToolbox->setChecked(myConfig.readConfigInt("ShowRightToolBox"));
checkBox_showStatusbarMessages->setChecked(myConfig->readConfigInt("ShowStatusbarMessages")); checkBox_showStatusbarMessages->setChecked(myConfig.readConfigInt("ShowStatusbarMessages"));
checkBox_showIntro->setChecked(myConfig->readConfigInt("ShowIntro")); checkBox_showIntro->setChecked(myConfig.readConfigInt("ShowIntro"));
checkBox_showFadeOutCardsAnimation->setChecked(myConfig->readConfigInt("ShowFadeOutCardsAnimation")); checkBox_showFadeOutCardsAnimation->setChecked(myConfig.readConfigInt("ShowFadeOutCardsAnimation"));
checkBox_showFlipCardsAnimation->setChecked(myConfig->readConfigInt("ShowFlipCardsAnimation")); checkBox_showFlipCardsAnimation->setChecked(myConfig.readConfigInt("ShowFlipCardsAnimation"));
radioButton_flipsideTux->setChecked(myConfig->readConfigInt("FlipsideTux")); radioButton_flipsideTux->setChecked(myConfig.readConfigInt("FlipsideTux"));
radioButton_flipsideOwn->setChecked(myConfig->readConfigInt("FlipsideOwn")); radioButton_flipsideOwn->setChecked(myConfig.readConfigInt("FlipsideOwn"));
if(radioButton_flipsideOwn->isChecked()) { if(radioButton_flipsideOwn->isChecked()) {
lineEdit_OwnFlipsideFilename->setEnabled(TRUE); lineEdit_OwnFlipsideFilename->setEnabled(TRUE);
pushButton_openFlipsidePicture->setEnabled(TRUE); pushButton_openFlipsidePicture->setEnabled(TRUE);
} }
lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig.readConfigString("FlipsideOwnFile").c_str()));
//Log //Log
lineEdit_logDir->setText(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); lineEdit_logDir->setText(QString::fromUtf8(myConfig.readConfigString("LogDir").c_str()));
spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration")); spinBox_logStoreDuration->setValue(myConfig.readConfigInt("LogStoreDuration"));
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( isAccepted() ) ); connect( buttonBox, SIGNAL( accepted() ), this, SLOT( isAccepted() ) );
connect( lineEdit_humanPlayerName, SIGNAL( textChanged( const QString &) ), this, SLOT( playerNickChanged() ) ); connect( lineEdit_humanPlayerName, SIGNAL( textChanged( const QString &) ), this, SLOT( playerNickChanged() ) );
@@ -119,11 +118,12 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = TRUE; settingsCorrect = TRUE;
//Daten speichern //Daten speichern
ConfigFile myConfig;
// Player Nicks // Player Nicks
myConfig->writeConfigString("MyName", lineEdit_humanPlayerName->text().toUtf8().constData()); myConfig.writeConfigString("MyName", lineEdit_humanPlayerName->text().toUtf8().constData());
if(QFile::QFile(lineEdit_humanPlayerAvatar->text()).exists() || lineEdit_humanPlayerAvatar->text() == "") { if(QFile::QFile(lineEdit_humanPlayerAvatar->text()).exists() || lineEdit_humanPlayerAvatar->text() == "") {
myConfig->writeConfigString("MyAvatar", lineEdit_humanPlayerAvatar->text().toUtf8().constData()); myConfig.writeConfigString("MyAvatar", lineEdit_humanPlayerAvatar->text().toUtf8().constData());
} }
else { QMessageBox::warning(this, tr("Settings Error"), else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered human player avatar picture doesn't exists.\n" tr("The entered human player avatar picture doesn't exists.\n"
@@ -132,9 +132,9 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = FALSE; settingsCorrect = FALSE;
} }
myConfig->writeConfigString("Opponent1Name", lineEdit_Opponent1Name->text().toUtf8().constData()); myConfig.writeConfigString("Opponent1Name", lineEdit_Opponent1Name->text().toUtf8().constData());
if(QFile::QFile(lineEdit_Opponent1Avatar->text()).exists() || lineEdit_Opponent1Avatar->text() == "") { if(QFile::QFile(lineEdit_Opponent1Avatar->text()).exists() || lineEdit_Opponent1Avatar->text() == "") {
myConfig->writeConfigString("Opponent1Avatar", lineEdit_Opponent1Avatar->text().toUtf8().constData()); myConfig.writeConfigString("Opponent1Avatar", lineEdit_Opponent1Avatar->text().toUtf8().constData());
} }
else { QMessageBox::warning(this, tr("Settings Error"), else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 1\" avatar picture doesn't exists.\n" tr("The entered \"opponent 1\" avatar picture doesn't exists.\n"
@@ -143,9 +143,9 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = FALSE; settingsCorrect = FALSE;
} }
myConfig->writeConfigString("Opponent2Name", lineEdit_Opponent2Name->text().toUtf8().constData()); myConfig.writeConfigString("Opponent2Name", lineEdit_Opponent2Name->text().toUtf8().constData());
if(QFile::QFile(lineEdit_Opponent2Avatar->text()).exists() || lineEdit_Opponent2Avatar->text() == "") { if(QFile::QFile(lineEdit_Opponent2Avatar->text()).exists() || lineEdit_Opponent2Avatar->text() == "") {
myConfig->writeConfigString("Opponent2Avatar", lineEdit_Opponent2Avatar->text().toUtf8().constData()); myConfig.writeConfigString("Opponent2Avatar", lineEdit_Opponent2Avatar->text().toUtf8().constData());
} }
else { QMessageBox::warning(this, tr("Settings Error"), else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 2\" avatar picture doesn't exists.\n" tr("The entered \"opponent 2\" avatar picture doesn't exists.\n"
@@ -154,9 +154,9 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = FALSE; settingsCorrect = FALSE;
} }
myConfig->writeConfigString("Opponent3Name", lineEdit_Opponent3Name->text().toUtf8().constData()); myConfig.writeConfigString("Opponent3Name", lineEdit_Opponent3Name->text().toUtf8().constData());
if(QFile::QFile(lineEdit_Opponent3Avatar->text()).exists() || lineEdit_Opponent3Avatar->text() == "") { if(QFile::QFile(lineEdit_Opponent3Avatar->text()).exists() || lineEdit_Opponent3Avatar->text() == "") {
myConfig->writeConfigString("Opponent3Avatar", lineEdit_Opponent3Avatar->text().toUtf8().constData()); myConfig.writeConfigString("Opponent3Avatar", lineEdit_Opponent3Avatar->text().toUtf8().constData());
} }
else { QMessageBox::warning(this, tr("Settings Error"), else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 3\" avatar picture doesn't exists.\n" tr("The entered \"opponent 3\" avatar picture doesn't exists.\n"
@@ -165,9 +165,9 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = FALSE; settingsCorrect = FALSE;
} }
myConfig->writeConfigString("Opponent4Name", lineEdit_Opponent4Name->text().toUtf8().constData()); myConfig.writeConfigString("Opponent4Name", lineEdit_Opponent4Name->text().toUtf8().constData());
if(QFile::QFile(lineEdit_Opponent4Avatar->text()).exists() || lineEdit_Opponent4Avatar->text() == "") { if(QFile::QFile(lineEdit_Opponent4Avatar->text()).exists() || lineEdit_Opponent4Avatar->text() == "") {
myConfig->writeConfigString("Opponent4Avatar", lineEdit_Opponent4Avatar->text().toUtf8().constData()); myConfig.writeConfigString("Opponent4Avatar", lineEdit_Opponent4Avatar->text().toUtf8().constData());
} }
else { QMessageBox::warning(this, tr("Settings Error"), else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 4\" avatar picture doesn't exists.\n" tr("The entered \"opponent 4\" avatar picture doesn't exists.\n"
@@ -176,9 +176,9 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = FALSE; settingsCorrect = FALSE;
} }
myConfig->writeConfigString("Opponent5Name", lineEdit_Opponent5Name->text().toUtf8().constData()); myConfig.writeConfigString("Opponent5Name", lineEdit_Opponent5Name->text().toUtf8().constData());
if(QFile::QFile(lineEdit_Opponent5Avatar->text()).exists() || lineEdit_Opponent5Avatar->text() == "") { if(QFile::QFile(lineEdit_Opponent5Avatar->text()).exists() || lineEdit_Opponent5Avatar->text() == "") {
myConfig->writeConfigString("Opponent5Avatar", lineEdit_Opponent5Avatar->text().toUtf8().constData()); myConfig.writeConfigString("Opponent5Avatar", lineEdit_Opponent5Avatar->text().toUtf8().constData());
} }
else { QMessageBox::warning(this, tr("Settings Error"), else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 5\" avatar picture doesn't exists.\n" tr("The entered \"opponent 5\" avatar picture doesn't exists.\n"
@@ -187,9 +187,9 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = FALSE; settingsCorrect = FALSE;
} }
myConfig->writeConfigString("Opponent6Name", lineEdit_Opponent6Name->text().toUtf8().constData()); myConfig.writeConfigString("Opponent6Name", lineEdit_Opponent6Name->text().toUtf8().constData());
if(QFile::QFile(lineEdit_Opponent6Avatar->text()).exists() || lineEdit_Opponent6Avatar->text() == "") { if(QFile::QFile(lineEdit_Opponent6Avatar->text()).exists() || lineEdit_Opponent6Avatar->text() == "") {
myConfig->writeConfigString("Opponent6Avatar", lineEdit_Opponent6Avatar->text().toUtf8().constData()); myConfig.writeConfigString("Opponent6Avatar", lineEdit_Opponent6Avatar->text().toUtf8().constData());
} }
else { QMessageBox::warning(this, tr("Settings Error"), else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 6\" avatar picture doesn't exists.\n" tr("The entered \"opponent 6\" avatar picture doesn't exists.\n"
@@ -199,38 +199,38 @@ void settingsDialogImpl::isAccepted() {
} }
// Local Game Settings // Local Game Settings
myConfig->writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value()); myConfig.writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value());
myConfig->writeConfigInt("StartCash", spinBox_startCash->value()); myConfig.writeConfigInt("StartCash", spinBox_startCash->value());
myConfig->writeConfigInt("SmallBlind", spinBox_smallBlind->value()); myConfig.writeConfigInt("SmallBlind", spinBox_smallBlind->value());
myConfig->writeConfigInt("HandsBeforeRaiseSmallBlind", spinBox_handsBeforeRaiseSmallBlind->value()); myConfig.writeConfigInt("HandsBeforeRaiseSmallBlind", spinBox_handsBeforeRaiseSmallBlind->value());
myConfig->writeConfigInt("GameSpeed", spinBox_gameSpeed->value()); myConfig.writeConfigInt("GameSpeed", spinBox_gameSpeed->value());
myConfig->writeConfigInt("EngineVersion", comboBox_engineVersion->currentIndex()); myConfig.writeConfigInt("EngineVersion", comboBox_engineVersion->currentIndex());
myConfig->writeConfigInt("PauseBetweenHands", checkBox_pauseBetweenHands->isChecked()); myConfig.writeConfigInt("PauseBetweenHands", checkBox_pauseBetweenHands->isChecked());
myConfig->writeConfigInt("ShowGameSettingsDialogOnNewGame", checkBox_showGameSettingsDialogOnNewGame->isChecked()); myConfig.writeConfigInt("ShowGameSettingsDialogOnNewGame", checkBox_showGameSettingsDialogOnNewGame->isChecked());
//Network Game Settings //Network Game Settings
myConfig->writeConfigInt("NetNumberOfPlayers", spinBox_netQuantityPlayers->value()); myConfig.writeConfigInt("NetNumberOfPlayers", spinBox_netQuantityPlayers->value());
myConfig->writeConfigInt("NetStartCash", spinBox_netStartCash->value()); myConfig.writeConfigInt("NetStartCash", spinBox_netStartCash->value());
myConfig->writeConfigInt("NetSmallBlind", spinBox_netSmallBlind->value()); myConfig.writeConfigInt("NetSmallBlind", spinBox_netSmallBlind->value());
myConfig->writeConfigInt("NetHandsBeforeRaiseSmallBlind", spinBox_netHandsBeforeRaiseSmallBlind->value()); myConfig.writeConfigInt("NetHandsBeforeRaiseSmallBlind", spinBox_netHandsBeforeRaiseSmallBlind->value());
myConfig->writeConfigInt("NetGameSpeed", spinBox_netGameSpeed->value()); myConfig.writeConfigInt("NetGameSpeed", spinBox_netGameSpeed->value());
myConfig->writeConfigInt("NetEngineVersion", comboBox_netEngineVersion->currentIndex()); myConfig.writeConfigInt("NetEngineVersion", comboBox_netEngineVersion->currentIndex());
myConfig->writeConfigInt("ServerPort", spinBox_serverPort->value()); myConfig.writeConfigInt("ServerPort", spinBox_serverPort->value());
myConfig->writeConfigString("ServerPassword", lineEdit_serverPassword->text().toUtf8().constData()); myConfig.writeConfigString("ServerPassword", lineEdit_serverPassword->text().toUtf8().constData());
myConfig->writeConfigInt("ServerUseIpv6", checkBox_useIpv6->isChecked()); myConfig.writeConfigInt("ServerUseIpv6", checkBox_useIpv6->isChecked());
// Interface // Interface
myConfig->writeConfigInt("ShowLeftToolBox", checkBox_showLeftToolbox->isChecked()); myConfig.writeConfigInt("ShowLeftToolBox", checkBox_showLeftToolbox->isChecked());
myConfig->writeConfigInt("ShowRightToolBox", checkBox_showRightToolbox->isChecked()); myConfig.writeConfigInt("ShowRightToolBox", checkBox_showRightToolbox->isChecked());
myConfig->writeConfigInt("ShowStatusbarMessages", checkBox_showStatusbarMessages->isChecked()); myConfig.writeConfigInt("ShowStatusbarMessages", checkBox_showStatusbarMessages->isChecked());
myConfig->writeConfigInt("ShowIntro", checkBox_showIntro->isChecked()); myConfig.writeConfigInt("ShowIntro", checkBox_showIntro->isChecked());
myConfig->writeConfigInt("ShowFadeOutCardsAnimation", checkBox_showFadeOutCardsAnimation->isChecked()); myConfig.writeConfigInt("ShowFadeOutCardsAnimation", checkBox_showFadeOutCardsAnimation->isChecked());
myConfig->writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked()); myConfig.writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked());
myConfig->writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked()); myConfig.writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked());
myConfig->writeConfigInt("FlipsideOwn", radioButton_flipsideOwn->isChecked()); myConfig.writeConfigInt("FlipsideOwn", radioButton_flipsideOwn->isChecked());
if(radioButton_flipsideOwn->isChecked()) { if(radioButton_flipsideOwn->isChecked()) {
if(QFile::QFile(lineEdit_OwnFlipsideFilename->text()).exists() && lineEdit_OwnFlipsideFilename->text() != "") {myConfig->writeConfigString("FlipsideOwnFile", lineEdit_OwnFlipsideFilename->text().toUtf8().constData()); } if(QFile::QFile(lineEdit_OwnFlipsideFilename->text()).exists() && lineEdit_OwnFlipsideFilename->text() != "") {myConfig.writeConfigString("FlipsideOwnFile", lineEdit_OwnFlipsideFilename->text().toUtf8().constData()); }
else { QMessageBox::warning(this, tr("Settings Error"), else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered flipside picture doesn't exists.\n" tr("The entered flipside picture doesn't exists.\n"
"Please enter an valid picture!"), "Please enter an valid picture!"),
@@ -240,7 +240,7 @@ void settingsDialogImpl::isAccepted() {
} }
// Log // Log
if(QDir::QDir(lineEdit_logDir->text()).exists() && lineEdit_logDir->text() != "") { myConfig->writeConfigString("LogDir", lineEdit_logDir->text().toUtf8().constData()); } if(QDir::QDir(lineEdit_logDir->text()).exists() && lineEdit_logDir->text() != "") { myConfig.writeConfigString("LogDir", lineEdit_logDir->text().toUtf8().constData()); }
else { else {
QMessageBox::warning(this, tr("Settings Error"), QMessageBox::warning(this, tr("Settings Error"),
tr("The log file directory doesn't exists.\n" tr("The log file directory doesn't exists.\n"
@@ -249,7 +249,7 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = FALSE; settingsCorrect = FALSE;
} }
myConfig->writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value()); myConfig.writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value());
//Wenn alles richtig eingegeben wurde --> Dialog schließen //Wenn alles richtig eingegeben wurde --> Dialog schließen
if(settingsCorrect) { this->hide(); } if(settingsCorrect) { this->hide(); }
@@ -22,16 +22,14 @@
#include "ui_settingsdialog.h" #include "ui_settingsdialog.h"
#include <string>
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
class ConfigFile;
class settingsDialogImpl: public QDialog, public Ui::settingsDialog { class settingsDialogImpl: public QDialog, public Ui::settingsDialog {
Q_OBJECT Q_OBJECT
public: public:
settingsDialogImpl(QWidget *parent = 0, std::string = ""); settingsDialogImpl(QWidget *parent = 0);
void setPlayerNickIsChanged(bool theValue){ playerNickIsChanged = theValue;} void setPlayerNickIsChanged(bool theValue){ playerNickIsChanged = theValue;}
bool getPlayerNickIsChanged() const{ return playerNickIsChanged;} bool getPlayerNickIsChanged() const{ return playerNickIsChanged;}
@@ -55,7 +53,6 @@ private:
bool playerNickIsChanged; bool playerNickIsChanged;
bool settingsCorrect; bool settingsCorrect;
ConfigFile *myConfig;
}; };
-26
View File
@@ -1,26 +0,0 @@
/***************************************************************************
* 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 "qttoolsinterface.h"
QtToolsInterface::~QtToolsInterface()
{
}
-35
View File
@@ -1,35 +0,0 @@
/***************************************************************************
* 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 QTTOOLSINTERFACE_H
#define QTTOOLSINTERFACE_H
#include <string>
class QtToolsInterface {
public:
virtual ~QtToolsInterface();
//appdirpath.cpp
virtual std::string getMyAppDirPath() const =0;
};
#endif
+3 -8
View File
@@ -52,7 +52,6 @@
using namespace std; using namespace std;
class GuiWrapper; class GuiWrapper;
class QtToolsWrapper;
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
@@ -68,13 +67,9 @@ int main( int argc, char **argv )
Q_INIT_RESOURCE(resources); Q_INIT_RESOURCE(resources);
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
GuiInterface *myGuiInterface = new GuiWrapper();
Session *theFirst = new Session(); Session theFirst(myGuiInterface);
myGuiInterface->setSession(&theFirst);
GuiInterface *myGuiInterface = new GuiWrapper(theFirst);
theFirst->setGuiInterface(myGuiInterface);
// myGuiInterface->setSession(&theFirst);
int retVal = a.exec(); int retVal = a.exec();
+4 -9
View File
@@ -20,7 +20,6 @@
#include "session.h" #include "session.h"
#include "game.h" #include "game.h"
#include "guiinterface.h" #include "guiinterface.h"
#include "qttoolswrapper.h"
#include "configfile.h" #include "configfile.h"
#include <net/clientthread.h> #include <net/clientthread.h>
#include <net/serverthread.h> #include <net/serverthread.h>
@@ -30,14 +29,10 @@
using namespace std; using namespace std;
Session::Session() Session::Session(GuiInterface *g)
: actualGameID(0), myNetClient(0), myNetServer(0), actualGame(0), myGui(0) : actualGameID(0), myNetClient(0), myNetServer(0), actualGame(0), myGui(g)
{ {
QtToolsInterface *myQtToolsInterface = new QtToolsWrapper(); myConfig = new ConfigFile;
myConfig = new ConfigFile(myQtToolsInterface->getMyAppDirPath());
setConfigPath(myQtToolsInterface->getMyAppDirPath());
} }
@@ -54,7 +49,7 @@ void Session::startGame(int qP, int sC, int sB) {
actualGameID++; actualGameID++;
actualGame = new Game(this, myGui, qP, sC, sB, actualGameID); actualGame = new Game(myConfig, myGui, qP, sC, sB, actualGameID);
} }
void Session::deleteGame() { void Session::deleteGame() {
+1 -8
View File
@@ -30,12 +30,10 @@ class ServerThread;
class Session{ class Session{
public: public:
Session(); Session(GuiInterface*);
~Session(); ~Session();
void setGuiInterface(GuiInterface *gui) { myGui = gui; }
void startGame(int, int, int); void startGame(int, int, int);
void deleteGame(); void deleteGame();
@@ -50,9 +48,6 @@ public:
void setActualGameID(const int& theValue) { actualGameID = theValue; } void setActualGameID(const int& theValue) { actualGameID = theValue; }
int getActualGameID() const { return actualGameID; } int getActualGameID() const { return actualGameID; }
void setConfigPath(const std::string& theValue) { configPath = theValue; }
std::string getConfigPath() const { return configPath; }
// void createConfig(); // void createConfig();
private: private:
@@ -66,8 +61,6 @@ private:
GuiInterface *myGui; GuiInterface *myGui;
ConfigFile *myConfig; ConfigFile *myConfig;
std::string configPath;
}; };