The checkbox "fill up with computer players" is now working (protocol has been changed to implement this). Lobby dialog is now also used after joining the game. Leaving game not possible yet.
This commit is contained in:
@@ -1,60 +1,62 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by FThauer FHammer *
|
||||
* f.thauer@web.de *
|
||||
* *
|
||||
* 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 "connecttoserverdialogimpl.h"
|
||||
// #include "configfile.h"
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
connectToServerDialogImpl::connectToServerDialogImpl(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by FThauer FHammer *
|
||||
* f.thauer@web.de *
|
||||
* *
|
||||
* 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 "connecttoserverdialogimpl.h"
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
connectToServerDialogImpl::connectToServerDialogImpl(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
void connectToServerDialogImpl::exec()
|
||||
{
|
||||
label_actionMessage->setText("");
|
||||
progressBar->setValue(0);
|
||||
progressBar->setValue(0);
|
||||
|
||||
QDialog::exec();
|
||||
}
|
||||
|
||||
void connectToServerDialogImpl::refresh(int actionID) {
|
||||
|
||||
switch (actionID) {
|
||||
|
||||
case MSG_SOCK_INIT_DONE: { label_actionMessage->setText("Resolving address..."); }
|
||||
break;
|
||||
case MSG_SOCK_RESOLVE_DONE: { label_actionMessage->setText("Connecting to server..."); }
|
||||
break;
|
||||
case MSG_SOCK_CONNECT_DONE: { label_actionMessage->setText("Starting session..."); }
|
||||
break;
|
||||
case MSG_SOCK_SESSION_DONE: { label_actionMessage->setText("Connection established!"); }
|
||||
break;
|
||||
|
||||
default: { label_actionMessage->setText("Please wait..."); }
|
||||
}
|
||||
|
||||
progressBar->setValue(actionID*(100/MSG_SOCK_LIMIT_CONNECT));
|
||||
|
||||
if (actionID == MSG_SOCK_LIMIT_CONNECT)
|
||||
QTimer::singleShot(1000, this, SLOT(accept()));
|
||||
}
|
||||
|
||||
|
||||
void connectToServerDialogImpl::refresh(int actionID) {
|
||||
|
||||
bool skip = false;
|
||||
switch (actionID) {
|
||||
|
||||
case MSG_SOCK_INIT_DONE: { label_actionMessage->setText(tr("Resolving address...")); }
|
||||
break;
|
||||
case MSG_SOCK_RESOLVE_DONE: { label_actionMessage->setText(tr("Connecting to server...")); }
|
||||
break;
|
||||
case MSG_SOCK_CONNECT_DONE: { label_actionMessage->setText(tr("Starting session...")); }
|
||||
break;
|
||||
case MSG_SOCK_SESSION_DONE: { label_actionMessage->setText(tr("Connection established!")); }
|
||||
break;
|
||||
default: skip = true;
|
||||
}
|
||||
|
||||
if (!skip)
|
||||
{
|
||||
progressBar->setValue(actionID*(100/MSG_SOCK_LIMIT_CONNECT));
|
||||
|
||||
if (actionID == MSG_SOCK_LIMIT_CONNECT)
|
||||
QTimer::singleShot(1000, this, SLOT(accept()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
|
||||
// Author: FThauer FHammer LMay <webmaster@pokerth.net>, (C) 2007
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "session.h"
|
||||
#include "configfile.h"
|
||||
#include "gamedata.h"
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
||||
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), isAdmin(false)
|
||||
@@ -22,6 +23,9 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
||||
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
|
||||
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
|
||||
connect( treeWidget_GameList, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( gameSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
|
||||
connect( pushButton_StartGame, SIGNAL( clicked() ), this, SLOT( startGame() ) );
|
||||
connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) );
|
||||
connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
|
||||
|
||||
clearDialog();
|
||||
}
|
||||
@@ -50,7 +54,7 @@ void gameLobbyDialogImpl::createGame()
|
||||
myCreateInternetGameDialog->exec();
|
||||
|
||||
if (myCreateInternetGameDialog->result() == QDialog::Accepted ) {
|
||||
|
||||
|
||||
GameData gameData;
|
||||
// Set Game Data
|
||||
gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value();
|
||||
@@ -59,12 +63,19 @@ void gameLobbyDialogImpl::createGame()
|
||||
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", myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData());
|
||||
|
||||
currentGameName = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) + QString("'s game");
|
||||
|
||||
accept();
|
||||
// Update dialog
|
||||
gameModeDialogUpdate();
|
||||
|
||||
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));
|
||||
|
||||
mySession->clientCreateGame(gameData, myConfig->readConfigString("MyName") + "'s game", myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,12 +84,19 @@ void gameLobbyDialogImpl::joinGame()
|
||||
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
|
||||
if (item)
|
||||
{
|
||||
QString gameName = item->text(0);
|
||||
|
||||
assert(mySession);
|
||||
mySession->clientJoinGame(gameName.toUtf8().constData(), "");
|
||||
mySession->clientJoinGame(item->data(0, Qt::UserRole).toUInt(), "");
|
||||
|
||||
accept();
|
||||
// Update dialog
|
||||
gameModeDialogUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::refresh(int actionID) {
|
||||
|
||||
if (actionID == MSG_NET_GAME_CLIENT_START)
|
||||
{
|
||||
QTimer::singleShot(500, this, SLOT(accept()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,13 +222,17 @@ void gameLobbyDialogImpl::clearDialog()
|
||||
label_TimeoutForPlayerAction->setText("");
|
||||
|
||||
treeWidget_GameList->clear();
|
||||
treeWidget_GameList->show();
|
||||
treeWidget_connectedPlayers->clear();
|
||||
|
||||
pushButton_JoinGame->setEnabled(false);
|
||||
pushButton_Leave->hide();
|
||||
pushButton_Kick->hide();
|
||||
pushButton_Kick->setEnabled(false);
|
||||
pushButton_StartGame->hide();
|
||||
checkBox_fillUpWithComputerOpponents->hide();
|
||||
pushButton_CreateGame->show();
|
||||
pushButton_JoinGame->show();
|
||||
pushButton_JoinGame->setEnabled(false);
|
||||
|
||||
treeWidget_GameList->setColumnWidth(0,250);
|
||||
treeWidget_GameList->setColumnWidth(1,75);
|
||||
@@ -221,13 +243,18 @@ void gameLobbyDialogImpl::clearDialog()
|
||||
|
||||
void gameLobbyDialogImpl::checkPlayerQuantity() {
|
||||
|
||||
// if (treeWidget->topLevelItemCount() >= 2 && isAdmin) {
|
||||
// pushButton_startGame->setEnabled(true);
|
||||
// }
|
||||
// else {
|
||||
// pushButton_startGame->setEnabled(false);
|
||||
// }
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, int rights) {
|
||||
@@ -284,3 +311,44 @@ void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) {
|
||||
checkPlayerQuantity();
|
||||
}
|
||||
|
||||
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() {
|
||||
assert(mySession);
|
||||
mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,12 @@ public slots:
|
||||
void updatePlayer(unsigned, QString);
|
||||
void removePlayer(unsigned, QString);
|
||||
|
||||
void playerSelected(QTreeWidgetItem*, QTreeWidgetItem*);
|
||||
void refresh(int actionID);
|
||||
void startGame();
|
||||
void kickPlayer();
|
||||
|
||||
void gameModeDialogUpdate();
|
||||
void clearDialog();
|
||||
|
||||
private:
|
||||
|
||||
@@ -647,6 +647,7 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
||||
|
||||
connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog, SLOT(refresh(int)));
|
||||
connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog, SLOT(refresh(int)));
|
||||
connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog, SLOT(refresh(int)));
|
||||
|
||||
connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(unsigned, QString, int)));
|
||||
connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(unsigned, QString, int)));
|
||||
@@ -845,9 +846,8 @@ void mainWindowImpl::callGameLobbyDialog() {
|
||||
|
||||
if (myGameLobbyDialog->result() == QDialog::Accepted)
|
||||
{
|
||||
if(myGameLobbyDialog->getCurrentGameName() != "")
|
||||
myStartNetworkGameDialog->setWindowTitle(myGameLobbyDialog->getCurrentGameName());
|
||||
showNetworkStartDialog();
|
||||
//some gui modifications
|
||||
networkGameModification();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by FThauer FHammer *
|
||||
* Copyright (C) 2006 by FThauer FHammer LMay *
|
||||
* f.thauer@web.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -46,7 +46,7 @@ void startNetworkGameDialogImpl::exec() {
|
||||
|
||||
void startNetworkGameDialogImpl::startGame() {
|
||||
assert(mySession);
|
||||
mySession->sendStartEvent();
|
||||
mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked());
|
||||
}
|
||||
|
||||
void startNetworkGameDialogImpl::cancel() {
|
||||
@@ -131,7 +131,7 @@ void startNetworkGameDialogImpl::kickPlayer() {
|
||||
}
|
||||
else {
|
||||
assert(mySession);
|
||||
mySession->kickPlayer(playerName.toUtf8().constData());
|
||||
mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt());
|
||||
}
|
||||
}
|
||||
pushButton_Kick->setEnabled(false);
|
||||
|
||||
@@ -33,7 +33,7 @@ class ConfigFile;
|
||||
class startNetworkGameDialogImpl: public QDialog, public Ui::startNetworkGameDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
startNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *config = 0);
|
||||
startNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *config = 0);
|
||||
|
||||
void setSession(Session *session);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user