GUI initialization now called by session.
This commit is contained in:
@@ -46,8 +46,6 @@ Game::Game(GuiInterface* gui, const PlayerDataList &playerDataList, const GameDa
|
|||||||
playerArray[i] = 0;
|
playerArray[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
myGui->setGame(this);
|
|
||||||
|
|
||||||
//EngineFactory erstellen
|
//EngineFactory erstellen
|
||||||
myFactory = new LocalEngineFactory; // LocalEngine erstellen
|
myFactory = new LocalEngineFactory; // LocalEngine erstellen
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ struct GameData
|
|||||||
int startCash;
|
int startCash;
|
||||||
int smallBlind;
|
int smallBlind;
|
||||||
int handsBeforeRaise;
|
int handsBeforeRaise;
|
||||||
|
int guiSpeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class GuiInterface : public ClientCallback, public ServerCallback {
|
|||||||
public:
|
public:
|
||||||
virtual ~GuiInterface();
|
virtual ~GuiInterface();
|
||||||
|
|
||||||
|
virtual void initGui(int speed) =0;
|
||||||
//set
|
//set
|
||||||
virtual void setGame(Game*) =0;
|
virtual void setGame(Game*) =0;
|
||||||
virtual void setHand(HandInterface*) =0;
|
virtual void setHand(HandInterface*) =0;
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ GuiWrapper::~GuiWrapper()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiWrapper::initGui(int speed) { myW->initGui(speed); }
|
||||||
|
|
||||||
void GuiWrapper::setGame(Game *g) { myW->setGame(g); }
|
void GuiWrapper::setGame(Game *g) { myW->setGame(g); }
|
||||||
void GuiWrapper::setHand(HandInterface *lh) { myW->setHand(lh); }
|
void GuiWrapper::setHand(HandInterface *lh) { myW->setHand(lh); }
|
||||||
void GuiWrapper::setSession(Session *s) { myW->setSession(s); }
|
void GuiWrapper::setSession(Session *s) { myW->setSession(s); }
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public:
|
|||||||
|
|
||||||
~GuiWrapper();
|
~GuiWrapper();
|
||||||
|
|
||||||
|
void initGui(int speed);
|
||||||
|
|
||||||
void setGame(Game*);
|
void setGame(Game*);
|
||||||
void setHand(HandInterface*);
|
void setHand(HandInterface*);
|
||||||
void setSession(Session*);
|
void setSession(Session*);
|
||||||
|
|||||||
@@ -581,63 +581,30 @@ void mainWindowImpl::callNewGameDialog() {
|
|||||||
|
|
||||||
void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// Start new local game - terminate existing network game.
|
// Start new local game - terminate existing network game.
|
||||||
mySession->terminateNetworkClient();
|
mySession->terminateNetworkClient();
|
||||||
mySession->terminateNetworkServer();
|
mySession->terminateNetworkServer();
|
||||||
|
|
||||||
if(actualGame) {
|
|
||||||
mySession->deleteGame();
|
|
||||||
actualGame = 0;
|
|
||||||
}
|
|
||||||
//restliche Singleshots killen!!!
|
|
||||||
stopTimer();
|
|
||||||
|
|
||||||
label_Pot->setText("<span style='font-weight:bold'>Pot</span>");
|
|
||||||
label_Total->setText("<span style='font-weight:bold'>Total:</span>");
|
|
||||||
label_Sets->setText("<span style='font-weight:bold'>Sets:</span>");
|
|
||||||
label_handNumber->setText("<span style='font-weight:bold'>Hand:</span>");
|
|
||||||
label_gameNumber->setText("<span style='font-weight:bold'>Game:</span>");
|
|
||||||
|
|
||||||
//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
|
//get values from local game dialog
|
||||||
GameData gameData;
|
GameData gameData;
|
||||||
if(v) {
|
if(v) {
|
||||||
//Speeds
|
|
||||||
guiGameSpeed = v->spinBox_gameSpeed->value();
|
|
||||||
setSpeeds();
|
|
||||||
//positioning Slider
|
|
||||||
horizontalSlider_speed->setValue(guiGameSpeed);
|
|
||||||
// Set Game Data
|
// Set Game Data
|
||||||
gameData.numberOfPlayers = v->spinBox_quantityPlayers->value();
|
gameData.numberOfPlayers = v->spinBox_quantityPlayers->value();
|
||||||
gameData.startCash = v->spinBox_startCash->value();
|
gameData.startCash = v->spinBox_startCash->value();
|
||||||
gameData.smallBlind = v->spinBox_smallBlind->value();
|
gameData.smallBlind = v->spinBox_smallBlind->value();
|
||||||
gameData.handsBeforeRaise = v->spinBox_handsBeforeRaiseSmallBlind->value();
|
gameData.handsBeforeRaise = v->spinBox_handsBeforeRaiseSmallBlind->value();
|
||||||
|
//Speeds
|
||||||
|
gameData.guiSpeed = v->spinBox_gameSpeed->value();
|
||||||
}
|
}
|
||||||
// start with default values
|
// start with default values
|
||||||
else {
|
else {
|
||||||
//Speeds
|
|
||||||
guiGameSpeed = myConfig->readConfigInt("GameSpeed");
|
|
||||||
setSpeeds();
|
|
||||||
//positioning Slider
|
|
||||||
horizontalSlider_speed->setValue(guiGameSpeed);
|
|
||||||
// Set Game Data
|
// Set Game Data
|
||||||
gameData.numberOfPlayers = myConfig->readConfigInt("NumberOfPlayers");
|
gameData.numberOfPlayers = myConfig->readConfigInt("NumberOfPlayers");
|
||||||
gameData.startCash = myConfig->readConfigInt("StartCash");
|
gameData.startCash = myConfig->readConfigInt("StartCash");
|
||||||
gameData.smallBlind = myConfig->readConfigInt("SmallBlind");
|
gameData.smallBlind = myConfig->readConfigInt("SmallBlind");
|
||||||
gameData.handsBeforeRaise = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind");
|
gameData.handsBeforeRaise = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind");
|
||||||
|
//Speeds
|
||||||
|
gameData.guiSpeed = myConfig->readConfigInt("GameSpeed");
|
||||||
}
|
}
|
||||||
//Start Game!!!
|
//Start Game!!!
|
||||||
mySession->startGame(gameData);
|
mySession->startGame(gameData);
|
||||||
@@ -664,6 +631,7 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
|
|||||||
gameData.startCash = myCreateNetworkGameDialog->spinBox_startCash->value();
|
gameData.startCash = myCreateNetworkGameDialog->spinBox_startCash->value();
|
||||||
gameData.smallBlind = myCreateNetworkGameDialog->spinBox_smallBlind->value();
|
gameData.smallBlind = myCreateNetworkGameDialog->spinBox_smallBlind->value();
|
||||||
gameData.handsBeforeRaise = myCreateNetworkGameDialog->spinBox_handsBeforeRaiseSmallBlind->value();
|
gameData.handsBeforeRaise = myCreateNetworkGameDialog->spinBox_handsBeforeRaiseSmallBlind->value();
|
||||||
|
gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value();
|
||||||
|
|
||||||
mySession->startNetworkServer(gameData);
|
mySession->startNetworkServer(gameData);
|
||||||
mySession->startNetworkClientForLocalServer();
|
mySession->startNetworkClientForLocalServer();
|
||||||
@@ -779,6 +747,35 @@ void mainWindowImpl::callSettingsDialog() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mainWindowImpl::initGui(int speed)
|
||||||
|
{
|
||||||
|
//restliche Singleshots killen!!!
|
||||||
|
stopTimer();
|
||||||
|
|
||||||
|
label_Pot->setText("<span style='font-weight:bold'>Pot</span>");
|
||||||
|
label_Total->setText("<span style='font-weight:bold'>Total:</span>");
|
||||||
|
label_Sets->setText("<span style='font-weight:bold'>Sets:</span>");
|
||||||
|
label_handNumber->setText("<span style='font-weight:bold'>Hand:</span>");
|
||||||
|
label_gameNumber->setText("<span style='font-weight:bold'>Game:</span>");
|
||||||
|
|
||||||
|
//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::setGame(Game *g) { actualGame = g; }
|
||||||
|
|
||||||
void mainWindowImpl::setHand(HandInterface* br) { actualHand = br; }
|
void mainWindowImpl::setHand(HandInterface* br) { actualHand = br; }
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
|
|
||||||
~mainWindowImpl();
|
~mainWindowImpl();
|
||||||
|
|
||||||
|
void initGui(int speed);
|
||||||
|
|
||||||
void setGame(Game*);
|
void setGame(Game*);
|
||||||
void setHand(HandInterface*);
|
void setHand(HandInterface*);
|
||||||
void setSession(Session*);
|
void setSession(Session*);
|
||||||
|
|||||||
+5
-1
@@ -48,6 +48,10 @@ Session::~Session()
|
|||||||
|
|
||||||
void Session::startGame(const GameData &gameData) {
|
void Session::startGame(const GameData &gameData) {
|
||||||
|
|
||||||
|
myGui->setGame(0);
|
||||||
|
myGui->initGui(gameData.guiSpeed);
|
||||||
|
deleteGame();
|
||||||
|
|
||||||
currentGameID++;
|
currentGameID++;
|
||||||
|
|
||||||
PlayerDataList playerDataList;
|
PlayerDataList playerDataList;
|
||||||
@@ -71,8 +75,8 @@ void Session::startGame(const GameData &gameData) {
|
|||||||
playerDataList.push_back(playerData);
|
playerDataList.push_back(playerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
actualGame = new Game(myGui, playerDataList, gameData, currentGameID);
|
actualGame = new Game(myGui, playerDataList, gameData, currentGameID);
|
||||||
|
myGui->setGame(actualGame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::deleteGame() {
|
void Session::deleteGame() {
|
||||||
|
|||||||
Reference in New Issue
Block a user