From ca027eb305e663021ec2568dac88e29a0b2730bd Mon Sep 17 00:00:00 2001 From: rainlizard Date: Mon, 30 Oct 2023 18:29:14 +1100 Subject: [PATCH] Confirmation box when removing custom slabs, column data always shows --- Scenes/Main.tscn | 17 +++++++++++++++++ Scenes/PickSlabWindow.gd | 17 +++++++++++------ Scenes/ViewColumn.gd | 16 ++++++++-------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Scenes/Main.tscn b/Scenes/Main.tscn index f943e753..51289b85 100644 --- a/Scenes/Main.tscn +++ b/Scenes/Main.tscn @@ -2140,6 +2140,22 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="ConfirmDeleteCustomSlab" type="ConfirmationDialog" parent="Ui/UiSystem"] +visible = true +margin_left = 916.0 +margin_top = -181.0 +margin_right = 1216.0 +margin_bottom = -76.0 +rect_min_size = Vector2( 300, 105 ) +popup_exclusive = true +window_title = "Confirm delete" +dialog_text = "Delete this custom slab?" +dialog_autowrap = true +script = ExtResource( 61 ) +__meta__ = { +"_edit_use_anchors_": false +} + [node name="ConfirmSaveBeforeQuit" type="WindowDialog" parent="Ui/UiSystem"] visible = true margin_left = 944.0 @@ -6362,6 +6378,7 @@ script = SubResource( 20 ) [connection signal="confirmed" from="Ui/UiSystem/ConfirmDelete" to="Ui/UiSystem/MapBrowser" method="_on_ConfirmDelete_confirmed"] [connection signal="confirmed" from="Ui/UiSystem/ConfirmDiscardChanges" to="Ui/UiSystem/Menu" method="_on_ConfirmDiscardChanges_confirmed"] [connection signal="confirmed" from="Ui/UiSystem/ConfirmQuit" to="Editor" method="_on_ConfirmQuit_confirmed"] +[connection signal="confirmed" from="Ui/UiSystem/ConfirmDeleteCustomSlab" to="Ui/UiTools/PickSlabWindow" method="_on_ConfirmDeleteCustomSlab_confirmed"] [connection signal="pressed" from="Ui/UiSystem/ConfirmSaveBeforeQuit/VBoxContainer/HBoxContainer/ButtonConfirmExitSave" to="Ui/UiSystem/ConfirmSaveBeforeQuit" method="_on_ButtonConfirmExitSave_pressed"] [connection signal="pressed" from="Ui/UiSystem/ConfirmSaveBeforeQuit/VBoxContainer/HBoxContainer/ButtonConfirmExitDontSave" to="Ui/UiSystem/ConfirmSaveBeforeQuit" method="_on_ButtonConfirmExitDontSave_pressed"] [connection signal="pressed" from="Ui/UiSystem/ConfirmSaveBeforeQuit/VBoxContainer/HBoxContainer/ButtonConfirmExitCancel" to="Ui/UiSystem/ConfirmSaveBeforeQuit" method="_on_ButtonConfirmExitCancel_pressed"] diff --git a/Scenes/PickSlabWindow.gd b/Scenes/PickSlabWindow.gd index b73788ad..a111017c 100644 --- a/Scenes/PickSlabWindow.gd +++ b/Scenes/PickSlabWindow.gd @@ -15,6 +15,8 @@ onready var oColumnEditor = Nodelist.list["oColumnEditor"] onready var oColumnEditorTabs = Nodelist.list["oColumnEditorTabs"] onready var oDkDat = Nodelist.list["oDkDat"] onready var oPlaceLockedCheckBox = Nodelist.list["oPlaceLockedCheckBox"] +onready var oConfirmDeleteCustomSlab = Nodelist.list["oConfirmDeleteCustomSlab"] + onready var oSelectedRect = $Clippy/SelectedRect @@ -233,13 +235,16 @@ func _on_slab_portrait_gui_input(event, id): if event.is_action_pressed("mouse_right"): var slabID = id.get_meta("ID_of_slab") if slabID >= 1000: - oCustomSlabSystem.remove_custom_slab(slabID) - - for child in current_grid_container().get_children(): - if child.get_meta("ID_of_slab") == slabID: - child.queue_free() - + Utils.popup_centered(oConfirmDeleteCustomSlab) + oConfirmDeleteCustomSlab.set_meta("ID_TO_DELETE", slabID) _on_hovered_none() func rect_changed_start_timer(): rectChangedTimer.start(0.2) + +func _on_ConfirmDeleteCustomSlab_confirmed(): + var slabID = oConfirmDeleteCustomSlab.get_meta("ID_TO_DELETE") + for child in tabs[Slabs.TAB_CUSTOM][GRIDCON_PATH].get_children(): + if child.has_meta("ID_of_slab") and child.get_meta("ID_of_slab") == slabID: + child.queue_free() + oCustomSlabSystem.remove_custom_slab(slabID) diff --git a/Scenes/ViewColumn.gd b/Scenes/ViewColumn.gd index a4d5d25f..9c28e4fd 100644 --- a/Scenes/ViewColumn.gd +++ b/Scenes/ViewColumn.gd @@ -40,14 +40,14 @@ func update_details(): # oColumnListData.clear() # return - if oColumnEditor.visible == true: - if oColumnEditorVoxelView.visible == true: - entryIndex = oColumnEditorVoxelView.viewObject - if oCustomSlabVoxelView.visible == true: - if is_instance_valid(get_focus_owner()): - if is_instance_valid(get_focus_owner().get_parent()): - if get_focus_owner().get_parent() is SpinBox: - entryIndex = get_focus_owner().get_parent().value +# if oColumnEditor.visible == true: +# if oColumnEditorVoxelView.visible == true: +# entryIndex = oColumnEditorVoxelView.viewObject +# if oCustomSlabVoxelView.visible == true: +# if is_instance_valid(get_focus_owner()): +# if is_instance_valid(get_focus_owner().get_parent()): +# if get_focus_owner().get_parent() is SpinBox: +# entryIndex = get_focus_owner().get_parent().value for i in 16: var description