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);
 
   95         column[
"label"] = 
units_.back()->race()->plural_name();
 
   96         row_data.emplace(
"race", column);
 
   98         column[
"label"] = 
units_.back()->type_name();
 
   99         if(
units_.back()->type_name().str() != 
units_.back()->id()) {
 
  100             column[
"label"] += 
" (" + 
units_.back()->id() + 
")";
 
  102         row_data.emplace(
"unit_type", column);
 
  113         ERR_GUI_G << 
"no unit types found for unit create dialog; not good" 
  118         [
this](
const std::size_t 
i) { 
return units_[
i]->race()->plural_name(); },
 
  119         [
this](
const std::size_t 
i) { 
return units_[
i]->type_name(); }
 
  130     listbox& list = find_widget<listbox>(
"unit_type_list");
 
  139     if(selected_row < 0) {
 
  141     } 
else if(
static_cast<std::size_t
>(selected_row) >= 
units_.size()) {
 
  143         ERR_GUI_G << 
"unit create dialog has more list items than known unit " 
  155     const int selected_row
 
  156         = find_widget<listbox>(
"unit_type_list").get_selected_row();
 
  158     if(selected_row == -1) {
 
  170     find_widget<unit_preview_pane>(
"unit_details").set_display_data(*ut);
 
  175     const int selected_row
 
  176         = find_widget<listbox>(
"unit_type_list").get_selected_row();
 
  178     if(selected_row == -1) {
 
  185         return units_[selected_row]->has_gender_variation(
gender);
 
  188     menu_button& var_box = find_widget<menu_button>(
"variation_box");
 
  189     std::vector<config> var_box_values;
 
  190     var_box_values.emplace_back(
"label", 
_(
"unit_variation^Default Variation"), 
"variation_id", 
"");
 
  192     const auto& ut = *
units_[selected_row];
 
  193     const auto& uvars = ut.variation_types();
 
  197     unsigned n = 0, selection = 0;
 
  199     for(
const auto& pair : uvars) {
 
  202         const std::string& uv_id = pair.first;
 
  205         std::string uv_label;
 
  209             uv_label = uv.
type_name() + 
" (" + uv_id + 
")";
 
  214         var_box_values.emplace_back(
"label", uv_label, 
"variation_id", uv_id);
 
  227     var_box.
set_values(var_box_values, selection);
 
  232     find_widget<listbox>(
"unit_type_list")
 
  236                 units_[row]->race()->plural_name(),
 
  251     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.
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