From aea6b39327414443c010225babff0a8f65981d20 Mon Sep 17 00:00:00 2001 From: doitux Date: Sun, 8 Jun 2008 21:18:29 +0000 Subject: [PATCH] next steps for startwindow --- pokerth_game.pro | 4 +- pokerth_lib.pro | 4 +- pokerth_server.pro | 4 +- src/gui/qt/gametable/gametableimpl.cpp | 84 ++++--- src/gui/qt/gametable/gametableimpl.h | 25 +- src/gui/qt/guiwrapper.cpp | 71 +++++- src/gui/qt/guiwrapper.h | 2 +- .../qt/settingsdialog/settingsdialogimpl.h | 2 +- src/gui/qt/startwindow.ui | 7 +- src/gui/qt/startwindow/startwindowimpl.cpp | 219 ++++++++++++++++++ src/gui/qt/startwindow/startwindowimpl.h | 88 ++++++- 11 files changed, 443 insertions(+), 67 deletions(-) diff --git a/pokerth_game.pro b/pokerth_game.pro index 77bb6ba2..37817bd3 100644 --- a/pokerth_game.pro +++ b/pokerth_game.pro @@ -7,8 +7,8 @@ isEmpty( PREFIX ) { TEMPLATE = app CODECFORSRC = UTF-8 -CONFIG += qt thread embed_manifest_exe exceptions rtti stl warn_on release -#CONFIG += qt thread embed_manifest_exe exceptions rtti stl warn_on debug +#CONFIG += qt thread embed_manifest_exe exceptions rtti stl warn_on release +CONFIG += qt thread embed_manifest_exe exceptions rtti stl warn_on debug #####Uncomment this for RELEASE #QTPLUGIN += qjpeg qgif diff --git a/pokerth_lib.pro b/pokerth_lib.pro index 90bf2204..da27e72c 100644 --- a/pokerth_lib.pro +++ b/pokerth_lib.pro @@ -3,8 +3,8 @@ TEMPLATE = lib CODECFORSRC = UTF-8 -CONFIG += staticlib thread exceptions rtti stl warn_on release -#CONFIG += staticlib thread exceptions rtti stl warn_on debug +#CONFIG += staticlib thread exceptions rtti stl warn_on release +CONFIG += staticlib thread exceptions rtti stl warn_on debug UI_DIR = uics TARGET = lib/pokerth_lib diff --git a/pokerth_server.pro b/pokerth_server.pro index a1bc7d53..65ec1db6 100644 --- a/pokerth_server.pro +++ b/pokerth_server.pro @@ -7,8 +7,8 @@ isEmpty( PREFIX ) { TEMPLATE = app CODECFORSRC = UTF-8 -CONFIG += thread console embed_manifest_exe exceptions rtti stl warn_on release -#CONFIG += thread console embed_manifest_exe exceptions rtti stl warn_on debug +#CONFIG += thread console embed_manifest_exe exceptions rtti stl warn_on release +CONFIG += thread console embed_manifest_exe exceptions rtti stl warn_on debug UI_DIR = uics TARGET = bin/pokerth_server diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index de78c6de..4ddcfbd9 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -33,6 +33,7 @@ #include "gamelobbydialogimpl.h" #include "timeoutmsgboximpl.h" #include "lobbychat.h" +#include "startwindowimpl.h" #include "startsplash.h" #include "mycardspixmaplabel.h" @@ -468,17 +469,17 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) #endif } - //Dialoge - 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); +// 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)); myStartNetworkGameDialog->setMyW(this); myGameLobbyDialog->setMyW(this); @@ -579,7 +580,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalRefreshButton()), this, SLOT(refreshButton())); connect(this, SIGNAL(signalRefreshGameLabels(int)), this, SLOT(refreshGameLabels(int))); connect(this, SIGNAL(signalSetPlayerAvatar(int, QString)), this, SLOT(setPlayerAvatar(int, QString))); - connect(this, SIGNAL(signalSetPlayerAvatar(int, QString)), myGameLobbyDialog, SLOT(refreshConnectedPlayerAvatars())); + connect(this, SIGNAL(signalSetPlayerAvatar(int, QString)), myGameLobbyDialog.get(), SLOT(refreshConnectedPlayerAvatars())); connect(this, SIGNAL(signalGuiUpdateDone()), this, SLOT(guiUpdateDone())); @@ -614,31 +615,31 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalNextRoundCleanGui()), this, SLOT(nextRoundCleanGui())); - 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(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(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)), 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)), 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(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(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(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(signalNetClientShowTimeoutDialog(int, unsigned)), this, SLOT(showTimeoutDialog(int, unsigned))); // Errors are handled globally, not within one dialog. @@ -650,7 +651,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) //Chat Messages connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myChat, SLOT(receiveMessage(QString, QString))); - connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog, SLOT(receiveChatMsg(QString, QString))); + connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog.get(), 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))); @@ -677,7 +678,7 @@ void gameTableImpl::callNewGameDialog() { if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ myNewGameDialog->exec(); - if (myNewGameDialog->result() == QDialog::Accepted ) { startNewLocalGame(myNewGameDialog); } + if (myNewGameDialog->result() == QDialog::Accepted ) { startNewLocalGame(myNewGameDialog.get()); } } // sonst mit gespeicherten Werten starten else { startNewLocalGame(); } @@ -685,6 +686,9 @@ void gameTableImpl::callNewGameDialog() { void gameTableImpl::startNewLocalGame(newGameDialogImpl *v) { + myStartWindow->hide(); + this->show(); + // Start new local game - terminate existing network game. mySession->terminateNetworkClient(); if (myServerGuiInterface.get()) @@ -3745,13 +3749,17 @@ void gameTableImpl::quitPokerTH() { mySession->terminateNetworkClient(); stopTimer(); if (myServerGuiInterface.get()) myServerGuiInterface->getSession().terminateNetworkServer(); - qApp->quit(); +// qApp->quit(); + this->hide(); + myStartWindow->show(); } } else { mySession->terminateNetworkClient(); stopTimer(); - qApp->quit(); +// qApp->quit(); + this->hide(); + myStartWindow->show(); } } diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index a6fff0c1..e8d31d7f 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -52,6 +52,7 @@ class startNetworkGameDialogImpl; class changeHumanPlayerNameDialogImpl; class gameLobbyDialogImpl; class timeoutMsgBoxImpl; +class startWindowImpl; class QColor; class SDLPlayer; @@ -68,6 +69,7 @@ public: Session &getSession(); void setSession(boost::shared_ptr session); + void setStartWindow(boost::shared_ptr s) { myStartWindow = s; } void setLog(Log* l) { myLog = l; } @@ -401,18 +403,19 @@ private: QPixmap *flipside; - //Dialoge - aboutPokerthImpl *myAboutPokerthDialog; - newGameDialogImpl *myNewGameDialog; - settingsDialogImpl *mySettingsDialog; - selectAvatarDialogImpl *mySelectAvatarDialog; - changeHumanPlayerNameDialogImpl *myChangeHumanPlayerNameDialog; - joinNetworkGameDialogImpl *myJoinNetworkGameDialog; - connectToServerDialogImpl *myConnectToServerDialog; - startNetworkGameDialogImpl *myStartNetworkGameDialog; - createNetworkGameDialogImpl *myCreateNetworkGameDialog; - gameLobbyDialogImpl *myGameLobbyDialog; +// 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; //Sound SDLPlayer *mySDLPlayer; diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index be5869eb..a2430bd3 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -29,7 +29,7 @@ using namespace std; -GuiWrapper::GuiWrapper(ConfigFile *c) : myLog(NULL), myW(NULL), myConfig(c), myStartWindow(NULL) +GuiWrapper::GuiWrapper(ConfigFile *c) : myLog(NULL), myW(NULL), myConfig(c) { @@ -37,8 +37,10 @@ GuiWrapper::GuiWrapper(ConfigFile *c) : myLog(NULL), myW(NULL), myConfig(c), myS myW->show(); myLog = new Log(myW, myConfig); - myStartWindow = new startWindowImpl(myW, myConfig); -// myStartWindow-> show(); + myStartWindow = boost::shared_ptr(new startWindowImpl(myW, myConfig)); +// myStartWindow->show(); + + myW->setStartWindow(myStartWindow); } @@ -49,7 +51,10 @@ GuiWrapper::~GuiWrapper() void GuiWrapper::initGui(int speed) { myW->signalInitGui(speed); } Session &GuiWrapper::getSession() { return myW->getSession(); } -void GuiWrapper::setSession(boost::shared_ptr session) { myW->setSession(session); } +void GuiWrapper::setSession(boost::shared_ptr session) { + myW->setSession(session); + myStartWindow->setSession(session); +} void GuiWrapper::refreshSet() const { myW->signalRefreshSet(); } void GuiWrapper::refreshCash() const { myW->signalRefreshCash(); } @@ -119,6 +124,60 @@ void GuiWrapper::flushLogAtGame(int gameID) { myLog->signalFlushLogAtGame(gameID void GuiWrapper::flushLogAtHand() { myLog->signalFlushLogAtHand(); } +// void GuiWrapper::SignalNetClientConnect(int actionID) { myStartWindow->signalNetClientConnect(actionID); } +// void GuiWrapper::SignalNetClientGameInfo(int actionID) { myStartWindow->signalNetClientGameInfo(actionID); } +// void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myStartWindow->signalNetClientError(errorID, osErrorID); } +// void GuiWrapper::SignalNetClientNotification(int notificationId) { myStartWindow->signalNetClientNotification(notificationId); } +// void GuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) { myStartWindow->signalNetClientStatsUpdate(stats); } +// void GuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) { myStartWindow->signalNetClientShowTimeoutDialog(reason, remainingSec); } +// void GuiWrapper::SignalNetClientRemovedFromGame(int notificationId) { myStartWindow->signalNetClientRemovedFromGame(notificationId); } +// void GuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, PlayerRights rights) { myStartWindow->signalNetClientSelfJoined(playerId, QString::fromUtf8(playerName.c_str()), rights); } +// void GuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, PlayerRights rights) { myStartWindow->signalNetClientPlayerJoined(playerId, QString::fromUtf8(playerName.c_str()), rights); } +// void GuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName) +// { +// myStartWindow->signalNetClientPlayerChanged(playerId, QString::fromUtf8(newPlayerName.c_str())); +// } +// void GuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName) +// { +// QString tmpName(QString::fromUtf8(playerName.c_str())); +// myStartWindow->signalNetClientPlayerLeft(playerId, tmpName); +// if (!playerName.empty() && playerName[0] != '#') +// myLog->signalLogPlayerLeftMsg(tmpName); +// } +// void GuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName) { +// +// myStartWindow->signalNetClientNewGameAdmin(playerId, QString::fromUtf8(playerName.c_str())); +// if (!playerName.empty() && playerName[0] != '#') +// myLog->signalLogNewGameAdminMsg(QString::fromUtf8(playerName.c_str())); +// +// } +// +// void GuiWrapper::SignalNetClientGameListNew(unsigned gameId) { myStartWindow->signalNetClientGameListNew(gameId); } +// void GuiWrapper::SignalNetClientGameListRemove(unsigned gameId) { myStartWindow->signalNetClientGameListRemove(gameId); } +// void GuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode) { myStartWindow->signalNetClientGameListUpdateMode(gameId, mode); } +// void GuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId) {myStartWindow->signalNetClientGameListUpdateAdmin(gameId, adminPlayerId); } +// void GuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) { myStartWindow->signalNetClientGameListPlayerJoined(gameId, playerId); } +// void GuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) { myStartWindow->signalNetClientGameListPlayerLeft(gameId, playerId); } +// +// void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) { myStartWindow->signalNetClientGameStart(game); } +// void GuiWrapper::SignalNetClientWaitDialog() { myStartWindow->signalShowClientDialog(); } +// void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myW->signalNetClientChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } +// void GuiWrapper::SignalNetServerSuccess(int /*actionID*/) { } +// void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { myW->signalNetServerError(errorID, osErrorID); } +// +// void GuiWrapper::SignalIrcConnect(const string &server) { myStartWindow->signalIrcConnect(QString::fromUtf8(server.c_str())); } +// void GuiWrapper::SignalIrcSelfJoined(const string &nickName, const string &channel) { myStartWindow->signalIrcSelfJoined(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(channel.c_str())); } +// void GuiWrapper::SignalIrcPlayerJoined(const string &nickName) { myStartWindow->signalIrcPlayerJoined(QString::fromUtf8(nickName.c_str())); } +// void GuiWrapper::SignalIrcPlayerChanged(const string &oldNick, const string &newNick) { myStartWindow->signalIrcPlayerChanged(QString::fromUtf8(oldNick.c_str()), QString::fromUtf8(newNick.c_str())); } +// void GuiWrapper::SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) { myStartWindow->signalIrcPlayerKicked(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(byWhom.c_str()), QString::fromUtf8(reason.c_str())); } +// void GuiWrapper::SignalIrcPlayerLeft(const std::string &nickName) { myStartWindow->signalIrcPlayerLeft(QString::fromUtf8(nickName.c_str())); } +// void GuiWrapper::SignalIrcChatMsg(const std::string &nickName, const std::string &msg) { myStartWindow->signalIrcChatMessage(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(msg.c_str())); } +// void GuiWrapper::SignalIrcError(int errorCode) { myStartWindow->signalIrcError(errorCode); } +// void GuiWrapper::SignalIrcServerError(int errorCode) {myStartWindow->signalIrcServerError(errorCode); } + + +//TEMPORARELY UNTIL STARTWINDOW REFACTORING IS OVER TODO + 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); } @@ -155,9 +214,8 @@ void GuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned p void GuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) { myW->signalNetClientGameListPlayerLeft(gameId, playerId); } void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) { myW->signalNetClientGameStart(game); } -void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myW->signalNetClientChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } void GuiWrapper::SignalNetClientWaitDialog() { myW->signalShowClientDialog(); } - +void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myW->signalNetClientChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } void GuiWrapper::SignalNetServerSuccess(int /*actionID*/) { } void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { myW->signalNetServerError(errorID, osErrorID); } @@ -171,3 +229,4 @@ void GuiWrapper::SignalIrcChatMsg(const std::string &nickName, const std::string void GuiWrapper::SignalIrcError(int errorCode) { myW->signalIrcError(errorCode); } void GuiWrapper::SignalIrcServerError(int errorCode) {myW->signalIrcServerError(errorCode); } +//TEMPORARELY UNTIL STARTWINDOW REFACTORING IS OVER TODO \ No newline at end of file diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 82cdb226..66ae72ed 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -147,7 +147,7 @@ private: Chat *myChat; gameTableImpl *myW; ConfigFile *myConfig; - startWindowImpl *myStartWindow; + boost::shared_ptr myStartWindow; }; diff --git a/src/gui/qt/settingsdialog/settingsdialogimpl.h b/src/gui/qt/settingsdialog/settingsdialogimpl.h index bc96fefd..fa4ed220 100644 --- a/src/gui/qt/settingsdialog/settingsdialogimpl.h +++ b/src/gui/qt/settingsdialog/settingsdialogimpl.h @@ -94,7 +94,7 @@ private: std::list myNetManualBlindsList; ConfigFile* myConfig; - selectAvatarDialogImpl* mySelectAvatarDialogImpl; + boost::shared_ptr mySelectAvatarDialogImpl; manualBlindsOrderDialogImpl *myManualBlindsOrderDialog; QString myAppDataPath; diff --git a/src/gui/qt/startwindow.ui b/src/gui/qt/startwindow.ui index c31fb890..68770e34 100644 --- a/src/gui/qt/startwindow.ui +++ b/src/gui/qt/startwindow.ui @@ -43,7 +43,7 @@ - + &2 Internet Game @@ -64,7 +64,7 @@ - + &1 Start Local Game @@ -154,6 +154,9 @@ Internet Game ... + + Ctrl+I + diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index 6033a2f9..6ae1a630 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -18,8 +18,32 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "startwindowimpl.h" + +#include +#include +#include + +#include "session.h" +#include "game.h" + #include "configfile.h" #include "gametableimpl.h" +#include "newgamedialogimpl.h" +#include "aboutpokerthimpl.h" +#include "mymessagedialogimpl.h" +#include "settingsdialogimpl.h" +#include "selectavatardialogimpl.h" +#include "joinnetworkgamedialogimpl.h" +#include "connecttoserverdialogimpl.h" +#include "createnetworkgamedialogimpl.h" +#include "startnetworkgamedialogimpl.h" +#include "changehumanplayernamedialogimpl.h" +#include "changecompleteblindsdialogimpl.h" +#include "gamelobbydialogimpl.h" +#include "timeoutmsgboximpl.h" +#include "lobbychat.h" + + startWindowImpl::startWindowImpl(gameTableImpl *w, ConfigFile *c) : myW(w), myConfig(c) @@ -29,6 +53,201 @@ startWindowImpl::startWindowImpl(gameTableImpl *w, ConfigFile *c) // setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); // #endif setupUi(this); + 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)); + + myStartNetworkGameDialog->setMyW(myW); + myGameLobbyDialog->setMyW(myW); + + myTimeoutDialog.reset(new timeoutMsgBoxImpl(this)); + + + connect( actionStart_Local_Game, SIGNAL( triggered() ), this, SLOT( callNewGameDialog() ) ); + connect( pushButtonStart_Local_Game, SIGNAL( clicked() ), this, SLOT( callNewGameDialog() ) ); + connect( actionInternet_Game, SIGNAL( triggered() ), this, SLOT( callGameLobbyDialog() ) ); + + 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(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)), 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(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(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog.get(), 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))); + connect(this, SIGNAL(signalIrcPlayerJoined(QString)), myGameLobbyDialog->getLobbyChat(), SLOT(playerJoined(QString))); + connect(this, SIGNAL(signalIrcPlayerChanged(QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(playerChanged(QString, QString))); + connect(this, SIGNAL(signalIrcPlayerKicked(QString, QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(playerKicked(QString, QString, QString))); + connect(this, SIGNAL(signalIrcPlayerLeft(QString)), myGameLobbyDialog->getLobbyChat(), SLOT(playerLeft(QString))); + connect(this, SIGNAL(signalIrcChatMessage(QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(displayMessage(QString, QString))); + connect(this, SIGNAL(signalIrcError(int)), myGameLobbyDialog->getLobbyChat(), SLOT(chatError(int))); + connect(this, SIGNAL(signalIrcServerError(int)), myGameLobbyDialog->getLobbyChat(), SLOT(chatServerError(int))); + } + +void startWindowImpl::callNewGameDialog() { + + //wenn Dialogfenster gezeigt werden soll + if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ + + myNewGameDialog->exec(); + if (myNewGameDialog->result() == QDialog::Accepted ) { myW->startNewLocalGame(myNewGameDialog.get()); } + } + // sonst mit gespeicherten Werten starten + else { myW->startNewLocalGame(); } +} + +void startWindowImpl::callGameLobbyDialog() { + + //Avoid join Lobby with "Human Player" nick + if(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) == QString("Human Player")) { + myChangeHumanPlayerNameDialog->label_Message->setText(tr("You cannot join Internet-Game-Lobby with \"Human Player\" as nickname.\nPlease choose another one.")); + myChangeHumanPlayerNameDialog->exec(); + + if(myChangeHumanPlayerNameDialog->result() == QDialog::Accepted) { + joinGameLobby(); + } + } + else { + joinGameLobby(); + } +} + +void startWindowImpl::joinGameLobby() { + + // Stop local game. + myW->stopTimer(); + +// Join Lobby + mySession->terminateNetworkClient(); + if (myServerGuiInterface.get()) + myServerGuiInterface->getSession().terminateNetworkServer(); + myGameLobbyDialog->setSession(&getSession()); + myStartNetworkGameDialog->setSession(&getSession()); + + // Clear Lobby dialog. + myGameLobbyDialog->clearDialog(); + + //set clean irc nick + QString myNick(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); + myNick.replace(QString::fromUtf8("ä"),"ae"); + myNick.replace(QString::fromUtf8("Ä"),"Ae"); + myNick.replace(QString::fromUtf8("ü"),"ue"); + myNick.replace(QString::fromUtf8("Ü"),"Ue"); + myNick.replace(QString::fromUtf8("ö"),"oe"); + myNick.replace(QString::fromUtf8("Ö"),"Oe"); + myNick.replace(QString::fromUtf8("é"),"e"); + myNick.replace(QString::fromUtf8("è"),"e"); + myNick.replace(QString::fromUtf8("á"),"a"); + myNick.replace(QString::fromUtf8("à"),"a"); + myNick.replace(QString::fromUtf8("ó"),"o"); + myNick.replace(QString::fromUtf8("ò"),"o"); + myNick.replace(QString::fromUtf8("ú"),"u"); + myNick.replace(QString::fromUtf8("ù"),"u"); + myNick.replace(QString::fromUtf8("É"),"E"); + myNick.replace(QString::fromUtf8("È"),"E"); + myNick.replace(QString::fromUtf8("Á"),"A"); + myNick.replace(QString::fromUtf8("À"),"A"); + myNick.replace(QString::fromUtf8("Ó"),"O"); + myNick.replace(QString::fromUtf8("Ò"),"O"); + myNick.replace(QString::fromUtf8("Ú"),"U"); + myNick.replace(QString::fromUtf8("Ù"),"U"); + myNick.remove(QRegExp("[^A-Z^a-z^0-9|\\-_\\\\^`]*")); + myNick = myNick.mid(0,16); + + mySession->setIrcNick(myNick.toUtf8().constData()); + + // Start client for dedicated server. + mySession->startInternetClient(); + + //Dialog mit Statusbalken + myConnectToServerDialog->exec(); + + if (myConnectToServerDialog->result() == QDialog::Rejected ) { + mySession->terminateNetworkClient(); + } + else + { + showLobbyDialog(); + } +} + +void startWindowImpl::showClientDialog() +{ + if (mySession->getGameType() == Session::GAME_TYPE_NETWORK) + { + if (!myStartNetworkGameDialog->isVisible()) + showNetworkStartDialog(); + } + else if (mySession->getGameType() == Session::GAME_TYPE_INTERNET) + { + if (!myGameLobbyDialog->isVisible()) + showLobbyDialog(); + } +} + +void startWindowImpl::showLobbyDialog() +{ + myGameLobbyDialog->exec(); + + if (myGameLobbyDialog->result() == QDialog::Accepted) + { + //some gui modifications + myW->networkGameModification(); + } + else + { + mySession->terminateNetworkClient(); + } +} + +void startWindowImpl::showNetworkStartDialog() +{ + myStartNetworkGameDialog->exec(); + + if (myStartNetworkGameDialog->result() == QDialog::Accepted ) { + + //some gui modifications + myW->networkGameModification(); + } + else { + mySession->terminateNetworkClient(); + if (myServerGuiInterface) + myServerGuiInterface->getSession().terminateNetworkServer(); + } +} diff --git a/src/gui/qt/startwindow/startwindowimpl.h b/src/gui/qt/startwindow/startwindowimpl.h index 64996c74..5d93bbb2 100644 --- a/src/gui/qt/startwindow/startwindowimpl.h +++ b/src/gui/qt/startwindow/startwindowimpl.h @@ -20,20 +20,104 @@ #ifndef STARTWINDOWIMPL_H #define STARTWINDOWIMPL_H +#include #include "ui_startwindow.h" +#include "game_defs.h" + +class GuiInterface; +class Session; +class Game; class ConfigFile; class gameTableImpl; +class newGameDialogImpl; +class settingsDialogImpl; +class selectAvatarDialogImpl; +class aboutPokerthImpl; +class joinNetworkGameDialogImpl; +class connectToServerDialogImpl; +class createNetworkGameDialogImpl; +class startNetworkGameDialogImpl; +class changeHumanPlayerNameDialogImpl; +class gameLobbyDialogImpl; +class timeoutMsgBoxImpl; + class startWindowImpl: public QMainWindow, public Ui::startWindow { Q_OBJECT public: startWindowImpl(gameTableImpl *w = 0, ConfigFile *c =0); -private: + void setSession(boost::shared_ptr session) { mySession = session; } + Session &getSession() { assert(mySession.get()); return *mySession; } - ConfigFile *myConfig; +signals: + void signalShowClientDialog(); + + void signalNetClientConnect(int actionID); + void signalNetClientGameInfo(int actionID); + void signalNetClientError(int errorID, int osErrorID); + void signalNetClientNotification(int notificationId); + void signalNetClientStatsUpdate(ServerStats stats); + void signalNetClientShowTimeoutDialog(int, unsigned); + void signalNetClientRemovedFromGame(int notificationId); + void signalNetServerError(int errorID, int osErrorID); + void signalNetClientSelfJoined(unsigned playerId, QString playerName, int rights); + void signalNetClientPlayerJoined(unsigned playerId, QString playerName, int rights); + void signalNetClientPlayerChanged(unsigned playerId, QString newPlayerName); + void signalNetClientPlayerLeft(unsigned playerId, QString playerName); + void signalNetClientNewGameAdmin(unsigned playerId, QString playerName); + void signalNetClientGameListNew(unsigned gameId); + void signalNetClientGameListRemove(unsigned gameId); + void signalNetClientGameListUpdateMode(unsigned gameId, int mode); + void signalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); + void signalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); + void signalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); + void signalNetClientGameStart(boost::shared_ptr game); + void signalNetClientChatMsg(QString nickName, QString msg); + + void signalIrcConnect(QString server); + void signalIrcSelfJoined(QString nickName, QString channel); + void signalIrcPlayerJoined(QString nickName); + void signalIrcPlayerChanged(QString oldNick, QString newNick); + void signalIrcPlayerKicked(QString nickName, QString byWhom, QString reason); + void signalIrcPlayerLeft(QString nickName); + void signalIrcChatMessage(QString nickName, QString msg); + void signalIrcError(int errorCode); + void signalIrcServerError(int errorCode); + + +public slots: + void callNewGameDialog(); + void callGameLobbyDialog(); + void showLobbyDialog(); + void joinGameLobby(); + void showClientDialog(); + void showNetworkStartDialog(); + +private: gameTableImpl *myW; + ConfigFile *myConfig; + + boost::shared_ptr mySession; + 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; + + +friend class GuiWrapper; }; #endif