2007-08-20 21:23:03 +00:00
|
|
|
//
|
|
|
|
|
// C++ Implementation: gamelobbydialogimpl
|
|
|
|
|
//
|
|
|
|
|
// Description:
|
|
|
|
|
//
|
|
|
|
|
//
|
2007-09-05 19:14:34 +00:00
|
|
|
// Author: FThauer FHammer LMay <webmaster@pokerth.net>, (C) 2007
|
2007-08-20 21:23:03 +00:00
|
|
|
//
|
|
|
|
|
// Copyright: See COPYING file that comes with this distribution
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
#include "gamelobbydialogimpl.h"
|
2007-09-07 20:26:13 +00:00
|
|
|
#include "lobbychat.h"
|
2007-08-21 12:34:33 +00:00
|
|
|
#include "session.h"
|
|
|
|
|
#include "configfile.h"
|
|
|
|
|
#include "gamedata.h"
|
2007-09-05 19:14:34 +00:00
|
|
|
#include <net/socket_msg.h>
|
2007-08-20 21:23:03 +00:00
|
|
|
|
|
|
|
|
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
2007-09-07 20:26:13 +00:00
|
|
|
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), isAdmin(false), myChat(NULL)
|
2007-08-20 21:23:03 +00:00
|
|
|
{
|
|
|
|
|
setupUi(this);
|
|
|
|
|
|
2007-09-07 20:26:13 +00:00
|
|
|
myChat = new LobbyChat(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-09-02 16:36:52 +00:00
|
|
|
connect( treeWidget_GameList, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( gameSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
|
2007-09-05 19:14:34 +00:00
|
|
|
connect( pushButton_StartGame, SIGNAL( clicked() ), this, SLOT( startGame() ) );
|
|
|
|
|
connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) );
|
2007-09-06 19:09:05 +00:00
|
|
|
connect( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) );
|
2007-09-05 19:14:34 +00:00
|
|
|
connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
|
2007-09-07 08:58:36 +00:00
|
|
|
connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) );
|
2007-09-07 20:26:13 +00:00
|
|
|
connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), this, SLOT( checkChatInputLength(QString) ) );
|
|
|
|
|
|
2007-09-04 17:38:13 +00:00
|
|
|
clearDialog();
|
2007-08-20 21:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::exec()
|
|
|
|
|
{
|
|
|
|
|
QDialog::exec();
|
2007-09-04 17:38:13 +00:00
|
|
|
clearDialog();
|
2007-08-20 21:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameLobbyDialogImpl::~gameLobbyDialogImpl()
|
|
|
|
|
{
|
2007-09-07 20:26:13 +00:00
|
|
|
delete myChat;
|
|
|
|
|
myChat = NULL;
|
|
|
|
|
|
2007-08-20 21:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
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 ) {
|
2007-09-05 19:14:34 +00:00
|
|
|
|
2007-08-21 23:31:09 +00:00
|
|
|
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();
|
2007-08-21 12:34:33 +00:00
|
|
|
|
2007-09-07 08:58:36 +00:00
|
|
|
QString gameString(tr("game"));
|
|
|
|
|
currentGameName = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) + QString("'s "+ gameString);
|
2007-08-22 20:03:19 +00:00
|
|
|
|
2007-09-05 19:14:34 +00:00
|
|
|
label_SmallBlind->setText(QString::number(gameData.smallBlind));
|
|
|
|
|
label_StartCash->setText(QString::number(gameData.startMoney));
|
|
|
|
|
label_MaximumNumberOfPlayers->setText(QString::number(gameData.maxNumberOfPlayers));
|
|
|
|
|
label_HandsToRaiseSmallBlind->setText(QString::number(gameData.handsBeforeRaise));
|
|
|
|
|
label_TimeoutForPlayerAction->setText(QString::number(gameData.playerActionTimeoutSec));
|
|
|
|
|
|
2007-09-07 08:58:36 +00:00
|
|
|
mySession->clientCreateGame(gameData, myConfig->readConfigString("MyName") + "'s "+ gameString.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData());
|
2007-08-21 23:31:09 +00:00
|
|
|
}
|
2007-08-21 12:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::joinGame()
|
|
|
|
|
{
|
2007-09-07 10:18:06 +00:00
|
|
|
assert(mySession);
|
2007-08-21 17:27:13 +00:00
|
|
|
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
|
|
|
|
|
if (item)
|
|
|
|
|
{
|
2007-09-07 10:18:06 +00:00
|
|
|
unsigned gameId = item->data(0, Qt::UserRole).toUInt();
|
|
|
|
|
GameInfo info(mySession->getClientGameInfo(gameId));
|
|
|
|
|
bool ok = true;
|
|
|
|
|
QString password;
|
2007-09-07 08:58:36 +00:00
|
|
|
//if private ask for password
|
2007-09-07 10:18:06 +00:00
|
|
|
if (info.isPasswordProtected) {
|
|
|
|
|
password = QInputDialog::getText(this, tr("Joining a private Game"),
|
|
|
|
|
tr("You are about to join a private game. Please enter the password!"), QLineEdit::Password, (""), &ok);
|
2007-09-07 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-07 10:18:06 +00:00
|
|
|
if (ok)
|
|
|
|
|
mySession->clientJoinGame(gameId, password.toUtf8().constData());
|
2007-09-05 19:14:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::refresh(int actionID) {
|
|
|
|
|
|
|
|
|
|
if (actionID == MSG_NET_GAME_CLIENT_START)
|
|
|
|
|
{
|
|
|
|
|
QTimer::singleShot(500, this, SLOT(accept()));
|
2007-08-21 17:27:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-06 19:09:05 +00:00
|
|
|
void gameLobbyDialogImpl::removedFromGame(int reason)
|
|
|
|
|
{
|
|
|
|
|
clearDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
void gameLobbyDialogImpl::gameSelected(QTreeWidgetItem* item, QTreeWidgetItem*)
|
2007-08-21 17:27:13 +00:00
|
|
|
{
|
2007-09-02 16:36:52 +00:00
|
|
|
if (item)
|
|
|
|
|
{
|
|
|
|
|
pushButton_JoinGame->setEnabled(true);
|
2007-08-22 20:03:19 +00:00
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
currentGameName = item->text(0);
|
2007-08-26 12:45:37 +00:00
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
groupBox_GameInfo->setEnabled(true);
|
|
|
|
|
groupBox_GameInfo->setTitle(tr("Game Info") + " - " + currentGameName);
|
2007-08-27 09:57:51 +00:00
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
assert(mySession);
|
|
|
|
|
GameInfo info(mySession->getClientGameInfo(item->data(0, Qt::UserRole).toUInt()));
|
|
|
|
|
label_SmallBlind->setText(QString::number(info.data.smallBlind));
|
|
|
|
|
label_StartCash->setText(QString::number(info.data.startMoney));
|
|
|
|
|
label_MaximumNumberOfPlayers->setText(QString::number(info.data.maxNumberOfPlayers));
|
|
|
|
|
label_HandsToRaiseSmallBlind->setText(QString::number(info.data.handsBeforeRaise));
|
|
|
|
|
label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec));
|
2007-08-21 12:34:33 +00:00
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
treeWidget_connectedPlayers->clear();
|
|
|
|
|
PlayerIdList::const_iterator i = info.players.begin();
|
|
|
|
|
PlayerIdList::const_iterator end = info.players.end();
|
|
|
|
|
while (i != end)
|
|
|
|
|
{
|
|
|
|
|
PlayerInfo info(mySession->getClientPlayerInfo(*i));
|
|
|
|
|
addConnectedPlayer(*i, QString::fromUtf8(info.playerName.c_str()), PLAYER_RIGHTS_NORMAL);
|
|
|
|
|
++i;
|
|
|
|
|
}
|
2007-08-21 12:34:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-08-20 21:23:03 +00:00
|
|
|
|
2007-09-04 12:44:11 +00:00
|
|
|
void gameLobbyDialogImpl::updateGameItem(QTreeWidgetItem *item, unsigned gameId)
|
2007-09-02 16:36:52 +00:00
|
|
|
{
|
2007-09-04 12:44:11 +00:00
|
|
|
assert(mySession);
|
|
|
|
|
GameInfo info(mySession->getClientGameInfo(gameId));
|
2007-09-02 16:36:52 +00:00
|
|
|
|
|
|
|
|
item->setData(0, Qt::UserRole, gameId);
|
2007-09-04 12:44:11 +00:00
|
|
|
item->setData(0, Qt::DisplayRole, QString::fromUtf8(info.name.c_str()));
|
|
|
|
|
|
|
|
|
|
QString playerStr;
|
|
|
|
|
playerStr.sprintf("%u/%u", info.players.size(), info.data.maxNumberOfPlayers);
|
|
|
|
|
item->setData(1, Qt::DisplayRole, playerStr);
|
|
|
|
|
|
|
|
|
|
if (info.isPasswordProtected)
|
|
|
|
|
item->setData(2, Qt::DisplayRole, "X");
|
2007-09-02 16:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-04 12:44:11 +00:00
|
|
|
void gameLobbyDialogImpl::addGame(unsigned gameId)
|
|
|
|
|
{
|
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_GameList, 0);
|
|
|
|
|
|
|
|
|
|
updateGameItem(item, gameId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::removeGame(unsigned gameId)
|
2007-09-02 16:36:52 +00:00
|
|
|
{
|
|
|
|
|
QTreeWidgetItemIterator it(treeWidget_GameList);
|
|
|
|
|
while (*it) {
|
|
|
|
|
if ((*it)->data(0, Qt::UserRole) == gameId)
|
|
|
|
|
{
|
|
|
|
|
treeWidget_GameList->takeTopLevelItem(treeWidget_GameList->indexOfTopLevelItem(*it));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++it;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
|
|
|
|
|
{
|
|
|
|
|
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
|
|
|
|
|
if (item && item->data(0, Qt::UserRole) == gameId)
|
|
|
|
|
{
|
|
|
|
|
assert(mySession);
|
|
|
|
|
PlayerInfo info(mySession->getClientPlayerInfo(playerId));
|
|
|
|
|
addConnectedPlayer(playerId, QString::fromUtf8(info.playerName.c_str()), PLAYER_RIGHTS_NORMAL);
|
|
|
|
|
}
|
2007-09-04 12:44:11 +00:00
|
|
|
|
|
|
|
|
QTreeWidgetItemIterator it(treeWidget_GameList);
|
|
|
|
|
while (*it) {
|
|
|
|
|
if ((*it)->data(0, Qt::UserRole) == gameId)
|
|
|
|
|
{
|
|
|
|
|
updateGameItem(*it, gameId);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++it;
|
|
|
|
|
}
|
2007-09-02 16:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
|
|
|
|
|
{
|
|
|
|
|
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
|
|
|
|
|
if (item && item->data(0, Qt::UserRole) == gameId)
|
|
|
|
|
{
|
|
|
|
|
assert(mySession);
|
|
|
|
|
PlayerInfo info(mySession->getClientPlayerInfo(playerId));
|
|
|
|
|
removePlayer(playerId, QString::fromUtf8(info.playerName.c_str()));
|
|
|
|
|
}
|
2007-09-04 12:44:11 +00:00
|
|
|
|
|
|
|
|
QTreeWidgetItemIterator it(treeWidget_GameList);
|
|
|
|
|
while (*it) {
|
|
|
|
|
if ((*it)->data(0, Qt::UserRole) == gameId)
|
|
|
|
|
{
|
|
|
|
|
updateGameItem(*it, gameId);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++it;
|
|
|
|
|
}
|
2007-09-02 16:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::clearDialog()
|
2007-08-27 09:57:51 +00:00
|
|
|
{
|
|
|
|
|
groupBox_GameInfo->setTitle(tr("Game Info"));
|
|
|
|
|
groupBox_GameInfo->setEnabled(false);
|
|
|
|
|
currentGameName = "";
|
|
|
|
|
|
|
|
|
|
label_SmallBlind->setText("");
|
|
|
|
|
label_StartCash->setText("");
|
|
|
|
|
label_MaximumNumberOfPlayers->setText("");
|
|
|
|
|
label_HandsToRaiseSmallBlind->setText("");
|
|
|
|
|
label_TimeoutForPlayerAction->setText("");
|
2007-09-02 16:36:52 +00:00
|
|
|
|
|
|
|
|
treeWidget_GameList->clear();
|
2007-09-05 19:14:34 +00:00
|
|
|
treeWidget_GameList->show();
|
2007-09-02 16:36:52 +00:00
|
|
|
treeWidget_connectedPlayers->clear();
|
|
|
|
|
|
|
|
|
|
pushButton_Leave->hide();
|
|
|
|
|
pushButton_Kick->hide();
|
2007-09-05 19:14:34 +00:00
|
|
|
pushButton_Kick->setEnabled(false);
|
2007-09-02 16:36:52 +00:00
|
|
|
pushButton_StartGame->hide();
|
2007-09-03 22:51:00 +00:00
|
|
|
checkBox_fillUpWithComputerOpponents->hide();
|
2007-09-05 19:14:34 +00:00
|
|
|
pushButton_CreateGame->show();
|
|
|
|
|
pushButton_JoinGame->show();
|
|
|
|
|
pushButton_JoinGame->setEnabled(false);
|
2007-09-02 16:36:52 +00:00
|
|
|
|
|
|
|
|
treeWidget_GameList->setColumnWidth(0,250);
|
|
|
|
|
treeWidget_GameList->setColumnWidth(1,75);
|
|
|
|
|
treeWidget_GameList->setColumnWidth(2,70);
|
|
|
|
|
|
2007-09-07 20:26:13 +00:00
|
|
|
pushButton_CreateGame->clearFocus();
|
2007-09-02 16:36:52 +00:00
|
|
|
lineEdit_ChatInput->setFocus();
|
2007-08-27 09:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-29 22:30:18 +00:00
|
|
|
void gameLobbyDialogImpl::checkPlayerQuantity() {
|
|
|
|
|
|
2007-09-05 19:14:34 +00:00
|
|
|
if(isAdmin){
|
|
|
|
|
pushButton_Kick->show();
|
|
|
|
|
pushButton_StartGame->show();
|
|
|
|
|
checkBox_fillUpWithComputerOpponents->show();
|
|
|
|
|
|
|
|
|
|
if (treeWidget_connectedPlayers->topLevelItemCount() >= 2) {
|
|
|
|
|
pushButton_StartGame->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pushButton_StartGame->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-08-29 22:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, int rights) {
|
2007-08-29 22:30:18 +00:00
|
|
|
|
2007-09-06 19:09:05 +00:00
|
|
|
// Update dialog
|
|
|
|
|
gameModeDialogUpdate();
|
|
|
|
|
|
2007-08-29 22:30:18 +00:00
|
|
|
isAdmin = rights == PLAYER_RIGHTS_ADMIN;
|
2007-09-02 16:36:52 +00:00
|
|
|
addConnectedPlayer(playerId, playerName, rights);
|
2007-08-29 22:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, int rights) {
|
2007-08-29 22:30:18 +00:00
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers, 0);
|
|
|
|
|
item->setData(0, Qt::UserRole, playerId);
|
|
|
|
|
item->setData(0, Qt::DisplayRole, playerName);
|
2007-08-29 22:30:18 +00:00
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
/* assert(mySession);
|
2007-08-29 22:30:18 +00:00
|
|
|
GameInfo info = mySession->getClientGameInfo(currentGameName.toUtf8().constData());
|
|
|
|
|
|
|
|
|
|
if(treeWidget_connectedPlayers->topLevelItemCount() != info.data.maxNumberOfPlayers) {
|
|
|
|
|
myW->getMySDLPlayer()->playSound("playerconnected", 0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
myW->getMySDLPlayer()->playSound("onlinegameready", 0);
|
2007-09-02 16:36:52 +00:00
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
checkPlayerQuantity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) {
|
|
|
|
|
|
|
|
|
|
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
|
|
|
|
|
while (*it) {
|
|
|
|
|
if ((*it)->data(0, Qt::UserRole) == playerId)
|
|
|
|
|
{
|
|
|
|
|
(*it)->setData(0, Qt::DisplayRole, newPlayerName);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++it;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) {
|
|
|
|
|
|
|
|
|
|
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
|
|
|
|
|
while (*it) {
|
|
|
|
|
if ((*it)->data(0, Qt::UserRole) == playerId)
|
|
|
|
|
{
|
|
|
|
|
treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++it;
|
2007-08-29 22:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkPlayerQuantity();
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 19:14:34 +00:00
|
|
|
void gameLobbyDialogImpl::gameModeDialogUpdate() {
|
|
|
|
|
groupBox_GameInfo->setEnabled(true);
|
|
|
|
|
groupBox_GameInfo->setTitle(currentGameName);
|
|
|
|
|
treeWidget_GameList->clear();
|
|
|
|
|
treeWidget_GameList->hide();
|
|
|
|
|
treeWidget_connectedPlayers->clear();
|
|
|
|
|
pushButton_CreateGame->hide();
|
|
|
|
|
pushButton_JoinGame->hide();
|
|
|
|
|
pushButton_Leave->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) {
|
|
|
|
|
|
|
|
|
|
if (item)
|
|
|
|
|
pushButton_Kick->setEnabled(isAdmin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::startGame() {
|
2007-09-06 19:09:05 +00:00
|
|
|
|
2007-09-05 19:14:34 +00:00
|
|
|
assert(mySession);
|
|
|
|
|
mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-06 19:09:05 +00:00
|
|
|
void gameLobbyDialogImpl::leaveGame() {
|
|
|
|
|
|
|
|
|
|
assert(mySession);
|
|
|
|
|
mySession->sendLeaveCurrentGame();
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 19:14:34 +00:00
|
|
|
void gameLobbyDialogImpl::kickPlayer() {
|
|
|
|
|
|
|
|
|
|
QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem();
|
|
|
|
|
if (item)
|
|
|
|
|
{
|
|
|
|
|
QString playerName = item->text(0);
|
|
|
|
|
if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) {
|
|
|
|
|
{ QMessageBox::warning(this, tr("Server Error"),
|
|
|
|
|
tr("You should not kick yourself from this game!"),
|
|
|
|
|
QMessageBox::Close); }
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
assert(mySession);
|
|
|
|
|
mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pushButton_Kick->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-07 20:26:13 +00:00
|
|
|
void gameLobbyDialogImpl::sendChatMessage() { myChat->sendMessage(); }
|
|
|
|
|
void gameLobbyDialogImpl::checkChatInputLength(QString string) { myChat->checkInputLength(string); }
|
|
|
|
|
|
|
|
|
|
void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) {
|
|
|
|
|
|
|
|
|
|
if (event->key() == Qt::Key_Enter) {}
|
|
|
|
|
}
|