[GamesModel] Rename 'Creator' column to 'Host' (#7083)

* [GamesModel] Rename 'Creator' column to 'Host' (#2108)


Took 5 minutes

* Actually re-broadcast host change

Took 8 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-08-13 18:58:21 +02:00 • committed by GitHub
parent 48776cfeba
commit 26fb8622e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 59 additions and 42 deletions

View file

@ -57,16 +57,16 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
gameNameFilterEdit->setText(filters.gameNameFilter); gameNameFilterEdit->setText(filters.gameNameFilter);
auto *gameNameFilterLabel = new QLabel(tr("Game &description:")); auto *gameNameFilterLabel = new QLabel(tr("Game &description:"));
gameNameFilterLabel->setBuddy(gameNameFilterEdit); gameNameFilterLabel->setBuddy(gameNameFilterEdit);
creatorNameFilterEdit = new QLineEdit; hostNameFilterEdit = new QLineEdit;
creatorNameFilterEdit->setText(filters.creatorNameFilters.join(", ")); hostNameFilterEdit->setText(filters.hostNameFilters.join(", "));
auto *creatorNameFilterLabel = new QLabel(tr("&Creator name:")); auto *hostNameFilterLabel = new QLabel(tr("&Host name:"));
creatorNameFilterLabel->setBuddy(creatorNameFilterEdit); hostNameFilterLabel->setBuddy(hostNameFilterEdit);
auto *generalGrid = new QGridLayout; auto *generalGrid = new QGridLayout;
generalGrid->addWidget(gameNameFilterLabel, 0, 0); generalGrid->addWidget(gameNameFilterLabel, 0, 0);
generalGrid->addWidget(gameNameFilterEdit, 0, 1); generalGrid->addWidget(gameNameFilterEdit, 0, 1);
generalGrid->addWidget(creatorNameFilterLabel, 1, 0); generalGrid->addWidget(hostNameFilterLabel, 1, 0);
generalGrid->addWidget(creatorNameFilterEdit, 1, 1); generalGrid->addWidget(hostNameFilterEdit, 1, 1);
generalGrid->addWidget(maxGameAgeLabel, 2, 0); generalGrid->addWidget(maxGameAgeLabel, 2, 0);
generalGrid->addWidget(maxGameAgeComboBox, 2, 1); generalGrid->addWidget(maxGameAgeComboBox, 2, 1);
generalGroupBox = new QGroupBox(tr("General")); generalGroupBox = new QGroupBox(tr("General"));
@ -193,7 +193,7 @@ GameFilterConfigs DlgFilterGames::getFilters() const
hideNotBuddyCreatedGames->isChecked(), hideNotBuddyCreatedGames->isChecked(),
hideOpenDecklistGames->isChecked(), hideOpenDecklistGames->isChecked(),
gameNameFilterEdit->text(), gameNameFilterEdit->text(),
getCreatorNameFilters(), getHostNameFilters(),
getGameTypeFilter(), getGameTypeFilter(),
maxPlayersFilterMinSpinBox->value(), maxPlayersFilterMinSpinBox->value(),
maxPlayersFilterMaxSpinBox->value(), maxPlayersFilterMaxSpinBox->value(),
@ -216,9 +216,9 @@ void DlgFilterGames::toggleSpectatorCheckboxEnabledness(bool spectatorsEnabled)
showOnlyIfSpectatorsCanSeeHands->setDisabled(!spectatorsEnabled); showOnlyIfSpectatorsCanSeeHands->setDisabled(!spectatorsEnabled);
} }
QStringList DlgFilterGames::getCreatorNameFilters() const QStringList DlgFilterGames::getHostNameFilters() const
{ {
return creatorNameFilterEdit->text().split(",", Qt::SkipEmptyParts); return hostNameFilterEdit->text().split(",", Qt::SkipEmptyParts);
} }
QSet<int> DlgFilterGames::getGameTypeFilter() const QSet<int> DlgFilterGames::getGameTypeFilter() const

View file

