/
game_preferences.hpp
337 lines (248 loc) · 8.51 KB
/
game_preferences.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/*
Copyright (C) 2003 - 2016 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef GAME_PREFERENCES_HPP_INCLUDED
#define GAME_PREFERENCES_HPP_INCLUDED
class game_board;
class gamemap;
class team;
class unit_map;
#include "preferences.hpp"
#include "game_config.hpp"
#include "serialization/compression.hpp"
#include <set>
#include <vector>
namespace preferences {
class acquaintance;
struct manager
{
manager();
~manager();
base_manager base;
};
bool is_authenticated();
void parse_admin_authentication(const std::string& sender, const std::string& message);
/**
* Used to reset is_authenticated flag after disconnecting.
*
* @todo FIXME: is_authenticated shouldn't be a preferences function. Also,
* the name is misleading.
*/
struct admin_authentication_reset
{
/**
* Default constructor, defined out of line to work around a warning in
* gcc 4.5.2
*/
admin_authentication_reset();
~admin_authentication_reset();
};
bool parse_should_show_lobby_join(const std::string& sender, const std::string& message);
int lobby_joins();
void _set_lobby_joins(int show);
enum LOBBY_JOINS { SHOW_NONE, SHOW_FRIENDS, SHOW_ALL };
bool new_lobby();
const std::map<std::string, acquaintance> & get_acquaintances();
std::map<std::string, std::string> get_acquaintances_nice(const std::string& filter);
preferences::acquaintance* add_acquaintance(const std::string& nick, const std::string& mode, const std::string& notes);
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level);
bool remove_acquaintance(const std::string& nick);
bool is_friend(const std::string& nick);
bool is_ignored(const std::string& nick);
bool is_campaign_completed(const std::string& campaign_id);
bool is_campaign_completed(const std::string& campaign_id, const std::string &difficulty_level);
const std::vector<game_config::server_info>& server_list();
std::string network_host();
void set_network_host(const std::string& host);
unsigned int get_ping_timeout();
std::string campaign_server();
void set_campaign_server(const std::string& host);
/**
* Returns whether the MP username is stored wrapped in markers.
*
* New usernames are stored in a specific format to force string interpretation
* (due to bug #16571).
*/
bool wrap_login();
void set_wrap_login(bool wrap);
std::string login();
void set_login(const std::string& username);
// If password remembering is turned off use
// prv::password instead. This way we will not
// have to worry about whether to remember the
// password or not anywhere else in the code.
//
// It is put into a separate namespace to make clear
// it is "private" and not supposed to be edit outside
// of the preferences functions.
namespace prv {
extern std::string password;
}
/**
* Returns whether the password is stored wrapped in markers.
*
* New passwords are stored in a specific format to force string interpretation
* (due to bug #16571).
*/
bool wrap_password();
void set_wrap_password(bool wrap);
std::string password();
void set_password(const std::string& password);
bool remember_password();
void set_remember_password(bool remember);
bool turn_dialog();
void set_turn_dialog(bool ison);
bool enable_whiteboard_mode_on_start();
void set_enable_whiteboard_mode_on_start(bool value);
bool hide_whiteboard();
void set_hide_whiteboard(bool value);
bool show_combat();
bool allow_observers();
void set_allow_observers(bool value);
bool registered_users_only();
void set_registered_users_only(bool value);
bool shuffle_sides();
void set_shuffle_sides(bool value);
std::string random_faction_mode();
void set_random_faction_mode(const std::string & value);
bool use_map_settings();
void set_use_map_settings(bool value);
int mp_server_warning_disabled();
void set_mp_server_warning_disabled(int value);
void set_mp_server_program_name(const std::string&);
std::string get_mp_server_program_name();
bool random_start_time();
void set_random_start_time(bool value);
bool fog();
void set_fog(bool value);
bool shroud();
void set_shroud(bool value);
int turns();
void set_turns(int value);
const config& options();
void set_options(const config& values);
bool skip_mp_replay();
void set_skip_mp_replay(bool value);
bool blindfold_replay();
void set_blindfold_replay(bool value);
bool countdown();
void set_countdown(bool value);
int countdown_init_time();
void set_countdown_init_time(int value);
int countdown_turn_bonus();
void set_countdown_turn_bonus(int value);
int countdown_reservoir_time();
void set_countdown_reservoir_time(int value);
int countdown_action_bonus();
void set_countdown_action_bonus(int value);
int village_gold();
void set_village_gold(int value);
int village_support();
void set_village_support(int value);
int xp_modifier();
void set_xp_modifier(int value);
std::string era();
void set_era(const std::string& value);
std::string level();
void set_level(const std::string& value);
int level_type();
void set_level_type(int value);
const std::vector<std::string>& modifications(bool mp=true);
void set_modifications(const std::vector<std::string>& value, bool mp=true);
bool show_ai_moves();
void set_show_ai_moves(bool value);
void set_show_side_colors(bool value);
bool show_side_colors();
bool save_replays();
void set_save_replays(bool value);
bool delete_saves();
void set_delete_saves(bool value);
void set_ask_delete_saves(bool value);
bool ask_delete_saves();
void set_interrupt_when_ally_sighted(bool value);
bool interrupt_when_ally_sighted();
void set_autosavemax(int value);
int autosavemax();
const int INFINITE_AUTO_SAVES = 61;
bool show_floating_labels();
void set_show_floating_labels(bool value);
bool message_private();
void set_message_private(bool value);
bool show_haloes();
void set_show_haloes(bool value);
// Multiplayer functions
std::string get_chat_timestamp(const time_t& t);
bool chat_timestamping();
void set_chat_timestamping(bool value);
int chat_lines();
void set_chat_lines(int lines);
int chat_message_aging();
void set_chat_message_aging(const int aging);
bool show_all_units_in_help();
void set_show_all_units_in_help(bool value);
compression::format save_compression_format();
std::set<std::string> &encountered_units();
std::set<t_translation::t_terrain> &encountered_terrains();
std::string custom_command();
void set_custom_command(const std::string& command);
std::vector<std::string>* get_history(const std::string& id);
void set_theme(const std::string& theme);
std::string theme();
// Ask for end turn confirmation
bool yellow_confirm();
bool green_confirm();
bool confirm_no_moves();
// Add all recruitable units as encountered so that information
// about them are displayed to the user in the help system.
void encounter_recruitable_units(const std::vector<team>& teams);
// Add all units that exist at the start to the encountered units so
// that information about them are displayed to the user in the help
// system.
void encounter_start_units(const unit_map& units);
// Add all units that are recallable as encountered units.
void encounter_recallable_units(std::vector<team>& teams);
// Add all terrains on the map as encountered terrains.
void encounter_map_terrain(const gamemap& map);
// Calls all of the above functions on the current game board
void encounter_all_content(const game_board & gb);
class acquaintance {
public:
acquaintance()
{
}
explicit acquaintance(const config& cfg)
{
load_from_config(cfg);
}
acquaintance(
const std::string& nick
, const std::string& status
, const std::string& notes)
: nick_(nick)
, status_(status)
, notes_(notes)
{
}
void load_from_config(const config& cfg);
const std::string& get_nick() const { return nick_; }
const std::string& get_status() const { return status_; }
const std::string& get_notes() const { return notes_; }
void save(config& cfg);
private:
/** acquaintance's MP nick */
std::string nick_;
/**status (e.g., "friend", "ignore") */
std::string status_;
/** notes on the acquaintance */
std::string notes_;
};
}
#endif