-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_settings.gd
More file actions
29 lines (28 loc) · 1.41 KB
/
main_settings.gd
File metadata and controls
29 lines (28 loc) · 1.41 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
extends PanelContainer
func _ready() -> void:
pass
func _process(_delta: float) -> void:
pass
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
if Rect2(Vector2.ZERO, size).has_point(event.position):
add_theme_stylebox_override("panel", preload("res://button_pressed_stylebox.tres"))
else:
add_theme_stylebox_override("panel", preload("res://button_stylebox.tres"))
elif event is InputEventMouseButton and event.button_index == MouseButton.MOUSE_BUTTON_LEFT:
if event.is_pressed():
add_theme_stylebox_override("panel", preload("res://button_pressed_stylebox.tres"))
elif event.is_released():
add_theme_stylebox_override("panel", preload("res://button_stylebox.tres"))
if Rect2(Vector2.ZERO, size).has_point(event.position):
if not FileAccess.file_exists(Global.DIR + "/settings.json"):
FileAccess.open(Global.DIR + "/settings.json", FileAccess.WRITE).close()
var fa = FileAccess.open(Global.DIR + "/settings.json", FileAccess.READ)
var settings = {
"music": 1,
"volumn": 1
} if fa.get_length() == 0 else JSON.parse_string(fa.get_as_text())
$"../../../../Settings/VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer/Contents/Music".value = settings["music"]
$"../../../../Settings/VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer/Contents/Volumn".value = settings["volumn"]
$"../../../../Settings".visible = true
fa.close()