wesnoth/source_lists/libwesnoth
Pentarctagon 971073055e
Refactor the preferences into a proper singleton. (#8930)
The current preferences handling is a mess:
* it's essentially a global config object that anything can modify in any way the caller wants, which is managed across multiple source files which have their own oddities and interdependencies.
* the general preferences has its own bit of SDL event handling and while I get the idea behind `events::sdl_handler` there's no reason to have SDL events handled in the preferences instead of just calling the relevant preferences setter for each event when it happens.
* the general preferences is where most of the preferences are handled and has its `base_manager` struct, which is part of the `manager` struct in the game preferences, which is then implicitly initialized as part of game_launcher's constructor.
* the editor preferences are the only preferences in a sub-namespace `preferences::editor` while all other preferences are just in the `preferences` namespace.
* the display, editor, and lobby preferences are all dependent on including the game preferences, the credentials are dependent on including the general preferences (but not the game preferences), the game preferences are dependent on including the general preferences, and the advanced preferences are entirely their own thing which is dependent on none of the other preference functionality and manages its own singleton.
* nothing checks whether the preferences file has actually been loaded before allowing values to be read from or written to the preferences config - if you attempt to get a value too early in wesnoth's initialization it will silently just give you whatever the default value for that preference happens to be.

With this there is instead a single access point (with exceptions handled via friend functions/classes), all predefined preferences are accessed via their own setter/getter, and all mainline preferences are defined in a single file (preference_list.hpp) so it's easily findable what preferences exist and where they're used. Having the list of all mainline preferences listed out also allows the lua preferences API to provide that full list rather than just the list of the preferences that have been set so far. Also it now checks for whether the location of the preferences file is known before attempting to load the preferences file and asserts if someone attempts to use the preferences too early.
2024-06-09 11:34:09 -05:00

64 lines
1.2 KiB
Plaintext

arrow.cpp
color.cpp
color_range.cpp
cursor.cpp
desktop/clipboard.cpp
deprecation.cpp
display.cpp
display_context.cpp
events.cpp
floating_label.cpp
font/font_config.cpp
font/sdl_ttf_compat.cpp
font/standard_colors.cpp
font/text.cpp
font/text_formatting.cpp
format_time_summary.cpp
formula/string_utils.cpp
game_config.cpp
game_end_exceptions.cpp
generators/cave_map_generator.cpp
generators/default_map_generator.cpp
generators/default_map_generator_job.cpp
generators/lua_map_generator.cpp
generators/map_create.cpp
generators/map_generator.cpp
generic_event.cpp
hotkey/command_executor.cpp
hotkey/hotkey_command.cpp
hotkey/hotkey_item.cpp
hotkey/hotkey_manager.cpp
picture.cpp
image_modifications.cpp
preferences/preferences.cpp
key.cpp
language.cpp
map/label.cpp
map/location.cpp
map/map.cpp
minimap.cpp
pathfind/astarsearch.cpp
pathutils.cpp
quit_confirmation.cpp
reports.cpp
show_dialog.cpp
sound.cpp
sound_music_track.cpp
soundsource.cpp
terrain/builder.cpp
terrain/terrain.cpp
terrain/translation.cpp
terrain/type_data.cpp
theme.cpp
time_of_day.cpp
tooltips.cpp
video.cpp
widgets/button.cpp
widgets/menu.cpp
widgets/menu_style.cpp
widgets/scrollarea.cpp
widgets/scrollbar.cpp
widgets/textbox.cpp
widgets/widget.cpp
wml_exception.cpp