disable join if spec disabled (#2605)
This commit is contained in:
parent
dd36187864
commit
e2e9c5ab96
2 changed files with 20 additions and 1 deletions
|
@ -98,6 +98,7 @@ GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSup
|
||||||
|
|
||||||
connect(joinButton, SIGNAL(clicked()), this, SLOT(actJoin()));
|
connect(joinButton, SIGNAL(clicked()), this, SLOT(actJoin()));
|
||||||
connect(spectateButton, SIGNAL(clicked()), this, SLOT(actJoin()));
|
connect(spectateButton, SIGNAL(clicked()), this, SLOT(actJoin()));
|
||||||
|
connect(gameListView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(updateButtonChoices(const QModelIndex &)));
|
||||||
connect(gameListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(actJoin()));
|
connect(gameListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(actJoin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ void GameSelector::checkResponse(const Response &response)
|
||||||
if (createButton)
|
if (createButton)
|
||||||
createButton->setEnabled(true);
|
createButton->setEnabled(true);
|
||||||
joinButton->setEnabled(true);
|
joinButton->setEnabled(true);
|
||||||
spectateButton->setEnabled(true);
|
|
||||||
|
|
||||||
switch (response.response_code()) {
|
switch (response.response_code()) {
|
||||||
case Response::RespNotInRoom: QMessageBox::critical(this, tr("Error"), tr("Please join the appropriate room first.")); break;
|
case Response::RespNotInRoom: QMessageBox::critical(this, tr("Error"), tr("Please join the appropriate room first.")); break;
|
||||||
|
@ -157,6 +158,9 @@ void GameSelector::checkResponse(const Response &response)
|
||||||
case Response::RespInIgnoreList: QMessageBox::critical(this, tr("Error"), tr("You are being ignored by the creator of this game.")); break;
|
case Response::RespInIgnoreList: QMessageBox::critical(this, tr("Error"), tr("You are being ignored by the creator of this game.")); break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (response.response_code() != Response::RespSpectatorsNotAllowed)
|
||||||
|
spectateButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSelector::actJoin()
|
void GameSelector::actJoin()
|
||||||
|
@ -212,3 +216,17 @@ void GameSelector::processGameInfo(const ServerInfo_Game &info)
|
||||||
{
|
{
|
||||||
gameListModel->updateGameList(info);
|
gameListModel->updateGameList(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameSelector::updateButtonChoices(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const ServerInfo_Game &game = gameListModel->getGame(index.data(Qt::UserRole).toInt());
|
||||||
|
bool overrideRestrictions = !tabSupervisor->getAdminLocked();
|
||||||
|
|
||||||
|
if (game.spectators_allowed() || overrideRestrictions)
|
||||||
|
spectateButton->setEnabled(true);
|
||||||
|
else
|
||||||
|
spectateButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ private slots:
|
||||||
void actCreate();
|
void actCreate();
|
||||||
void actJoin();
|
void actJoin();
|
||||||
void checkResponse(const Response &response);
|
void checkResponse(const Response &response);
|
||||||
|
void updateButtonChoices(const QModelIndex &);
|
||||||
signals:
|
signals:
|
||||||
void gameJoined(int gameId);
|
void gameJoined(int gameId);
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue