36 lines
749 B
GDScript
36 lines
749 B
GDScript
extends Node
|
|
|
|
const CONFIG_PATH = "user://claustrophemia.cfg"
|
|
|
|
var settings = {
|
|
"bars": 0
|
|
}
|
|
|
|
func _ready() -> void:
|
|
load_settings()
|
|
|
|
func load_settings() -> void:
|
|
var config = ConfigFile.new()
|
|
|
|
if config.load(CONFIG_PATH) == OK:
|
|
for key in settings.keys():
|
|
if config.has_section_key("Settings", key):
|
|
settings[key] = config.get_value("Settings", key, settings[key])
|
|
|
|
func save_settings():
|
|
var config = ConfigFile.new()
|
|
|
|
for key in settings.keys():
|
|
config.set_value("Settings", key, settings[key])
|
|
|
|
config.save(CONFIG_PATH)
|
|
|
|
func set_setting(key: String, value) -> void:
|
|
if settings.has(key):
|
|
settings[key] = value
|
|
save_settings()
|
|
|
|
func get_setting(key: String):
|
|
if settings.has(key):
|
|
return settings[key]
|
|
return null
|