Skip to content

Commit

Permalink
Add reset logic, adjust confirm modal
Browse files Browse the repository at this point in the history
  • Loading branch information
seriouscatsoserious authored and Marc Platt committed Jul 30, 2024
1 parent 3ca130e commit 88237e4
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 15 deletions.
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 26 additions & 0 deletions ui/components/settings/reset_confirm_scene.gd
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 7 additions & 10 deletions ui/components/settings/reset_confirm_scene.tscn
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"]

0 comments on commit 88237e4

Please sign in to comment.