2023-10-30 02:21:50 +02:00
|
|
|
extends Node3D
|
|
|
|
|
2024-04-17 17:49:58 +03:00
|
|
|
const Notification = preload ("res://content/ui/components/notification/notification.tscn")
|
2023-11-28 00:46:05 +02:00
|
|
|
|
2023-11-20 00:58:26 +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
|
2023-11-16 20:23:17 +02:00
|
|
|
|
2024-04-17 17:49:58 +03:00
|
|
|
var show_menu = R.state(false)
|
|
|
|
|
|
|
|
func _ready():
|
2024-05-22 19:38:28 +03:00
|
|
|
App.main.remove_child(self)
|
2024-04-17 17:49:58 +03:00
|
|
|
|
|
|
|
R.effect(func(_arg):
|
|
|
|
if show_menu.value:
|
2024-05-22 19:38:28 +03:00
|
|
|
App.main.add_child(self)
|
2024-04-17 17:49:58 +03:00
|
|
|
move_into_view()
|
2023-11-20 00:58:26 +02:00
|
|
|
animation_player.play_backwards("hide_menu")
|
2024-05-09 13:40:41 +03:00
|
|
|
open_sound.play()
|
|
|
|
close_sound.stop()
|
2023-11-20 00:58:26 +02:00
|
|
|
else:
|
|
|
|
animation_player.play("hide_menu")
|
2024-05-09 13:40:41 +03:00
|
|
|
close_sound.play()
|
|
|
|
open_sound.stop()
|
2024-04-17 17:49:58 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
animation_player.animation_finished.connect(func(_animation):
|
|
|
|
if show_menu.value == false:
|
2024-05-22 19:38:28 +03:00
|
|
|
App.main.remove_child(self)
|
|
|
|
)
|
|
|
|
|
|
|
|
EventSystem.on_action_down.connect(func(action):
|
|
|
|
if action.name == "menu_button":
|
|
|
|
toggle_open()
|
2024-04-17 17:49:58 +03:00
|
|
|
)
|
2023-10-30 02:21:50 +02:00
|
|
|
|
2023-12-13 23:22:52 +02:00
|
|
|
EventSystem.on_notify.connect(func(event: EventNotify):
|
2024-04-17 17:49:58 +03:00
|
|
|
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)
|
2023-11-20 00:58:26 +02:00
|
|
|
)
|
2024-04-17 17:49:58 +03:00
|
|
|
|
2024-05-22 19:38:28 +03:00
|
|
|
func toggle_open():
|
|
|
|
show_menu.value = !show_menu.value
|
|
|
|
|
2024-04-17 17:49:58 +03:00
|
|
|
func move_into_view():
|
2024-05-22 19:38:28 +03:00
|
|
|
var camera_transform = App.camera.global_transform
|
2024-04-17 17:49:58 +03:00
|
|
|
camera_transform.origin -= camera_transform.basis.z * 0.5
|
|
|
|
|
|
|
|
global_transform = camera_transform
|