The Battle for Wesnoth  1.17.14+dev
game_config.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2022
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 
18 class config;
19 class color_range;
20 
21 #include "color.hpp"
22 #include "tstring.hpp"
23 #include "game_config_view.hpp"
24 
25 #include <vector>
26 #include <map>
27 #include <cstdint>
28 
29 //basic game configuration information is here.
30 namespace game_config
31 {
32  extern int base_income;
33  extern int village_income;
34  extern int village_support;
35  extern int poison_amount;
36  extern int rest_heal_amount;
37  extern int recall_cost;
38  extern int kill_experience;
39  extern int combat_experience;
40  extern unsigned int tile_size;
41  extern unsigned lobby_network_timer;
42  extern unsigned lobby_refresh;
43  extern const std::string default_title_string;
44  extern std::string default_terrain;
45 
46  extern std::vector<unsigned int> zoom_levels;
47 
48  inline int kill_xp(int level)
49  {
50  return level ? kill_experience * level : kill_experience / 2;
51  }
52 
53  inline int combat_xp(int level)
54  {
55  return combat_experience * level;
56  }
57 
58  extern std::string wesnoth_program_dir;
59 
60  /** Default percentage gold carried over to the next scenario. */
61  extern const int gold_carryover_percentage;
62 
65 
66  extern bool allow_insecure;
67 
68  extern const bool& debug;
69  void set_debug(bool new_debug);
70 
71  extern int cache_compression_level;
72 
73  extern std::string path;
74  extern std::string default_preferences_path;
75  extern bool check_migration;
76 
77  struct server_info
78  {
79  std::string name;
80  std::string address; /**< may include ':' followed by port number */
81  };
82 
83  extern std::vector<server_info> server_list;
84 
85  extern std::string title_music,
87 
88  extern std::vector<std::string> default_defeat_music;
89  extern std::vector<std::string> default_victory_music;
90 
91  namespace colors {
92  extern std::string ally_orb_color;
93  extern std::string enemy_orb_color;
94  extern std::string moved_orb_color;
95  extern std::string partial_orb_color;
96  extern std::string unmoved_orb_color;
97  extern std::string default_color_list;
98  } // colors
99 
100  extern bool show_ally_orb;
101  extern bool show_disengaged_orb;
102  extern bool show_enemy_orb;
103  extern bool show_moved_orb;
104  extern bool show_partial_orb;
105  extern bool show_status_on_ally_orb;
106  extern bool show_unmoved_orb;
107 
108  namespace images {
109  extern std::string game_title,
111  game_logo,
116  // orbs and hp/xp bar
117  orb,
119  energy,
120  // top bar icons
121  battery_icon,
122  time_icon,
123  // flags
124  flag,
125  flag_icon,
126  // hex overlay
127  terrain_mask,
128  grid_top,
129  grid_bottom,
130  mouseover,
131  selected,
132  editor_brush,
133  unreachable,
134  linger,
135  // GUI elements
136  observer,
137  tod_bright,
138  tod_dark,
141  checked_menu,
143  wml_menu,
144  level,
145  ellipsis,
146  missing,
147  blank,
148  // notifications icon
149  app_icon;
150  } //images
151 
152 
153  extern std::string shroud_prefix, fog_prefix;
154 
155  extern double hp_bar_scaling, xp_bar_scaling;
156 
157  extern std::string flag_rgb, unit_rgb;
158  extern std::vector<color_t> red_green_scale;
159  extern std::vector<color_t> red_green_scale_text;
160 
161  extern std::vector<std::string> foot_speed_prefix;
162  extern std::string foot_teleport_enter, foot_teleport_exit;
163 
164  /**
165  * Colors defined by WML [color_range] tags. In addition to team colors such as "red" and
166  * "blue", this also contains the colors used on the minimap for "cave", "fungus" etc.
167  */
168  extern std::map<std::string, color_range> team_rgb_range;
169  extern std::map<std::string, t_string> team_rgb_name;
170  extern std::map<std::string, std::vector<color_t>> team_rgb_colors;
171 
172  extern std::vector<std::string> default_colors;
173 
174  /** observer team name used for observer team chat */
175  extern const std::string observer_team_name;
176 
177  /**
178  * The maximum number of hexes on a map and items in an array and also used
179  * as maximum in wml loops.
180  * WARNING : This should not be set to less than the max map area
181  */
182  extern const std::size_t max_loop;
183 
184  namespace sounds {
185  extern std::string turn_bell, timer_bell, public_message,
186  private_message, friend_message,
187  server_message, player_joins, player_leaves,
189  game_has_begun, game_created;
190  extern const std::string button_press, checkbox_release, slider_adjust,
192  namespace status {
193  extern std::string poisoned, slowed, petrified;
194  }
195  }
196 
197  void load_config(const config &cfg);
198 
199  void add_color_info(const game_config_view& v);
200  void reset_color_info();
201  const std::vector<color_t>& tc_info(const std::string& name);
202  const color_range& color_info(const std::string& name);
203 
204  /**
205  * Return a color corresponding to the value val
206  * red for val=0.0 to green for val=100.0, passing by yellow.
207  * Colors are defined by [game_config] keys
208  * red_green_scale and red_green_scale_text
209  */
210  color_t red_to_green(double val, bool for_text = true);
211  color_t blue_to_white(double val, bool for_text = true);
212 
213  std::string get_default_title_string();
214 }
int kill_xp(int level)
Definition: game_config.hpp:48
std::vector< std::string > default_victory_music
std::string battery_icon
int combat_xp(int level)
Definition: game_config.hpp:53
std::string game_user_leave
std::string victory_laurel
std::string tod_dark
bool show_unmoved_orb
double hp_bar_scaling
Definition: game_config.cpp:79
double xp_bar_scaling
Definition: game_config.cpp:80
std::map< std::string, color_range > team_rgb_range
Colors defined by WML [color_range] tags.
int village_support
Definition: game_config.cpp:56
bool check_migration
Definition: game_config.cpp:47
std::string mouseover
std::vector< unsigned int > zoom_levels
Definition: game_config.cpp:74
const std::string menu_expand
std::string private_message
std::string game_title
std::string selected_menu
std::string lobby_music
std::string unreachable
const std::string slider_adjust
std::string unit_rgb
std::string get_default_title_string()
const std::string default_title_string
const std::string menu_select
std::string unchecked_menu
std::string victory_laurel_easy
std::string enemy_orb_color
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...
Definition: game_config.cpp:92
bool show_enemy_orb
std::string player_joins
std::string address
may include &#39;:&#39; followed by port number
Definition: game_config.hpp:80
void load_config(const config &v)
int rest_heal_amount
Definition: game_config.cpp:62
bool show_ally_orb
std::vector< std::string > default_defeat_music
std::string terrain_mask
std::string flag_icon
std::string turn_bell
std::string timer_bell
std::string ally_orb_color
std::string deselected_menu
const std::string ellipsis
Definition: constants.cpp:39
std::string victory_laurel_hardest
std::vector< color_t > red_green_scale_text
unsigned lobby_network_timer
Definition: game_config.cpp:87
bool disable_autosave
std::string default_color_list
std::string ready_for_start
const int gold_carryover_percentage
Default percentage gold carried over to the next scenario.
Definition: game_config.cpp:64
std::string game_user_arrive
bool ignore_replay_errors
std::string selected
std::string foot_teleport_enter
std::string game_title_background
The basic class for representing 8-bit RGB or RGBA colour values.
Definition: color.hpp:58
int kill_experience
Definition: game_config.cpp:58
std::string grid_bottom
std::string path
Definition: game_config.cpp:39
std::string game_logo_background
std::string shroud_prefix
Definition: game_config.cpp:72
std::string default_terrain
Definition: game_config.cpp:71
std::string moved_orb_color
static void add_color_info(const game_config_view &v, bool build_defaults)
bool allow_insecure
Definition: game_config.cpp:96
std::string flag_rgb
bool show_status_on_ally_orb
std::map< std::string, std::vector< color_t > > team_rgb_colors
std::string editor_brush
std::string unmoved_orb_color
Game configuration data as global variables.
Definition: build_info.cpp:60
std::string public_message
int village_income
Definition: game_config.cpp:55
void reset_color_info()
const std::string menu_contract
A color range definition is made of four reference RGB colors, used for calculating conversions from ...
Definition: color_range.hpp:49
std::vector< color_t > red_green_scale
std::string title_music
bool show_moved_orb
int combat_experience
Definition: game_config.cpp:59
const bool & debug
std::vector< std::string > foot_speed_prefix
color_t blue_to_white(double val, bool for_text)
std::string observer
std::string player_leaves
const std::string button_press
std::string foot_teleport_exit
unsigned int tile_size
Definition: game_config.cpp:69
unsigned lobby_refresh
Definition: game_config.cpp:88
const color_range & color_info(const std::string &name)
std::string tod_bright
std::string game_logo
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.0, passing by yellow.
const std::vector< color_t > & tc_info(const std::string &name)
std::string time_icon
std::string checked_menu
bool show_partial_orb
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.
Definition: config.hpp:60
std::string wml_menu
std::map< std::string, t_string > team_rgb_name
std::string game_has_begun
bool show_disengaged_orb
std::string grid_top
std::string fog_prefix
Definition: game_config.cpp:72
std::vector< server_info > server_list
Definition: game_config.cpp:94
std::string app_icon
std::string wesnoth_program_dir
Definition: game_config.cpp:49
void set_debug(bool new_debug)
std::string default_preferences_path
Definition: game_config.cpp:45
const std::string observer_team_name
observer team name used for observer team chat
Definition: game_config.cpp:90
const std::string checkbox_release
int cache_compression_level
Definition: game_config.cpp:85