timeoutDialog

This commit is contained in:
doitux
2008-03-03 23:31:20 +00:00
parent 00d0e77528
commit c2313a20d6
9 changed files with 48 additions and 38 deletions
+5
View File
@@ -73,6 +73,11 @@ enum Button {
BUTTON_SMALL_BLIND, BUTTON_SMALL_BLIND,
BUTTON_BIG_BLIND }; BUTTON_BIG_BLIND };
enum NetTimeoutReason {
GENERIC = 0,
OPENGAMEADMINIDLE
};
struct ServerStats struct ServerStats
{ {
ServerStats() ServerStats()
@@ -12,7 +12,6 @@
#include "gamelobbydialogimpl.h" #include "gamelobbydialogimpl.h"
#include "lobbychat.h" #include "lobbychat.h"
#include "changecompleteblindsdialogimpl.h" #include "changecompleteblindsdialogimpl.h"
#include "timeoutmsgboximpl.h"
#include "session.h" #include "session.h"
#include "configfile.h" #include "configfile.h"
#include "gamedata.h" #include "gamedata.h"
@@ -32,8 +31,6 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
myOpenGameTimeoutMsgBoxImpl.reset(new timeoutMsgBoxImpl(this, 1));
//wait start game message //wait start game message
waitStartGameMsgBox = new QMessageBox(this); waitStartGameMsgBox = new QMessageBox(this);
waitStartGameMsgBox->setText(tr("Starting game. Please wait ...")); waitStartGameMsgBox->setText(tr("Starting game. Please wait ..."));
@@ -80,7 +77,6 @@ void gameLobbyDialogImpl::exec()
waitStartGameMsgBoxTimer->stop(); waitStartGameMsgBoxTimer->stop();
waitStartGameMsgBox->hide(); waitStartGameMsgBox->hide();
myOpenGameTimeoutMsgBoxImpl->hide();
} }
@@ -844,17 +840,3 @@ void gameLobbyDialogImpl::joinAnyGameButtonRefresh() {
else pushButton_joinAnyGame->setEnabled(FALSE); else pushButton_joinAnyGame->setEnabled(FALSE);
} }
void gameLobbyDialogImpl::startOpenGameTimeout() {
myOpenGameTimeoutMsgBoxImpl->setMySession(mySession);
myOpenGameTimeoutMsgBoxImpl->show();
myOpenGameTimeoutMsgBoxImpl->raise();
myOpenGameTimeoutMsgBoxImpl->activateWindow();
myOpenGameTimeoutMsgBoxImpl->startTimeout();
}
void gameLobbyDialogImpl::closeOpenGameTimeoutMsgBox() {
myOpenGameTimeoutMsgBoxImpl->hide();
}
@@ -27,7 +27,6 @@
class Session; class Session;
class ConfigFile; class ConfigFile;
class LobbyChat; class LobbyChat;
class timeoutMsgBoxImpl;
/** /**
@author FThauer FHammer <webmaster@pokerth.net> @author FThauer FHammer <webmaster@pokerth.net>
@@ -101,9 +100,6 @@ public slots:
void showWaitStartGameMsgBox(); void showWaitStartGameMsgBox();
void startOpenGameTimeout();
void closeOpenGameTimeoutMsgBox();
void joinAnyGameButtonRefresh(); void joinAnyGameButtonRefresh();
@@ -122,7 +118,7 @@ private:
int keyUpCounter; int keyUpCounter;
QMessageBox *waitStartGameMsgBox; QMessageBox *waitStartGameMsgBox;
QTimer *waitStartGameMsgBoxTimer; QTimer *waitStartGameMsgBoxTimer;
boost::shared_ptr<timeoutMsgBoxImpl> myOpenGameTimeoutMsgBoxImpl;
protected: protected:
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event);
+1 -1
View File
@@ -120,7 +120,7 @@ void GuiWrapper::SignalNetClientGameInfo(int actionID) { myW->signalNetClientGam
void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->signalNetClientError(errorID, osErrorID); } void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->signalNetClientError(errorID, osErrorID); }
void GuiWrapper::SignalNetClientNotification(int notificationId) { myW->signalNetClientNotification(notificationId); } void GuiWrapper::SignalNetClientNotification(int notificationId) { myW->signalNetClientNotification(notificationId); }
void GuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) { myW->signalNetClientStatsUpdate(stats); } 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::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::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); } void GuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, PlayerRights rights) { myW->signalNetClientPlayerJoined(playerId, QString::fromUtf8(playerName.c_str()), rights); }
+1 -1
View File
@@ -108,7 +108,7 @@ public:
void SignalNetClientError(int errorID, int osErrorID); void SignalNetClientError(int errorID, int osErrorID);
void SignalNetClientNotification(int notificationId); void SignalNetClientNotification(int notificationId);
void SignalNetClientStatsUpdate(const ServerStats &stats); void SignalNetClientStatsUpdate(const ServerStats &stats);
void SignalNetClientStartOpenGameTimeout(); void SignalNetClientShowTimeoutDialog(int);
void SignalNetClientRemovedFromGame(int notificationId); void SignalNetClientRemovedFromGame(int notificationId);
void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, PlayerRights rights); void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, PlayerRights rights);
void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, PlayerRights rights); void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, PlayerRights rights);
+17 -1
View File
@@ -31,6 +31,7 @@
#include "changehumanplayernamedialogimpl.h" #include "changehumanplayernamedialogimpl.h"
#include "changecompleteblindsdialogimpl.h" #include "changecompleteblindsdialogimpl.h"
#include "gamelobbydialogimpl.h" #include "gamelobbydialogimpl.h"
#include "timeoutmsgboximpl.h"
#include "lobbychat.h" #include "lobbychat.h"
#include "startsplash.h" #include "startsplash.h"
@@ -480,6 +481,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
myStartNetworkGameDialog->setMyW(this); myStartNetworkGameDialog->setMyW(this);
myGameLobbyDialog->setMyW(this); myGameLobbyDialog->setMyW(this);
myTimeoutDialog.reset(new timeoutMsgBoxImpl(this));
myChat = new Chat(this, myConfig); 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(signalNetClientGameListPlayerLeft(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameRemovePlayer(unsigned, unsigned)));
connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog, SLOT(removedFromGame(int))); connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog, SLOT(removedFromGame(int)));
connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog, SLOT(updateStats(ServerStats))); 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. // Errors are handled globally, not within one dialog.
connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int))); 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(); }
+6 -2
View File
@@ -50,6 +50,7 @@ class createNetworkGameDialogImpl;
class startNetworkGameDialogImpl; class startNetworkGameDialogImpl;
class changeHumanPlayerNameDialogImpl; class changeHumanPlayerNameDialogImpl;
class gameLobbyDialogImpl; class gameLobbyDialogImpl;
class timeoutMsgBoxImpl;
class QColor; class QColor;
class SDLPlayer; class SDLPlayer;
@@ -130,7 +131,7 @@ signals:
void signalNetClientError(int errorID, int osErrorID); void signalNetClientError(int errorID, int osErrorID);
void signalNetClientNotification(int notificationId); void signalNetClientNotification(int notificationId);
void signalNetClientStatsUpdate(ServerStats stats); void signalNetClientStatsUpdate(ServerStats stats);
void signalNetClientStartOpenGameTimeout(); void signalNetClientShowTimeoutDialog(int);
void signalNetClientRemovedFromGame(int notificationId); void signalNetClientRemovedFromGame(int notificationId);
void signalNetServerError(int errorID, int osErrorID); void signalNetServerError(int errorID, int osErrorID);
void signalNetClientSelfJoined(unsigned playerId, QString playerName, int rights); void signalNetClientSelfJoined(unsigned playerId, QString playerName, int rights);
@@ -331,6 +332,9 @@ public slots:
void showMaximized (); void showMaximized ();
void quitPokerTH(); void quitPokerTH();
void showTimeoutDialog(int msgID);
void hideTimeoutDialog();
// void paintEvent(QPaintEvent *); // void paintEvent(QPaintEvent *);
@@ -407,7 +411,7 @@ private:
startNetworkGameDialogImpl *myStartNetworkGameDialog; startNetworkGameDialogImpl *myStartNetworkGameDialog;
createNetworkGameDialogImpl *myCreateNetworkGameDialog; createNetworkGameDialogImpl *myCreateNetworkGameDialog;
gameLobbyDialogImpl *myGameLobbyDialog; gameLobbyDialogImpl *myGameLobbyDialog;
boost::shared_ptr<timeoutMsgBoxImpl> myTimeoutDialog;
//Sound //Sound
SDLPlayer *mySDLPlayer; SDLPlayer *mySDLPlayer;
+10 -6
View File
@@ -12,8 +12,8 @@
#include "timeoutmsgboximpl.h" #include "timeoutmsgboximpl.h"
#include "session.h" #include "session.h"
timeoutMsgBoxImpl::timeoutMsgBoxImpl(QDialog *parent, int id) timeoutMsgBoxImpl::timeoutMsgBoxImpl(QMainWindow *parent)
: QMessageBox(parent), mySession(NULL), msgId(id) : QMessageBox(parent)
{ {
okButton = this->addButton(QMessageBox::Ok); okButton = this->addButton(QMessageBox::Ok);
@@ -24,7 +24,7 @@ timeoutMsgBoxImpl::timeoutMsgBoxImpl(QDialog *parent, int id)
timeOutTimer = new QTimer; timeOutTimer = new QTimer;
connect(timeOutTimer, SIGNAL(timeout()), this, SLOT(timerRefresh())); 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(); unsigned int realTimerValue = realTimer.elapsed().total_milliseconds();
sec -= realTimerValue/1000; sec -= realTimerValue/1000;
if (sec < 0) sec = 0; if (sec < 0) sec = 0;
switch (msgId) { switch (msgID) {
case 0: { this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); } case GENERIC: { this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); }
break; 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; break;
} }
} }
void timeoutMsgBoxImpl::stopTimeout() {
// mySession->stopTimeout
}
+7 -4
View File
@@ -16,6 +16,7 @@
#include <QtGui> #include <QtGui>
#include <QtCore> #include <QtCore>
#include <core/boost/timers.hpp> #include <core/boost/timers.hpp>
#include "game_defs.h"
/** /**
@author Felix Hammer <f.hammer@web.de> @author Felix Hammer <f.hammer@web.de>
@@ -26,7 +27,7 @@ class timeoutMsgBoxImpl : public QMessageBox
{ {
Q_OBJECT Q_OBJECT
public: public:
timeoutMsgBoxImpl(QDialog*, int); timeoutMsgBoxImpl(QMainWindow*);
~timeoutMsgBoxImpl(); ~timeoutMsgBoxImpl();
@@ -34,15 +35,17 @@ public slots:
void startTimeout(); void startTimeout();
void timerRefresh(); void timerRefresh();
void stopTimeout();
void setMySession ( Session* theValue ) { mySession = theValue; } void setMySession ( boost::shared_ptr<Session> theValue ) { mySession = theValue; }
void setMsgID ( int theValue ) { msgID = theValue; }
private: private:
QTimer *timeOutTimer; QTimer *timeOutTimer;
QPushButton *okButton; QPushButton *okButton;
Session *mySession; boost::shared_ptr<Session> mySession;
int msgId; int msgID;
boost::timers::portable::microsec_timer realTimer; boost::timers::portable::microsec_timer realTimer;
}; };