parent
f2a887a6a4
commit
acb40bc738
2 changed files with 7 additions and 10 deletions
|
@ -98,7 +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->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(actSelectedGameChanged(const QModelIndex &, const QModelIndex &)));
|
||||||
connect(gameListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(actJoin()));
|
connect(gameListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(actJoin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,6 @@ void GameSelector::checkResponse(const Response &response)
|
||||||
createButton->setEnabled(true);
|
createButton->setEnabled(true);
|
||||||
joinButton->setEnabled(true);
|
joinButton->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;
|
||||||
case Response::RespWrongPassword: QMessageBox::critical(this, tr("Error"), tr("Wrong password.")); break;
|
case Response::RespWrongPassword: QMessageBox::critical(this, tr("Error"), tr("Wrong password.")); break;
|
||||||
|
@ -217,16 +216,14 @@ void GameSelector::processGameInfo(const ServerInfo_Game &info)
|
||||||
gameListModel->updateGameList(info);
|
gameListModel->updateGameList(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSelector::updateButtonChoices(const QModelIndex &index)
|
void GameSelector::actSelectedGameChanged(const QModelIndex ¤t, const QModelIndex & /* previous */)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!current.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const ServerInfo_Game &game = gameListModel->getGame(index.data(Qt::UserRole).toInt());
|
const ServerInfo_Game &game = gameListModel->getGame(current.data(Qt::UserRole).toInt());
|
||||||
bool overrideRestrictions = !tabSupervisor->getAdminLocked();
|
bool overrideRestrictions = !tabSupervisor->getAdminLocked();
|
||||||
|
|
||||||
if (game.spectators_allowed() || overrideRestrictions)
|
spectateButton->setEnabled(game.spectators_allowed() || overrideRestrictions);
|
||||||
spectateButton->setEnabled(true);
|
joinButton->setEnabled( game.player_count() < game.max_players() || overrideRestrictions);
|
||||||
else
|
|
||||||
spectateButton->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ private slots:
|
||||||
void actClearFilter();
|
void actClearFilter();
|
||||||
void actCreate();
|
void actCreate();
|
||||||
void actJoin();
|
void actJoin();
|
||||||
|
void actSelectedGameChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
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