Files
CarRacer/Menu.gd
2020-11-03 23:04:17 +01:00

58 lines
1.5 KiB
GDScript

extends Control
signal game_started()
signal track_changed()
signal skin_changed(skin)
enum Actions { PLAY, CHANGE_TRACK, QUIT }
var _focus = null setget _set_focus
func _set_focus(value):
_focus = value
print("New focus: ", value)
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _input(event):
if event is InputEventMouseButton:
if _focus != null:
if event.button_index == BUTTON_LEFT and event.pressed:
match _focus:
Actions.PLAY:
emit_signal("game_started")
Actions.CHANGE_TRACK:
emit_signal("track_changed")
Actions.QUIT:
get_tree().quit()
_focus = null
func _on_Jouer_mouse_exited():
get_node("Main/Jouer").set("custom_colors/font_color", Color.white)
_focus = null
func _on_Jouer_mouse_entered():
get_node("Main/Jouer").set("custom_colors/font_color", Color.orange)
_set_focus(Actions.PLAY)
func _on_Options_mouse_exited():
get_node("Main/Options").set("custom_colors/font_color", Color.white)
_focus = null
func _on_Options_mouse_entered():
get_node("Main/Options").set("custom_colors/font_color", Color.orange)
_set_focus(Actions.CHANGE_TRACK)
func _on_Quitter_mouse_entered():
get_node("Main/Quitter").set("custom_colors/font_color", Color.orange)
_set_focus(Actions.QUIT)
func _on_Quitter_mouse_exited():
get_node("Main/Quitter").set("custom_colors/font_color", Color.white)
_focus = null