28 #define LOG_NG LOG_STREAM(info, log_engine)
29 #define ERR_NG LOG_STREAM(err, log_engine)
273 std::vector<std::string> zoom_levels_str =
utils::split(v[
"zoom_levels"]);
274 if(!zoom_levels_str.empty()) {
276 std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(
zoom_levels), [](
const std::string zoom) {
277 return static_cast<int>(std::stold(zoom) * tile_size);
317 orb =
i[
"orb"].str();
324 flag =
i[
"flag"].str();
365 const auto parse_config_color_list = [&](
366 const std::string& key,
367 const color_t fallback)->std::vector<color_t>
369 std::vector<color_t> color_vec;
374 }
catch(
const std::invalid_argument&
e) {
375 ERR_NG <<
"Error parsing color list '" << key <<
"'.\n" <<
e.what();
376 color_vec.push_back(fallback);
383 red_green_scale = parse_config_color_list(
"red_green_scale", {255, 255, 255});
385 blue_white_scale = parse_config_color_list(
"blue_white_scale", {0 , 0 , 255});
392 sinf.
name = server[
"name"].str();
393 sinf.
address = server[
"address"].str();
400 const auto load_attribute = [](
const config&
c,
const std::string& key, std::string& member) {
401 if(
c.has_attribute(key)) {
402 member =
c[key].str();
420 if(
auto ss =
s->optional_child(
"status")) {
423 load_attribute(*ss,
"poisoned",
poisoned);
424 load_attribute(*ss,
"slowed",
slowed);
425 load_attribute(*ss,
"petrified",
petrified);
442 std::string
id = *a1;
443 std::vector<color_t> temp;
448 }
catch(
const std::invalid_argument&) {
449 std::stringstream ss;
450 ss <<
"can't parse color string:\n" << teamC.debug() <<
"\n";
466 if(build_defaults && teamC[
"default"].to_bool()) {
473 std::vector<color_t> temp;
477 }
catch(
const std::invalid_argument&) {
478 ERR_NG <<
"Invalid color in palette: " <<
s;
483 LOG_NG <<
"registered color palette: " << rgb.first;
503 std::vector<color_t> temp;
507 }
catch(
const std::invalid_argument&) {
516 const std::vector<color_t>&
tc_info(
const std::string& name)
523 std::vector<color_t> temp;
527 }
catch(
const std::invalid_argument&) {
528 static std::vector<color_t> stv;
529 ERR_NG <<
"Invalid color in palette: " <<
s;
542 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
543 const int lvl = std::nearbyint((color_scale.size() - 1) * val_scaled);
545 return color_scale[lvl];
552 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
553 const int lvl = std::nearbyint((color_scale.size() - 1) * val_scaled);
555 return color_scale[lvl];
560 std::string ret =
_(
"The Battle for Wesnoth") +
" - " +
revision;
A color range definition is made of four reference RGB colors, used for calculating conversions from ...
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
attribute_map::value_type attribute
const attribute_value * get(config_key_type key) const
Returns a pointer to the attribute with the given key or nullptr if it does not exist.
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Euivalent to mandatory_child, but returns an empty optional if the nth child was not found.
A class grating read only view to a vector of config objects, viewed as one config with all children ...
static game_config_view wrap(const config &cfg)
config_array_view child_range(config_key_type key) const
std::vector< color_t > palette(const color_range &cr)
Creates a reference color palette from a color range.
static lg::log_domain log_engine("engine")
Interfaces for manipulating version numbers of engine, add-ons, etc.
static std::string _(const char *str)
std::string id
Text to match against addon_info.tags()
Standard logging facilities (interface).
General math utility functions.
Manage the empty-palette in the editor.
std::string partial_orb_color
std::string moved_orb_color
std::string unmoved_orb_color
std::string ally_orb_color
std::string enemy_orb_color
std::string default_color_list
std::string selected_menu
std::string victory_laurel_hardest
std::string victory_laurel
std::string orb_two_color
std::string deselected_menu
std::string unchecked_menu
std::string game_title_background
std::string game_logo_background
std::string victory_laurel_easy
std::string public_message
std::string private_message
const std::string menu_expand
std::string player_leaves
std::string server_message
std::string game_user_arrive
const std::string menu_contract
std::string game_user_leave
const std::string checkbox_release
std::string friend_message
const std::string menu_select
std::string ready_for_start
std::string game_has_begun
const std::string button_press
const std::string slider_adjust
Game configuration data as global variables.
std::vector< std::string > default_defeat_music
std::map< std::string, color_range > team_rgb_range
Colors defined by WML [color_range] tags.
color_t blue_to_white(double val, bool for_text)
const std::size_t max_loop
The maximum number of hexes on a map and items in an array and also used as maximum in wml loops.
std::string get_default_title_string()
bool ignore_replay_errors
std::string foot_teleport_enter
bool show_status_on_ally_orb
std::vector< color_t > red_green_scale_text
std::vector< std::string > foot_speed_prefix
const int gold_carryover_percentage
Default percentage gold carried over to the next scenario.
std::string foot_teleport_exit
static std::vector< color_t > blue_white_scale_text
const std::vector< color_t > & tc_info(const std::string &name)
std::vector< std::string > default_colors
std::string shroud_prefix
std::vector< server_info > server_list
static void add_color_info(const game_config_view &v, bool build_defaults)
std::map< std::string, t_string > team_rgb_name
std::vector< unsigned int > zoom_levels
const color_range & color_info(const std::string &name)
std::string default_terrain
unsigned lobby_network_timer
static std::vector< color_t > blue_white_scale
std::vector< std::string > default_victory_music
std::map< std::string, std::vector< color_t > > team_rgb_colors
const std::string revision
void set_debug(bool new_debug)
std::vector< color_t > red_green_scale
void load_config(const config &v)
color_t red_to_green(double val, bool for_text)
Return a color corresponding to the value val red for val=0.0 to green for val=100....
bool set_log_domain_severity(const std::string &name, int severity)
bool get_log_domain_severity(const std::string &name, int &severity)
std::vector< std::string > split(const config_attribute_value &val)
The basic class for representing 8-bit RGB or RGBA colour values.
static color_t from_hex_string(const std::string &c)
Creates a new color_t object from a string variable in hex format.
std::string address
may include ':' followed by port number
static map_location::DIRECTION s
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.