16 #define GETTEXT_DOMAIN "wesnoth-lib"
36 LOG_GUI_G <<
"Initializing UI subststem.";
41 config guis_cfg, addons_cfg;
47 std::string current_file;
48 const std::string schema_file =
"schema/gui.cfg";
53 current_file =
"gui/_main.cfg";
59 ERR_GUI_P <<
"Setting: could not read gui file: " << current_file;
61 ERR_GUI_P <<
"Setting: could not read schema file: " << schema_file;
70 std::vector<std::string> user_dirs;
73 std::vector<std::string> user_files;
78 for(
const std::string& umc : user_dirs) {
80 const std::string gui_file = umc +
"/gui-theme.cfg";
86 addons_cfg.
append(addon_cfg);
90 ERR_GUI_P <<
"Setting: could not read gui file: " << current_file;
92 ERR_GUI_P <<
"Setting: could not read schema file: " << schema_file;
101 const std::string
id =
g[
"id"];
103 auto [iter, is_unique] =
guis.try_emplace(
id,
g);
106 ERR_GUI_P <<
"GUI Theme ID '" <<
id <<
"' already exists.";
108 if(
id ==
"default") {
118 const std::string
id =
g[
"id"];
121 auto [iter, is_unique] =
guis.try_emplace(
id,
g);
124 ERR_GUI_P <<
"GUI Theme ID '" <<
id <<
"' already exists.";
137 if (current_theme.empty() || current_theme ==
"default") {
142 if (
gui.first == current_theme) {
146 if (gui_itor !=
guis.end()) {
152 ERR_GUI_P <<
"Missing [gui] definition for '" << current_theme <<
"'";
A config object defines a single node in a WML file, with access to child nodes.
void append(const config &cfg)
Append data from another config object to this one.
child_itors child_range(config_key_type key)
static config_cache & instance()
Get reference to the singleton object.
Realization of serialization/validator.hpp abstract validator.
Declarations for File-IO.
static std::string _(const char *str)
Define the common log macros for the gui toolkit.
std::string id
Text to match against addon_info.tags()
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs, name_mode mode, filter_mode filter, reorder_mode reorder, file_tree_checksum *checksum)
Get a list of all files and/or directories in a given directory.
static bool file_exists(const bfs::path &fpath)
utils::optional< std::string > get_wml_location(const std::string &path, const utils::optional< std::string > ¤t_dir)
Returns a translated path to the actual file or directory, if it exists.
std::unique_ptr< std::istream > scoped_istream
std::string get_short_wml_path(const std::string &filename)
Returns a short path to filename, skipping the (user) data directory.
std::string get_addons_dir()
void update_screen_size_variables()
Update the size of the screen variables in settings.
void init()
Initializes the GUI subsystems.
gui_theme_map_t guis
Map of all known GUIs.
void switch_theme(const std::string ¤t_theme)
Set and activate the given gui2 theme.
gui_theme_map_t::iterator current_gui
Iterator pointing to the current GUI.
gui_theme_map_t::iterator default_gui
Iterator pointing to the default GUI.
std::string::const_iterator iterator
filesystem::scoped_istream preprocess_file(const std::string &fname, preproc_map *defines)
Function to use the WML preprocessor on a file.
std::map< std::string, struct preproc_define > preproc_map
One of the realizations of serialization/validator.hpp abstract validator.
void read(config &cfg, std::istream &in, abstract_validator *validator)
This file contains the settings handling of the widget library.
Used to manage with not initialized validators Supposed to be thrown from the constructor.
Helper class, don't construct this directly.
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.