Game list in Lobby is now shown and updated even after joining or creating a game. Game updates will be sent by the server at all times (even during the game).
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
||||
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), isAdmin(false), myChat(NULL)
|
||||
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), isAdmin(false), inGame(false), myChat(NULL)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -50,7 +50,6 @@ void gameLobbyDialogImpl::exec()
|
||||
mySession->startIrcClient();
|
||||
QDialog::exec();
|
||||
mySession->terminateIrcClient();
|
||||
clearDialog();
|
||||
}
|
||||
|
||||
|
||||
@@ -162,12 +161,14 @@ void gameLobbyDialogImpl::refresh(int actionID) {
|
||||
|
||||
void gameLobbyDialogImpl::removedFromGame(int reason)
|
||||
{
|
||||
clearDialog();
|
||||
inGame = false;
|
||||
isAdmin = false;
|
||||
leftGameDialogUpdate();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::gameSelected(QTreeWidgetItem* item, QTreeWidgetItem*)
|
||||
{
|
||||
if (item)
|
||||
if (!inGame && item)
|
||||
{
|
||||
pushButton_JoinGame->setEnabled(true);
|
||||
|
||||
@@ -234,12 +235,15 @@ void gameLobbyDialogImpl::removeGame(unsigned gameId)
|
||||
|
||||
void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
|
||||
if (item && item->data(0, Qt::UserRole) == gameId)
|
||||
if (!inGame)
|
||||
{
|
||||
assert(mySession);
|
||||
PlayerInfo info(mySession->getClientPlayerInfo(playerId));
|
||||
addConnectedPlayer(playerId, QString::fromUtf8(info.playerName.c_str()), PLAYER_RIGHTS_NORMAL);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItemIterator it(treeWidget_GameList);
|
||||
@@ -255,12 +259,15 @@ void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
|
||||
|
||||
void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
|
||||
if (item && item->data(0, Qt::UserRole) == gameId)
|
||||
if (!inGame)
|
||||
{
|
||||
assert(mySession);
|
||||
PlayerInfo info(mySession->getClientPlayerInfo(playerId));
|
||||
removePlayer(playerId, QString::fromUtf8(info.playerName.c_str()));
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItemIterator it(treeWidget_GameList);
|
||||
@@ -307,6 +314,8 @@ void gameLobbyDialogImpl::clearDialog()
|
||||
pushButton_CreateGame->clearFocus();
|
||||
lineEdit_ChatInput->setFocus();
|
||||
myChat->clearChat();
|
||||
inGame = false;
|
||||
isAdmin = false;
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::checkPlayerQuantity() {
|
||||
@@ -328,7 +337,8 @@ void gameLobbyDialogImpl::checkPlayerQuantity() {
|
||||
void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, int rights) {
|
||||
|
||||
// Update dialog
|
||||
gameModeDialogUpdate();
|
||||
inGame = true;
|
||||
joinedGameDialogUpdate();
|
||||
|
||||
isAdmin = rights == PLAYER_RIGHTS_ADMIN;
|
||||
addConnectedPlayer(playerId, playerName, rights);
|
||||
@@ -382,17 +392,43 @@ void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) {
|
||||
checkPlayerQuantity();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::gameModeDialogUpdate() {
|
||||
void gameLobbyDialogImpl::joinedGameDialogUpdate() {
|
||||
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::leftGameDialogUpdate() {
|
||||
|
||||
// un-select current game.
|
||||
treeWidget_GameList->clearSelection();
|
||||
|
||||
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("");
|
||||
|
||||
treeWidget_connectedPlayers->clear();
|
||||
pushButton_StartGame->hide();
|
||||
pushButton_Leave->hide();
|
||||
pushButton_Kick->hide();
|
||||
pushButton_Kick->setEnabled(false);
|
||||
checkBox_fillUpWithComputerOpponents->hide();
|
||||
pushButton_CreateGame->show();
|
||||
pushButton_JoinGame->show();
|
||||
pushButton_JoinGame->setEnabled(false);
|
||||
|
||||
lineEdit_ChatInput->setFocus();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) {
|
||||
|
||||
if (item)
|
||||
|
||||
@@ -82,7 +82,8 @@ public slots:
|
||||
void leaveGame();
|
||||
void kickPlayer();
|
||||
|
||||
void gameModeDialogUpdate();
|
||||
void joinedGameDialogUpdate();
|
||||
void leftGameDialogUpdate();
|
||||
void clearDialog();
|
||||
|
||||
void sendChatMessage();
|
||||
@@ -98,6 +99,7 @@ private:
|
||||
createInternetGameDialogImpl *myCreateInternetGameDialog;
|
||||
QString currentGameName;
|
||||
bool isAdmin;
|
||||
bool inGame;
|
||||
LobbyChat *myChat;
|
||||
|
||||
};
|
||||
|
||||
@@ -59,7 +59,6 @@ void LobbyChat::selfJoined(QString ownName, QString channel)
|
||||
myNick = ownName;
|
||||
myLobby->textBrowser_ChatDisplay->append(tr("Joined channel:") + " " + channel + " " + tr("as user") + " " + ownName + ".");
|
||||
myLobby->textBrowser_ChatDisplay->append("");
|
||||
playerJoined(ownName);
|
||||
myLobby->lineEdit_ChatInput->setEnabled(true);
|
||||
myLobby->lineEdit_ChatInput->setFocus();
|
||||
}
|
||||
|
||||
@@ -884,6 +884,9 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
|
||||
myGameLobbyDialog->setSession(&getSession());
|
||||
myStartNetworkGameDialog->setSession(&getSession());
|
||||
|
||||
// Clear network game dialog.
|
||||
myStartNetworkGameDialog->clearDialog();
|
||||
|
||||
myServerGuiInterface->getSession().startNetworkServer();
|
||||
mySession->startNetworkClientForLocalServer(gameData);
|
||||
|
||||
@@ -908,6 +911,8 @@ void mainWindowImpl::callJoinNetworkGameDialog() {
|
||||
|
||||
myGameLobbyDialog->setSession(&getSession());
|
||||
myStartNetworkGameDialog->setSession(&getSession());
|
||||
// Clear network game dialog
|
||||
myStartNetworkGameDialog->clearDialog();
|
||||
// Maybe use QUrl::toPunycode.
|
||||
mySession->startNetworkClient(
|
||||
myJoinNetworkGameDialog->lineEdit_ipAddress->text().toUtf8().constData(),
|
||||
@@ -957,7 +962,9 @@ void mainWindowImpl::joinGameLobby() {
|
||||
myServerGuiInterface->getSession().terminateNetworkServer();
|
||||
myGameLobbyDialog->setSession(&getSession());
|
||||
myStartNetworkGameDialog->setSession(&getSession());
|
||||
|
||||
|
||||
// Clear Lobby dialog.
|
||||
myGameLobbyDialog->clearDialog();
|
||||
// Start client for dedicated server.
|
||||
mySession->startInternetClient();
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ void startNetworkGameDialogImpl::exec() {
|
||||
label_maxPlayerNumber->setText(QString::number(info.data.maxNumberOfPlayers));
|
||||
|
||||
QDialog::exec();
|
||||
clearDialog();
|
||||
}
|
||||
|
||||
void startNetworkGameDialogImpl::startGame() {
|
||||
|
||||
Reference in New Issue
Block a user