UI improvements
This commit is contained in:
+12
-19
@@ -1,4 +1,4 @@
|
||||
class_name GameMenu extends Control
|
||||
class_name GameMenu extends ClosableMenu
|
||||
|
||||
enum Tab { PARTY, ITEMS }
|
||||
|
||||
@@ -9,21 +9,14 @@ enum Tab { PARTY, ITEMS }
|
||||
var _currentTab:Tab = Tab.PARTY
|
||||
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
super._ready()
|
||||
SIDEBAR.item_selected.connect(_onTabSelected)
|
||||
|
||||
func open() -> void:
|
||||
visible = true
|
||||
func _grabInitialFocus() -> void:
|
||||
_selectTab(_currentTab)
|
||||
SIDEBAR.select(_currentTab)
|
||||
SIDEBAR.grab_focus()
|
||||
|
||||
func close() -> void:
|
||||
visible = false
|
||||
|
||||
func isOpen() -> bool:
|
||||
return visible
|
||||
|
||||
func _onTabSelected(index:int) -> void:
|
||||
_selectTab(index as Tab)
|
||||
|
||||
@@ -37,16 +30,16 @@ func _selectTab(tab:Tab) -> void:
|
||||
Tab.ITEMS:
|
||||
ITEMS_TAB.refresh()
|
||||
|
||||
func _input(event:InputEvent) -> void:
|
||||
if not event.is_action_pressed("menu"):
|
||||
return
|
||||
if isOpen:
|
||||
close()
|
||||
elif UI.FOCUS_STACK.top() == null and not UI.dialogueActive and SCENE.currentScene == SceneSingleton.SceneType.OVERWORLD:
|
||||
open()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _unhandled_input(event:InputEvent) -> void:
|
||||
if event.is_action_pressed("menu"):
|
||||
if visible:
|
||||
close()
|
||||
elif !UI.dialogueActive and SCENE.currentScene == SceneSingleton.SceneType.OVERWORLD:
|
||||
open()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if !visible:
|
||||
return
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
close()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
Reference in New Issue
Block a user