30 #define LOG_NG LOG_STREAM(info, log_engine)
31 #define ERR_NG LOG_STREAM(err, log_engine)
33 using namespace std::chrono_literals;
102 int severityInt =
static_cast<int>(
severity);
109 int severityInt =
static_cast<int>(
severity);
278 std::vector<std::string> zoom_levels_str =
utils::split(v[
"zoom_levels"]);
279 if(!zoom_levels_str.empty()) {
281 std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(
zoom_levels), [](
const std::string zoom) {
282 int z = std::stoi(zoom);
283 if((z / 4) * 4 != z) {
284 ERR_NG <<
"zoom level " << z <<
" is not divisible by 4."
285 <<
" This will cause graphical glitches!";
297 if(
auto i = v.optional_child(
"colors")){
315 if(
auto i = v.optional_child(
"images")){
318 if (!
i[
"game_title_background"].
blank()) {
320 const auto backgrounds =
utils::split(
i[
"game_title_background"].str());
321 if (backgrounds.size() > 1) {
322 int r = rand() % (backgrounds.size());
324 }
else if (backgrounds.size() == 1) {
338 orb =
i[
"orb"].str();
345 flag =
i[
"flag"].str();
386 const auto parse_config_color_list = [&](
387 const std::string& key,
388 const color_t fallback)->std::vector<color_t>
390 std::vector<color_t> color_vec;
395 }
catch(
const std::invalid_argument&
e) {
396 ERR_NG <<
"Error parsing color list '" << key <<
"'.\n" <<
e.what();
397 color_vec.push_back(fallback);
404 red_green_scale = parse_config_color_list(
"red_green_scale", {255, 255, 255});
406 blue_white_scale = parse_config_color_list(
"blue_white_scale", {0 , 0 , 255});
413 sinf.name = server[
"name"].str();
414 sinf.address = server[
"address"].str();
418 if(
auto s = v.optional_child(
"sounds")) {
421 const auto load_attribute = [](
const config&
c,
const std::string& key, std::string& member) {
422 if(
c.has_attribute(key)) {
423 member =
c[key].str();
441 if(
auto ss =
s->optional_child(
"status")) {
444 load_attribute(*ss,
"poisoned",
poisoned);
445 load_attribute(*ss,
"slowed",
slowed);
446 load_attribute(*ss,
"petrified",
petrified);
463 std::string
id = *a1;
464 std::vector<color_t> temp;
469 }
catch(
const std::invalid_argument&) {
470 std::stringstream ss;
471 ss <<
"can't parse color string:\n" << teamC.debug() <<
"\n";
484 if(build_defaults && teamC[
"default"].to_bool()) {
490 for(
const auto& [key, value] : cp.attribute_range()) {
491 std::vector<color_t> temp;
495 }
catch(
const std::invalid_argument&
e) {
496 ERR_NG <<
"Invalid color in palette: " <<
s <<
" (" <<
e.what() <<
")";
501 LOG_NG <<
"registered color palette: " << key;
521 std::vector<color_t> temp;
525 }
catch(
const std::invalid_argument&) {
534 const std::vector<color_t>&
tc_info(std::string_view name)
541 std::vector<color_t> temp;
545 }
catch(
const std::invalid_argument&
e) {
546 static std::vector<color_t> stv;
547 ERR_NG <<
"Invalid color in palette: " <<
s <<
" (" <<
e.what() <<
")";
560 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
561 const int lvl = int(std::nearbyint((color_scale.size() - 1) * val_scaled));
563 return color_scale[lvl];
570 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
571 const int lvl = int(std::nearbyint((color_scale.size() - 1) * val_scaled));
573 return color_scale[lvl];
578 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)
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.
Definitions for the interface to Wesnoth Markup Language (WML).
@ grid_bottom
Bottom half part of grid image.
@ grid_top
Top half part of grid image.
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).
auto parse_duration(const config_attribute_value &val, const Duration &def=Duration{0})
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)
const color_range & color_info(std::string_view name)
std::vector< std::string > default_colors
std::vector< color_t > blue_white_scale
std::string shroud_prefix
std::vector< server_info > server_list
void add_color_info(const game_config_view &v)
std::chrono::milliseconds lobby_refresh
std::chrono::milliseconds lobby_network_timer
std::string default_terrain
std::string reach_map_prefix
std::vector< std::string > default_victory_music
const std::string revision
void set_debug(bool new_debug)
std::vector< color_t > red_green_scale
std::vector< color_t > blue_white_scale_text
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(std::string_view c)
Creates a new color_t object from a string variable in hex format.
static map_location::direction s