More steps towards supporting multiple games per server. Player rights still broken, so starting the game is not possible. Games are not yet terminated after all players have left.
This commit is contained in:
@@ -111,6 +111,8 @@ void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (my
|
||||
void ServerGuiWrapper::SignalNetClientSelfJoined(const string &playerName, PlayerRights rights) { if (myClientcb) myClientcb->SignalNetClientSelfJoined(playerName, rights); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerJoined(const string &playerName, PlayerRights rights) { if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerName, rights); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerLeft(const string &playerName) { if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerName); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListNew(const string &gameName) { if (myClientcb) myClientcb->SignalNetClientGameListNew(gameName); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListRemove(const string &gameName) { if (myClientcb) myClientcb->SignalNetClientGameListRemove(gameName); }
|
||||
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(); }
|
||||
|
||||
@@ -98,6 +98,8 @@ public:
|
||||
void SignalNetClientChatMsg(const std::string &playerName, const std::string &msg);
|
||||
void SignalNetClientWaitDialog();
|
||||
|
||||
void SignalNetClientGameListNew(const std::string &gameName);
|
||||
void SignalNetClientGameListRemove(const std::string &gameName);
|
||||
void SignalNetClientGameStart(boost::shared_ptr<Game> game);
|
||||
|
||||
void SignalNetServerSuccess(int actionID);
|
||||
|
||||
@@ -10,12 +10,17 @@
|
||||
//
|
||||
//
|
||||
#include "gamelobbydialogimpl.h"
|
||||
#include "session.h"
|
||||
#include "configfile.h"
|
||||
#include "gamedata.h"
|
||||
|
||||
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
||||
: QDialog(parent), myConfig(c)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
|
||||
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::exec()
|
||||
@@ -29,4 +34,50 @@ gameLobbyDialogImpl::~gameLobbyDialogImpl()
|
||||
{
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::setSession(Session *session)
|
||||
{
|
||||
mySession = session;
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::createGame()
|
||||
{
|
||||
assert(mySession);
|
||||
|
||||
// TODO: don't use hardcoded values
|
||||
GameData gameData;
|
||||
// Set Game Data
|
||||
gameData.maxNumberOfPlayers = myConfig->readConfigInt("NumberOfPlayers");
|
||||
gameData.startMoney = myConfig->readConfigInt("StartCash");
|
||||
gameData.smallBlind = myConfig->readConfigInt("SmallBlind");
|
||||
gameData.handsBeforeRaise = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind");
|
||||
//Speeds
|
||||
gameData.guiSpeed = myConfig->readConfigInt("GameSpeed");
|
||||
|
||||
mySession->clientCreateGame(gameData, "default", "");
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::joinGame()
|
||||
{
|
||||
assert(mySession);
|
||||
|
||||
mySession->clientJoinGame("default", "");
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::addGame(QString gameName)
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_GameList,0);
|
||||
item->setData(0, 0, gameName);
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::removeGame(QString gameName)
|
||||
{
|
||||
QList<QTreeWidgetItem *> list = treeWidget_GameList->findItems(gameName, Qt::MatchExactly, 0);
|
||||
if(!list.empty()) {
|
||||
treeWidget_GameList->takeTopLevelItem(treeWidget_GameList->indexOfTopLevelItem(list[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,29 +13,39 @@
|
||||
#define GAMELOBBYDIALOGIMPL_H
|
||||
|
||||
#include <ui_gamelobbydialog.h>
|
||||
#include "configfile.h"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtCore>
|
||||
|
||||
class Session;
|
||||
class ConfigFile;
|
||||
|
||||
/**
|
||||
@author FThauer FHammer <webmaster@pokerth.net>
|
||||
*/
|
||||
class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
gameLobbyDialogImpl(QWidget *parent = 0, ConfigFile* = 0);
|
||||
gameLobbyDialogImpl(QWidget *parent = 0, ConfigFile* = 0);
|
||||
|
||||
~gameLobbyDialogImpl();
|
||||
|
||||
~gameLobbyDialogImpl();
|
||||
|
||||
void exec();
|
||||
|
||||
void setSession(Session *session);
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
|
||||
ConfigFile *myConfig;
|
||||
void createGame();
|
||||
void joinGame();
|
||||
|
||||
void addGame(QString gameName);
|
||||
void removeGame(QString gameName);
|
||||
|
||||
private:
|
||||
|
||||
ConfigFile *myConfig;
|
||||
Session *mySession;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -119,6 +119,10 @@ void GuiWrapper::SignalNetClientPlayerLeft(const string &playerName)
|
||||
myW->signalNetClientPlayerLeft(tmpName);
|
||||
myLog->signalLogPlayerLeftMsg(tmpName);
|
||||
}
|
||||
|
||||
void GuiWrapper::SignalNetClientGameListNew(const string &gameName) { myW->signalNetClientGameListNew(QString::fromUtf8(gameName.c_str())); }
|
||||
void GuiWrapper::SignalNetClientGameListRemove(const string &gameName) { myW->signalNetClientGameListRemove(QString::fromUtf8(gameName.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->signalShowNetworkStartDialog(); }
|
||||
|
||||
@@ -105,6 +105,9 @@ public:
|
||||
void SignalNetClientChatMsg(const std::string &playerName, const std::string &msg);
|
||||
void SignalNetClientWaitDialog();
|
||||
|
||||
void SignalNetClientGameListNew(const std::string &gameName);
|
||||
void SignalNetClientGameListRemove(const std::string &gameName);
|
||||
|
||||
void SignalNetClientGameStart(boost::shared_ptr<Game> game);
|
||||
|
||||
void SignalNetServerSuccess(int actionID);
|
||||
|
||||
@@ -652,6 +652,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
||||
connect(this, SIGNAL(signalNetClientSelfJoined(QString, int)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(QString, int)));
|
||||
connect(this, SIGNAL(signalNetClientPlayerJoined(QString, int)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(QString, int)));
|
||||
connect(this, SIGNAL(signalNetClientPlayerLeft(QString)), myStartNetworkGameDialog, SLOT(removePlayer(QString)));
|
||||
connect(this, SIGNAL(signalNetClientGameListNew(QString)), myGameLobbyDialog, SLOT(addGame(QString)));
|
||||
connect(this, SIGNAL(signalNetClientGameListRemove(QString)), myGameLobbyDialog, SLOT(removeGame(QString)));
|
||||
|
||||
// Errors are handled globally, not within one dialog.
|
||||
connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int)));
|
||||
@@ -808,7 +810,22 @@ void mainWindowImpl::callJoinNetworkGameDialog() {
|
||||
|
||||
void mainWindowImpl::callGameLobbyDialog() {
|
||||
|
||||
mySession->terminateNetworkClient();
|
||||
if (myServerGuiInterface.get())
|
||||
myServerGuiInterface->getSession().terminateNetworkServer();
|
||||
|
||||
myGameLobbyDialog->setSession(&getSession());
|
||||
myGameLobbyDialog->treeWidget_GameList->clear();
|
||||
|
||||
// Just for testing
|
||||
mySession->startNetworkClientForLocalServer();
|
||||
|
||||
myGameLobbyDialog->exec();
|
||||
|
||||
if (myGameLobbyDialog->result() == QDialog::Accepted)
|
||||
{
|
||||
showNetworkStartDialog();
|
||||
}
|
||||
}
|
||||
|
||||
void mainWindowImpl::callSettingsDialog() {
|
||||
|
||||
@@ -129,6 +129,8 @@ signals:
|
||||
void signalNetClientSelfJoined(QString playerName, int rights);
|
||||
void signalNetClientPlayerJoined(QString playerName, int rights);
|
||||
void signalNetClientPlayerLeft(QString playerName);
|
||||
void signalNetClientGameListNew(QString gameName);
|
||||
void signalNetClientGameListRemove(QString gameName);
|
||||
void signalNetClientGameStart(boost::shared_ptr<Game> game);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
startNetworkGameDialogImpl::startNetworkGameDialogImpl(QWidget *parent, ConfigFile *config)
|
||||
: QDialog(parent), myConfig(config), isAdmin(false), myW(0)
|
||||
: QDialog(parent), myW(NULL), isAdmin(false), myConfig(config), mySession(NULL)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ Q_OBJECT
|
||||
public:
|
||||
startNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *config = 0);
|
||||
|
||||
void setSession(Session *session);
|
||||
|
||||
public slots:
|
||||
|
||||
void setMyW ( mainWindowImpl* theValue ) { myW = theValue; }
|
||||
@@ -50,8 +52,6 @@ public slots:
|
||||
void kickPlayer();
|
||||
void checkPlayerQuantity();
|
||||
|
||||
void setSession(Session *session);
|
||||
|
||||
void keyPressEvent ( QKeyEvent*);
|
||||
|
||||
void setMaxPlayerNumber ( int theValue ) { maxPlayerNumber = theValue; label_maxPlayerNumber->setText(QString::number(theValue,10)); }
|
||||
|
||||
Reference in New Issue
Block a user