From f75af2196de693b4a5cd4cbcb61257663459f508 Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Sun, 8 Dec 2024 21:51:04 -0700 Subject: [PATCH] Settings overrides are written to a file under user:// --- .gitignore | 1 - project.godot | 1 + src/game/game_settings.gd | 4 ++++ src/ui/menus/settings_menu/settings_menu.gd | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2448cca..2568c6c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ # Godot-specific ignores .import/ -override.cfg export.cfg export_presets.cfg diff --git a/project.godot b/project.godot index c8bc3c3..5fb6396 100644 --- a/project.godot +++ b/project.godot @@ -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 diff --git a/src/game/game_settings.gd b/src/game/game_settings.gd index e64c1be..2f5a7d1 100644 --- a/src/game/game_settings.gd +++ b/src/game/game_settings.gd @@ -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") diff --git a/src/ui/menus/settings_menu/settings_menu.gd b/src/ui/menus/settings_menu/settings_menu.gd index e3d68aa..de10c60 100644 --- a/src/ui/menus/settings_menu/settings_menu.gd +++ b/src/ui/menus/settings_menu/settings_menu.gd @@ -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()