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

51 lines
1.3 KiB
GDScript3
Raw Normal View History

2023-11-16 20:23:17 +02:00
extends Node3D
2024-03-21 11:51:58 +02:00
const ButtonScene = preload ("res://content/ui/components/button/button.tscn")
2023-11-16 20:23:17 +02:00
@onready var devices_page = $Devices
@onready var entities_page = $Entities
2024-05-09 13:40:41 +03:00
@onready var spawn_sound = $SpawnSound
var selected_device = R.state(null)
2023-11-16 20:23:17 +02:00
func _ready():
entities_page.selected_device = selected_device
remove_child(entities_page)
2023-11-16 20:23:17 +02:00
devices_page.on_select_device.connect(func(device):
selected_device.value=device
entities_page.page.value=0
2023-11-16 20:23:17 +02:00
)
entities_page.on_select_entity.connect(func(entity_name):
2024-05-09 13:40:41 +03:00
spawn_sound.play()
2023-11-16 20:23:17 +02:00
var entity=House.body.create_entity(entity_name, global_position)
2024-05-06 13:45:45 +03:00
if typeof(entity) == TYPE_BOOL&&entity == false:
EventSystem.notify("Entity is not in Room", EventNotify.Type.INFO)
if entity == null:
EventSystem.notify("This Entity is not supported yet", EventNotify.Type.INFO)
2023-11-16 20:23:17 +02:00
)
entities_page.on_back.connect(func():
selected_device.value=null
)
2023-11-16 20:23:17 +02:00
R.effect(func(_arg):
if selected_device.value == null:
if devices_page.is_inside_tree() == false:
add_child(devices_page)
2023-11-16 20:23:17 +02:00
if entities_page.is_inside_tree():
remove_child(entities_page)
2024-01-27 16:38:47 +02:00
if selected_device.value != null:
if entities_page.is_inside_tree() == false:
add_child(entities_page)
if devices_page.is_inside_tree():
remove_child(devices_page)
)