Add controller ui
This commit is contained in:
+17
-1
@@ -8,11 +8,27 @@ class_name MainMenu extends Control
|
||||
func _ready() -> void:
|
||||
btnNewGame.pressed.connect(onNewGamePressed)
|
||||
btnSettings.pressed.connect(onSettingsPressed)
|
||||
settingsMenu.opened.connect(_onSettingsOpened)
|
||||
settingsMenu.closed.connect(_onSettingsClosed)
|
||||
btnNewGame.grab_focus()
|
||||
|
||||
func _onSettingsOpened() -> void:
|
||||
# Move focus into the settings panel so the controller can navigate it.
|
||||
# The SettingsMenu grabs its own internal focus via _notification.
|
||||
pass
|
||||
|
||||
func _onSettingsClosed() -> void:
|
||||
btnSettings.grab_focus()
|
||||
|
||||
func _unhandled_input(event:InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if settingsMenu.isOpen:
|
||||
settingsMenu.close()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func onNewGamePressed() -> void:
|
||||
SCENE.setScene(SceneSingleton.SceneType.OVERWORLD)
|
||||
OVERWORLD.mapChange(newGameScene, "PlayerSpawnPoint")
|
||||
|
||||
func onSettingsPressed() -> void:
|
||||
print("Settings button pressed")
|
||||
settingsMenu.isOpen = true
|
||||
|
||||
Reference in New Issue
Block a user