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())
56 find_widget<label>(&
window,
"starting_pos",
false).set_label(std::to_string(
side_));
81 find_widget<button>(&
window,
"type_profile",
false).connect_click_handler(
87 listbox& list = find_widget<listbox>(&
window,
"faction_list",
false);
100 const std::string name = side[
"name"].str();
102 const std::string
flag_rgb = !side[
"flag_rgb"].
empty() ? side[
"flag_rgb"].str() :
"magenta";
105 data.emplace(
"faction_image",
item);
107 item[
"label"] = name;
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) {
167 return translation::compare(s1, s2) < 0;
170 find_widget<styled_widget>(
get_window(),
"recruits",
false).set_label(
utils::join(recruit_names,
"\n"));
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();
218 find_widget<drawing>(
get_window(),
"leader_image",
false).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.
ng::flg_manager & flg_manager_
const std::string tc_color_
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
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.
window * get_window()
Returns a pointer to the dialog's window.
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.
base class of top level items, the only item which needs to store the final canvases to draw on.
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
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 & id() const
The id for this unit_type.
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.
Define the common log macros for the gui toolkit.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
const std::string unicode_em_dash
const std::string unicode_bullet
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.
std::pair< std::string, unsigned > item
void show_unit_description(const unit &u)
const std::string random_enemy_picture("units/random-dice.png")
std::set< std::string > & encountered_units()
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::vector< std::string > split(const config_attribute_value &val)
This file contains the settings handling of the widget library.
static map_location::DIRECTION s
unit_type_data unit_types