The Battle for Wesnoth  1.19.17+dev
Classes | Typedefs | Enumerations | Functions | Variables
help Namespace Reference

Classes

class  help_manager
 The help implementation caches data parsed from the game_config. More...
 
class  topic_generator
 Generate a topic text on the fly. More...
 
class  text_topic_generator
 
class  topic_text
 The text displayed in a topic. More...
 
struct  topic
 A topic contains a title, an id and some text. More...
 
struct  section
 A section contains topics and sections along with title and ID. More...
 
class  has_id
 To be used as a function object to locate sections and topics with a specified ID. More...
 
class  title_less
 To be used as a function object when sorting topic lists on the title. More...
 
class  section_less
 To be used as a function object when sorting section lists on the title. More...
 
class  string_less
 
struct  parse_error
 Thrown when the help system fails to parse something. More...
 
struct  terrain_movement_info
 
class  terrain_topic_generator
 
class  unit_topic_generator
 

Typedefs

typedef std::list< sectionsection_list
 
typedef std::list< topictopic_list
 
typedef std::pair< std::string, std::string > trait_data
 

Enumerations

enum  UNIT_DESCRIPTION_TYPE { FULL_DESCRIPTION , NO_DESCRIPTION , HIDDEN_BUT_SHOW_MACROS }
 

Functions

void show_terrain_description (const terrain_type &t)
 
std::string get_unit_type_help_id (const unit_type &t)
 Given a unit type, find the corresponding help topic's id. More...
 
void show_unit_description (const unit &u)
 
void show_unit_description (const unit_type &t)
 
void show_with_toplevel (const section &toplevel_sec, const std::string &show_topic)
 
void show_help (const std::string &show_topic="")
 Open the help browser. More...
 
bool section_is_referenced (const std::string &section_id, const config &cfg)
 Return true if the section with id section_id is referenced from another section in the config, or the toplevel. More...
 
bool topic_is_referenced (const std::string &topic_id, const config &cfg)
 Return true if the topic with id topic_id is referenced from another section in the config, or the toplevel. More...
 
void parse_config_internal (const config *help_cfg, const config *section_cfg, section &sec, int level=0)
 Recursive function used by parse_config. More...
 
section parse_config (const config *cfg)
 Parse a help config, return the top level section. More...
 
std::vector< topicgenerate_topics (const bool sort_generated, const std::string &generator)
 
void generate_sections (const config *help_cfg, const std::string &generator, section &sec, int level)
 Dispatch generators to their appropriate functions. More...
 
std::string generate_topic_text (const std::string &generator, const config *help_cfg, const section &sec)
 
static std::string time_of_day_bonus_colored (const int time_of_day_bonus)
 
std::vector< topicgenerate_time_of_day_topics (const bool)
 
std::vector< topicgenerate_weapon_special_topics (const bool sort_generated)
 
std::vector< topicgenerate_ability_topics (const bool sort_generated)
 
std::vector< topicgenerate_era_topics (const bool sort_generated, const std::string &era_id)
 
std::vector< topicgenerate_faction_topics (const config &era, const bool sort_generated)
 
std::vector< topicgenerate_trait_topics (const bool sort_generated)
 
std::string make_unit_link (const std::string &type_id)
 return a hyperlink with the unit's name and pointing to the unit page return empty string if this unit is hidden. More...
 
std::vector< std::string > make_unit_links_list (const std::vector< std::string > &type_id_list, bool ordered=false)
 return a list of hyperlinks to unit's pages (ordered or not) More...
 
void generate_races_sections (const config *help_cfg, section &sec, int level)
 
void generate_era_sections (const config *help_cfg, section &sec, int level)
 
void generate_terrain_sections (section &sec, int)
 
void generate_unit_sections (const config *, section &sec, int, const bool, const std::string &race)
 
std::vector< topicgenerate_unit_topics (const bool sort_generated, const std::string &race)
 
UNIT_DESCRIPTION_TYPE description_type (const unit_type &type)
 Return the type of description that should be shown for a unit of the given kind. More...
 
std::string generate_contents_links (const std::string &section_name, config const *help_cfg)
 
std::string generate_contents_links (const section &sec)
 
const topicfind_topic (const section &sec, const std::string &id)
 Search for the topic with the specified identifier in the section and its subsections. More...
 
