79 nick_ = cfg[
"nick"].str();
81 notes_ = cfg[
"notes"].str();
84 acquaintance(
const std::string& nick,
const std::string& status,
const std::string& notes)
117 : vector<unsigned char>(std::forward<T>(args)...)
145 ,
name(pref[
"name"].t_str())
147 ,
field(pref[
"field"].str())
150 const std::string p_type =
cfg[
"type"];
152 if(p_type ==
"boolean") {
154 }
else if(p_type ==
"int") {
156 }
else if(p_type ==
"combo") {
158 }
else if(p_type ==
"custom") {
161 throw std::invalid_argument(
"Unknown type '" + p_type +
"' for advanced preference " +
name);
184 #define PREF_GETTER_SETTER(pref, type, def) \
185 void set_##pref(const type& value) { \
186 preferences_[prefs_list::pref] = value; \
188 type pref() const { \
189 return preferences_[prefs_list::pref].to(def); \
201 static prefs prefs_manager;
202 return prefs_manager;
248 std::vector<std::string>*
get_history(
const std::string&
id);
298 void add_alias(
const std::string& alias,
const std::string& command);
352 std::pair<preferences::acquaintance*, bool>
add_acquaintance(
const std::string& nick,
const std::string& mode,
const std::string& notes);
404 std::string
password(
const std::string& server,
const std::string&
login);
405 void set_password(
const std::string& server,
const std::string&
login,
const std::string& key);
441 bool achievement(
const std::string& content_for,
const std::string&
id);
448 void set_achievement(
const std::string& content_for,
const std::string&
id);
464 int progress_achievement(
const std::string& content_for,
const std::string&
id,
int limit = 999999,
int max_progress = 999999,
int amount = 0);
472 bool sub_achievement(
const std::string& content_for,
const std::string&
id,
const std::string& sub_id);
483 void set_sub_achievement(
const std::string& content_for,
const std::string&
id,
const std::string& sub_id);
593 #undef PREF_GETTER_SETTER
631 std::string
get(
const std::string& key,
const std::string& def);
670 prefs_list::player_joins_sound,
671 prefs_list::player_joins_notif,
672 prefs_list::player_joins_lobby,
673 prefs_list::player_leaves_sound,
674 prefs_list::player_leaves_notif,
675 prefs_list::player_leaves_lobby,
676 prefs_list::private_message_sound,
677 prefs_list::private_message_notif,
678 prefs_list::private_message_lobby,
679 prefs_list::friend_message_sound,
680 prefs_list::friend_message_notif,
681 prefs_list::friend_message_lobby,
682 prefs_list::public_message_sound,
683 prefs_list::public_message_notif,
684 prefs_list::public_message_lobby,
685 prefs_list::server_message_sound,
686 prefs_list::server_message_notif,
687 prefs_list::server_message_lobby,
688 prefs_list::ready_for_start_sound,
689 prefs_list::ready_for_start_notif,
690 prefs_list::ready_for_start_lobby,
691 prefs_list::game_has_begun_sound,
692 prefs_list::game_has_begun_notif,
693 prefs_list::game_has_begun_lobby,
694 prefs_list::turn_changed_sound,
695 prefs_list::turn_changed_notif,
696 prefs_list::turn_changed_lobby,
697 prefs_list::game_created_sound,
698 prefs_list::game_created_notif,
699 prefs_list::game_created_lobby,
700 prefs_list::_last_cache_cleaned_ver,
701 prefs_list::addon_manager_saved_order_direction,
702 prefs_list::addon_manager_saved_order_name,
704 prefs_list::allow_observers,
706 prefs_list::ally_sighted_interrupts,
707 prefs_list::auto_save_max,
708 prefs_list::blindfold_replay,
709 prefs_list::campaign_server,
710 prefs_list::chat_lines,
711 prefs_list::chat_timestamp,
712 prefs_list::confirm_end_turn,
713 prefs_list::custom_command,
714 prefs_list::delete_saves,
715 prefs_list::disable_auto_moves,
716 prefs_list::editor_auto_update_transitions,
717 prefs_list::editor_draw_hex_coordinates,
718 prefs_list::editor_draw_num_of_bitmaps,
719 prefs_list::editor_draw_terrain_codes,
720 prefs_list::enable_planning_mode_on_start,
721 prefs_list::encountered_terrain_list,
722 prefs_list::encountered_units,
724 prefs_list::fi_blocked_in_game,
725 prefs_list::fi_friends_in_game,
726 prefs_list::fi_invert,
727 prefs_list::fi_vacant_slots,
728 prefs_list::floating_labels,
730 prefs_list::hide_whiteboard,
732 prefs_list::idle_anim,
733 prefs_list::idle_anim_rate,
735 prefs_list::lobby_whisper_friends_only,
738 prefs_list::message_bell,
739 prefs_list::minimap_draw_terrain,
740 prefs_list::minimap_draw_units,
741 prefs_list::minimap_draw_villages,
742 prefs_list::minimap_movement_coding,
743 prefs_list::minimap_terrain_coding,
745 prefs_list::mp_countdown,
746 prefs_list::mp_countdown_action_bonus,
747 prefs_list::mp_countdown_init_time,
748 prefs_list::mp_countdown_reservoir_time,
749 prefs_list::mp_countdown_turn_bonus,
751 prefs_list::mp_level_type,
752 prefs_list::mp_random_start_time,
753 prefs_list::mp_server_warning_disabled,
754 prefs_list::mp_shroud,
755 prefs_list::mp_turns,
756 prefs_list::mp_use_map_settings,
757 prefs_list::mp_village_gold,
758 prefs_list::mp_village_support,
759 prefs_list::mp_xp_modifier,
763 prefs_list::remember_password,
764 prefs_list::save_replays,
766 prefs_list::scroll_threshold,
772 prefs_list::show_side_colors,
775 prefs_list::shuffle_sides,
776 prefs_list::skip_ai_moves,
777 prefs_list::skip_mp_replay,
779 prefs_list::sample_rate,
780 prefs_list::stop_music_in_background,
782 prefs_list::turbo_speed,
784 prefs_list::turn_dialog,
785 prefs_list::ui_sound,
786 prefs_list::unit_standing_animations,
788 prefs_list::ask_delete,
789 prefs_list::chat_message_aging,
790 prefs_list::color_cursors,
791 prefs_list::compress_saves,
792 prefs_list::confirm_load_save_from_different_version,
793 prefs_list::damage_prediction_allow_monte_carlo_simulation,
794 prefs_list::editor_max_recent_files,
795 prefs_list::keepalive_timeout,
796 prefs_list::lobby_auto_open_whisper_windows,
797 prefs_list::middle_click_scrolls,
798 prefs_list::mouse_scrolling,
799 prefs_list::scroll_to_action,
800 prefs_list::scroll_when_mouse_outside,
801 prefs_list::show_all_units_in_help,
802 prefs_list::show_combat,
803 prefs_list::show_deprecation,
804 prefs_list::use_twelve_hour_clock_format,
806 prefs_list::mp_level,
807 prefs_list::mp_modifications,
808 prefs_list::selected_achievement_group,
809 prefs_list::sp_modifications,
810 prefs_list::animate_map,
811 prefs_list::animate_water,
814 prefs_list::achievements,
815 prefs_list::completed_campaigns,
820 prefs_list::auto_pixel_scale,
822 prefs_list::draw_delay,
823 prefs_list::editor_chosen_addon,
824 prefs_list::gui2_theme,
825 prefs_list::mp_server_program_name,
826 prefs_list::pixel_scale,
827 prefs_list::sound_buffer_size,
831 prefs_list::xresolution,
832 prefs_list::yresolution,
833 prefs_list::font_scale,
838 prefs_list::fullscreen,
839 prefs_list::maximized,
842 prefs_list::editor_recent_files,
843 prefs_list::dir_bookmarks,
856 static void set(
const std::string& pref,
bool value)
860 static void set(
const std::string& pref,
int value)
864 static void set(
const std::string& pref,
const std::string& value)
869 static bool get(
const std::string& pref,
bool def)
873 static int get(
const std::string& pref,
int def)
877 static std::string
get(
const std::string& pref,
const std::string& def)
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
A class grating read only view to a vector of config objects, viewed as one config with all children ...
Encapsulates the map of the game.
std::string nick_
acquaintance's MP nick
acquaintance(const std::string &nick, const std::string &status, const std::string ¬es)
std::string notes_
notes on the acquaintance
const std::string & get_status() const
const std::string & get_nick() const
std::string status_
status (e.g., "friend", "ignore")
const std::string & get_notes() const
acquaintance(const config &cfg)
secure_buffer(T &&... args)
void set_lobby_joins(pref_constants::lobby_joins show)
std::string enemy_color()
config::attribute_value get_as_attribute(const std::string &key)
void set_network_host(const std::string &host)
std::set< t_translation::terrain_code > & encountered_terrains()
bool set_music(bool ison)
void set_sound_volume(int vol)
void set_remember_password(bool remember)
const std::map< std::string, preferences::acquaintance > & get_acquaintances()
optional_const_config get_alias()
void set_turbo(bool ison)
std::string get_system_username()
prefs(const prefs &&p)=delete
bool mp_modifications_initialized_
std::map< std::string, std::vector< std::string > > history_map_
void set_addon_manager_saved_order_direction(sort_order::type value)
bool middle_click_scrolls()
int countdown_init_time()
std::set< std::string > & encountered_units()
void add_alias(const std::string &alias, const std::string &command)
void set_countdown_reservoir_time(int value)
std::vector< std::string > sp_modifications_
void clear_mp_alert_prefs()
The most recently selected add-on id from the editor.
void set_village_gold(int value)
bool confirm_load_save_from_different_version()
std::string network_host()
void clear_countdown_init_time()
std::set< std::string > unknown_unsynced_attributes_
bool set_ui_sound(bool ison)
void set_login(const std::string &login)
const std::string get_ignored_delim()
std::map< std::string, preferences::acquaintance > acquaintances_
friend int impl_preferences_set(lua_State *L)
The __newindex metamethod.
static constexpr std::array unsynced_children_
void set_countdown_action_bonus(int value)
void encounter_recallable_units(const std::vector< team > &teams)
std::map< std::string, std::set< std::string > > completed_campaigns_
optional_const_config dir_bookmarks()
void set_theme(const std::string &theme)
void set_xp_modifier(int value)
void set_user_servers_list(const std::vector< game_config::server_info > &value)
preferences::secure_buffer build_key(const std::string &server, const std::string &login)
Fills a secure_buffer with 32 bytes of deterministically generated bytes, then overwrites it with the...
std::vector< preferences::option > & get_advanced_preferences()
int countdown_action_bonus()
bool is_campaign_completed(const std::string &campaign_id)
void set_allied_color(const std::string &color_id)
bool get_scroll_when_mouse_outside(bool def)
void show_wesnothd_server_search()
int mouse_scroll_threshold()
Gets the threshold for when to scroll.
bool is_ignored(const std::string &nick)
std::vector< std::string > mp_modifications_
bool achievement(const std::string &content_for, const std::string &id)
std::set< std::string > unknown_synced_attributes_
void set_enemy_color(const std::string &color_id)
void set_password(const std::string &server, const std::string &login, const std::string &key)
bool sub_achievement(const std::string &content_for, const std::string &id, const std::string &sub_id)
std::vector< preferences::login_info > credentials_
std::vector< std::string > do_read_editor_mru()
void encounter_recruitable_units(const std::vector< team > &teams)
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
static bool preferences_save()
int progress_achievement(const std::string &content_for, const std::string &id, int limit=999999, int max_progress=999999, int amount=0)
Increments the achievement's current progress by amount if it hasn't already been completed.
sort_order::type addon_manager_saved_order_direction()
bool set_turn_bell(bool ison)
static constexpr std::array synced_attributes_
unsigned int sample_rate()
static constexpr std::array synced_children_
void set_options(const config &values)
void set_message_private(bool value)
std::vector< game_config::server_info > user_servers_list()
optional_const_config get_child(const std::string &key)
std::string unmoved_color()
void set_music_volume(int vol)
void load_advanced_prefs(const game_config_view &gc)
std::string allied_color()
void set_show_standing_animations(bool value)
void set_show_fps(bool value)
void set_pixel_scale(const int scale)
std::size_t editor_mru_limit()
void set_color_cursors(bool value)
std::vector< preferences::option > advanced_prefs_
void encounter_start_units(const unit_map &units)
void set_countdown_turn_bonus(int value)
pref_constants::lobby_joins get_lobby_joins()
void encounter_map_terrain(const gamemap &map)
void set_village_support(int value)
preferences::secure_buffer escape(const preferences::secure_buffer &text)
prefs & operator=(const prefs &&p)=delete
std::string moved_color()
void set_font_scaling(int scale)
std::size_t sound_buffer_size()
void migrate_preferences(const std::string &prefs_dir)
void set_dir_bookmarks(const config &cfg)
std::set< t_translation::terrain_code > encountered_terrains_set_
friend int impl_preferences_get(lua_State *L)
The __index metamethod.
bool set_sound(bool ison)
bool is_friend(const std::string &nick)
void set_achievement(const std::string &content_for, const std::string &id)
Marks the specified achievement as completed.
preferences::secure_buffer aes_decrypt(const preferences::secure_buffer &text, const preferences::secure_buffer &key)
Same as aes_encrypt(), except of course it takes encrypted data as an argument and returns decrypted ...
void clear_countdown_turn_bonus()
int font_scaled(int size)
void set_scroll_speed(const int scroll)
std::pair< preferences::acquaintance *, bool > add_acquaintance(const std::string &nick, const std::string &mode, const std::string ¬es)
prefs(const prefs &p)=delete
bool options_initialized_
std::string partial_color()
preferences::secure_buffer unescape(const preferences::secure_buffer &text)
void set_resolution(const point &res)
static void disable_preferences_save()
void set_campaign_server(const std::string &host)
void set_countdown_init_time(int value)
void set_unmoved_color(const std::string &color_id)
bool remove_acquaintance(const std::string &nick)
void clear_countdown_reservoir_time()
void set_ui_volume(int vol)
const std::vector< std::string > & modifications(bool mp=true)
void do_commit_editor_mru(const std::vector< std::string > &mru)
compression::format save_compression_format()
std::vector< std::string > recent_files()
Retrieves the list of recently opened files.
std::set< std::string > encountered_units_set_
void set_bell_volume(int vol)
std::string get_mp_server_program_name()
prefs & operator=(const prefs &p)=delete
void set_partial_color(const std::string &color_id)
void set_child(const std::string &key, const config &val)
static constexpr std::array unsynced_attributes_
std::set< std::string > all_attributes()
void set_mp_server_program_name(const std::string &)
void add_recent_files_entry(const std::string &path)
Adds an entry to the recent files list.
void set_moved_color(const std::string &color_id)
std::string get_chat_timestamp(const std::time_t &t)
void save_sample_rate(const unsigned int rate)
bool use_twelve_hour_clock_format()
static bool no_preferences_save
void set_modifications(const std::vector< std::string > &value, bool mp=true)
void set_sub_achievement(const std::string &content_for, const std::string &id, const std::string &sub_id)
Marks the specified sub-achievement as completed.
int countdown_reservoir_time()
std::set< std::string > unknown_unsynced_children_
const std::vector< game_config::server_info > & builtin_servers_list()
void reload_preferences()
std::string campaign_server()
std::set< std::string > unknown_synced_children_
int countdown_turn_bonus()
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
void save_sound_buffer_size(const std::size_t size)
void encounter_all_content(const game_board &gb)
std::string password(const std::string &server, const std::string &login)
bool sp_modifications_initialized_
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...
preferences::secure_buffer aes_encrypt(const preferences::secure_buffer &text, const preferences::secure_buffer &key)
Encrypts the value of text using key and a hard coded IV using AES.
bool auto_open_whisper_windows()
std::map< std::string, std::string > get_acquaintances_nice(const std::string &filter)
bool get_show_deprecation(bool def)
bool show_standing_animations()
void clear_countdown_action_bonus()
Container associating units to locations.
Definitions for the interface to Wesnoth Markup Language (WML).
Declarations for File-IO.
Standard logging facilities (interface).
void fill(const SDL_Rect &rect, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Fill an area with the given colour.
std::string partial_orb_color
std::string moved_orb_color
std::string unmoved_orb_color
std::string ally_orb_color
std::string enemy_orb_color
bool show_status_on_ally_orb
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
static int music_volume()
static int sound_volume()
std::pair< std::string, unsigned > item
Main entry points of multiplayer mode.
const int min_window_height
const int TRANSITION_UPDATE_ON
const int max_pixel_scale
const std::string EMPTY_LOGIN
const int min_pixel_scale
const std::string default_addons_server
const int def_window_width
const int min_font_scaling
const int TRANSITION_UPDATE_COUNT
const int min_window_width
const int TRANSITION_UPDATE_OFF
const int max_font_scaling
const int max_window_height
const int max_window_width
const int def_window_height
const int INFINITE_AUTO_SAVES
const unsigned char CREDENTIAL_SEPARATOR
const int TRANSITION_UPDATE_PARTIAL
Modify, read and display user preferences.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
void scale(size_t factor, const uint32_t *src, uint32_t *trg, int srcWidth, int srcHeight, ColorFormat colFmt, const ScalerCfg &cfg=ScalerCfg(), int yFirst=0, int yLast=std::numeric_limits< int >::max())
#define PREF_GETTER_SETTER(pref, type, def)
string_enums::enum_base< random_faction_mode_defines > random_faction_mode
login_info(const std::string &username, const std::string &server, const secure_buffer &key)
login_info(const std::string &username, const std::string &server)
t_string description
Displayed description.
avd_type type
The preference type.
option(const config &pref)
t_string name
Displayed name.
std::string field
The actual field saved in the prefs file and by which this preference may be accessed.
config cfg
The full config, including type-specific options.
static void set(const std::string &pref, int value)
friend class preferences_dialog
static void set(const std::string &pref, const std::string &value)
static int get(const std::string &pref, int def)
static std::string get(const std::string &pref, const std::string &def)
static bool get(const std::string &pref, bool def)
static void set(const std::string &pref, bool value)
The base template for associating string values with enum values.