updates
This commit is contained in:
parent
0cba7f5ee0
commit
32ed347b58
172 changed files with 5464 additions and 582 deletions
38
ui/game_settings.gd
Normal file
38
ui/game_settings.gd
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
class_name GameSettings
|
||||
## The player's settings, kept in user://settings.cfg between runs. The game scene only reads them
|
||||
## when it's entered from the menu (see SceneRouter), so tests that open it directly always start
|
||||
## from DEFAULTS.
|
||||
|
||||
const PATH := "user://settings.cfg"
|
||||
const DEFAULTS := {"stops": "combat", "autoSkip": true, "checkInvariants": false, "botDelay": 0.45, "anim": "normal"}
|
||||
## Animation speeds: `scale` multiplies every animation's length; 0 is instant.
|
||||
const ANIM_SPEEDS := {
|
||||
"slow": {"label": "Slow", "scale": 1.6},
|
||||
"normal": {"label": "Normal", "scale": 1.0},
|
||||
"fast": {"label": "Fast", "scale": 0.5},
|
||||
"instant": {"label": "Instant", "scale": 0.0},
|
||||
}
|
||||
|
||||
|
||||
static func load_saved() -> Dictionary:
|
||||
var out := DEFAULTS.duplicate()
|
||||
var cfg := ConfigFile.new()
|
||||
if cfg.load(PATH) == OK:
|
||||
for k in DEFAULTS:
|
||||
var v = cfg.get_value("game", k, DEFAULTS[k])
|
||||
if typeof(v) == typeof(DEFAULTS[k]) or (DEFAULTS[k] is float and v is int):
|
||||
out[k] = v
|
||||
if not ANIM_SPEEDS.has(out.anim):
|
||||
out.anim = DEFAULTS.anim
|
||||
return out
|
||||
|
||||
|
||||
static func save(settings: Dictionary) -> void:
|
||||
var cfg := ConfigFile.new()
|
||||
for k in DEFAULTS:
|
||||
cfg.set_value("game", k, settings.get(k, DEFAULTS[k]))
|
||||
cfg.save(PATH)
|
||||
|
||||
|
||||
static func anim_scale(settings: Dictionary) -> float:
|
||||
return ANIM_SPEEDS.get(settings.get("anim", "normal"), ANIM_SPEEDS.normal).scale
|
||||
Loading…
Add table
Add a link
Reference in a new issue