immersive-home/app/content/ui/menu/menu.gd

51 lines
1.3 KiB
GDScript3
Raw Normal View History

2023-10-30 02:21:50 +02:00
extends Node3D
const Notification = preload ("res://content/ui/components/notification/notification.tscn")
2023-11-28 00:46:05 +02:00
@onready var animation_player = $AnimationPlayer
2024-05-09 13:40:41 +03:00
@onready var open_sound = $OpenSound
@onready var close_sound = $CloseSound
2023-12-13 23:22:52 +02:00
@onready var notify_place = $AnimationContainer/NotifyPlace
@onready var main = $"/root/Main"
2023-11-16 20:23:17 +02:00
var show_menu = R.state(false)
func _ready():
await main.ready
main.remove_child(self)
R.effect(func(_arg):
if show_menu.value:
main.add_child(self)
move_into_view()
animation_player.play_backwards("hide_menu")
2024-05-09 13:40:41 +03:00
open_sound.play()
close_sound.stop()
else:
animation_player.play("hide_menu")
2024-05-09 13:40:41 +03:00
close_sound.play()
open_sound.stop()
)
animation_player.animation_finished.connect(func(_animation):
if show_menu.value == false:
main.remove_child(self)
)
2023-10-30 02:21:50 +02:00
2023-12-13 23:22:52 +02:00
EventSystem.on_notify.connect(func(event: EventNotify):
var notification_node=Notification.instantiate()
notification_node.text=event.message
notification_node.type=event.type
2023-12-13 23:22:52 +02:00
for child in notify_place.get_children():
2024-04-25 17:05:52 +03:00
child.position += Vector3(0, 0.06, 0)
2023-12-13 23:22:52 +02:00
notify_place.add_child(notification_node)
)
func move_into_view():
var camera_transform = main.camera.global_transform
camera_transform.origin -= camera_transform.basis.z * 0.5
global_transform = camera_transform