20 #define GETTEXT_DOMAIN "wesnoth-lib"
65 static std::vector<ttip>
tips;
81 static std::vector<std::string>
result;
86 std::function<
void(tgui_definition&,
128 typedef std::map<std::string ,
134 std::map<std::string, twindow_definition>
windows;
139 const std::string& definition_type,
140 const std::vector<tcontrol_definition_ptr>& definitions);
338 id = cfg[
"id"].str();
345 DBG_GUI_P <<
"Parsing gui " <<
id <<
'\n';
351 widget_type.second(*
this, widget_type.first, cfg,
nullptr);
357 std::pair<std::string, twindow_builder> child;
358 child.first = child.second.read(
w);
362 if(
id ==
"default") {
365 for(std::vector<std::string>::const_iterator
itor
370 const std::string error_msg(
371 "Window not defined in WML: '" + *
itor
372 +
"'. Perhaps a mismatch between data and source versions."
373 " Try --data-dir <trunk-dir>");
432 const std::string& definition_type,
433 const std::vector<tcontrol_definition_ptr>& definitions)
435 for(
const auto & def : definitions)
443 .insert(std::make_pair(def->id, def));
447 symbols[
"definition"] = definition_type;
448 symbols[
"id"] =
"default";
450 "doesn't contain the definition for '$id'.",
459 static std::map<std::string, twindow_builder>
windows;
462 static std::map<std::string, tgui_definition>
guis;
465 static std::map<std::string, tgui_definition>::const_iterator
current_gui = guis.end();
502 read(cfg, *stream, &validator);
507 ERR_GUI_P <<
"Setting: could not read file 'data/gui/default.cfg'."
512 ERR_GUI_P <<
"Setting: could not read file 'data/gui/schema.cfg'."
519 std::pair<std::string, tgui_definition> child;
520 child.first = child.second.read(
g);
524 VALIDATE(guis.find(
"default") != guis.end(),
_(
"No default gui defined."));
526 current_gui = guis.find(
"default");
527 current_gui->second.activate();
553 VALIDATE(draw,
_(
"No state or draw section defined."));
560 const std::string& definition_type,
569 const std::string& definition_type,
570 const std::vector<tcontrol_definition_ptr>& definitions)
572 DBG_GUI_P <<
"Load definition '" << definition_type <<
"'.\n";
577 const std::string& definition)
579 const tgui_definition::tcontrol_definition_map::const_iterator
580 #ifdef GUI2_EXPERIMENTAL_LISTBOX
582 = (control_type ==
"list")
583 ? current_gui->second.control_definition.find(
"listbox")
584 : current_gui->second.control_definition.find(
588 = current_gui->second.control_definition.find(control_type);
592 != current_gui->second.control_definition.end(),
593 "Type '" << control_type <<
"' is unknown.");
595 std::map<std::string, tcontrol_definition_ptr>::const_iterator control
596 = control_definition->second.find(definition);
598 if(control == control_definition->second.end()) {
599 LOG_GUI_G <<
"Control: type '" << control_type <<
"' definition '"
600 << definition <<
"' not found, falling back to 'default'.\n";
601 control = control_definition->second.find(
"default");
602 assert(control != control_definition->second.end());
605 for(std::vector<tresolution_definition_ptr>::const_iterator
itor
606 = (*control->second).resolutions.begin(),
607 end = (*control->second).resolutions.end();
623 std::vector<twindow_builder::tresolution>::const_iterator
628 std::map<std::string, twindow_builder>::const_iterator window
629 = current_gui->second.window_types.find(type);
632 if(window == current_gui->second.window_types.end()) {
639 for(std::vector<twindow_builder::tresolution>::const_iterator
itor
640 = window->second.resolutions.begin(),
641 end = window->second.resolutions.end();
645 if(settings::screen_width <= itor->window_width
646 && settings::screen_height <= itor->window_height) {
Define the common log macros for the gui toolkit.
std::map< std::string, twindow_builder > window_types
bool new_widgets
Do we wish to use the new library or not.
child_itors child_range(const std::string &key)
std::string sound_button_click_
static config_cache & instance()
Get reference to the singleton object.
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
unsigned double_click_time
const char * what() const
void register_window(const std::string &id)
Registers a window.
std::string sound_toggle_button_click_
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
GLuint GLuint GLsizei GLenum type
itor second functor(surf, f[1])
std::vector< ttip > load(const config &cfg)
Loads the tips from a config.
std::string sound_button_click
static std::map< std::string, twindow_builder > windows
Map with all known windows, (the builder class builds a window).
tcontrol_definition_map control_definition
static void update_screen_size()
Update the size of the screen variables in settings.
tstate_definition(const config &cfg)
std::string sound_toggle_panel_click_
t_string has_helptip_message_
static std::vector< std::string > get_registered_window_list()
Returns a copy of the list of registered windows.
void activate() const
Activates a gui.
unsigned gamemap_width
The size of the map area, if not available equal to the screen size.
static tregistered_widget_type & registred_widget_type()
std::map< std::string, twindow_definition > windows
std::string sound_slider_adjust
Helper struct to signal that get_window_builder failed.
std::map< std::string, preproc_define > preproc_map
std::string missing_mandatory_wml_key(const std::string §ion, const std::string &key, const std::string &primary_key, const std::string &primary_value)
Returns a standard message for a missing wml key.
std::map< std::string, std::function< void(tgui_definition &, const std::string &, const config &, const char *key)> > tregistered_widget_type
void load_widget_definitions(tgui_definition &gui_definition, const std::string &definition_type, const std::vector< tcontrol_definition_ptr > &definitions)
Loads the definitions of a widget.
A class inherited from ttext_box that displays its input as stars.
static std::vector< std::string > & registered_window_types()
Returns the list of registered windows.
One of the realizations of serialization/validator.hpp abstract validator.
void set_cfg(const config &cfg)
Sets the config.
unsigned repeat_button_repeat_time
void register_widget(const std::string &id, std::function< void(tgui_definition &gui_definition, const std::string &definition_type, const config &cfg, const char *key)> functor)
Registers a widgets.
unsigned double_click_time_
static UNUSEDNOWARN std::string _(const char *str)
void load_widget_definitions(const std::string &definition_type, const std::vector< tcontrol_definition_ptr > &definitions)
static std::map< std::string, tgui_definition > guis
Map with all known guis.
std::map< std::string, t_string > string_map
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
t_string has_helptip_message
Used to manage with not initialized validators Supposed to be thrown from the constructor.
std::vector< ttip > shuffle(const std::vector< ttip > &tips)
Shuffles the tips.
GLubyte GLubyte GLubyte GLubyte w
std::string sound_slider_adjust_
std::vector< twindow_builder::tresolution >::const_iterator get_window_builder(const std::string &type)
Returns an interator to the requested builder.
void draw(surface screen)
unsigned popup_show_delay_
tresolution_definition_ptr get_control(const std::string &control_type, const std::string &definition)
static std::map< std::string, tgui_definition >::const_iterator current_gui
Points to the current gui.
const std::string & read(const config &cfg)
std::map< std::string, tfilter >::iterator itor
std::string get_wml_location(const std::string &filename, const std::string ¤t_dir=std::string())
Returns a complete path to the actual WML file or directory or an empty string if the file isn't pres...
Contains the general settings which have a default.
unsigned gamemap_x_offset
The offset between the left edge of the screen and the gamemap.
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::vector< ttip > tips_
unsigned screen_width
The screen resolution should be available for all widgets since their drawing method will depend on i...
Declarations for File-IO.
void read(config &cfg, std::istream &in, abstract_validator *validator)
std::string sound_toggle_panel_click
std::istream * preprocess_file(std::string const &fname, preproc_map *defines)
void load_settings()
Loads the setting for the theme.
unsigned popup_show_delay
These are copied from the active gui.
bool find(E event, F functor)
Tests whether an event handler is available.
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
unsigned repeat_button_repeat_time_
unsigned popup_show_time_
Realization of serialization/validator.hpp abstract validator.
A config object defines a single node in a WML file, with access to child nodes.
std::string sound_toggle_button_click
std::vector< ttip > get_tips()
std::map< std::string, std::map< std::string, tcontrol_definition_ptr > > tcontrol_definition_map
GLsizei const GLcharARB ** string
static std::vector< ttip > tips