15 #define GETTEXT_DOMAIN "wesnoth-lib" 44 : flg_manager_(flg_manager)
47 , last_faction_(flg_manager.current_faction_index())
48 , last_leader_(flg_manager.current_leader_index())
49 , last_gender_(flg_manager.current_gender_index())
55 find_widget<label>(&window,
"starting_pos",
false).set_label(std::to_string(
side_));
60 toggle_button& gender_rand = find_widget<toggle_button>(&window,
"gender_random",
false);
61 toggle_button& gender_male = find_widget<toggle_button>(&window,
"gender_male",
false);
62 toggle_button& gender_female = find_widget<toggle_button>(&window,
"gender_female",
false);
80 find_widget<button>(&window,
"type_profile",
false).connect_click_handler(
86 listbox& list = find_widget<listbox>(&window,
"faction_list",
false);
88 window.keyboard_capture(&list);
96 std::map<std::string, string_map> data;
99 const std::string name = side[
"name"].str();
101 const std::string
flag_rgb = !side[
"flag_rgb"].
empty() ? side[
"flag_rgb"].str() :
"magenta";
103 item[
"label"] = (
formatter() << side[
"image"] <<
"~RC(" << flag_rgb <<
">" <<
tc_color_ <<
")").str();
104 data.emplace(
"faction_image", item);
106 item[
"label"] = name;
107 data.emplace(
"faction_name", item);
119 const int selected_row = find_widget<listbox>(
get_window(),
"faction_list",
false).get_selected_row();
121 if(selected_row == -1) {
131 std::vector<config> leaders;
138 leaders.emplace_back(
"label", unit->
type_name(),
"icon", icon);
139 }
else if(leader ==
"random") {
141 }
else if(leader ==
"null") {
144 leaders.emplace_back(
"label",
"?");
150 leader_dropdown.
set_values(leaders, std::min<int>(leaders.size() - 1, previous_leader_selection));
157 std::vector<t_string> recruit_names;
159 for(
const auto& recruit : recruit_list) {
165 std::sort(recruit_names.begin(), recruit_names.end(), [](
const std::string& s1,
const std::string& s2) {
169 find_widget<styled_widget>(
get_window(),
"recruits",
false).set_label(
utils::join(recruit_names,
"\n"));
180 return std::find(genders.begin(), genders.end(), gender) != genders.end();
186 button& profile_button = find_widget<button>(
get_window(),
"type_profile",
false);
187 const std::string& leader_type = find_widget<menu_button>(
get_window(),
"leader_menu",
false).get_value_string();
193 const std::string& leader_type = find_widget<menu_button>(
get_window(),
"leader_menu",
false).get_value_string();
217 find_widget<drawing>(
get_window(),
"leader_image",
false).set_label(leader_image);
Define the common log macros for the gui toolkit.
const std::vector< std::string > & choosable_genders() const
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
int current_faction_index() const
static const std::string s_male
Standard string id (not translatable) for MALE.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
void on_faction_select()
Callbacks.
void on_gender_select(const std::string val)
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.
This class represents a single unit of a specific type.
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
const std::string & current_gender() const
int compare(const std::string &s1, const std::string &s2)
Case-sensitive lexicographical comparison.
const std::string & flag_rgb() const
void set_members_enabled(std::function< bool(const T &)> predicate)
Wrapper for enabling or disabling member widgets.
void profile_button_callback()
unit_type_data unit_types
void set_current_leader(const unsigned index)
window * get_window() const
Returns a pointer to the dialog's window.
int current_leader_index() const
void set_current_gender(const unsigned index)
static std::string _(const char *str)
A single unit type that the player may recruit.
const std::vector< const config * > & choosable_factions() const
static const std::string s_female
Standard string id (not translatable) for FEMALE.
void set_callback_on_value_change(std::function< void(widget &, const T)> func)
Sets a common callback function for all members.
void update_leader_image()
const std::vector< std::string > & choosable_leaders() const
This file contains the settings handling of the widget library.
const t_string & type_name() const
The name of the unit in the current language setting.
const std::string & current_leader() const
const std::string & id() const
The id for this unit_type.
bool is_saved_game() const
void show_unit_description(const unit &u)
void set_current_faction(const unsigned index)
void add_member(selectable_item *w, const T &value)
Adds a widget/value pair to the group map.
const config & current_faction() const
static map_location::DIRECTION s
std::set< std::string > & encountered_units()
const std::string unicode_bullet
const std::string random_enemy_picture("units/random-dice.png")
const std::string & image() const
const std::string tc_color_
int get_retval() const
Returns the cached window exit code.
std::vector< std::string > split(const config_attribute_value &val)
const std::string unicode_em_dash
group< std::string > gender_toggle_
const unit_type & get_gender_unit_type(std::string gender) const
Returns a gendered variant of this unit_type.
Dialog was closed with the OK button.
A config object defines a single node in a WML file, with access to child nodes.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
base class of top level items, the only item which needs to store the final canvases to draw on...
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
std::pair< std::string, unsigned > item
void set_member_states(const T &value)
Sets the toggle values for all widgets besides the one associated with the specified value to false...
ng::flg_manager & flg_manager_