MP Lobby: split game type markers from type name (fixes #4724)

Also closes #5006
This commit is contained in:
Charles Dang 2020-10-26 13:10:48 +11:00
parent 6ea4bd58cf
commit 4abeef29d4
3 changed files with 11 additions and 5 deletions

View file

@ -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()
@ -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
@ -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"];
@ -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;
}

View file

@ -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;

View file

@ -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);