The Battle for Wesnoth  1.15.1+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  server_info() : name(""), address("") { }
74  std::string name;
75  std::string address; /**< may include ':' followed by port number */
76  };
77  extern std::vector<server_info> server_list;
78 
79  extern std::string title_music,
81 
82  extern std::vector<std::string> default_defeat_music;
83  extern std::vector<std::string> default_victory_music;
84 
85  namespace colors {
86  extern std::string unmoved_orb_color,
92  } // colors
93 
95 
96  namespace images {
97  extern std::string game_title,
99  game_logo,
104  // orbs and hp/xp bar
105  orb,
106  energy,
107  // top bar icons
108  battery_icon,
109  time_icon,
110  // flags
111  flag,
112  flag_icon,
113  // hex overlay
114  terrain_mask,
115  grid_top,
116  grid_bottom,
117  mouseover,
118  selected,
119  editor_brush,
120  unreachable,
121  linger,
122  // GUI elements
123  observer,
124  tod_bright,
125  tod_dark,
128  checked_menu,
130  wml_menu,
131  level,
132  ellipsis,
133  missing,
134  // notifications icon
135  app_icon;
136  } //images
137 
138 
139  extern std::string shroud_prefix, fog_prefix;
140 
141  extern double hp_bar_scaling, xp_bar_scaling;
142  extern double hex_brightening;
143  extern double hex_semi_brightening;
144 
145  extern std::string flag_rgb, unit_rgb;
146  extern std::vector<color_t> red_green_scale;
147  extern std::vector<color_t> red_green_scale_text;
148 
149  extern std::vector<std::string> foot_speed_prefix;
150  extern std::string foot_teleport_enter, foot_teleport_exit;
151 
152  extern std::map<std::string, color_range> team_rgb_range;
153  extern std::map<std::string, t_string> team_rgb_name;
154  extern std::map<std::string, std::vector<color_t>> team_rgb_colors;
155 
156  extern std::vector<std::string> default_colors;
157 
158  /** observer team name used for observer team chat */
159  extern const std::string observer_team_name;
160 
161  /**
162  * The maximum number of hexes on a map and items in an array and also used
163  * as maximum in wml loops.
164  * WARNING : This should not be set to less than the max map area
165  */
166  extern const std::size_t max_loop;
167 
168  namespace sounds {
169  extern std::string turn_bell, timer_bell, public_message,
174  extern const std::string button_press, checkbox_release, slider_adjust,
176  namespace status {
177  extern std::string poisoned, slowed, petrified;
178  }
179  }
180 
181  void load_config(const config &cfg);
182 
183  void add_color_info(const config& v);
184  void reset_color_info();
185  const std::vector<color_t>& tc_info(const std::string& name);
186  const color_range& color_info(const std::string& name);
187 
188  /**
189  * Return a color corresponding to the value val
190  * red for val=0 to green for val=100, passing by yellow.
191  * Colors are defined by [game_config] keys
192  * red_green_scale and red_green_scale_text
193  */
194 
195  color_t red_to_green(int val, bool for_text = true);
196  color_t blue_to_white(int val, bool for_text = true);
197 
198  std::string get_default_title_string();
199 }
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
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:92
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