@ -35,7 +35,7 @@ private:
QCheckBox *hideNotBuddyCreatedGames; QCheckBox *hideNotBuddyCreatedGames;
QCheckBox *hideOpenDecklistGames; QCheckBox *hideOpenDecklistGames;
QLineEdit *gameNameFilterEdit; QLineEdit *gameNameFilterEdit;
QLineEdit *creatorNameFilterEdit; QLineEdit *hostNameFilterEdit;
QMap<int, QCheckBox *> gameTypeFilterCheckBoxes; QMap<int, QCheckBox *> gameTypeFilterCheckBoxes;
QSpinBox *maxPlayersFilterMinSpinBox; QSpinBox *maxPlayersFilterMinSpinBox;
QSpinBox *maxPlayersFilterMaxSpinBox; QSpinBox *maxPlayersFilterMaxSpinBox;
@ -50,7 +50,7 @@ private:
const GamesProxyModel *gamesProxyModel; const GamesProxyModel *gamesProxyModel;
const QMap<QTime, QString> gameAgeMap; const QMap<QTime, QString> gameAgeMap;
[[nodiscard]] QStringList getCreatorNameFilters() const; [[nodiscard]] QStringList getHostNameFilters() const;
[[nodiscard]] QSet<int> getGameTypeFilter() const; [[nodiscard]] QSet<int> getGameTypeFilter() const;
[[nodiscard]] QTime getMaxGameAge() const; [[nodiscard]] QTime getMaxGameAge() const;
[[nodiscard]] bool getShowSpectatorPasswordProtected() const; [[nodiscard]] bool getShowSpectatorPasswordProtected() const;

View file

@ -19,7 +19,7 @@ struct GameFilterConfigs
bool hideNotBuddyCreatedGames = false; bool hideNotBuddyCreatedGames = false;
bool hideOpenDecklistGames = false; bool hideOpenDecklistGames = false;
QString gameNameFilter = ""; QString gameNameFilter = "";
QStringList creatorNameFilters = {}; QStringList hostNameFilters = {};
QSet<int> gameTypeFilter = {}; QSet<int> gameTypeFilter = {};
int maxPlayersFilterMin = DEFAULT_MAX_PLAYERS_MIN; int maxPlayersFilterMin = DEFAULT_MAX_PLAYERS_MIN;
int maxPlayersFilterMax = DEFAULT_MAX_PLAYERS_MAX; int maxPlayersFilterMax = DEFAULT_MAX_PLAYERS_MAX;

View file

