The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
game_preferences.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 #ifndef GAME_PREFERENCES_HPP_INCLUDED
15 #define GAME_PREFERENCES_HPP_INCLUDED
16 
17 class game_board;
18 class gamemap;
19 class team;
20 class unit_map;
21 
22 #include "preferences.hpp"
23 #include "game_config.hpp"
24 
26 
27 #include <set>
28 #include <vector>
29 
30 namespace preferences {
31 
32 class acquaintance;
33 
34  struct manager
35  {
36  manager();
37  ~manager();
38 
40  };
41 
42  bool is_authenticated();
43  void parse_admin_authentication(const std::string& sender, const std::string& message);
44 
45  /**
46  * Used to reset is_authenticated flag after disconnecting.
47  *
48  * @todo FIXME: is_authenticated shouldn't be a preferences function. Also,
49  * the name is misleading.
50  */
52  {
53  /**
54  * Default constructor, defined out of line to work around a warning in
55  * gcc 4.5.2
56  */
59  };
60 
61  bool parse_should_show_lobby_join(const std::string& sender, const std::string& message);
62  int lobby_joins();
63  void _set_lobby_joins(int show);
65 
66  bool new_lobby();
67 
68  const std::map<std::string, acquaintance> & get_acquaintances();
69  std::map<std::string, std::string> get_acquaintances_nice(const std::string& filter);
70  bool add_friend(const std::string& nick, const std::string& notes);
71  bool add_ignore(const std::string& nick, const std::string& reason);
72  void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level);
73  bool remove_acquaintance(const std::string& nick);
74  bool is_friend(const std::string& nick);
75  bool is_ignored(const std::string& nick);
76  bool is_campaign_completed(const std::string& campaign_id);
77  bool is_campaign_completed(const std::string& campaign_id, const std::string &difficulty_level);
78 
79  const std::vector<game_config::server_info>& server_list();
80 
82  void set_network_host(const std::string& host);
83 
84  unsigned int get_ping_timeout();
85 
87  void set_campaign_server(const std::string& host);
88 
89  /**
90  * Returns whether the MP username is stored wrapped in markers.
91  *
92  * New usernames are stored in a specific format to force string interpretation
93  * (due to bug #16571).
94  */
95  bool wrap_login();
96  void set_wrap_login(bool wrap);
97 
99  void set_login(const std::string& username);
100 
101  // If password remembering is turned off use
102  // prv::password instead. This way we will not
103  // have to worry about whether to remember the
104  // password or not anywhere else in the code.
105  //
106  // It is put into a separate namespace to make clear
107  // it is "private" and not supposed to be edit outside
108  // of the preferences functions.
109  namespace prv {
110  extern std::string password;
111  }
112 
113  /**
114  * Returns whether the password is stored wrapped in markers.
115  *
116  * New passwords are stored in a specific format to force string interpretation
117  * (due to bug #16571).
118  */
119  bool wrap_password();
120  void set_wrap_password(bool wrap);
121 
123  void set_password(const std::string& password);
124 
125  bool remember_password();
126  void set_remember_password(bool remember);
127 
128  bool turn_dialog();
129  void set_turn_dialog(bool ison);
130 
133 
134  bool hide_whiteboard();
135  void set_hide_whiteboard(bool value);
136 
137  bool show_combat();
138 
139  bool allow_observers();
140  void set_allow_observers(bool value);
141 
142  bool registered_users_only();
143  void set_registered_users_only(bool value);
144 
145  bool shuffle_sides();
146  void set_shuffle_sides(bool value);
147 
150 
151  bool use_map_settings();
152  void set_use_map_settings(bool value);
153 
156 
159 
160  bool random_start_time();
161  void set_random_start_time(bool value);
162 
163  bool fog();
164  void set_fog(bool value);
165 
166  bool shroud();
167  void set_shroud(bool value);
168 
169  int turns();
170  void set_turns(int value);
171 
172  const config& options();
173  void set_options(const config& values);
174 
175  bool skip_mp_replay();
176  void set_skip_mp_replay(bool value);
177 
178  bool blindfold_replay();
179  void set_blindfold_replay(bool value);
180 
181  bool countdown();
182  void set_countdown(bool value);
183  int countdown_init_time();
184  void set_countdown_init_time(int value);
185  int countdown_turn_bonus();
191 
192  int village_gold();
193  void set_village_gold(int value);
194 
195  int village_support();
196  void set_village_support(int value);
197 
198  int xp_modifier();
199  void set_xp_modifier(int value);
200 
201  std::string era();
202  void set_era(const std::string& value);
203 
204  std::string level();
205  void set_level(const std::string& value);
206  int level_type();
207  void set_level_type(int value);
208 
209  const std::vector<std::string>& modifications(bool mp=true);
210  void set_modifications(const std::vector<std::string>& value, bool mp=true);
211 
212  bool show_ai_moves();
213  void set_show_ai_moves(bool value);
214 
215  void set_show_side_colors(bool value);
216  bool show_side_colors();
217 
218  bool save_replays();
219  void set_save_replays(bool value);
220 
221  bool delete_saves();
222  void set_delete_saves(bool value);
223 
224  void set_ask_delete_saves(bool value);
225  bool ask_delete_saves();
226 
229 
230  void set_autosavemax(int value);
231  int autosavemax();
232 
233  const int INFINITE_AUTO_SAVES = 61;
234 
235  bool show_floating_labels();
236  void set_show_floating_labels(bool value);
237 
238  bool message_private();
239  void set_message_private(bool value);
240 
241  bool show_haloes();
242  void set_show_haloes(bool value);
243 
244 
245  // Multiplayer functions
246  std::string get_chat_timestamp(const time_t& t);
247  bool chat_timestamping();
248  void set_chat_timestamping(bool value);
249 
250  int chat_lines();
251  void set_chat_lines(int lines);
252 
253  int chat_message_aging();
254  void set_chat_message_aging(const int aging);
255 
256  int max_wml_menu_items();
257  void set_max_wml_menu_items(int max);
258 
259  bool show_all_units_in_help();
261 
263 
264  std::set<std::string> &encountered_units();
265  std::set<t_translation::t_terrain> &encountered_terrains();
266 
268  void set_custom_command(const std::string& command);
269 
270  std::vector<std::string>* get_history(const std::string& id);
271 
272  void set_theme(const std::string& theme);
273  std::string theme();
274 
275  // Ask for end turn confirmation
276  bool yellow_confirm();
277  bool green_confirm();
278  bool confirm_no_moves();
279 
280  // Add all recruitable units as encountered so that information
281  // about them are displayed to the user in the help system.
282  void encounter_recruitable_units(const std::vector<team>& teams);
283  // Add all units that exist at the start to the encountered units so
284  // that information about them are displayed to the user in the help
285  // system.
286  void encounter_start_units(const unit_map& units);
287  // Add all units that are recallable as encountered units.
288  void encounter_recallable_units(std::vector<team>& teams);
289  // Add all terrains on the map as encountered terrains.
290  void encounter_map_terrain(const gamemap& map);
291 
292  // Calls all of the above functions on the current game board
293  void encounter_all_content(const game_board & gb);
294 
296 public:
297 
299  {
300  }
301 
302  explicit acquaintance(const config& cfg)
303  {
304  load_from_config(cfg);
305  }
306 
308  const std::string& nick
309  , const std::string& status
310  , const std::string& notes)
311  : nick_(nick)
312  , status_(status)
313  , notes_(notes)
314  {
315 
316  }
317 
318  void load_from_config(const config& cfg);
319 
320  const std::string& get_nick() const { return nick_; }
321  const std::string& get_status() const { return status_; }
322  const std::string& get_notes() const { return notes_; }
323 
324  void save(config& cfg);
325 
326 private:
327 
328  /** acquaintance's MP nick */
330 
331  /**status (e.g., "friend", "ignore") */
333 
334  /** notes on the acquaintance */
336 
337 };
338 
339 }
340 
341 #endif
void set_password(const std::string &password)
Game board class.
Definition: game_board.hpp:55
void set_hide_whiteboard(bool value)
void set_campaign_server(const std::string &host)
void set_village_support(int value)
bool remember_password()
void set_wrap_password(bool wrap)
void set_show_haloes(bool value)
acquaintance(const config &cfg)
std::string random_faction_mode()
static void encounter_recallable_units(const std::vector< team > &teams)
unsigned int get_ping_timeout()
void set_countdown_action_bonus(int value)
void set_countdown_turn_bonus(int value)
std::string era()
void set_shroud(bool value)
void set_countdown_init_time(int value)
std::string campaign_server()
void set_mp_server_warning_disabled(int value)
bool wrap_login()
Returns whether the MP username is stored wrapped in markers.
void set_remember_password(bool remember)
void set_show_floating_labels(bool value)
void set_options(const config &values)
bool wrap_password()
Returns whether the password is stored wrapped in markers.
const std::map< std::string, acquaintance > & get_acquaintances()
bool is_campaign_completed(const std::string &campaign_id)
const int INFINITE_AUTO_SAVES
void set_show_side_colors(bool value)
std::string network_host()
void load_from_config(const config &cfg)
void parse_admin_authentication(const std::string &sender, const std::string &message)
void set_login(const std::string &username)
void _set_lobby_joins(int show)
void set_chat_lines(int lines)
std::string status_
status (e.g., "friend", "ignore")
void set_random_faction_mode(const std::string &value)
void set_network_host(const std::string &host)
void set_countdown(bool value)
GLdouble GLdouble t
Definition: glew.h:1366
bool remove_acquaintance(const std::string &nick)
void set_interrupt_when_ally_sighted(bool value)
void set_registered_users_only(bool value)
void set_max_wml_menu_items(int max)
GLboolean GLenum GLenum GLvoid * values
Definition: glew.h:3799
void set_mp_server_program_name(const std::string &path)
This module controls the multiplayer lobby.
static std::vector< team > *& teams
Definition: team.cpp:50
void set_chat_message_aging(const int aging)
const config & options()
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
void set_turn_dialog(bool ison)
int countdown_turn_bonus()
void set_level_type(int value)
void set_custom_command(const std::string &command)
std::string level()
void set_save_replays(bool value)
bool is_friend(const std::string &nick)
void set_theme(const std::string &theme)
void encounter_map_terrain(const gamemap &map)
void encounter_start_units(const unit_map &units)
std::string theme()
int countdown_reservoir_time()
GLsizei const GLfloat * value
Definition: glew.h:1817
void set_enable_whiteboard_mode_on_start(bool value)
std::set< t_translation::t_terrain > & encountered_terrains()
Encapsulates the map of the game.
Definition: map.hpp:37
const std::vector< game_config::server_info > & server_list()
void set_random_start_time(bool value)
const std::string & get_status() const
Modify, read and display user preferences.
bool registered_users_only()
Used to reset is_authenticated flag after disconnecting.
bool show_all_units_in_help()
void set_blindfold_replay(bool value)
void set_message_private(bool value)
bool is_ignored(const std::string &nick)
void set_chat_timestamping(bool value)
void show(CVideo &video, const std::string &window_id, const t_string &message, const tpoint &mouse)
Shows a tip.
Definition: tip.cpp:133
void set_level(const std::string &value)
std::string login()
bool add_friend(const std::string &nick, const std::string &notes)
bool add_ignore(const std::string &nick, const std::string &reason)
admin_authentication_reset()
Default constructor, defined out of line to work around a warning in gcc 4.5.2.
void set_allow_observers(bool value)
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...
const std::string & get_notes() const
int mp_server_warning_disabled()
std::string get_mp_server_program_name()
bool interrupt_when_ally_sighted()
void set_delete_saves(bool value)
Definition: theme.hpp:37
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
void set_wrap_login(bool wrap)
void encounter_all_content(const game_board &gameboard_)
void set_skip_mp_replay(bool value)
std::set< std::string > & encountered_units()
std::map< std::string, std::string > get_acquaintances_nice(const std::string &filter)
const std::string & get_nick() const
void set_turns(int value)
void set_autosavemax(int value)
compression::format save_compression_format()
void set_show_all_units_in_help(bool value)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:3448
bool show_floating_labels()
const std::vector< std::string > & modifications(bool mp)
std::string notes_
notes on the acquaintance
std::string get_chat_timestamp(const time_t &t)
void set_modifications(const std::vector< std::string > &value, bool mp)
bool enable_whiteboard_mode_on_start()
int countdown_action_bonus()
void set_show_ai_moves(bool value)
Container associating units to locations.
Definition: map.hpp:90
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
void set_era(const std::string &value)
void set_shuffle_sides(bool value)
void set_fog(bool value)
void set_ask_delete_saves(bool value)
void encounter_recruitable_units(const std::vector< team > &teams)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
void set_countdown_reservoir_time(int value)
bool random_start_time()
std::string custom_command()
std::string password()
void set_xp_modifier(int value)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
unit_map * units
Definition: resources.cpp:35
void set_village_gold(int value)
void set_use_map_settings(bool value)
acquaintance(const std::string &nick, const std::string &status, const std::string &notes)
std::string nick_
acquaintance's MP nick