extends Node ## Singleton Settings: valori di calibrazione del gameplay, caricati/salvati ## in user://settings.cfg. Modificati dal menù di configurazione e applicati ## al riavvio della scena. const PATH := "user://settings.cfg" const VERSION := 6 # incrementa quando cambiano i default, per resettare i file vecchi var version := VERSION var start_time := 4.5 # tempo iniziale (s) tra un ordine e l'altro var min_time := 0.8 # tempo minimo (velocità massima) var score_ramp := 8000.0 # punteggio per difficoltà piena (velocità massima) var points_per_combo := 1 # punti per ogni lancio corretto (lineare, default 1) var target_score := 1000 # punteggio da raggiungere per la vittoria var max_combo := 5.0 # combo massimo di default (configurabile) var combo_decay_threshold := 0.0 # combo sopra cui inizia il decay (0 = da subito) var combo_decay_rate := 0.15 # combo persi al secondo per unità sopra la soglia var difficulty_decay_rate := 0.3 # decay aggiuntivo legato alla difficoltà # Modalità di gioco (mutuamente esclusive): 0=Classica (a punteggio), 1=Zen, 2=Survival var game_mode := 0 # Accessibilità / neurodivergenza var gentle_errors := true # errore: combo -1 invece di azzerare func _ready() -> void: load_settings() func load_settings() -> void: var cfg := ConfigFile.new() if cfg.load(PATH) != OK: return # usa i default version = cfg.get_value("meta", "version", 0) if version < VERSION: # file di impostazioni vecchio: applica i nuovi default e risalva reset_defaults() save_settings() return start_time = cfg.get_value("gameplay", "start_time", start_time) min_time = cfg.get_value("gameplay", "min_time", min_time) score_ramp = cfg.get_value("gameplay", "score_ramp", score_ramp) points_per_combo = cfg.get_value("gameplay", "points_per_combo", points_per_combo) target_score = cfg.get_value("gameplay", "target_score", target_score) game_mode = cfg.get_value("gameplay", "game_mode", game_mode) max_combo = cfg.get_value("gameplay", "max_combo", max_combo) combo_decay_threshold = cfg.get_value("gameplay", "combo_decay_threshold", combo_decay_threshold) combo_decay_rate = cfg.get_value("gameplay", "combo_decay_rate", combo_decay_rate) difficulty_decay_rate = cfg.get_value("gameplay", "difficulty_decay_rate", difficulty_decay_rate) gentle_errors = cfg.get_value("accessibility", "gentle_errors", gentle_errors) func save_settings() -> void: var cfg := ConfigFile.new() cfg.set_value("meta", "version", VERSION) cfg.set_value("gameplay", "start_time", start_time) cfg.set_value("gameplay", "min_time", min_time) cfg.set_value("gameplay", "score_ramp", score_ramp) cfg.set_value("gameplay", "points_per_combo", points_per_combo) cfg.set_value("gameplay", "target_score", target_score) cfg.set_value("gameplay", "game_mode", game_mode) cfg.set_value("gameplay", "max_combo", max_combo) cfg.set_value("gameplay", "combo_decay_threshold", combo_decay_threshold) cfg.set_value("gameplay", "combo_decay_rate", combo_decay_rate) cfg.set_value("gameplay", "difficulty_decay_rate", difficulty_decay_rate) cfg.set_value("accessibility", "gentle_errors", gentle_errors) cfg.save(PATH) func reset_defaults() -> void: start_time = 4.5 min_time = 0.8 score_ramp = 8000.0 points_per_combo = 1 target_score = 1000 game_mode = 0 max_combo = 5.0 combo_decay_threshold = 0.0 combo_decay_rate = 0.15 difficulty_decay_rate = 0.3 gentle_errors = true