Added new packet type as end of game notification. Now displaying dialogs at end of game, to start a new game. Server errors are displayed.

This commit is contained in:
lotodore
2007-06-10 23:28:25 +00:00
parent 8129880461
commit baf2c82864
20 changed files with 418 additions and 169 deletions
+2 -1
View File
@@ -110,6 +110,7 @@ void GuiWrapper::SignalNetClientPlayerJoined(const string &playerName) { myW->si
void GuiWrapper::SignalNetClientPlayerLeft(const string &playerName) { myW->signalNetClientPlayerLeft(QString::fromUtf8(playerName.c_str())); }
void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr<Game> game) { myW->signalNetClientGameStart(game); }
void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myChat->signalChatMessage(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); }
void GuiWrapper::SignalNetClientWaitDialog() { myW->signalShowClientWaitDialog(); }
void GuiWrapper::SignalNetServerSuccess(int actionID) { }
void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { myW->signalNetServerError(errorID, osErrorID); }
@@ -120,5 +121,5 @@ void GuiWrapper::SignalNetServerPlayerLeft(const string &playerName)
myW->signalNetServerPlayerLeft(tmpName);
myLog->signalLogPlayerLeftMsg(tmpName);
}
void GuiWrapper::SignalNetServerStartDialog() { myW->signalShowServerStartDialog(); }
+5
View File
@@ -42,6 +42,9 @@ public:
Session &getSession();
void setSession(boost::shared_ptr<Session> session);
void showServerStartDialog();
void showClientWaitDialog();
void refreshSet() const;
void refreshCash() const;
void refreshAction(int =-1, int =-1) const;
@@ -98,6 +101,7 @@ public:
void SignalNetClientPlayerJoined(const std::string &playerName);
void SignalNetClientPlayerLeft(const std::string &playerName);
void SignalNetClientChatMsg(const std::string &playerName, const std::string &msg);
void SignalNetClientWaitDialog();
void SignalNetClientGameStart(boost::shared_ptr<Game> game);
@@ -105,6 +109,7 @@ public:
void SignalNetServerError(int errorID, int osErrorID);
void SignalNetServerPlayerJoined(const std::string &playerName);
void SignalNetServerPlayerLeft(const std::string &playerName);
void SignalNetServerStartDialog();
private:
+39 -24
View File
@@ -573,6 +573,9 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
//Nachrichten Thread-Save
connect(this, SIGNAL(signalInitGui(int)), this, SLOT(initGui(int)));
connect(this, SIGNAL(signalShowServerStartDialog()), this, SLOT(showServerStartDialog()));
connect(this, SIGNAL(signalShowClientWaitDialog()), this, SLOT(showClientWaitDialog()));
connect(this, SIGNAL(signalRefreshSet()), this, SLOT(refreshSet()));
connect(this, SIGNAL(signalRefreshCash()), this, SLOT(refreshCash()));
connect(this, SIGNAL(signalRefreshAction(int, int)), this, SLOT(refreshAction(int, int)));
@@ -733,21 +736,8 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
mySession->startNetworkClientForLocalServer();
myStartNetworkGameDialog->setMaxPlayerNumber(gameData.numberOfPlayers);
myStartNetworkGameDialog->exec();
if (myStartNetworkGameDialog->result() == QDialog::Accepted ) {
//some gui modifications
networkGameModification();
myServerGuiInterface->getSession().initiateNetworkServerGame();
}
else {
mySession->terminateNetworkClient();
myServerGuiInterface->getSession().terminateNetworkServer();
}
showServerStartDialog();
}
}
@@ -779,15 +769,7 @@ void mainWindowImpl::callJoinNetworkGameDialog() {
actionJoin_network_Game->trigger(); // re-trigger
}
else {
myWaitingForServerGameDialog->exec();
if (myWaitingForServerGameDialog->result() == QDialog::Rejected) {
mySession->terminateNetworkClient();
}
else {
//some gui modifications
networkGameModification();
}
showClientWaitDialog();
}
}
}
@@ -890,6 +872,39 @@ void mainWindowImpl::initGui(int speed)
setSpeeds();
}
void mainWindowImpl::showServerStartDialog()
{
myStartNetworkGameDialog->exec();
if (myStartNetworkGameDialog->result() == QDialog::Accepted ) {
//some gui modifications
networkGameModification();
myServerGuiInterface->getSession().initiateNetworkServerGame();
}
else {
mySession->terminateNetworkClient();
myServerGuiInterface->getSession().terminateNetworkServer();
}
}
void mainWindowImpl::showClientWaitDialog()
{
if (!myServerGuiInterface.get() || !myServerGuiInterface->getSession().isNetworkServerRunning())
{
myWaitingForServerGameDialog->exec();
if (myWaitingForServerGameDialog->result() == QDialog::Accepted) {
//some gui modifications
networkGameModification();
}
else {
mySession->terminateNetworkClient();
}
}
}
Session &mainWindowImpl::getSession() { assert(mySession.get()); return *mySession; }
void mainWindowImpl::setSession(boost::shared_ptr<Session> session) { mySession = session; }
@@ -2344,7 +2359,7 @@ void mainWindowImpl::breakButtonClicked() {
int width = tempMetrics.width(tr("Stop"));
pushButton_break->setMinimumSize(width+10,20);
pushButton_break->setText(tr("Stop"));
pushButton_break->setText(tr("Stop"));
startNewHand();
}
}
+6
View File
@@ -74,6 +74,9 @@ public:
signals:
void signalInitGui(int speed);
void signalShowServerStartDialog();
void signalShowClientWaitDialog();
void signalRefreshSet();
void signalRefreshCash();
void signalRefreshAction(int =-1, int=-1);
@@ -129,6 +132,9 @@ public slots:
void initGui(int speed);
void showServerStartDialog();
void showClientWaitDialog();
//refresh-Funktionen
void refreshSet();
void refreshCash();
@@ -19,6 +19,7 @@
***************************************************************************/
#include "waitforservertostartgamedialogimpl.h"
#include "session.h"
#include <net/socket_msg.h>
// #include "configfile.h"
waitForServerToStartGameDialogImpl::waitForServerToStartGameDialogImpl(QWidget *parent)
@@ -33,7 +34,10 @@ waitForServerToStartGameDialogImpl::waitForServerToStartGameDialogImpl(QWidget *
void waitForServerToStartGameDialogImpl::refresh(int actionID) {
QTimer::singleShot(1000, this, SLOT(accept()));
if (actionID == MSG_NET_GAME_CLIENT_START)
{
QTimer::singleShot(500, this, SLOT(accept()));
}
}
void waitForServerToStartGameDialogImpl::cancel() {