update
This commit is contained in:
24
scripts/core/Settings.gd
Normal file
24
scripts/core/Settings.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
class_name Settings
|
||||
extends RefCounted
|
||||
|
||||
## Lautstärke und Schwierigkeit in user://settings.cfg.
|
||||
|
||||
const PATH := "user://settings.cfg"
|
||||
|
||||
var volume: float = 0.8
|
||||
var difficulty: int = Data.Difficulty.NORMAL
|
||||
|
||||
|
||||
func load_from_disk(path: String = PATH) -> void:
|
||||
var cfg := ConfigFile.new()
|
||||
if cfg.load(path) != OK:
|
||||
return
|
||||
volume = clampf(float(cfg.get_value("audio", "volume", volume)), 0.0, 1.0)
|
||||
difficulty = clampi(int(cfg.get_value("game", "difficulty", difficulty)), 0, 2)
|
||||
|
||||
|
||||
func save_to_disk(path: String = PATH) -> void:
|
||||
var cfg := ConfigFile.new()
|
||||
cfg.set_value("audio", "volume", volume)
|
||||
cfg.set_value("game", "difficulty", difficulty)
|
||||
cfg.save(path)
|
||||
Reference in New Issue
Block a user