15 #define GETTEXT_DOMAIN "wesnoth-lib"
47 , recruit_map_(recruit_map)
51 for(
const auto& pair : recruit_map) {
52 recruit_list_.push_back(pair.first);
55 std::sort(recruit_list_.begin(), recruit_list_.end(), [](
const unit_type* t1,
const unit_type* t2) {
56 return t1->type_name().str() < t2->type_name().str();
73 const std::vector<std::string> words =
utils::split(text,
' ');
79 boost::dynamic_bitset<> show_items;
89 for(
const auto & word : words)
102 show_items[
i] = found;
111 text_box* filter = find_widget<text_box>(&
window,
"filter_box",
false,
true);
115 listbox& list = find_widget<listbox>(&
window,
"recruit_list",
false);
123 find_widget<button>(&
window,
"show_help",
false),
132 std::string image_string = recruit->image() +
"~RC(" + recruit->flag_rgb() +
">"
135 const bool is_recruitable = error.
empty();
137 const std::string cost_string = std::to_string(recruit->cost());
139 column[
"use_markup"] =
"true";
142 column[
"tooltip"] = error;
145 column[
"label"] = image_string + (is_recruitable ?
"" :
"~GS()");
146 row_data.emplace(
"unit_image", column);
149 row_data.emplace(
"unit_type", column);
152 row_data.emplace(
"unit_cost", column);
155 if(!is_recruitable) {
167 const int selected_row
168 = find_widget<listbox>(
get_window(),
"recruit_list",
false).get_selected_row();
170 if(selected_row == -1) {
174 find_widget<unit_preview_pane>(
get_window(),
"recruit_details",
false)
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.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
std::map< const unit_type *, t_string > & recruit_map_
void filter_text_changed(const std::string &text)
std::vector< std::string > last_words_
std::vector< const unit_type * > recruit_list_
A vector of unit types in the order listed in the UI.
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
t_string get_image() const
Wrapper for label.
void set_image(const t_string &label)
Wrapper for set_label.
void set_row_shown(const unsigned row, const bool shown)
Makes a row visible or invisible.
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.
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.
Class for a single line text area.
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.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
This class stores all the data for a single 'side' (in game nomenclature).
const std::string & color() const
A single unit type that the player may recruit.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
std::string span_color(const color_t &color)
Returns a Pango formatting string using the provided color_t object.
static std::string gray_if_unrecruitable(const std::string &text, const bool is_recruitable)
static const color_t inactive_row_color(0x96, 0x96, 0x96)
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
@ OK
Dialog was closed with the OK button.
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Functions to load and save images from/to disk.
bool ci_search(const std::string &s1, const std::string &s2)
std::vector< std::string > split(const config_attribute_value &val)
This file contains the settings handling of the widget library.
The basic class for representing 8-bit RGB or RGBA colour values.