const sectionfind_section (const section &sec, const std::string &id)
 Search for the section with the specified identifier in the section and its subsections. More...
 
sectionfind_section (section &sec, const std::string &id)
 
std::pair< section, sectiongenerate_contents ()
 Generate the help contents from the configurations given to the manager. More...
 
std::string hidden_symbol (bool hidden)
 
bool is_visible_id (const std::string &id)
 
bool is_valid_id (const std::string &id)
 Return true if the id is valid for user defined topics and sections. More...
 
std::shared_ptr< terrain_type_dataload_terrain_types_data ()
 Load the appropriate terrain types data to use. More...
 
static void print_trait_list (std::stringstream &ss, const std::vector< trait_data > &l)
 

Variables

help::section default_toplevel
 
help::section hidden_sections
 
const int max_section_level = 15
 
const std::string default_show_topic = "..introduction"
 
const std::string unknown_unit_topic = ".unknown_unit"
 
const std::string unit_prefix = "unit_"
 
const std::string terrain_prefix = "terrain_"
 
const std::string race_prefix = "race_"
 
const std::string faction_prefix = "faction_"
 
const std::string era_prefix = "era_"
 
const std::string variation_prefix = "variation_"
 
const std::string ability_prefix = "ability_"
 

Typedef Documentation

◆ section_list

typedef std::list<section> help::section_list

Definition at line 137 of file help_impl.hpp.

◆ topic_list

typedef std::list<topic> help::topic_list

Definition at line 138 of file help_impl.hpp.

◆ trait_data

typedef std::pair<std::string, std::string> help::trait_data

Definition at line 339 of file help_topic_generators.cpp.

Enumeration Type Documentation

◆ UNIT_DESCRIPTION_TYPE

Enumerator
FULL_DESCRIPTION 
NO_DESCRIPTION 

Ignore this unit for documentation purposes.

HIDDEN_BUT_SHOW_MACROS 

Although the unit itself is hidden, traits reachable via this unit are not hidden.

This is a bug workaround - traits are defined by WML macros, and therefore the help system has to use a place where that macro is instanciated to provide the documentation. None of the normal unit types has the "loyal" trait, but there is a hidden unit which does, purely to support the help system.

Definition at line 237 of file help_impl.hpp.

Function Documentation

◆ description_type()

UNIT_DESCRIPTION_TYPE help::description_type ( const unit_type type)

Return the type of description that should be shown for a unit of the given kind.

This method is intended to filter out information about units that should not be shown, for example due to not being encountered.

Definition at line 1096 of file help_impl.cpp.

References game_config::debug, prefs::encountered_units(), FULL_DESCRIPTION, prefs::get(), HIDDEN_BUT_SHOW_MACROS, hotkey::is_scope_active(), NO_DESCRIPTION, and hotkey::SCOPE_EDITOR.

Referenced by generate_ability_topics(), generate_races_sections(), generate_trait_topics(), generate_unit_topics(), generate_weapon_special_topics(), make_unit_link(), and help::unit_topic_generator::operator()().

◆ find_section() [1/2]

const section * help::find_section ( const section sec,
const std::string &  id 
)

Search for the section with the specified identifier in the section and its subsections.

Return the found section or nullptr if none could be found.

Definition at line 1219 of file help_impl.cpp.

References s, and help::section::sections.

Referenced by find_section(), generate_contents(), and generate_races_sections().

◆ find_section() [2/2]

section * help::find_section ( section sec,
const std::string &  id 
)

Definition at line 1235 of file help_impl.cpp.

References find_section().

◆ find_topic()

const topic * help::find_topic ( const section sec,
const std::string &  id 
)

Search for the topic with the specified identifier in the section and its subsections.

Return the found topic, or nullptr if none could be found.

Definition at line 1203 of file help_impl.cpp.

References s, help::section::sections, t, and help::section::topics.

Referenced by generate_contents(), and gui2::dialogs::help_browser::show_topic().

◆ generate_ability_topics()

std::vector< topic > help::generate_ability_topics ( const bool  sort_generated)

◆ generate_contents()

std::pair< section, section > help::generate_contents ( )

Generate the help contents from the configurations given to the manager.

Returns
A pair consisting of the toplevel section and any hidden sections.

