From f6fb29b883c1894631baffd651aff27866b9894a Mon Sep 17 00:00:00 2001 From: lotodore Date: Wed, 2 May 2007 21:20:54 +0000 Subject: [PATCH] GUI initialization now called by session. --- src/game.cpp | 2 - src/gamedata.h | 1 + src/gui/guiinterface.h | 2 +- src/gui/qt/guiwrapper.cpp | 2 + src/gui/qt/guiwrapper.h | 2 + src/gui/qt/mainwindow/mainwindowimpl.cpp | 71 ++++++++++++------------ src/gui/qt/mainwindow/mainwindowimpl.h | 2 + src/session.cpp | 6 +- 8 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 6ec3bdd5..9a030a46 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -46,8 +46,6 @@ Game::Game(GuiInterface* gui, const PlayerDataList &playerDataList, const GameDa playerArray[i] = 0; } - myGui->setGame(this); - //EngineFactory erstellen myFactory = new LocalEngineFactory; // LocalEngine erstellen diff --git a/src/gamedata.h b/src/gamedata.h index c5b8ffae..51bf01b9 100644 --- a/src/gamedata.h +++ b/src/gamedata.h @@ -30,6 +30,7 @@ struct GameData int startCash; int smallBlind; int handsBeforeRaise; + int guiSpeed; }; #endif diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index de12ad48..2b107dcc 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -33,7 +33,7 @@ class GuiInterface : public ClientCallback, public ServerCallback { public: virtual ~GuiInterface(); - + virtual void initGui(int speed) =0; //set virtual void setGame(Game*) =0; virtual void setHand(HandInterface*) =0; diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index e6c19a77..2aa0a962 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -41,6 +41,8 @@ GuiWrapper::~GuiWrapper() { } +void GuiWrapper::initGui(int speed) { myW->initGui(speed); } + void GuiWrapper::setGame(Game *g) { myW->setGame(g); } void GuiWrapper::setHand(HandInterface *lh) { myW->setHand(lh); } void GuiWrapper::setSession(Session *s) { myW->setSession(s); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index cc9ef6f5..3abf2eea 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -42,6 +42,8 @@ public: ~GuiWrapper(); + void initGui(int speed); + void setGame(Game*); void setHand(HandInterface*); void setSession(Session*); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 8360e1b2..dfdc1ce9 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -581,63 +581,30 @@ void mainWindowImpl::callNewGameDialog() { void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) { - int i; - // Start new local game - terminate existing network game. mySession->terminateNetworkClient(); mySession->terminateNetworkServer(); - if(actualGame) { - mySession->deleteGame(); - actualGame = 0; - } - //restliche Singleshots killen!!! - stopTimer(); - - label_Pot->setText("Pot"); - label_Total->setText("Total:"); - label_Sets->setText("Sets:"); - label_handNumber->setText("Hand:"); - label_gameNumber->setText("Game:"); - - //Tools und Board aufhellen und enablen -// QPalette tempPalette = groupBox_board->palette(); -// tempPalette.setColor(QPalette::Window, active); -// groupBox_board->setPalette(tempPalette); - groupBox_RightToolBox->setDisabled(FALSE); - groupBox_LeftToolBox->setDisabled(FALSE); - - //show human player buttons - for(i=0; i<3; i++) { - userWidgetsArray[i]->show(); - } - //get values from local game dialog GameData gameData; if(v) { - //Speeds - guiGameSpeed = v->spinBox_gameSpeed->value(); - setSpeeds(); - //positioning Slider - horizontalSlider_speed->setValue(guiGameSpeed); // Set Game Data gameData.numberOfPlayers = v->spinBox_quantityPlayers->value(); gameData.startCash = v->spinBox_startCash->value(); gameData.smallBlind = v->spinBox_smallBlind->value(); gameData.handsBeforeRaise = v->spinBox_handsBeforeRaiseSmallBlind->value(); + //Speeds + gameData.guiSpeed = v->spinBox_gameSpeed->value(); } // start with default values else { - //Speeds - guiGameSpeed = myConfig->readConfigInt("GameSpeed"); - setSpeeds(); - //positioning Slider - horizontalSlider_speed->setValue(guiGameSpeed); // Set Game Data gameData.numberOfPlayers = myConfig->readConfigInt("NumberOfPlayers"); gameData.startCash = myConfig->readConfigInt("StartCash"); gameData.smallBlind = myConfig->readConfigInt("SmallBlind"); gameData.handsBeforeRaise = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind"); + //Speeds + gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); } //Start Game!!! mySession->startGame(gameData); @@ -664,6 +631,7 @@ void mainWindowImpl::callCreateNetworkGameDialog() { gameData.startCash = myCreateNetworkGameDialog->spinBox_startCash->value(); gameData.smallBlind = myCreateNetworkGameDialog->spinBox_smallBlind->value(); gameData.handsBeforeRaise = myCreateNetworkGameDialog->spinBox_handsBeforeRaiseSmallBlind->value(); + gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value(); mySession->startNetworkServer(gameData); mySession->startNetworkClientForLocalServer(); @@ -779,6 +747,35 @@ void mainWindowImpl::callSettingsDialog() { } } +void mainWindowImpl::initGui(int speed) +{ + //restliche Singleshots killen!!! + stopTimer(); + + label_Pot->setText("Pot"); + label_Total->setText("Total:"); + label_Sets->setText("Sets:"); + label_handNumber->setText("Hand:"); + label_gameNumber->setText("Game:"); + + //Tools und Board aufhellen und enablen +// QPalette tempPalette = groupBox_board->palette(); +// tempPalette.setColor(QPalette::Window, active); +// groupBox_board->setPalette(tempPalette); + groupBox_RightToolBox->setDisabled(FALSE); + groupBox_LeftToolBox->setDisabled(FALSE); + + //show human player buttons + for(int i=0; i<3; i++) { + userWidgetsArray[i]->show(); + } + + guiGameSpeed = speed; + //positioning Slider + horizontalSlider_speed->setValue(guiGameSpeed); + setSpeeds(); +} + void mainWindowImpl::setGame(Game *g) { actualGame = g; } void mainWindowImpl::setHand(HandInterface* br) { actualHand = br; } diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index e5b1718a..fd2335d9 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -58,6 +58,8 @@ public: ~mainWindowImpl(); + void initGui(int speed); + void setGame(Game*); void setHand(HandInterface*); void setSession(Session*); diff --git a/src/session.cpp b/src/session.cpp index 807782bb..ca239a3a 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -48,6 +48,10 @@ Session::~Session() void Session::startGame(const GameData &gameData) { + myGui->setGame(0); + myGui->initGui(gameData.guiSpeed); + deleteGame(); + currentGameID++; PlayerDataList playerDataList; @@ -71,8 +75,8 @@ void Session::startGame(const GameData &gameData) { playerDataList.push_back(playerData); } - actualGame = new Game(myGui, playerDataList, gameData, currentGameID); + myGui->setGame(actualGame); } void Session::deleteGame() {