The Battle for Wesnoth  1.17.0-dev
game.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2021
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 
78 bool parse_should_show_lobby_join(const std::string& sender, const std::string& message);
79 int lobby_joins();
80 void _set_lobby_joins(int show);
81 
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:51
void set_hide_whiteboard(bool value)
Definition: game.cpp:455
int autosavemax()
Definition: game.cpp:805
void set_campaign_server(const std::string &host)
Definition: game.cpp:425
void set_village_support(int value)
Definition: game.cpp:680
acquaintance(const config &cfg)
Definition: game.hpp:47
std::string random_faction_mode()
Definition: game.cpp:485
bool message_private()
Definition: game.cpp:847
static void encounter_recallable_units(const std::vector< team > &teams)
Definition: game.cpp:994
void set_countdown_action_bonus(int value)
Definition: game.cpp:660
void set_countdown_turn_bonus(int value)
Definition: game.cpp:650
std::string era()
Definition: game.cpp:695
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:554
void set_countdown_init_time(int value)
Definition: game.cpp:630
int xp_modifier()
Definition: game.cpp:685
std::string campaign_server()
Definition: game.cpp:416
void set_mp_server_warning_disabled(int value)
Definition: game.cpp:510
void set_show_floating_labels(bool value)
Definition: game.cpp:842
void set_options(const config &values)
Definition: game.cpp:589
int lobby_joins()
Definition: game.cpp:345
const std::map< std::string, acquaintance > & get_acquaintances()
Definition: game.cpp:201
bool is_campaign_completed(const std::string &campaign_id)
Definition: game.cpp:307
const int INFINITE_AUTO_SAVES
Definition: game.hpp:208
const std::string get_ignored_delim()
Definition: game.cpp:207
bool shuffle_sides()
Definition: game.cpp:475
void set_show_side_colors(bool value)
Definition: game.cpp:755
std::string network_host()
Definition: game.cpp:401
bool hide_whiteboard()
Definition: game.cpp:450
void _set_lobby_joins(int show)
Definition: game.cpp:359
void set_chat_lines(int lines)
Definition: game.cpp:905
int chat_lines()
Definition: game.cpp:900
std::string status_
status (e.g., "friend", "ignore")
Definition: game.hpp:72
void set_random_faction_mode(const std::string &value)
Definition: game.cpp:490
void set_network_host(const std::string &host)
Definition: game.cpp:411
bool show_side_colors()
Definition: game.cpp:760
void set_countdown(bool value)
Definition: game.cpp:620
bool remove_acquaintance(const std::string &nick)
Definition: game.cpp:255
void set_interrupt_when_ally_sighted(bool value)
Definition: game.cpp:795
int countdown_init_time()
Definition: game.cpp:625
bool yellow_confirm()
Definition: game.cpp:967
void set_mp_server_program_name(const std::string &path)
Definition: game.cpp:515
bool fog()
Definition: game.cpp:539
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:52
bool confirm_no_moves()
Definition: game.cpp:972
void set_chat_message_aging(const int aging)
Definition: game.cpp:910
const config & options()
Definition: game.cpp:569
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:72
void set_turn_dialog(bool ison)
Definition: game.cpp:435
int countdown_turn_bonus()
Definition: game.cpp:645
void set_level_type(int value)
Definition: game.cpp:720
void set_custom_command(const std::string &command)
Definition: game.cpp:945
const std::vector< game_config::server_info > & builtin_servers_list()
Definition: game.cpp:370
int village_support()
Definition: game.cpp:675
std::string level()
Definition: game.cpp:705
void set_save_replays(bool value)
Definition: game.cpp:765
bool is_friend(const std::string &nick)
Definition: game.cpp:278
base_manager base
Definition: game.hpp:37
void set_theme(const std::string &theme)
Definition: game.cpp:830
void encounter_map_terrain(const gamemap &map)
Definition: game.cpp:1003
void encounter_start_units(const unit_map &units)
Definition: game.cpp:987
const std::string & get_nick() const
Definition: game.hpp:61
std::string theme()
Definition: game.cpp:815
std::pair< preferences::acquaintance *, bool > add_acquaintance(const std::string &nick, const std::string &mode, const std::string &notes)
Definition: game.cpp:236
int countdown_reservoir_time()
Definition: game.cpp:635
void set_enable_whiteboard_mode_on_start(bool value)
Definition: game.cpp:445
bool blindfold_replay()
Definition: game.cpp:605
Encapsulates the map of the game.
Definition: map.hpp:171
void set_random_start_time(bool value)
Definition: game.cpp:534
std::set< t_translation::terrain_code > & encountered_terrains()
Definition: game.cpp:935
void set_user_servers_list(const std::vector< game_config::server_info > &value)
Definition: game.cpp:389
Modify, read and display user preferences.
bool show_combat()
Definition: game.cpp:460
int village_gold()
Definition: game.cpp:665
bool show_all_units_in_help()
Definition: game.cpp:920
void set_blindfold_replay(bool value)
Definition: game.cpp:610
bool chat_timestamping()
Definition: game.cpp:890
void set_message_private(bool value)
Definition: game.cpp:852
bool is_ignored(const std::string &nick)
Definition: game.cpp:290
void set_chat_timestamping(bool value)
Definition: game.cpp:895
void set_level(const std::string &value)
Definition: game.cpp:710
void set_allow_observers(bool value)
Definition: game.cpp:470
bool countdown()
Definition: game.cpp:615
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:956
bool shroud()
Definition: game.cpp:549
int mp_server_warning_disabled()
Definition: game.cpp:505
std::string get_mp_server_program_name()
Definition: game.cpp:524
bool interrupt_when_ally_sighted()
Definition: game.cpp:800
void load_game_prefs()
Definition: game.cpp:122
void set_delete_saves(bool value)
Definition: game.cpp:775
Definition: theme.hpp:41
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
Definition: game.cpp:302
void encounter_all_content(const game_board &gameboard_)
Definition: game.cpp:1014
bool use_map_settings()
Definition: game.cpp:495
bool delete_saves()
Definition: game.cpp:780
void set_skip_mp_replay(bool value)
Definition: game.cpp:600
std::set< std::string > & encountered_units()
Definition: game.cpp:930
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:222
bool ask_delete_saves()
Definition: game.cpp:790
bool skip_mp_replay()
Definition: game.cpp:595
const std::string & get_notes() const
Definition: game.hpp:63
static void save(LexState *ls, int c)
Definition: llex.cpp:57
void set_turns(int value)
Definition: game.cpp:564
std::string get_chat_timestamp(const std::time_t &t)
Definition: game.cpp:877
void set_autosavemax(int value)
Definition: game.cpp:810
compression::format save_compression_format()
Definition: game.cpp:857
void set_show_all_units_in_help(bool value)
Definition: game.cpp:925
bool allow_observers()
Definition: game.cpp:465
bool green_confirm()
Definition: game.cpp:961
int turns()
Definition: game.cpp:559
bool show_floating_labels()
Definition: game.cpp:837
const std::vector< std::string > & modifications(bool mp)
Definition: game.cpp:725
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:734
int chat_message_aging()
Definition: game.cpp:915
bool enable_whiteboard_mode_on_start()
Definition: game.cpp:440
int countdown_action_bonus()
Definition: game.cpp:655
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:318
void set_era(const std::string &value)
Definition: game.cpp:700
void set_shuffle_sides(bool value)
Definition: game.cpp:480
void set_fog(bool value)
Definition: game.cpp:544
void set_ask_delete_saves(bool value)
Definition: game.cpp:785
void encounter_recruitable_units(const std::vector< team > &teams)
Definition: game.cpp:979
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
void set_countdown_reservoir_time(int value)
Definition: game.cpp:640
bool random_start_time()
Definition: game.cpp:529
std::vector< game_config::server_info > user_servers_list()
Definition: game.cpp:376
void set_skip_ai_moves(bool value)
Definition: game.cpp:750
std::string custom_command()
Definition: game.cpp:940
void set_xp_modifier(int value)
Definition: game.cpp:690
bool turn_dialog()
Definition: game.cpp:430
void set_village_gold(int value)
Definition: game.cpp:670
void set_use_map_settings(bool value)
Definition: game.cpp:500
bool skip_ai_moves()
Definition: game.cpp:745
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:140
std::string nick_
acquaintance&#39;s MP nick
Definition: game.hpp:69
bool save_replays()
Definition: game.cpp:770
int level_type()
Definition: game.cpp:715