MP Lobby: sort mods list alphabetically and color "missing" text
This commit is contained in:
parent
ef316bfc0d
commit
19d0c9198c
3 changed files with 25 additions and 8 deletions
|
@ -279,7 +279,8 @@ game_info::game_info(const config& game, const config& game_config, const std::v
|
|||
info_stream << era;
|
||||
|
||||
for(const config& cfg : game.child_range("modification")) {
|
||||
mod_info += (mod_info.empty() ? "" : ", ") + cfg["name"].str();
|
||||
mod_info.emplace_back(cfg["name"].str(), true);
|
||||
info_stream << ' ' << mod_info.back().first;
|
||||
|
||||
if(cfg["require_modification"].to_bool(false)) {
|
||||
if(const config& mod = game_config.find_child("modification", "id", cfg["id"])) {
|
||||
|
@ -287,14 +288,18 @@ game_info::game_info(const config& game, const config& game_config, const std::v
|
|||
addons_outcome = std::max(addons_outcome, result); // Elevate to most severe error level encountered so far
|
||||
} else {
|
||||
have_all_mods = false;
|
||||
mod_info += " " + _("(missing)");
|
||||
mod_info.back().second = false;
|
||||
|
||||
addons_outcome = NEED_DOWNLOAD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info_stream << mod_info;
|
||||
std::sort(mod_info.begin(), mod_info.end(), [](const auto& lhs, const auto& rhs) {
|
||||
return translation::icompare(lhs.first, rhs.first) < 0;
|
||||
});
|
||||
|
||||
info_stream << ' ';
|
||||
|
||||
if(map_data.empty()) {
|
||||
map_data = filesystem::read_map(game["mp_scenario"]);
|
||||
|
|
|
@ -150,7 +150,9 @@ struct game_info
|
|||
std::string map_size_info;
|
||||
std::string era;
|
||||
std::string era_short;
|
||||
std::string mod_info;
|
||||
|
||||
/** List of modification names and whether they're installed or not. */
|
||||
std::vector<std::pair<std::string, bool>> mod_info;
|
||||
|
||||
std::string gold;
|
||||
std::string support;
|
||||
|
|
|
@ -452,22 +452,32 @@ void mp_lobby::adjust_game_row_contents(const mp::game_info& game, grid* grid, b
|
|||
//
|
||||
std::ostringstream ss;
|
||||
|
||||
const auto mark_missing = [&ss]() {
|
||||
ss << ' ' << font::span_color(font::BAD_COLOR) << "(" << _("era_or_mod^missing") << ")</span>";
|
||||
};
|
||||
|
||||
ss << "<big>" << colorize(_("Era"), font::TITLE_COLOR) << "</big>\n" << game.era;
|
||||
|
||||
if(!game.have_era) {
|
||||
// NOTE: not using colorize() here deliberately to avoid awkward string concatenation.
|
||||
ss << " " << font::span_color(font::BAD_COLOR) << "(" << _("era^missing") << ")</span>";
|
||||
mark_missing();
|
||||
}
|
||||
|
||||
ss << "\n\n<big>" << colorize(_("Modifications"), font::TITLE_COLOR) << "</big>\n";
|
||||
|
||||
std::vector<std::string> mods = utils::split(game.mod_info);
|
||||
auto mods = game.mod_info;
|
||||
|
||||
if(mods.empty()) {
|
||||
ss << _("active_modifications^None") << "\n";
|
||||
} else {
|
||||
for(const std::string& mod : mods) {
|
||||
ss << mod << "\n";
|
||||
for(const auto& mod : mods) {
|
||||
ss << mod.first;
|
||||
|
||||
if(!mod.second) {
|
||||
mark_missing();
|
||||
}
|
||||
|
||||
ss << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue