Game Load: Show the user-name difficulty name instead of the internal name.

The internal name (Easy/Medium/Hard/Nightmare) will only be shown if the campaign
is not installed, or doesn't declare the saved difficulty.
This commit is contained in:
josteph 2018-08-18 18:05:42 +00:00 committed by Jyrki Vesterinen
parent 54c93f0935
commit 4a2675a42c

View file

@ -303,6 +303,7 @@ void game_load::filter_text_changed(text_box_base* textbox, const std::string& t
void game_load::evaluate_summary_string(std::stringstream& str, const config& cfg_summary)
{
std::string difficulty_human_str = string_table[cfg_summary["difficulty"]];
if(cfg_summary["corrupt"].to_bool()) {
str << "\n<span color='#f00'>" << _("(Invalid)") << "</span>";
@ -323,6 +324,16 @@ void game_load::evaluate_summary_string(std::stringstream& str, const config& cf
}
}
if (campaign != nullptr) {
try {
const config &difficulty = campaign->find_child("difficulty", "define", cfg_summary["difficulty"]);
std::ostringstream ss;
ss << difficulty["label"] << " (" << difficulty["description"] << ")";
difficulty_human_str = ss.str();
} catch(const config::error&) {
}
}
utils::string_map symbols;
if(campaign != nullptr) {
symbols["campaign_name"] = (*campaign)["name"];
@ -364,7 +375,7 @@ void game_load::evaluate_summary_string(std::stringstream& str, const config& cf
}
str << "\n" << _("Difficulty: ")
<< string_table[cfg_summary["difficulty"]];
<< difficulty_human_str;
if(!cfg_summary["version"].empty()) {
str << "\n" << _("Version: ") << cfg_summary["version"];