adds basic menu functionnality
This commit is contained in:
52
Menu.gd
52
Menu.gd
@@ -1,12 +1,15 @@
|
||||
extends CanvasLayer
|
||||
extends Control
|
||||
|
||||
signal track_changed(track_idx)
|
||||
signal game_started()
|
||||
signal track_changed()
|
||||
signal skin_changed(skin)
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
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.
|
||||
@@ -14,3 +17,42 @@ func _ready():
|
||||
# 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
|
||||
Reference in New Issue
Block a user