16 #define GETTEXT_DOMAIN "wesnoth-lib"
29 const std::string& caption,
31 const unsigned maximum_length)
42 const std::vector<wml_message_option>& option_list,
45 assert(!option_list.empty());
46 assert(chosen_option);
64 label& title = find_widget<label>(
"title");
77 label& caption = find_widget<label>(
"input_caption");
78 text_box& input = find_widget<text_box>(
"input",
true);
94 listbox& options = find_widget<listbox>(
"input_list",
true);
100 data[
"icon"][
"label"] = item.image();
101 data[
"label"][
"label"] = item.label();
102 data[
"label"][
"use_markup"] =
"true";
103 data[
"description"][
"label"] = item.description();
104 data[
"description"][
"use_markup"] =
"true";
133 = find_widget<text_box>(
"input",
true).get_value();
162 std::shared_ptr<wml_message_base> dlg;
165 }
else if(!left && right) {
167 }
else if(right && left) {
172 if(input.text_input_was_specified) {
173 dlg->set_input(input.caption, &input.text, input.maximum_length);
176 if(!options.option_list.empty()) {
177 dlg->set_option_list(options.option_list, &options.chosen_option);
181 return dlg->get_retval();
void set_variable(const std::string &key, wfl::variant &&value)
Main class to show messages to the user.
std::string * input_text_
The text input.
std::string portrait_
Filename of the portrait.
std::string message_
The message to show to the user.
void set_input(const std::string &caption, std::string *text, const unsigned maximum_length)
Sets the input text variables.
virtual void pre_show() override
bool has_input_
Do we need to show an input box?
unsigned input_maximum_length_
The maximum length of the input text.
bool mirror_
Mirror the portrait?
int * chosen_option_
The chosen option.
std::string input_caption_
The caption to show for the input text.
void set_option_list(const std::vector< wml_message_option > &option_list, int *chosen_option)
Sets the option list.
std::string title_
The title for the dialog.
std::vector< wml_message_option > option_list_
The list of options the user can choose.
virtual void post_show() override
Actions to be taken after the window has been shown.
Shows a dialog with two portraits, one on each side.
std::string second_portrait_
virtual void pre_show() override
Shows a dialog with the portrait on the left side.
Helper class for message options.
Shows a dialog with the portrait on the right side.
void set_can_wrap(const bool wrap)
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.
bool select_row(const unsigned row, const bool select=true)
Selects a row.
virtual void set_value(const std::string &text)
The set_value is virtual for the password_box class.
void set_maximum_length(const std::size_t maximum_length)
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 set_escape_disabled(const bool escape_disabled)
Disable the escape key.
void set_click_dismiss(const bool click_dismiss)
int show_wml_message(const std::string &title, const std::string &message, const wml_message_portrait *left, const wml_message_portrait *right, const wml_message_options &options, const wml_message_input &input)
Helper function to show a portrait.
REGISTER_DIALOG(editor_edit_unit)
std::map< std::string, widget_item > widget_data
Parameter pack for message list input options.
Parameter pack for message portrait.