The Battle for Wesnoth  1.17.4+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 disengaged_orb_color;
94  extern std::string enemy_orb_color;
95  extern std::string moved_orb_color;
96  extern std::string partial_orb_color;
97  extern std::string unmoved_orb_color;
98  extern std::string default_color_list;
99  } // colors
100 
101  extern bool show_ally_orb;
102  extern bool show_disengaged_orb;
103  extern bool show_enemy_orb;
104  extern bool show_moved_orb;
105  extern bool show_partial_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  // notifications icon
148  app_icon;
149  } //images
150 
151 
152  extern std::string shroud_prefix, fog_prefix;
153 
154  extern double hp_bar_scaling, xp_bar_scaling;
155  extern double hex_brightening;
156  extern double hex_semi_brightening;
157 
158  extern std::string flag_rgb, unit_rgb;
159  extern std::vector<color_t> red_green_scale;
160  extern std::vector<color_t> red_green_scale_text;
161 
162  extern std::vector<std::string> foot_speed_prefix;
163  extern std::string foot_teleport_enter, foot_teleport_exit;
164 
165  /**
166  * Colors defined by WML [color_range] tags. In addition to team colors such as "red" and
167  * "blue", this also contains the colors used on the minimap for "cave", "fungus" etc.
168  */
169  extern std::map<std::string, color_range> team_rgb_range;
170  extern std::map<std::string, t_string> team_rgb_name;
171  extern std::map<std::string, std::vector<color_t>> team_rgb_colors;
172 
173  extern std::vector<std::string> default_colors;
174 
175  /** observer team name used for observer team chat */
176  extern const std::string observer_team_name;
177 
178  /**
179  * The maximum number of hexes on a map and items in an array and also used
180  * as maximum in wml loops.
181  * WARNING : This should not be set to less than the max map area
182  */
183  extern const std::size_t max_loop;
184 
185  namespace sounds {
186  extern std::string turn_bell, timer_bell, public_message,
187  private_message, friend_message,
188  server_message, player_joins, player_leaves,
190  game_has_begun, game_created;
191  extern const std::string button_press, checkbox_release, slider_adjust,
193  namespace status {
194  extern std::string poisoned, slowed, petrified;
195  }
196  }
197 
198  void load_config(const config &cfg);
199 
200  void add_color_info(const game_config_view& v);
201  void reset_color_info();
202  const std::vector<color_t>& tc_info(const std::string& name);
203  const color_range& color_info(const std::string& name);
204 
205  /**
206  * Return a color corresponding to the value val
207  * red for val=0 to green for val=100, passing by yellow.
208  * Colors are defined by [game_config] keys
209  * red_green_scale and red_green_scale_text
210  */
211 
212  color_t red_to_green(int val, bool for_text = true);
213  color_t blue_to_white(int val, bool for_text = true);
214 
215  std::string get_default_title_string();
216 }
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
color_t blue_to_white(int val, bool for_text)
std::string private_message
std::string game_title
double hex_semi_brightening
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:93
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 disengaged_orb_color
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:88
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
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:97
std::string flag_rgb
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
std::string observer
std::string player_leaves
const std::string button_press
std::string foot_teleport_exit
color_t red_to_green(int val, bool for_text)
Return a color corresponding to the value val red for val=0 to green for val=100, passing by yellow...
unsigned int tile_size
Definition: game_config.cpp:69
unsigned lobby_refresh
Definition: game_config.cpp:89
const color_range & color_info(const std::string &name)
double hex_brightening
Definition: game_config.cpp:81
std::string tod_bright
std::string game_logo
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:95
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:91
const std::string checkbox_release
int cache_compression_level
Definition: game_config.cpp:86