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_BIG_BLIND };
enum NetTimeoutReason {
GENERIC = 0,
OPENGAMEADMINIDLE
};
struct ServerStats
{
ServerStats()
@@ -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();
}
@@ -27,7 +27,6 @@
class Session;
class ConfigFile;
class LobbyChat;
class timeoutMsgBoxImpl;
/**
@author FThauer FHammer <webmaster@pokerth.net>
@@ -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<timeoutMsgBoxImpl> myOpenGameTimeoutMsgBoxImpl;
protected:
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::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); }
+1 -1
View File
@@ -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);
+17 -1
View File
@@ -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(); }
+6 -2
View File
@@ -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<timeoutMsgBoxImpl> myTimeoutDialog;
//Sound
SDLPlayer *mySDLPlayer;
+10 -6
View File
@@ -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
}
+7 -4
View File
@@ -16,6 +16,7 @@
#include <QtGui>
#include <QtCore>
#include <core/boost/timers.hpp>
#include "game_defs.h"
/**
@author Felix Hammer <f.hammer@web.de>
@@ -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<Session> theValue ) { mySession = theValue; }
void setMsgID ( int theValue ) { msgID = theValue; }
private:
QTimer *timeOutTimer;
QPushButton *okButton;
Session *mySession;
int msgId;
boost::shared_ptr<Session> mySession;
int msgID;
boost::timers::portable::microsec_timer realTimer;
};