-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.gd
55 lines (42 loc) · 1.59 KB
/
menu.gd
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
extends Node2D
signal play_button_pressed()
signal settings_changed()
onready var play_button := $Play
onready var tutorial_button := $Tutorial
onready var mouse_button := $Mouse
onready var sound_button := $Sound
onready var music_button := $Music
onready var highscore := $Highscore
func _ready():
tutorial_button.pressed = true if Global.tutorial_on else false
mouse_button.pressed = true if Global.mouse_mode_on else false
sound_button.pressed = true if Global.sound_on else false
music_button.pressed = true if Global.music_on else false
change_sound_button_text()
set_highscore(0)
func _input(event):
if visible == false:
return
if event is InputEventKey and event.is_pressed():
match event.scancode:
KEY_ENTER:
emit_signal("play_button_pressed")
func change_sound_button_text():
tutorial_button.text = "Tutorial on" if tutorial_button.pressed else "Tutorial off"
mouse_button.text = "Mouse on" if mouse_button.pressed else "Mouse off"
sound_button.text = "Sound on" if sound_button.pressed else "Sound off"
music_button.text = "Music on" if music_button.pressed else "Music off"
func set_highscore(value) -> void:
if value > Global.highscore:
Global.highscore = value
highscore.text = "Highscore: " + str(Global.highscore) + " Points"
# Signals
func _on_settings_button_pressed():
change_sound_button_text()
Global.tutorial_on = tutorial_button.pressed
Global.mouse_mode_on = mouse_button.pressed
Global.sound_on = sound_button.pressed
Global.music_on = music_button.pressed
emit_signal("settings_changed")
func _on_play_pressed():
emit_signal("play_button_pressed")