@ -17,13 +17,27 @@ enum GameListColumn
ROOM, ROOM,
CREATED, CREATED,
DESCRIPTION, DESCRIPTION,
CREATOR, HOST,
GAME_TYPE, GAME_TYPE,
RESTRICTIONS, RESTRICTIONS,
PLAYERS, PLAYERS,
SPECTATORS SPECTATORS
}; };
namespace
{
/**
* @brief Returns the user info of the game's current host, falling back to the creator.
*
* The server only sends host_info once a host transfer has happened, so older
* servers and freshly created games fall back to the original creator.
*/
const ServerInfo_User &getGameHost(const ServerInfo_Game &game)
{
return game.has_host_info() ? game.host_info() : game.creator_info();
}
} // namespace
const QString GamesModel::getGameCreatedString(const int secs) const QString GamesModel::getGameCreatedString(const int secs)
{ {
static const QTime zeroTime{0, 0}; static const QTime zeroTime{0, 0};
@ -110,16 +124,16 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
default: default:
return QVariant(); return QVariant();
} }
case CREATOR: { case HOST: {
switch (role) { switch (role) {
case SORT_ROLE: case SORT_ROLE:
case Qt::DisplayRole: case Qt::DisplayRole:
return QString::fromStdString(gameentry.creator_info().name()); return QString::fromStdString(getGameHost(gameentry).name());
case Qt::DecorationRole: { case Qt::DecorationRole: {
return UserLevelPixmapGenerator::generateIcon( const ServerInfo_User &host = getGameHost(gameentry);
13, UserLevelFlags(gameentry.creator_info().user_level()), return UserLevelPixmapGenerator::generateIcon(13, UserLevelFlags(host.user_level()),
gameentry.creator_info().pawn_colors(), false, host.pawn_colors(), false,
QString::fromStdString(gameentry.creator_info().privlevel())); QString::fromStdString(host.privlevel()));
} }
default: default:
return QVariant(); return QVariant();
@ -233,8 +247,8 @@ QVariant GamesModel::headerData(int section, Qt::Orientation /*orientation*/, in
} }
case DESCRIPTION: case DESCRIPTION:
return tr("Description"); return tr("Description");
case CREATOR: case HOST:
return tr("Creator"); return tr("Host");
case GAME_TYPE: case GAME_TYPE:
return tr("Type"); return tr("Type");
case RESTRICTIONS: case RESTRICTIONS:
@ -347,7 +361,7 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
gameFilters.isHideFullGames(), gameFilters.isHideGamesThatStarted(), gameFilters.isHideFullGames(), gameFilters.isHideGamesThatStarted(),
gameFilters.isHidePasswordProtectedGames(), gameFilters.isHideNotBuddyCreatedGames(), gameFilters.isHidePasswordProtectedGames(), gameFilters.isHideNotBuddyCreatedGames(),
gameFilters.isHideOpenDecklistGames(), gameFilters.getGameNameFilter(), gameFilters.isHideOpenDecklistGames(), gameFilters.getGameNameFilter(),
gameFilters.getCreatorNameFilters(), newGameTypeFilter, gameFilters.getMinPlayers(), gameFilters.getHostNameFilters(), newGameTypeFilter, gameFilters.getMinPlayers(),
gameFilters.getMaxPlayers(), gameFilters.getMaxGameAge(), gameFilters.getMaxPlayers(), gameFilters.getMaxGameAge(),
gameFilters.isShowOnlyIfSpectatorsCanWatch(), gameFilters.isShowSpectatorPasswordProtected(), gameFilters.isShowOnlyIfSpectatorsCanWatch(), gameFilters.isShowSpectatorPasswordProtected(),
gameFilters.isShowOnlyIfSpectatorsCanChat(), gameFilters.isShowOnlyIfSpectatorsCanSeeHands()}); gameFilters.isShowOnlyIfSpectatorsCanChat(), gameFilters.isShowOnlyIfSpectatorsCanSeeHands()});
@ -364,7 +378,7 @@ void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameType
gameFilters.setHideNotBuddyCreatedGames(filters.hideNotBuddyCreatedGames); gameFilters.setHideNotBuddyCreatedGames(filters.hideNotBuddyCreatedGames);
gameFilters.setHideOpenDecklistGames(filters.hideOpenDecklistGames); gameFilters.setHideOpenDecklistGames(filters.hideOpenDecklistGames);
gameFilters.setGameNameFilter(filters.gameNameFilter); gameFilters.setGameNameFilter(filters.gameNameFilter);
gameFilters.setCreatorNameFilters(filters.creatorNameFilters); gameFilters.setHostNameFilters(filters.hostNameFilters);
QMapIterator<int, QString> gameTypeIterator(allGameTypes); QMapIterator<int, QString> gameTypeIterator(allGameTypes);
while (gameTypeIterator.hasNext()) { while (gameTypeIterator.hasNext()) {
@ -409,11 +423,11 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
return false; return false;
} }
if (filters.hideIgnoredUserGames && if (filters.hideIgnoredUserGames &&
userListProxy->isUserIgnored(QString::fromStdString(game.creator_info().name()))) { userListProxy->isUserIgnored(QString::fromStdString(getGameHost(game).name()))) {
return false; return false;
} }
if (filters.hideNotBuddyCreatedGames && if (filters.hideNotBuddyCreatedGames &&
!userListProxy->isUserBuddy(QString::fromStdString(game.creator_info().name()))) { !userListProxy->isUserBuddy(QString::fromStdString(getGameHost(game).name()))) {
return false; return false;
} }
if (filters.hideFullGames && game.player_count() == game.max_players()) { if (filters.hideFullGames && game.player_count() == game.max_players()) {
@ -435,10 +449,10 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
return false; return false;
} }
} }
if (!filters.creatorNameFilters.isEmpty()) { if (!filters.hostNameFilters.isEmpty()) {
bool found = false; bool found = false;
for (const auto &createNameFilter : filters.creatorNameFilters) { for (const auto &hostNameFilter : filters.hostNameFilters) {
if (QString::fromStdString(game.creator_info().name()).contains(createNameFilter, Qt::CaseInsensitive)) { if (QString::fromStdString(getGameHost(game).name()).contains(hostNameFilter, Qt::CaseInsensitive)) {
found = true; found = true;
} }
} }

View file

@ -526,10 +526,7 @@ void Server_Game::addPlayer(Server_AbstractUserInterface *userInterface,
if (broadcastUpdate) { if (broadcastUpdate) {
ServerInfo_Game gameInfo; ServerInfo_Game gameInfo;
gameInfo.set_room_id(room->getId()); getInfo(gameInfo);
gameInfo.set_game_id(gameId);
gameInfo.set_player_count(getPlayerCount());
gameInfo.set_spectators_count(getSpectatorCount());
emit gameInfoChanged(gameInfo); emit gameInfoChanged(gameInfo);
} }
@ -588,10 +585,7 @@ void Server_Game::removeParticipant(Server_AbstractParticipant *participant, Eve
} }
ServerInfo_Game gameInfo; ServerInfo_Game gameInfo;
gameInfo.set_room_id(room->getId()); getInfo(gameInfo);
gameInfo.set_game_id(gameId);
gameInfo.set_player_count(getPlayerCount());
gameInfo.set_spectators_count(getSpectatorCount());
emit gameInfoChanged(gameInfo); emit gameInfoChanged(gameInfo);
} }
@ -847,6 +841,12 @@ void Server_Game::getInfo(ServerInfo_Game &result) const
result.set_player_count(getPlayerCount()); result.set_player_count(getPlayerCount());
result.set_started(gameStarted); result.set_started(gameStarted);
result.mutable_creator_info()->CopyFrom(*getCreatorInfo()); result.mutable_creator_info()->CopyFrom(*getCreatorInfo());
const Server_AbstractParticipant *host = participants.value(hostId, nullptr);
if (host != nullptr) {
result.mutable_host_info()->CopyFrom(*host->getUserInfo());
} else {
result.mutable_host_info()->CopyFrom(*getCreatorInfo());
}
result.set_only_buddies(onlyBuddies); result.set_only_buddies(onlyBuddies);
result.set_only_registered(onlyRegistered); result.set_only_registered(onlyRegistered);
result.set_spectators_allowed(getSpectatorsAllowed()); result.set_spectators_allowed(getSpectatorsAllowed());

