16 #define GETTEXT_DOMAIN "wesnoth-lib"
30 #define DBG_DP LOG_STREAM(debug, log_display)
31 #define WRN_DP LOG_STREAM(warn, log_display)
39 , always_save_fields_(false)
42 , allow_plugin_skip_(true)
43 , show_even_without_video_(false)
54 struct window_stack_handler {
58 ~window_stack_handler() {
68 DBG_DP <<
"modal_dialog::show denied";
91 window_stack_handler push_window_stack(
this);
119 template<
typename T,
typename... Args>
122 static_assert(std::is_base_of_v<field_base, T>,
"Type is not a field type");
123 auto field = std::make_unique<T>(std::forward<Args>(args)...);
124 T* res =
field.get();
130 const std::string&
id,
131 const bool mandatory,
132 const std::function<
bool()> callback_load_value,
133 const std::function<
void(
bool)> callback_save_value,
134 const std::function<
void(
widget&)> callback_change,
135 const bool initial_fire)
150 const bool mandatory,
151 bool& linked_variable,
152 const std::function<
void(
widget&)> callback_change,
153 const bool initial_fire)
156 =
new field_bool(
id, mandatory, linked_variable, callback_change, initial_fire);
163 const std::string&
id,
164 const bool mandatory,
165 const std::function<
int()> callback_load_value,
166 const std::function<
void(
const int)> callback_save_value)
169 id, mandatory, callback_load_value, callback_save_value);
176 const bool mandatory,
177 int& linked_variable)
186 const std::string&
id,
187 const bool mandatory,
188 const std::function<std::string()> callback_load_value,
189 const std::function<
void(
const std::string&)> callback_save_value,
190 const bool capture_focus)
193 id, mandatory, callback_load_value, callback_save_value);
204 const bool mandatory,
205 std::string& linked_variable,
206 const bool capture_focus)
219 const bool mandatory,
220 const std::string& text,
221 const bool use_markup)
A config object defines a single node in a WML file, with access to child nodes.
bool always_save_fields_
Always save the fields upon closing.
virtual void init_fields()
Initializes all fields in the dialog and set the keyboard focus.
virtual void post_show(window &window)
Actions to be taken after the window has been shown.
virtual void pre_show(window &window)
Actions to be taken before showing the window.
std::string focus_
Contains the widget that should get the focus when the window is shown.
std::vector< std::unique_ptr< class field_base > > fields_
Contains the automatically managed fields.
virtual const std::string & window_id() const =0
The ID of the window to build.
field_label * register_label(const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false)
Registers a new styled_widget as a label.
modal_dialog(const std::string &window_id)
field_text * register_text(const std::string &id, const bool mandatory, const std::function< std::string()> callback_load_value=nullptr, const std::function< void(const std::string &)> callback_save_value=nullptr, const bool capture_focus=false)
Creates a new text field.
bool allow_plugin_skip_
Allow plugins to skip through the dialog? Most dialogs install a plugins context to allow plugins to ...
T * register_field(Args &&... args)
Creates a new field of given type with given arguments.
virtual void finalize_fields(const bool save_fields)
When the dialog is closed with the OK status saves all fields.
bool show_even_without_video_
Show the dialog even with –nogui? Some dialogs need to be shown even when –nogui is specified if the ...
field_integer * register_integer(const std::string &id, const bool mandatory, const std::function< int()> callback_load_value=nullptr, const std::function< void(int)> callback_save_value=nullptr)
Creates a new integer field.
bool show(const unsigned auto_close_time=0)
Shows the window.
field_bool * register_bool(const std::string &id, const bool mandatory, const std::function< bool()> callback_load_value=nullptr, const std::function< void(bool)> callback_save_value=nullptr, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false)
Creates a new boolean field.
int retval_
The window's exit code (return value).
void widget_finalize()
Finalizes the widget.
void widget_init()
Initializes the widget.
void detach_from_window()
Detaches the field from a window.
void attach_to_window(window &window)
Attaches the field to a window.
Specialized field class for boolean.
Specialized field class for a styled_widget, used for labels and images.
Specialized field class for text.
Template class to implement the generic field implementation.
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 finish_build(const builder_window::window_resolution &)
int show(unsigned auto_close_timeout=0)
Shows the window, running an event loop until it should close.
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
void set_callback(const std::string &name, callback_function)
static plugins_manager * get()
#define DOUBLE_CLICK_EVENT
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed.
static lg::log_domain log_display("display")
void remove_from_window_stack(window *window)
Removes a entry from the open_window_stack list.
field< int, integer_selector > field_integer
const builder_window::window_resolution & get_window_builder(const std::string &type)
Returns an reference to the requested builder.
std::vector< window * > open_window_stack
Keeps track of any open windows of any type (modal, non-modal, or tooltip) in the order in which they...
retval
Default window/dialog return values.
@ OK
Dialog was closed with the OK button.
@ NONE
Default, unset return value.
bool headless()
The game is running headless.