Settings overrides are written to a file under user://

This commit is contained in:
Rob Kelly 2024-12-08 21:51:04 -07:00
parent dff8065f95
commit f75af2196d
4 changed files with 7 additions and 3 deletions

1
.gitignore vendored
View File

@ -3,7 +3,6 @@
# Godot-specific ignores
.import/
override.cfg
export.cfg
export_presets.cfg

View File

@ -13,6 +13,7 @@ config_version=5
config/name="GFOLF 2"
config/description="GFOLF: Combat Golf Action"
run/main_scene="res://src/game/game.tscn"
config/project_settings_override="user://settings.godot"
config/features=PackedStringArray("4.3", "Forward Plus")
run/max_fps=60

View File

@ -1,6 +1,8 @@
class_name GameSettingsType extends Node
## Container for project settings, for quick runtime access.
var settings_file: String
var free_camera_speed: float
var x_sensitivity: float
var y_sensitivity: float
@ -16,6 +18,8 @@ func _init() -> void:
func _read_settings() -> void:
settings_file = ProjectSettings.get_setting("application/config/project_settings_override")
free_camera_speed = ProjectSettings.get_setting("game/config/controls/camera/free_camera_speed")
x_sensitivity = ProjectSettings.get_setting("game/config/controls/camera/x_axis_sensitivity")
y_sensitivity = ProjectSettings.get_setting("game/config/controls/camera/y_axis_sensitivity")

View File

@ -2,7 +2,6 @@ extends MarginContainer
## Menu allowing the user to adjust game configuration.
const SETTINGS_GROUP := "Settings"
const SETTINGS_FILE := "override.cfg"
@onready var control_binding_list: VBoxContainer = %ControlBindingList
@ -36,7 +35,8 @@ func apply() -> void:
## Write all applied settings to disk.
func save_settings() -> void:
ProjectSettings.save_custom(SETTINGS_FILE)
print_debug("Writing settings to ", Game.settings.settings_file)
ProjectSettings.save_custom(Game.settings.settings_file)
BindingLoader.write()