Add controller ui

This commit is contained in:
2026-06-11 20:19:15 -05:00
parent 619bf09ab9
commit 456ea1e07e
6 changed files with 98 additions and 17 deletions
+17 -1
View File
@@ -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
+3 -2
View File
@@ -4,11 +4,12 @@ func _ready() -> void:
visible = false
$HBoxContainer/ItemList.item_selected.connect(onItemSelected)
func open():
func open() -> void:
visible = true
$HBoxContainer/ItemList.clear()
$HBoxContainer/ItemList.grab_focus()
func close():
func close() -> void:
visible = false
func isOpen() -> bool:
+11
View File
@@ -17,3 +17,14 @@ func close() -> void:
visible = false
MAIN.close()
SETTINGS.close()
func _unhandled_input(event:InputEvent) -> void:
if !visible:
return
if event.is_action_pressed("ui_cancel"):
if SETTINGS.isOpen():
SETTINGS.close()
MAIN.open()
else:
close()
get_viewport().set_input_as_handled()
+4 -1
View File
@@ -7,9 +7,12 @@ func _ready() -> void:
tabs.tab_changed.connect(onTabChanged)
onTabChanged(tabs.current_tab)
func _notification(what:int) -> void:
if what == NOTIFICATION_VISIBILITY_CHANGED and visible:
tabs.grab_focus()
func onTabChanged(tabIndex:int) -> void:
for control in tabControls:
control.visible = false
if tabIndex >= 0 and tabIndex < tabControls.size():
tabControls[tabIndex].visible = true