The Battle for Wesnoth  1.15.1+dev
Macros | Typedefs | Functions | Variables
theme.cpp File Reference
#include "theme.hpp"
#include "desktop/battery_info.hpp"
#include "display.hpp"
#include "gettext.hpp"
#include "hotkey/hotkey_command.hpp"
#include "hotkey/hotkey_item.hpp"
#include "log.hpp"
#include "sdl/rect.hpp"
#include "serialization/string_utils.hpp"
#include "wml_exception.hpp"
#include <sstream>
#include <utility>
Include dependency graph for theme.cpp:

Go to the source code of this file.

Macros

#define DBG_DP   LOG_STREAM(debug, log_display)
 
#define LOG_DP   LOG_STREAM(info, log_display)
 
#define ERR_DP   LOG_STREAM(err, log_display)
 

Typedefs

typedef std::map< std::string, configknown_themes_map
 

Functions

static std::size_t compute (std::string expr, std::size_t ref1, std::size_t ref2=0)
 
static _rect read_rect (const config &cfg)
 
static SDL_Rect read_sdl_rect (const config &cfg)
 
static std::string resolve_rect (const std::string &rect_str)
 
static configfind_ref (const std::string &id, config &cfg, bool remove=false)
 
static config get_resolution (const config &resolutions, const std::string &id)
 Returns a copy of the wanted resolution. More...
 
static config expand_partialresolution (const config &theme)
 Returns a config with all partial resolutions of a theme expanded. More...
 
static void do_resolve_rects (const config &cfg, config &resolved_config, config *resol_cfg=nullptr)
 

Variables

static lg::log_domain log_display ("display")
 

Macro Definition Documentation

◆ DBG_DP

#define DBG_DP   LOG_STREAM(debug, log_display)

Definition at line 33 of file theme.cpp.

Referenced by theme::add_object().

◆ ERR_DP

#define ERR_DP   LOG_STREAM(err, log_display)

Definition at line 35 of file theme.cpp.

Referenced by do_resolve_rects(), and theme::set_resolution().

◆ LOG_DP

#define LOG_DP   LOG_STREAM(info, log_display)

Definition at line 34 of file theme.cpp.

Referenced by theme::modify_label(), and theme::set_resolution().

Typedef Documentation

◆ known_themes_map

typedef std::map<std::string, config> known_themes_map

Definition at line 925 of file theme.cpp.

Function Documentation

◆ compute()

static std::size_t compute ( std::string  expr,
std::size_t  ref1,
std::size_t  ref2 = 0 
)
static

◆ do_resolve_rects()

static void do_resolve_rects ( const config cfg,
config resolved_config,
config resol_cfg = nullptr 
)
static

◆ expand_partialresolution()

static config expand_partialresolution ( const config theme)
static

Returns a config with all partial resolutions of a theme expanded.

Parameters
themeThe original object, whose objects need to be expanded.
Returns
A new object with the expanded resolutions in a theme. This object no longer contains partial resolutions.

Definition at line 204 of file theme.cpp.

References config::add_child(), config::child_range(), find_ref(), get_resolution(), config::merge_attributes(), missing_mandatory_wml_key(), preferences::resolution(), and VALIDATE.

Referenced by theme::theme().

◆ find_ref()

static config& find_ref ( const std::string &  id,
config cfg,
bool  remove = false 
)
static

◆ get_resolution()

static config get_resolution ( const config resolutions,
const std::string &  id 
)
static

Returns a copy of the wanted resolution.

The function returns a copy since our caller uses a copy of this resolution as base to expand a partial resolution.

Parameters
resolutionsA config object containing the expanded resolutions.
idThe id of the resolution to return.
Exceptions
config::errorIf the id is not found.
Returns
A copy of the resolution config.

Definition at line 183 of file theme.cpp.

References config::child_range(), error(), and preferences::resolution().

Referenced by expand_partialresolution().

◆ read_rect()

static _rect read_rect ( const config cfg)
static

Definition at line 62 of file theme.cpp.

References mp_ui_alerts::items, and utils::split().

Referenced by do_resolve_rects(), and read_sdl_rect().

◆ read_sdl_rect()

static SDL_Rect read_sdl_rect ( const config cfg)
static

Definition at line 85 of file theme.cpp.

References read_rect(), _rect::x1, _rect::x2, _rect::y1, and _rect::y2.

◆ resolve_rect()

static std::string resolve_rect ( const std::string &  rect_str)
static

Definition at line 97 of file theme.cpp.

References compute(), mp_ui_alerts::items, and utils::split().

Referenced by do_resolve_rects().

Variable Documentation

◆ log_display

lg::log_domain log_display("display")
static