2023-10-30 02:21:50 +02:00
|
|
|
extends Node3D
|
|
|
|
|
2023-11-28 00:46:05 +02:00
|
|
|
const Proxy = preload("res://lib/utils/proxy.gd")
|
|
|
|
|
2023-11-20 00:58:26 +02:00
|
|
|
@onready var _controller := XRHelpers.get_xr_controller(self)
|
|
|
|
|
|
|
|
@onready var nav_view = $AnimationContainer/Navigation/View
|
|
|
|
@onready var nav_edit: Button3D = $AnimationContainer/Navigation/Edit
|
|
|
|
@onready var menu_edit: Node3D = $AnimationContainer/Content/EditMenu
|
|
|
|
@onready var nav_room = $AnimationContainer/Navigation/Room
|
|
|
|
@onready var menu_room: Node3D = $AnimationContainer/Content/RoomMenu
|
|
|
|
@onready var nav_automate = $AnimationContainer/Navigation/Automate
|
|
|
|
@onready var nav_settings = $AnimationContainer/Navigation/Settings
|
|
|
|
@onready var menu_settings: Node3D = $AnimationContainer/Content/SettingsMenu
|
|
|
|
|
|
|
|
@onready var menu_root = $AnimationContainer
|
|
|
|
@onready var content = $AnimationContainer/Content
|
|
|
|
@onready var nav = $AnimationContainer/Navigation
|
|
|
|
@onready var animation_player = $AnimationPlayer
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2023-11-23 04:41:13 +02:00
|
|
|
var selected_nav = null
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2023-11-20 00:58:26 +02:00
|
|
|
var show_menu := true:
|
|
|
|
set(value):
|
|
|
|
show_menu = value
|
|
|
|
if value:
|
|
|
|
animation_player.play_backwards("hide_menu")
|
|
|
|
AudioPlayer.play_effect("open_menu")
|
|
|
|
else:
|
|
|
|
animation_player.play("hide_menu")
|
|
|
|
AudioPlayer.play_effect("close_menu")
|
2023-10-30 02:21:50 +02:00
|
|
|
|
|
|
|
func _ready():
|
2023-11-20 00:58:26 +02:00
|
|
|
_controller.button_pressed.connect(func(button):
|
|
|
|
if button == "by_button":
|
|
|
|
show_menu = !show_menu
|
|
|
|
)
|
|
|
|
|
2023-11-28 00:46:05 +02:00
|
|
|
var nav_buttons = [
|
|
|
|
nav_view,
|
|
|
|
nav_edit,
|
|
|
|
nav_room,
|
|
|
|
nav_automate,
|
|
|
|
nav_settings
|
|
|
|
]
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2023-11-28 00:46:05 +02:00
|
|
|
for nav_button in nav_buttons:
|
|
|
|
var getter = func():
|
|
|
|
return nav_button == selected_nav
|
|
|
|
|
|
|
|
var setter = func(value):
|
|
|
|
if value:
|
|
|
|
select_menu(nav_button)
|
|
|
|
|
|
|
|
nav_button.external_value = Proxy.new(getter, setter)
|
|
|
|
|
|
|
|
select_menu(nav_edit)
|
2023-11-23 04:41:13 +02:00
|
|
|
|
|
|
|
func select_menu(nav):
|
|
|
|
if _is_valid_nav(nav) == false || selected_nav == nav:
|
|
|
|
return
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2023-11-20 00:58:26 +02:00
|
|
|
for child in content.get_children():
|
|
|
|
content.remove_child(child)
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2023-11-28 00:46:05 +02:00
|
|
|
var old_nav = selected_nav
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2023-11-23 04:41:13 +02:00
|
|
|
selected_nav = nav
|
2023-11-18 15:27:42 +02:00
|
|
|
|
2023-11-28 00:46:05 +02:00
|
|
|
if old_nav != null:
|
|
|
|
old_nav.update_animation()
|
|
|
|
|
2023-11-23 04:41:13 +02:00
|
|
|
if selected_nav != null:
|
2023-11-28 00:46:05 +02:00
|
|
|
selected_nav.update_animation()
|
2023-11-23 04:41:13 +02:00
|
|
|
var menu = _nav_to_menu(selected_nav)
|
|
|
|
if menu != null:
|
|
|
|
content.add_child(menu)
|
|
|
|
menu.visible = true
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2023-11-23 04:41:13 +02:00
|
|
|
func _is_valid_nav(nav):
|
|
|
|
return nav == nav_view || nav == nav_edit || nav == nav_room || nav == nav_automate || nav == nav_settings
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2023-11-23 04:41:13 +02:00
|
|
|
func _nav_to_menu(nav):
|
|
|
|
match nav:
|
|
|
|
nav_view:
|
2023-11-16 20:23:17 +02:00
|
|
|
return null
|
2023-11-23 04:41:13 +02:00
|
|
|
nav_edit:
|
2023-11-16 20:23:17 +02:00
|
|
|
return menu_edit
|
2023-11-23 04:41:13 +02:00
|
|
|
nav_room:
|
2023-11-18 16:32:37 +02:00
|
|
|
return menu_room
|
2023-11-23 04:41:13 +02:00
|
|
|
nav_automate:
|
2023-11-16 20:23:17 +02:00
|
|
|
return null
|
2023-11-23 04:41:13 +02:00
|
|
|
nav_settings:
|
2023-11-20 00:58:26 +02:00
|
|
|
return menu_settings
|
2023-11-23 04:41:13 +02:00
|
|
|
return null
|