SlimePlatformer/UI/main_menu.gd

47 lines
1.4 KiB
GDScript3
Raw Normal View History

extends Control
# Quick placeholder title screen. Start goes straight to the test level for now.
const FIRST_LEVEL = "res://Levels/test_level.tscn"
@onready var mainPanel = $CenterContainer
@onready var startButton = $CenterContainer/VBoxContainer/StartButton
@onready var mazeButton = $CenterContainer/VBoxContainer/MazeButton
@onready var optionsButton = $CenterContainer/VBoxContainer/OptionsButton
@onready var optionsMenu = $OptionsMenu
@onready var mazeSetupMenu = $MazeSetupMenu
func _ready() -> void:
# Keyboard focus on Start so arrow keys + Enter work right away.
startButton.grab_focus()
func _unhandled_input(event: InputEvent) -> void:
# Escape backs out of the options or maze screen.
if event.is_action_pressed("pause") and optionsMenu.visible:
optionsMenu.close()
get_viewport().set_input_as_handled()
elif event.is_action_pressed("pause") and mazeSetupMenu.visible:
mazeSetupMenu.close()
get_viewport().set_input_as_handled()
func _on_start_button_pressed() -> void:
Transition.change_scene(FIRST_LEVEL)
func _on_maze_button_pressed() -> void:
mainPanel.hide()
mazeSetupMenu.open()
func _on_maze_setup_menu_closed() -> void:
mainPanel.show()
mazeButton.grab_focus()
func _on_options_button_pressed() -> void:
mainPanel.hide()
optionsMenu.open()
func _on_options_menu_closed() -> void:
mainPanel.show()
optionsButton.grab_focus()
func _on_quit_button_pressed() -> void:
get_tree().quit()