diff --git a/changelog b/changelog index 39ad7efae79b..49572a94fa07 100644 --- a/changelog +++ b/changelog @@ -121,6 +121,8 @@ Version 1.13.0-dev: * Fixed in-game help descriptions of default factions, using content from wiki * Added automatically generated lists of races and alignments to the descriptions of factions * Autogenerated Time of Day Schedule section + * Unit types that do not include any visible (hide_help=no) variations no + longer generate topic sections. * Language and i18n: * Updated translations: Czech, French, Galician, German, Greek, Hungarian, Italian, Lithuanian, Portuguese, Russian, Scottish Gaelic, Slovak, Spanish, diff --git a/players_changelog b/players_changelog index 71446f507308..3ad881c3c7f5 100644 --- a/players_changelog +++ b/players_changelog @@ -44,6 +44,8 @@ Version 1.13.0-dev: * Help Browser: * Autogenerated Time of Day Schedule section + * Unit types that do not include any visible (hide_help=no) variations no + longer generate topic sections. * Language and i18n: * Updated translations: Czech, French, Galician, German, Greek, Hungarian, diff --git a/src/editor/controller/editor_controller.cpp b/src/editor/controller/editor_controller.cpp index e3f128c51aaf..ab349dd554e1 100644 --- a/src/editor/controller/editor_controller.cpp +++ b/src/editor/controller/editor_controller.cpp @@ -1075,7 +1075,7 @@ void editor_controller::unit_description() const unit_map & units = context_manager_->get_map_context().get_units(); const unit_map::const_unit_iterator un = units.find(loc); if(un != units.end()) { - help::show_unit_help(*gui_, un->type_id(), !un->type().variations().empty(), false); + help::show_unit_help(*gui_, un->type_id(), un->type().show_variations_in_help(), false); } else { help::show_help(*gui_, "..units"); } diff --git a/src/help/help.cpp b/src/help/help.cpp index 2cad6476f2a9..d33176343277 100644 --- a/src/help/help.cpp +++ b/src/help/help.cpp @@ -88,7 +88,7 @@ void show_unit_description(const unit_type &t) if (use_variation) help::show_variation_help(*display::get_singleton(), t.id(), var_id, hide_help); else - help::show_unit_help(*display::get_singleton(), t.id(), !t.variations().empty(), hide_help); + help::show_unit_help(*display::get_singleton(), t.id(), t.show_variations_in_help(), hide_help); } help_manager::help_manager(const config *cfg) //, gamemap *_map) diff --git a/src/help/help_impl.cpp b/src/help/help_impl.cpp index 5ceb1cada371..5c26e7dc6e58 100644 --- a/src/help/help_impl.cpp +++ b/src/help/help_impl.cpp @@ -416,7 +416,7 @@ std::vector generate_weapon_special_topics(const bool sort_generated) //add a link in the list of units having this special std::string type_name = type.type_name(); //check for variations (walking corpse/soulless etc) - const std::string section_prefix = type.variations().empty() ? "" : ".."; + const std::string section_prefix = type.show_variations_in_help() ? ".." : ""; std::string ref_id = section_prefix + unit_prefix + type.id(); //we put the translated name at the beginning of the hyperlink, //so the automatic alphabetic sorting of std::set can use it @@ -639,7 +639,7 @@ std::string make_unit_link(const std::string& type_id) std::string name = type->type_name(); std::string ref_id; if (description_type(*type) == FULL_DESCRIPTION) { - const std::string section_prefix = type->variations().empty() ? "" : ".."; + const std::string section_prefix = type->show_variations_in_help() ? ".." : ""; ref_id = section_prefix + unit_prefix + type->id(); } else { ref_id = unknown_unit_topic; @@ -785,7 +785,7 @@ void generate_unit_sections(const config* /*help_cfg*/, section& sec, int level, if (type.race_id() != race) continue; - if (type.variations().empty()) + if (!type.show_variations_in_help()) continue; section base_unit; @@ -830,7 +830,7 @@ std::vector generate_unit_topics(const bool sort_generated, const std::st continue; const std::string type_name = type.type_name(); - const std::string real_prefix = type.variations().empty() ? "" : ".."; + const std::string real_prefix = type.show_variations_in_help() ? ".." : ""; const std::string ref_id = hidden_symbol(type.hide_help()) + real_prefix + unit_prefix + type.id(); topic unit_topic(type_name, ref_id, ""); unit_topic.text = new unit_topic_generator(type); diff --git a/src/reports.cpp b/src/reports.cpp index 0afa71e23500..9dec9f50bba6 100644 --- a/src/reports.cpp +++ b/src/reports.cpp @@ -163,7 +163,7 @@ REPORT_GENERATOR(selected_unit_name, rc) static config unit_type(const unit* u) { if (!u) return config(); - std::string has_variations_prefix = (!u->type().variations().empty() ? ".." : ""); + std::string has_variations_prefix = (u->type().show_variations_in_help() ? ".." : ""); std::ostringstream str, tooltip; str << u->type_name(); tooltip << _("Type: ") << "" << u->type_name() << "\n" diff --git a/src/unit_types.cpp b/src/unit_types.cpp index 4f6a067671ce..46d7f69fc165 100644 --- a/src/unit_types.cpp +++ b/src/unit_types.cpp @@ -1052,6 +1052,18 @@ bool unit_type::has_variation(const std::string& variation_id) const return variations_.find(variation_id) != variations_.end(); } +bool unit_type::show_variations_in_help() const +{ + BOOST_FOREACH(const variations_map::value_type &val, variations_) { + assert(val.second != NULL); + if (!val.second->hide_help()) { + return true; + } + } + + return false; +} + /** * Generates (and returns) a trimmed config suitable for use with units. */ diff --git a/src/unit_types.hpp b/src/unit_types.hpp index aae3638a204a..e6d48e806f8b 100644 --- a/src/unit_types.hpp +++ b/src/unit_types.hpp @@ -288,6 +288,11 @@ class unit_type */ bool has_variation(const std::string& variation_id) const; + /** + * Whether the unit type has at least one help-visible variation. + */ + bool show_variations_in_help() const; + /// Returns the ID of this type's race without the need to build the type. std::string race_id() const { return cfg_["race"]; } //race_->id(); } /// Never returns NULL, but may point to the null race.