29 #define LOG_NG LOG_STREAM(info, log_engine)
30 #define ERR_NG LOG_STREAM(err, log_engine)
100 int severityInt =
static_cast<int>(
severity);
107 int severityInt =
static_cast<int>(
severity);
277 std::vector<std::string> zoom_levels_str =
utils::split(v[
"zoom_levels"]);
278 if(!zoom_levels_str.empty()) {
280 std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(
zoom_levels), [](
const std::string zoom) {
281 int z = std::stoi(zoom);
282 if((z / 4) * 4 != z) {
283 ERR_NG <<
"zoom level " << z <<
" is not divisible by 4."
284 <<
" This will cause graphical glitches!";
296 if(
auto i = v.optional_child(
"colors")){
314 if(
auto i = v.optional_child(
"images")){
317 if (!
i[
"game_title_background"].
blank()) {
319 const auto backgrounds =
utils::split(
i[
"game_title_background"].str());
320 if (backgrounds.size() > 1) {
321 int r = rand() % (backgrounds.size());
323 }
else if (backgrounds.size() == 1) {
337 orb =
i[
"orb"].str();
344 flag =
i[
"flag"].str();
385 const auto parse_config_color_list = [&](
386 const std::string& key,
387 const color_t fallback)->std::vector<color_t>
389 std::vector<color_t> color_vec;
394 }
catch(
const std::invalid_argument&
e) {
395 ERR_NG <<
"Error parsing color list '" << key <<
"'.\n" <<
e.what();
396 color_vec.push_back(fallback);
403 red_green_scale = parse_config_color_list(
"red_green_scale", {255, 255, 255});
405 blue_white_scale = parse_config_color_list(
"blue_white_scale", {0 , 0 , 255});
412 sinf.name = server[
"name"].str();
413 sinf.address = server[
"address"].str();
417 if(
auto s = v.optional_child(
"sounds")) {
420 const auto load_attribute = [](
const config&
c,
const std::string& key, std::string& member) {
421 if(
c.has_attribute(key)) {
422 member =
c[key].str();
440 if(
auto ss =
s->optional_child(
"status")) {
443 load_attribute(*ss,
"poisoned",
poisoned);
444 load_attribute(*ss,
"slowed",
slowed);
445 load_attribute(*ss,
"petrified",
petrified);
462 std::string
id = *a1;
463 std::vector<color_t> temp;
468 }
catch(
const std::invalid_argument&) {
469 std::stringstream ss;
470 ss <<
"can't parse color string:\n" << teamC.debug() <<
"\n";
486 if(build_defaults && teamC[
"default"].to_bool()) {
493 std::vector<color_t> temp;
497 }
catch(
const std::invalid_argument&
e) {
498 ERR_NG <<
"Invalid color in palette: " <<
s <<
" (" <<
e.what() <<
")";
503 LOG_NG <<
"registered color palette: " << rgb.first;
523 std::vector<color_t> temp;
527 }
catch(
const std::invalid_argument&) {
536 const std::vector<color_t>&
tc_info(std::string_view name)
543 std::vector<color_t> temp;
547 }
catch(
const std::invalid_argument&
e) {
548 static std::vector<color_t> stv;
549 ERR_NG <<
"Invalid color in palette: " <<
s <<
" (" <<
e.what() <<
")";
562 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
563 const int lvl = int(std::nearbyint((color_scale.size() - 1) * val_scaled));
565 return color_scale[lvl];
572 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
573 const int lvl = int(std::nearbyint((color_scale.size() - 1) * val_scaled));
575 return color_scale[lvl];
580 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
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).
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, std::less<> > team_rgb_range
Colors defined by WML [color_range] tags.
color_t blue_to_white(double val, bool for_text)
std::map< std::string, t_string, std::less<> > team_rgb_name
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
const std::vector< color_t > & tc_info(std::string_view name)
static std::vector< color_t > blue_white_scale_text
const color_range & color_info(std::string_view 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::vector< unsigned int > zoom_levels
std::string default_terrain
unsigned lobby_network_timer
static std::vector< color_t > blue_white_scale
std::vector< std::string > default_victory_music
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....
std::map< std::string, std::vector< color_t >, std::less<> > team_rgb_colors
bool get_log_domain_severity(const std::string &name, severity &severity)
bool set_log_domain_severity(const std::string &name, severity 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.
static map_location::DIRECTION s