Skip to content

Commit

Permalink
MP Lobby: split game type markers from type name (fixes #4724)
Browse files Browse the repository at this point in the history
Also closes #5006
  • Loading branch information
Vultraz committed Oct 26, 2020
1 parent 6ea4bd5 commit 4abeef2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/game_initialization/lobby_data.cpp
Expand Up @@ -200,6 +200,7 @@ game_info::game_info(const config& game, const std::vector<std::string>& install
, map_data(game["map_data"])
, name(font::escape_text(game["name"]))
, scenario()
, type_marker()
, remote_scenario(false)
, map_info()
, map_size_info()
Expand Down Expand Up @@ -351,7 +352,8 @@ game_info::game_info(const config& game, const std::vector<std::string>& install
}

if(*level_cfg) {
scenario = formatter() << make_game_type_marker(_("scenario_abbreviation^S"), false) << (*level_cfg)["name"].str();
type_marker = make_game_type_marker(_("scenario_abbreviation^S"), false);
scenario = (*level_cfg)["name"].str();
info_stream << scenario;

// Reloaded games do not match the original scenario hash, so it makes no sense
Expand Down Expand Up @@ -384,15 +386,17 @@ game_info::game_info(const config& game, const std::vector<std::string>& install
if(require) {
addons_outcome = std::max(addons_outcome, NEED_DOWNLOAD); // Elevate to most severe error level encountered so far
}
scenario = formatter() << make_game_type_marker(_("scenario_abbreviation^S"), true) << game["mp_scenario_name"].str();
type_marker = make_game_type_marker(_("scenario_abbreviation^S"), true);
scenario = game["mp_scenario_name"].str();
info_stream << scenario;
verified = false;
}
} else if(!game["mp_campaign"].empty()) {
if(const config& campaign_cfg = game_config.find_child("campaign", "id", game["mp_campaign"])) {
type_marker = make_game_type_marker(_("campaign_abbreviation^C"), false);

std::stringstream campaign_text;
campaign_text
<< make_game_type_marker(_("campaign_abbreviation^C"), false)
<< campaign_cfg["name"] << spaced_em_dash()
<< game["mp_scenario_name"];

Expand All @@ -415,7 +419,8 @@ game_info::game_info(const config& game, const std::vector<std::string>& install
addons_outcome = std::max(addons_outcome, result); // Elevate to most severe error level encountered so far
//}
} else {
scenario = formatter() << make_game_type_marker(_("campaign_abbreviation^C"), true) << game["mp_campaign_name"].str();
type_marker = make_game_type_marker(_("campaign_abbreviation^C"), true);
scenario = game["mp_campaign_name"].str();
info_stream << scenario;
verified = false;
}
Expand Down
1 change: 1 addition & 0 deletions src/game_initialization/lobby_data.hpp
Expand Up @@ -145,6 +145,7 @@ struct game_info
std::string map_data;
std::string name;
std::string scenario;
std::string type_marker;
bool remote_scenario;
std::string map_info;
std::string map_size_info;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/multiplayer/lobby.cpp
Expand Up @@ -425,7 +425,7 @@ std::map<std::string, string_map> mp_lobby::make_game_row_data(const mp::game_in
item["label"] = game.vacant_slots > 0 ? colorize(game.name, color_string) : game.name;
data.emplace("name", item);

item["label"] = colorize("<i>" + scenario_text + "</i>", font::GRAY_COLOR);
item["label"] = colorize("<i>" + game.type_marker + scenario_text + "</i>", font::GRAY_COLOR);
data.emplace("scenario", item);

item["label"] = colorize(game.status, color_string);
Expand Down

0 comments on commit 4abeef2

Please sign in to comment.