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:
1 parent
697f063eb1
commit
839a4f7112
21 files changed
+237
-31
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user