The Battle for Wesnoth  1.19.0+dev
game.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
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
double t
Definition: astarsearch.cpp:63
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Game board class.
Definition: game_board.hpp:46
Encapsulates the map of the game.
Definition: map.hpp:172
void load_from_config(const config &cfg)
Definition: game.cpp:1005
std::string nick_
acquaintance's MP nick
Definition: game.hpp:69
acquaintance(const std::string &nick, const std::string &status, const std::string &notes)
Definition: game.hpp:52
std::string notes_
notes on the acquaintance
Definition: game.hpp:75
const std::string & get_status() const
Definition: game.hpp:62
void save(config &cfg)
Definition: game.cpp:1012
const std::string & get_nick() const
Definition: game.hpp:61
std::string status_
status (e.g., "friend", "ignore")
Definition: game.hpp:72
const std::string & get_notes() const
Definition: game.hpp:63
acquaintance(const config &cfg)
Definition: game.hpp:47
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:74
Definition: theme.hpp:43
Container associating units to locations.
Definition: map.hpp:98
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:65
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:50
Modify, read and display user preferences.
void set_village_support(int value)
Definition: game.cpp:663
void set_show_side_colors(bool value)
Definition: game.cpp:738
void set_campaign_server(const std::string &host)
Definition: game.cpp:408
void set_skip_ai_moves(bool value)
Definition: game.cpp:733
bool show_all_units_in_help()
Definition: game.cpp:903
void set_village_gold(int value)
Definition: game.cpp:653
bool ask_delete_saves()
Definition: game.cpp:773
bool show_floating_labels()
Definition: game.cpp:820
bool fog()
Definition: game.cpp:522
int village_support()
Definition: game.cpp:658
void set_era(const std::string &value)
Definition: game.cpp:683
void set_user_servers_list(const std::vector< game_config::server_info > &value)
Definition: game.cpp:372
void set_shuffle_sides(bool value)
Definition: game.cpp:463
lobby_joins get_lobby_joins()
Definition: game.cpp:328
void set_allow_observers(bool value)
Definition: game.cpp:453
void set_skip_mp_replay(bool value)
Definition: game.cpp:583
void _set_lobby_joins(lobby_joins show)
Definition: game.cpp:342
std::string get_mp_server_program_name()
Definition: game.cpp:507
void set_message_private(bool value)
Definition: game.cpp:835
bool shroud()
Definition: game.cpp:532
void set_mp_server_program_name(const std::string &path)
Definition: game.cpp:498
bool is_ignored(const std::string &nick)
Definition: game.cpp:273
bool blindfold_replay()
Definition: game.cpp:588
bool chat_timestamping()
Definition: game.cpp:873
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
Definition: game.cpp:285
int village_gold()
Definition: game.cpp:648
void set_hide_whiteboard(bool value)
Definition: game.cpp:438
int level_type()
Definition: game.cpp:698
void set_shroud(bool value)
Definition: game.cpp:537
void set_custom_command(const std::string &command)
Definition: game.cpp:928
bool skip_mp_replay()
Definition: game.cpp:578
bool delete_saves()
Definition: game.cpp:763
int countdown_init_time()
Definition: game.cpp:608
bool interrupt_when_ally_sighted()
Definition: game.cpp:783
void set_random_faction_mode(const std::string &value)
Definition: game.cpp:473
const std::string get_ignored_delim()
Definition: game.cpp:195
void set_modifications(const std::vector< std::string > &value, bool mp)
Definition: game.cpp:717
void set_turns(int value)
Definition: game.cpp:547
int autosavemax()
Definition: game.cpp:788
std::string campaign_server()
Definition: game.cpp:399
bool is_campaign_completed(const std::string &campaign_id)
Definition: game.cpp:290
void set_blindfold_replay(bool value)
Definition: game.cpp:593
void set_mp_server_warning_disabled(int value)
Definition: game.cpp:493
std::set< std::string > & encountered_units()
Definition: game.cpp:913
compression::format save_compression_format()
Definition: game.cpp:840
std::string network_host()
Definition: game.cpp:384
void set_show_all_units_in_help(bool value)
Definition: game.cpp:908
std::string level()
Definition: game.cpp:688
std::string era()
Definition: game.cpp:678
void set_chat_lines(int lines)
Definition: game.cpp:888
void set_chat_message_aging(const int aging)
Definition: game.cpp:893
bool save_replays()
Definition: game.cpp:753
void encounter_all_content(const game_board &gameboard_)
Definition: game.cpp:997
std::vector< game_config::server_info > user_servers_list()
Definition: game.cpp:359
void set_network_host(const std::string &host)
Definition: game.cpp:394
void encounter_start_units(const unit_map &units)
Definition: game.cpp:970
bool confirm_no_moves()
Definition: game.cpp:955
void set_delete_saves(bool value)
Definition: game.cpp:758
void set_interrupt_when_ally_sighted(bool value)
Definition: game.cpp:778
int chat_message_aging()
Definition: game.cpp:898
void set_chat_timestamping(bool value)
Definition: game.cpp:878
bool countdown()
Definition: game.cpp:598
void set_xp_modifier(int value)
Definition: game.cpp:673
void set_use_map_settings(bool value)
Definition: game.cpp:483
bool shuffle_sides()
Definition: game.cpp:458
bool turn_dialog()
Definition: game.cpp:413
void set_level_type(int value)
Definition: game.cpp:703
bool use_map_settings()
Definition: game.cpp:478
static void encounter_recallable_units(const std::vector< team > &teams)
Definition: game.cpp:977
bool random_start_time()
Definition: game.cpp:512
void set_countdown_reservoir_time(int value)
Definition: game.cpp:623
int countdown_turn_bonus()
Definition: game.cpp:628
int countdown_action_bonus()
Definition: game.cpp:638
std::set< t_translation::terrain_code > & encountered_terrains()
Definition: game.cpp:918
int turns()
Definition: game.cpp:542
void set_countdown(bool value)
Definition: game.cpp:603
bool hide_whiteboard()
Definition: game.cpp:433
void encounter_recruitable_units(const std::vector< team > &teams)
Definition: game.cpp:962
bool show_combat()
Definition: game.cpp:443
std::string get_chat_timestamp(const std::time_t &t)
Definition: game.cpp:860
std::string theme()
Definition: game.cpp:798
std::string custom_command()
Definition: game.cpp:923
void set_turn_dialog(bool ison)
Definition: game.cpp:418
int mp_server_warning_disabled()
Definition: game.cpp:488
bool green_confirm()
Definition: game.cpp:944
bool message_private()
Definition: game.cpp:830
const std::vector< game_config::server_info > & builtin_servers_list()
Definition: game.cpp:353
void set_theme(const std::string &theme)
Definition: game.cpp:813
bool remove_acquaintance(const std::string &nick)
Definition: game.cpp:238
void encounter_map_terrain(const gamemap &map)
Definition: game.cpp:986
int chat_lines()
Definition: game.cpp:883
void set_countdown_init_time(int value)
Definition: game.cpp:613
bool show_side_colors()
Definition: game.cpp:743
void set_ask_delete_saves(bool value)
Definition: game.cpp:768
void set_countdown_action_bonus(int value)
Definition: game.cpp:643
void set_level(const std::string &value)
Definition: game.cpp:693
void set_show_floating_labels(bool value)
Definition: game.cpp:825
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
Definition: game.cpp:301
std::pair< preferences::acquaintance *, bool > add_acquaintance(const std::string &nick, const std::string &mode, const std::string &notes)
Definition: game.cpp:224
void set_fog(bool value)
Definition: game.cpp:527
void set_options(const config &values)
Definition: game.cpp:572
void set_save_replays(bool value)
Definition: game.cpp:748
void set_random_start_time(bool value)
Definition: game.cpp:517
void set_autosavemax(int value)
Definition: game.cpp:793
std::map< std::string, std::string > get_acquaintances_nice(const std::string &filter)
Definition: game.cpp:210
bool skip_ai_moves()
Definition: game.cpp:728
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't exist...
Definition: game.cpp:939
int countdown_reservoir_time()
Definition: game.cpp:618
void load_game_prefs()
Definition: game.cpp:117
const int INFINITE_AUTO_SAVES
Definition: game.hpp:208
bool enable_whiteboard_mode_on_start()
Definition: game.cpp:423
void set_countdown_turn_bonus(int value)
Definition: game.cpp:633
void set_enable_whiteboard_mode_on_start(bool value)
Definition: game.cpp:428
const config & options()
Definition: game.cpp:552
std::string random_faction_mode()
Definition: game.cpp:468
bool allow_observers()
Definition: game.cpp:448
int xp_modifier()
Definition: game.cpp:668
bool yellow_confirm()
Definition: game.cpp:950
const std::map< std::string, acquaintance > & get_acquaintances()
Definition: game.cpp:189
bool is_friend(const std::string &nick)
Definition: game.cpp:261
const std::vector< std::string > & modifications(bool mp)
Definition: game.cpp:708
base_manager base
Definition: game.hpp:37