The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Typedefs | Enumerations | Functions | Variables
help Namespace Reference

Classes

class  about_text_formatter
 Class to be used as a function object when generating the about text. More...
 
struct  create_section
 
struct  delete_section
 
class  has_id
 To be used as a function object to locate sections and topics with a specified ID. More...
 
class  help_browser
 A help browser widget. More...
 
class  help_button
 
struct  help_manager
 
class  help_menu
 The menu to the left in the help browser, where topics can be navigated through and chosen. More...
 
class  help_text_area
 The area where the content is shown in the help browser. More...
 
struct  parse_error
 Thrown when the help system fails to parse something. More...
 
struct  section
 A section contains topics and sections along with title and ID. More...
 
class  section_less
 To be used as a function object when sorting section lists on the title. More...
 
class  string_less
 
class  terrain_topic_generator
 
class  text_topic_generator
 
class  title_less
 To be used as a function object when sorting topic lists on the title. More...
 
struct  topic
 A topic contains a title, an id and some text. More...
 
class  topic_generator
 Generate a topic text on the fly. More...
 
class  topic_text
 The text displayed in a topic. More...
 
class  unit_topic_generator
 

Typedefs

typedef std::vector< section * > section_list
 
typedef std::list< topictopic_list
 
typedef std::vector
< std::vector< std::pair
< std::string, unsigned int > > > 
table_spec
 
typedef
t_translation::t_list::const_iterator 
t_it
 
typedef std::pair< std::string,
std::string
trait_data
 

Enumerations

enum  UNIT_DESCRIPTION_TYPE { FULL_DESCRIPTION, NO_DESCRIPTION, NON_REVEALING_DESCRIPTION }
 

Functions

void show_unit_description (CVideo &video, const unit &u)
 
void show_terrain_description (CVideo &video, const terrain_type &t)
 
void show_unit_description (CVideo &video, const unit_type &t)
 
void show_help (CVideo &video, const std::string &show_topic, int xloc, int yloc)
 Open the help browser, show topic with id show_topic. More...
 
void show_unit_help (CVideo &video, const std::string &show_topic, bool has_variations, bool hidden, int xloc, int yloc)
 Open the help browser, show unit with id unit_id. More...
 
void show_terrain_help (CVideo &video, const std::string &show_topic, bool hidden, int xloc, int yloc)
 Open the help browser, show terrain with id terrain_id. More...
 
void show_variation_help (CVideo &video, const std::string &unit, const std::string &variation, bool hidden, int xloc, int yloc)
 Open the help browser, show the variation of the unit matching. More...
 
void show_help (CVideo &video, const section &toplevel_sec, const std::string &show_topic, int xloc, int yloc)
 Open a help dialog using a toplevel other than the default. 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, const std::vector< topic > &generated_topics)
 
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::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::stringmake_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 (const config *, section &sec, int)
 
void generate_unit_sections (const config *, section &sec, int level, 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_about_text ()
 
std::string generate_contents_links (const std::string &section_name, config const *help_cfg)
 
std::string generate_contents_links (const section &sec, const std::vector< topic > &topics)
 
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...
 
std::vector< std::stringparse_text (const std::string &text)
 Parse a text string. More...
 
std::string convert_to_wml (const std::string &element_name, const std::string &contents)
 Convert the contents to wml attributes, surrounded within [element_name]...[/element_name]. More...
 
SDL_Color string_to_color (const std::string &s)
 Return the color the string represents. More...
 
std::vector< std::stringsplit_in_width (const std::string &s, const int font_size, const unsigned width)
 Make a best effort to word wrap s. All parts are less than width. More...
 
std::string remove_first_space (const std::string &text)
 
std::string get_first_word (const std::string &s)
 Return the first word in s, not removing any spaces in the start of it. More...
 
void generate_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...
 
unsigned image_width (const std::string &filename)
 
void push_tab_pair (std::vector< std::pair< std::string, unsigned int > > &v, const std::string &s)
 
std::string generate_table (const table_spec &tab, const unsigned int spacing)
 
std::string escape (const std::string &s)
 Prepend all chars with meaning inside attributes with a backslash. More...
 
tdata_cache load_terrain_types_data ()
 Load the appropriate terrain types data to use. More...
 
std::string make_link (const std::string &text, const std::string &dst)
 
std::string jump_to (const unsigned pos)
 
std::string jump (const unsigned amount)
 
std::string bold (const std::string &s)
 
static std::string best_str (bool best)
 
static std::string print_behavior_description (t_it start, t_it end, const tdata_cache &tdata, bool first_level=true, bool begin_best=true)
 
static void print_trait_list (std::stringstream &ss, const std::vector< trait_data > &l)
 

Variables

config dummy_cfg
 
const configgame_cfg = nullptr
 
help::section toplevel
 
help::section hidden_sections
 
int last_num_encountered_units = -1
 
int last_num_encountered_terrains = -1
 
bool last_debug_state = game_config::debug
 
std::vector< std::stringempty_string_vector
 
const int max_section_level = 15
 
const int title_size = font::SIZE_LARGE
 
const int title2_size = font::SIZE_15
 
const int box_width = 2
 
const int normal_font_size = font::SIZE_NORMAL
 
const unsigned max_history = 100
 
const std::string topic_img = "help/topic.png"
 
const std::string closed_section_img = "help/closed_section.png"
 
const std::string open_section_img = "help/open_section.png"
 
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_"
 

Typedef Documentation

typedef std::vector<section *> help::section_list

Definition at line 59 of file help_impl.hpp.

typedef t_translation::t_list::const_iterator help::t_it

Definition at line 52 of file help_topic_generators.cpp.

typedef std::vector<std::vector<std::pair<std::string, unsigned int > > > help::table_spec

Definition at line 402 of file help_impl.hpp.

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

Definition at line 140 of file help_impl.hpp.

Definition at line 219 of file help_topic_generators.cpp.

Enumeration Type Documentation

Enumerator
FULL_DESCRIPTION 
NO_DESCRIPTION 
NON_REVEALING_DESCRIPTION 

Definition at line 250 of file help_impl.hpp.

Function Documentation

static std::string help::best_str ( bool  best)
static

Definition at line 45 of file help_topic_generators.cpp.

References _().

Referenced by print_behavior_description().

std::string help::bold ( const std::string s)
inline
std::string help::convert_to_wml ( const std::string element_name,
const std::string contents 
)

Convert the contents to wml attributes, surrounded within [element_name]...[/element_name].

Return the resulting WML.

Definition at line 1155 of file help_impl.cpp.

References c, game_logic::msg(), and pos.

Referenced by parse_text().

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 902 of file help_impl.cpp.

References game_config::debug, preferences::encountered_units(), FULL_DESCRIPTION, unit_type::id(), hotkey::is_scope_active(), NO_DESCRIPTION, hotkey::SCOPE_EDITOR, and preferences::show_all_units_in_help().

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

std::string help::escape ( const std::string s)

Prepend all chars with meaning inside attributes with a backslash.

Definition at line 1437 of file help_impl.cpp.

References utils::escape().

Referenced by bold(), make_link(), help::unit_topic_generator::operator()(), and help::about_text_formatter::operator()().

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 1066 of file help_impl.cpp.

References help::section::sections.

Referenced by generate_contents().

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 1049 of file help_impl.cpp.

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

Referenced by generate_contents(), help::help_browser::handle_event(), help::help_text_area::handle_ref_cfg(), help::help_menu::process(), and help::help_browser::show_topic().

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

Definition at line 916 of file help_impl.cpp.

References about::get_text(), utils::join(), and schema_validation::remove.

Referenced by generate_topic_text().

void help::generate_contents ( )
std::string help::generate_contents_links ( const std::string section_name,
config const *  help_cfg 
)
std::string help::generate_contents_links ( const section &  sec,
const std::vector< topic > &  topics 
)

Definition at line 965 of file help_impl.cpp.

References is_visible_id(), make_link(), and help::section::sections.

void help::generate_era_sections ( const config help_cfg,
section &  sec,
int  level 
)
std::vector< topic > help::generate_era_topics ( const bool  sort_generated,
const std::string era_id 
)
std::vector< topic > help::generate_faction_topics ( const config era,
const bool  sort_generated 
)
void help::generate_races_sections ( const config help_cfg,
section &  sec,
int  level 
)
void help::generate_sections ( const config help_cfg,
const std::string generator,
section &  sec,
int  level 
)

Dispatch generators to their appropriate functions.

Definition at line 287 of file help_impl.cpp.

References DBG_HP, generate_era_sections(), generate_races_sections(), generate_terrain_sections(), generate_unit_sections(), utils::split(), utils::STRIP_SPACES, and WRN_HP.

Referenced by parse_config_internal().

std::string help::generate_table ( const table_spec &  tab,
const unsigned int  spacing 
)

Definition at line 1394 of file help_impl.cpp.

References i, and jump_to().

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

void help::generate_terrain_sections ( const config ,
section &  sec,
int   
)
std::vector< topic > help::generate_time_of_day_topics ( const bool  )

Definition at line 357 of file help_impl.cpp.

References jump(), jump_to(), make_link(), N_, tod_manager::times(), resources::tod_manager, and toplevel.

Referenced by generate_topics().

std::string help::generate_topic_text ( const std::string generator,
const config help_cfg,
const section &  sec,
const std::vector< topic > &  generated_topics 
)
std::vector< topic > help::generate_topics ( const bool  sort_generated,
const std::string generator 
)
void help::generate_unit_sections ( const config ,
section &  sec,
int  level,
const bool  ,
const std::string race 
)
std::vector< topic > help::generate_unit_topics ( const bool  sort_generated,
const std::string race 
)
std::vector< topic > help::generate_weapon_special_topics ( const bool  sort_generated)
std::string help::get_first_word ( const std::string s)

Return the first word in s, not removing any spaces in the start of it.

Definition at line 1257 of file help_impl.cpp.

References ucs4::iterator_base< string_type, update_implementation >::end(), font::is_cjk_char(), and unicode_cast().

Referenced by help::help_text_area::add_text_item().

std::string help::hidden_symbol ( bool  hidden)
unsigned help::image_width ( const std::string filename)
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 1358 of file help_impl.cpp.

References gui2::event::find(), and hidden_symbol().

Referenced by parse_config_internal().

bool help::is_visible_id ( const std::string id)
std::string help::jump ( const unsigned  amount)
inline
std::string help::jump_to ( const unsigned  pos)
inline
tdata_cache help::load_terrain_types_data ( )
std::string help::make_link ( const std::string text,
const std::string dst 
)
inline
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 626 of file help_impl.cpp.

References description_type(), unit_type_data::find(), FULL_DESCRIPTION, unit_type::HELP_INDEXED, unit_type::hide_help(), unit_type::id(), make_link(), unit_type::show_variations_in_help(), unit_type::type_name(), unit_types, and unknown_unit_topic.

Referenced by 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 652 of file help_impl.cpp.

References make_unit_link(), and sort().

Referenced by generate_faction_topics().

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 250 of file help_impl.cpp.

References config::child(), and parse_config_internal().

Referenced by generate_contents().

void help::parse_config_internal ( const config help_cfg,
const config section_cfg,
section &  sec,
int  level 
)
std::vector< std::string > help::parse_text ( const std::string text)

Parse a text string.

Return a vector with the different parts of the text. Each markup item is a separate part while the text between markups are separate parts.

Definition at line 1082 of file help_impl.cpp.

References c, convert_to_wml(), game_logic::msg(), desktop::notifications::OTHER, and pos.

Referenced by help::topic_text::parsed_text().

static std::string help::print_behavior_description ( t_it  start,
t_it  end,
const tdata_cache tdata,
bool  first_level = true,
bool  begin_best = true 
)
static
static void help::print_trait_list ( std::stringstream &  ss,
const std::vector< trait_data > &  l 
)
static

Definition at line 222 of file help_topic_generators.cpp.

References i, and make_link().

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

void help::push_tab_pair ( std::vector< std::pair< std::string, unsigned int > > &  v,
const std::string s 
)

Definition at line 1389 of file help_impl.cpp.

References font::line_width().

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

std::string help::remove_first_space ( const std::string text)

Definition at line 1249 of file help_impl.cpp.

Referenced by help::help_text_area::add_text_item().

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 95 of file help_impl.cpp.

References config::child(), config::child_range(), gui2::event::find(), and utils::quoted_split().

Referenced by generate_contents().

void help::show_help ( CVideo video,
const std::string show_topic,
int  xloc,
int  yloc 
)

Open the help browser, show topic with id show_topic.

Open the help browser.

If show_topic is the empty string, the default topic will be shown.

The help browser will have the topic with id show_topic open if it is not the empty string. The default topic will be shown if show_topic is the empty string.

Definition at line 117 of file help.cpp.

References toplevel.

Referenced by tooltips::click(), do_gameloop(), gui2::taddon_connect::help_button_callback(), game_lua_kernel::intf_open_help(), help::help_button::show_help(), gui2::tunit_recruit::show_help(), events::menu_handler::show_help(), gui2::taddon_list::show_help(), editor::editor_controller::show_help(), show_terrain_help(), show_unit_help(), show_variation_help(), and editor::editor_controller::unit_description().

void help::show_help ( CVideo video,
const section &  toplevel_sec,
const std::string show_topic,
int  xloc,
int  yloc 
)
void help::show_terrain_description ( CVideo video,
const terrain_type t 
)
void help::show_terrain_help ( CVideo video,
const std::string show_topic,
bool  hidden,
int  xloc,
int  yloc 
)

Open the help browser, show terrain with id terrain_id.

wrapper to add terrain prefix and hiding symbol

If show_topic is the empty string, the default topic will be shown.

Definition at line 138 of file help.cpp.

References hidden_symbol(), show_help(), terrain_prefix, and toplevel.

Referenced by show_terrain_description().

void help::show_unit_description ( CVideo video,
const unit u 
)
void help::show_unit_description ( CVideo video,
const unit_type t 
)
void help::show_unit_help ( CVideo video,
const std::string show_topic,
bool  has_variations,
bool  hidden,
int  xloc,
int  yloc 
)

Open the help browser, show unit with id unit_id.

wrapper to add unit prefix and hiding symbol

If show_topic is the empty string, the default topic will be shown.

Definition at line 127 of file help.cpp.

References hidden_symbol(), show_help(), toplevel, and unit_prefix.

Referenced by gui2::tunit_attack::profile_button_callback(), gui2::tunit_preview_pane::profile_button_callback(), show_unit_description(), and editor::editor_controller::unit_description().

void help::show_variation_help ( CVideo video,
const std::string unit,
const std::string variation,
bool  hidden,
int  xloc,
int  yloc 
)

Open the help browser, show the variation of the unit matching.

wrapper to add variation prefix and hiding symbol

Definition at line 148 of file help.cpp.

References hidden_symbol(), show_help(), toplevel, and variation_prefix.

Referenced by show_unit_description().

std::vector< std::string > help::split_in_width ( const std::string s,
const int  font_size,
const unsigned  width 
)

Make a best effort to word wrap s. All parts are less than width.

Definition at line 1230 of file help_impl.cpp.

References _(), and font::word_wrap_text().

Referenced by help::help_text_area::add_text_item().

SDL_Color help::string_to_color ( const std::string s)

Return the color the string represents.

Return font::NORMAL_COLOR if the string is empty or can't be matched against any other color.

Definition at line 1206 of file help_impl.cpp.

Referenced by help::help_text_area::handle_format_cfg(), game_lua_kernel::intf_float_label(), game_lua_kernel::intf_print(), and terrain_label::read().

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 119 of file help_impl.cpp.

References config::child(), config::child_range(), gui2::event::find(), and utils::quoted_split().

Referenced by generate_contents().

Variable Documentation

const int help::box_width = 2
const std::string help::closed_section_img = "help/closed_section.png"

Definition at line 83 of file help_impl.cpp.

Referenced by help::help_menu::get_string_to_show(), and help::help_menu::process().

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

Definition at line 86 of file help_impl.cpp.

Referenced by show_help().

config help::dummy_cfg

Definition at line 74 of file help_impl.cpp.

Referenced by game_display::create_dummy_display(), and generate_contents().

std::vector< std::string > help::empty_string_vector

Definition at line 75 of file help_impl.cpp.

Referenced by gui::dialog::get_empty_menu().

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

Definition at line 92 of file help_impl.cpp.

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

Definition at line 91 of file help_impl.cpp.

const config * help::game_cfg = nullptr
help::section help::hidden_sections

Definition at line 68 of file help_impl.cpp.

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

bool help::last_debug_state = game_config::debug

Definition at line 72 of file help_impl.cpp.

Referenced by show_help().

int help::last_num_encountered_terrains = -1

Definition at line 71 of file help_impl.cpp.

Referenced by show_help(), and help::help_manager::~help_manager().

int help::last_num_encountered_units = -1

Definition at line 70 of file help_impl.cpp.

Referenced by show_help(), and help::help_manager::~help_manager().

const unsigned help::max_history = 100
const int help::max_section_level = 15

Definition at line 76 of file help_impl.cpp.

const int help::normal_font_size = font::SIZE_NORMAL
const std::string help::open_section_img = "help/open_section.png"

Definition at line 84 of file help_impl.cpp.

Referenced by help::help_menu::get_string_to_show(), and help::help_menu::process().

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

Definition at line 90 of file help_impl.cpp.

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

Definition at line 89 of file help_impl.cpp.

Referenced by help::terrain_topic_generator::operator()(), and show_terrain_help().

const int help::title2_size = font::SIZE_15

Definition at line 78 of file help_impl.cpp.

Referenced by help::help_text_area::handle_header_cfg().

const int help::title_size = font::SIZE_LARGE

Definition at line 77 of file help_impl.cpp.

Referenced by help::help_text_area::set_items().

const std::string help::topic_img = "help/topic.png"

Definition at line 82 of file help_impl.cpp.

Referenced by help::help_menu::get_string_to_show().

help::section help::toplevel
const std::string help::unit_prefix = "unit_"
const std::string help::unknown_unit_topic = ".unknown_unit"
const std::string help::variation_prefix = "variation_"

Definition at line 93 of file help_impl.cpp.

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