immersive-home/app/content/ui/menu/room/views/doors.gd

52 lines
1.3 KiB
GDScript3
Raw Normal View History

2024-04-28 21:13:09 +03:00
extends Node3D
const ConstructRoomMesh = preload ("res://lib/utils/mesh/construct_room_mesh.gd")
const material_selected = preload ("../room_selected.tres")
const material_unselected = preload ("../room_unselected.tres")
@onready var door_button = $Button
@onready var door_label = $Label3D
@onready var rooms_map = $Rooms
@onready var doors_map = $Doors
var editing_door = R.state(false)
func _ready():
2024-04-29 18:18:15 +03:00
rooms_map.selectable.value = false
var button_icon = R.computed(func(_arg):
if doors_map.selected_door.value == null:
return "add"
elif editing_door.value == false:
return "edit"
else:
return "save"
2024-04-28 21:13:09 +03:00
)
2024-04-29 18:18:15 +03:00
R.bind(door_button, "label", button_icon)
var button_label = R.computed(func(_arg):
if doors_map.selected_door.value == null:
return "Add Door"
elif editing_door.value == false:
return "Edit Door"
else:
return "Save Door"
)
R.bind(door_label, "text", button_label)
2024-04-28 21:13:09 +03:00
door_button.on_button_up.connect(func():
2024-04-29 18:18:15 +03:00
if doors_map.selected_door.value == null:
var id=House.body.doors.add()
editing_door.value=true
doors_map.selected_door.value=id
elif editing_door.value == false:
editing_door.value=true
House.body.doors.edit(doors_map.selected_door.value)
else:
House.body.doors.save()
editing_door.value=false
2024-04-28 21:13:09 +03:00
)