make config save if some properties are not found
This commit is contained in:
parent
fc5ab58571
commit
a4d6a3eb81
@ -15,11 +15,6 @@ tonemap_white = 16.0
|
|||||||
process_priority = -1
|
process_priority = -1
|
||||||
process_physics_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="Geometry" type="Node" parent="."]
|
||||||
|
|
||||||
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="Geometry"]
|
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="Geometry"]
|
||||||
|
|||||||
@ -5,9 +5,6 @@ const CONFIG_PATH := "user://settings.cfg"
|
|||||||
|
|
||||||
@export_group("Gameplay")
|
@export_group("Gameplay")
|
||||||
@export_subgroup("Camera")
|
@export_subgroup("Camera")
|
||||||
@export var camera_fov: float = 75:
|
|
||||||
set(value):
|
|
||||||
camera_fov = value
|
|
||||||
|
|
||||||
@export_group("Video")
|
@export_group("Video")
|
||||||
@export_subgroup("Display")
|
@export_subgroup("Display")
|
||||||
@ -129,6 +126,7 @@ func load_config() -> void:
|
|||||||
return
|
return
|
||||||
|
|
||||||
var section: String = ""
|
var section: String = ""
|
||||||
|
var some_not_found := false
|
||||||
for property in get_property_list():
|
for property in get_property_list():
|
||||||
if _property_is_section(property):
|
if _property_is_section(property):
|
||||||
section = property["name"] as String
|
section = property["name"] as String
|
||||||
@ -139,11 +137,15 @@ func load_config() -> void:
|
|||||||
if not config.has_section_key(section, property_name):
|
if not config.has_section_key(section, property_name):
|
||||||
print("%s not found in config, setting default" % property_name)
|
print("%s not found in config, setting default" % property_name)
|
||||||
set(property_name, _default_values[property_name])
|
set(property_name, _default_values[property_name])
|
||||||
|
some_not_found = true
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var value: Variant = config.get_value(section, property_name)
|
var value: Variant = config.get_value(section, property_name)
|
||||||
set(property_name, value)
|
set(property_name, value)
|
||||||
|
|
||||||
|
if some_not_found:
|
||||||
|
save_config()
|
||||||
|
|
||||||
|
|
||||||
func _property_is_setting(property: Dictionary) -> bool:
|
func _property_is_setting(property: Dictionary) -> bool:
|
||||||
return (property["usage"] as int & SETTING_USAGE_FLAG) == SETTING_USAGE_FLAG
|
return (property["usage"] as int & SETTING_USAGE_FLAG) == SETTING_USAGE_FLAG
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user