Display Difficulty as em dash when it is not valid (resolves #5321)
Also shows campaign-specific difficulty for MP games. * Test scenario: No difficulty -> — * Pre-1.15 Tutorial: No difficulty -> — * SP Campaigns: Custom difficulty -> no change * MP Campaigns: Plain difficulty -> Custom difficulty * MP Scenario: No difficulty -> — Save Game Before After --------- ------ ----- Test scenario Medium — Tutorial (1.14 Tutorial) Medium — Tutorial (1.17 Campaign) Tutorial (Beginner) Tutorial (Beginner) MP single scenario Medium — SP campaign (HttT) Commander (Normal) Commander (Normal) MP campaign (HttT) Medium Commander (Normal) SP campaign (LoW) Lord (Challenging) Lord (Challenging) MP campaign (LoW) Medium Lord (Challenging) Using — follows precedent in MP Staging, plus has the benefit of not breaking the string freeze in lead-up to 1.16 release.
This commit is contained in:
parent
d17dcff522
commit
6b3ca0e167
1 changed files with 44 additions and 15 deletions
|
@ -353,7 +353,6 @@ void game_load::filter_text_changed(const std::string& text)
|
|||
|
||||
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>";
|
||||
// \todo: this skips the catch() statement in display_savegame. Low priority, as the
|
||||
|
@ -364,12 +363,11 @@ void game_load::evaluate_summary_string(std::stringstream& str, const config& cf
|
|||
}
|
||||
|
||||
const std::string& campaign_type = cfg_summary["campaign_type"];
|
||||
const std::string campaign_id = cfg_summary["campaign"];
|
||||
|
||||
try {
|
||||
switch(game_classification::CAMPAIGN_TYPE::string_to_enum(campaign_type).v) {
|
||||
case game_classification::CAMPAIGN_TYPE::SCENARIO: {
|
||||
const std::string campaign_id = cfg_summary["campaign"];
|
||||
|
||||
const config* campaign = nullptr;
|
||||
if(!campaign_id.empty()) {
|
||||
if(const config& c = cache_config_.find_child("campaign", "id", campaign_id)) {
|
||||
|
@ -377,16 +375,6 @@ 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"];
|
||||
|
@ -427,8 +415,49 @@ void game_load::evaluate_summary_string(std::stringstream& str, const config& cf
|
|||
str << _("Scenario start");
|
||||
}
|
||||
|
||||
str << "\n" << _("Difficulty: ")
|
||||
<< difficulty_human_str;
|
||||
str << "\n" << _("Difficulty: ");
|
||||
try {
|
||||
switch (game_classification::CAMPAIGN_TYPE::string_to_enum(campaign_type).v) {
|
||||
case game_classification::CAMPAIGN_TYPE::SCENARIO:
|
||||
case game_classification::CAMPAIGN_TYPE::MULTIPLAYER: {
|
||||
const config* campaign = nullptr;
|
||||
if (!campaign_id.empty()) {
|
||||
if (const config& c = cache_config_.find_child("campaign", "id", campaign_id)) {
|
||||
campaign = &c;
|
||||
}
|
||||
}
|
||||
|
||||
// 'SCENARIO' or SP should only ever be campaigns
|
||||
// 'MULTIPLAYER' may be a campaign with difficulty or single scenario without difficulty
|
||||
// For the latter do not show the difficulty - even though it will be listed as
|
||||
// NORMAL -> Medium in the save file it should not be considered valid (GitHub Issue #5321)
|
||||
if (campaign != nullptr) {
|
||||
try {
|
||||
const config& difficulty = campaign->find_child("difficulty", "define", cfg_summary["difficulty"]);
|
||||
std::ostringstream ss;
|
||||
ss << difficulty["label"] << " (" << difficulty["description"] << ")";
|
||||
str << ss.str();
|
||||
}
|
||||
catch (const config::error&) {
|
||||
// fall back to standard difficulty string in case of exception
|
||||
str << string_table[cfg_summary["difficulty"]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
str << "—";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case game_classification::CAMPAIGN_TYPE::TUTORIAL:
|
||||
case game_classification::CAMPAIGN_TYPE::TEST:
|
||||
str << "—";
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (const bad_enum_cast&) {
|
||||
str << "—";
|
||||
}
|
||||
|
||||
if(!cfg_summary["version"].empty()) {
|
||||
str << "\n" << _("Version: ") << cfg_summary["version"];
|
||||
|
|
Loading…
Add table
Reference in a new issue