add option to delete doors

This commit is contained in:
Nitwel 2024-04-29 18:19:06 +02:00
parent 4451f5c5b8
commit 6cb2c7a2de
3 changed files with 21 additions and 1 deletions

View File

@ -34,6 +34,10 @@ func add():
return next_index + 1
func delete(door):
Store.house.state.doors = Store.house.state.doors.filter(func(d): return d.id != door)
Store.house.save_local()
func edit(door):
var doors = Store.house.state.doors
editing_door = door

View File

@ -6,6 +6,7 @@ const material_selected = preload ("../room_selected.tres")
const material_unselected = preload ("../room_unselected.tres")
@onready var door_button = $Button
@onready var delete_button = $DeleteButton
@onready var door_label = $Label3D
@onready var rooms_map = $Rooms
@onready var doors_map = $Doors
@ -37,6 +38,11 @@ func _ready():
R.bind(door_label, "text", button_label)
R.effect(func(_arg):
delete_button.disabled=doors_map.selected_door.value == null
delete_button.visible=doors_map.selected_door.value != null
)
door_button.on_button_up.connect(func():
if doors_map.selected_door.value == null:
var id=House.body.doors.add()
@ -49,4 +55,10 @@ func _ready():
House.body.doors.save()
editing_door.value=false
)
delete_button.on_button_up.connect(func():
if doors_map.selected_door.value != null:
House.body.doors.delete(doors_map.selected_door.value)
doors_map.selected_door.value=null
)

View File

@ -46,9 +46,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.28, 0)
label = "add"
icon = true
[node name="DeleteButton" parent="." instance=ExtResource("2_v01ty")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.28, 0)
label = "delete"
icon = true
[node name="Background" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.21, -0.16, 0)
visible = false
material_override = SubResource("ShaderMaterial_dah0r")
mesh = SubResource("QuadMesh_fq44b")
skeleton = NodePath("../..")