16 #define GETTEXT_DOMAIN "wesnoth-lib"
56 = find_widget<toggle_button>(&
window,
"male_toggle",
false);
58 = find_widget<toggle_button>(&
window,
"female_toggle",
false);
72 listbox& list = find_widget<listbox>(&
window,
"unit_type_list",
false);
75 = find_widget<text_box>(&
window,
"filter_box",
false,
true);
97 column[
"label"] =
units_.back()->race()->plural_name();
98 row_data.emplace(
"race", column);
100 column[
"label"] =
units_.back()->type_name();
101 if(
units_.back()->type_name().str() !=
units_.back()->id()) {
102 column[
"label"] +=
" (" +
units_.back()->id() +
")";
104 row_data.emplace(
"unit_type", column);
115 ERR_GUI_G <<
"no unit types found for unit create dialog; not good"
130 listbox& list = find_widget<listbox>(&
window,
"unit_type_list",
false);
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>(
this,
"unit_type_list",
false).get_selected_row();
158 if(selected_row == -1) {
170 find_widget<unit_preview_pane>(
this,
"unit_details",
false).set_displayed_type(*ut);
175 const int selected_row
176 = find_widget<listbox>(
this,
"unit_type_list",
false).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>(
this,
"variation_box",
false);
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 listbox& list = find_widget<listbox>(
this,
"unit_type_list",
false);
234 const std::vector<std::string> words =
utils::split(text,
' ');
240 boost::dynamic_bitset<> show_items;
249 = find_widget<label>(*it,
"unit_type",
false);
251 = find_widget<label>(*it,
"race",
false);
254 const std::string& unit_type_id =
units_[
i] ?
units_[
i]->id() :
"";
257 for(
const auto & word : words)
269 show_items[
i] = found;
285 menu_button& var_box = find_widget<menu_button>(
this,
"variation_box",
false);
Abstract base class for all modal dialogs.
int get_retval() const
Returns the cached window exit code.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
unit_race::GENDER gender_
group< unit_race::GENDER > gender_toggle
unit_race::GENDER gender()
Gender choice from the user.
std::vector< std::string > last_words_
void list_item_clicked()
Callbacks.
void variation_menu_callback()
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
void filter_text_changed(const std::string &text)
void update_displayed_type()
void gender_toggle_callback(const unit_race::GENDER val)
std::vector< const unit_type * > units_
Iterator for the child items.
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.
void set_row_shown(const unsigned row, const bool shown)
Makes a row visible or invisible.
void set_active_sorting_option(const order_pair &sort_by, const bool select_first=false)
Sorts the listbox by a pre-set sorting option.
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.
const grid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.
void register_translatable_sorting_option(const int col, translatable_sorter_func_t f)
Registers a special sorting function specifically for translatable values.
void clear()
Removes all the rows in the listbox, clearing it.
int get_selected_row() const
Returns the first selected row.
unsigned get_item_count() const
Returns the number of items in the listbox.
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.
base class of top level items, the only item which needs to store the final canvases to draw on.
void keyboard_capture(widget *widget)
void add_to_keyboard_chain(widget *widget)
Adds the widget to the keyboard chain.
const std::string & str() const
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.
bool ci_search(const std::string &s1, const std::string &s2)
std::vector< std::string > split(const config_attribute_value &val)
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