2007-08-20 21:23:03 +00:00
|
|
|
//
|
|
|
|
|
// C++ Implementation: gamelobbydialogimpl
|
|
|
|
|
//
|
|
|
|
|
// Description:
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
|
|
|
|
|
//
|
|
|
|
|
// Copyright: See COPYING file that comes with this distribution
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
#include "gamelobbydialogimpl.h"
|
2007-08-21 12:34:33 +00:00
|
|
|
#include "session.h"
|
|
|
|
|
#include "configfile.h"
|
|
|
|
|
#include "gamedata.h"
|
2007-08-20 21:23:03 +00:00
|
|
|
|
|
|
|
|
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
2007-08-22 20:03:19 +00:00
|
|
|
: QDialog(parent), myConfig(c), currentGameName("")
|
2007-08-20 21:23:03 +00:00
|
|
|
{
|
|
|
|
|
setupUi(this);
|
|
|
|
|
|
2007-08-21 12:34:33 +00:00
|
|
|
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
|
|
|
|
|
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
|
2007-08-21 17:27:13 +00:00
|
|
|
connect( treeWidget_GameList, SIGNAL( itemClicked ( QTreeWidgetItem*, int) ), this, SLOT( gameSelected(QTreeWidgetItem*, int) ) );
|
|
|
|
|
|
|
|
|
|
pushButton_JoinGame->setEnabled(false);
|
2007-08-26 12:45:37 +00:00
|
|
|
|
|
|
|
|
pushButton_Leave->hide();
|
|
|
|
|
pushButton_Kick->hide();
|
|
|
|
|
pushButton_StartGame->hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
treeWidget_GameList->setColumnWidth(0,250);
|
|
|
|
|
treeWidget_GameList->setColumnWidth(1,75);
|
|
|
|
|
treeWidget_GameList->setColumnWidth(2,70);
|
|
|
|
|
|
2007-08-20 21:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::exec()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
QDialog::exec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameLobbyDialogImpl::~gameLobbyDialogImpl()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-21 12:34:33 +00:00
|
|
|
void gameLobbyDialogImpl::setSession(Session *session)
|
|
|
|
|
{
|
|
|
|
|
mySession = session;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::createGame()
|
|
|
|
|
{
|
|
|
|
|
assert(mySession);
|
|
|
|
|
|
2007-08-21 23:31:09 +00:00
|
|
|
myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig);
|
|
|
|
|
myCreateInternetGameDialog->exec();
|
|
|
|
|
|
|
|
|
|
if (myCreateInternetGameDialog->result() == QDialog::Accepted ) {
|
|
|
|
|
|
|
|
|
|
GameData gameData;
|
|
|
|
|
// Set Game Data
|
|
|
|
|
gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value();
|
|
|
|
|
gameData.startMoney = myCreateInternetGameDialog->spinBox_startCash->value();
|
|
|
|
|
gameData.smallBlind = myCreateInternetGameDialog->spinBox_smallBlind->value();
|
|
|
|
|
gameData.handsBeforeRaise = myCreateInternetGameDialog->spinBox_handsBeforeRaiseSmallBlind->value();
|
|
|
|
|
gameData.guiSpeed = myCreateInternetGameDialog->spinBox_gameSpeed->value();
|
|
|
|
|
gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value();
|
|
|
|
|
|
|
|
|
|
mySession->clientCreateGame(gameData, myConfig->readConfigString("MyName") + "'s game", "");
|
2007-08-21 12:34:33 +00:00
|
|
|
|
2007-08-22 20:03:19 +00:00
|
|
|
currentGameName = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) + QString("'s game");
|
|
|
|
|
|
2007-08-21 23:31:09 +00:00
|
|
|
accept();
|
|
|
|
|
}
|
2007-08-21 12:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::joinGame()
|
|
|
|
|
{
|
2007-08-21 17:27:13 +00:00
|
|
|
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
|
|
|
|
|
if (item)
|
|
|
|
|
{
|
|
|
|
|
QString gameName = item->text(0);
|
2007-08-21 12:34:33 +00:00
|
|
|
|
2007-08-21 17:27:13 +00:00
|
|
|
assert(mySession);
|
|
|
|
|
mySession->clientJoinGame(gameName.toUtf8().constData(), "");
|
2007-08-21 12:34:33 +00:00
|
|
|
|
2007-08-21 17:27:13 +00:00
|
|
|
accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 20:03:19 +00:00
|
|
|
void gameLobbyDialogImpl::gameSelected(QTreeWidgetItem* item, int)
|
2007-08-21 17:27:13 +00:00
|
|
|
{
|
|
|
|
|
pushButton_JoinGame->setEnabled(true);
|
2007-08-22 20:03:19 +00:00
|
|
|
|
|
|
|
|
currentGameName = item->text(0);
|
2007-08-26 12:45:37 +00:00
|
|
|
|
|
|
|
|
groupBox_GameInfo->setEnabled(TRUE);
|
|
|
|
|
groupBox_GameInfo->setTitle("Game Info - " + item->text(0));
|
2007-08-21 12:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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]));
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-08-20 21:23:03 +00:00
|
|
|
|