The Battle for Wesnoth  1.15.2+dev
game_config.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 class config;
18 class color_range;
19 
20 #include "color.hpp"
21 #include "tstring.hpp"
22 
23 #include <vector>
24 #include <map>
25 #include <cstdint>
26 
27 //basic game configuration information is here.
28 namespace game_config
29 {
30  extern int base_income;
31  extern int village_income;
32  extern int village_support;
33  extern int poison_amount;
34  extern int rest_heal_amount;
35  extern int recall_cost;
36  extern int kill_experience;
37  extern int combat_experience;
38  extern unsigned int tile_size;
39  extern unsigned lobby_network_timer;
40  extern unsigned lobby_refresh;
41  extern const std::string default_title_string;
42  extern std::string default_terrain;
43 
44  extern std::vector<unsigned int> zoom_levels;
45 
46  inline int kill_xp(int level)
47  {
48  return level ? kill_experience * level : kill_experience / 2;
49  }
50 
51  inline int combat_xp(int level)
52  {
53  return combat_experience * level;
54  }
55 
56  extern std::string wesnoth_program_dir;
57 
58  /** Default percentage gold carried over to the next scenario. */
59  extern const int gold_carryover_percentage;
60 
63 
64  extern const bool& debug;
65  void set_debug(bool new_debug);
66 
67  extern int cache_compression_level;
68 
69  extern std::string path;
70  extern std::string default_preferences_path;
71 
72  struct server_info
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 unmoved_orb_color,
93  } // colors
94 
96 
97  namespace images {
98  extern std::string game_title,
100  game_logo,
105  // orbs and hp/xp bar
106  orb,
107  energy,
108  // top bar icons
109  battery_icon,
110  time_icon,
111  // flags
112  flag,
113  flag_icon,
114  // hex overlay
115  terrain_mask,
116  grid_top,
117  grid_bottom,
118  mouseover,
119  selected,
120  editor_brush,
121  unreachable,
122  linger,
123  // GUI elements
124  observer,
125  tod_bright,
126  tod_dark,
129  checked_menu,
131  wml_menu,
132  level,
133  ellipsis,
134  missing,
135  // notifications icon
136  app_icon;
137  } //images
138 
139 
140  extern std::string shroud_prefix, fog_prefix;
141 
142  extern double hp_bar_scaling, xp_bar_scaling;
143  extern double hex_brightening;
144  extern double hex_semi_brightening;
145 
146  extern std::string flag_rgb, unit_rgb;
147  extern std::vector<color_t> red_green_scale;
148  extern std::vector<color_t> red_green_scale_text;
149 
150  extern std::vector<std::string> foot_speed_prefix;
151  extern std::string foot_teleport_enter, foot_teleport_exit;
152 
153  extern std::map<std::string, color_range> team_rgb_range;
154  extern std::map<std::string, t_string> team_rgb_name;
155  extern std::map<std::string, std::vector<color_t>> team_rgb_colors;
156 
157  extern std::vector<std::string> default_colors;
158 
159  /** observer team name used for observer team chat */
160  extern const std::string observer_team_name;
161 
162  /**
163  * The maximum number of hexes on a map and items in an array and also used
164  * as maximum in wml loops.
165  * WARNING : This should not be set to less than the max map area
166  */
167  extern const std::size_t max_loop;
168 
169  namespace sounds {
170  extern std::string turn_bell, timer_bell, public_message,
175  extern const std::string button_press, checkbox_release, slider_adjust,
177  namespace status {
178  extern std::string poisoned, slowed, petrified;
179  }
180  }
181 
182  void load_config(const config &cfg);
183 
184  void add_color_info(const config& v);
185  void reset_color_info();
186  const std::vector<color_t>& tc_info(const std::string& name);
187  const color_range& color_info(const std::string& name);
188 
189  /**
190  * Return a color corresponding to the value val
191  * red for val=0 to green for val=100, passing by yellow.
192  * Colors are defined by [game_config] keys
193  * red_green_scale and red_green_scale_text
194  */
195 
196  color_t red_to_green(int val, bool for_text = true);
197  color_t blue_to_white(int val, bool for_text = true);
198 
199  std::string get_default_title_string();
200 }
int kill_xp(int level)
Definition: game_config.hpp:46
std::vector< std::string > default_victory_music
std::string battery_icon
int combat_xp(int level)
Definition: game_config.hpp:51
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:78
double xp_bar_scaling
Definition: game_config.cpp:79
std::map< std::string, color_range > team_rgb_range
int village_support
Definition: game_config.cpp:55
std::string mouseover
std::vector< unsigned int > zoom_levels
Definition: game_config.cpp:73
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 friend_message
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:75
void load_config(const config &v)
static void add_color_info(const config &v, bool build_defaults)
int rest_heal_amount
Definition: game_config.cpp:61
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:35
std::string victory_laurel_hardest
std::vector< color_t > red_green_scale_text
unsigned lobby_network_timer
Definition: game_config.cpp:87
std::string game_created
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:63
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:57
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:71
std::string default_terrain
Definition: game_config.cpp:70
std::string moved_orb_color
std::string flag_rgb
std::string server_message
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:49
std::string public_message
int village_income
Definition: game_config.cpp:54
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:50
std::vector< color_t > red_green_scale
std::string title_music
bool show_moved_orb
int combat_experience
Definition: game_config.cpp:58
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:68
unsigned lobby_refresh
Definition: game_config.cpp:88
const color_range & color_info(const std::string &name)
double hex_brightening
Definition: game_config.cpp:80
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
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
std::string wml_menu
std::map< std::string, t_string > team_rgb_name
std::string game_has_begun
std::string grid_top
std::string fog_prefix
Definition: game_config.cpp:71
std::vector< server_info > server_list
Definition: game_config.cpp:94
std::string app_icon
std::string wesnoth_program_dir
Definition: game_config.cpp:48
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