make config save if some properties are not found

This commit is contained in:
Teatov 2025-02-27 22:18:05 +10:00
parent fc5ab58571
commit a4d6a3eb81
2 changed files with 5 additions and 8 deletions

View File

@ -15,11 +15,6 @@ tonemap_white = 16.0
process_priority = -1
process_physics_priority = -1
[node name="Player2" parent="." instance=ExtResource("2_f4ehn")]
process_priority = -1
process_physics_priority = -1
_input_mode = 1
[node name="Geometry" type="Node" parent="."]
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="Geometry"]

View File

@ -5,9 +5,6 @@ const CONFIG_PATH := "user://settings.cfg"
@export_group("Gameplay")
@export_subgroup("Camera")
@export var camera_fov: float = 75:
set(value):
camera_fov = value
@export_group("Video")
@export_subgroup("Display")
@ -129,6 +126,7 @@ func load_config() -> void:
return
var section: String = ""
var some_not_found := false
for property in get_property_list():
if _property_is_section(property):
section = property["name"] as String
@ -139,11 +137,15 @@ func load_config() -> void:
if not config.has_section_key(section, property_name):
print("%s not found in config, setting default" % property_name)
set(property_name, _default_values[property_name])
some_not_found = true
continue
var value: Variant = config.get_value(section, property_name)
set(property_name, value)
if some_not_found:
save_config()
func _property_is_setting(property: Dictionary) -> bool:
return (property["usage"] as int & SETTING_USAGE_FLAG) == SETTING_USAGE_FLAG