16 #define GETTEXT_DOMAIN "wesnoth-lib" 32 , always_save_fields_(false)
36 , allow_plugin_skip_(true)
37 , show_even_without_video_(false)
46 struct window_stack_handler {
47 window_stack_handler(std::unique_ptr<window>& win) :
local_window(win) {
50 ~window_stack_handler() {
89 window_stack_handler push_window_stack(
window_);
127 template<
typename T,
typename... Args>
130 static_assert(std::is_base_of_v<field_base, T>,
"Type is not a field type");
131 auto field = std::make_unique<T>(std::forward<Args>(args)...);
132 T* res =
field.get();
138 const std::string&
id,
139 const bool mandatory,
140 const std::function<
bool()> callback_load_value,
141 const std::function<
void(
bool)> callback_save_value,
142 const std::function<
void(
widget&)> callback_change,
143 const bool initial_fire)
158 const bool mandatory,
159 bool& linked_variable,
160 const std::function<
void(
widget&)> callback_change,
161 const bool initial_fire)
164 =
new field_bool(
id, mandatory, linked_variable, callback_change, initial_fire);
171 const std::string&
id,
172 const bool mandatory,
173 const std::function<
int()> callback_load_value,
174 const std::function<
void(
const int)> callback_save_value)
177 id, mandatory, callback_load_value, callback_save_value);
184 const bool mandatory,
185 int& linked_variable)
194 const std::string&
id,
195 const bool mandatory,
196 const std::function<std::string()> callback_load_value,
197 const std::function<
void(
const std::string&)> callback_save_value,
198 const bool capture_focus)
201 id, mandatory, callback_load_value, callback_save_value);
212 const bool mandatory,
213 std::string& linked_variable,
214 const bool capture_focus)
227 const bool mandatory,
228 const std::string& text,
229 const bool use_markup)
T * register_field(Args &&... args)
Creates a new field of given type with given arguments.
void keyboard_capture(widget *widget)
void set_callback(const std::string &name, callback_function)
std::unique_ptr< window > & local_window
void attach_to_window(window &window)
Attaches the field to a window.
bool show_even_without_video_
Show the dialog even with –nogui? Some dialogs need to be shown even when –nogui is specified if th...
Specialized field class for boolean.
virtual void post_build(window &window)
Actions to be taken directly after the window is build.
bool allow_plugin_skip_
Allow plugins to skip through the dialog? Most dialogs install a plugins context to allow plugins to ...
static CVideo & get_singleton()
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.
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed...
bool always_save_fields_
Always save the fields upon closing.
bool show(const unsigned auto_close_time=0)
Shows the window.
field< int, integer_selector > field_integer
void detach_from_window()
Detaches the field from a window.
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::vector< std::unique_ptr< class field_base > > fields_
Contains the automatically managed fields.
bool restore_
Restore the screen after showing?
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.
void remove_from_window_stack(window *window)
Removes a entry from the open_window_stack list.
void widget_finalize()
Finalizes the widget.
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
std::string id
Text to match against addon_info.tags()
#define DOUBLE_CLICK_EVENT
virtual void init_fields(window &window)
Initializes all fields in the dialog and set the keyboard focus.
Default, unset return value.
virtual void finalize_fields(const bool save_fields)
When the dialog is closed with the OK status saves all fields.
Specialized field class for a styled_widget, used for labels and images.
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.
virtual const std::string & window_id() const =0
The id of the window to build.
int retval_
The window's exit code (return value).
std::unique_ptr< window > window_
The window object build for this dialog.
std::unique_ptr< window > build_window() const
Builds the window.
virtual void pre_show(window &window)
Actions to be taken before showing the window.
void widget_init()
Initializes the widget.
retval
Default window/dialog return values.
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
Dialog was closed with the OK button.
virtual void post_show(window &window)
Actions to be taken after the window has been shown.
std::string focus_
Contains the widget that should get the focus when the window is shown.
A config object defines a single node in a WML file, with access to child nodes.
Specialized field class for text.
void set_retval(int retval)
Convenience wrapper to set the window's exit code.
base class of top level items, the only item which needs to store the final canvases to draw on...
Template class to implement the generic field implementation.
static plugins_manager * get()
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...