The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
game_config.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2003 - 2025
3 by David White <dave@whitevine.net>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16#pragma once
17
18class config;
19class color_range;
20
21#include "color.hpp"
22#include "color_range.hpp"
23#include "tstring.hpp"
24#include "game_config_view.hpp"
25
26#include <chrono>
27#include <vector>
28#include <map>
29
30//basic game configuration information is here.
31namespace game_config
32{
33 extern int base_income;
34 extern int village_income;
35 extern int village_support;
36 extern int poison_amount;
37 extern int rest_heal_amount;
38 extern int recall_cost;
39 extern int kill_experience;
40 extern int combat_experience;
41 extern unsigned int tile_size;
42 extern std::chrono::milliseconds lobby_network_timer;
43 extern std::chrono::milliseconds lobby_refresh;
44 extern const std::string default_title_string;
45 extern std::string default_terrain;
46
47 extern std::vector<unsigned int> zoom_levels;
48
49 inline int kill_xp(int level)
50 {
51 return level ? kill_experience * level : kill_experience / 2;
52 }
53
54 inline int combat_xp(int level)
55 {
56 return combat_experience * level;
57 }
58
59 /** Default percentage gold carried over to the next scenario. */
60 extern const int gold_carryover_percentage;
61
64
65 extern bool allow_insecure;
66 extern bool addon_server_info;
67 extern bool no_simd;
68
69 extern const bool& debug;
70 void set_debug(bool new_debug);
71
73 {
74 std::string name;
75 std::string address; /**< may include ':' followed by port number */
76 };
77
78 extern std::vector<server_info> server_list;
79
80 extern std::string title_music,
82
83 extern std::vector<std::string> default_defeat_music;
84 extern std::vector<std::string> default_victory_music;
85
86 namespace colors {
87 extern std::string ally_orb_color;
88 extern std::string enemy_orb_color;
89 extern std::string moved_orb_color;
90 extern std::string partial_orb_color;
91 extern std::string unmoved_orb_color;
92 extern std::string reach_map_color;
93 extern std::string reach_map_enemy_color;
94 extern std::string default_color_list;
95 } // colors
96
97 extern bool show_ally_orb;
98 extern bool show_disengaged_orb;
99 extern bool show_enemy_orb;
100 extern bool show_moved_orb;
101 extern bool show_partial_orb;
102 extern bool show_status_on_ally_orb;
103 extern bool show_unmoved_orb;
104 extern int reach_map_border_opacity;
105 extern int reach_map_tint_opacity;
106 extern int reach_map_darken_opacity;
107 extern bool reach_map_darken_tex;
108
109 namespace images {
110 extern std::string game_title,
112 game_logo,
117 // orbs and hp/xp bar
118 orb,
120 energy,
121 // top bar icons
123 time_icon,
124 // flags
125 flag,
126 flag_icon,
127 // hex overlay
129 grid_top,
131 mouseover,
132 selected,
135 linger,
136 // GUI elements
137 observer,
139 tod_dark,
140 wml_menu,
141 level,
142 ellipsis,
143 missing,
144 blank,
145 // notifications icon
146 app_icon;
147 } //images
148
149
150 extern std::string shroud_prefix, fog_prefix, reach_map_prefix;
151
152 extern double hp_bar_scaling, xp_bar_scaling;
153
154 extern std::string flag_rgb, unit_rgb;
155 extern std::vector<color_t> red_green_scale;
156 extern std::vector<color_t> red_green_scale_text;
157 extern std::vector<color_t> blue_white_scale;
158 extern std::vector<color_t> blue_white_scale_text;
159
160 extern std::string foot_teleport_enter, foot_teleport_exit;
161
162 /**
163 * Colors defined by WML [color_range] tags. In addition to team colors such as "red" and
164 * "blue", this also contains the colors used on the minimap for "cave", "fungus" etc.
165 */
166 extern std::map<std::string, color_range, std::less<>> team_rgb_range;
167 extern std::map<std::string, t_string, std::less<>> team_rgb_name;
168 /**
169 * For colors defined by WML [color_range] tags, the palettes for team-based recoloring.
170 *
171 * This is data calculated from the color_range structs, but isn't in those structs,
172 * allowing them to be Plain Old Data.
173 */
174 extern std::map<std::string, std::vector<color_t>, std::less<>> team_rgb_colors;
175
176 /**
177 * The [color_range]id= attributes, equivalently the keys in the team_rgb_* maps,
178 * for which [color_range]default=yes.
179 */
180 extern std::vector<std::string> default_colors;
181
182 /**
183 * The maximum number of hexes on a map and items in an array and also used
184 * as maximum in wml loops.
185 * WARNING : This should not be set to less than the max map area
186 */
187 extern const std::size_t max_loop;
188
189 namespace sounds {
190 extern std::string turn_bell, timer_bell, public_message,
195 extern const std::string button_press, checkbox_release, slider_adjust,
197 namespace status {
198 extern std::string poisoned, slowed, petrified;
199 }
200 }
201
202 void load_config(const config &cfg);
203
204 void add_color_info(const game_config_view& v);
205 void reset_color_info();
206 const std::vector<color_t>& tc_info(std::string_view name);
207 const color_range& color_info(std::string_view name);
208
209 /**
210 * Return a color corresponding to the value val
211 * red for val=0.0 to green for val=100.0, passing by yellow.
212 * Colors are defined by [game_config] keys
213 * red_green_scale and red_green_scale_text
214 */
215 color_t red_to_green(double val, bool for_text = true);
216 color_t blue_to_white(double val, bool for_text = true);
217
218 std::string get_default_title_string();
219}
Representing the "team color" information, this C++ class contains a subset of WML's [color_range] ta...
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
A class grating read only view to a vector of config objects, viewed as one config with all children ...
const config * cfg
std::string partial_orb_color
std::string reach_map_enemy_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 reach_map_color
std::string terrain_mask
std::string victory_laurel_hardest
std::string victory_laurel
std::string orb_two_color
std::string game_title_background
std::string grid_bottom
std::string unreachable
std::string game_logo_background
std::string editor_brush
std::string battery_icon
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
std::string game_created
std::string player_joins
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.
std::string flag_rgb
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
bool addon_server_info
int kill_xp(int level)
const int gold_carryover_percentage
Default percentage gold carried over to the next scenario.
std::string foot_teleport_exit
std::string lobby_music
const std::vector< color_t > & tc_info(std::string_view name)
std::string fog_prefix
const bool & debug
const color_range & color_info(std::string_view name)
std::vector< std::string > default_colors
The [color_range]id= attributes, equivalently the keys in the team_rgb_* maps, for which [color_range...
std::vector< color_t > blue_white_scale
std::string shroud_prefix
int reach_map_border_opacity
int reach_map_darken_opacity
double hp_bar_scaling
bool disable_autosave
std::vector< server_info > server_list
std::string unit_rgb
unsigned int tile_size
bool allow_insecure
static void add_color_info(const game_config_view &v, bool build_defaults)
bool show_disengaged_orb
std::vector< unsigned int > zoom_levels
bool show_partial_orb
std::chrono::milliseconds lobby_refresh
std::string title_music
std::chrono::milliseconds lobby_network_timer
std::string default_terrain
bool show_unmoved_orb
std::string reach_map_prefix
std::vector< std::string > default_victory_music
int combat_experience
bool reach_map_darken_tex
void reset_color_info()
int reach_map_tint_opacity
const std::string default_title_string
void set_debug(bool new_debug)
std::vector< color_t > red_green_scale
int combat_xp(int level)
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
For colors defined by WML [color_range] tags, the palettes for team-based recoloring.
double xp_bar_scaling
The basic class for representing 8-bit RGB or RGBA colour values.
Definition color.hpp:51
std::string address
may include ':' followed by port number