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);
407 std::string
password(
const std::string& server,
const std::string&
login);
408 void set_password(
const std::string& server,
const std::string&
login,
const std::string& key);
444 bool achievement(
const std::string& content_for,
const std::string&
id);
451 void set_achievement(
const std::string& content_for,
const std::string&
id);
467 int progress_achievement(
const std::string& content_for,
const std::string&
id,
int limit = 999999,
int max_progress = 999999,
int amount = 0);
475 bool sub_achievement(
const std::string& content_for,
const std::string&
id,
const std::string& sub_id);
486 void set_sub_achievement(
const std::string& content_for,
const std::string&
id,
const std::string& sub_id);
596 #undef PREF_GETTER_SETTER
634 std::string
get(
const std::string& key,
const std::string& def);
673 prefs_list::player_joins_sound,
674 prefs_list::player_joins_notif,
675 prefs_list::player_joins_lobby,
676 prefs_list::player_leaves_sound,
677 prefs_list::player_leaves_notif,
678 prefs_list::player_leaves_lobby,
679 prefs_list::private_message_sound,
680 prefs_list::private_message_notif,
681 prefs_list::private_message_lobby,
682 prefs_list::friend_message_sound,
683 prefs_list::friend_message_notif,
684 prefs_list::friend_message_lobby,
685 prefs_list::public_message_sound,
686 prefs_list::public_message_notif,
687 prefs_list::public_message_lobby,
688 prefs_list::server_message_sound,
689 prefs_list::server_message_notif,
690 prefs_list::server_message_lobby,
691 prefs_list::ready_for_start_sound,
692 prefs_list::ready_for_start_notif,
693 prefs_list::ready_for_start_lobby,
694 prefs_list::game_has_begun_sound,
695 prefs_list::game_has_begun_notif,
696 prefs_list::game_has_begun_lobby,
697 prefs_list::turn_changed_sound,
698 prefs_list::turn_changed_notif,
699 prefs_list::turn_changed_lobby,
700 prefs_list::game_created_sound,
701 prefs_list::game_created_notif,
702 prefs_list::game_created_lobby,
703 prefs_list::_last_cache_cleaned_ver,
704 prefs_list::addon_manager_saved_order_direction,
705 prefs_list::addon_manager_saved_order_name,
707 prefs_list::allow_observers,
709 prefs_list::ally_sighted_interrupts,
710 prefs_list::auto_save_max,
711 prefs_list::blindfold_replay,
712 prefs_list::campaign_server,
713 prefs_list::chat_lines,
714 prefs_list::chat_timestamp,
715 prefs_list::confirm_end_turn,
716 prefs_list::custom_command,
717 prefs_list::delete_saves,
718 prefs_list::disable_auto_moves,
719 prefs_list::editor_auto_update_transitions,
720 prefs_list::editor_draw_hex_coordinates,
721 prefs_list::editor_draw_num_of_bitmaps,
722 prefs_list::editor_draw_terrain_codes,
723 prefs_list::enable_planning_mode_on_start,
724 prefs_list::encountered_terrain_list,
725 prefs_list::encountered_units,
727 prefs_list::fi_blocked_in_game,
728 prefs_list::fi_friends_in_game,
729 prefs_list::fi_invert,
730 prefs_list::fi_vacant_slots,
731 prefs_list::floating_labels,
733 prefs_list::hide_whiteboard,
735 prefs_list::idle_anim,
736 prefs_list::idle_anim_rate,
738 prefs_list::lobby_whisper_friends_only,
741 prefs_list::message_bell,
742 prefs_list::minimap_draw_terrain,
743 prefs_list::minimap_draw_units,
744 prefs_list::minimap_draw_villages,
745 prefs_list::minimap_movement_coding,
746 prefs_list::minimap_terrain_coding,
748 prefs_list::mp_countdown,
749 prefs_list::mp_countdown_action_bonus,
750 prefs_list::mp_countdown_init_time,
751 prefs_list::mp_countdown_reservoir_time,
752 prefs_list::mp_countdown_turn_bonus,
754 prefs_list::mp_level_type,
755 prefs_list::mp_random_start_time,
756 prefs_list::mp_server_warning_disabled,
757 prefs_list::mp_shroud,
758 prefs_list::mp_turns,
759 prefs_list::mp_use_map_settings,
760 prefs_list::mp_village_gold,
761 prefs_list::mp_village_support,
762 prefs_list::mp_xp_modifier,
766 prefs_list::remember_password,
767 prefs_list::save_replays,
769 prefs_list::scroll_threshold,
775 prefs_list::show_side_colors,
778 prefs_list::shuffle_sides,
779 prefs_list::skip_ai_moves,
780 prefs_list::skip_mp_replay,
782 prefs_list::sample_rate,
783 prefs_list::stop_music_in_background,
785 prefs_list::turbo_speed,
787 prefs_list::turn_dialog,
788 prefs_list::ui_sound,
789 prefs_list::unit_standing_animations,
791 prefs_list::ask_delete,
792 prefs_list::chat_message_aging,
793 prefs_list::color_cursors,
794 prefs_list::compress_saves,
795 prefs_list::confirm_load_save_from_different_version,
796 prefs_list::damage_prediction_allow_monte_carlo_simulation,
797 prefs_list::editor_max_recent_files,
798 prefs_list::keepalive_timeout,
799 prefs_list::lobby_auto_open_whisper_windows,
800 prefs_list::middle_click_scrolls,
801 prefs_list::mouse_scrolling,
802 prefs_list::scroll_to_action,
803 prefs_list::scroll_when_mouse_outside,
804 prefs_list::show_all_units_in_help,
805 prefs_list::show_combat,
806 prefs_list::show_deprecation,
807 prefs_list::use_twelve_hour_clock_format,
809 prefs_list::mp_level,
810 prefs_list::mp_modifications,
811 prefs_list::selected_achievement_group,
812 prefs_list::sp_modifications,
813 prefs_list::animate_map,
814 prefs_list::animate_water,
815 prefs_list::addon_icons,
818 prefs_list::acquaintance,
819 prefs_list::achievements,
820 prefs_list::completed_campaigns,
826 prefs_list::auto_pixel_scale,
828 prefs_list::refresh_rate,
829 prefs_list::editor_chosen_addon,
830 prefs_list::gui2_theme,
831 prefs_list::mp_server_program_name,
832 prefs_list::pixel_scale,
833 prefs_list::sound_buffer_size,
837 prefs_list::xresolution,
838 prefs_list::yresolution,
839 prefs_list::font_scale,
844 prefs_list::fullscreen,
845 prefs_list::maximized,
848 prefs_list::editor_recent_files,
849 prefs_list::dir_bookmarks,
862 static void set(
const std::string& pref,
bool value)
866 static void set(
const std::string& pref,
int value)
870 static void set(
const std::string& pref,
const std::string& value)
875 static bool get(
const std::string& pref,
bool def)
879 static int get(
const std::string& pref,
int def)
883 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)
std::chrono::seconds countdown_turn_bonus()
bool middle_click_scrolls()
void set_countdown_reservoir_time(const std::chrono::seconds &value)
std::set< std::string > & encountered_units()
void add_alias(const std::string &alias, const std::string &command)
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)
std::chrono::minutes chat_message_aging()
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 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...
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.
std::string get_chat_timestamp(const std::chrono::system_clock::time_point &t)
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)
std::chrono::seconds countdown_init_time()
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()
void set_countdown_turn_bonus(const std::chrono::seconds &value)
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)
pref_constants::lobby_joins get_lobby_joins()
void set_chat_message_aging(const std::chrono::minutes &value)
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::chrono::seconds countdown_action_bonus()
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_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)
std::chrono::seconds countdown_reservoir_time()
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()
const std::vector< preferences::option > & get_advanced_preferences()
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)
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_countdown_init_time(const std::chrono::seconds &value)
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.
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_
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.
void set_countdown_action_bonus(const std::chrono::seconds &value)
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
Game configuration data as global variables.
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()
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(std::string_view 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.