Replace settings.dat with a toml file#4619
Merged
Loobinex merged 2 commits intodkfans:masterfrom Mar 19, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces the binary settings.dat persistence with a human-editable settings.toml, with the goal of making future settings changes easier without strict binary compatibility concerns.
Changes:
- Switch settings load/save from
settings.dat(binary struct) tosettings.toml(TOML viavalue_util/toml_parse). - Add TOML serialization/deserialization for video/audio/display/gameplay settings plus keybinds.
- Introduce keycode/modifier string mappings to represent keybinds in TOML.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+372
to
+376
| char *fname = prepare_file_path(FGrp_Save, "settings.toml"); | ||
| VALUE root; | ||
| if (!load_toml_file(fname, &root, CnfLd_IgnoreErrors)) | ||
| { | ||
| if (LbFileLoadAt(fname, &settings) == sizeof(struct GameSettings)) | ||
| { | ||
| // sanity checks | ||
| settings.video_shadows = clamp(settings.video_shadows, 0, 3); | ||
| settings.view_distance = clamp(settings.view_distance, 0, 3); | ||
| settings.video_rotate_mode = clamp(settings.video_rotate_mode, 0, 2); | ||
| settings.video_textures = clamp(settings.video_textures, 0, 1); | ||
| settings.video_cluedo_mode = clamp(settings.video_cluedo_mode, 0, 1); | ||
| settings.sound_volume = clamp(settings.sound_volume, 0, FULL_LOUDNESS); | ||
| settings.music_volume = clamp(settings.music_volume, 0, FULL_LOUDNESS); | ||
| settings.mentor_volume = clamp(settings.mentor_volume, 0, FULL_LOUDNESS); | ||
| settings.gamma_correction = clamp(settings.gamma_correction, 0, GAMMA_LEVELS_COUNT); | ||
| settings.switching_vidmodes_index = clamp(settings.switching_vidmodes_index, 0, MAX_GAME_VIDMODE_COUNT); | ||
| settings.first_person_move_sensitivity = clamp(settings.first_person_move_sensitivity, 0, 1000); | ||
| settings.minimap_zoom = clamp(settings.minimap_zoom, 256, 2048); | ||
| settings.isometric_view_zoom_level = clamp(settings.isometric_view_zoom_level, CAMERA_ZOOM_MIN, CAMERA_ZOOM_MAX); | ||
| settings.frontview_zoom_level = clamp(settings.frontview_zoom_level, FRONTVIEW_CAMERA_ZOOM_MIN, FRONTVIEW_CAMERA_ZOOM_MAX); | ||
| settings.isometric_tilt = clamp(settings.isometric_tilt, CAMERA_TILT_MIN, CAMERA_TILT_MAX); | ||
| settings.highlight_mode = clamp(settings.highlight_mode, false, true); | ||
| return true; | ||
| } | ||
| save_settings(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
needed to not need to worry about backwards compatibility when updating what's stored in settings