path to UTF8

configfile split
This commit is contained in:
doitux
2007-04-18 00:11:24 +00:00
parent 27cd08ccb0
commit 2b94ce958f
33 changed files with 565 additions and 498 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
#todo items for future releases
- save games to continue at the saved game-state#
- blinking start-stop button when click start is needed for next round
- blinking start-stop button when click start is needed for next round
- chip stack animation
- fold cards animation (throw in the center)
+4 -4
View File
@@ -22,7 +22,7 @@ DEPENDPATH += . \
src/gui/qt/createnetworkgamedialog \
src/gui/qt/joinnetworkgamedialog \
src/gui/qt/log \
src/gui/qt/qthelper \
src/gui/qt/defaultconfig \
src/gui/qt/newlocalgamedialog \
src/gui/qt/settingsdialog \
src/gui/qt/startnetworkgamedialog \
@@ -37,7 +37,7 @@ INCLUDEPATH += . \
src/core/tinyxml \
src/gui/qt \
src/gui/qt/log \
src/gui/qt/qthelper \
src/gui/qt/defaultconfig \
src/gui/qt/connecttoserverdialog \
src/core \
src/gui/qt/mainwindow \
@@ -102,7 +102,7 @@ HEADERS += src/game.h \
src/gui/qt/settingsdialog/settingsdialogimpl.h \
src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h \
src/gui/qt/waitforservertostartgamedialog/waitforservertostartgamedialogimpl.h \
src/gui/qt/qthelper/qthelper.h
src/gui/qt/defaultconfig/defaultconfig.h
FORMS += src/gui/qt/mainwindow.ui \
src/gui/qt/aboutpokerth.ui \
src/gui/qt/connecttoserverdialog.ui \
@@ -174,7 +174,7 @@ SOURCES += src/game.cpp \
src/gui/qt/settingsdialog/settingsdialogimpl.cpp \
src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp \
src/gui/qt/waitforservertostartgamedialog/waitforservertostartgamedialogimpl.cpp \
src/gui/qt/qthelper/qthelper.cpp
src/gui/qt/defaultconfig/defaultconfig.cpp
RESOURCES += src/gui/qt/resources.qrc
TEMPLATE = vcapp
+18 -252
View File
@@ -32,255 +32,21 @@
using namespace std;
ConfigFile::ConfigFile()
{
// !!!! Revisionsnummer der Configdefaults !!!!!
configRev = 17;
// Pfad und Dateinamen setzen
#ifdef _WIN32
const char *appDataPath = getenv("AppData");
if (appDataPath && appDataPath[0] != 0) {
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
logDir = configFileName;
logDir += "log-files\\";
mkdir(logDir.c_str());
//data Ordner auch erstellen
dataDir = configFileName;
dataDir += "data\\";
mkdir(dataDir.c_str());
#else
//Programmordner erstellen
const char *homePath = getenv("HOME");
if(homePath) {
configFileName = homePath;
configFileName += "/.pokerth/";
mkdir(configFileName.c_str(), MODUS) ;
//Log-File Ordner auch erstellen
logDir = configFileName;
logDir += "log-files/";
mkdir(logDir.c_str(), MODUS);
//data Ordner auch erstellen
dataDir = configFileName;
dataDir += "data/";
mkdir(dataDir.c_str(), MODUS);
}
#endif
configFileName += "config.xml";
//Prüfen ob Configfile existiert --> sonst anlegen
TiXmlDocument doc(configFileName);
if(!doc.LoadFile()){ createDefaultConfig(); }
else {
//Prüfen ob die Revision stimmt ansonsten löschen und neue anlegen
int temp = 0;
TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement();
if ( conf ) { conf->QueryIntAttribute("value", &temp ); }
if (temp < configRev) { /*löschen()*/ createDefaultConfig() ;}
}
ConfigFile::ConfigFile(std::string path)
: myPath(path)
{
}
ConfigFile::~ConfigFile()
{
}
void ConfigFile::createDefaultConfig() {
//Anlegen!
TiXmlDocument doc;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "");
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement( "PokerTH" );
doc.LinkEndChild( root );
//
TiXmlElement * config;
config = new TiXmlElement( "Configuration" );
root->LinkEndChild( config );
TiXmlElement * confElement0 = new TiXmlElement( "ConfigRevision" );
config->LinkEndChild( confElement0 );
confElement0->SetAttribute("value", configRev);
TiXmlElement * confElement11 = new TiXmlElement( "ShowLeftToolBox" );
config->LinkEndChild( confElement11 );
confElement11->SetAttribute("value", 1);
TiXmlElement * confElement22 = new TiXmlElement( "ShowRightToolBox" );
config->LinkEndChild( confElement22 );
confElement22->SetAttribute("value", 1);
TiXmlElement * confElement43 = new TiXmlElement( "ShowStatusbarMessages" );
config->LinkEndChild( confElement43 );
confElement43->SetAttribute("value", 1);
TiXmlElement * confElement13 = new TiXmlElement( "ShowIntro" );
config->LinkEndChild( confElement13 );
confElement13->SetAttribute("value", 1);
TiXmlElement * confElement15 = new TiXmlElement( "ShowFadeOutCardsAnimation" );
config->LinkEndChild( confElement15 );
confElement15->SetAttribute("value", 1);
TiXmlElement * confElement19 = new TiXmlElement( "ShowFlipCardsAnimation" );
config->LinkEndChild( confElement19 );
confElement19->SetAttribute("value", 1);
TiXmlElement * confElement16 = new TiXmlElement( "FlipsideTux" );
config->LinkEndChild( confElement16 );
confElement16->SetAttribute("value", 1);
TiXmlElement * confElement17 = new TiXmlElement( "FlipsideOwn" );
config->LinkEndChild( confElement17 );
confElement17->SetAttribute("value", 0);
TiXmlElement * confElement18 = new TiXmlElement( "FlipsideOwnFile" );
config->LinkEndChild( confElement18 );
confElement18->SetAttribute("value", "");
TiXmlElement * confElement1 = new TiXmlElement( "NumberOfPlayers" );
config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", 7);
TiXmlElement * confElement2 = new TiXmlElement( "StartCash" );
config->LinkEndChild( confElement2 );
confElement2->SetAttribute("value", 3000);
TiXmlElement * confElement3 = new TiXmlElement( "SmallBlind" );
config->LinkEndChild( confElement3 );
confElement3->SetAttribute("value", 10);
TiXmlElement * confElement12 = new TiXmlElement( "HandsBeforeRaiseSmallBlind" );
config->LinkEndChild( confElement12 );
confElement12->SetAttribute("value", 8);
TiXmlElement * confElement4 = new TiXmlElement( "GameSpeed" );
config->LinkEndChild( confElement4 );
confElement4->SetAttribute("value", 4);
TiXmlElement * confElement32 = new TiXmlElement( "EngineVersion" );
config->LinkEndChild( confElement32 );
confElement32->SetAttribute("value", 0);
TiXmlElement * confElement14 = new TiXmlElement( "PauseBetweenHands" );
config->LinkEndChild( confElement14 );
confElement14->SetAttribute("value", 0);
TiXmlElement * confElement5 = new TiXmlElement( "ShowGameSettingsDialogOnNewGame" );
config->LinkEndChild( confElement5 );
confElement5->SetAttribute("value", 1);
TiXmlElement * confElement23 = new TiXmlElement( "NetNumberOfPlayers" );
config->LinkEndChild( confElement23 );
confElement23->SetAttribute("value", 7);
TiXmlElement * confElement24 = new TiXmlElement( "NetStartCash" );
config->LinkEndChild( confElement24 );
confElement24->SetAttribute("value", 2000);
TiXmlElement * confElement25 = new TiXmlElement( "NetSmallBlind" );
config->LinkEndChild( confElement25 );
confElement25->SetAttribute("value", 10);
TiXmlElement * confElement26 = new TiXmlElement( "NetHandsBeforeRaiseSmallBlind" );
config->LinkEndChild( confElement26 );
confElement26->SetAttribute("value", 9);
TiXmlElement * confElement27 = new TiXmlElement( "NetGameSpeed" );
config->LinkEndChild( confElement27 );
confElement27->SetAttribute("value", 4);
TiXmlElement * confElement33 = new TiXmlElement( "NetEngineVersion" );
config->LinkEndChild( confElement33 );
confElement33->SetAttribute("value", 1);
TiXmlElement * confElement28 = new TiXmlElement( "ServerPassword" );
config->LinkEndChild( confElement28 );
confElement28->SetAttribute("value", "");
TiXmlElement * confElement29 = new TiXmlElement( "ServerUseIpv6" );
config->LinkEndChild( confElement29 );
confElement29->SetAttribute("value", 0);
TiXmlElement * confElement30 = new TiXmlElement( "ServerPort" );
config->LinkEndChild( confElement30 );
confElement30->SetAttribute("value", 7234);
TiXmlElement * confElement6 = new TiXmlElement( "MyName" );
config->LinkEndChild( confElement6 );
confElement6->SetAttribute("value", "Human Player");
TiXmlElement * confElement34 = new TiXmlElement( "MyAvatar" );
config->LinkEndChild( confElement34 );
confElement34->SetAttribute("value", "");
TiXmlElement * confElement7 = new TiXmlElement( "Opponent1Name" );
config->LinkEndChild( confElement7 );
confElement7->SetAttribute("value", "Player 1");
TiXmlElement * confElement35 = new TiXmlElement( "Opponent1Avatar" );
config->LinkEndChild( confElement35 );
confElement35->SetAttribute("value", "");
TiXmlElement * confElement8 = new TiXmlElement( "Opponent2Name" );
config->LinkEndChild( confElement8 );
confElement8->SetAttribute("value", "Player 2");
TiXmlElement * confElement36 = new TiXmlElement( "Opponent2Avatar" );
config->LinkEndChild( confElement36 );
confElement36->SetAttribute("value", "");
TiXmlElement * confElement9 = new TiXmlElement( "Opponent3Name" );
config->LinkEndChild( confElement9 );
confElement9->SetAttribute("value", "Player 3");
TiXmlElement * confElement37 = new TiXmlElement( "Opponent3Avatar" );
config->LinkEndChild( confElement37 );
confElement37->SetAttribute("value", "");
TiXmlElement * confElement10 = new TiXmlElement( "Opponent4Name" );
config->LinkEndChild( confElement10 );
confElement10->SetAttribute("value", "Player 4");
TiXmlElement * confElement38 = new TiXmlElement( "Opponent4Avatar" );
config->LinkEndChild( confElement38 );
confElement38->SetAttribute("value", "");
TiXmlElement * confElement39 = new TiXmlElement( "Opponent5Name" );
config->LinkEndChild( confElement39 );
confElement39->SetAttribute("value", "Player 5");
TiXmlElement * confElement40 = new TiXmlElement( "Opponent5Avatar" );
config->LinkEndChild( confElement40 );
confElement40->SetAttribute("value", "");
TiXmlElement * confElement41 = new TiXmlElement( "Opponent6Name" );
config->LinkEndChild( confElement41 );
confElement41->SetAttribute("value", "Player 6");
TiXmlElement * confElement42 = new TiXmlElement( "Opponent6Avatar" );
config->LinkEndChild( confElement42 );
confElement42->SetAttribute("value", "");
TiXmlElement * confElement20 = new TiXmlElement( "LogDir" );
config->LinkEndChild( confElement20 );
confElement20->SetAttribute("value", logDir);
TiXmlElement * confElement21 = new TiXmlElement( "LogStoreDuration" );
config->LinkEndChild( confElement21 );
confElement21->SetAttribute("value", 2);
TiXmlElement * confElement31 = new TiXmlElement( "DataDir" );
config->LinkEndChild( confElement31 );
confElement31->SetAttribute("value", dataDir);
doc.SaveFile( configFileName );
}
string ConfigFile::readConfigString(string varName)
{
string tempString("");
TiXmlDocument doc(configFileName);
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; }
TiXmlDocument doc(myPath.c_str());
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << myPath << "\n"; }
TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement();
@@ -294,7 +60,7 @@ string ConfigFile::readConfigString(string varName)
TiXmlElement * confElement1 = new TiXmlElement( varName );
config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", defaultValue);
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; }
return readConfigString(varName, defaultValue);
}
@@ -307,8 +73,8 @@ int ConfigFile::readConfigInt(string varName)
{
int tempInt=0;
// cout << varName << " : " << tempInt << "\n";
TiXmlDocument doc(configFileName);
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; }
TiXmlDocument doc(myPath.c_str());
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << myPath << "\n"; }
TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement();
@@ -323,7 +89,7 @@ int ConfigFile::readConfigInt(string varName)
TiXmlElement * confElement1 = new TiXmlElement( varName );
config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", defaultValue);
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; }
return readConfigInt(varName, defaultValue);
}
@@ -336,14 +102,14 @@ int ConfigFile::readConfigInt(string varName)
void ConfigFile::writeConfigInt(string varName, int varCont)
{
TiXmlDocument doc(configFileName);
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; }
TiXmlDocument doc(myPath.c_str());
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << myPath << "\n"; }
TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement();
if ( conf ) {
conf->SetAttribute("value", varCont );
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; }
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; }
} else {
//Wenn nicht gefunden eines neues Anlegen
TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement();
@@ -354,17 +120,17 @@ void ConfigFile::writeConfigInt(string varName, int varCont)
config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", varCont);
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"; }
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; }
}
void ConfigFile::writeConfigString(string varName, string varCont)
{
TiXmlDocument doc(configFileName);
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; }
TiXmlDocument doc(myPath.c_str());
if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << myPath << "\n"; }
TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement();
@@ -377,10 +143,10 @@ void ConfigFile::writeConfigString(string varName, string varCont)
TiXmlElement * confElement1 = new TiXmlElement( varName );
config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", varCont);
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"; }
if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << myPath << "\n"; }
}
+3 -9
View File
@@ -25,25 +25,19 @@
class ConfigFile{
public:
ConfigFile();
ConfigFile(std::string);
~ConfigFile();
void createDefaultConfig();
std::string readConfigString(std::string varName);
void writeConfigString(std::string varName, std::string varCont);
int readConfigInt(std::string varName);
void writeConfigInt(std::string varName, int varCont);
private:
std::string configFileName;
std::string logDir;
std::string dataDir;
int configRev;
std::string myPath;
};
#endif
+2 -1
View File
@@ -27,6 +27,7 @@
#include "flopinterface.h"
#include "turninterface.h"
#include "riverinterface.h"
#include "session.h"
class EngineFactory{
@@ -36,7 +37,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 BoardInterface* createBoard() =0;
virtual PlayerInterface* createPlayer(BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB) =0;
virtual PlayerInterface* createPlayer(Session*s, 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 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;
@@ -35,7 +35,7 @@ HandInterface* LocalEngineFactory::createHand(EngineFactory *f, GuiInterface *g,
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
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); }
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); }
PreflopInterface* LocalEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalPreflop(hi, id, aP, dP, sB); }
+2 -1
View File
@@ -29,6 +29,7 @@
#include "localflop.h"
#include "localturn.h"
#include "localriver.h"
#include "session.h"
class LocalEngineFactory : public EngineFactory
{
@@ -39,7 +40,7 @@ public:
HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC);
BoardInterface* createBoard();
PlayerInterface* createPlayer(BoardInterface *b, int id, std::string name, std::string avatar, int sC, bool aS, int mB);
PlayerInterface* createPlayer(Session *s, 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);
FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB);
TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB);
+11 -13
View File
@@ -23,7 +23,7 @@
using namespace std;
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)
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)
{
// for statistic development
@@ -32,7 +32,9 @@ LocalPlayer::LocalPlayer(BoardInterface *b, int id, std::string name, std::strin
// myCash=0;
// }
////////////////////////////
myConfig = new ConfigFile(mySession->getConfigPath());
// myBestHandPosition mit -1 initialisieren
int i;
for(i=0; i<5; i++) {
@@ -83,12 +85,11 @@ void LocalPlayer::setHand(HandInterface* br) { actualHand = br; }
void LocalPlayer::action() {
ConfigFile myConfig;
switch(actualHand->getActualRound()) {
case 0: {
if(myConfig.readConfigInt("EngineVersion")) preflopEngine3();
if(myConfig->readConfigInt("EngineVersion")) preflopEngine3();
else preflopEngine();
actualBoard->collectSets();
@@ -97,7 +98,7 @@ void LocalPlayer::action() {
} break;
case 1: {
if(myConfig.readConfigInt("EngineVersion")) flopEngine3();
if(myConfig->readConfigInt("EngineVersion")) flopEngine3();
else flopEngine();
actualBoard->collectSets();
@@ -106,7 +107,7 @@ void LocalPlayer::action() {
} break;
case 2: {
if(myConfig.readConfigInt("EngineVersion")) turnEngine3();
if(myConfig->readConfigInt("EngineVersion")) turnEngine3();
else turnEngine();
actualBoard->collectSets();
@@ -115,7 +116,7 @@ void LocalPlayer::action() {
} break;
case 3: {
if(myConfig.readConfigInt("EngineVersion")) riverEngine3();
if(myConfig->readConfigInt("EngineVersion")) riverEngine3();
else riverEngine();
actualBoard->collectSets();
@@ -809,7 +810,6 @@ void LocalPlayer::flopEngine() {
void LocalPlayer::turnEngine() {
ConfigFile myConfig;
// int tempArray[6];
// int boardCards[5];
@@ -1056,7 +1056,6 @@ void LocalPlayer::turnEngine() {
void LocalPlayer::riverEngine() {
ConfigFile myConfig;
// int tempArray[6];
// int boardCards[5];
@@ -2057,7 +2056,6 @@ int LocalPlayer::flopCardsValue(int* cards) {
void LocalPlayer::readFile() {
ConfigFile myConfig;
int handCode;
switch(actualHand->getActualRound()) {
@@ -2066,7 +2064,7 @@ void LocalPlayer::readFile() {
handCode = preflopCardsValue(myCards);
std::string fileName = myConfig.readConfigString("DataDir")+"preflopValues";
std::string fileName = myConfig->readConfigString("DataDir")+"preflopValues";
ifstream fin;
@@ -2120,7 +2118,7 @@ void LocalPlayer::readFile() {
// cout << "\t" << handCode << endl;
std::string fileName = myConfig.readConfigString("DataDir")+"flopValues";
std::string fileName = myConfig->readConfigString("DataDir")+"flopValues";
ifstream fin;
+4 -2
View File
@@ -25,6 +25,7 @@
#include "cardsvalue.h"
#include "configfile.h"
#include "session.h"
#include <string>
#include <fstream>
@@ -36,7 +37,7 @@ class BoardInterface;
class LocalPlayer : public PlayerInterface{
public:
LocalPlayer(BoardInterface*, int, std::string, std::string, int, bool, int);
LocalPlayer(Session*, BoardInterface*, int, std::string, std::string, int, bool, int);
~LocalPlayer();
@@ -140,10 +141,11 @@ public:
private:
Session *mySession;
HandInterface *actualHand;
BoardInterface *actualBoard;
CardsValue *myCardsValue;
ConfigFile *myConfig;
// Konstanten
int myID;
+5 -2
View File
@@ -28,13 +28,16 @@
#include "handinterface.h"
#include "configfile.h"
#include "session.h"
using namespace std;
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)
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)
{
// cout << "Create Game Object" << "\n";
int i;
myConfig = new ConfigFile(mySession->getConfigPath());
actualHandID = 0;
@@ -69,7 +72,7 @@ Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB, int gId) : my
else { myAvatar << "Opponent" << i << "Avatar"; }
//PlayerObjekte erzeugen
tempPlayer = myFactory->createPlayer(actualBoard, i, myConfig->readConfigString(myName.str()), myConfig->readConfigString(myAvatar.str()), startCash, startQuantityPlayers > i, 0);
tempPlayer = myFactory->createPlayer(mySession, actualBoard, i, myConfig->readConfigString(myName.str()), myConfig->readConfigString(myAvatar.str()), startCash, startQuantityPlayers > i, 0);
playerArray[i] = tempPlayer;
}
actualBoard->setPlayer(playerArray);
+4 -1
View File
@@ -32,12 +32,14 @@ class PlayerInterface;
class BoardInterface;
class EngineFactory;
class ConfigFile;
class Session;
class Game {
public:
Game(ConfigFile*, GuiInterface*, int, int, int, int);
Game(Session*, GuiInterface*, int, int, int, int);
~Game();
@@ -82,6 +84,7 @@ public:
private:
EngineFactory *myFactory;
Session *mySession;
ConfigFile *myConfig;
GuiInterface *myGui;
+1 -3
View File
@@ -90,13 +90,11 @@ public:
// virtual void timerBlockerFalse() const=0;
virtual void meInAction() const=0;
//log.cpp
virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0;
virtual void logNewGameHandMsg(int gameID, int HandID) =0;
//qthelper.cpp
virtual std::string stringToUtf8(const std::string &) =0;
};
@@ -21,11 +21,13 @@
#include "session.h"
#include "configfile.h"
createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent)
: QDialog(parent)
createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, std::string path)
: QDialog(parent), myConfig(0)
{
setupUi(this);
myConfig = new ConfigFile(path);
setupUi(this);
fillFormular();
@@ -46,14 +48,13 @@ void createNetworkGameDialogImpl::cancel() {
void createNetworkGameDialogImpl::fillFormular() {
//Formulare Füllen
ConfigFile myConfig;
//Network Game Settings
spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NetNumberOfPlayers"));
spinBox_startCash->setValue(myConfig.readConfigInt("NetStartCash"));
spinBox_smallBlind->setValue(myConfig.readConfigInt("NetSmallBlind"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("NetHandsBeforeRaiseSmallBlind"));
spinBox_gameSpeed->setValue(myConfig.readConfigInt("NetGameSpeed"));
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash"));
spinBox_smallBlind->setValue(myConfig->readConfigInt("NetSmallBlind"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("NetHandsBeforeRaiseSmallBlind"));
spinBox_gameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed"));
}
void createNetworkGameDialogImpl::showDialog() {
@@ -23,15 +23,18 @@
#include "ui_createnetworkgamedialog.h"
#include <iostream>
#include <string>
#include <QtGui>
#include <QtCore>
class Session;
class ConfigFile;
class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog {
Q_OBJECT
public:
createNetworkGameDialogImpl(QWidget *parent = 0);
createNetworkGameDialogImpl(QWidget *parent = 0, std::string = "");
public slots:
@@ -40,6 +43,10 @@ public slots:
void fillFormular();
void showDialog();
void keyPressEvent ( QKeyEvent * event );
private:
ConfigFile *myConfig;
};
#endif
+288
View File
@@ -0,0 +1,288 @@
/***************************************************************************
* 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 "defaultconfig.h"
#include <QtCore>
#include <cstdlib>
#include <fstream>
#include <sys/types.h>
#include <sys/stat.h>
#define MODUS 0711
#ifdef _WIN32
#include <windows.h>
#include <direct.h>
#endif
using namespace std;
DefaultConfig::DefaultConfig()
{
// !!!! Revisionsnummer der Configdefaults !!!!!
configRev = 17;
// Pfad und Dateinamen setzen
#ifdef _WIN32
const char *appDataPath = getenv("AppData");
if (appDataPath && appDataPath[0] != 0) {
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;
}
}
//UTF8 !!!!
QString tmpString = QString::fromStdString(configFileName);
configFileName = tmpString.toUtf8().constData();
//UTF8 !!!!
//Programmordner erstellen
configFileName += "\\pokerth\\";
mkdir(configFileName.c_str());
//Log-File Ordner auch erstellen
logDir = configFileName;
logDir += "log-files\\";
mkdir(logDir.c_str());
//data Ordner auch erstellen
dataDir = configFileName;
dataDir += "data\\";
mkdir(dataDir.c_str());
#else
//Programmordner erstellen
const char *homePath = getenv("HOME");
if(homePath) {
configFileName = homePath;
configFileName += "/.pokerth/";
mkdir(configFileName.c_str(), MODUS) ;
//Log-File Ordner auch erstellen
logDir = configFileName;
logDir += "log-files/";
mkdir(logDir.c_str(), MODUS);
//data Ordner auch erstellen
dataDir = configFileName;
dataDir += "data/";
mkdir(dataDir.c_str(), MODUS);
}
#endif
configFileName += "config.xml";
//Prüfen ob Configfile existiert --> sonst anlegen
TiXmlDocument doc(configFileName);
if(!doc.LoadFile()){ createDefaultConfig(); }
else {
//Prüfen ob die Revision stimmt ansonsten löschen und neue anlegen
int temp = 0;
TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement();
if ( conf ) { conf->QueryIntAttribute("value", &temp ); }
if (temp < configRev) { /*löschen()*/ createDefaultConfig() ;}
}
}
DefaultConfig::~DefaultConfig()
{
}
void DefaultConfig::createDefaultConfig() {
//Anlegen!
TiXmlDocument doc;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "");
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement( "PokerTH" );
doc.LinkEndChild( root );
//
TiXmlElement * config;
config = new TiXmlElement( "Configuration" );
root->LinkEndChild( config );
TiXmlElement * confElement0 = new TiXmlElement( "ConfigRevision" );
config->LinkEndChild( confElement0 );
confElement0->SetAttribute("value", configRev);
TiXmlElement * confElement11 = new TiXmlElement( "ShowLeftToolBox" );
config->LinkEndChild( confElement11 );
confElement11->SetAttribute("value", 1);
TiXmlElement * confElement22 = new TiXmlElement( "ShowRightToolBox" );
config->LinkEndChild( confElement22 );
confElement22->SetAttribute("value", 1);
TiXmlElement * confElement43 = new TiXmlElement( "ShowStatusbarMessages" );
config->LinkEndChild( confElement43 );
confElement43->SetAttribute("value", 1);
TiXmlElement * confElement13 = new TiXmlElement( "ShowIntro" );
config->LinkEndChild( confElement13 );
confElement13->SetAttribute("value", 1);
TiXmlElement * confElement15 = new TiXmlElement( "ShowFadeOutCardsAnimation" );
config->LinkEndChild( confElement15 );
confElement15->SetAttribute("value", 1);
TiXmlElement * confElement19 = new TiXmlElement( "ShowFlipCardsAnimation" );
config->LinkEndChild( confElement19 );
confElement19->SetAttribute("value", 1);
TiXmlElement * confElement16 = new TiXmlElement( "FlipsideTux" );
config->LinkEndChild( confElement16 );
confElement16->SetAttribute("value", 1);
TiXmlElement * confElement17 = new TiXmlElement( "FlipsideOwn" );
config->LinkEndChild( confElement17 );
confElement17->SetAttribute("value", 0);
TiXmlElement * confElement18 = new TiXmlElement( "FlipsideOwnFile" );
config->LinkEndChild( confElement18 );
confElement18->SetAttribute("value", "");
TiXmlElement * confElement1 = new TiXmlElement( "NumberOfPlayers" );
config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", 7);
TiXmlElement * confElement2 = new TiXmlElement( "StartCash" );
config->LinkEndChild( confElement2 );
confElement2->SetAttribute("value", 3000);
TiXmlElement * confElement3 = new TiXmlElement( "SmallBlind" );
config->LinkEndChild( confElement3 );
confElement3->SetAttribute("value", 10);
TiXmlElement * confElement12 = new TiXmlElement( "HandsBeforeRaiseSmallBlind" );
config->LinkEndChild( confElement12 );
confElement12->SetAttribute("value", 8);
TiXmlElement * confElement4 = new TiXmlElement( "GameSpeed" );
config->LinkEndChild( confElement4 );
confElement4->SetAttribute("value", 4);
TiXmlElement * confElement32 = new TiXmlElement( "EngineVersion" );
config->LinkEndChild( confElement32 );
confElement32->SetAttribute("value", 0);
TiXmlElement * confElement14 = new TiXmlElement( "PauseBetweenHands" );
config->LinkEndChild( confElement14 );
confElement14->SetAttribute("value", 0);
TiXmlElement * confElement5 = new TiXmlElement( "ShowGameSettingsDialogOnNewGame" );
config->LinkEndChild( confElement5 );
confElement5->SetAttribute("value", 1);
TiXmlElement * confElement23 = new TiXmlElement( "NetNumberOfPlayers" );
config->LinkEndChild( confElement23 );
confElement23->SetAttribute("value", 7);
TiXmlElement * confElement24 = new TiXmlElement( "NetStartCash" );
config->LinkEndChild( confElement24 );
confElement24->SetAttribute("value", 2000);
TiXmlElement * confElement25 = new TiXmlElement( "NetSmallBlind" );
config->LinkEndChild( confElement25 );
confElement25->SetAttribute("value", 10);
TiXmlElement * confElement26 = new TiXmlElement( "NetHandsBeforeRaiseSmallBlind" );
config->LinkEndChild( confElement26 );
confElement26->SetAttribute("value", 9);
TiXmlElement * confElement27 = new TiXmlElement( "NetGameSpeed" );
config->LinkEndChild( confElement27 );
confElement27->SetAttribute("value", 4);
TiXmlElement * confElement33 = new TiXmlElement( "NetEngineVersion" );
config->LinkEndChild( confElement33 );
confElement33->SetAttribute("value", 1);
TiXmlElement * confElement28 = new TiXmlElement( "ServerPassword" );
config->LinkEndChild( confElement28 );
confElement28->SetAttribute("value", "");
TiXmlElement * confElement29 = new TiXmlElement( "ServerUseIpv6" );
config->LinkEndChild( confElement29 );
confElement29->SetAttribute("value", 0);
TiXmlElement * confElement30 = new TiXmlElement( "ServerPort" );
config->LinkEndChild( confElement30 );
confElement30->SetAttribute("value", 7234);
TiXmlElement * confElement6 = new TiXmlElement( "MyName" );
config->LinkEndChild( confElement6 );
confElement6->SetAttribute("value", "Human Player");
TiXmlElement * confElement34 = new TiXmlElement( "MyAvatar" );
config->LinkEndChild( confElement34 );
confElement34->SetAttribute("value", "");
TiXmlElement * confElement7 = new TiXmlElement( "Opponent1Name" );
config->LinkEndChild( confElement7 );
confElement7->SetAttribute("value", "Player 1");
TiXmlElement * confElement35 = new TiXmlElement( "Opponent1Avatar" );
config->LinkEndChild( confElement35 );
confElement35->SetAttribute("value", "");
TiXmlElement * confElement8 = new TiXmlElement( "Opponent2Name" );
config->LinkEndChild( confElement8 );
confElement8->SetAttribute("value", "Player 2");
TiXmlElement * confElement36 = new TiXmlElement( "Opponent2Avatar" );
config->LinkEndChild( confElement36 );
confElement36->SetAttribute("value", "");
TiXmlElement * confElement9 = new TiXmlElement( "Opponent3Name" );
config->LinkEndChild( confElement9 );
confElement9->SetAttribute("value", "Player 3");
TiXmlElement * confElement37 = new TiXmlElement( "Opponent3Avatar" );
config->LinkEndChild( confElement37 );
confElement37->SetAttribute("value", "");
TiXmlElement * confElement10 = new TiXmlElement( "Opponent4Name" );
config->LinkEndChild( confElement10 );
confElement10->SetAttribute("value", "Player 4");
TiXmlElement * confElement38 = new TiXmlElement( "Opponent4Avatar" );
config->LinkEndChild( confElement38 );
confElement38->SetAttribute("value", "");
TiXmlElement * confElement39 = new TiXmlElement( "Opponent5Name" );
config->LinkEndChild( confElement39 );
confElement39->SetAttribute("value", "Player 5");
TiXmlElement * confElement40 = new TiXmlElement( "Opponent5Avatar" );
config->LinkEndChild( confElement40 );
confElement40->SetAttribute("value", "");
TiXmlElement * confElement41 = new TiXmlElement( "Opponent6Name" );
config->LinkEndChild( confElement41 );
confElement41->SetAttribute("value", "Player 6");
TiXmlElement * confElement42 = new TiXmlElement( "Opponent6Avatar" );
config->LinkEndChild( confElement42 );
confElement42->SetAttribute("value", "");
TiXmlElement * confElement20 = new TiXmlElement( "LogDir" );
config->LinkEndChild( confElement20 );
confElement20->SetAttribute("value", logDir);
TiXmlElement * confElement21 = new TiXmlElement( "LogStoreDuration" );
config->LinkEndChild( confElement21 );
confElement21->SetAttribute("value", 2);
TiXmlElement * confElement31 = new TiXmlElement( "DataDir" );
config->LinkEndChild( confElement31 );
confElement31->SetAttribute("value", dataDir);
doc.SaveFile( configFileName );
}
+44
View File
@@ -0,0 +1,44 @@
/***************************************************************************
* 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 DEFAULTCONFIG_H
#define DEFAULTCONFIG_H
#include "tinyxml.h"
#include <string>
class DefaultConfig{
public:
DefaultConfig();
~DefaultConfig();
void createDefaultConfig();
std::string getMyPath() const { return configFileName; }
private:
std::string configFileName;
std::string logDir;
std::string dataDir;
int configRev;
};
#endif
+3 -9
View File
@@ -24,16 +24,13 @@
using namespace std;
GuiWrapper::GuiWrapper() : myLog(0), myW(0)
GuiWrapper::GuiWrapper(Session *session) : myLog(0), myW(0)
{
myW = new mainWindowImpl;
myW = new mainWindowImpl(session);
myW->show();
myLog = new Log(myW);
myConfig = new ConfigFile;
}
@@ -88,9 +85,6 @@ void GuiWrapper::meInAction() const { myW->meInAction(); }
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); }
std::string GuiWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); }
void GuiWrapper::SignalNetClientConnect(int actionID) { myW->SignalNetClientConnect(actionID); }
void GuiWrapper::SignalNetClientGameInfo(int actionID) { myW->SignalNetClientGameInfo(actionID); }
void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->SignalNetClientError(errorID, osErrorID); }
+1 -6
View File
@@ -25,7 +25,6 @@
#include "log.h"
#include "mainwindowimpl.h"
#include "connecttoserverdialogimpl.h"
#include "qthelper.h"
#include "configfile.h"
#include <string>
@@ -39,7 +38,7 @@
class GuiWrapper : public GuiInterface
{
public:
GuiWrapper();
GuiWrapper(Session*);
~GuiWrapper();
@@ -89,8 +88,6 @@ public:
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
void logNewGameHandMsg(int gameID, int handID) ;
std::string stringToUtf8(const std::string &);
void SignalNetClientConnect(int actionID);
void SignalNetClientGameInfo(int actionID);
void SignalNetClientError(int errorID, int osErrorID);
@@ -103,8 +100,6 @@ private:
Log *myLog;
mainWindowImpl *myW;
ConfigFile *myConfig;
QtHelper *myQtHelper;
};
@@ -24,11 +24,12 @@
using namespace std;
joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent)
: QDialog(parent)
joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent, std::string path)
: QDialog(parent), myConfig(0)
{
setupUi(this);
myConfig = new ConfigFile(path);
setupUi(this);
//Profile Name darf nicht mit einer Zahl beginnen --> XML konform
QRegExp rx("[A-Z|a-z]+[A-Z|a-z|\\d]*");
@@ -39,7 +40,7 @@ joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent)
lineEdit_ipAddress->setFocus();
myServerProfilesFile = myConfig.readConfigString("DataDir")+"serverprofiles.xml";
myServerProfilesFile = myConfig->readConfigString("DataDir")+"serverprofiles.xml";
//Anlegen wenn noch nicht existiert!
QFile serverProfilesfile(QString::fromUtf8(myServerProfilesFile.c_str()));
@@ -24,7 +24,6 @@
#include <iostream>
#include <string>
#include "configfile.h"
#include <QtGui>
#include <QtCore>
@@ -34,9 +33,9 @@ class ConfigFile;
class joinNetworkGameDialogImpl: public QDialog, public Ui::joinNetworkGameDialog {
Q_OBJECT
public:
joinNetworkGameDialogImpl(QWidget *parent = 0);
joinNetworkGameDialogImpl(QWidget *parent = 0, std::string = "");
ConfigFile myConfig;
std::string myServerProfilesFile;
public slots:
@@ -47,6 +46,9 @@ public slots:
void saveServerProfile();
void deleteServerProfile();
void keyPressEvent ( QKeyEvent * event );
private:
ConfigFile *myConfig;
};
#endif
+3 -1
View File
@@ -21,6 +21,7 @@
#include "mainwindowimpl.h"
#include <game_defs.h>
#include "session.h"
using namespace std;
@@ -28,7 +29,8 @@ Log::Log(mainWindowImpl* w) : myW(w)
{
myW->setLog(this);
myConfig = new ConfigFile;
myConfig = new ConfigFile(myW->getSession()->getConfigPath());
if(myConfig->readConfigString("LogDir") != "" && QDir::QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())).exists()) {
#ifdef _WIN32
-1
View File
@@ -30,7 +30,6 @@
class mainWindowImpl;
class Log{
public:
Log(mainWindowImpl*);
+16 -9
View File
@@ -39,6 +39,7 @@
#include "log.h"
#include "configfile.h"
#include "defaultconfig.h"
#include <net/socket_msg.h>
@@ -48,8 +49,8 @@
using namespace std;
mainWindowImpl::mainWindowImpl(QMainWindow *parent)
: QMainWindow(parent), actualGame(0), actualHand(0), mySession(0), gameSpeed(0), debugMode(0), breakAfterActualHand(FALSE)
mainWindowImpl::mainWindowImpl(Session* s, QMainWindow *parent)
: QMainWindow(parent), actualGame(0), actualHand(0), mySession(s), gameSpeed(0), debugMode(0), breakAfterActualHand(FALSE)
{
int i;
@@ -59,7 +60,13 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent)
}
////////////////////////////
myConfig = new ConfigFile;
//Create Defaultconfig if there is no one
DefaultConfig myDefaultConfig;
//set SessionConfigPath
mySession->setConfigPath(myDefaultConfig.getMyPath());
myConfig = new ConfigFile(mySession->getConfigPath());
// Resourcen abladen
QFile preflopValuesFile(":data/resources/data/preflopValues");
@@ -479,10 +486,10 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent)
}
//Dialoge
myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this);
myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this, mySession->getConfigPath());
myConnectToServerDialog = new connectToServerDialogImpl(this);
myStartNetworkGameDialog = new startNetworkGameDialogImpl(this);
myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this);
myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, mySession->getConfigPath());
myWaitingForServerGameDialog = new waitForServerToStartGameDialogImpl(this);
//Connects
@@ -554,7 +561,7 @@ void mainWindowImpl::callNewGameDialog() {
//wenn Dialogfenster gezeigt werden soll
if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){
newGameDialogImpl *v = new newGameDialogImpl(this);
newGameDialogImpl *v = new newGameDialogImpl(this, mySession->getConfigPath());
v->exec();
if (v->result() == QDialog::Accepted ) { startNewLocalGame(v); }
// else { startNewLocalGame(); }
@@ -685,7 +692,7 @@ void mainWindowImpl::callJoinNetworkGameDialog() {
void mainWindowImpl::callSettingsDialog() {
settingsDialogImpl *v = new settingsDialogImpl(this);
settingsDialogImpl *v = new settingsDialogImpl(this, mySession->getConfigPath());
v->exec();
@@ -826,7 +833,7 @@ void mainWindowImpl::refreshPlayerAvatar() {
if(actualHand->getPlayerArray()[i]->getMyActiveStatus()) {
if(!i) {
if(actualHand->getPlayerArray()[0]->getMyAvatar() == "") {
if(actualHand->getPlayerArray()[0]->getMyAvatar() == ""/* || !QDir::QDir(QString::fromUtf8(actualHand->getPlayerArray()[0]->getMyAvatar().c_str())).exists()*/) {
playerAvatarLabelArray[0]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png"));
}
else {
@@ -834,7 +841,7 @@ void mainWindowImpl::refreshPlayerAvatar() {
}
}
else {
if(actualHand->getPlayerArray()[i]->getMyAvatar() == "") {
if(actualHand->getPlayerArray()[i]->getMyAvatar() == ""/* || !QDir::QDir(QString::fromUtf8(actualHand->getPlayerArray()[i]->getMyAvatar().c_str())).exists()*/) {
playerAvatarLabelArray[i]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png"));
}
else {
+2 -1
View File
@@ -53,13 +53,14 @@ class mainWindowImpl: public QMainWindow, public Ui::mainWindow {
Q_OBJECT
public:
mainWindowImpl(QMainWindow *parent = 0 );
mainWindowImpl(Session* = 0, QMainWindow *parent = 0 );
~mainWindowImpl();
void setGame(Game*);
void setHand(HandInterface*);
void setSession(Session*);
Session* getSession() { return mySession; }
void setLog(Log*);
void setActualHand(HandInterface* theValue) { actualHand = theValue;}
@@ -20,22 +20,22 @@
#include "newgamedialogimpl.h"
#include "configfile.h"
newGameDialogImpl::newGameDialogImpl(QWidget *parent)
newGameDialogImpl::newGameDialogImpl(QWidget *parent, std::string path)
: QDialog(parent)
{
setupUi(this);
//Formulare Füllen
ConfigFile myConfig;
myConfig = new ConfigFile(path);
//Game Settings
spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers"));
spinBox_startCash->setValue(myConfig.readConfigInt("StartCash"));
spinBox_smallBlind->setValue(myConfig.readConfigInt("SmallBlind"));
spinBox_gameSpeed->setValue(myConfig.readConfigInt("GameSpeed"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("HandsBeforeRaiseSmallBlind"));
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NumberOfPlayers"));
spinBox_startCash->setValue(myConfig->readConfigInt("StartCash"));
spinBox_smallBlind->setValue(myConfig->readConfigInt("SmallBlind"));
spinBox_gameSpeed->setValue(myConfig->readConfigInt("GameSpeed"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("HandsBeforeRaiseSmallBlind"));
}
@@ -23,17 +23,22 @@
#include "ui_newgamedialog.h"
#include <iostream>
#include <string>
#include <QtGui>
#include <QtCore>
class ConfigFile;
class newGameDialogImpl: public QDialog, public Ui::newGameDialog {
Q_OBJECT
public:
newGameDialogImpl(QWidget *parent = 0);
newGameDialogImpl(QWidget *parent = 0, std::string = "");
public slots:
private:
ConfigFile *myConfig;
};
#endif
-30
View File
@@ -1,30 +0,0 @@
//
// 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
@@ -1,29 +0,0 @@
//
// 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,9 +22,10 @@
#include <iostream>
settingsDialogImpl::settingsDialogImpl(QWidget *parent)
settingsDialogImpl::settingsDialogImpl(QWidget *parent, std::string path)
: QDialog(parent)
{
myConfig = new ConfigFile(path);
setupUi(this);
@@ -35,64 +36,64 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent)
playerNickIsChanged = FALSE;
//Formulare Füllen
ConfigFile myConfig;
//Player Nicks
lineEdit_humanPlayerName->setText(QString::fromUtf8(myConfig.readConfigString("MyName").c_str()));
lineEdit_humanPlayerAvatar->setText(QString::fromUtf8(myConfig.readConfigString("MyAvatar").c_str()));
lineEdit_Opponent1Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent1Name").c_str()));
lineEdit_Opponent1Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent1Avatar").c_str()));
lineEdit_Opponent2Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent2Name").c_str()));
lineEdit_Opponent2Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent2Avatar").c_str()));
lineEdit_Opponent3Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent3Name").c_str()));
lineEdit_Opponent3Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent3Avatar").c_str()));
lineEdit_Opponent4Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent4Name").c_str()));
lineEdit_Opponent4Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent4Avatar").c_str()));
lineEdit_Opponent5Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent5Name").c_str()));
lineEdit_Opponent5Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent5Avatar").c_str()));
lineEdit_Opponent6Name->setText(QString::fromUtf8(myConfig.readConfigString("Opponent6Name").c_str()));
lineEdit_Opponent6Avatar->setText(QString::fromUtf8(myConfig.readConfigString("Opponent6Avatar").c_str()));
lineEdit_humanPlayerName->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()));
lineEdit_humanPlayerAvatar->setText(QString::fromUtf8(myConfig->readConfigString("MyAvatar").c_str()));
lineEdit_Opponent1Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent1Name").c_str()));
lineEdit_Opponent1Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent1Avatar").c_str()));
lineEdit_Opponent2Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent2Name").c_str()));
lineEdit_Opponent2Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent2Avatar").c_str()));
lineEdit_Opponent3Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent3Name").c_str()));
lineEdit_Opponent3Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent3Avatar").c_str()));
lineEdit_Opponent4Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent4Name").c_str()));
lineEdit_Opponent4Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent4Avatar").c_str()));
lineEdit_Opponent5Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent5Name").c_str()));
lineEdit_Opponent5Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent5Avatar").c_str()));
lineEdit_Opponent6Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent6Name").c_str()));
lineEdit_Opponent6Avatar->setText(QString::fromUtf8(myConfig->readConfigString("Opponent6Avatar").c_str()));
//Local Game Settings
spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers"));
spinBox_startCash->setValue(myConfig.readConfigInt("StartCash"));
spinBox_smallBlind->setValue(myConfig.readConfigInt("SmallBlind"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("HandsBeforeRaiseSmallBlind"));
spinBox_gameSpeed->setValue(myConfig.readConfigInt("GameSpeed"));
checkBox_pauseBetweenHands->setChecked(myConfig.readConfigInt("PauseBetweenHands"));
checkBox_showGameSettingsDialogOnNewGame->setChecked(myConfig.readConfigInt("ShowGameSettingsDialogOnNewGame"));
comboBox_engineVersion->setCurrentIndex(myConfig.readConfigInt("EngineVersion"));
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NumberOfPlayers"));
spinBox_startCash->setValue(myConfig->readConfigInt("StartCash"));
spinBox_smallBlind->setValue(myConfig->readConfigInt("SmallBlind"));
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("HandsBeforeRaiseSmallBlind"));
spinBox_gameSpeed->setValue(myConfig->readConfigInt("GameSpeed"));
checkBox_pauseBetweenHands->setChecked(myConfig->readConfigInt("PauseBetweenHands"));
checkBox_showGameSettingsDialogOnNewGame->setChecked(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame"));
comboBox_engineVersion->setCurrentIndex(myConfig->readConfigInt("EngineVersion"));
//Network Game Settings
spinBox_netQuantityPlayers->setValue(myConfig.readConfigInt("NetNumberOfPlayers"));
spinBox_netStartCash->setValue(myConfig.readConfigInt("NetStartCash"));
spinBox_netSmallBlind->setValue(myConfig.readConfigInt("NetSmallBlind"));
spinBox_netHandsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("NetHandsBeforeRaiseSmallBlind"));
spinBox_netGameSpeed->setValue(myConfig.readConfigInt("NetGameSpeed"));
comboBox_netEngineVersion->setCurrentIndex(myConfig.readConfigInt("NetEngineVersion"));
spinBox_serverPort->setValue(myConfig.readConfigInt("ServerPort"));
lineEdit_serverPassword->setText(QString::fromUtf8(myConfig.readConfigString("ServerPassword").c_str()));
checkBox_useIpv6->setChecked(myConfig.readConfigInt("ServerUseIpv6"));
spinBox_netQuantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
spinBox_netStartCash->setValue(myConfig->readConfigInt("NetStartCash"));
spinBox_netSmallBlind->setValue(myConfig->readConfigInt("NetSmallBlind"));
spinBox_netHandsBeforeRaiseSmallBlind->setValue(myConfig->readConfigInt("NetHandsBeforeRaiseSmallBlind"));
spinBox_netGameSpeed->setValue(myConfig->readConfigInt("NetGameSpeed"));
comboBox_netEngineVersion->setCurrentIndex(myConfig->readConfigInt("NetEngineVersion"));
spinBox_serverPort->setValue(myConfig->readConfigInt("ServerPort"));
lineEdit_serverPassword->setText(QString::fromUtf8(myConfig->readConfigString("ServerPassword").c_str()));
checkBox_useIpv6->setChecked(myConfig->readConfigInt("ServerUseIpv6"));
//Interface
checkBox_showLeftToolbox->setChecked(myConfig.readConfigInt("ShowLeftToolBox"));
checkBox_showRightToolbox->setChecked(myConfig.readConfigInt("ShowRightToolBox"));
checkBox_showStatusbarMessages->setChecked(myConfig.readConfigInt("ShowStatusbarMessages"));
checkBox_showIntro->setChecked(myConfig.readConfigInt("ShowIntro"));
checkBox_showFadeOutCardsAnimation->setChecked(myConfig.readConfigInt("ShowFadeOutCardsAnimation"));
checkBox_showFlipCardsAnimation->setChecked(myConfig.readConfigInt("ShowFlipCardsAnimation"));
radioButton_flipsideTux->setChecked(myConfig.readConfigInt("FlipsideTux"));
radioButton_flipsideOwn->setChecked(myConfig.readConfigInt("FlipsideOwn"));
checkBox_showLeftToolbox->setChecked(myConfig->readConfigInt("ShowLeftToolBox"));
checkBox_showRightToolbox->setChecked(myConfig->readConfigInt("ShowRightToolBox"));
checkBox_showStatusbarMessages->setChecked(myConfig->readConfigInt("ShowStatusbarMessages"));
checkBox_showIntro->setChecked(myConfig->readConfigInt("ShowIntro"));
checkBox_showFadeOutCardsAnimation->setChecked(myConfig->readConfigInt("ShowFadeOutCardsAnimation"));
checkBox_showFlipCardsAnimation->setChecked(myConfig->readConfigInt("ShowFlipCardsAnimation"));
radioButton_flipsideTux->setChecked(myConfig->readConfigInt("FlipsideTux"));
radioButton_flipsideOwn->setChecked(myConfig->readConfigInt("FlipsideOwn"));
if(radioButton_flipsideOwn->isChecked()) {
lineEdit_OwnFlipsideFilename->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
lineEdit_logDir->setText(QString::fromUtf8(myConfig.readConfigString("LogDir").c_str()));
spinBox_logStoreDuration->setValue(myConfig.readConfigInt("LogStoreDuration"));
lineEdit_logDir->setText(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration"));
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( isAccepted() ) );
connect( lineEdit_humanPlayerName, SIGNAL( textChanged( const QString &) ), this, SLOT( playerNickChanged() ) );
@@ -118,12 +119,11 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = TRUE;
//Daten speichern
ConfigFile myConfig;
// 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() == "") {
myConfig.writeConfigString("MyAvatar", lineEdit_humanPlayerAvatar->text().toUtf8().constData());
myConfig->writeConfigString("MyAvatar", lineEdit_humanPlayerAvatar->text().toUtf8().constData());
}
else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered human player avatar picture doesn't exists.\n"
@@ -132,9 +132,9 @@ void settingsDialogImpl::isAccepted() {
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() == "") {
myConfig.writeConfigString("Opponent1Avatar", lineEdit_Opponent1Avatar->text().toUtf8().constData());
myConfig->writeConfigString("Opponent1Avatar", lineEdit_Opponent1Avatar->text().toUtf8().constData());
}
else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 1\" avatar picture doesn't exists.\n"
@@ -143,9 +143,9 @@ void settingsDialogImpl::isAccepted() {
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() == "") {
myConfig.writeConfigString("Opponent2Avatar", lineEdit_Opponent2Avatar->text().toUtf8().constData());
myConfig->writeConfigString("Opponent2Avatar", lineEdit_Opponent2Avatar->text().toUtf8().constData());
}
else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 2\" avatar picture doesn't exists.\n"
@@ -154,9 +154,9 @@ void settingsDialogImpl::isAccepted() {
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() == "") {
myConfig.writeConfigString("Opponent3Avatar", lineEdit_Opponent3Avatar->text().toUtf8().constData());
myConfig->writeConfigString("Opponent3Avatar", lineEdit_Opponent3Avatar->text().toUtf8().constData());
}
else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 3\" avatar picture doesn't exists.\n"
@@ -165,9 +165,9 @@ void settingsDialogImpl::isAccepted() {
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() == "") {
myConfig.writeConfigString("Opponent4Avatar", lineEdit_Opponent4Avatar->text().toUtf8().constData());
myConfig->writeConfigString("Opponent4Avatar", lineEdit_Opponent4Avatar->text().toUtf8().constData());
}
else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 4\" avatar picture doesn't exists.\n"
@@ -176,9 +176,9 @@ void settingsDialogImpl::isAccepted() {
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() == "") {
myConfig.writeConfigString("Opponent5Avatar", lineEdit_Opponent5Avatar->text().toUtf8().constData());
myConfig->writeConfigString("Opponent5Avatar", lineEdit_Opponent5Avatar->text().toUtf8().constData());
}
else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 5\" avatar picture doesn't exists.\n"
@@ -187,9 +187,9 @@ void settingsDialogImpl::isAccepted() {
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() == "") {
myConfig.writeConfigString("Opponent6Avatar", lineEdit_Opponent6Avatar->text().toUtf8().constData());
myConfig->writeConfigString("Opponent6Avatar", lineEdit_Opponent6Avatar->text().toUtf8().constData());
}
else { QMessageBox::warning(this, tr("Settings Error"),
tr("The entered \"opponent 6\" avatar picture doesn't exists.\n"
@@ -199,38 +199,38 @@ void settingsDialogImpl::isAccepted() {
}
// Local Game Settings
myConfig.writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value());
myConfig.writeConfigInt("StartCash", spinBox_startCash->value());
myConfig.writeConfigInt("SmallBlind", spinBox_smallBlind->value());
myConfig.writeConfigInt("HandsBeforeRaiseSmallBlind", spinBox_handsBeforeRaiseSmallBlind->value());
myConfig.writeConfigInt("GameSpeed", spinBox_gameSpeed->value());
myConfig.writeConfigInt("EngineVersion", comboBox_engineVersion->currentIndex());
myConfig.writeConfigInt("PauseBetweenHands", checkBox_pauseBetweenHands->isChecked());
myConfig.writeConfigInt("ShowGameSettingsDialogOnNewGame", checkBox_showGameSettingsDialogOnNewGame->isChecked());
myConfig->writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value());
myConfig->writeConfigInt("StartCash", spinBox_startCash->value());
myConfig->writeConfigInt("SmallBlind", spinBox_smallBlind->value());
myConfig->writeConfigInt("HandsBeforeRaiseSmallBlind", spinBox_handsBeforeRaiseSmallBlind->value());
myConfig->writeConfigInt("GameSpeed", spinBox_gameSpeed->value());
myConfig->writeConfigInt("EngineVersion", comboBox_engineVersion->currentIndex());
myConfig->writeConfigInt("PauseBetweenHands", checkBox_pauseBetweenHands->isChecked());
myConfig->writeConfigInt("ShowGameSettingsDialogOnNewGame", checkBox_showGameSettingsDialogOnNewGame->isChecked());
//Network Game Settings
myConfig.writeConfigInt("NetNumberOfPlayers", spinBox_netQuantityPlayers->value());
myConfig.writeConfigInt("NetStartCash", spinBox_netStartCash->value());
myConfig.writeConfigInt("NetSmallBlind", spinBox_netSmallBlind->value());
myConfig.writeConfigInt("NetHandsBeforeRaiseSmallBlind", spinBox_netHandsBeforeRaiseSmallBlind->value());
myConfig.writeConfigInt("NetGameSpeed", spinBox_netGameSpeed->value());
myConfig.writeConfigInt("NetEngineVersion", comboBox_netEngineVersion->currentIndex());
myConfig.writeConfigInt("ServerPort", spinBox_serverPort->value());
myConfig.writeConfigString("ServerPassword", lineEdit_serverPassword->text().toUtf8().constData());
myConfig.writeConfigInt("ServerUseIpv6", checkBox_useIpv6->isChecked());
myConfig->writeConfigInt("NetNumberOfPlayers", spinBox_netQuantityPlayers->value());
myConfig->writeConfigInt("NetStartCash", spinBox_netStartCash->value());
myConfig->writeConfigInt("NetSmallBlind", spinBox_netSmallBlind->value());
myConfig->writeConfigInt("NetHandsBeforeRaiseSmallBlind", spinBox_netHandsBeforeRaiseSmallBlind->value());
myConfig->writeConfigInt("NetGameSpeed", spinBox_netGameSpeed->value());
myConfig->writeConfigInt("NetEngineVersion", comboBox_netEngineVersion->currentIndex());
myConfig->writeConfigInt("ServerPort", spinBox_serverPort->value());
myConfig->writeConfigString("ServerPassword", lineEdit_serverPassword->text().toUtf8().constData());
myConfig->writeConfigInt("ServerUseIpv6", checkBox_useIpv6->isChecked());
// Interface
myConfig.writeConfigInt("ShowLeftToolBox", checkBox_showLeftToolbox->isChecked());
myConfig.writeConfigInt("ShowRightToolBox", checkBox_showRightToolbox->isChecked());
myConfig.writeConfigInt("ShowStatusbarMessages", checkBox_showStatusbarMessages->isChecked());
myConfig.writeConfigInt("ShowIntro", checkBox_showIntro->isChecked());
myConfig.writeConfigInt("ShowFadeOutCardsAnimation", checkBox_showFadeOutCardsAnimation->isChecked());
myConfig.writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked());
myConfig.writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked());
myConfig.writeConfigInt("FlipsideOwn", radioButton_flipsideOwn->isChecked());
myConfig->writeConfigInt("ShowLeftToolBox", checkBox_showLeftToolbox->isChecked());
myConfig->writeConfigInt("ShowRightToolBox", checkBox_showRightToolbox->isChecked());
myConfig->writeConfigInt("ShowStatusbarMessages", checkBox_showStatusbarMessages->isChecked());
myConfig->writeConfigInt("ShowIntro", checkBox_showIntro->isChecked());
myConfig->writeConfigInt("ShowFadeOutCardsAnimation", checkBox_showFadeOutCardsAnimation->isChecked());
myConfig->writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked());
myConfig->writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked());
myConfig->writeConfigInt("FlipsideOwn", 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"),
tr("The entered flipside picture doesn't exists.\n"
"Please enter an valid picture!"),
@@ -240,7 +240,7 @@ void settingsDialogImpl::isAccepted() {
}
// 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 {
QMessageBox::warning(this, tr("Settings Error"),
tr("The log file directory doesn't exists.\n"
@@ -249,7 +249,7 @@ void settingsDialogImpl::isAccepted() {
settingsCorrect = FALSE;
}
myConfig.writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value());
myConfig->writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value());
//Wenn alles richtig eingegeben wurde --> Dialog schließen
if(settingsCorrect) { this->hide(); }
@@ -22,14 +22,16 @@
#include "ui_settingsdialog.h"
#include <string>
#include <QtCore>
#include <QtGui>
class ConfigFile;
class settingsDialogImpl: public QDialog, public Ui::settingsDialog {
Q_OBJECT
public:
settingsDialogImpl(QWidget *parent = 0);
settingsDialogImpl(QWidget *parent = 0, std::string = "");
void setPlayerNickIsChanged(bool theValue){ playerNickIsChanged = theValue;}
bool getPlayerNickIsChanged() const{ return playerNickIsChanged;}
@@ -53,6 +55,7 @@ private:
bool playerNickIsChanged;
bool settingsCorrect;
ConfigFile *myConfig;
};
+5 -3
View File
@@ -67,9 +67,11 @@ int main( int argc, char **argv )
Q_INIT_RESOURCE(resources);
///////////////////////////////////////////////////
GuiInterface *myGuiInterface = new GuiWrapper();
Session theFirst(myGuiInterface);
myGuiInterface->setSession(&theFirst);
Session *theFirst = new Session();
GuiInterface *myGuiInterface = new GuiWrapper(theFirst);
theFirst->setGuiInterface(myGuiInterface);
// myGuiInterface->setSession(&theFirst);
int retVal = a.exec();
+4 -4
View File
@@ -29,10 +29,10 @@
using namespace std;
Session::Session(GuiInterface *g)
: actualGameID(0), myNetClient(0), myNetServer(0), actualGame(0), myGui(g)
Session::Session()
: actualGameID(0), myNetClient(0), myNetServer(0), actualGame(0), myGui(0)
{
myConfig = new ConfigFile;
myConfig = new ConfigFile(getConfigPath());
}
@@ -49,7 +49,7 @@ void Session::startGame(int qP, int sC, int sB) {
actualGameID++;
actualGame = new Game(myConfig, myGui, qP, sC, sB, actualGameID);
actualGame = new Game(this, myGui, qP, sC, sB, actualGameID);
}
void Session::deleteGame() {
+8 -1
View File
@@ -30,10 +30,12 @@ class ServerThread;
class Session{
public:
Session(GuiInterface*);
Session();
~Session();
void setGuiInterface(GuiInterface *gui) { myGui = gui; }
void startGame(int, int, int);
void deleteGame();
@@ -48,6 +50,9 @@ public:
void setActualGameID(const int& theValue) { actualGameID = theValue; }
int getActualGameID() const { return actualGameID; }
void setConfigPath(const std::string& theValue) { configPath = theValue; }
std::string getConfigPath() const { return configPath; }
// void createConfig();
private:
@@ -61,6 +66,8 @@ private:
GuiInterface *myGui;
ConfigFile *myConfig;
std::string configPath;
};