The Battle for Wesnoth  1.19.5+dev
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
unit_race Class Reference

#include <race.hpp>

Public Types

enum  GENDER { MALE , FEMALE , NUM_GENDERS }
 

Public Member Functions

 unit_race (const config &cfg)
 
const configget_cfg () const
 
const std::string & id () const
 
const std::string & editor_icon () const
 
const t_stringname (GENDER gender=MALE) const
 
const t_stringplural_name () const
 
const t_stringdescription () const
 
std::string generate_name (GENDER gender) const
 
const name_generatorgenerator (GENDER gender) const
 
bool uses_global_traits () const
 
const config::const_child_itorsadditional_traits () const
 
const config::const_child_itorsadditional_topics () const
 
unsigned int num_traits () const
 
const std::string & undead_variation () const
 
std::string get_icon_path_stem () const
 Gets this race's icon path without state/size suffix and extension. More...
 
const std::string & help_taxonomy () const
 

Static Public Attributes

static const std::string s_female
 Standard string id (not translatable) for FEMALE. More...
 
static const std::string s_male
 Standard string id (not translatable) for MALE. More...
 
static const unit_race null_race
 Dummy race used when a race is not yet known. More...
 

Private Member Functions

 unit_race ()
 Only used to construct null_race. More...
 

Private Attributes

const config cfg_
 
std::string id_
 
std::string icon_
 
std::array< t_string, NUM_GENDERSname_
 
t_string plural_name_
 
t_string description_
 
unsigned int ntraits_
 
std::array< std::shared_ptr< name_generator >, NUM_GENDERSname_generator_
 
config::const_child_itors traits_
 
config::const_child_itors topics_
 
bool global_traits_
 
std::string undead_variation_
 
std::string help_taxonomy_
 

Detailed Description

Definition at line 25 of file race.hpp.

Member Enumeration Documentation

◆ GENDER

Enumerator
MALE 
FEMALE 
NUM_GENDERS 

Definition at line 28 of file race.hpp.

Constructor & Destructor Documentation

◆ unit_race() [1/2]

unit_race::unit_race ( const config cfg)
explicit

◆ unit_race() [2/2]

unit_race::unit_race ( )
private

Only used to construct null_race.

Definition at line 49 of file race.cpp.

References generator(), and name_generator_.

Member Function Documentation

◆ additional_topics()

const config::const_child_itors & unit_race::additional_topics ( ) const

Definition at line 131 of file race.cpp.

References topics_.

◆ additional_traits()

const config::const_child_itors & unit_race::additional_traits ( ) const

Definition at line 126 of file race.cpp.

References traits_.

Referenced by unit_type::build_help_index(), and impl_race_get().

◆ description()

const t_string& unit_race::description ( ) const
inline

Definition at line 40 of file race.hpp.

References description_.

Referenced by impl_race_get().

◆ editor_icon()

const std::string& unit_race::editor_icon ( ) const
inline

Definition at line 37 of file race.hpp.

References icon_.

◆ generate_name()

std::string unit_race::generate_name ( unit_race::GENDER  gender) const

Definition at line 111 of file race.cpp.

References name_generator_.

Referenced by unit::generate_name().

◆ generator()

const name_generator & unit_race::generator ( unit_race::GENDER  gender) const

Definition at line 116 of file race.cpp.

References name_generator_.

Referenced by impl_race_get(), and unit_race().

◆ get_cfg()

const config& unit_race::get_cfg ( ) const
inline

Definition at line 35 of file race.hpp.

References cfg_.

Referenced by impl_race_get().

◆ get_icon_path_stem()

std::string unit_race::get_icon_path_stem ( ) const

Gets this race's icon path without state/size suffix and extension.

This doesn't return the full path. Its output looks something like this: icons/unit-groups/race_elf

This is because this output is used in the editor for a GUI1 button's icon, and GUI1 automatically appends the state extension, such as "_30-pressed.png"

If a custom icon has been provided, that is used. Else, it checks if an appropriate icon exists in icons/unit-groups/. If not, a generic custom race icon will be used.

Definition at line 165 of file race.cpp.

References filesystem::get_binary_file_location(), icon_, id_, and game_config::path.

