Add command zone visibility and filtering to game lobby

This commit is contained in:
DawnFire42 2026-08-07 19:54:13 -04:00
parent 127d8a5f5a
commit 1ba839ca20
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
9 changed files with 35 additions and 3 deletions

View file

@ -219,6 +219,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
spectatorsCanTalkCheckBox->setChecked(gameInfo.spectators_can_chat());
spectatorsSeeEverythingCheckBox->setChecked(gameInfo.spectators_omniscient());
shareDecklistsOnLoadCheckBox->setChecked(gameInfo.share_decklists_on_load());
enableCommandZoneCheckBox->setChecked(gameInfo.enable_command_zone());
QSet<int> types;
for (int i = 0; i < gameInfo.game_types_size(); ++i) {

View file

@ -45,6 +45,9 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
hideOpenDecklistGames = new QCheckBox(tr("Hide games with forced open decklists"));
hideOpenDecklistGames->setChecked(filters.hideOpenDecklistGames);
hideCommandZoneGames = new QCheckBox(tr("Hide games with command zone enabled"));
hideCommandZoneGames->setChecked(filters.hideCommandZoneGames);
maxGameAgeComboBox = new QComboBox();
maxGameAgeComboBox->setEditable(false);
maxGameAgeComboBox->addItems(gameAgeMap.values());
@ -122,6 +125,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
restrictionsLayout->addWidget(hideIgnoredUserGames, 4, 0);
restrictionsLayout->addWidget(hideNotBuddyCreatedGames, 5, 0);
restrictionsLayout->addWidget(hideOpenDecklistGames, 6, 0);
restrictionsLayout->addWidget(hideCommandZoneGames, 7, 0);
auto *restrictionsGroupBox = new QGroupBox(tr("Restrictions"));
restrictionsGroupBox->setLayout(restrictionsLayout);
@ -192,6 +196,7 @@ GameFilterConfigs DlgFilterGames::getFilters() const
hidePasswordProtectedGames->isChecked(),
hideNotBuddyCreatedGames->isChecked(),
hideOpenDecklistGames->isChecked(),
hideCommandZoneGames->isChecked(),
gameNameFilterEdit->text(),
getCreatorNameFilters(),
getGameTypeFilter(),

View file

@ -34,6 +34,7 @@ private:
QCheckBox *hideIgnoredUserGames;
QCheckBox *hideNotBuddyCreatedGames;
QCheckBox *hideOpenDecklistGames;
QCheckBox *hideCommandZoneGames;
QLineEdit *gameNameFilterEdit;
QLineEdit *creatorNameFilterEdit;
QMap<int, QCheckBox *> gameTypeFilterCheckBoxes;

View file

@ -18,6 +18,7 @@ struct GameFilterConfigs
bool hidePasswordProtectedGames = false;
bool hideNotBuddyCreatedGames = false;
bool hideOpenDecklistGames = false;
bool hideCommandZoneGames = false;
QString gameNameFilter = "";
QStringList creatorNameFilters = {};
QSet<int> gameTypeFilter = {};

View file

@ -158,6 +158,9 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
if (gameentry.share_decklists_on_load()) {
result.append(tr("open decklists"));
}
if (gameentry.enable_command_zone()) {
result.append(tr("command zone"));
}
return result.join(", ");
}
case Qt::DecorationRole: {
@ -346,9 +349,9 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
setGameFilters({gameFilters.isHideBuddiesOnlyGames(), gameFilters.isHideIgnoredUserGames(),
gameFilters.isHideFullGames(), gameFilters.isHideGamesThatStarted(),
gameFilters.isHidePasswordProtectedGames(), gameFilters.isHideNotBuddyCreatedGames(),
gameFilters.isHideOpenDecklistGames(), gameFilters.getGameNameFilter(),
gameFilters.getCreatorNameFilters(), newGameTypeFilter, gameFilters.getMinPlayers(),
gameFilters.getMaxPlayers(), gameFilters.getMaxGameAge(),
gameFilters.isHideOpenDecklistGames(), gameFilters.isHideCommandZoneGames(),
gameFilters.getGameNameFilter(), gameFilters.getCreatorNameFilters(), newGameTypeFilter,
gameFilters.getMinPlayers(), gameFilters.getMaxPlayers(), gameFilters.getMaxGameAge(),
gameFilters.isShowOnlyIfSpectatorsCanWatch(), gameFilters.isShowSpectatorPasswordProtected(),
gameFilters.isShowOnlyIfSpectatorsCanChat(), gameFilters.isShowOnlyIfSpectatorsCanSeeHands()});
}
@ -363,6 +366,7 @@ void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameType
gameFilters.setHideIgnoredUserGames(filters.hideIgnoredUserGames);
gameFilters.setHideNotBuddyCreatedGames(filters.hideNotBuddyCreatedGames);
gameFilters.setHideOpenDecklistGames(filters.hideOpenDecklistGames);
gameFilters.setHideCommandZoneGames(filters.hideCommandZoneGames);
gameFilters.setGameNameFilter(filters.gameNameFilter);
gameFilters.setCreatorNameFilters(filters.creatorNameFilters);
@ -408,6 +412,9 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
if (filters.hideOpenDecklistGames && game.share_decklists_on_load()) {
return false;
}
if (filters.hideCommandZoneGames && game.enable_command_zone()) {
return false;
}
if (filters.hideIgnoredUserGames &&
userListProxy->isUserIgnored(QString::fromStdString(game.creator_info().name()))) {
return false;

View file

@ -855,6 +855,7 @@ void Server_Game::getInfo(ServerInfo_Game &result) const
result.set_spectators_can_chat(spectatorsCanTalk);
result.set_spectators_omniscient(spectatorsSeeEverything);
result.set_share_decklists_on_load(shareDecklistsOnLoad);
result.set_enable_command_zone(enableCommandZone);
result.set_spectators_count(getSpectatorCount());
result.set_start_time(startTime.toSecsSinceEpoch());
}

View file

@ -48,6 +48,9 @@ message ServerInfo_Game {
// decklists are sent to all players when loaded
optional bool share_decklists_on_load = 15;
// command zone is enabled for Commander format
optional bool enable_command_zone = 16;
// the current player count
optional uint32 player_count = 30;

View file

@ -94,6 +94,17 @@ bool GameFiltersSettings::isHideOpenDecklistGames() const
return previous == QVariant() ? false : previous.toBool();
}
void GameFiltersSettings::setHideCommandZoneGames(bool hide)
{
setValue(hide, "hide_command_zone_games");
}
bool GameFiltersSettings::isHideCommandZoneGames() const
{
QVariant previous = getValue("hide_command_zone_games");
return previous == QVariant() ? false : previous.toBool();
}
void GameFiltersSettings::setGameNameFilter(QString gameName)
{
setValue(gameName, "gameNameFilter");

View file

@ -23,6 +23,7 @@ public:
bool isHideIgnoredUserGames() const;
bool isHideNotBuddyCreatedGames() const;
bool isHideOpenDecklistGames() const;
bool isHideCommandZoneGames() const;
QString getGameNameFilter() const;
QStringList getCreatorNameFilters() const;
int getMinPlayers() const;
@ -37,6 +38,7 @@ public:
void setHideBuddiesOnlyGames(bool hide);
void setHideIgnoredUserGames(bool hide);
void setHideOpenDecklistGames(bool hide);
void setHideCommandZoneGames(bool hide);
void setHideFullGames(bool hide);
void setHideGamesThatStarted(bool hide);
void setHidePasswordProtectedGames(bool hide);