From ee771dbf5c442afcad198e7f5d79d9b92351b2d8 Mon Sep 17 00:00:00 2001 From: Iris Morelle Date: Thu, 25 Jun 2020 17:17:35 -0400 Subject: [PATCH] help: Skip nameless abilities in Ability and Ability Upgrades Nameless abilities are relatively common outside of mainline in particular as they are used for implementation details of more complex abilities. Fixes #3060. --- changelog.md | 3 +++ src/help/help_topic_generators.cpp | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 332055e3fac7..2419eaf835dd 100644 --- a/changelog.md +++ b/changelog.md @@ -526,6 +526,9 @@ ## Version 1.14.13+dev ### Language and i18n * Updated translations: + ### User interface + * Do not list nameless abilities in the Abilities and Ability Upgrades lists in unit + descriptions in Help (issue #3060). ### Miscellaneous and bug fixes ## Version 1.14.13 diff --git a/src/help/help_topic_generators.cpp b/src/help/help_topic_generators.cpp index 0b74c1f2c592..a4a4d735e2bf 100644 --- a/src/help/help_topic_generators.cpp +++ b/src/help/help_topic_generators.cpp @@ -471,15 +471,23 @@ std::string unit_topic_generator::operator()() const { if(!type_.abilities_metadata().empty()) { ss << _("Abilities: "); + bool start = true; + for(auto iter = type_.abilities_metadata().begin(); iter != type_.abilities_metadata().end(); ++iter) { const std::string ref_id = ability_prefix + iter->id + iter->name.base_str(); - std::string lang_ability = translation::gettext(iter->name.c_str()); - ss << make_link(lang_ability, ref_id); + if(iter->name.empty()) { + continue; + } - if(std::next(iter) != type_.abilities_metadata().end()) { + if(!start) { ss << ", "; + } else { + start = false; } + + std::string lang_ability = translation::gettext(iter->name.c_str()); + ss << make_link(lang_ability, ref_id); } ss << "\n\n"; @@ -489,15 +497,23 @@ std::string unit_topic_generator::operator()() const { if(!type_.adv_abilities_metadata().empty()) { ss << _("Ability Upgrades: "); + bool start = true; + for(auto iter = type_.adv_abilities_metadata().begin(); iter != type_.adv_abilities_metadata().end(); ++iter) { const std::string ref_id = ability_prefix + iter->id + iter->name.base_str(); - std::string lang_ability = translation::gettext(iter->name.c_str()); - ss << make_link(lang_ability, ref_id); + if(iter->name.empty()) { + continue; + } - if(std::next(iter) != type_.adv_abilities_metadata().end()) { + if(!start) { ss << ", "; + } else { + start = false; } + + std::string lang_ability = translation::gettext(iter->name.c_str()); + ss << make_link(lang_ability, ref_id); } ss << "\n\n";