From 88237e4682d37915f329032791117476c7a85037 Mon Sep 17 00:00:00 2001 From: seriouscatsoserious <121734574+seriouscatsoserious@users.noreply.github.com> Date: Tue, 28 May 2024 12:00:57 -0500 Subject: [PATCH] Add reset logic, adjust confirm modal --- project.godot | 1 + .../base_chain_dashboard_panel.gd | 28 +++++++++++++++---- .../chain_provider_info.tscn | 1 + ui/components/settings/reset_confirm_scene.gd | 26 +++++++++++++++++ .../settings/reset_confirm_scene.tscn | 17 +++++------ 5 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 ui/components/settings/reset_confirm_scene.gd diff --git a/project.godot b/project.godot index dd58509..b3f25ab 100644 --- a/project.godot +++ b/project.godot @@ -24,6 +24,7 @@ Appstate="*res://autoloads/appstate.tscn" Net="*res://net.gd" DashboardPanel="*res://ui/components/dashboard/base_dashboard_panel/base_chain_dashboard_panel.gd" chain_state="*res://models/chain_state.gd" +ResetSidechainWindow="*res://ui/components/dashboard/chain_providers_info/reset_sidechain_window.gd" [display] diff --git a/ui/components/dashboard/base_dashboard_panel/base_chain_dashboard_panel.gd b/ui/components/dashboard/base_dashboard_panel/base_chain_dashboard_panel.gd index b1da1b3..783c171 100644 --- a/ui/components/dashboard/base_dashboard_panel/base_chain_dashboard_panel.gd +++ b/ui/components/dashboard/base_dashboard_panel/base_chain_dashboard_panel.gd @@ -603,11 +603,29 @@ func _on_settings_button_2_pressed(): purge() func _on_settings_button_3_pressed(): - print("Settings button 3 pressed") # Replace with function body. - var reset_window = reset_confirm_scene.instantiate() - get_tree().root.get_node("Main").add_child(reset_window) - reset_window.show() # Call this method if the window is not set to automatically show upon being added to the scene tree. - print("Reset window opened") + # Create the confirmation dialog on the fly + var confirmation_dialog = ConfirmationDialog.new() + confirmation_dialog.dialog_text = "Are you sure you want to delete your node AND wallet?" + confirmation_dialog.min_size = Vector2(400, 100) # Adjust size to your preference + add_child(confirmation_dialog) + confirmation_dialog.popup_centered() # Center and show the dialog + + # Connect the 'confirmed' signal to a custom method to handle the confirmation + confirmation_dialog.connect("confirmed", Callable(self, "_on_confirm_delete_and_purge")) + + # Connect the 'popup_hide' signal to automatically queue_free the dialog after closing + confirmation_dialog.connect("popup_hide", Callable(confirmation_dialog, "queue_free")) + +func _on_confirm_delete_and_purge(): + print("User has confirmed the action.") + delete_backup() + purge() + + ##print(chain_provider.id) # Replace with function body. + ##var reset_window = reset_confirm_scene.instantiate() + ##get_tree().root.get_node("Main").add_child(reset_window) + ##reset_window.show() # Call this method if the window is not set to automatically show upon being added to the scene tree. + ##print("Reset window opened") #delete_backup() #purge() diff --git a/ui/components/dashboard/chain_providers_info/chain_provider_info.tscn b/ui/components/dashboard/chain_providers_info/chain_provider_info.tscn index 169547b..bb91d84 100644 --- a/ui/components/dashboard/chain_providers_info/chain_provider_info.tscn +++ b/ui/components/dashboard/chain_providers_info/chain_provider_info.tscn @@ -122,6 +122,7 @@ size_flags_horizontal = 10 vertical_alignment = 1 [node name="Footer" type="VBoxContainer" parent="Center/Panel/Margin/VBox"] +visible = false layout_mode = 2 size_flags_vertical = 10 diff --git a/ui/components/settings/reset_confirm_scene.gd b/ui/components/settings/reset_confirm_scene.gd new file mode 100644 index 0000000..a4af8c7 --- /dev/null +++ b/ui/components/settings/reset_confirm_scene.gd @@ -0,0 +1,26 @@ +extends ColorRect + +var chain_provider : ChainProvider + +func setup(_chain_provider: ChainProvider, _chain_state: ChainState): + self.chain_provider = _chain_provider +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _on_center_container_gui_input(event): + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if event.pressed: + queue_free() + + + +func _on_button_2_pressed(): + ResetSidechainWindow.delete_backup() + print("testing") # Replace with function body. diff --git a/ui/components/settings/reset_confirm_scene.tscn b/ui/components/settings/reset_confirm_scene.tscn index 2e82c90..d4fe541 100644 --- a/ui/components/settings/reset_confirm_scene.tscn +++ b/ui/components/settings/reset_confirm_scene.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=3 format=3 uid="uid://c34upjg3vigfo"] -[ext_resource type="Script" path="res://ui/components/settings/reset_everything_window.gd" id="1_5uuov"] +[ext_resource type="Script" path="res://ui/components/settings/reset_confirm_scene.gd" id="1_3p30n"] [ext_resource type="Theme" uid="uid://b730juygqetth" path="res://ui/themes/dangerous_button.tres" id="2_h8kap"] -[node name="ResetEverythingWindow" type="ColorRect"] +[node name="ResetConfirmScene" type="ColorRect"] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -12,7 +12,7 @@ grow_vertical = 2 size_flags_horizontal = 3 size_flags_vertical = 3 color = Color(0, 0, 0, 0.721569) -script = ExtResource("1_5uuov") +script = ExtResource("1_3p30n") [node name="CenterContainer" type="CenterContainer" parent="."] layout_mode = 1 @@ -23,11 +23,12 @@ grow_horizontal = 2 grow_vertical = 2 [node name="Panel" type="PanelContainer" parent="CenterContainer"] -custom_minimum_size = Vector2(500, 275) +custom_minimum_size = Vector2(500, 200) layout_mode = 2 [node name="MarginContainer" type="MarginContainer" parent="CenterContainer/Panel"] layout_mode = 2 +size_flags_vertical = 4 theme_override_constants/margin_left = 16 theme_override_constants/margin_top = 8 theme_override_constants/margin_right = 16 @@ -38,14 +39,10 @@ layout_mode = 2 size_flags_vertical = 4 theme_override_constants/separation = 10 -[node name="Control" type="Control" parent="CenterContainer/Panel/MarginContainer/VBoxContainer"] -custom_minimum_size = Vector2(0, 8) -layout_mode = 2 - [node name="Label2" type="Label" parent="CenterContainer/Panel/MarginContainer/VBoxContainer"] custom_minimum_size = Vector2(500, 0) layout_mode = 2 -text = "Choose \"Reset everything\" to get a fresh install of the Launcher and to delete all sidechains and all wallets." +text = "Are you sure want to delete your node and your wallet?" horizontal_alignment = 1 vertical_alignment = 3 autowrap_mode = 2 @@ -54,7 +51,7 @@ autowrap_mode = 2 layout_mode = 2 size_flags_horizontal = 4 theme = ExtResource("2_h8kap") -text = "Reset everything" +text = "Yes, delete my node AND my wallet" [connection signal="gui_input" from="CenterContainer" to="." method="_on_center_container_gui_input"] [connection signal="pressed" from="CenterContainer/Panel/MarginContainer/VBoxContainer/Button2" to="." method="_on_button_2_pressed"]