From ef9f82682e2638824dd3c98bd4bab9e5300669de Mon Sep 17 00:00:00 2001 From: Nitwel Date: Fri, 24 May 2024 11:02:50 +0200 Subject: [PATCH] fix delete button --- app/content/main.tscn | 1 + app/content/system/house/house.gd | 8 ++------ app/content/ui/menu/room/views/rooms.gd | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/content/main.tscn b/app/content/main.tscn index 5c9216d..b9df03e 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -53,6 +53,7 @@ unique_name_in_owner = true transform = Transform3D(0.999999, -1.39635e-11, 0, 1.31553e-10, 1, 0, 0, 0, 1, 0.336726, 0.575093, -0.437942) [node name="XRSimulator" parent="." instance=ExtResource("5_3qc8g")] +disable_xr_in_editor = false min_camera_height = 0.01 xr_origin = NodePath("../XROrigin3D") diff --git a/app/content/system/house/house.gd b/app/content/system/house/house.gd index 148bfb0..6ca450c 100644 --- a/app/content/system/house/house.gd +++ b/app/content/system/house/house.gd @@ -103,14 +103,10 @@ func delete_room(room_name): if editing_room == room: editing_room = null - room.get_parent().remove_child(room) + rooms.remove_child(room) room.queue_free() - await room.tree_exited - var store_room = Store.house.get_room(room_name) - - if store_room != null: - Store.house.state.rooms.erase(store_room) + Store.house.state.rooms = Store.house.state.rooms.filter(func(r): return r.name != room_name) Store.house.save_local() diff --git a/app/content/ui/menu/room/views/rooms.gd b/app/content/ui/menu/room/views/rooms.gd index c6e898f..7d5f822 100644 --- a/app/content/ui/menu/room/views/rooms.gd +++ b/app/content/ui/menu/room/views/rooms.gd @@ -42,8 +42,8 @@ func _ready(): sync_room_button.visible=editing_room.value sync_room_label.visible=editing_room.value sync_room_button.disabled=!editing_room.value - delete_button.visible=editing_room.value - delete_button.disabled=!editing_room.value + delete_button.visible=rooms_map.selected_room.value != null + delete_button.disabled=rooms_map.selected_room.value == null ) if !Store.house.is_loaded(): await Store.house.on_loaded