diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index d6c47b2c..e7833d99 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -23,6 +23,7 @@ class ConfigFile; class Session; +class gameTableImpl; class ServerGuiWrapper : public GuiInterface { @@ -35,6 +36,8 @@ public: Session &getSession(); void setSession(boost::shared_ptr session); + gameTableImpl* getMyW() const{}; + void refreshSet() const; void refreshCash() const; void refreshAction(int =-1, int =-1) const; diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 7ac4193c..2c4c67d7 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -29,7 +29,7 @@ class Session; - +class gameTableImpl; class GuiInterface : public ClientCallback, public ServerCallback, public IrcCallback { public: @@ -40,6 +40,8 @@ public: virtual Session &getSession() =0; virtual void setSession(boost::shared_ptr session) =0; + virtual gameTableImpl *getMyW() const=0; + //refresh-Funktionen virtual void refreshSet() const=0; virtual void refreshCash() const=0; diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index ca0d40f5..a96eeadc 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -44,6 +44,8 @@ public: Session &getSession(); void setSession(boost::shared_ptr session); + gameTableImpl* getMyW() const { return myW; } + void refreshSet() const; void refreshCash() const; void refreshAction(int =-1, int =-1) const; @@ -142,6 +144,7 @@ public: void SignalIrcError(int errorCode); void SignalIrcServerError(int errorCode); + private: Log *myLog; diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index 8c97d9d0..f1d1dc23 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -64,21 +64,21 @@ startWindowImpl::startWindowImpl(ConfigFile *c) this->setWindowTitle(QString(tr("PokerTH %1 - The Open-Source Texas Holdem Engine").arg(POKERTH_BETA_RELEASE_STRING))); // Dialogs - myNewGameDialog = boost::shared_ptr(new newGameDialogImpl(this, myConfig)); - mySelectAvatarDialog = boost::shared_ptr(new selectAvatarDialogImpl(this, myConfig)); - mySettingsDialog = boost::shared_ptr(new settingsDialogImpl(this, myConfig, mySelectAvatarDialog.get())); - myChangeHumanPlayerNameDialog = boost::shared_ptr(new changeHumanPlayerNameDialogImpl(this, myConfig)); - myJoinNetworkGameDialog = boost::shared_ptr(new joinNetworkGameDialogImpl(this, myConfig)); - myConnectToServerDialog = boost::shared_ptr(new connectToServerDialogImpl(this)); - myStartNetworkGameDialog = boost::shared_ptr(new startNetworkGameDialogImpl(this, myConfig)); - myCreateNetworkGameDialog = boost::shared_ptr(new createNetworkGameDialogImpl(this, myConfig)); - myAboutPokerthDialog = boost::shared_ptr(new aboutPokerthImpl(this, myConfig)); - myGameLobbyDialog = boost::shared_ptr(new gameLobbyDialogImpl(this, myConfig)); + myNewGameDialog = new newGameDialogImpl(this, myConfig); + mySelectAvatarDialog = new selectAvatarDialogImpl(this, myConfig); + mySettingsDialog = new settingsDialogImpl(this, myConfig, mySelectAvatarDialog); + myChangeHumanPlayerNameDialog = new changeHumanPlayerNameDialogImpl(this, myConfig); + myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this, myConfig); + myConnectToServerDialog = new connectToServerDialogImpl(this); + myStartNetworkGameDialog = new startNetworkGameDialogImpl(this, myConfig); + myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig); + myAboutPokerthDialog = new aboutPokerthImpl(this, myConfig); + myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig); - myStartNetworkGameDialog->setMyW(myW); - myGameLobbyDialog->setMyW(myW); + myStartNetworkGameDialog->setMyW(myGuiInterface->getMyW()); + myGameLobbyDialog->setMyW(myGuiInterface->getMyW()); - myTimeoutDialog.reset(new timeoutMsgBoxImpl(this)); + myTimeoutDialog = new timeoutMsgBoxImpl(this); connect( actionStart_Local_Game, SIGNAL( triggered() ), this, SLOT( callNewGameDialog() ) ); @@ -93,33 +93,33 @@ startWindowImpl::startWindowImpl(ConfigFile *c) connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog())); - connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog.get(), SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog.get(), SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog.get(), SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog, SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog, SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog, SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myStartNetworkGameDialog.get(), SLOT(joinedNetworkGame(unsigned, QString, int))); - connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myStartNetworkGameDialog.get(), SLOT(addConnectedPlayer(unsigned, QString, int))); - connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(updatePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(removePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(newGameAdmin(unsigned, QString))); - connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myStartNetworkGameDialog.get(), SLOT(gameCreated(unsigned))); + connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(unsigned, QString, int))); + connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(unsigned, QString, int))); + connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog, SLOT(updatePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myStartNetworkGameDialog, SLOT(removePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myStartNetworkGameDialog, SLOT(newGameAdmin(unsigned, QString))); + connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myStartNetworkGameDialog, SLOT(gameCreated(unsigned))); - connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myGameLobbyDialog.get(), SLOT(joinedNetworkGame(unsigned, QString, int))); - connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myGameLobbyDialog.get(), SLOT(addConnectedPlayer(unsigned, QString, int))); - connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myGameLobbyDialog.get(), SLOT(updatePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myGameLobbyDialog.get(), SLOT(removePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myGameLobbyDialog.get(), SLOT(newGameAdmin(unsigned, QString))); + connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myGameLobbyDialog, SLOT(joinedNetworkGame(unsigned, QString, int))); + connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myGameLobbyDialog, SLOT(addConnectedPlayer(unsigned, QString, int))); + connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myGameLobbyDialog, SLOT(updatePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myGameLobbyDialog, SLOT(removePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myGameLobbyDialog, SLOT(newGameAdmin(unsigned, QString))); - connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myGameLobbyDialog.get(), SLOT(addGame(unsigned))); - connect(this, SIGNAL(signalNetClientGameListRemove(unsigned)), myGameLobbyDialog.get(), SLOT(removeGame(unsigned))); - connect(this, SIGNAL(signalNetClientGameListUpdateMode(unsigned, int)), myGameLobbyDialog.get(), SLOT(updateGameMode(unsigned, int))); - connect(this, SIGNAL(signalNetClientGameListUpdateAdmin(unsigned, unsigned)), myGameLobbyDialog.get(), SLOT(updateGameAdmin(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientGameListPlayerJoined(unsigned, unsigned)), myGameLobbyDialog.get(), SLOT(gameAddPlayer(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientGameListPlayerLeft(unsigned, unsigned)), myGameLobbyDialog.get(), SLOT(gameRemovePlayer(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog.get(), SLOT(removedFromGame(int))); - connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog.get(), SLOT(updateStats(ServerStats))); + connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myGameLobbyDialog, SLOT(addGame(unsigned))); + connect(this, SIGNAL(signalNetClientGameListRemove(unsigned)), myGameLobbyDialog, SLOT(removeGame(unsigned))); + connect(this, SIGNAL(signalNetClientGameListUpdateMode(unsigned, int)), myGameLobbyDialog, SLOT(updateGameMode(unsigned, int))); + connect(this, SIGNAL(signalNetClientGameListUpdateAdmin(unsigned, unsigned)), myGameLobbyDialog, SLOT(updateGameAdmin(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientGameListPlayerJoined(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameAddPlayer(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientGameListPlayerLeft(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameRemovePlayer(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog, SLOT(removedFromGame(int))); + connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog, SLOT(updateStats(ServerStats))); - connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog.get(), SLOT(receiveChatMsg(QString, QString))); + connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog, SLOT(receiveChatMsg(QString, QString))); connect(this, SIGNAL(signalIrcConnect(QString)), myGameLobbyDialog->getLobbyChat(), SLOT(connected(QString))); connect(this, SIGNAL(signalIrcSelfJoined(QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(selfJoined(QString, QString))); @@ -141,7 +141,7 @@ void startWindowImpl::callNewGameDialog() { if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ myNewGameDialog->exec(); - if (myNewGameDialog->result() == QDialog::Accepted ) { myW->startNewLocalGame(myNewGameDialog.get()); } + if (myNewGameDialog->result() == QDialog::Accepted ) { myW->startNewLocalGame(myNewGameDialog); } } // sonst mit gespeicherten Werten starten else { myW->startNewLocalGame(); } @@ -170,7 +170,7 @@ void startWindowImpl::joinGameLobby() { // Join Lobby mySession->terminateNetworkClient(); - if (myServerGuiInterface.get()) + if (myServerGuiInterface) myServerGuiInterface->getSession().terminateNetworkServer(); myGameLobbyDialog->setSession(&getSession()); myStartNetworkGameDialog->setSession(&getSession()); @@ -231,7 +231,7 @@ void startWindowImpl::callCreateNetworkGameDialog() { // Stop local game. myW->stopTimer(); - if (!myServerGuiInterface.get()) + if (!myServerGuiInterface) { // Create pseudo Gui Wrapper for the server. myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui(), mySession->getGui())); @@ -314,7 +314,7 @@ void startWindowImpl::callJoinNetworkGameDialog() { myW->stopTimer(); mySession->terminateNetworkClient(); - if (myServerGuiInterface.get()) + if (myServerGuiInterface) myServerGuiInterface->getSession().terminateNetworkServer(); myGameLobbyDialog->setSession(&getSession()); diff --git a/src/gui/qt/startwindow/startwindowimpl.h b/src/gui/qt/startwindow/startwindowimpl.h index b5ba6b9a..7a5a5013 100644 --- a/src/gui/qt/startwindow/startwindowimpl.h +++ b/src/gui/qt/startwindow/startwindowimpl.h @@ -106,18 +106,18 @@ private: boost::shared_ptr myServerGuiInterface; // Dialogs - boost::shared_ptr myAboutPokerthDialog; - boost::shared_ptr myNewGameDialog; - boost::shared_ptr mySettingsDialog; - boost::shared_ptr mySelectAvatarDialog; - boost::shared_ptr myChangeHumanPlayerNameDialog; - boost::shared_ptr myJoinNetworkGameDialog; - boost::shared_ptr myConnectToServerDialog; - boost::shared_ptr myStartNetworkGameDialog; - boost::shared_ptr myCreateNetworkGameDialog; - boost::shared_ptr myGameLobbyDialog; - boost::shared_ptr myTimeoutDialog; - boost::shared_ptr myStartWindow; + aboutPokerthImpl *myAboutPokerthDialog; + newGameDialogImpl *myNewGameDialog; + settingsDialogImpl *mySettingsDialog; + selectAvatarDialogImpl *mySelectAvatarDialog; + changeHumanPlayerNameDialogImpl *myChangeHumanPlayerNameDialog; + joinNetworkGameDialogImpl *myJoinNetworkGameDialog; + connectToServerDialogImpl *myConnectToServerDialog; + startNetworkGameDialogImpl *myStartNetworkGameDialog; + createNetworkGameDialogImpl *myCreateNetworkGameDialog; + gameLobbyDialogImpl *myGameLobbyDialog; + timeoutMsgBoxImpl *myTimeoutDialog; + startWindowImpl *myStartWindow; friend class GuiWrapper;