diff --git a/src/game_defs.h b/src/game_defs.h index b93a0d06..ffc5606f 100644 --- a/src/game_defs.h +++ b/src/game_defs.h @@ -73,6 +73,11 @@ enum Button { BUTTON_SMALL_BLIND, BUTTON_BIG_BLIND }; +enum NetTimeoutReason { + GENERIC = 0, + OPENGAMEADMINIDLE +}; + struct ServerStats { ServerStats() diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 414b7bca..dcb93745 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -12,7 +12,6 @@ #include "gamelobbydialogimpl.h" #include "lobbychat.h" #include "changecompleteblindsdialogimpl.h" -#include "timeoutmsgboximpl.h" #include "session.h" #include "configfile.h" #include "gamedata.h" @@ -32,8 +31,6 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c) myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - myOpenGameTimeoutMsgBoxImpl.reset(new timeoutMsgBoxImpl(this, 1)); - //wait start game message waitStartGameMsgBox = new QMessageBox(this); waitStartGameMsgBox->setText(tr("Starting game. Please wait ...")); @@ -80,7 +77,6 @@ void gameLobbyDialogImpl::exec() waitStartGameMsgBoxTimer->stop(); waitStartGameMsgBox->hide(); - myOpenGameTimeoutMsgBoxImpl->hide(); } @@ -844,17 +840,3 @@ void gameLobbyDialogImpl::joinAnyGameButtonRefresh() { else pushButton_joinAnyGame->setEnabled(FALSE); } -void gameLobbyDialogImpl::startOpenGameTimeout() { - - myOpenGameTimeoutMsgBoxImpl->setMySession(mySession); - - myOpenGameTimeoutMsgBoxImpl->show(); - myOpenGameTimeoutMsgBoxImpl->raise(); - myOpenGameTimeoutMsgBoxImpl->activateWindow(); - myOpenGameTimeoutMsgBoxImpl->startTimeout(); -} - -void gameLobbyDialogImpl::closeOpenGameTimeoutMsgBox() { - - myOpenGameTimeoutMsgBoxImpl->hide(); -} diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 21721a65..8a87ede7 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -27,7 +27,6 @@ class Session; class ConfigFile; class LobbyChat; -class timeoutMsgBoxImpl; /** @author FThauer FHammer @@ -101,9 +100,6 @@ public slots: void showWaitStartGameMsgBox(); - void startOpenGameTimeout(); - void closeOpenGameTimeoutMsgBox(); - void joinAnyGameButtonRefresh(); @@ -122,7 +118,7 @@ private: int keyUpCounter; QMessageBox *waitStartGameMsgBox; QTimer *waitStartGameMsgBoxTimer; - boost::shared_ptr myOpenGameTimeoutMsgBoxImpl; + protected: bool eventFilter(QObject *obj, QEvent *event); diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 2949ef08..76852d56 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -120,7 +120,7 @@ void GuiWrapper::SignalNetClientGameInfo(int actionID) { myW->signalNetClientGam void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->signalNetClientError(errorID, osErrorID); } void GuiWrapper::SignalNetClientNotification(int notificationId) { myW->signalNetClientNotification(notificationId); } void GuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) { myW->signalNetClientStatsUpdate(stats); } -void GuiWrapper::SignalNetClientStartOpenGameTimeout() { myW->signalNetClientStartOpenGameTimeout(); } +void GuiWrapper::SignalNetClientShowTimeoutDialog(int msgID) { myW->signalNetClientShowTimeoutDialog(msgID); } void GuiWrapper::SignalNetClientRemovedFromGame(int notificationId) { myW->signalNetClientRemovedFromGame(notificationId); } void GuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, PlayerRights rights) { myW->signalNetClientSelfJoined(playerId, QString::fromUtf8(playerName.c_str()), rights); } void GuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, PlayerRights rights) { myW->signalNetClientPlayerJoined(playerId, QString::fromUtf8(playerName.c_str()), rights); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 2e600d9f..d4840ae6 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -108,7 +108,7 @@ public: void SignalNetClientError(int errorID, int osErrorID); void SignalNetClientNotification(int notificationId); void SignalNetClientStatsUpdate(const ServerStats &stats); - void SignalNetClientStartOpenGameTimeout(); + void SignalNetClientShowTimeoutDialog(int); void SignalNetClientRemovedFromGame(int notificationId); void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, PlayerRights rights); void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, PlayerRights rights); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 751cedae..e22babcd 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -31,6 +31,7 @@ #include "changehumanplayernamedialogimpl.h" #include "changecompleteblindsdialogimpl.h" #include "gamelobbydialogimpl.h" +#include "timeoutmsgboximpl.h" #include "lobbychat.h" #include "startsplash.h" @@ -480,6 +481,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) myStartNetworkGameDialog->setMyW(this); myGameLobbyDialog->setMyW(this); + + myTimeoutDialog.reset(new timeoutMsgBoxImpl(this)); myChat = new Chat(this, myConfig); @@ -635,7 +638,7 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) 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(signalNetClientStartOpenGameTimeout()), myGameLobbyDialog, SLOT(startOpenGameTimeout())); + connect(this, SIGNAL(signalNetClientShowTimeoutDialog(int)), this, SLOT(showTimeoutDialog(int))); // Errors are handled globally, not within one dialog. connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int))); @@ -3770,3 +3773,16 @@ void mainWindowImpl::leaveCurrentNetworkGame() { } } } + + +void mainWindowImpl::showTimeoutDialog(int msgID) { + + myTimeoutDialog->setMySession(mySession); + myTimeoutDialog->setMsgID(msgID); + myTimeoutDialog->show(); + myTimeoutDialog->raise(); + myTimeoutDialog->activateWindow(); + myTimeoutDialog->startTimeout(); +} + +void mainWindowImpl::hideTimeoutDialog() { myTimeoutDialog->hide(); } diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index 0a8a8afb..b0445516 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -50,6 +50,7 @@ class createNetworkGameDialogImpl; class startNetworkGameDialogImpl; class changeHumanPlayerNameDialogImpl; class gameLobbyDialogImpl; +class timeoutMsgBoxImpl; class QColor; class SDLPlayer; @@ -130,7 +131,7 @@ signals: void signalNetClientError(int errorID, int osErrorID); void signalNetClientNotification(int notificationId); void signalNetClientStatsUpdate(ServerStats stats); - void signalNetClientStartOpenGameTimeout(); + void signalNetClientShowTimeoutDialog(int); void signalNetClientRemovedFromGame(int notificationId); void signalNetServerError(int errorID, int osErrorID); void signalNetClientSelfJoined(unsigned playerId, QString playerName, int rights); @@ -331,6 +332,9 @@ public slots: void showMaximized (); void quitPokerTH(); + + void showTimeoutDialog(int msgID); + void hideTimeoutDialog(); // void paintEvent(QPaintEvent *); @@ -407,7 +411,7 @@ private: startNetworkGameDialogImpl *myStartNetworkGameDialog; createNetworkGameDialogImpl *myCreateNetworkGameDialog; gameLobbyDialogImpl *myGameLobbyDialog; - + boost::shared_ptr myTimeoutDialog; //Sound SDLPlayer *mySDLPlayer; diff --git a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp index e68cbce3..88657144 100644 --- a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp +++ b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp @@ -12,8 +12,8 @@ #include "timeoutmsgboximpl.h" #include "session.h" -timeoutMsgBoxImpl::timeoutMsgBoxImpl(QDialog *parent, int id) - : QMessageBox(parent), mySession(NULL), msgId(id) +timeoutMsgBoxImpl::timeoutMsgBoxImpl(QMainWindow *parent) + : QMessageBox(parent) { okButton = this->addButton(QMessageBox::Ok); @@ -24,7 +24,7 @@ timeoutMsgBoxImpl::timeoutMsgBoxImpl(QDialog *parent, int id) timeOutTimer = new QTimer; connect(timeOutTimer, SIGNAL(timeout()), this, SLOT(timerRefresh())); -// connect(okButton, SIGNAL(clicked()), mySession, SLOT(spechialSessionSlot(msgId))); + connect(okButton, SIGNAL(clicked()), this, SLOT(stopTimeout())); } @@ -46,12 +46,16 @@ void timeoutMsgBoxImpl::timerRefresh() { unsigned int realTimerValue = realTimer.elapsed().total_milliseconds(); sec -= realTimerValue/1000; if (sec < 0) sec = 0; - switch (msgId) { - case 0: { this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); } + switch (msgID) { + case GENERIC: { this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); } break; - case 1: { this->setText(tr("Your open game reaches timeout in %1 seconds.").arg(sec,0,10)); } + case OPENGAMEADMINIDLE: { this->setText(tr("Your open game reaches timeout in %1 seconds.").arg(sec,0,10)); } break; } } +void timeoutMsgBoxImpl::stopTimeout() { + +// mySession->stopTimeout +} diff --git a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h index 82930ab3..984d5899 100644 --- a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h +++ b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h @@ -16,6 +16,7 @@ #include #include #include +#include "game_defs.h" /** @author Felix Hammer @@ -26,7 +27,7 @@ class timeoutMsgBoxImpl : public QMessageBox { Q_OBJECT public: - timeoutMsgBoxImpl(QDialog*, int); + timeoutMsgBoxImpl(QMainWindow*); ~timeoutMsgBoxImpl(); @@ -34,15 +35,17 @@ public slots: void startTimeout(); void timerRefresh(); + void stopTimeout(); - void setMySession ( Session* theValue ) { mySession = theValue; } + void setMySession ( boost::shared_ptr theValue ) { mySession = theValue; } + void setMsgID ( int theValue ) { msgID = theValue; } private: QTimer *timeOutTimer; QPushButton *okButton; - Session *mySession; - int msgId; + boost::shared_ptr mySession; + int msgID; boost::timers::portable::microsec_timer realTimer; };