Major redesign: The game can not be left without disconnecting from the server. This happens if a player is kicked, if he wishes to leave, or for other reasons. Error packets from the server will always cause a disconnect, however.

If joining a game fails, there is a proper failure packet now.
This commit is contained in:
lotodore
2007-09-06 19:09:05 +00:00
parent 040aadda3c
commit 9d0edc5eee
24 changed files with 694 additions and 140 deletions
@@ -25,6 +25,7 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
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( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) );
connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
clearDialog();
@@ -66,9 +67,6 @@ void gameLobbyDialogImpl::createGame()
currentGameName = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) + QString("'s game");
// Update dialog
gameModeDialogUpdate();
label_SmallBlind->setText(QString::number(gameData.smallBlind));
label_StartCash->setText(QString::number(gameData.startMoney));
label_MaximumNumberOfPlayers->setText(QString::number(gameData.maxNumberOfPlayers));
@@ -86,9 +84,6 @@ void gameLobbyDialogImpl::joinGame()
{
assert(mySession);
mySession->clientJoinGame(item->data(0, Qt::UserRole).toUInt(), "");
// Update dialog
gameModeDialogUpdate();
}
}
@@ -100,6 +95,11 @@ void gameLobbyDialogImpl::refresh(int actionID) {
}
}
void gameLobbyDialogImpl::removedFromGame(int reason)
{
clearDialog();
}
void gameLobbyDialogImpl::gameSelected(QTreeWidgetItem* item, QTreeWidgetItem*)
{
if (item)
@@ -259,6 +259,9 @@ void gameLobbyDialogImpl::checkPlayerQuantity() {
void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, int rights) {
// Update dialog
gameModeDialogUpdate();
isAdmin = rights == PLAYER_RIGHTS_ADMIN;
addConnectedPlayer(playerId, playerName, rights);
}
@@ -329,10 +332,17 @@ void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*
}
void gameLobbyDialogImpl::startGame() {
assert(mySession);
mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked());
}
void gameLobbyDialogImpl::leaveGame() {
assert(mySession);
mySession->sendLeaveCurrentGame();
}
void gameLobbyDialogImpl::kickPlayer() {
QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem();