48 #include <boost/logic/tribool.hpp>
108 const std::vector<std::string>&
parsed_text()
const;
121 topic(
const std::string &_title,
const std::string &_id) :
128 topic(
const std::string &_title,
const std::string &_id,
const std::string &_text)
130 topic(
const std::string &_title,
const std::string &_id, std::shared_ptr<topic_generator>
g)
207 bool operator() (
const std::string &s1,
const std::string &s2)
const {
226 const section &sec,
const std::vector<topic>& generated_topics);
237 const std::vector<std::string>& type_id_list,
bool ordered =
false);
280 section &sec,
int level=0);
298 const topic *
find_topic(
const section &sec,
const std::string &
id);
305 const section *
find_section(
const section &sec,
const std::string &
id);
306 section *
find_section(section &sec,
const std::string &
id);
313 std::vector<std::string>
parse_text(
const std::string &text);
319 std::string
convert_to_wml(
const std::string &element_name,
const std::string &contents);
328 std::vector<std::string>
split_in_width(
const std::string &
s,
const int font_size,
const unsigned width);
333 std::string
escape(
const std::string &
s);
386 inline std::string
make_link(
const std::string& text,
const std::string& dst)
392 inline std::string
jump_to(
const unsigned pos)
394 std::stringstream ss;
395 ss <<
"<jump>to=" << pos <<
"</jump>";
399 inline std::string
jump(
const unsigned amount)
401 std::stringstream ss;
402 ss <<
"<jump>amount=" << amount <<
"</jump>";
406 inline std::string
bold(
const std::string &
s)
408 std::stringstream ss;
414 typedef std::pair< std::string, unsigned >
item;
427 void push_tab_pair(std::vector<help::item> &v,
const std::string &
s,
const std::optional<std::string> &
image = {},
unsigned padding = 0);
A config object defines a single node in a WML file, with access to child nodes.
A class grating read only view to a vector of config objects, viewed as one config with all children ...
To be used as a function object to locate sections and topics with a specified ID.
has_id(const std::string &id)
bool operator()(const topic &t)
bool operator()(const section &s)
bool operator()(const section *s)
To be used as a function object when sorting section lists on the title.
bool operator()(const section &s1, const section &s2)
bool operator()(const std::string &s1, const std::string &s2) const
text_topic_generator(const std::string &t)
virtual std::string operator()() const
To be used as a function object when sorting topic lists on the title.
bool operator()(const topic &t1, const topic &t2)
Generate a topic text on the fly.
virtual std::string operator()() const =0
virtual ~topic_generator()
topic_generator()=default
The text displayed in a topic.
topic_text(const topic_text &t)=default
topic_text & operator=(const topic_text &t)=default
const std::vector< std::string > & parsed_text() const
topic_text(std::shared_ptr< topic_generator > g)
std::shared_ptr< topic_generator > generator_
topic_text & operator=(topic_text &&t)=default
std::vector< std::string > parsed_text_
topic_text(const std::string &t)
topic_text(topic_text &&t)=default
Contains the database of all known terrain types, both those defined explicitly by WML [terrain_type]...
A single unit type that the player may recruit.
std::string id
Text to match against addon_info.tags()
int relative_size(int size)
std::string get_first_word(const std::string &s)
Return the first word in s, not removing any spaces in the start of it.
std::vector< topic > generate_unit_topics(const bool sort_generated, const std::string &race)
std::string hidden_symbol(bool hidden)
void generate_unit_sections(const config *, section &sec, int, const bool, const std::string &race)
@ HIDDEN_BUT_SHOW_MACROS
Although the unit itself is hidden, traits reachable via this unit are not hidden.
@ NO_DESCRIPTION
Ignore this unit for documentation purposes.
std::string bold(const std::string &s)
std::string make_link(const std::string &text, const std::string &dst)
void generate_races_sections(const config *help_cfg, section &sec, int level)
std::string escape(const std::string &s)
Prepend all chars with meaning inside attributes with a backslash.
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,...
std::vector< topic > generate_time_of_day_topics(const bool)
int last_num_encountered_units
void generate_terrain_sections(section &sec, int)
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 uni...
const std::string open_section_img
const std::string unit_prefix
unsigned image_width(const std::string &filename)
const std::string variation_prefix
void parse_config_internal(const config *help_cfg, const config *section_cfg, section &sec, int level)
Recursive function used by parse_config.
bool is_visible_id(const std::string &id)
const std::string closed_section_img
std::vector< topic > generate_faction_topics(const config &era, const bool sort_generated)
void generate_sections(const config *help_cfg, const std::string &generator, section &sec, int level)
Dispatch generators to their appropriate functions.
const std::string topic_img
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.
const std::string race_prefix
const std::string ability_prefix
std::vector< std::vector< help::item > > table_spec
std::vector< std::string > 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)
std::vector< topic > generate_topics(const bool sort_generated, const std::string &generator)
const section * find_section(const section &sec, const std::string &id)
Search for the section with the specified identifier in the section and its subsections.
void push_tab_pair(std::vector< help::item > &v, const std::string &s, const std::optional< std::string > &image, unsigned padding)
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].
std::pair< std::string, unsigned > item
const int normal_font_size
void generate_contents()
Generate the help contents from the configurations given to the manager.
std::string generate_table(const table_spec &tab, const unsigned int spacing)
const std::string terrain_prefix
std::vector< topic > generate_weapon_special_topics(const bool sort_generated)
std::vector< topic > generate_ability_topics(const bool sort_generated)
std::string remove_first_space(const std::string &text)
std::string jump_to(const unsigned pos)
const std::string unknown_unit_topic
const int max_section_level
const unsigned max_history
std::vector< std::string > empty_string_vector
bool section_is_referenced(const std::string §ion_id, const config &cfg)
Return true if the section with id section_id is referenced from another section in the config,...
std::shared_ptr< terrain_type_data > load_terrain_types_data()
Load the appropriate terrain types data to use.
std::string generate_topic_text(const std::string &generator, const config *help_cfg, const section &sec, const std::vector< topic > &generated_topics)
bool is_valid_id(const std::string &id)
Return true if the id is valid for user defined topics and sections.
boost::tribool last_debug_state
std::string generate_contents_links(const std::string §ion_name, config const *help_cfg)
std::vector< std::string > split_in_width(const std::string &s, const int font_size, const unsigned width)
Make a best effort to word wrap s.
std::list< topic > topic_list
help::section default_toplevel
const topic * find_topic(const section &sec, const std::string &id)
Search for the topic with the specified identifier in the section and its subsections.
color_t string_to_color(const std::string &cmp_str)
Return the color the string represents.
std::string jump(const unsigned amount)
section parse_config(const config *cfg)
Parse a help config, return the top level section.
std::vector< topic > generate_era_topics(const bool sort_generated, const std::string &era_id)
const game_config_view * game_cfg
int last_num_encountered_terrains
std::list< section > section_list
help::section hidden_sections
std::vector< topic > generate_trait_topics(const bool sort_generated)
std::vector< std::string > parse_text(const std::string &text)
Parse a text string.
const std::string default_show_topic
void generate_era_sections(const config *help_cfg, section &sec, int level)
const std::string era_prefix
const std::string faction_prefix
Functions to load and save images from/to disk.
rng * generator
This generator is automatically synced during synced context.
int compare(const std::string &s1, const std::string &s2)
Case-sensitive lexicographical comparison.
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
The basic class for representing 8-bit RGB or RGBA colour values.
Base class for all the errors encountered by the engine.
Thrown when the help system fails to parse something.
parse_error(const std::string &msg)
A section contains topics and sections along with title and ID.
bool operator<(const section &) const
Comparison on the ID.
void add_section(const section &s)
Allocate memory for and add the section.
bool operator==(const section &) const
Two sections are equal if their IDs are equal.
A topic contains a title, an id and some text.
topic(const std::string &_title, const std::string &_id, std::shared_ptr< topic_generator > g)
bool operator==(const topic &) const
Two topics are equal if their IDs are equal.
topic(const std::string &_title, const std::string &_id, const std::string &_text)
bool operator!=(const topic &t) const
bool operator<(const topic &) const
Comparison on the ID.
topic(const std::string &_title, const std::string &_id)
static map_location::DIRECTION s