16 #define GETTEXT_DOMAIN "wesnoth-lib"
30 #define DBG_DP LOG_STREAM(debug, log_display)
31 #define WRN_DP LOG_STREAM(warn, log_display)
38 , always_save_fields_(false)
41 , allow_plugin_skip_(true)
42 , show_even_without_video_(false)
54 DBG_DP <<
"modal_dialog::show denied";
93 template<
typename T,
typename... Args>
96 static_assert(std::is_base_of_v<field_base, T>,
"Type is not a field type");
97 auto field = std::make_unique<T>(std::forward<Args>(args)...);
104 const std::string&
id,
105 const bool mandatory,
106 const std::function<
bool()>& callback_load_value,
107 const std::function<
void(
bool)>& callback_save_value,
108 const std::function<
void(
widget&)>& callback_change,
109 const bool initial_fire)
124 const bool mandatory,
125 bool& linked_variable,
126 const std::function<
void(
widget&)>& callback_change,
127 const bool initial_fire)
130 =
new field_bool(
id, mandatory, linked_variable, callback_change, initial_fire);
137 const std::string&
id,
138 const bool mandatory,
139 const std::function<
int()>& callback_load_value,
140 const std::function<
void(
int)>& callback_save_value)
143 id, mandatory, callback_load_value, callback_save_value);
150 const bool mandatory,
151 int& linked_variable)
160 const std::string&
id,
161 const bool mandatory,
162 const std::function<std::string()>& callback_load_value,
163 const std::function<
void(
const std::string&)>& callback_save_value,
164 const bool capture_focus)
167 id, mandatory, callback_load_value, callback_save_value);
178 const bool mandatory,
179 std::string& linked_variable,
180 const bool capture_focus)
193 const bool mandatory,
194 const std::string& text,
195 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.
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 set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
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)
void set_accessor_string(const std::string &name, const std::function< std::string(config)> &)
static plugins_manager * get()
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed.
static lg::log_domain log_display("display")
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.
@ OK
Dialog was closed with the OK button.
@ CANCEL
Dialog was closed with the CANCEL button.
bool headless()
The game is running headless.