48 #include <boost/shared_ptr.hpp>
56 #define WRN_DP LOG_STREAM(warn, log_display)
59 #define WRN_HP LOG_STREAM(warn, log_help)
60 #define DBG_HP LOG_STREAM(debug, log_help)
99 const std::vector<std::string> toplevel_refs
101 if (
std::find(toplevel_refs.begin(), toplevel_refs.end(), section_id)
102 != toplevel_refs.end()) {
109 const std::vector<std::string> sections_refd
111 if (
std::find(sections_refd.begin(), sections_refd.end(), section_id)
112 != sections_refd.end()) {
121 if (
const config &toplevel = cfg.
child(
"toplevel"))
123 const std::vector<std::string> toplevel_refs
125 if (
std::find(toplevel_refs.begin(), toplevel_refs.end(), topic_id)
126 != toplevel_refs.end()) {
133 const std::vector<std::string> topics_refd
135 if (
std::find(topics_refd.begin(), topics_refd.end(), topic_id)
136 != topics_refd.end()) {
146 if (level > max_section_level) {
147 std::cerr <<
"Maximum section depth has been reached. Maybe circular dependency?"
150 else if (section_cfg !=
nullptr) {
153 std::string id = level == 0 ?
"toplevel" : (*section_cfg)[
"id"].str();
156 std::stringstream ss;
157 ss <<
"Invalid ID, used for internal purpose: '" <<
id <<
"'";
161 std::string title = level == 0 ?
"" : (*section_cfg)[
"title"].str();
164 std::vector<std::string>::const_iterator it;
166 for (it = sections.begin(); it != sections.end(); ++it) {
174 std::stringstream ss;
175 ss <<
"Help-section '" << *it <<
"' referenced from '"
176 <<
id <<
"' but could not be found.";
183 if ((*section_cfg)[
"sort_sections"] ==
"yes") {
187 bool sort_topics =
false;
188 bool sort_generated =
true;
190 if ((*section_cfg)[
"sort_topics"] ==
"yes") {
192 sort_generated =
false;
193 }
else if ((*section_cfg)[
"sort_topics"] ==
"no") {
195 sort_generated =
false;
196 }
else if ((*section_cfg)[
"sort_topics"] ==
"generated") {
198 sort_generated =
true;
199 }
else if (!(*section_cfg)[
"sort_topics"].empty()) {
200 std::stringstream ss;
201 ss <<
"Invalid sort option: '" << (*section_cfg)[
"sort_topics"] <<
"'";
205 std::vector<topic> generated_topics =
209 std::vector<topic> topics;
212 for (it = topics_id.begin(); it != topics_id.end(); ++it) {
217 topic child_topic(topic_cfg[
"title"], topic_cfg[
"id"], text);
219 std::stringstream ss;
220 ss <<
"Invalid ID, used for internal purpose: '" <<
id <<
"'";
223 topics.push_back(child_topic);
226 std::stringstream ss;
227 ss <<
"Help-topic '" << *it <<
"' referenced from '" <<
id
228 <<
"' but could not be found." << std::endl;
237 std::merge(generated_topics.begin(),
238 generated_topics.end(),topics.begin(),topics.end()
243 topics.begin(), topics.end());
245 generated_topics.begin(), generated_topics.end());
253 if (cfg !=
nullptr) {
254 config const &toplevel_cfg = cfg->
child(
"toplevel");
262 std::vector<topic>
res;
263 if (generator ==
"") {
267 if (generator ==
"abilities") {
269 }
else if (generator ==
"weapon_specials") {
271 }
else if (generator ==
"time_of_days") {
275 if (parts[0] ==
"units" && parts.size()>1) {
277 }
else if (parts[0] ==
"era" && parts.size()>1) {
280 WRN_HP <<
"Found a topic generator that I didn't recognize: " << generator <<
"\n";
289 if (generator ==
"races") {
291 }
else if (generator ==
"terrains") {
293 }
else if (generator ==
"eras") {
294 DBG_HP <<
"Generating eras...\n";
298 if (parts[0] ==
"units" && parts.size()>1) {
300 }
else if (generator.size() > 0) {
301 WRN_HP <<
"Found a section generator that I didn't recognize: " << generator <<
"\n";
309 if (generator ==
"") {
311 }
else if (generator ==
"about") {
314 std::vector<std::string> parts =
utils::split(generator,
':');
315 if (parts.size()>1 && parts[0] ==
"contents") {
316 if (parts[1] ==
"generated") {
359 std::vector<topic> topics;
363 toplevel <<
N_(
"Only available during a scenario.");
364 topics.push_back(
topic(
"Time of Day Schedule",
"..schedule", toplevel.str()) );
372 std::stringstream text;
375 image <<
jump(30) << time.lawful_bonus <<
'\n';
377 text << image <<
'\n' <<
378 time.description.str() <<
'\n' <<
379 "Lawful Bonus: " << time.lawful_bonus <<
'\n' <<
382 topics.push_back(
topic(time.name.str(),
id, text.str()) );
385 topics.push_back(
topic(
"Time of Day Schedule",
"..schedule", toplevel.str()) );
391 std::vector<topic> topics;
393 std::map<t_string, std::string> special_description;
394 std::map<t_string, std::set<std::string, string_less> > special_units;
396 for (
const unit_type_data::unit_type_map::value_type &
i :
unit_types.
types())
404 std::vector<attack_type> attacks = type.
attacks();
405 for (std::vector<attack_type>::const_iterator it = attacks.begin();
406 it != attacks.end(); ++it) {
408 std::vector<std::pair<t_string, t_string> > specials = it->special_tooltips();
409 for (
size_t i = 0;
i != specials.size(); ++
i )
411 special_description.insert(std::make_pair(specials[
i].
first, specials[
i].second));
418 std::string ref_id = section_prefix + unit_prefix + type.
id();
422 special_units[specials[
i].first].insert(link);
429 s != special_description.end(); ++
s) {
431 std::string id =
"weaponspecial_" +
s->first.base_str();
432 std::stringstream text;
434 text <<
"\n\n" <<
_(
"<header>text='Units with this special attack'</header>") <<
"\n";
435 std::set<std::string, string_less> &
units = special_units[
s->first];
437 text <<
"• " << (*u) <<
"\n";
440 topics.push_back(
topic(
s->first,
id, text.str()) );
451 std::vector<topic> topics;
452 std::map<t_string, std::string> ability_description;
453 std::map<t_string, std::set<std::string, string_less> > ability_units;
458 for (
const unit_type_data::unit_type_map::value_type &
i :
unit_types.
types())
463 std::vector<t_string>
const* abil_vecs[2];
467 std::vector<t_string>
const* desc_vecs[2];
471 for(
int i=0;
i<2; ++
i) {
472 std::vector<t_string>
const& abil_vec = *abil_vecs[
i];
473 std::vector<t_string>
const& desc_vec = *desc_vecs[
i];
474 for(
size_t j=0; j < abil_vec.size(); ++j) {
475 t_string const& abil_name = abil_vec[j];
477 j >= desc_vec.size() ?
"" : desc_vec[j].str();
479 ability_description.insert(std::make_pair(abil_name, abil_desc));
488 ability_units[abil_name].insert(link);
498 std::stringstream text;
500 text <<
"\n\n" <<
_(
"<header>text='Units with this ability'</header>") <<
"\n";
501 std::set<std::string, string_less> &
units = ability_units[
a->first];
503 text <<
"• " << (*u) <<
"\n";
506 topics.push_back(
topic(
a->first,
id, text.str()) );
516 std::vector<topic> topics;
519 if(era && !era[
"hide_help"].to_bool()) {
522 std::vector<std::string> faction_links;
523 for (
const topic &
t : topics) {
527 std::stringstream text;
528 text <<
"<header>text='" <<
_(
"Era:") <<
" " << era[
"name"] <<
"'</header>" <<
"\n";
531 if (!description.
empty()) {
532 text << description.
t_str() <<
"\n";
536 text <<
"<header>text='" <<
_(
"Factions") <<
"'</header>" <<
"\n";
538 std::sort(faction_links.begin(), faction_links.end());
540 text <<
"• " << link <<
"\n";
543 topic era_topic(era[
"name"],
".." + era_prefix + era[
"id"].str(), text.str());
545 topics.push_back( era_topic );
552 std::vector<topic> topics;
558 std::stringstream text;
561 if (!description.
empty()) {
562 text << description.
t_str() <<
"\n";
566 const std::vector<std::string> recruit_ids =
utils::split(
f[
"recruit"]);
567 std::set<std::string> races;
568 std::set<std::string> alignments;
583 if (!races.empty()) {
585 text <<
_(
"Races: ") << *(it++);
586 while(it != races.end()) {
587 text <<
", " << *(it++);
592 if (!alignments.empty()) {
594 text <<
_(
"Alignments: ") << *(it++);
595 while(it != alignments.end()) {
596 text <<
", " << *(it++);
601 text <<
"<header>text='" <<
_(
"Leaders") <<
"'</header>" <<
"\n";
602 const std::vector<std::string> leaders =
605 text <<
"• " << link <<
"\n";
610 text <<
"<header>text='" <<
_(
"Recruits") <<
"'</header>" <<
"\n";
611 const std::vector<std::string> recruit_links =
614 text <<
"• " << link <<
"\n";
619 topics.push_back(
topic(name, ref_id, text.str()) );
632 std::cerr <<
"Unknown unit type : " << type_id <<
"\n";
641 ref_id = section_prefix + unit_prefix + type->
id();
654 std::vector<std::string> links_list;
657 if (!unit_link.empty())
658 links_list.push_back(unit_link);
662 std::sort(links_list.begin(), links_list.end());
669 std::set<std::string, string_less> races;
670 std::set<std::string, string_less> visible_races;
672 for (
const unit_type_data::unit_type_map::value_type &
i :
unit_types.
types())
679 visible_races.insert(type.
race_id());
687 bool hidden = (visible_races.count(*it) == 0);
689 section_cfg[
"id"] =
hidden_symbol(hidden) + race_prefix + *it;
693 title =
r->plural_name();
695 title =
_ (
"race^Miscellaneous");
697 section_cfg[
"title"] = title;
699 section_cfg[
"sections_generator"] =
"units:" + *it;
700 section_cfg[
"generator"] =
"units:" + *it;
710 if (
era[
"hide_help"].to_bool()) {
714 DBG_HP <<
"Adding help section: " <<
era[
"id"].str() <<
"\n";
718 section_cfg[
"id"] = era_prefix +
era[
"id"].str();
719 section_cfg[
"title"] =
era[
"name"];
721 section_cfg[
"generator"] =
"era:" +
era[
"id"].str();
735 WRN_HP <<
"When building terrain help sections, couldn't acquire terrain types data, aborting.\n";
739 std::map<std::string, section> base_map;
761 const terrain_type& base_info = tdata->get_terrain_info(base);
766 section& base_section = base_map[base_info.
id()];
768 base_section.
id = terrain_prefix + base_info.
id();
771 if (base_info.
id() == info.
id())
772 terrain_topic.
id =
".." + terrain_prefix + info.
id();
773 base_section.
topics.push_back(terrain_topic);
777 for (std::map<std::string, section>::const_iterator it = base_map.begin(); it != base_map.end(); ++it) {
784 for (
const unit_type_data::unit_type_map::value_type &
i :
unit_types.
types()) {
800 topic var_topic(topic_name, var_ref,
"");
802 base_unit.
topics.push_back(var_topic);
808 base_unit.
id = ref_id;
809 base_unit.
title = type_name;
810 base_unit.
level = level +1;
818 std::vector<topic> topics;
819 std::set<std::string, string_less> race_units;
820 std::set<std::string, string_less> race_topics;
821 std::set<std::string> alignments;
823 for (
const unit_type_data::unit_type_map::value_type &
i :
unit_types.
types())
837 topic unit_topic(type_name, ref_id,
"");
839 topics.push_back(unit_topic);
845 race_units.insert(link);
856 race_name =
r->plural_name();
857 race_description =
r->description();
859 for (
const config &additional_topic :
r->additional_topics())
865 topics.push_back(
topic(title,
id,text));
867 race_topics.insert(link);
870 race_name =
_ (
"race^Miscellaneous");
874 std::stringstream text;
876 if (!race_description.empty()) {
877 text << race_description <<
"\n\n";
880 if (!alignments.empty()) {
882 text << (alignments.size() > 1 ?
_(
"Alignments: ") :
_(
"Alignment: ")) << *(it++);
883 while(it != alignments.end()) {
884 text <<
", " << *(it++);
889 text <<
_(
"<header>text='Units of this race'</header>") <<
"\n";
891 text <<
"• " << (*u) <<
"\n";
894 topics.push_back(
topic(race_name, race_id, text.str()) );
910 if (encountered_units.find(type.
id()) != encountered_units.end()) {
919 std::vector<std::string> res_lines;
920 std::transform(about_lines.begin(), about_lines.end(), std::back_inserter(res_lines),
922 res_lines.erase(
std::remove(res_lines.begin(), res_lines.end(),
""), res_lines.end());
929 config const §ion_cfg = help_cfg->
find_child(
"section",
"id", section_name);
934 std::ostringstream
res;
939 typedef std::pair<std::string,std::string> link;
940 std::vector<link> topics_links;
944 for (t = topics.begin(); t != topics.end(); ++
t) {
948 topics_links.push_back(link(topic_cfg[
"title"],
id));
952 if (section_cfg[
"sort_topics"] ==
"yes") {
953 std::sort(topics_links.begin(),topics_links.end());
957 for (l = topics_links.begin(); l != topics_links.end(); ++
l) {
959 res <<
"• " << link <<
"\n";
967 std::stringstream
res;
969 section_list::const_iterator
s;
973 res <<
"• " << link <<
"\n";
977 std::vector<topic>::const_iterator
t;
978 for (t = topics.begin(); t != topics.end(); ++
t) {
981 res <<
"• " << link <<
"\n";
1027 return sec.
id ==
id;
1051 topic_list::const_iterator tit =
1053 if (tit != sec.
topics.end()) {
1056 section_list::const_iterator sit;
1068 section_list::const_iterator sit =
1084 std::vector<std::string>
res;
1085 bool last_char_escape =
false;
1086 const char escape_char =
'\\';
1087 std::stringstream ss;
1090 for (pos = 0; pos < text.size(); ++
pos) {
1091 const char c = text[
pos];
1092 if (c == escape_char && !last_char_escape) {
1093 last_char_escape =
true;
1096 if (state ==
OTHER) {
1098 if (last_char_escape) {
1102 res.push_back(ss.str());
1104 state = ELEMENT_NAME;
1111 else if (state == ELEMENT_NAME) {
1116 else if (c ==
'>') {
1118 std::stringstream
s;
1121 s <<
"</" << element_name <<
">";
1123 size_t end_pos = text.find(end_element_name, pos);
1124 if (end_pos == std::string::npos) {
1125 std::stringstream
msg;
1126 msg <<
"Unterminated element: " << element_name;
1130 const std::string contents = text.substr(pos + 1, end_pos - pos - 1);
1132 res.push_back(element);
1133 pos = end_pos + end_element_name.size() - 1;
1140 last_char_escape =
false;
1143 if (state == ELEMENT_NAME) {
1144 std::stringstream
msg;
1145 msg <<
"Element '" << ss.str() <<
"' continues through end of string.";
1148 if (ss.str() !=
"") {
1150 res.push_back(ss.str());
1157 std::stringstream ss;
1158 bool in_quotes =
false;
1159 bool last_char_escape =
false;
1160 const char escape_char =
'\\';
1161 std::vector<std::string> attributes;
1166 for (
size_t pos = 0;
pos < contents.size(); ++
pos) {
1167 const char c = contents[
pos];
1168 if (c == escape_char && !last_char_escape) {
1169 last_char_escape =
true;
1172 if (c ==
'\'' && !last_char_escape) {
1174 in_quotes = !in_quotes;
1176 else if ((c ==
' ' || c ==
'\n') && !last_char_escape && !in_quotes) {
1178 attributes.push_back(ss.str());
1184 last_char_escape =
false;
1188 std::stringstream
msg;
1189 msg <<
"Unterminated single quote after: '" << ss.str() <<
"'";
1192 if (ss.str() !=
"") {
1193 attributes.push_back(ss.str());
1197 ss <<
"[" << element_name <<
"]\n";
1198 for (std::vector<std::string>::const_iterator it = attributes.begin();
1199 it != attributes.end(); ++it) {
1202 ss <<
"[/" << element_name <<
"]\n";
1208 if (cmp_str ==
"green") {
1211 if (cmp_str ==
"red") {
1214 if (cmp_str ==
"black") {
1217 if (cmp_str ==
"yellow") {
1220 if (cmp_str ==
"white") {
1224 if (*cmp_str.c_str() ==
'#' && cmp_str.size() == 7) {
1225 return int_to_color(strtoul(cmp_str.c_str() + 1,
nullptr, 16));
1231 const unsigned width)
1233 std::vector<std::string>
res;
1236 res.push_back(first_line);
1237 if(s.size() > first_line.size()) {
1238 res.push_back(s.substr(first_line.size()));
1251 if (text.length() > 0 && text[0] ==
' ') {
1252 return text.substr(1);
1259 size_t first_word_start = s.find_first_not_of(
' ');
1260 if (first_word_start == std::string::npos) {
1263 size_t first_word_end = s.find_first_of(
" \n", first_word_start);
1264 if( first_word_end == first_word_start ) {
1266 first_word_end = first_word_start+1;
1286 hidden_sections.
clear();
1287 if (game_cfg !=
nullptr) {
1288 const config *help_config = &game_cfg->
child(
"help");
1289 if (!*help_config) {
1301 std::stringstream ss;
1310 if (ss.str() !=
"") {
1317 hidden_toplevel[
"sections"] = ss.str();
1324 if (ss.str() !=
"") {
1331 hidden_toplevel[
"topics"] = ss.str();
1332 config hidden_cfg = *help_config;
1335 hidden_cfg.
add_child(
"toplevel", hidden_toplevel);
1339 std::stringstream
msg;
1340 msg <<
"Parse error when parsing help text: '" << e.
message <<
"'";
1341 std::cerr << msg.str() << std::endl;
1348 return (hidden ?
"." :
"");
1352 return (
id.empty() ||
id[0] !=
'.');
1359 if (
id ==
"toplevel") {
1365 if (
id.
find(
"ability_") == 0) {
1368 if (
id.
find(
"weaponspecial_") == 0) {
1371 if (
id ==
"hidden") {
1383 if (surf !=
nullptr) {
1396 table_spec::const_iterator row_it;
1397 std::vector<std::pair<std::string, unsigned> >::const_iterator col_it;
1398 unsigned int num_cols = 0;
1399 for (row_it = tab.begin(); row_it != tab.end(); ++row_it) {
1400 if (row_it->size() > num_cols) {
1401 num_cols = row_it->size();
1404 std::vector<unsigned int> col_widths(num_cols, 0);
1406 for (row_it = tab.begin(); row_it != tab.end(); ++row_it) {
1407 unsigned int col = 0;
1408 for (col_it = row_it->begin(); col_it != row_it->end(); ++col_it) {
1409 if (col_widths[col] < col_it->second + spacing) {
1410 col_widths[col] = col_it->second + spacing;
1415 std::vector<unsigned int> col_starts(num_cols);
1417 for (
unsigned int i = 0;
i < num_cols; ++
i) {
1418 unsigned int this_col_start = 0;
1419 for (
unsigned int j = 0; j <
i; ++j) {
1420 this_col_start += col_widths[j];
1422 col_starts[
i] = this_col_start;
1424 std::stringstream ss;
1425 for (row_it = tab.begin(); row_it != tab.end(); ++row_it) {
1426 unsigned int col = 0;
1427 for (col_it = row_it->begin(); col_it != row_it->end(); ++col_it) {
1428 ss <<
jump_to(col_starts[col]) << col_it->first;
std::string jump_to(const unsigned pos)
const SDL_Color BIGMAP_COLOR
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
child_itors child_range(const std::string &key)
section parse_config(const config *cfg)
Parse a help config, return the top level section.
::tod_manager * tod_manager
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
static display * get_singleton()
Returns the display object if a display object exists.
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
const t_string & type_name() const
The name of the unit in the current language setting.
boost::shared_ptr< terrain_type_data > tdata_cache
const std::vector< t_string > & abilities() const
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
const SDL_Color BLACK_COLOR
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
SDL_Color int_to_color(const Uint32 rgb)
const std::vector< t_string > & ability_tooltips() const
std::vector< std::string > get_text(const std::string &campaign, bool split_multiline_headers)
ucs4_convert_impl::enableif< TD, typename TS::value_type >::type unicode_cast(const TS &source)
const std::string & variation_name() const
Thrown when the help system fails to parse something.
std::vector< std::string > empty_string_vector
bool is_scope_active(hk_scopes s)
std::string word_wrap_text(const std::string &unwrapped_text, int font_size, int max_width, int max_height, int max_lines, bool partial_line)
Wrap text.
unit_type_data unit_types
const std::string & id() const
bool operator<(const topic &) const
Comparison on the ID.
const int normal_font_size
std::string debug() const
topic_generator * generator_
unsigned image_width(const std::string &filename)
void clear_children(const std::string &key)
const std::string terrain_prefix
int last_num_encountered_terrains
bool empty() const
Tests for an attribute that either was never set or was set to "".
const SDL_Color NORMAL_COLOR
bool is_visible_id(const std::string &id)
const t_string & editor_name() const
virtual const gamemap & map() const =0
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)
Variant for storing WML attributes.
const tdata_cache & tdata() const
void generate_sections(const config *help_cfg, const std::string &generator, section &sec, int level)
Dispatch generators to their appropriate functions.
const SDL_Color GOOD_COLOR
help::section hidden_sections
static const std::string empty_string
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.
GLuint GLenum GLenum transform
STRIP_SPACES : strips leading and trailing blank spaces.
Object which defines a time of day with associated bonuses, image, sounds etc.
To be used as a function object to locate sections and topics with a specified ID.
static game_config_manager * get()
static UNUSEDNOWARN std::string _(const char *str)
const unit_race * find_race(const std::string &) const
The text displayed in a topic.
std::string generate_table(const table_spec &tab, const unsigned int spacing)
std::string hidden_symbol(bool hidden)
const SDL_Color BAD_COLOR
const unit_type_map & types() const
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
GLboolean GLboolean GLboolean GLboolean a
void generate_terrain_sections(const config *, section &sec, int)
std::set< t_translation::t_terrain > & encountered_terrains()
std::vector< topic > generate_faction_topics(const config &era, const bool sort_generated)
const std::vector< unit_race::GENDER > & genders() const
The returned vector will not be empty, provided this has been built to the HELP_INDEXED status...
bool show_variations_in_help() const
Whether the unit type has at least one help-visible variation.
config & add_child(const std::string &key)
tdata_cache load_terrain_types_data()
Load the appropriate terrain types data to use.
map_display and display: classes which take care of displaying the map and game-data on the screen...
std::vector< std::string > parsed_text_
static lg::log_domain log_help("help")
bool show_all_units_in_help()
std::string race_id() const
Returns the ID of this type's race without the need to build the type.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
void parse_config_internal(const config *help_cfg, const config *section_cfg, section &sec, int level)
Recursive function used by parse_config.
std::string join(T const &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::string escape(const std::string &str, const char *special_chars)
Prepends a configurable set of characters with a backslash.
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...
std::vector< std::string > quoted_split(std::string const &val, char c, int flags, char quote)
This function is identical to split(), except it does not split when it otherwise would if the previo...
To be used as a function object when sorting section lists on the title.
const std::string variation_prefix
Thrown by operations encountering invalid UTF-8 data.
topic_text & operator=(topic_generator *g)
const unit_type & get_variation(const std::string &id) const
int last_num_encountered_units
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].
bool is_cjk_char(const ucs4::char_t ch)
Determine if a ucs4::char_t is a CJK character.
std::vector< std::string > variations() const
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::set< std::string > & encountered_units()
GLdouble GLdouble GLdouble r
void generate_races_sections(const config *help_cfg, section &sec, int level)
static int sort(lua_State *L)
static iterator_base end(const string_type &str)
const tdata_cache & terrain_types() const
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
GLuint const GLchar * name
std::vector< topic > generate_time_of_day_topics(const bool)
static lg::log_domain log_display("display")
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)
const std::vector< t_string > & adv_abilities() const
const std::string default_show_topic
void generate_contents()
Generate the help contents from the configurations given to the manager.
bool find(E event, F functor)
Tests whether an event handler is available.
std::vector< topic > generate_topics(const bool sort_generated, const std::string &generator)
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.
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
const std::vector< time_of_day > & times(const map_location &loc=map_location::null_location()) const
bool operator<(const section &) const
Comparison on the ID.
std::vector< attack_type > attacks() const
config & find_child(const std::string &key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
this module manages the cache of images.
Standard logging facilities (interface).
Generate a topic text on the fly.
A topic contains a title, an id and some text.
const display_context & get_disp_context() const
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
const std::string remove
remove directive
GLint GLint GLint GLint GLint GLint GLsizei width
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
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.
const SDL_Color YELLOW_COLOR
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.
static std::string alignment_description(ALIGNMENT align, unit_race::GENDER gender=unit_race::MALE)
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)
Defines the MAKE_ENUM macro.
GLsizei const GLcharARB ** string
int line_width(const std::string &line, int font_size, int style)
Determine the width of a line of text given a certain font size.
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.
const std::string & id() const
The id for this unit_type.
std::vector< t_terrain > t_list
section & operator=(const section &)
const std::vector< t_string > & adv_ability_tooltips() const