15 #define GETTEXT_DOMAIN "wesnoth-lib"
22 #ifdef GUI2_EXPERIMENTAL_LISTBOX
93 = find_widget<ttoggle_button>(&window,
"male_toggle",
false);
95 = find_widget<ttoggle_button>(&window,
"female_toggle",
false);
103 dialog_callback<tunit_create, &tunit_create::gender_toggle_callback>);
105 female_toggle.set_callback_state_change(
106 dialog_callback<tunit_create, &tunit_create::gender_toggle_callback>);
108 tlistbox& list = find_widget<tlistbox>(&window,
"unit_type_list",
false);
111 = find_widget<ttext_box>(&window,
"filter_box",
false,
true);
116 window.keyboard_capture(filter);
118 #ifdef GUI2_EXPERIMENTAL_LISTBOX
125 dialog_callback<tunit_create, &tunit_create::list_item_clicked>);
132 if(
i.second.do_not_list())
140 std::map<std::string, string_map> row_data;
143 column[
"label"] =
units_.back()->race()->plural_name();
144 row_data.insert(std::make_pair(
"race", column));
145 column[
"label"] =
units_.back()->type_name();
146 row_data.insert(std::make_pair(
"unit_type", column));
157 ERR_GUI_G <<
"no unit types found for unit create dialog; not good"
161 std::vector<tgenerator_::torder_func> order_funcs(2);
174 return units_[i1]->type_name().str() <
units_[i2]->type_name().str();
179 return units_[i1]->race()->plural_name().str() <
units_[i2]->race()->plural_name().str();
184 return units_[i1]->type_name().str() >
units_[i2]->type_name().str();
189 return units_[i1]->race()->plural_name().str() >
units_[i2]->race()->plural_name().str();
194 tlistbox& list = find_widget<tlistbox>(&window,
"unit_type_list",
false);
203 if(selected_row < 0) {
205 }
else if(static_cast<size_t>(selected_row) >=
units_.size()) {
207 ERR_GUI_G <<
"unit create dialog has more list items than known unit "
218 const int selected_row
219 = find_widget<tlistbox>(&window,
"unit_type_list",
false).get_selected_row();
221 if(selected_row == -1) {
225 find_widget<tunit_preview_pane>(&window,
"unit_details",
false)
226 .set_displayed_type(
units_[selected_row]);
233 tlistbox& list = find_widget<tlistbox>(&window,
"unit_type_list",
false);
235 const std::vector<std::string> words =
utils::split(text,
' ');
249 = find_widget<tlabel>(*it,
"unit_type",
false);
252 for(
const auto & word : words)
254 found = std::search(type_label.
label().
str().begin(),
267 show_items[
i] = found;
Define the common log macros for the gui toolkit.
void set_row_shown(const unsigned row, const bool shown)
Makes a row visible or invisible.
std::vector< const unit_type * > units_
void connect_signal_notify_modified(tdispatcher &dispatcher, const tsignal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
void gender_toggle_callback(twindow &window)
bool compare_race(unsigned i1, unsigned i2) const
bool select_row(const unsigned row, const bool select=true)
Selectes a row.
REGISTER_DIALOG(label_settings)
std::vector< std::string > last_words_
void filter_text_changed(ttext_ *textbox, const std::string &text)
unit_type_data unit_types
Class for a single line text area.
void list_item_clicked(twindow &window)
Callbacks.
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
bool chars_equal_insensitive(char a, char b)
Dialog is closed with ok button.
unsigned get_item_count() const
Returns the number of items in the listbox.
const unit_type_map & types() const
void add_row(const string_map &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
static std::string last_chosen_type_id
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.
void set_column_order(unsigned col, const std::vector< tgenerator_::torder_func > &func)
Iterator for the tchild items.
bool compare_race_rev(unsigned i1, unsigned i2) const
const t_string & label() const
static unit_race::GENDER last_gender
void pre_show(twindow &window)
Inherited from tdialog.
std::map< std::string, t_string > string_map
bool compare_type(unsigned i1, unsigned i2) const
GLenum GLenum GLvoid GLvoid * column
T get_active_member_value()
Returns the value paired with the currently activiely toggled member of the group.
unit_race::GENDER gender_
bool compare_type_rev(unsigned i1, unsigned i2) const
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLenum GLenum GLvoid * row
void set_callback_value_change(const std::function< void(twidget &)> &callback)
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
void add_member(tselectable_ *widget, const T &value)
Adds a widget/value pair to the group vector.
const std::string & str() const
int get_selected_row() const
Returns the first selected row.
GLsizei const GLcharARB ** string
tgroup< unit_race::GENDER > gender_toggle
void set_member_states(const T &value)
Sets the toggle values for all widgets besides the one associated with the specified value to false...
Abstract base class for text items.
void clear()
Removes all the rows in the listbox, clearing it.
void post_show(twindow &window)
Inherited from tdialog.
const tgrid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.
void set_text_changed_callback(std::function< void(ttext_ *textbox, const std::string text)> cb)
Set the text_changed callback.