SlimePlatformer/UI/main_menu.gd

33 lines
1,019 B
GDScript
Executable file

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 optionsButton = $CenterContainer/VBoxContainer/OptionsButton
@onready var optionsMenu = $OptionsMenu
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 screen.
if event.is_action_pressed("pause") and optionsMenu.visible:
optionsMenu.close()
get_viewport().set_input_as_handled()
func _on_start_button_pressed() -> void:
Transition.change_scene(FIRST_LEVEL)
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()