Definition at line 1240 of file help_impl.cpp.

References config::add_child(), config::child_or_empty(), config::child_range(), config::clear_children(), default_toplevel, e, find_section(), find_topic(), game_config_manager::get(), hidden_sections, id, wfl::msg(), parse_config(), PLAIN_LOG, section_is_referenced(), and topic_is_referenced().

Referenced by help::help_manager::verify_cache().

◆ generate_contents_links() [1/2]

std::string help::generate_contents_links ( const section sec)

◆ generate_contents_links() [2/2]

std::string help::generate_contents_links ( const std::string &  section_name,
config const *  help_cfg 
)

◆ generate_era_sections()

void help::generate_era_sections ( const config help_cfg,
section sec,
int  level 
)

◆ generate_era_topics()

std::vector< topic > help::generate_era_topics ( const bool  sort_generated,
const std::string &  era_id 
)

◆ generate_faction_topics()

std::vector< topic > help::generate_faction_topics ( const config era,
const bool  sort_generated 
)

◆ generate_races_sections()

void help::generate_races_sections ( const config help_cfg,
section sec,
int  level 
)

◆ generate_sections()

void help::generate_sections ( const config help_cfg,
const std::string &  generator,
section sec,
int  level 
)

◆ generate_terrain_sections()

void help::generate_terrain_sections ( section sec,
int   
)

◆ generate_time_of_day_topics()

std::vector< topic > help::generate_time_of_day_topics ( const bool  )

◆ generate_topic_text()

std::string help::generate_topic_text ( const std::string &  generator,
const config help_cfg,
const section sec 
)

Definition at line 270 of file help_impl.cpp.

References generate_contents_links(), randomness::generator, and utils::split().

Referenced by parse_config_internal().

◆ generate_topics()

std::vector< topic > help::generate_topics ( const bool  sort_generated,
const std::string &  generator 
)

◆ generate_trait_topics()

std::vector< topic > help::generate_trait_topics ( const bool  sort_generated)

◆ generate_unit_sections()

void help::generate_unit_sections ( const config ,
section sec,
int  ,
const bool  ,
const std::string &  race 
)

◆ generate_unit_topics()

std::vector< topic > help::generate_unit_topics ( const bool  sort_generated,
const std::string &  race 
)

◆ generate_weapon_special_topics()

std::vector< topic > help::generate_weapon_special_topics ( const bool  sort_generated)

◆ get_unit_type_help_id()

std::string help::get_unit_type_help_id ( const unit_type t)

Given a unit type, find the corresponding help topic's id.

Definition at line 53 of file help.cpp.

References unit_type_data::find(), hidden_symbol(), unit_type::hide_help(), t, unit_prefix, unit_types, and variation_prefix.

Referenced by show_unit_description(), and unit_type().

◆ hidden_symbol()

std::string help::hidden_symbol ( bool  hidden)

◆ is_valid_id()

bool help::is_valid_id ( const std::string &  id)

Return true if the id is valid for user defined topics and sections.

Some IDs are special, such as toplevel and may not be be defined in the config.

Definition at line 1317 of file help_impl.cpp.

References translation::compare(), hidden_symbol(), and unit_prefix.

Referenced by parse_config_internal().

◆ is_visible_id()

bool help::is_visible_id ( const std::string &  id)

Definition at line 1308 of file help_impl.cpp.

Referenced by generate_contents_links().

◆ load_terrain_types_data()

std::shared_ptr< terrain_type_data > help::load_terrain_types_data ( )

Load the appropriate terrain types data to use.

Definition at line 1337 of file help_impl.cpp.

References game_config_manager::get(), and game_config_manager::terrain_types().

Referenced by generate_terrain_sections(), gui2::get_mp_tooltip(), and help::terrain_topic_generator::operator()().

◆ make_unit_link()

std::string help::make_unit_link ( const std::string &  type_id)

return a hyperlink with the unit's name and pointing to the unit page return empty string if this unit is hidden.

If not yet discovered add the (?) suffix

Definition at line 704 of file help_impl.cpp.

References description_type(), unit_type_data::find(), FULL_DESCRIPTION, unit_type::HELP_INDEXED, markup::make_link(), PLAIN_LOG, unit_prefix, unit_types, and unknown_unit_topic.

