immersive-home/content/ui/menu/room/room_menu.gd

41 lines
1002 B
GDScript3
Raw Normal View History

2023-11-18 15:27:42 +02:00
extends Node3D
const Room = preload("res://content/system/room/room.tscn")
2023-12-01 22:37:36 +02:00
const window_scene = preload("./window.tscn")
2023-11-18 15:27:42 +02:00
2023-11-26 03:01:27 +02:00
@onready var background = $Background
2023-11-18 16:32:37 +02:00
@onready var toggle_edit_button = $Interface/ToggleEdit
2023-11-29 23:24:38 +02:00
@onready var spawn_windows = $SpawnWindows
@onready var rooms = get_tree().root.get_node("Main/Rooms")
var room: Node3D
2023-11-18 15:27:42 +02:00
func _ready():
2023-11-26 03:01:27 +02:00
background.visible = false
2023-11-18 15:27:42 +02:00
HomeApi.on_connect.connect(func():
if rooms.get_child_count() == 0:
room = Room.instantiate()
rooms.add_child(room)
else:
room = rooms.get_child(0)
2023-12-11 16:24:10 +02:00
if rooms.get_child_count() > 1:
for child in rooms.get_children():
if child != room:
child.queue_free()
2023-11-29 23:24:38 +02:00
)
spawn_windows.on_button_down.connect(func():
get_tree().root.get_node("Main").add_child.call_deferred(window_scene.instantiate())
2023-11-18 15:27:42 +02:00
)
2023-11-28 16:14:21 +02:00
toggle_edit_button.on_button_down.connect(func():
if room != null:
room.editable = true
2023-11-18 15:27:42 +02:00
)
toggle_edit_button.on_button_up.connect(func():
if room != null:
room.editable = false
2023-11-18 15:27:42 +02:00
)