16 #define GETTEXT_DOMAIN "wesnoth-lib"
30 #define ERR_WML LOG_STREAM(err, log_wml)
43 const std::string&
id,
44 const bool must_be_active)
47 if(!stack.find_in_all_layers_) {
48 return stack.container_base::find(
id, must_be_active);
51 for(
unsigned i = 0;
i < stack.get_layer_count(); ++
i) {
52 if(W* res = stack.get_layer_grid(
i)->find(
id, must_be_active)) {
57 return stack.container_base::find(
id, must_be_active);
65 , find_in_all_layers_(false)
94 for(
const auto & builder : widget_builders) {
112 for(
unsigned int i = 0;
i < num_layers; ++
i) {
113 const bool selected = display_condition(
i);
135 for(
unsigned int i = 0;
i < num_layers; ++
i) {
198 return stacked_widget_implementation::find<widget>(*
this,
id, must_be_active);
203 return stacked_widget_implementation::find<const widget>(*
this,
id, must_be_active);
213 load_resolutions<resolution>(cfg);
226 grid = std::make_shared<builder_grid>(*child);
234 builder_stacked_widget::builder_stacked_widget(
const config& real_cfg)
238 if(&cfg != &real_cfg) {
239 lg::log_to_chat() <<
"Stacked widgets no longer require a [stack] tag. Instead, place [layer] tags directly in the widget definition.\n";
240 ERR_WML <<
"Stacked widgets no longer require a [stack] tag. Instead, place [layer] tags directly in the widget definition.";
245 stack.emplace_back(layer);
251 auto widget = std::make_unique<stacked_widget>(*
this);
253 DBG_GUI_G <<
"Window builder: placed stacked widget '" <<
id
254 <<
"' with definition '" <<
definition <<
"'.";
259 widget->init_grid(*conf->grid);
A config object defines a single node in a WML file, with access to child nodes.
config & mandatory_child(config_key_type key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
child_itors child_range(config_key_type key)
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Equivalent to mandatory_child, but returns an empty optional if the nth child was not found.
A generic container base class.
const grid & get_grid() const
virtual void select_item(const unsigned index, const bool select)=0
(De)selects an item.
virtual grid & item(const unsigned index)=0
Gets the grid of an item.
virtual unsigned get_item_count() const =0
Returns the number of items.
static std::unique_ptr< generator_base > build(const bool has_minimum, const bool has_maximum, const placement placement, const bool select)
Create a new generator.
virtual bool is_selected(const unsigned index) const =0
Returns whether the item is selected.
Basic template class to generate new items.
grid & create_item(const int index, const builder_grid &list_builder, const widget_item &item_data, const std::function< void(widget &)> &callback) override
Inherited from generator_base.
virtual void layout_children() override
See widget::layout_children.
static std::string _(const char *str)
std::map< std::string, t_string > widget_item
void swap_grid(grid *g, grid *content_grid, std::unique_ptr< widget > widget, const std::string &id)
Swaps an item in a grid for another one.
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::stringstream & log_to_chat()
Use this to show WML errors in the ingame chat.
typename const_clone< D, S >::reference const_clone_ref
std::vector< state_definition > state
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
#define VALIDATE(cond, message)
The macro to use for the validation of WML.