The Battle for Wesnoth  1.17.4+dev
game.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 #include "game_config.hpp"
19 #include "preferences/general.hpp"
21 
22 #include <set>
23 #include <vector>
24 
25 class game_board;
26 class gamemap;
27 class team;
28 class unit_map;
29 
30 namespace preferences
31 {
32 struct manager
33 {
34  manager();
35  ~manager();
36 
38 };
39 
41 {
42 public:
44  {
45  }
46 
47  explicit acquaintance(const config& cfg)
48  {
49  load_from_config(cfg);
50  }
51 
52  acquaintance(const std::string& nick, const std::string& status, const std::string& notes)
53  : nick_(nick)
54  , status_(status)
55  , notes_(notes)
56  {
57  }
58 
59  void load_from_config(const config& cfg);
60 
61  const std::string& get_nick() const { return nick_; }
62  const std::string& get_status() const { return status_; }
63  const std::string& get_notes() const { return notes_; }
64 
65  void save(config& cfg);
66 
67 private:
68  /** acquaintance's MP nick */
69  std::string nick_;
70 
71  /**status (e.g., "friend", "ignore") */
72  std::string status_;
73 
74  /** notes on the acquaintance */
75  std::string notes_;
76 };
77 
79 
80 bool parse_should_show_lobby_join(const std::string& sender, const std::string& message);
83 
84 void load_game_prefs();
85 const std::map<std::string, acquaintance>& get_acquaintances();
86 const std::string get_ignored_delim();
87 std::map<std::string, std::string> get_acquaintances_nice(const std::string& filter);
88 std::pair<preferences::acquaintance*, bool> add_acquaintance(const std::string& nick, const std::string& mode, const std::string& notes);
89 void add_completed_campaign(const std::string&campaign_id, const std::string& difficulty_level);
90 bool remove_acquaintance(const std::string& nick);
91 bool is_friend(const std::string& nick);
92 bool is_ignored(const std::string& nick);
93 bool is_campaign_completed(const std::string& campaign_id);
94 bool is_campaign_completed(const std::string& campaign_id, const std::string& difficulty_level);
95 
96 const std::vector<game_config::server_info>& builtin_servers_list();
97 std::vector<game_config::server_info> user_servers_list();
98 void set_user_servers_list(const std::vector<game_config::server_info>& value);
99 
100 std::string network_host();
101 void set_network_host(const std::string& host);
102 
103 std::string campaign_server();
104 void set_campaign_server(const std::string& host);
105 
106 bool turn_dialog();
107 void set_turn_dialog(bool ison);
108 
110 void set_enable_whiteboard_mode_on_start(bool value);
111 
112 bool hide_whiteboard();
113 void set_hide_whiteboard(bool value);
114 
115 bool show_combat();
116 
117 bool allow_observers();
118 void set_allow_observers(bool value);
119 
120 bool shuffle_sides();
121 void set_shuffle_sides(bool value);
122 
123 std::string random_faction_mode();
124 void set_random_faction_mode(const std::string& value);
125 
126 bool use_map_settings();
127 void set_use_map_settings(bool value);
128 
130 void set_mp_server_warning_disabled(int value);
131 
132 void set_mp_server_program_name(const std::string&);
133 std::string get_mp_server_program_name();
134 
135 bool random_start_time();
136 void set_random_start_time(bool value);
137 
138 bool fog();
139 void set_fog(bool value);
140 
141 bool shroud();
142 void set_shroud(bool value);
143 
144 int turns();
145 void set_turns(int value);
146 
147 const config& options();
148 void set_options(const config& values);
149 
150 bool skip_mp_replay();
151 void set_skip_mp_replay(bool value);
152 
153 bool blindfold_replay();
154 void set_blindfold_replay(bool value);
155 
156 bool countdown();
157 void set_countdown(bool value);
158 int countdown_init_time();
159 void set_countdown_init_time(int value);
161 void set_countdown_turn_bonus(int value);
163 void set_countdown_reservoir_time(int value);
165 void set_countdown_action_bonus(int value);
166 
167 int village_gold();
168 void set_village_gold(int value);
169 
170 int village_support();
171 void set_village_support(int value);
172 
173 int xp_modifier();
174 void set_xp_modifier(int value);
175 
176 std::string era();
177 void set_era(const std::string& value);
178 
179 std::string level();
180 void set_level(const std::string& value);
181 int level_type();
182 void set_level_type(int value);
183 
184 const std::vector<std::string>& modifications(bool mp = true);
185 void set_modifications(const std::vector<std::string>& value, bool mp = true);
186 
187 bool skip_ai_moves();
188 void set_skip_ai_moves(bool value);
189 
190 void set_show_side_colors(bool value);
191 bool show_side_colors();
192 
193 bool save_replays();
194 void set_save_replays(bool value);
195 
196 bool delete_saves();
197 void set_delete_saves(bool value);
198 
199 void set_ask_delete_saves(bool value);
200 bool ask_delete_saves();
201 
202 void set_interrupt_when_ally_sighted(bool value);
204 
205 void set_autosavemax(int value);
206 int autosavemax();
207 
208 const int INFINITE_AUTO_SAVES = 61;
209 
210 bool show_floating_labels();
211 void set_show_floating_labels(bool value);
212 
213 bool message_private();
214 void set_message_private(bool value);
215 
216 // Multiplayer functions
217 std::string get_chat_timestamp(const std::time_t& t);
218 bool chat_timestamping();
219 void set_chat_timestamping(bool value);
220 
221 int chat_lines();
222 void set_chat_lines(int lines);
223 
224 int chat_message_aging();
225 void set_chat_message_aging(const int aging);
226 
228 void set_show_all_units_in_help(bool value);
229 
231 
232 std::set<std::string>&encountered_units();
233 std::set<t_translation::terrain_code>&encountered_terrains();
234 
235 std::string custom_command();
236 void set_custom_command(const std::string& command);
237 
238 std::vector<std::string>* get_history(const std::string& id);
239 
240 void set_theme(const std::string& theme);
241 std::string theme();
242 
243 // Ask for end turn confirmation
244 bool yellow_confirm();
245 bool green_confirm();
246 bool confirm_no_moves();
247 
248 // Add all recruitable units as encountered so that information
249 // about them are displayed to the user in the help system.
250 void encounter_recruitable_units(const std::vector<team>& teams);
251 
252 // Add all units that exist at the start to the encountered units so
253 // that information about them are displayed to the user in the help
254 // system.
255 void encounter_start_units(const unit_map& units);
256 
257 // Add all units that are recallable as encountered units.
258 void encounter_recallable_units(std::vector<team>& teams);
259 
260 // Add all terrains on the map as encountered terrains.
261 void encounter_map_terrain(const gamemap& map);
262 
263 // Calls all of the above functions on the current game board
264 void encounter_all_content(const game_board& gb);
265 
266 } // namespace preferences
Game board class.
Definition: game_board.hpp:52
void set_hide_whiteboard(bool value)
Definition: game.cpp:441
int autosavemax()
Definition: game.cpp:791
void set_campaign_server(const std::string &host)
Definition: game.cpp:411
void set_village_support(int value)
Definition: game.cpp:666
acquaintance(const config &cfg)
Definition: game.hpp:47
std::string random_faction_mode()
Definition: game.cpp:471
bool message_private()
Definition: game.cpp:833
static void encounter_recallable_units(const std::vector< team > &teams)
Definition: game.cpp:980
void set_countdown_action_bonus(int value)
Definition: game.cpp:646
void set_countdown_turn_bonus(int value)
Definition: game.cpp:636
std::string era()
Definition: game.cpp:681
hotkey_ptr load_from_config(const config &cfg)
Create and instantiate a hotkey from a config element.
void set_shroud(bool value)
Definition: game.cpp:540
void set_countdown_init_time(int value)
Definition: game.cpp:616
int xp_modifier()
Definition: game.cpp:671
std::string campaign_server()
Definition: game.cpp:402
void set_mp_server_warning_disabled(int value)
Definition: game.cpp:496
void set_show_floating_labels(bool value)
Definition: game.cpp:828
void set_options(const config &values)
Definition: game.cpp:575
const std::map< std::string, acquaintance > & get_acquaintances()
Definition: game.cpp:192
bool is_campaign_completed(const std::string &campaign_id)
Definition: game.cpp:293
const int INFINITE_AUTO_SAVES
Definition: game.hpp:208
const std::string get_ignored_delim()
Definition: game.cpp:198
bool shuffle_sides()
Definition: game.cpp:461
void set_show_side_colors(bool value)
Definition: game.cpp:741
std::string network_host()
Definition: game.cpp:387
bool hide_whiteboard()
Definition: game.cpp:436
void set_chat_lines(int lines)
Definition: game.cpp:891
int chat_lines()
Definition: game.cpp:886
std::string status_
status (e.g., "friend", "ignore")
Definition: game.hpp:72
void set_random_faction_mode(const std::string &value)
Definition: game.cpp:476
void set_network_host(const std::string &host)
Definition: game.cpp:397
bool show_side_colors()
Definition: game.cpp:746
void set_countdown(bool value)
Definition: game.cpp:606
bool remove_acquaintance(const std::string &nick)
Definition: game.cpp:241
void set_interrupt_when_ally_sighted(bool value)
Definition: game.cpp:781
int countdown_init_time()
Definition: game.cpp:611
bool yellow_confirm()
Definition: game.cpp:953
void set_mp_server_program_name(const std::string &path)
Definition: game.cpp:501
bool fog()
Definition: game.cpp:525
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:52
bool confirm_no_moves()
Definition: game.cpp:958
void set_chat_message_aging(const int aging)
Definition: game.cpp:896
const config & options()
Definition: game.cpp:555
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:75
void set_turn_dialog(bool ison)
Definition: game.cpp:421
int countdown_turn_bonus()
Definition: game.cpp:631
void set_level_type(int value)
Definition: game.cpp:706
void set_custom_command(const std::string &command)
Definition: game.cpp:931
const std::vector< game_config::server_info > & builtin_servers_list()
Definition: game.cpp:356
int village_support()
Definition: game.cpp:661
std::string level()
Definition: game.cpp:691
void set_save_replays(bool value)
Definition: game.cpp:751
bool is_friend(const std::string &nick)
Definition: game.cpp:264
base_manager base
Definition: game.hpp:37
void set_theme(const std::string &theme)
Definition: game.cpp:816
void encounter_map_terrain(const gamemap &map)
Definition: game.cpp:989
void encounter_start_units(const unit_map &units)
Definition: game.cpp:973
const std::string & get_nick() const
Definition: game.hpp:61
std::string theme()
Definition: game.cpp:801
void _set_lobby_joins(lobby_joins show)
Definition: game.cpp:345
std::pair< preferences::acquaintance *, bool > add_acquaintance(const std::string &nick, const std::string &mode, const std::string &notes)
Definition: game.cpp:227
int countdown_reservoir_time()
Definition: game.cpp:621
void set_enable_whiteboard_mode_on_start(bool value)
Definition: game.cpp:431
bool blindfold_replay()
Definition: game.cpp:591
Encapsulates the map of the game.
Definition: map.hpp:171
void set_random_start_time(bool value)
Definition: game.cpp:520
std::set< t_translation::terrain_code > & encountered_terrains()
Definition: game.cpp:921
void set_user_servers_list(const std::vector< game_config::server_info > &value)
Definition: game.cpp:375
Modify, read and display user preferences.
bool show_combat()
Definition: game.cpp:446
int village_gold()
Definition: game.cpp:651
bool show_all_units_in_help()
Definition: game.cpp:906
void set_blindfold_replay(bool value)
Definition: game.cpp:596
bool chat_timestamping()
Definition: game.cpp:876
void set_message_private(bool value)
Definition: game.cpp:838
bool is_ignored(const std::string &nick)
Definition: game.cpp:276
void set_chat_timestamping(bool value)
Definition: game.cpp:881
void set_level(const std::string &value)
Definition: game.cpp:696
void set_allow_observers(bool value)
Definition: game.cpp:456
bool countdown()
Definition: game.cpp:601
std::vector< std::string > * get_history(const std::string &id)
Returns a pointer to the history vector associated with given id making a new one if it doesn&#39;t exist...
Definition: game.cpp:942
bool shroud()
Definition: game.cpp:535
int mp_server_warning_disabled()
Definition: game.cpp:491
std::string get_mp_server_program_name()
Definition: game.cpp:510
bool interrupt_when_ally_sighted()
Definition: game.cpp:786
void load_game_prefs()
Definition: game.cpp:120
void set_delete_saves(bool value)
Definition: game.cpp:761
Definition: theme.hpp:41
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
Definition: game.cpp:288
void encounter_all_content(const game_board &gameboard_)
Definition: game.cpp:1000
bool use_map_settings()
Definition: game.cpp:481
bool delete_saves()
Definition: game.cpp:766
void set_skip_mp_replay(bool value)
Definition: game.cpp:586
std::set< std::string > & encountered_units()
Definition: game.cpp:916
const std::string & get_status() const
Definition: game.hpp:62
std::map< std::string, std::string > get_acquaintances_nice(const std::string &filter)
Definition: game.cpp:213
bool ask_delete_saves()
Definition: game.cpp:776
bool skip_mp_replay()
Definition: game.cpp:581
const std::string & get_notes() const
Definition: game.hpp:63
void set_turns(int value)
Definition: game.cpp:550
std::string get_chat_timestamp(const std::time_t &t)
Definition: game.cpp:863
void set_autosavemax(int value)
Definition: game.cpp:796
compression::format save_compression_format()
Definition: game.cpp:843
void set_show_all_units_in_help(bool value)
Definition: game.cpp:911
bool allow_observers()
Definition: game.cpp:451
bool green_confirm()
Definition: game.cpp:947
int turns()
Definition: game.cpp:545
bool show_floating_labels()
Definition: game.cpp:823
const std::vector< std::string > & modifications(bool mp)
Definition: game.cpp:711
lobby_joins get_lobby_joins()
Definition: game.cpp:331
double t
Definition: astarsearch.cpp:65
std::string notes_
notes on the acquaintance
Definition: game.hpp:75
void set_modifications(const std::vector< std::string > &value, bool mp)
Definition: game.cpp:720
int chat_message_aging()
Definition: game.cpp:901
bool enable_whiteboard_mode_on_start()
Definition: game.cpp:426
int countdown_action_bonus()
Definition: game.cpp:641
Container associating units to locations.
Definition: map.hpp:98
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
Definition: game.cpp:304
void set_era(const std::string &value)
Definition: game.cpp:686
void set_shuffle_sides(bool value)
Definition: game.cpp:466
void set_fog(bool value)
Definition: game.cpp:530
void set_ask_delete_saves(bool value)
Definition: game.cpp:771
void encounter_recruitable_units(const std::vector< team > &teams)
Definition: game.cpp:965
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60
void set_countdown_reservoir_time(int value)
Definition: game.cpp:626
bool random_start_time()
Definition: game.cpp:515
std::vector< game_config::server_info > user_servers_list()
Definition: game.cpp:362
void set_skip_ai_moves(bool value)
Definition: game.cpp:736
std::string custom_command()
Definition: game.cpp:926
void set_xp_modifier(int value)
Definition: game.cpp:676
bool turn_dialog()
Definition: game.cpp:416
void set_village_gold(int value)
Definition: game.cpp:656
void set_use_map_settings(bool value)
Definition: game.cpp:486
bool skip_ai_moves()
Definition: game.cpp:731
acquaintance(const std::string &nick, const std::string &status, const std::string &notes)
Definition: game.hpp:52
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
Definition: tooltip.cpp:140
std::string nick_
acquaintance&#39;s MP nick
Definition: game.hpp:69
bool save_replays()
Definition: game.cpp:756
int level_type()
Definition: game.cpp:701