Referenced by make_unit_links_list().

◆ make_unit_links_list()

std::vector< std::string > help::make_unit_links_list ( const std::vector< std::string > &  type_id_list,
bool  ordered 
)

return a list of hyperlinks to unit's pages (ordered or not)

Definition at line 730 of file help_impl.cpp.

References make_unit_link().

Referenced by generate_faction_topics().

◆ parse_config()

section help::parse_config ( const config cfg)

Parse a help config, return the top level section.

Return an empty section if cfg is nullptr.

Definition at line 212 of file help_impl.cpp.

References cfg, config::optional_child(), and parse_config_internal().

Referenced by generate_contents().

◆ parse_config_internal()

void help::parse_config_internal ( const config help_cfg,
const config section_cfg,
section sec,
int  level 
)

◆ print_trait_list()

static void help::print_trait_list ( std::stringstream &  ss,
const std::vector< trait_data > &  l 
)
static

Definition at line 342 of file help_topic_generators.cpp.

References i, and markup::make_link().

Referenced by help::unit_topic_generator::operator()().

◆ section_is_referenced()

bool help::section_is_referenced ( const std::string &  section_id,
const config cfg 
)

Return true if the section with id section_id is referenced from another section in the config, or the toplevel.

Definition at line 76 of file help_impl.cpp.

References cfg, config::child_range(), utils::contains(), config::optional_child(), and utils::quoted_split().

Referenced by generate_contents().

◆ show_help()

void help::show_help ( const std::string &  show_topic = "")

◆ show_terrain_description()

void help::show_terrain_description ( const terrain_type t)

◆ show_unit_description() [1/2]

void help::show_unit_description ( const unit u)

◆ show_unit_description() [2/2]

void help::show_unit_description ( const unit_type t)

Definition at line 84 of file help.cpp.

References get_unit_type_help_id(), show_help(), and t.

◆ show_with_toplevel()

void help::show_with_toplevel ( const section toplevel_sec,
const std::string &  show_topic 
)

Definition at line 123 of file help.cpp.

Referenced by show_help().

◆ time_of_day_bonus_colored()

static std::string help::time_of_day_bonus_colored ( const int  time_of_day_bonus)
static

Definition at line 304 of file help_impl.cpp.

References markup::span_color().

Referenced by generate_time_of_day_topics().

◆ topic_is_referenced()

bool help::topic_is_referenced ( const std::string &  topic_id,
const config cfg 
)

Return true if the topic with id topic_id is referenced from another section in the config, or the toplevel.

Definition at line 94 of file help_impl.cpp.

References cfg, config::child_range(), utils::contains(), config::optional_child(), and utils::quoted_split().

Referenced by generate_contents().

Variable Documentation

◆ ability_prefix

const std::string help::ability_prefix = "ability_"

◆ default_show_topic

const std::string help::default_show_topic = "..introduction"

Definition at line 66 of file help_impl.cpp.

◆ default_toplevel

help::section help::default_toplevel

Definition at line 60 of file help_impl.cpp.

Referenced by generate_contents().

◆ era_prefix

const std::string help::era_prefix = "era_"

Definition at line 72 of file help_impl.cpp.

Referenced by generate_era_sections(), and generate_era_topics().

◆ faction_prefix

const std::string help::faction_prefix = "faction_"

Definition at line 71 of file help_impl.cpp.

Referenced by generate_faction_topics().

◆ hidden_sections

help::section help::hidden_sections

Definition at line 62 of file help_impl.cpp.

Referenced by generate_contents().

◆ max_section_level

const int help::max_section_level = 15

Definition at line 64 of file help_impl.cpp.

Referenced by parse_config_internal().

◆ race_prefix

const std::string help::race_prefix = "race_"

Definition at line 70 of file help_impl.cpp.

Referenced by generate_faction_topics(), and generate_races_sections().

◆ terrain_prefix

const std::string help::terrain_prefix = "terrain_"

◆ unit_prefix

const std::string help::unit_prefix = "unit_"

◆ unknown_unit_topic

const std::string help::unknown_unit_topic = ".unknown_unit"

Definition at line 67 of file help_impl.cpp.

Referenced by make_unit_link(), and help::unit_topic_generator::operator()().

◆ variation_prefix

const std::string help::variation_prefix = "variation_"