From 39efcf3ddf8310f9f30cd5b08c8de517d7ab074b Mon Sep 17 00:00:00 2001 From: doitux Date: Sat, 1 Mar 2008 23:44:12 +0000 Subject: [PATCH] opengametimeoutmsgbox local basics --- pokerth_game.pro | 8 +++-- .../gamelobbydialog/gamelobbydialogimpl.cpp | 19 +++++++++++ .../qt/gamelobbydialog/gamelobbydialogimpl.h | 6 ++++ .../opengametimeoutmsgboximpl.cpp | 33 +++++++++++++++++-- .../opengametimeoutmsgboximpl.h | 18 +++++++++- src/gui/qt/guiwrapper.cpp | 1 + src/gui/qt/guiwrapper.h | 1 + src/gui/qt/mainwindow/mainwindowimpl.cpp | 1 + src/gui/qt/mainwindow/mainwindowimpl.h | 1 + 9 files changed, 82 insertions(+), 6 deletions(-) diff --git a/pokerth_game.pro b/pokerth_game.pro index 651fd3c9..ce7061d1 100644 --- a/pokerth_game.pro +++ b/pokerth_game.pro @@ -53,7 +53,8 @@ INCLUDEPATH += . \ src/gui/qt/changecompleteblindsdialog \ src/gui/qt/mymessagedialog \ src/gui/qt/gamelobbydialog \ - src/gui/qt/gamelobbydialog/lobbychat + src/gui/qt/gamelobbydialog/lobbychat \ + src/gui/qt/gamelobbydialog/opengametimeoutmsgbox DEPENDPATH += . \ src \ @@ -90,7 +91,8 @@ DEPENDPATH += . \ src/gui/qt/changecompleteblindsdialog \ src/gui/qt/mymessagedialog \ src/gui/qt/gamelobbydialog \ - src/gui/qt/gamelobbydialog/lobbychat + src/gui/qt/gamelobbydialog/lobbychat \ + src/gui/qt/gamelobbydialog/opengametimeoutmsgbox # Input HEADERS += \ @@ -171,6 +173,7 @@ HEADERS += \ src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h \ src/gui/qt/gamelobbydialog/mygamelisttreewidget.h \ src/gui/qt/gamelobbydialog/lobbychat/lobbychat.h \ + src/gui/qt/gamelobbydialog/opengametimeoutmsgbox\opengametimeoutmsgboximpl.h \ src/gui/qt/mymessagedialog/mymessagedialogimpl.h \ src/gui/qttoolsinterface.h \ src/gui/qt/qttools/qttoolswrapper.h \ @@ -229,6 +232,7 @@ SOURCES += \ src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp \ src/gui/qt/gamelobbydialog/mygamelisttreewidget.cpp \ src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp \ + src/gui/qt/gamelobbydialog/opengametimeoutmsgbox\opengametimeoutmsgboximpl.cpp \ src/net/common/net_helper_client.cpp \ src/core/common/loghelper_client.cpp diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 665229bc..b783681f 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -12,6 +12,7 @@ #include "gamelobbydialogimpl.h" #include "lobbychat.h" #include "changecompleteblindsdialogimpl.h" +#include "opengametimeoutmsgboximpl.h" #include "session.h" #include "configfile.h" #include "gamedata.h" @@ -31,6 +32,8 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c) myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); + myOpenGameTimeoutMsgBoxImpl = new openGameTimeoutMsgBoxImpl(this, this); + //wait start game message waitStartGameMsgBox = new QMessageBox(this); waitStartGameMsgBox->setText(tr("Starting game. Please wait ...")); @@ -77,6 +80,8 @@ void gameLobbyDialogImpl::exec() waitStartGameMsgBoxTimer->stop(); waitStartGameMsgBox->hide(); + myOpenGameTimeoutMsgBoxImpl->hide(); + } @@ -838,3 +843,17 @@ void gameLobbyDialogImpl::joinAnyGameButtonRefresh() { else pushButton_joinAnyGame->setEnabled(FALSE); } +void gameLobbyDialogImpl::startOpenGameTimeout() { + + myOpenGameTimeoutMsgBoxImpl->show(); + myOpenGameTimeoutMsgBoxImpl->raise(); + myOpenGameTimeoutMsgBoxImpl->activateWindow(); + myOpenGameTimeoutMsgBoxImpl->startTimeout(); +} + +void gameLobbyDialogImpl::closeOpenGameTimeoutMsgBox() { + + myOpenGameTimeoutMsgBoxImpl->hide(); +} + +void gameLobbyDialogImpl::openGameTimeoutStoped() { /*mySession->openGameTimeoutStoped();*/ } diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 7896bbc3..26db179a 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -27,6 +27,7 @@ class Session; class ConfigFile; class LobbyChat; +class openGameTimeoutMsgBoxImpl; /** @author FThauer FHammer @@ -100,6 +101,10 @@ public slots: void showWaitStartGameMsgBox(); + void startOpenGameTimeout(); + void openGameTimeoutStoped(); + void closeOpenGameTimeoutMsgBox(); + void joinAnyGameButtonRefresh(); @@ -118,6 +123,7 @@ private: int keyUpCounter; QMessageBox *waitStartGameMsgBox; QTimer *waitStartGameMsgBoxTimer; + openGameTimeoutMsgBoxImpl *myOpenGameTimeoutMsgBoxImpl; protected: bool eventFilter(QObject *obj, QEvent *event); diff --git a/src/gui/qt/gamelobbydialog/opengametimeoutmsgbox/opengametimeoutmsgboximpl.cpp b/src/gui/qt/gamelobbydialog/opengametimeoutmsgbox/opengametimeoutmsgboximpl.cpp index 9afa6996..4ed7fc25 100644 --- a/src/gui/qt/gamelobbydialog/opengametimeoutmsgbox/opengametimeoutmsgboximpl.cpp +++ b/src/gui/qt/gamelobbydialog/opengametimeoutmsgbox/opengametimeoutmsgboximpl.cpp @@ -10,15 +10,42 @@ // // #include "opengametimeoutmsgboximpl.h" +#include "gamelobbydialogimpl.h" -openGameTimeoutMsgBoxImpl::openGameTimeoutMsgBoxImpl() - : QMessageBox() +openGameTimeoutMsgBoxImpl::openGameTimeoutMsgBoxImpl(QDialog *parent, gameLobbyDialogImpl *l) + : QMessageBox(parent), myLobby(l) { -} + okButton = this->addButton(QMessageBox::Ok); + this->setWindowTitle(tr("Open Game Timeout Warning")); + this->setIcon(QMessageBox::Warning); + this->setText(tr("Your open game reaches timeout in %1 seconds.").arg(60,0,10)); + this->setInformativeText(tr("Please click \"OK\" to stop timeout!")); + + timeOutTimer = new QTimer; + + connect(timeOutTimer, SIGNAL(timeout()), this, SLOT(timerRefresh())); + connect(okButton, SIGNAL(clicked()), myLobby, SLOT(openGameTimeoutStoped())); + +} openGameTimeoutMsgBoxImpl::~openGameTimeoutMsgBoxImpl() { } +void openGameTimeoutMsgBoxImpl::startTimeout() { + //start the real timer + realTimer.reset(); + realTimer.start(); + timeOutTimer->start(1000); +} + +void openGameTimeoutMsgBoxImpl::timerRefresh() { + + int sec = 60; + unsigned int realTimerValue = realTimer.elapsed().total_milliseconds(); + sec -= realTimerValue/1000; + if (sec < 0) sec = 0; + this->setText(tr("Your open game reaches timeout in %1 seconds.").arg(sec,0,10)); +} diff --git a/src/gui/qt/gamelobbydialog/opengametimeoutmsgbox/opengametimeoutmsgboximpl.h b/src/gui/qt/gamelobbydialog/opengametimeoutmsgbox/opengametimeoutmsgboximpl.h index 284c862e..63395684 100644 --- a/src/gui/qt/gamelobbydialog/opengametimeoutmsgbox/opengametimeoutmsgboximpl.h +++ b/src/gui/qt/gamelobbydialog/opengametimeoutmsgbox/opengametimeoutmsgboximpl.h @@ -13,17 +13,33 @@ #define OPENGAMETIMEOUTMSGBOXIMPL_H #include +#include +#include +#include /** @author Felix Hammer */ +class gameLobbyDialogImpl; + class openGameTimeoutMsgBoxImpl : public QMessageBox { +Q_OBJECT public: - openGameTimeoutMsgBoxImpl(); + openGameTimeoutMsgBoxImpl(QDialog*, gameLobbyDialogImpl*); ~openGameTimeoutMsgBoxImpl(); +public slots: + + void startTimeout(); + void timerRefresh(); + +private: + QTimer *timeOutTimer; + QPushButton *okButton; + gameLobbyDialogImpl *myLobby; + boost::timers::portable::microsec_timer realTimer; }; #endif diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index d81e513a..2949ef08 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -120,6 +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::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 c6a867f6..2e600d9f 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -108,6 +108,7 @@ public: void SignalNetClientError(int errorID, int osErrorID); void SignalNetClientNotification(int notificationId); void SignalNetClientStatsUpdate(const ServerStats &stats); + void SignalNetClientStartOpenGameTimeout(); 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 50ba4980..7f47dc67 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -635,6 +635,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())); // Errors are handled globally, not within one dialog. connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int))); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index 5b2c6731..0a8a8afb 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -130,6 +130,7 @@ signals: void signalNetClientError(int errorID, int osErrorID); void signalNetClientNotification(int notificationId); void signalNetClientStatsUpdate(ServerStats stats); + void signalNetClientStartOpenGameTimeout(); void signalNetClientRemovedFromGame(int notificationId); void signalNetServerError(int errorID, int osErrorID); void signalNetClientSelfJoined(unsigned playerId, QString playerName, int rights);