15 #define GETTEXT_DOMAIN "wesnoth-lib"
41 , recruit_map_(recruit_map)
45 for(
const auto& pair : recruit_map) {
46 recruit_list_.push_back(pair.first);
49 std::sort(recruit_list_.begin(), recruit_list_.end(), [](
const unit_type* t1,
const unit_type* t2) {
50 return t1->type_name().str() < t2->type_name().str();
67 const std::vector<std::string> words =
utils::split(text,
' ');
73 boost::dynamic_bitset<> show_items;
82 auto default_gender = !
type->genders().empty()
84 const auto* race =
type->race();
88 auto criteria = std::make_tuple(
91 std::to_string(
type->level()),
93 (race ? race->name(default_gender) :
""),
94 (race ? race->plural_name() :
"")
98 for(
const auto & word : words)
102 std::apply([&](
auto&&... criterion) {
112 show_items[
i] = found;
121 text_box* filter = find_widget<text_box>(&
window,
"filter_box",
false,
true);
125 listbox& list = find_widget<listbox>(&
window,
"recruit_list",
false);
133 find_widget<button>(&
window,
"show_help",
false),
142 std::string image_string = recruit->image() +
"~RC(" + recruit->flag_rgb() +
">"
145 const bool is_recruitable = error.
empty();
147 const std::string cost_string = std::to_string(recruit->cost());
149 column[
"use_markup"] =
"true";
152 column[
"tooltip"] = error;
155 column[
"label"] = image_string + (is_recruitable ?
"" :
"~GS()");
156 row_data.emplace(
"unit_image", column);
159 row_data.emplace(
"unit_type", column);
162 row_data.emplace(
"unit_cost", column);
165 if(!is_recruitable) {
177 const int selected_row
178 = find_widget<listbox>(
get_window(),
"recruit_list",
false).get_selected_row();
180 if(selected_row == -1) {
184 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.
static std::string alignment_description(unit_alignments::type align, unit_race::GENDER gender=unit_race::MALE)
Implementation detail of unit_type::alignment_description.
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)
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.
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)
The basic class for representing 8-bit RGB or RGBA colour values.