extends Control signal game_started() signal skin_changed(skin) enum Actions { PLAY, ENTER_OPTIONS, EXIT_OPTIONS, NEXT_TRACK, PREV_TRACK, # PREV_SKIN, # NEXT_SKIN, # PREV_INPUT_MODE, # NEXT_INPUT_MODE, # PREV_GAME_MODE, # NEXT_GAME_MODE, QUIT, } var actions = {} # Registered actions var _focus = null # The node that has focus func _ready(): _connect_action("Main/Jouer", Actions.PLAY) _connect_action("Main/Options", Actions.ENTER_OPTIONS) _connect_action("Main/Quitter", Actions.QUIT) _connect_action("Options/Return", Actions.EXIT_OPTIONS) _connect_action("Options/TrackSelection/LeftArrow", Actions.PREV_TRACK) _connect_action("Options/TrackSelection/RightArrow", Actions.NEXT_TRACK) TrackSelection.connect("track_changed", self, "_on_track_changed") _on_track_changed() func _input(event): # TODO: Handle navigation if event is InputEventMouseButton and _focus != null: if event.button_index == BUTTON_LEFT and event.pressed: match actions[_focus]: Actions.PLAY: emit_signal("game_started") Actions.ENTER_OPTIONS: $Main.set_visible(false) $Options.set_visible(true) Actions.EXIT_OPTIONS: $Main.set_visible(true) $Options.set_visible(false) Actions.QUIT: get_tree().quit() Actions.PREV_TRACK: TrackSelection.set_previous_track() Actions.NEXT_TRACK: TrackSelection.set_next_track() func _on_track_changed(): get_node("Options/TrackSelection/Value").set_text(TrackSelection.get_current_track_name()) func _connect_action(node_path, action): var node = get_node(node_path) node.connect("mouse_entered", self, "set_focus", [node]) node.connect("mouse_exited", self, "leave_focus", [node]) actions[node] = action func set_focus(node): _set_active(true, node) _focus = node func leave_focus(node): _set_active(false, node) _focus = null func _set_active(is_active, node): # Updates the focus effect for node var color = Color.orange if is_active else Color.white node.set("custom_colors/font_color", color)