extends Node
## Player-facing game options (autoload `Settings`), persisted to user://settings.cfg.
## Distinct from DP (debug tunables) and Controls (keybinds): this is the small set of
## comfort/accessibility toggles the options menu exposes to the player.

signal changed(key: String, value: Variant)

const SAVE_PATH := "user://settings.cfg"
const SECTION := "options"

## Master screen-shake toggle — gates every camera_iso.trigger_hit (hits and ability FX).
var screen_shake: bool = true
## Gore toggle — when off, no blood spawns (impact spurt + ongoing spear-wound bleed).
var gore: bool = true


func _ready() -> void:
	load_saved()


func set_screen_shake(value: bool) -> void:
	if screen_shake == value:
		return
	screen_shake = value
	changed.emit("screen_shake", value)
	save()


func set_gore(value: bool) -> void:
	if gore == value:
		return
	gore = value
	changed.emit("gore", value)
	save()


func save() -> void:
	var cfg := ConfigFile.new()
	cfg.set_value(SECTION, "screen_shake", screen_shake)
	cfg.set_value(SECTION, "gore", gore)
	cfg.save(SAVE_PATH)


func load_saved() -> void:
	var cfg := ConfigFile.new()
	if cfg.load(SAVE_PATH) != OK:
		return
	screen_shake = cfg.get_value(SECTION, "screen_shake", true) as bool
	gore = cfg.get_value(SECTION, "gore", true) as bool