View file

@ -62,4 +62,7 @@ message ServerInfo_Game {
// whether the game is closed. Closed games are finished and can't be interacted with // whether the game is closed. Closed games are finished and can't be interacted with
optional bool closed = 52; optional bool closed = 52;
// the current host of the game, which may differ from the creator after a host transfer
optional ServerInfo_User host_info = 53;
} }

View file

@ -104,14 +104,14 @@ QString GameFiltersSettings::getGameNameFilter() const
return getValue("gameNameFilter").toString(); return getValue("gameNameFilter").toString();
} }
void GameFiltersSettings::setCreatorNameFilters(QStringList creatorName) void GameFiltersSettings::setHostNameFilters(QStringList hostName)
{ {
setValue(creatorName, "creatorNameFilter"); setValue(hostName, "hostNameFilter");
} }
QStringList GameFiltersSettings::getCreatorNameFilters() const QStringList GameFiltersSettings::getHostNameFilters() const
{ {
return getValue("creatorNameFilter").toStringList(); return getValue("hostNameFilter").toStringList();
} }
void GameFiltersSettings::setMinPlayers(int min) void GameFiltersSettings::setMinPlayers(int min)

View file

@ -24,7 +24,7 @@ public:
bool isHideNotBuddyCreatedGames() const; bool isHideNotBuddyCreatedGames() const;
bool isHideOpenDecklistGames() const; bool isHideOpenDecklistGames() const;
QString getGameNameFilter() const; QString getGameNameFilter() const;
QStringList getCreatorNameFilters() const; QStringList getHostNameFilters() const;
int getMinPlayers() const; int getMinPlayers() const;
int getMaxPlayers() const; int getMaxPlayers() const;
QTime getMaxGameAge() const; QTime getMaxGameAge() const;
@ -42,7 +42,7 @@ public:
void setHidePasswordProtectedGames(bool hide); void setHidePasswordProtectedGames(bool hide);
void setHideNotBuddyCreatedGames(bool hide); void setHideNotBuddyCreatedGames(bool hide);
void setGameNameFilter(QString gameName); void setGameNameFilter(QString gameName);
void setCreatorNameFilters(QStringList creatorName); void setHostNameFilters(QStringList hostName);
void setMinPlayers(int min); void setMinPlayers(int min);
void setMaxPlayers(int max); void setMaxPlayers(int max);
void setMaxGameAge(const QTime &maxGameAge); void setMaxGameAge(const QTime &maxGameAge);