From 0b4348b5332aaed6b861d3db774175b9fe2ccb94 Mon Sep 17 00:00:00 2001 From: doitux Date: Tue, 23 Jan 2007 00:49:45 +0000 Subject: [PATCH] ConfigFile runs with tinyXml; NewRoundTimerBlock commented. Menu->actionNewGame disabled while running Hand --- src/config/configfile.cpp | 28 ++++++++--------- src/game.cpp | 2 ++ src/gui/qt/mainwindowimpl.cpp | 53 ++++++++++++++++++-------------- src/gui/qt/newgamedialogimpl.cpp | 1 + 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index 658dc8ea..c20edcd2 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -76,7 +76,7 @@ void ConfigFile::createDefaultConfig() { TiXmlElement * confElement1 = new TiXmlElement( "NumberOfPlayers" ); config->LinkEndChild( confElement1 ); confElement1->SetAttribute("value", 5); - TiXmlElement * confElement2 = new TiXmlElement( "StartChash" ); + TiXmlElement * confElement2 = new TiXmlElement( "StartCash" ); config->LinkEndChild( confElement2 ); confElement2->SetAttribute("value", 2000); TiXmlElement * confElement3 = new TiXmlElement( "SmallBlind" ); @@ -121,9 +121,9 @@ string ConfigFile::readConfigString(string varName, string defaultValue) TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); if ( conf ) { - tempString = conf->Attribute("value"); - cout << tempString << "\n"; - } else { + const char *tmpStr = conf->Attribute("value"); + if (tmpStr) tempString = tmpStr; + } /*else { //Wenn nicht gefunden eines neues Anlegen TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement(); if ( config ) { @@ -134,7 +134,7 @@ string ConfigFile::readConfigString(string varName, string defaultValue) return readConfigString(varName, defaultValue); } - } + }*/ return tempString; } @@ -142,18 +142,18 @@ string ConfigFile::readConfigString(string varName, string defaultValue) int ConfigFile::readConfigInt(string varName, int defaultValue) { int tempInt=0; - +// cout << varName << " : " << tempInt << "\n"; TiXmlDocument doc(configFileName); - if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; } - TiXmlHandle docHandle( &doc ); - + TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); if ( conf ) { - conf->QueryValueAttribute("value", &tempInt ); - } else { - //Wenn nicht gefunden eines neues Anlegen +// cout << varName << " : " << tempInt << "\n"; + conf->QueryIntAttribute("value", &tempInt ); +// cout << varName << " : " << tempInt << "\n"; + } /*else { +// Wenn nicht gefunden eines neues Anlegen TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement(); if ( config ) { TiXmlElement * confElement1 = new TiXmlElement( varName ); @@ -163,7 +163,7 @@ int ConfigFile::readConfigInt(string varName, int defaultValue) return readConfigInt(varName, defaultValue); } - } + }*/ return tempInt; } @@ -219,4 +219,4 @@ void ConfigFile::writeConfigString(string varName, string varCont) if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; } -} \ No newline at end of file +} diff --git a/src/game.cpp b/src/game.cpp index f951210d..ec309733 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -33,6 +33,7 @@ using namespace std; Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB) : myConfig(c), myGui(g), actualHand(0), actualBoard(0), startQuantityPlayers(qP), startCash(sC), startSmallBlind(sB), actualQuantityPlayers(qP), actualSmallBlind(sB), actualHandID(0), dealerPosition(0) { +// cout << "Create Game Object" << "\n"; int i; for(i=0; igetMaxQuantityPlayers(); i++) { @@ -87,6 +88,7 @@ Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB) : myConfig(c) Game::~Game() { +// cout << "Delete Game Object" << "\n"; int i; delete actualBoard; diff --git a/src/gui/qt/mainwindowimpl.cpp b/src/gui/qt/mainwindowimpl.cpp index e6260cff..6baf3822 100755 --- a/src/gui/qt/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindowimpl.cpp @@ -208,18 +208,20 @@ void mainWindowImpl::callNewGameDialog() { mySession->deleteGame(); actualGame = 0; } + + guiGameSpeed = v->spinBox_gameSpeed->value(); + // debugMode = v->checkBox_debugMode->isChecked(); + //Speeds + setSpeeds(); //restliche Singleshots abfangen!!! - if (firstCallNewGame) { firstCallNewGame = FALSE; } - else { newRoundTimerBlock = TRUE; } - QTimer::singleShot(40*gameSpeed, this, SLOT( timerBlockerFalse() )); - +// if (firstCallNewGame) { firstCallNewGame = FALSE; } +// else { newRoundTimerBlock = TRUE; } +// QTimer::singleShot(400*gameSpeed, this, SLOT( timerBlockerFalse() )); label_Pot->setText("

Pot Total

"); label_Sets->setText("

Sets:

"); - guiGameSpeed = v->spinBox_gameSpeed->value(); - // debugMode = v->checkBox_debugMode->isChecked(); //Tools und Board aufhellen und enablen QPalette tempPalette = groupBox_board->palette(); @@ -227,8 +229,6 @@ void mainWindowImpl::callNewGameDialog() { groupBox_board->setPalette(tempPalette); groupBox_tools->setDisabled(FALSE); - //Speeds - setSpeeds(); //positioning Slider horizontalSlider_speed->setValue(guiGameSpeed); @@ -236,25 +236,29 @@ void mainWindowImpl::callNewGameDialog() { mySession->startGame(v->spinBox_quantityPlayers->value(), v->spinBox_startCash->value(), v->spinBox_smallBlind->value()); } -// } + } // sonst mit gespeicherten Werten starten -// else { + else { if(actualGame) { mySession->deleteGame(); actualGame = 0; } + guiGameSpeed = myConfig->readConfigInt("GameSpeed",4); + //Speeds + setSpeeds(); + //restliche Singleshots abfangen!!! - if (firstCallNewGame) { firstCallNewGame = FALSE; } - else { newRoundTimerBlock = TRUE; } - QTimer::singleShot(40*gameSpeed, this, SLOT( timerBlockerFalse() )); +// if (firstCallNewGame) { firstCallNewGame = FALSE; } +// else { newRoundTimerBlock = TRUE; } +// QTimer::singleShot(40*gameSpeed, this, SLOT( timerBlockerFalse() )); label_Pot->setText("

Pot Total

"); label_Sets->setText("

Sets:

"); - guiGameSpeed = myConfig->readConfigInt("GameSpeed",4); + // debugMode = v->checkBox_debugMode->isChecked(); //Tools und Board aufhellen und enablen @@ -263,9 +267,7 @@ void mainWindowImpl::callNewGameDialog() { groupBox_board->setPalette(tempPalette); groupBox_tools->setDisabled(FALSE); - //Speeds - setSpeeds(); - + //positioning Slider horizontalSlider_speed->setValue(guiGameSpeed); @@ -276,6 +278,8 @@ void mainWindowImpl::callNewGameDialog() { } + actionNewGame->setDisabled(TRUE); + } void mainWindowImpl::callAboutPokerthDialog() { @@ -740,6 +744,8 @@ else { newRoundTimerBlock=FALSE; } void mainWindowImpl::meInAction() { + actionNewGame->setDisabled(FALSE); + switch (actualHand->getActualRound()) { @@ -1035,6 +1041,8 @@ void mainWindowImpl::myAllIn(){ void mainWindowImpl::nextPlayerAnimation() { + actionNewGame->setDisabled(TRUE); + refreshChangePlayer(); //weiter mit switchrounds in Hand @@ -1275,7 +1283,10 @@ else { } -void mainWindowImpl::handSwitchRounds() { actualHand->switchRounds(); } +void mainWindowImpl::handSwitchRounds() { +if( !newRoundTimerBlock ){ actualHand->switchRounds(); } +else { newRoundTimerBlock=FALSE; } +} void mainWindowImpl::nextRoundCleanGui() { @@ -1334,11 +1345,7 @@ void mainWindowImpl::userWidgetsBackgroudColor() { } } -void mainWindowImpl::timerBlockerFalse() { - - newRoundTimerBlock=FALSE; - -} +void mainWindowImpl::timerBlockerFalse() { newRoundTimerBlock=FALSE; } void mainWindowImpl::setSpeeds() { diff --git a/src/gui/qt/newgamedialogimpl.cpp b/src/gui/qt/newgamedialogimpl.cpp index a180b606..2688dcf4 100755 --- a/src/gui/qt/newgamedialogimpl.cpp +++ b/src/gui/qt/newgamedialogimpl.cpp @@ -30,6 +30,7 @@ newGameDialogImpl::newGameDialogImpl(QWidget *parent, const char *name) ConfigFile myConfig; //Game Settings + spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers", 5)); spinBox_startCash->setValue(myConfig.readConfigInt("StartCash", 2000)); spinBox_smallBlind->setValue(myConfig.readConfigInt("SmallBlind", 10));