The Battle for Wesnoth  1.17.8+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:442
int autosavemax()
Definition: game.cpp:792
void set_campaign_server(const std::string &host)
Definition: game.cpp:412
void set_village_support(int value)
Definition: game.cpp:667
acquaintance(const config &cfg)
Definition: game.hpp:47
std::string random_faction_mode()
Definition: game.cpp:472
bool message_private()
Definition: game.cpp:834
static void encounter_recallable_units(const std::vector< team > &teams)
Definition: game.cpp:981
void set_countdown_action_bonus(int value)
Definition: game.cpp:647
void set_countdown_turn_bonus(int value)
Definition: game.cpp:637
std::string era()
Definition: game.cpp:682
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:541
void set_countdown_init_time(int value)
Definition: game.cpp:617
int xp_modifier()
Definition: game.cpp:672
std::string campaign_server()
Definition: game.cpp:403
void set_mp_server_warning_disabled(int value)
Definition: game.cpp:497
void set_show_floating_labels(bool value)
Definition: game.cpp:829
void set_options(const config &values)
Definition: game.cpp:576
const std::map< std::string, acquaintance > & get_acquaintances()
Definition: game.cpp:193
bool is_campaign_completed(const std::string &campaign_id)
Definition: game.cpp:294
const int INFINITE_AUTO_SAVES
Definition: game.hpp:208
const std::string get_ignored_delim()
Definition: game.cpp:199
bool shuffle_sides()
Definition: game.cpp:462
void set_show_side_colors(bool value)
Definition: game.cpp:742
std::string network_host()
Definition: game.cpp:388
bool hide_whiteboard()
Definition: game.cpp:437
void set_chat_lines(int lines)
Definition: game.cpp:892
int chat_lines()
Definition: game.cpp:887
std::string status_
status (e.g., "friend", "ignore")
Definition: game.hpp:72
void set_random_faction_mode(const std::string &value)
Definition: game.cpp:477
void set_network_host(const std::string &host)
Definition: game.cpp:398
bool show_side_colors()
Definition: game.cpp:747
void set_countdown(bool value)
Definition: game.cpp:607
bool remove_acquaintance(const std::string &nick)
Definition: game.cpp:242
void set_interrupt_when_ally_sighted(bool value)
Definition: game.cpp:782
int countdown_init_time()
Definition: game.cpp:612
bool yellow_confirm()
Definition: game.cpp:954
void set_mp_server_program_name(const std::string &path)
Definition: game.cpp:502
bool fog()
Definition: game.cpp:526
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:52
bool confirm_no_moves()
Definition: game.cpp:959
void set_chat_message_aging(const int aging)
Definition: game.cpp:897
const config & options()
Definition: game.cpp:556
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:422
int countdown_turn_bonus()
Definition: game.cpp:632
void set_level_type(int value)
Definition: game.cpp:707
void set_custom_command(const std::string &command)
Definition: game.cpp:932
const std::vector< game_config::server_info > & builtin_servers_list()
Definition: game.cpp:357
int village_support()
Definition: game.cpp:662
std::string level()
Definition: game.cpp:692
void set_save_replays(bool value)
Definition: game.cpp:752
bool is_friend(const std::string &nick)
Definition: game.cpp:265
base_manager base
Definition: game.hpp:37
void set_theme(const std::string &theme)
Definition: game.cpp:817
void encounter_map_terrain(const gamemap &map)
Definition: game.cpp:990
void encounter_start_units(const unit_map &units)
Definition: game.cpp:974
const std::string & get_nick() const
Definition: game.hpp:61
std::string theme()
Definition: game.cpp:802
void _set_lobby_joins(lobby_joins show)
Definition: game.cpp:346
std::pair< preferences::acquaintance *, bool > add_acquaintance(const std::string &nick, const std::string &mode, const std::string &notes)
Definition: game.cpp:228
int countdown_reservoir_time()
Definition: game.cpp:622
void set_enable_whiteboard_mode_on_start(bool value)
Definition: game.cpp:432
bool blindfold_replay()
Definition: game.cpp:592
Encapsulates the map of the game.
Definition: map.hpp:171
void set_random_start_time(bool value)
Definition: game.cpp:521
std::set< t_translation::terrain_code > & encountered_terrains()
Definition: game.cpp:922
void set_user_servers_list(const std::vector< game_config::server_info > &value)
Definition: game.cpp:376
Modify, read and display user preferences.
bool show_combat()
Definition: game.cpp:447
int village_gold()
Definition: game.cpp:652
bool show_all_units_in_help()
Definition: game.cpp:907
void set_blindfold_replay(bool value)
Definition: game.cpp:597
bool chat_timestamping()
Definition: game.cpp:877
void set_message_private(bool value)
Definition: game.cpp:839
bool is_ignored(const std::string &nick)
Definition: game.cpp:277
void set_chat_timestamping(bool value)
Definition: game.cpp:882
void set_level(const std::string &value)
Definition: game.cpp:697
void set_allow_observers(bool value)
Definition: game.cpp:457
bool countdown()
Definition: game.cpp:602
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:943
bool shroud()
Definition: game.cpp:536
int mp_server_warning_disabled()
Definition: game.cpp:492
std::string get_mp_server_program_name()
Definition: game.cpp:511
bool interrupt_when_ally_sighted()
Definition: game.cpp:787
void load_game_prefs()
Definition: game.cpp:121
void set_delete_saves(bool value)
Definition: game.cpp:762
Definition: theme.hpp:42
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
Definition: game.cpp:289
void encounter_all_content(const game_board &gameboard_)
Definition: game.cpp:1001
bool use_map_settings()
Definition: game.cpp:482
bool delete_saves()
Definition: game.cpp:767
void set_skip_mp_replay(bool value)
Definition: game.cpp:587
std::set< std::string > & encountered_units()
Definition: game.cpp:917
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:214
bool ask_delete_saves()
Definition: game.cpp:777
bool skip_mp_replay()
Definition: game.cpp:582
const std::string & get_notes() const
Definition: game.hpp:63
void set_turns(int value)
Definition: game.cpp:551
std::string get_chat_timestamp(const std::time_t &t)
Definition: game.cpp:864
void set_autosavemax(int value)
Definition: game.cpp:797
compression::format save_compression_format()
Definition: game.cpp:844
void set_show_all_units_in_help(bool value)
Definition: game.cpp:912
bool allow_observers()
Definition: game.cpp:452
bool green_confirm()
Definition: game.cpp:948
int turns()
Definition: game.cpp:546
bool show_floating_labels()
Definition: game.cpp:824
const std::vector< std::string > & modifications(bool mp)
Definition: game.cpp:712
lobby_joins get_lobby_joins()
Definition: game.cpp:332
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:721
int chat_message_aging()
Definition: game.cpp:902
bool enable_whiteboard_mode_on_start()
Definition: game.cpp:427
int countdown_action_bonus()
Definition: game.cpp:642
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:305
void set_era(const std::string &value)
Definition: game.cpp:687
void set_shuffle_sides(bool value)
Definition: game.cpp:467
void set_fog(bool value)
Definition: game.cpp:531
void set_ask_delete_saves(bool value)
Definition: game.cpp:772
void encounter_recruitable_units(const std::vector< team > &teams)
Definition: game.cpp:966
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:627
bool random_start_time()
Definition: game.cpp:516
std::vector< game_config::server_info > user_servers_list()
Definition: game.cpp:363
void set_skip_ai_moves(bool value)
Definition: game.cpp:737
std::string custom_command()
Definition: game.cpp:927
void set_xp_modifier(int value)
Definition: game.cpp:677
bool turn_dialog()
Definition: game.cpp:417
void set_village_gold(int value)
Definition: game.cpp:657
void set_use_map_settings(bool value)
Definition: game.cpp:487
bool skip_ai_moves()
Definition: game.cpp:732
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:81
std::string nick_
acquaintance&#39;s MP nick
Definition: game.hpp:69
bool save_replays()
Definition: game.cpp:757
int level_type()
Definition: game.cpp:702