15 #define GETTEXT_DOMAIN "wesnoth-lib"
41 , flg_manager_(flg_manager)
44 , last_faction_(flg_manager.current_faction_index())
45 , last_leader_(flg_manager.current_leader_index())
46 , last_gender_(flg_manager.current_gender_index())
52 find_widget<label>(
"starting_pos").set_label(std::to_string(
side_));
57 toggle_button& gender_rand = find_widget<toggle_button>(
"gender_random");
58 toggle_button& gender_male = find_widget<toggle_button>(
"gender_male");
59 toggle_button& gender_female = find_widget<toggle_button>(
"gender_female");
77 find_widget<button>(
"type_profile").connect_click_handler(
83 listbox& list = find_widget<listbox>(
"faction_list");
96 const std::string name = side[
"name"].str();
98 const std::string
flag_rgb = !side[
"flag_rgb"].
empty() ? side[
"flag_rgb"].str() :
"magenta";
101 data.emplace(
"faction_image", item);
103 item[
"label"] = name;
104 data.emplace(
"faction_name", item);
116 const int selected_row = find_widget<listbox>(
"faction_list").get_selected_row();
118 if(selected_row == -1) {
128 std::vector<config> leaders;
135 leaders.emplace_back(
"label",
unit->
type_name(),
"icon", icon);
136 }
else if(leader ==
"random") {
138 }
else if(leader ==
"null") {
141 leaders.emplace_back(
"label",
"?");
145 menu_button& leader_dropdown = find_widget<menu_button>(
"leader_menu");
147 leader_dropdown.
set_values(leaders, std::min<int>(leaders.size() - 1, previous_leader_selection));
153 std::vector<t_string> recruit_names;
156 recruit_names.push_back(rt->type_name());
160 std::sort(recruit_names.begin(), recruit_names.end(), [](
const std::string& s1,
const std::string& s2) {
161 return translation::compare(s1, s2) < 0;
164 find_widget<styled_widget>(
"recruits").set_label(
utils::bullet_list(recruit_names, 0));
175 return std::find(genders.begin(), genders.end(), gender) != genders.end();
181 button& profile_button = find_widget<button>(
"type_profile");
209 find_widget<drawing>(
"leader_image").set_label(leader_image);
A config object defines a single node in a WML file, with access to child nodes.
void on_gender_select(const std::string val)
void update_leader_image()
void on_faction_select()
Callbacks.
virtual void post_show() override
Actions to be taken after the window has been shown.
ng::flg_manager & flg_manager_
const std::string tc_color_
virtual void pre_show() override
Actions to be taken before showing the window.
group< std::string > gender_toggle_
void profile_button_callback()
Abstract base class for all modal dialogs.
int get_retval() const
Returns the cached window exit code.
void add_member(selectable_item *w, const T &value)
Adds a widget/value pair to the group map.
void set_member_states(const T &value)
Sets the toggle values for all widgets besides the one associated with the specified value to false.
void set_callback_on_value_change(std::function< void(widget &, const T)> func)
Sets a common callback function for all members.
void set_members_enabled(std::function< bool(const T &)> predicate)
Wrapper for enabling or disabling member widgets.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
bool select_row(const unsigned row, const bool select=true)
Selects a row.
void keyboard_capture(widget *widget)
const std::vector< const config * > & choosable_factions() const
const std::string & current_gender() const
void set_current_faction(const unsigned index)
const std::vector< std::string > & choosable_genders() const
bool is_saved_game() const
int current_leader_index() const
const std::vector< std::string > & choosable_leaders() const
void set_current_leader(const unsigned index)
int current_faction_index() const
void set_current_gender(const unsigned index)
const config & current_faction() const
const std::string & current_leader() const
std::set< std::string > & encountered_units()
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 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.
A single unit type that the player may recruit.
const std::string & image() const
const std::string & flag_rgb() const
const unit_type & get_gender_unit_type(std::string gender) const
Returns a gendered variant of this unit_type.
This class represents a single unit of a specific type.
static std::string _(const char *str)
const t_string & type_name() const
Gets the translatable name of this unit's type.
const std::string & flag_rgb() const
Get the source color palette to use when recoloring the unit's image.
const std::string unicode_em_dash
REGISTER_DIALOG(editor_edit_unit)
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
@ OK
Dialog was closed with the OK button.
void show_unit_description(const unit &u)
const std::string random_enemy_picture("units/random-dice.png")
std::string bullet_list(const T &v, std::size_t indent=4, const std::string &bullet=font::unicode_bullet)
Generates a new string containing a bullet list.
std::vector< std::string > split(const config_attribute_value &val)
static map_location::direction s
unit_type_data unit_types