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
+119 -117
View File
@@ -1,117 +1,119 @@
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "serverguiwrapper.h"
#include <session.h>
using namespace std;
ServerGuiWrapper::ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb)
: myConfig(config), myClientcb(clientcb), myServercb(servercb)
{
}
ServerGuiWrapper::~ServerGuiWrapper()
{
}
void ServerGuiWrapper::initGui(int speed) {}
Session &ServerGuiWrapper::getSession()
{
assert(mySession.get());
return *mySession;
}
void ServerGuiWrapper::setSession(boost::shared_ptr<Session> session)
{
mySession = session;
}
void ServerGuiWrapper::refreshSet() const {}
void ServerGuiWrapper::refreshCash() const {}
void ServerGuiWrapper::refreshAction(int playerID, int playerAction) const {}
void ServerGuiWrapper::refreshChangePlayer() const {}
void ServerGuiWrapper::refreshAll() const {}
void ServerGuiWrapper::refreshPot() const {}
void ServerGuiWrapper::refreshGroupbox(int playerID, int status) const {}
void ServerGuiWrapper::refreshPlayerName() const {}
void ServerGuiWrapper::refreshButton() const {}
void ServerGuiWrapper::refreshGameLabels(GameState state) const {}
void ServerGuiWrapper::waitForGuiUpdateDone() const {}
void ServerGuiWrapper::dealHoleCards() {}
void ServerGuiWrapper::dealFlopCards() {}
void ServerGuiWrapper::dealTurnCard() {}
void ServerGuiWrapper::dealRiverCard() {}
void ServerGuiWrapper::nextPlayerAnimation() {}
void ServerGuiWrapper::preflopAnimation1() {}
void ServerGuiWrapper::preflopAnimation2() {}
void ServerGuiWrapper::flopAnimation1() {}
void ServerGuiWrapper::flopAnimation2() {}
void ServerGuiWrapper::turnAnimation1() {}
void ServerGuiWrapper::turnAnimation2() {}
void ServerGuiWrapper::riverAnimation1() {}
void ServerGuiWrapper::riverAnimation2() {}
void ServerGuiWrapper::postRiverAnimation1() {}
void ServerGuiWrapper::postRiverRunAnimation1() {}
void ServerGuiWrapper::flipHolecardsAllIn() {}
void ServerGuiWrapper::nextRoundCleanGui() {}
void ServerGuiWrapper::meInAction() {}
void ServerGuiWrapper::disableMyButtons() {}
void ServerGuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) {}
void ServerGuiWrapper::stopTimeoutAnimation(int playerId) {}
void ServerGuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) {}
void ServerGuiWrapper::logNewGameHandMsg(int gameID, int handID) {}
void ServerGuiWrapper::logPlayerWinsMsg(int playerID, int pot) {}
void ServerGuiWrapper::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) {}
void ServerGuiWrapper::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt, std::string showHas) {}
void ServerGuiWrapper::SignalNetClientConnect(int actionID) { if (myClientcb) myClientcb->SignalNetClientConnect(actionID); }
void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); }
void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); }
void ServerGuiWrapper::SignalNetClientPlayerJoined(const string &playerName) { if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerName); }
void ServerGuiWrapper::SignalNetClientPlayerLeft(const string &playerName) { if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerName); }
void ServerGuiWrapper::SignalNetClientGameStart(boost::shared_ptr<Game> game) { if (myClientcb) myClientcb->SignalNetClientGameStart(game); }
void ServerGuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientChatMsg(playerName, msg); }
void ServerGuiWrapper::SignalNetServerSuccess(int actionID) { if (myServercb) myServercb->SignalNetServerSuccess(actionID); }
void ServerGuiWrapper::SignalNetServerError(int errorID, int osErrorID) { if (myServercb) myServercb->SignalNetServerError(errorID, osErrorID); }
void ServerGuiWrapper::SignalNetServerPlayerJoined(const string &playerName) { if (myServercb) myServercb->SignalNetServerPlayerJoined(playerName); }
void ServerGuiWrapper::SignalNetServerPlayerLeft(const string &playerName) { if (myServercb) myServercb->SignalNetServerPlayerLeft(playerName); }
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "serverguiwrapper.h"
#include <session.h>
using namespace std;
ServerGuiWrapper::ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb)
: myConfig(config), myClientcb(clientcb), myServercb(servercb)
{
}
ServerGuiWrapper::~ServerGuiWrapper()
{
}
void ServerGuiWrapper::initGui(int speed) {}
Session &ServerGuiWrapper::getSession()
{
assert(mySession.get());
return *mySession;
}
void ServerGuiWrapper::setSession(boost::shared_ptr<Session> session)
{
mySession = session;
}
void ServerGuiWrapper::refreshSet() const {}
void ServerGuiWrapper::refreshCash() const {}
void ServerGuiWrapper::refreshAction(int playerID, int playerAction) const {}
void ServerGuiWrapper::refreshChangePlayer() const {}
void ServerGuiWrapper::refreshAll() const {}
void ServerGuiWrapper::refreshPot() const {}
void ServerGuiWrapper::refreshGroupbox(int playerID, int status) const {}
void ServerGuiWrapper::refreshPlayerName() const {}
void ServerGuiWrapper::refreshButton() const {}
void ServerGuiWrapper::refreshGameLabels(GameState state) const {}
void ServerGuiWrapper::waitForGuiUpdateDone() const {}
void ServerGuiWrapper::dealHoleCards() {}
void ServerGuiWrapper::dealFlopCards() {}
void ServerGuiWrapper::dealTurnCard() {}
void ServerGuiWrapper::dealRiverCard() {}
void ServerGuiWrapper::nextPlayerAnimation() {}
void ServerGuiWrapper::preflopAnimation1() {}
void ServerGuiWrapper::preflopAnimation2() {}
void ServerGuiWrapper::flopAnimation1() {}
void ServerGuiWrapper::flopAnimation2() {}
void ServerGuiWrapper::turnAnimation1() {}
void ServerGuiWrapper::turnAnimation2() {}
void ServerGuiWrapper::riverAnimation1() {}
void ServerGuiWrapper::riverAnimation2() {}
void ServerGuiWrapper::postRiverAnimation1() {}
void ServerGuiWrapper::postRiverRunAnimation1() {}
void ServerGuiWrapper::flipHolecardsAllIn() {}
void ServerGuiWrapper::nextRoundCleanGui() {}
void ServerGuiWrapper::meInAction() {}
void ServerGuiWrapper::disableMyButtons() {}
void ServerGuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) {}
void ServerGuiWrapper::stopTimeoutAnimation(int playerId) {}
void ServerGuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) {}
void ServerGuiWrapper::logNewGameHandMsg(int gameID, int handID) {}
void ServerGuiWrapper::logPlayerWinsMsg(int playerID, int pot) {}
void ServerGuiWrapper::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) {}
void ServerGuiWrapper::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt, std::string showHas) {}
void ServerGuiWrapper::SignalNetClientConnect(int actionID) { if (myClientcb) myClientcb->SignalNetClientConnect(actionID); }
void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); }
void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); }
void ServerGuiWrapper::SignalNetClientPlayerJoined(const string &playerName) { if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerName); }
void ServerGuiWrapper::SignalNetClientPlayerLeft(const string &playerName) { if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerName); }
void ServerGuiWrapper::SignalNetClientGameStart(boost::shared_ptr<Game> game) { if (myClientcb) myClientcb->SignalNetClientGameStart(game); }
void ServerGuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientChatMsg(playerName, msg); }
void ServerGuiWrapper::SignalNetClientWaitDialog() { if (myClientcb) myClientcb->SignalNetClientWaitDialog(); }
void ServerGuiWrapper::SignalNetServerSuccess(int actionID) { if (myServercb) myServercb->SignalNetServerSuccess(actionID); }
void ServerGuiWrapper::SignalNetServerError(int errorID, int osErrorID) { if (myServercb) myServercb->SignalNetServerError(errorID, osErrorID); }
void ServerGuiWrapper::SignalNetServerPlayerJoined(const string &playerName) { if (myServercb) myServercb->SignalNetServerPlayerJoined(playerName); }
void ServerGuiWrapper::SignalNetServerPlayerLeft(const string &playerName) { if (myServercb) myServercb->SignalNetServerPlayerLeft(playerName); }
void ServerGuiWrapper::SignalNetServerStartDialog() { if (myServercb) myServercb->SignalNetServerStartDialog(); }
\
+2
View File
@@ -91,6 +91,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);
@@ -98,6 +99,7 @@ public:
void SignalNetServerError(int errorID, int osErrorID);
void SignalNetServerPlayerJoined(const std::string &playerName);
void SignalNetServerPlayerLeft(const std::string &playerName);
void SignalNetServerStartDialog();
private:
+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() {