diff --git a/app/content/system/house/doors/doors.gd b/app/content/system/house/doors/doors.gd index ee8952a..9d6ed45 100644 --- a/app/content/system/house/doors/doors.gd +++ b/app/content/system/house/doors/doors.gd @@ -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 diff --git a/app/content/ui/menu/room/views/doors.gd b/app/content/ui/menu/room/views/doors.gd index cf252af..c355e34 100644 --- a/app/content/ui/menu/room/views/doors.gd +++ b/app/content/ui/menu/room/views/doors.gd @@ -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 + ) \ No newline at end of file diff --git a/app/content/ui/menu/room/views/doors.tscn b/app/content/ui/menu/room/views/doors.tscn index e22abbe..d5ce7d6 100644 --- a/app/content/ui/menu/room/views/doors.tscn +++ b/app/content/ui/menu/room/views/doors.tscn @@ -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("../..")