32 #ifndef HELP_IMPL_INCLUDED
33 #define HELP_IMPL_INCLUDED
44 #include <boost/shared_ptr.hpp>
51 namespace help {
struct section; }
107 const std::vector<std::string>&
parsed_text()
const;
190 return strcoll(t1.
title.c_str(), t2.
title.c_str()) < 0; }
198 return strcoll(s1->
title.c_str(), s2->
title.c_str()) < 0; }
205 return strcoll(s1.c_str(), s2.c_str()) < 0;
234 const section &sec,
const std::vector<topic>& generated_topics);
244 const std::vector<std::string>& type_id_list,
bool ordered =
false);
269 section &sec,
int level=0);
362 if (s.empty())
return s;
365 return " \n<header>text='" +
help::escape(s.substr(1)) +
"'</header>";
383 std::stringstream ss;
384 ss <<
"<jump>to=" << pos <<
"</jump>";
390 std::stringstream ss;
391 ss <<
"<jump>amount=" << amount <<
"</jump>";
397 std::stringstream ss;
402 typedef std::vector<std::vector<std::pair<std::string, unsigned int > > >
table_spec;
std::string jump_to(const unsigned pos)
section parse_config(const config *cfg)
Parse a help config, return the top level section.
bool operator()(const std::string &s1, const std::string &s2) const
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
std::vector< topic > generate_unit_topics(const bool sort_generated, const std::string &race)
const std::string era_prefix
void generate_unit_sections(const config *, section &sec, int level, const bool, const std::string &race)
const std::string topic_img
void push_tab_pair(std::vector< std::pair< std::string, unsigned int > > &v, const std::string &s)
bool operator==(const section &) const
Two sections are equal if their IDs are equal.
const std::vector< std::string > & parsed_text() const
bool operator()(const section &s)
const std::string closed_section_img
std::string remove_first_space(const std::string &text)
A section contains topics and sections along with title and ID.
const std::string unknown_unit_topic
const std::string race_prefix
rng * generator
This generator is automatically synced during synced context.
std::string generate_topic_text(const std::string &generator, const config *help_cfg, const section &sec, const std::vector< topic > &generated_topics)
GLuint GLuint GLsizei GLenum type
topic(const std::string &_title, const std::string &_id, const std::string &_text)
int relative_size(int size)
text_topic_generator(std::string const &t)
Thrown when the help system fails to parse something.
parse_error(const std::string &msg)
std::vector< std::string > empty_string_vector
topic_text(std::string const &t)
bool operator<(const topic &) const
Comparison on the ID.
std::vector< section * > section_list
std::string operator()(const std::string &s)
virtual std::string operator()() const
const int normal_font_size
topic_generator * generator_
unsigned image_width(const std::string &filename)
const std::string terrain_prefix
int last_num_encountered_terrains
bool is_visible_id(const std::string &id)
std::string generate_about_text()
std::vector< topic > generate_weapon_special_topics(const bool sort_generated)
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::string bold(const std::string &s)
topic_text(topic_generator *g)
section * operator()(const section &s)
void generate_sections(const config *help_cfg, const std::string &generator, section &sec, int level)
Dispatch generators to their appropriate functions.
help::section hidden_sections
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.
To be used as a function object to locate sections and topics with a specified ID.
The text displayed in a topic.
std::string generate_table(const table_spec &tab, const unsigned int spacing)
std::string hidden_symbol(bool hidden)
bool operator()(const topic &t1, const topic &t2)
std::vector< topic > generate_era_topics(const bool sort_generated, const std::string &era_id)
std::vector< std::vector< std::pair< std::string, unsigned int > > > table_spec
void generate_terrain_sections(const config *, section &sec, int)
std::vector< topic > generate_faction_topics(const config &era, const bool sort_generated)
tdata_cache load_terrain_types_data()
Load the appropriate terrain types data to use.
std::vector< std::string > parsed_text_
std::list< topic > topic_list
bool operator()(const section *s1, const section *s2)
const std::string ¶meters float amount
void parse_config_internal(const config *help_cfg, const config *section_cfg, section &sec, int level)
Recursive function used by parse_config.
topic(const std::string &_title, const std::string &_id, topic_generator *g)
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...
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...
To be used as a function object when sorting section lists on the title.
const std::string variation_prefix
topic_text & operator=(topic_generator *g)
bool operator!=(const topic &t) const
int last_num_encountered_units
bool operator()(const section *s)
std::string make_link(const std::string &text, const std::string &dst)
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].
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
void generate_races_sections(const config *help_cfg, section &sec, int level)
void operator()(section *s)
std::string escape(const std::string &s)
Prepend all chars with meaning inside attributes with a backslash.
std::vector< std::string > parse_text(const std::string &text)
Parse a text string.
const unsigned max_history
std::vector< topic > generate_time_of_day_topics(const bool)
std::string generate_contents_links(const std::string §ion_name, config const *help_cfg)
const std::string faction_prefix
std::string jump(const unsigned amount)
has_id(const std::string &id)
const std::string default_show_topic
void generate_contents()
Generate the help contents from the configurations given to the manager.
Base class for all the errors encountered by the engine.
std::vector< topic > generate_topics(const bool sort_generated, const std::string &generator)
virtual std::string operator()() const =0
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.
bool operator<(const section &) const
Comparison on the ID.
Generate a topic text on the fly.
bool operator()(const topic &t)
A topic contains a title, an id and some text.
boost::shared_ptr< terrain_type_data > tdata_cache
GLint GLint GLint GLint GLint GLint GLsizei width
Class to be used as a function object when generating the about text.
SDL_Color string_to_color(const std::string &cmp_str)
Return the color the string represents.
virtual ~topic_generator()
topic(const std::string &_title, 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.
A config object defines a single node in a WML file, with access to child nodes.
std::string get_first_word(const std::string &s)
Return the first word in s, not removing any spaces in the start of it.
bool operator==(const topic &) const
Two topics are equal if their IDs are equal.
void add_section(const section &s)
Allocate memory for and add the section.
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. ...
std::vector< topic > generate_ability_topics(const bool sort_generated)
void generate_era_sections(const config *help_cfg, section &sec, int level)
GLsizei const GLcharARB ** string
const int max_section_level
To be used as a function object when sorting topic lists on the title.
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. All parts are less than width.
section * operator()(const section *s)
section & operator=(const section &)