The Battle for Wesnoth  1.15.12+dev
game.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 #include "game_config.hpp"
18 #include "preferences/general.hpp"
20 
21 #include <set>
22 #include <vector>
23 
24 class game_board;
25 class gamemap;
26 class team;
27 class unit_map;
28 
29 namespace preferences
30 {
31 struct manager
32 {
33  manager();
34  ~manager();
35 
37 };
38 
40 {
41 public:
43  {
44  }
45 
46  explicit acquaintance(const config& cfg)
47  {
48  load_from_config(cfg);
49  }
50 
51  acquaintance(const std::string& nick, const std::string& status, const std::string& notes)
52  : nick_(nick)
53  , status_(status)
54  , notes_(notes)
55  {
56  }
57 
58  void load_from_config(const config& cfg);
59 
60  const std::string& get_nick() const { return nick_; }
61  const std::string& get_status() const { return status_; }
62  const std::string& get_notes() const { return notes_; }
63 
64  void save(config& cfg);
65 
66 private:
67  /** acquaintance's MP nick */
68  std::string nick_;
69 
70  /**status (e.g., "friend", "ignore") */
71  std::string status_;
72 
73  /** notes on the acquaintance */
74  std::string notes_;
75 };
76 
77 bool parse_should_show_lobby_join(const std::string& sender, const std::string& message);
78 int lobby_joins();
79 void _set_lobby_joins(int show);
80 
82 
83 const std::map<std::string, acquaintance>& get_acquaintances();
84 const std::string get_ignored_delim();
85 std::map<std::string, std::string> get_acquaintances_nice(const std::string& filter);
86 std::pair<preferences::acquaintance*, bool> add_acquaintance(const std::string& nick, const std::string& mode, const std::string& notes);
87 void add_completed_campaign(const std::string&campaign_id, const std::string& difficulty_level);
88 bool remove_acquaintance(const std::string& nick);
89 bool is_friend(const std::string& nick);
90 bool is_ignored(const std::string& nick);
91 bool is_campaign_completed(const std::string& campaign_id);
92 bool is_campaign_completed(const std::string& campaign_id, const std::string& difficulty_level);
93 
94 const std::vector<game_config::server_info>& builtin_servers_list();
95 std::vector<game_config::server_info> user_servers_list();
96 void set_user_servers_list(const std::vector<game_config::server_info>& value);
97 
98 std::string network_host();
99 void set_network_host(const std::string& host);
100 
101 std::string campaign_server();
102 void set_campaign_server(const std::string& host);
103 
104 bool turn_dialog();
105 void set_turn_dialog(bool ison);
106 
108 void set_enable_whiteboard_mode_on_start(bool value);
109 
110 bool hide_whiteboard();
111 void set_hide_whiteboard(bool value);
112 
113 bool show_combat();
114 
115 bool allow_observers();
116 void set_allow_observers(bool value);
117 
118 bool shuffle_sides();
119 void set_shuffle_sides(bool value);
120 
121 std::string random_faction_mode();
122 void set_random_faction_mode(const std::string& value);
123 
124 bool use_map_settings();
125 void set_use_map_settings(bool value);
126 
128 void set_mp_server_warning_disabled(int value);
129 
130 void set_mp_server_program_name(const std::string&);
131 std::string get_mp_server_program_name();
132 
133 bool random_start_time();
134 void set_random_start_time(bool value);
135 
136 bool fog();
137 void set_fog(bool value);
138 
139 bool shroud();
140 void set_shroud(bool value);
141 
142 int turns();
143 void set_turns(int value);
144 
145 const config& options();
146 void set_options(const config& values);
147 
148 bool skip_mp_replay();
149 void set_skip_mp_replay(bool value);
150 
151 bool blindfold_replay();
152 void set_blindfold_replay(bool value);
153 
154 bool countdown();
155 void set_countdown(bool value);
156 int countdown_init_time();
157 void set_countdown_init_time(int value);
159 void set_countdown_turn_bonus(int value);
161 void set_countdown_reservoir_time(int value);
163 void set_countdown_action_bonus(int value);
164 
165 int village_gold();
166 void set_village_gold(int value);
167 
168 int village_support();
169 void set_village_support(int value);
170 
171 int xp_modifier();
172 void set_xp_modifier(int value);
173 
174 std::string era();
175 void set_era(const std::string& value);
176 
177 std::string level();
178 void set_level(const std::string& value);
179 int level_type();
180 void set_level_type(int value);
181 
182 const std::vector<std::string>& modifications(bool mp = true);
183 void set_modifications(const std::vector<std::string>& value, bool mp = true);
184 
185 bool skip_ai_moves();
186 void set_skip_ai_moves(bool value);
187 
188 void set_show_side_colors(bool value);
189 bool show_side_colors();
190 
191 bool save_replays();
192 void set_save_replays(bool value);
193 
194 bool delete_saves();
195 void set_delete_saves(bool value);
196 
197 void set_ask_delete_saves(bool value);
198 bool ask_delete_saves();
199 
200 void set_interrupt_when_ally_sighted(bool value);
202 
203 void set_autosavemax(int value);
204 int autosavemax();
205 
206 const int INFINITE_AUTO_SAVES = 61;
207 
208 bool show_floating_labels();
209 void set_show_floating_labels(bool value);
210 
211 bool message_private();
212 void set_message_private(bool value);
213 
214 // Multiplayer functions
215 std::string get_chat_timestamp(const std::time_t& t);
216 bool chat_timestamping();
217 void set_chat_timestamping(bool value);
218 
219 int chat_lines();
220 void set_chat_lines(int lines);
221 
222 int chat_message_aging();
223 void set_chat_message_aging(const int aging);
224 
226 void set_show_all_units_in_help(bool value);
227 
229 
230 std::set<std::string>&encountered_units();
231 std::set<t_translation::terrain_code>&encountered_terrains();
232 
233 std::string custom_command();
234 void set_custom_command(const std::string& command);
235 
236 std::vector<std::string>* get_history(const std::string& id);
237 
238 void set_theme(const std::string& theme);
239 std::string theme();
240 
241 // Ask for end turn confirmation
242 bool yellow_confirm();
243 bool green_confirm();
244 bool confirm_no_moves();
245 
246 // Add all recruitable units as encountered so that information
247 // about them are displayed to the user in the help system.
248 void encounter_recruitable_units(const std::vector<team>& teams);
249 
250 // Add all units that exist at the start to the encountered units so
251 // that information about them are displayed to the user in the help
252 // system.
253 void encounter_start_units(const unit_map& units);
254 
255 // Add all units that are recallable as encountered units.
256 void encounter_recallable_units(std::vector<team>& teams);
257 
258 // Add all terrains on the map as encountered terrains.
259 void encounter_map_terrain(const gamemap& map);
260 
261 // Calls all of the above functions on the current game board
262 void encounter_all_content(const game_board& gb);
263 
264 } // namespace preferences
Game board class.
Definition: game_board.hpp:50
void set_hide_whiteboard(bool value)
Definition: game.cpp:449
int autosavemax()
Definition: game.cpp:799
void set_campaign_server(const std::string &host)
Definition: game.cpp:419
void set_village_support(int value)
Definition: game.cpp:674
acquaintance(const config &cfg)
Definition: game.hpp:46
std::string random_faction_mode()
Definition: game.cpp:479
bool message_private()
Definition: game.cpp:841
static void encounter_recallable_units(const std::vector< team > &teams)
Definition: game.cpp:988
void set_countdown_action_bonus(int value)
Definition: game.cpp:654
void set_countdown_turn_bonus(int value)
Definition: game.cpp:644
std::string era()
Definition: game.cpp:689
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:548
void set_countdown_init_time(int value)
Definition: game.cpp:624
int xp_modifier()
Definition: game.cpp:679
std::string campaign_server()
Definition: game.cpp:410
void set_mp_server_warning_disabled(int value)
Definition: game.cpp:504
void set_show_floating_labels(bool value)
Definition: game.cpp:836
void set_options(const config &values)
Definition: game.cpp:583
int lobby_joins()
Definition: game.cpp:339
const std::map< std::string, acquaintance > & get_acquaintances()
Definition: game.cpp:195
bool is_campaign_completed(const std::string &campaign_id)
Definition: game.cpp:301
const int INFINITE_AUTO_SAVES
Definition: game.hpp:206
const std::string get_ignored_delim()
Definition: game.cpp:201
bool shuffle_sides()
Definition: game.cpp:469
void set_show_side_colors(bool value)
Definition: game.cpp:749
std::string network_host()
Definition: game.cpp:395
bool hide_whiteboard()
Definition: game.cpp:444
void _set_lobby_joins(int show)
Definition: game.cpp:353
void set_chat_lines(int lines)
Definition: game.cpp:899
int chat_lines()
Definition: game.cpp:894
std::string status_
status (e.g., "friend", "ignore")
Definition: game.hpp:71
void set_random_faction_mode(const std::string &value)
Definition: game.cpp:484
void set_network_host(const std::string &host)
Definition: game.cpp:405
bool show_side_colors()
Definition: game.cpp:754
void set_countdown(bool value)
Definition: game.cpp:614
bool remove_acquaintance(const std::string &nick)
Definition: game.cpp:249
void set_interrupt_when_ally_sighted(bool value)
Definition: game.cpp:789
int countdown_init_time()
Definition: game.cpp:619
bool yellow_confirm()
Definition: game.cpp:961
void set_mp_server_program_name(const std::string &path)
Definition: game.cpp:509
bool fog()
Definition: game.cpp:533
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:51
bool confirm_no_moves()
Definition: game.cpp:966
void set_chat_message_aging(const int aging)
Definition: game.cpp:904
const config & options()
Definition: game.cpp:563
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:44
void set_turn_dialog(bool ison)
Definition: game.cpp:429
int countdown_turn_bonus()
Definition: game.cpp:639
void set_level_type(int value)
Definition: game.cpp:714
void set_custom_command(const std::string &command)
Definition: game.cpp:939
const std::vector< game_config::server_info > & builtin_servers_list()
Definition: game.cpp:364
int village_support()
Definition: game.cpp:669
std::string level()
Definition: game.cpp:699
void set_save_replays(bool value)
Definition: game.cpp:759
bool is_friend(const std::string &nick)
Definition: game.cpp:272
base_manager base
Definition: game.hpp:36
void set_theme(const std::string &theme)
Definition: game.cpp:824
void encounter_map_terrain(const gamemap &map)
Definition: game.cpp:997
void encounter_start_units(const unit_map &units)
Definition: game.cpp:981
const std::string & get_nick() const
Definition: game.hpp:60
std::string theme()
Definition: game.cpp:809
std::pair< preferences::acquaintance *, bool > add_acquaintance(const std::string &nick, const std::string &mode, const std::string &notes)
Definition: game.cpp:230
int countdown_reservoir_time()
Definition: game.cpp:629
void set_enable_whiteboard_mode_on_start(bool value)
Definition: game.cpp:439
bool blindfold_replay()
Definition: game.cpp:599
Encapsulates the map of the game.
Definition: map.hpp:170
void set_random_start_time(bool value)
Definition: game.cpp:528
std::set< t_translation::terrain_code > & encountered_terrains()
Definition: game.cpp:929
void set_user_servers_list(const std::vector< game_config::server_info > &value)
Definition: game.cpp:383
Modify, read and display user preferences.
bool show_combat()
Definition: game.cpp:454
int village_gold()
Definition: game.cpp:659
bool show_all_units_in_help()
Definition: game.cpp:914
void set_blindfold_replay(bool value)
Definition: game.cpp:604
bool chat_timestamping()
Definition: game.cpp:884
void set_message_private(bool value)
Definition: game.cpp:846
bool is_ignored(const std::string &nick)
Definition: game.cpp:284
void set_chat_timestamping(bool value)
Definition: game.cpp:889
void set_level(const std::string &value)
Definition: game.cpp:704
void set_allow_observers(bool value)
Definition: game.cpp:464
bool countdown()
Definition: game.cpp:609
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:950
bool shroud()
Definition: game.cpp:543
int mp_server_warning_disabled()
Definition: game.cpp:499
std::string get_mp_server_program_name()
Definition: game.cpp:518
bool interrupt_when_ally_sighted()
Definition: game.cpp:794
void set_delete_saves(bool value)
Definition: game.cpp:769
Definition: theme.hpp:40
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
Definition: game.cpp:296
void encounter_all_content(const game_board &gameboard_)
Definition: game.cpp:1008
bool use_map_settings()
Definition: game.cpp:489
bool delete_saves()
Definition: game.cpp:774
void set_skip_mp_replay(bool value)
Definition: game.cpp:594
std::set< std::string > & encountered_units()
Definition: game.cpp:924
const std::string & get_status() const
Definition: game.hpp:61
std::map< std::string, std::string > get_acquaintances_nice(const std::string &filter)
Definition: game.cpp:216
bool ask_delete_saves()
Definition: game.cpp:784
bool skip_mp_replay()
Definition: game.cpp:589
const std::string & get_notes() const
Definition: game.hpp:62
static void save(LexState *ls, int c)
Definition: llex.cpp:57
void set_turns(int value)
Definition: game.cpp:558
std::string get_chat_timestamp(const std::time_t &t)
Definition: game.cpp:871
void set_autosavemax(int value)
Definition: game.cpp:804
compression::format save_compression_format()
Definition: game.cpp:851
void set_show_all_units_in_help(bool value)
Definition: game.cpp:919
bool allow_observers()
Definition: game.cpp:459
bool green_confirm()
Definition: game.cpp:955
int turns()
Definition: game.cpp:553
bool show_floating_labels()
Definition: game.cpp:831
const std::vector< std::string > & modifications(bool mp)
Definition: game.cpp:719
double t
Definition: astarsearch.cpp:64
std::string notes_
notes on the acquaintance
Definition: game.hpp:74
void set_modifications(const std::vector< std::string > &value, bool mp)
Definition: game.cpp:728
int chat_message_aging()
Definition: game.cpp:909
bool enable_whiteboard_mode_on_start()
Definition: game.cpp:434
int countdown_action_bonus()
Definition: game.cpp:649
Container associating units to locations.
Definition: map.hpp:97
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
Definition: game.cpp:312
void set_era(const std::string &value)
Definition: game.cpp:694
void set_shuffle_sides(bool value)
Definition: game.cpp:474
void set_fog(bool value)
Definition: game.cpp:538
void set_ask_delete_saves(bool value)
Definition: game.cpp:779
void encounter_recruitable_units(const std::vector< team > &teams)
Definition: game.cpp:973
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:59
void set_countdown_reservoir_time(int value)
Definition: game.cpp:634
bool random_start_time()
Definition: game.cpp:523
std::vector< game_config::server_info > user_servers_list()
Definition: game.cpp:370
void set_skip_ai_moves(bool value)
Definition: game.cpp:744
std::string custom_command()
Definition: game.cpp:934
void set_xp_modifier(int value)
Definition: game.cpp:684
bool turn_dialog()
Definition: game.cpp:424
void set_village_gold(int value)
Definition: game.cpp:664
void set_use_map_settings(bool value)
Definition: game.cpp:494
bool skip_ai_moves()
Definition: game.cpp:739
acquaintance(const std::string &nick, const std::string &status, const std::string &notes)
Definition: game.hpp:51
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:139
std::string nick_
acquaintance&#39;s MP nick
Definition: game.hpp:68
bool save_replays()
Definition: game.cpp:764
int level_type()
Definition: game.cpp:709