30 #define LOG_NG LOG_STREAM(info, log_engine)
31 #define ERR_NG LOG_STREAM(err, log_engine)
33 using namespace std::chrono_literals;
103 int severityInt =
static_cast<int>(
severity);
110 int severityInt =
static_cast<int>(
severity);
279 std::vector<std::string> zoom_levels_str =
utils::split(v[
"zoom_levels"]);
280 if(!zoom_levels_str.empty()) {
282 std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(
zoom_levels), [](
const std::string& zoom) {
283 int z = std::stoi(zoom);
284 if((z / 4) * 4 != z) {
285 ERR_NG <<
"zoom level " << z <<
" is not divisible by 4."
286 <<
" This will cause graphical glitches!";
298 if(
auto i = v.optional_child(
"colors")){
316 if(
auto i = v.optional_child(
"images")){
319 if (!
i[
"game_title_background"].
blank()) {
321 const auto backgrounds =
utils::split(
i[
"game_title_background"].str());
322 if (backgrounds.size() > 1) {
323 int r = rand() % (backgrounds.size());
325 }
else if (backgrounds.size() == 1) {
339 orb =
i[
"orb"].str();
346 flag =
i[
"flag"].str();
387 const auto parse_config_color_list = [&](
388 const std::string& key,
389 const color_t fallback)->std::vector<color_t>
391 std::vector<color_t> color_vec;
396 }
catch(
const std::invalid_argument&
e) {
397 ERR_NG <<
"Error parsing color list '" << key <<
"'.\n" <<
e.what();
398 color_vec.push_back(fallback);
405 red_green_scale = parse_config_color_list(
"red_green_scale", {255, 255, 255});
407 blue_white_scale = parse_config_color_list(
"blue_white_scale", {0 , 0 , 255});
414 sinf.name = server[
"name"].str();
415 sinf.address = server[
"address"].str();
419 if(
auto s = v.optional_child(
"sounds")) {
422 const auto load_attribute = [](
const config&
c,
const std::string& key, std::string& member) {
423 if(
c.has_attribute(key)) {
424 member =
c[key].str();
442 if(
auto ss =
s->optional_child(
"status")) {
445 load_attribute(*ss,
"poisoned",
poisoned);
446 load_attribute(*ss,
"slowed",
slowed);
447 load_attribute(*ss,
"petrified",
petrified);
464 std::string
id = *a1;
465 std::vector<color_t> temp;
470 }
catch(
const std::invalid_argument&) {
471 std::stringstream ss;
472 ss <<
"can't parse color string:\n" << teamC.debug() <<
"\n";
485 if(build_defaults && teamC[
"default"].to_bool()) {
491 for(
const auto& [key, value] : cp.attribute_range()) {
492 std::vector<color_t> temp;
496 }
catch(
const std::invalid_argument&
e) {
497 ERR_NG <<
"Invalid color in palette: " <<
s <<
" (" <<
e.what() <<
")";
502 LOG_NG <<
"registered color palette: " << key;
522 std::vector<color_t> temp;
526 }
catch(
const std::invalid_argument&) {
535 const std::vector<color_t>&
tc_info(std::string_view name)
542 std::vector<color_t> temp;
546 }
catch(
const std::invalid_argument&
e) {
547 static std::vector<color_t> stv;
548 ERR_NG <<
"Invalid color in palette: " <<
s <<
" (" <<
e.what() <<
")";
561 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
562 const int lvl = int(std::nearbyint((color_scale.size() - 1) * val_scaled));
564 return color_scale[lvl];
571 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
572 const int lvl = int(std::nearbyint((color_scale.size() - 1) * val_scaled));
574 return color_scale[lvl];
579 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