-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.gd
More file actions
34 lines (26 loc) · 1.25 KB
/
Settings.gd
File metadata and controls
34 lines (26 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
extends Node
var config = ConfigFile.new()
const CHARACTERS = ["res://player-row.tscn", "res://player-ite.tscn", "res://player-iamond.tscn"]
func _ready():
var has_config = config.load("user://settings.cfg") == OK
print(has_config)
$"../Layout/Play".disabled = not has_config
if has_config:
$Menu/Username.text = config.get_value("config", "username")
$Menu/MusicVolume.value = config.get_value("config", "music_volume", 1)
$"Menu/SFX Volume".value = config.get_value("config", "sfx_volume", 1)
$Menu/Controls.selected = 0 if config.get_value("config", "relative_controls") else 1
$Menu/Character.selected = CHARACTERS.find(config.get_value("gameplay", "class", "res://player-row.tscn"))
func _process(delta):
check_valid("")
func check_valid(none):
$Close.disabled = len($Menu/Username.text) != 3
func save():
config.set_value("config", "username", $Menu/Username.text)
config.set_value("config", "relative_controls", $Menu/Controls.selected == 0)
config.set_value("config", "music_volume", $Menu/MusicVolume.value)
config.set_value("config", "sfx_volume", $"Menu/SFX Volume".value)
config.set_value("gameplay", "class", CHARACTERS[$Menu/Character.selected])
print("Saving!")
config.save("user://settings.cfg")
$"../Layout/Play".disabled = false