27 #define LOG_NG LOG_STREAM(info, log_engine) 28 #define ERR_NG LOG_STREAM(err, log_engine) 36 std::string
path = WESNOTH_PATH;
38 std::string path =
"";
41 #ifdef DEFAULT_PREFS_PATH 44 std::string default_preferences_path =
"";
279 base_income = v[
"base_income"].to_int(2);
280 village_income = v[
"village_income"].to_int(1);
281 village_support = v[
"village_support"].to_int(1);
282 poison_amount = v[
"poison_amount"].to_int(8);
283 rest_heal_amount = v[
"rest_heal_amount"].to_int(2);
284 recall_cost = v[
"recall_cost"].to_int(20);
285 kill_experience = v[
"kill_experience"].to_int(8);
286 combat_experience= v[
"combat_experience"].to_int(1);
287 lobby_refresh = v[
"lobby_refresh"].to_int(2000);
288 default_terrain = v[
"default_terrain"].str();
289 tile_size = v[
"tile_size"].to_int(72);
291 std::vector<std::string> zoom_levels_str =
utils::split(v[
"zoom_levels"]);
292 if(!zoom_levels_str.empty()) {
294 std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(
zoom_levels), [](
const std::string zoom) {
295 return static_cast<int>(std::stold(zoom) *
tile_size);
299 title_music = v[
"title_music"].str();
300 lobby_music = v[
"lobby_music"].str();
302 default_victory_music =
utils::split(v[
"default_victory_music"].str());
303 default_defeat_music =
utils::split(v[
"default_defeat_music"].str());
316 show_ally_orb = v[
"show_ally_orb"].to_bool(
true);
317 show_enemy_orb = v[
"show_enemy_orb"].to_bool(
false);
318 show_moved_orb = v[
"show_moved_orb"].to_bool(
true);
319 show_partial_orb = v[
"show_partly_orb"].to_bool(
true);
320 show_unmoved_orb = v[
"show_unmoved_orb"].to_bool(
true);
321 show_disengaged_orb = v[
"show_disengaged_orb"].to_bool(
true);
335 orb =
i[
"orb"].str();
342 flag =
i[
"flag"].str();
362 hp_bar_scaling = v[
"hp_bar_scaling"].to_double(0.666);
363 xp_bar_scaling = v[
"xp_bar_scaling"].to_double(0.5);
364 hex_brightening = v[
"hex_brightening"].to_double(1.25);
366 foot_speed_prefix =
utils::split(v[
"footprint_prefix"]);
367 foot_teleport_enter = v[
"footprint_teleport_enter"].str();
368 foot_teleport_exit = v[
"footprint_teleport_exit"].str();
370 shroud_prefix = v[
"shroud_prefix"].str();
371 fog_prefix = v[
"fog_prefix"].str();
383 const auto parse_config_color_list = [&](
384 const std::string& key,
385 const color_t fallback)->std::vector<color_t>
387 std::vector<color_t> color_vec;
392 }
catch(
const std::invalid_argument&
e) {
393 ERR_NG <<
"Error parsing color list '" << key <<
"'.\n" << e.what() << std::endl;
394 color_vec.push_back(fallback);
401 red_green_scale = parse_config_color_list(
"red_green_scale", {255, 255, 255});
402 red_green_scale_text = parse_config_color_list(
"red_green_scale_text", {255, 255, 255});
403 blue_white_scale = parse_config_color_list(
"blue_white_scale", {0 , 0 , 255});
404 blue_white_scale_text = parse_config_color_list(
"blue_white_scale_text", {0 , 0 , 255});
410 sinf.
name = server[
"name"].str();
411 sinf.
address = server[
"address"].str();
412 server_list.push_back(sinf);
418 const auto load_attribute = [](
const config&
c,
const std::string& key, std::string& member) {
420 member = c[key].str();
438 if(
const config & ss =
s.child(
"status")) {
441 load_attribute(ss,
"poisoned",
poisoned);
442 load_attribute(ss,
"slowed",
slowed);
443 load_attribute(ss,
"petrified",
petrified);
451 default_colors.clear();
460 std::string
id = *a1;
461 std::vector<color_t> temp;
466 }
catch(
const std::invalid_argument&) {
467 std::stringstream ss;
468 ss <<
"can't parse color string:\n" << teamC.debug() <<
"\n";
474 team_rgb_name.emplace(
id, teamC[
"name"].t_str());
476 LOG_NG <<
"registered color range '" <<
id <<
"': " << team_rgb_range[id].debug() <<
'\n';
479 std::vector<color_t> tp =
palette(team_rgb_range[
id]);
481 team_rgb_colors.emplace(
id, tp);
484 if(build_defaults && teamC[
"default"].to_bool()) {
485 default_colors.push_back(*a1);
491 std::vector<color_t> temp;
495 }
catch(
const std::invalid_argument&) {
496 ERR_NG <<
"Invalid color in palette: " <<
s << std::endl;
500 team_rgb_colors.emplace(rgb.first, temp);
501 LOG_NG <<
"registered color palette: " << rgb.first <<
'\n';
508 default_colors.clear();
509 team_rgb_colors.clear();
510 team_rgb_name.clear();
511 team_rgb_range.clear();
516 auto i = team_rgb_range.find(name);
517 if(
i != team_rgb_range.end()) {
521 std::vector<color_t> temp;
525 }
catch(
const std::invalid_argument&) {
534 const std::vector<color_t>&
tc_info(
const std::string& name)
536 auto i = team_rgb_colors.find(name);
537 if(
i != team_rgb_colors.end()) {
541 std::vector<color_t> temp;
545 }
catch(
const std::invalid_argument&) {
546 static std::vector<color_t> stv;
547 ERR_NG <<
"Invalid color in palette: " <<
s << std::endl;
552 team_rgb_colors.emplace(name, temp);
560 val = std::clamp(val, 0, 100);
561 const int lvl = (color_scale.size() - 1) * val / 100;
563 return color_scale[lvl];
570 val = std::clamp(val, 0, 100);
571 const int lvl = (color_scale.size() - 1) * val / 100;
573 return color_scale[lvl];
578 std::string ret =
_(
"The Battle for Wesnoth") +
" - " +
revision;
std::vector< std::string > default_victory_music
std::string game_user_leave
std::string victory_laurel
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
std::map< std::string, color_range > team_rgb_range
Colors defined by WML [color_range] tags.
Interfaces for manipulating version numbers of engine, add-ons, etc.
Variant for storing WML attributes.
std::vector< unsigned int > zoom_levels
const std::string menu_expand
std::vector< color_t > palette(const color_range &cr)
Creates a reference color palette from a color range.
static l_noret error(LoadState *S, const char *why)
static game_config_view wrap(const config &cfg)
color_t blue_to_white(int val, bool for_text)
bool has_attribute(config_key_type key) const
config_array_view child_range(config_key_type key) const
std::string private_message
child_itors child_range(config_key_type key)
std::string selected_menu
static std::vector< color_t > blue_white_scale
attribute_map::value_type attribute
const std::string slider_adjust
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.
std::string friend_message
std::string get_default_title_string()
const std::string menu_select
std::string unchecked_menu
std::string victory_laurel_easy
std::string enemy_orb_color
static std::string _(const char *str)
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...
Definitions for the interface to Wesnoth Markup Language (WML).
std::string address
may include ':' followed by port number
void load_config(const config &v)
std::vector< std::string > default_defeat_music
std::string disengaged_orb_color
std::string ally_orb_color
std::string deselected_menu
bool get_log_domain_severity(const std::string &name, int &severity)
std::string victory_laurel_hardest
std::vector< color_t > red_green_scale_text
unsigned lobby_network_timer
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 default_color_list
std::string ready_for_start
const int gold_carryover_percentage
Default percentage gold carried over to the next scenario.
std::string game_user_arrive
bool ignore_replay_errors
std::string foot_teleport_enter
std::string game_title_background
General math utility functions.
std::string game_logo_background
std::string shroud_prefix
Manage the empty-palette in the editor.
std::string default_terrain
std::string moved_orb_color
static void add_color_info(const game_config_view &v, bool build_defaults)
std::string server_message
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
std::map< std::string, std::vector< color_t > > team_rgb_colors
std::string unmoved_orb_color
const std::string revision
Game configuration data as global variables.
std::string public_message
static map_location::DIRECTION s
const std::string menu_contract
A color range definition is made of four reference RGB colors, used for calculating conversions from ...
std::vector< color_t > red_green_scale
std::vector< std::string > foot_speed_prefix
bool set_log_domain_severity(const std::string &name, int severity)
std::string player_leaves
const std::string button_press
std::string foot_teleport_exit
color_t red_to_green(int val, bool for_text)
Return a color corresponding to the value val red for val=0 to green for val=100, passing by yellow...
std::vector< std::string > split(const config_attribute_value &val)
const color_range & color_info(const std::string &name)
Standard logging facilities (interface).
const std::vector< color_t > & tc_info(const std::string &name)
static std::vector< color_t > blue_white_scale_text
std::string partial_orb_color
std::vector< std::string > default_colors
std::string orb_two_color
A config object defines a single node in a WML file, with access to child nodes.
std::map< std::string, t_string > team_rgb_name
std::string game_has_begun
std::vector< server_info > server_list
std::string wesnoth_program_dir
void set_debug(bool new_debug)
static lg::log_domain log_engine("engine")
std::string default_preferences_path
const std::string observer_team_name
observer team name used for observer team chat
const std::string checkbox_release
int cache_compression_level