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);
276 std::vector<std::string> zoom_levels_str =
utils::split(v[
"zoom_levels"]);
277 if(!zoom_levels_str.empty()) {
279 std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(
zoom_levels), [](
const std::string zoom) {
280 int z = std::stoi(zoom);
281 if((z / 4) * 4 != z) {
282 ERR_NG <<
"zoom level " << z <<
" is not divisible by 4."
283 <<
" This will cause graphical glitches!";
295 if(
auto i = v.optional_child(
"colors")){
313 if(
auto i = v.optional_child(
"images")){
316 if (!
i[
"game_title_background"].
blank()) {
318 const auto backgrounds =
utils::split(
i[
"game_title_background"].str());
319 if (backgrounds.size() > 1) {
320 int r = rand() % (backgrounds.size());
322 }
else if (backgrounds.size() == 1) {
336 orb =
i[
"orb"].str();
343 flag =
i[
"flag"].str();
384 const auto parse_config_color_list = [&](
385 const std::string& key,
386 const color_t fallback)->std::vector<color_t>
388 std::vector<color_t> color_vec;
393 }
catch(
const std::invalid_argument&
e) {
394 ERR_NG <<
"Error parsing color list '" << key <<
"'.\n" <<
e.what();
395 color_vec.push_back(fallback);
402 red_green_scale = parse_config_color_list(
"red_green_scale", {255, 255, 255});
404 blue_white_scale = parse_config_color_list(
"blue_white_scale", {0 , 0 , 255});
411 sinf.name = server[
"name"].str();
412 sinf.address = server[
"address"].str();
416 if(
auto s = v.optional_child(
"sounds")) {
419 const auto load_attribute = [](
const config&
c,
const std::string& key, std::string& member) {
420 if(
c.has_attribute(key)) {
421 member =
c[key].str();
439 if(
auto ss =
s->optional_child(
"status")) {
442 load_attribute(*ss,
"poisoned",
poisoned);
443 load_attribute(*ss,
"slowed",
slowed);
444 load_attribute(*ss,
"petrified",
petrified);
461 std::string
id = *a1;
462 std::vector<color_t> temp;
467 }
catch(
const std::invalid_argument&) {
468 std::stringstream ss;
469 ss <<
"can't parse color string:\n" << teamC.debug() <<
"\n";
482 if(build_defaults && teamC[
"default"].to_bool()) {
488 for(
const auto& [key, value] : cp.attribute_range()) {
489 std::vector<color_t> temp;
493 }
catch(
const std::invalid_argument&
e) {
494 ERR_NG <<
"Invalid color in palette: " <<
s <<
" (" <<
e.what() <<
")";
499 LOG_NG <<
"registered color palette: " << key;
519 std::vector<color_t> temp;
523 }
catch(
const std::invalid_argument&) {
532 const std::vector<color_t>&
tc_info(std::string_view name)
539 std::vector<color_t> temp;
543 }
catch(
const std::invalid_argument&
e) {
544 static std::vector<color_t> stv;
545 ERR_NG <<
"Invalid color in palette: " <<
s <<
" (" <<
e.what() <<
")";
558 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
559 const int lvl = int(std::nearbyint((color_scale.size() - 1) * val_scaled));
561 return color_scale[lvl];
568 const double val_scaled = std::clamp(0.01 * val, 0.0, 1.0);
569 const int lvl = int(std::nearbyint((color_scale.size() - 1) * val_scaled));
571 return color_scale[lvl];
576 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).
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)
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
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
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
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(std::string_view c)
Creates a new color_t object from a string variable in hex format.
static map_location::direction s