15 #define GETTEXT_DOMAIN "wesnoth-lib" 45 , flg_manager_(flg_manager)
48 , last_faction_(flg_manager.current_faction_index())
49 , last_leader_(flg_manager.current_leader_index())
50 , last_gender_(flg_manager.current_gender_index())
81 find_widget<button>(&
window,
"type_profile",
false).connect_click_handler(
87 listbox& list = find_widget<listbox>(&
window,
"faction_list",
false);
89 window.keyboard_capture(&list);
100 const std::string name = side[
"name"].str();
102 const std::string
flag_rgb = !side[
"flag_rgb"].
empty() ? side[
"flag_rgb"].str() :
"magenta";
104 item[
"label"] = (
formatter() << side[
"image"] <<
"~RC(" << flag_rgb <<
">" <<
tc_color_ <<
")").str();
105 data.emplace(
"faction_image", item);
107 item[
"label"] = name;
108 data.emplace(
"faction_name", item);
120 const int selected_row = find_widget<listbox>(
get_window(),
"faction_list",
false).get_selected_row();
122 if(selected_row == -1) {
132 std::vector<config> leaders;
139 leaders.emplace_back(
"label", unit->
type_name(),
"icon", icon);
140 }
else if(leader ==
"random") {
142 }
else if(leader ==
"null") {
145 leaders.emplace_back(
"label",
"?");
151 leader_dropdown.
set_values(leaders, std::min<int>(leaders.size() - 1, previous_leader_selection));
158 std::vector<t_string> recruit_names;
160 for(
const auto& recruit : recruit_list) {
166 std::sort(recruit_names.begin(), recruit_names.end(), [](
const std::string& s1,
const std::string& s2) {
181 return std::find(genders.begin(), genders.end(), gender) != genders.end();
187 button& profile_button = find_widget<button>(
get_window(),
"type_profile",
false);
188 const std::string& leader_type = find_widget<menu_button>(
get_window(),
"leader_menu",
false).get_value_string();
194 const std::string& leader_type = find_widget<menu_button>(
get_window(),
"leader_menu",
false).get_value_string();
Define the common log macros for the gui toolkit.
window(const builder_window::window_resolution &definition)
< Needs to be initialized in show.
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)
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
std::map< std::string, t_string > widget_item
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)
window * get_window()
Returns a pointer to the dialog's window.
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
Abstract base class for all modal dialogs.
group< std::string > gender_toggle_
const unit_type & get_gender_unit_type(std::string gender) const
Returns a gendered variant of this unit_type.
std::map< std::string, widget_item > widget_data
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_