29 #define ERR_WML LOG_STREAM(err, log_wml)
70 icon_(cfg[
"editor_icon"]),
71 plural_name_(cfg[
"plural_name"].t_str()),
72 description_(cfg[
"description"].t_str()),
73 ntraits_(cfg[
"num_traits"]),
74 traits_(cfg.child_range(
"trait")),
75 topics_(cfg.child_range(
"topic")),
76 global_traits_(!cfg[
"ignore_global_traits"].to_bool()),
77 undead_variation_(cfg[
"undead_variation"]),
78 help_taxonomy_(cfg[
"help_taxonomy"])
83 ERR_WML <<
"[race] id='" <<
id_ <<
"' is missing a plural_name field.";
96 if(std::any_of(
name_.begin(),
name_.end(), [](
const auto&
n) {
return n.empty(); })) {
98 <<
"[race] id='" <<
id_
99 <<
"' is missing a singular name field (either 'name' or both 'male_name' and 'female_name').\n";
101 <<
"' is missing a singular name field (either 'name' or both 'male_name' and 'female_name').";
161 const std::string & female_key,
const std::string & default_key)
172 std::string
path =
"icons/unit-groups/race_" +
id_;
176 path =
"icons/unit-groups/race_custom";
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
const attribute_value & get_or(const config_key_type key, const config_key_type default_key) const
Chooses a value.
boost::iterator_range< const_child_iterator > const_child_itors
std::shared_ptr< name_generator > get_name_generator()
Gets the default name generator.
bool uses_global_traits() const
std::string get_icon_path_stem() const
Gets this race's icon path without state/size suffix and extension.
static const unit_race null_race
Dummy race used when a race is not yet known.
const config::const_child_itors & additional_topics() const
config::const_child_itors topics_
std::string generate_name(GENDER gender) const
unit_race()
Only used to construct null_race.
std::array< std::shared_ptr< name_generator >, NUM_GENDERS > name_generator_
unsigned int num_traits() const
std::array< t_string, NUM_GENDERS > name_
config::const_child_itors traits_
const config::const_child_itors & additional_traits() const
static const std::string s_female
Standard string id (not translatable) for FEMALE.
static const std::string s_male
Standard string id (not translatable) for MALE.
const name_generator & generator(GENDER gender) const
Declarations for File-IO.
Standard logging facilities (interface).
utils::optional< std::string > get_binary_file_location(const std::string &type, const std::string &filename)
Returns a complete path to the actual file of a given type, if it exists.
std::stringstream & log_to_chat()
Use this to show WML errors in the ingame chat.
const std::string & gender_string(unit_race::GENDER gender)
static const config & empty_traits()
static const config & empty_topics()
unit_race::GENDER string_gender(const std::string &str, unit_race::GENDER def)
const config::attribute_value & gender_value(const config &cfg, unit_race::GENDER gender, const std::string &male_key, const std::string &female_key, const std::string &default_key)
Chooses a value from the given config based on gender.
static lg::log_domain log_wml("wml")
static map_location::DIRECTION n