This repository has been archived on 2024-08-28. You can view files and clone it, but cannot push or open issues or pull requests.
gmtk-2024/scripts/config_manager.gd
2024-08-19 03:16:36 +01:00

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