Referenced by gui2::unit_preview_pane::set_displayed_unit().

◆ help_taxonomy()

const std::string& unit_race::help_taxonomy ( ) const
inline

Definition at line 67 of file race.hpp.

References help_taxonomy_.

◆ id()

const std::string& unit_race::id ( ) const
inline

◆ name()

const t_string& unit_race::name ( GENDER  gender = MALE) const
inline

Definition at line 38 of file race.hpp.

References name_.

Referenced by impl_race_get(), gui2::unit_preview_pane::set_displayed_unit(), and unit_race().

◆ num_traits()

unsigned int unit_race::num_traits ( ) const

Definition at line 136 of file race.cpp.

References ntraits_.

Referenced by unit_type::build_help_index(), and impl_race_get().

◆ plural_name()

const t_string& unit_race::plural_name ( ) const
inline

Definition at line 39 of file race.hpp.

References plural_name_.

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

◆ undead_variation()

const std::string& unit_race::undead_variation ( ) const
inline

Definition at line 50 of file race.hpp.

References undead_variation_.

Referenced by unit_type::build_full(), unit_type::build_help_index(), and impl_race_get().

◆ uses_global_traits()

bool unit_race::uses_global_traits ( ) const

Definition at line 121 of file race.cpp.

References global_traits_.

Referenced by unit_type::build_help_index(), and impl_race_get().

Member Data Documentation

◆ cfg_

const config unit_race::cfg_
private

Definition at line 76 of file race.hpp.

Referenced by get_cfg().

◆ description_

t_string unit_race::description_
private

Definition at line 82 of file race.hpp.

Referenced by description().

◆ global_traits_

bool unit_race::global_traits_
private

Definition at line 88 of file race.hpp.

Referenced by uses_global_traits().

◆ help_taxonomy_

std::string unit_race::help_taxonomy_
private

Definition at line 90 of file race.hpp.

Referenced by help_taxonomy().

◆ icon_

std::string unit_race::icon_
private

Definition at line 79 of file race.hpp.

Referenced by editor_icon(), and get_icon_path_stem().

◆ id_

std::string unit_race::id_
private

Definition at line 78 of file race.hpp.

Referenced by get_icon_path_stem(), id(), and unit_race().

◆ name_

std::array<t_string, NUM_GENDERS> unit_race::name_
private

Definition at line 80 of file race.hpp.

Referenced by name(), and unit_race().

◆ name_generator_

std::array<std::shared_ptr<name_generator>, NUM_GENDERS> unit_race::name_generator_
private

Definition at line 84 of file race.hpp.

Referenced by generate_name(), generator(), and unit_race().

◆ ntraits_

unsigned int unit_race::ntraits_
private

Definition at line 83 of file race.hpp.

Referenced by num_traits().

◆ null_race

const unit_race unit_race::null_race
static

Dummy race used when a race is not yet known.

Definition at line 70 of file race.hpp.

Referenced by unit_type::build_full(), unit_type::build_help_index(), and unit::init().

◆ plural_name_

t_string unit_race::plural_name_
private

Definition at line 81 of file race.hpp.

Referenced by plural_name(), and unit_race().

◆ s_female

const std::string unit_race::s_female
static

Standard string id (not translatable) for FEMALE.

Definition at line 29 of file race.hpp.

Referenced by gender_string(), unit_type::get_gender_unit_type(), gui2::dialogs::faction_select::pre_show(), string_gender(), and ng::flg_manager::update_available_genders().

◆ s_male

const std::string unit_race::s_male
static

Standard string id (not translatable) for MALE.

Definition at line 30 of file race.hpp.

Referenced by gender_string(), unit_type::get_gender_unit_type(), gui2::dialogs::faction_select::pre_show(), string_gender(), and ng::flg_manager::update_available_genders().

◆ topics_

config::const_child_itors unit_race::topics_
private

Definition at line 87 of file race.hpp.

Referenced by additional_topics().

◆ traits_

config::const_child_itors unit_race::traits_
private

Definition at line 86 of file race.hpp.

Referenced by additional_traits().

◆ undead_variation_

std::string unit_race::undead_variation_
private

Definition at line 89 of file race.hpp.

Referenced by undead_variation().


The documentation for this class was generated from the following files: