diff --git a/Main.tscn b/Main.tscn index e0ccd0f95..a0688960a 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1237,6 +1237,7 @@ margin_right = 200.0 margin_bottom = 70.0 [node name="VBoxContainer" type="VBoxContainer" parent="CreateNewImage"] +editor/display_folded = true margin_left = 8.0 margin_top = 8.0 margin_right = 192.0 @@ -1365,6 +1366,7 @@ margin_right = 200.0 margin_bottom = 114.0 [node name="VBoxContainer" type="VBoxContainer" parent="ScaleImage"] +editor/display_folded = true margin_left = 8.0 margin_top = 8.0 margin_right = 192.0 @@ -1466,11 +1468,13 @@ Developed by Orama Interactive align = 1 [node name="Links" type="CenterContainer" parent="AboutDialog/AboutUI"] +editor/display_folded = true margin_top = 87.0 margin_right = 268.0 margin_bottom = 107.0 [node name="LinkButtons" type="HBoxContainer" parent="AboutDialog/AboutUI/Links"] +editor/display_folded = true margin_left = 22.0 margin_right = 246.0 margin_bottom = 20.0 @@ -1500,6 +1504,12 @@ text = " Copyright 2019 - Orama Interactive" align = 1 +[node name="QuitDialog" type="ConfirmationDialog" parent="."] +margin_right = 200.0 +margin_bottom = 70.0 +resizable = true +dialog_text = "Are you sure you want to exit Pixelorama?" + [node name="AnimationTimer" type="Timer" parent="."] [connection signal="color_changed" from="MenuAndUI/UI/ToolPanel/Tools/ToolOptions/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton" to="." method="_on_LeftColorPickerButton_color_changed"] [connection signal="popup_closed" from="MenuAndUI/UI/ToolPanel/Tools/ToolOptions/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton" to="." method="_can_draw_true"] @@ -1568,4 +1578,6 @@ align = 1 [connection signal="pressed" from="AboutDialog/AboutUI/Links/LinkButtons/Website" to="AboutDialog" method="_on_Website_pressed"] [connection signal="pressed" from="AboutDialog/AboutUI/Links/LinkButtons/GitHub" to="AboutDialog" method="_on_GitHub_pressed"] [connection signal="pressed" from="AboutDialog/AboutUI/Links/LinkButtons/Donate" to="AboutDialog" method="_on_Donate_pressed"] +[connection signal="confirmed" from="QuitDialog" to="." method="_on_QuitDialog_confirmed"] +[connection signal="popup_hide" from="QuitDialog" to="." method="_can_draw_true"] [connection signal="timeout" from="AnimationTimer" to="." method="_on_AnimationTimer_timeout"] diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 646692786..dc6d33a83 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -17,6 +17,7 @@ var animation_forward := true # Called when the node enters the scene tree for the first time. func _ready() -> void: + get_tree().set_auto_accept_quit(false) OS.set_window_title("(untitled) - Pixelorama") # Set a minimum window size to prevent UI elements from collapsing on each other. # This property is only available in 3.2alpha or later, so use `set()` to fail gracefully if it doesn't exist. @@ -141,7 +142,7 @@ func _ready() -> void: brushes_dir.list_dir_end() Global.brushes_from_files = Global.custom_brushes.size() -func _input(event): +func _input(event) -> void: if event.is_action_pressed("toggle_fullscreen"): OS.window_fullscreen = !OS.window_fullscreen @@ -152,6 +153,11 @@ func _input(event): elif event.is_action_pressed(t[1]): #Shortcut for left button _on_Tool_pressed(t[0], false, true) +func _notification(what) -> void: + if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: #Handle exit + $QuitDialog.popup_centered() + Global.can_draw = false + func file_menu_id_pressed(id : int) -> void: match id: 0: #New @@ -184,7 +190,8 @@ func file_menu_id_pressed(id : int) -> void: $ExportSprites.popup_centered() Global.can_draw = false 7: #Quit - get_tree().quit() + $QuitDialog.popup_centered() + Global.can_draw = false func edit_menu_id_pressed(id : int) -> void: match id: @@ -953,6 +960,9 @@ func _on_RightHorizontalMirroring_toggled(button_pressed) -> void: func _on_RightVerticalMirroring_toggled(button_pressed) -> void: Global.right_vertical_mirror = button_pressed +func _on_QuitDialog_confirmed() -> void: + get_tree().quit() + func _exit_tree() -> void: # Save the window position and size to remember it when restarting the application config_cache.set_value("window", "screen", OS.current_screen) @@ -960,4 +970,3 @@ func _exit_tree() -> void: config_cache.set_value("window", "position", OS.window_position) config_cache.set_value("window", "size", OS.window_size) config_cache.save("user://cache.ini") - diff --git a/Scripts/NotificationLabel.gd b/Scripts/NotificationLabel.gd index 77cb82883..cfabbfb05 100644 --- a/Scripts/NotificationLabel.gd +++ b/Scripts/NotificationLabel.gd @@ -1,6 +1,5 @@ extends Label - # Called when the node enters the scene tree for the first time. func _ready() -> void: var tween := $Tween