16 #define GETTEXT_DOMAIN "wesnoth-lib"
55 = find_widget<toggle_button>(
"male_toggle");
57 = find_widget<toggle_button>(
"female_toggle");
67 menu_button& var_box = find_widget<menu_button>(
"variation_box");
71 listbox& list = find_widget<listbox>(
"unit_type_list");
74 = find_widget<text_box>(
"filter_box",
false,
true);
96 column[
"label"] =
units_.back()->race()->plural_name();
97 row_data.emplace(
"race", column);
99 column[
"label"] =
units_.back()->type_name();
100 if(
units_.back()->type_name().str() !=
units_.back()->id()) {
101 column[
"label"] +=
" (" +
units_.back()->id() +
")";
103 row_data.emplace(
"unit_type", column);
114 ERR_GUI_G <<
"no unit types found for unit create dialog; not good"
119 [
this](
const std::size_t
i) {
return units_[
i]->race()->plural_name(); },
120 [
this](
const std::size_t
i) {
return units_[
i]->type_name(); }
131 listbox& list = find_widget<listbox>(
"unit_type_list");
140 if(selected_row < 0) {
142 }
else if(
static_cast<std::size_t
>(selected_row) >=
units_.size()) {
144 ERR_GUI_G <<
"unit create dialog has more list items than known unit "
156 const int selected_row
157 = find_widget<listbox>(
"unit_type_list").get_selected_row();
159 if(selected_row == -1) {
171 find_widget<unit_preview_pane>(
"unit_details").set_display_data(*ut);
176 const int selected_row
177 = find_widget<listbox>(
"unit_type_list").get_selected_row();
179 if(selected_row == -1) {
186 return units_[selected_row]->has_gender_variation(
gender);
189 menu_button& var_box = find_widget<menu_button>(
"variation_box");
190 std::vector<config> var_box_values;
191 var_box_values.emplace_back(
"label",
_(
"unit_variation^Default Variation"),
"variation_id",
"");
193 const auto& ut = *
units_[selected_row];
194 const auto& uvars = ut.variation_types();
198 unsigned n = 0, selection = 0;
200 for(
const auto& pair : uvars) {
203 const std::string& uv_id = pair.first;
206 std::string uv_label;
210 uv_label = uv.
type_name() +
" (" + uv_id +
")";
215 var_box_values.emplace_back(
"label", uv_label,
"variation_id", uv_id);
228 var_box.
set_values(var_box_values, selection);
233 find_widget<listbox>(
"unit_type_list")
237 units_[row]->race()->plural_name(),
252 menu_button& var_box = find_widget<menu_button>(
"variation_box");
Abstract base class for all modal dialogs.
int get_retval() const
Returns the cached window exit code.
virtual void pre_show() override
Actions to be taken before showing the window.
unit_race::GENDER gender_
group< unit_race::GENDER > gender_toggle
unit_race::GENDER gender()
Gender choice from the user.
void list_item_clicked()
Callbacks.
void variation_menu_callback()
void filter_text_changed(const std::string &text)
virtual void post_show() override
Actions to be taken after the window has been shown.
void update_displayed_type()
void gender_toggle_callback(const unit_race::GENDER val)
std::vector< const unit_type * > units_
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.
bool select_last_row(const bool select=true)
Does exactly as advertised: selects the list's last row.
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.
void set_active_sorter(std::string_view id, sort_order::type order, bool select_first=false)
Sorts the listbox by a pre-set sorting option.
void set_sorters(Args &&... functors)
Registers sorting controls using magic index IDs.
void clear()
Removes all the rows in the listbox, clearing it.
int get_selected_row() const
Returns the first selected row.
void set_text_changed_callback(std::function< void(text_box_base *textbox, const std::string text)> cb)
Set the text_changed callback.
A widget that allows the user to input text in single line.
void keyboard_capture(widget *widget)
void add_to_keyboard_chain(widget *widget)
Adds the widget to the keyboard chain.
void build_unit_type(const unit_type &ut, unit_type::BUILD_STATUS status) const
Makes sure the provided unit_type is built to the specified level.
const unit_type_map & types() const
A single unit type that the player may recruit.
const unit_type & get_variation(const std::string &id) const
const t_string & variation_name() const
const t_string & type_name() const
The name of the unit in the current language setting.
static std::string _(const char *str)
Define the common log macros for the gui toolkit.
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.
auto make_ci_matcher(std::string_view filter_text)
Returns a function which performs locale-aware case-insensitive search.
static map_location::direction n
unit_type_data unit_types
static unit_race::GENDER last_gender
static std::string last_chosen_type_id
static std::string last_variation