Game Load: Show list of enabled modifications (#3495)

This commit is contained in:
jostephd 2018-08-27 16:42:47 +00:00 committed by Jyrki Vesterinen
parent 8d4e869336
commit 14abecb2df
3 changed files with 26 additions and 4 deletions

View file

@ -365,11 +365,13 @@
border_size = 5
horizontal_grow = true
[label]
id = "lblSummary"
[scroll_label]
id = "slblSummary"
definition = "default_small"
use_markup = true
[/label]
vertical_scrollbar_mode = "auto"
wrap = false
[/scroll_label]
[/column]

View file

@ -30,6 +30,7 @@
#include "gui/widgets/button.hpp"
#include "gui/widgets/image.hpp"
#include "gui/widgets/label.hpp"
#include "gui/widgets/scroll_label.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
#else
@ -228,7 +229,9 @@ void game_load::display_savegame(window& window)
str << game.format_time_local() << "\n";
evaluate_summary_string(str, summary_);
find_widget<label>(&window, "lblSummary", false).set_label(str.str());
// The new label value may have more or less lines than the previous value, so invalidate the layout.
find_widget<scroll_label>(&window, "slblSummary", false).set_label(str.str());
window.invalidate_layout();
toggle_button& replay_toggle = dynamic_cast<toggle_button&>(*show_replay_->get_widget());
toggle_button& cancel_orders_toggle = dynamic_cast<toggle_button&>(*cancel_orders_->get_widget());
@ -380,6 +383,22 @@ void game_load::evaluate_summary_string(std::stringstream& str, const config& cf
if(!cfg_summary["version"].empty()) {
str << "\n" << _("Version: ") << cfg_summary["version"];
}
const std::vector<std::string>& active_mods = utils::split(cfg_summary["active_mods"]);
if(!active_mods.empty()) {
str << "\n" << _("Modifications: ");
for(const auto& mod_id : active_mods) {
std::string mod_name;
try {
mod_name = cache_config_.find_child("modification", "id", mod_id)["name"].str();
} catch(const config::error&) {
// Fallback to nontranslatable mod id.
mod_name = "(" + mod_id + ")";
}
str << "\n" << font::unicode_bullet << " " << mod_name;
}
}
}
void game_load::delete_button_callback(window& window)

View file

@ -373,6 +373,7 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
cfg_summary["difficulty"] = cfg_save["difficulty"];
cfg_summary["random_mode"] = cfg_save["random_mode"];
cfg_summary["active_mods"] = cfg_save.child("multiplayer")["active_mods"];
cfg_summary["campaign"] = cfg_save["campaign"];
cfg_summary["version"] = cfg_save["version"];
cfg_summary["corrupt"] = "";