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)
53 struct window_stack_handler {
57 ~window_stack_handler() {
67 DBG_DP <<
"modal_dialog::show denied";
90 window_stack_handler push_window_stack(
this);
118 template<
typename T,
typename... Args>
121 static_assert(std::is_base_of_v<field_base, T>,
"Type is not a field type");
122 auto field = std::make_unique<T>(std::forward<Args>(args)...);
123 T* res =
field.get();
129 const std::string&
id,
130 const bool mandatory,
131 const std::function<
bool()>& callback_load_value,
132 const std::function<
void(
bool)>& callback_save_value,
133 const std::function<
void(
widget&)>& callback_change,
134 const bool initial_fire)
149 const bool mandatory,
150 bool& linked_variable,
151 const std::function<
void(
widget&)>& callback_change,
152 const bool initial_fire)
155 =
new field_bool(
id, mandatory, linked_variable, callback_change, initial_fire);
162 const std::string&
id,
163 const bool mandatory,
164 const std::function<
int()>& callback_load_value,
165 const std::function<
void(
int)>& callback_save_value)
168 id, mandatory, callback_load_value, callback_save_value);
175 const bool mandatory,
176 int& linked_variable)
185 const std::string&
id,
186 const bool mandatory,
187 const std::function<std::string()>& callback_load_value,
188 const std::function<
void(
const std::string&)>& callback_save_value,
189 const bool capture_focus)
192 id, mandatory, callback_load_value, callback_save_value);
203 const bool mandatory,
204 std::string& linked_variable,
205 const bool capture_focus)
218 const bool mandatory,
219 const std::string& text,
220 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.
void init_fields()
Initializes all fields in the dialog and set the keyboard focus.
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.
virtual void post_show()
Actions to be taken after the window has been shown.
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.
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)
virtual void pre_show()
Actions to be taken before showing the window.
bool allow_plugin_skip_
Allow plugins to skip through the dialog? Most dialogs install a plugins context to allow plugins to ...
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.
T * register_field(Args &&... args)
Creates a new field of given type with given arguments.
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 ...
bool show(const unsigned auto_close_time=0)
Shows the window.
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)
widget * find(const std::string_view id, const bool must_be_active) override
See widget::find.
int show(unsigned auto_close_timeout=0)
Shows the window, running an event loop until it should close.
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.