diff --git a/src/Main.gd b/src/Main.gd index 510e11dd5..a7109e836 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -19,15 +19,15 @@ func _ready() -> void: Import.import_brushes(Global.directory_module.get_brushes_search_path_in_order()) Import.import_patterns(Global.directory_module.get_patterns_search_path_in_order()) - $QuitAndSaveDialog.add_button("Save & Exit", false, "Save") - $QuitAndSaveDialog.get_ok().text = "Exit without saving" + Global.quit_and_save_dialog.add_button("Save & Exit", false, "Save") + Global.quit_and_save_dialog.get_ok().text = "Exit without saving" var zstd_checkbox := CheckBox.new() zstd_checkbox.name = "ZSTDCompression" zstd_checkbox.pressed = true zstd_checkbox.text = "Use ZSTD Compression" zstd_checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND - $SaveSprite.get_vbox().add_child(zstd_checkbox) + Global.save_sprites_dialog.get_vbox().add_child(zstd_checkbox) if not Global.config_cache.has_section_key("preferences", "startup"): Global.config_cache.set_value("preferences", "startup", true) @@ -82,7 +82,7 @@ func show_splash_screen() -> void: # Wait for the window to adjust itself, so the popup is correctly centered yield(get_tree().create_timer(0.01), "timeout") if Global.config_cache.get_value("preferences", "startup"): - $SplashDialog.popup_centered() # Splash screen + $Dialogs/SplashDialog.popup_centered() # Splash screen modulate = Color(0.5, 0.5, 0.5) else: Global.can_draw = true @@ -90,7 +90,8 @@ func show_splash_screen() -> void: func handle_backup() -> void: # If backup file exists then Pixelorama was not closed properly (probably crashed) - reopen backup - $BackupConfirmation.get_cancel().text = tr("Delete") + var backup_confirmation : ConfirmationDialog = $Dialogs/BackupConfirmation + backup_confirmation.get_cancel().text = tr("Delete") if Global.config_cache.has_section("backups"): var project_paths = Global.config_cache.get_section_keys("backups") if project_paths.size() > 0: @@ -100,10 +101,10 @@ func handle_backup() -> void: backup_paths.append(Global.config_cache.get_value("backups", p_path)) # Temporatily stop autosave until user confirms backup OpenSave.autosave_timer.stop() - $BackupConfirmation.dialog_text = tr($BackupConfirmation.dialog_text) % project_paths - $BackupConfirmation.connect("confirmed", self, "_on_BackupConfirmation_confirmed", [project_paths, backup_paths]) - $BackupConfirmation.get_cancel().connect("pressed", self, "_on_BackupConfirmation_delete", [project_paths, backup_paths]) - $BackupConfirmation.popup_centered() + backup_confirmation.dialog_text = tr(backup_confirmation.dialog_text) % project_paths + backup_confirmation.connect("confirmed", self, "_on_BackupConfirmation_confirmed", [project_paths, backup_paths]) + backup_confirmation.get_cancel().connect("pressed", self, "_on_BackupConfirmation_delete", [project_paths, backup_paths]) + backup_confirmation.popup_centered() Global.can_draw = false modulate = Color(0.5, 0.5, 0.5) else: @@ -179,8 +180,8 @@ func show_quit_dialog() -> void: func _on_QuitAndSaveDialog_custom_action(action : String) -> void: if action == "Save": is_quitting_on_save = true - $SaveSprite.popup_centered() - $QuitDialog.hide() + Global.save_sprites_dialog.popup_centered() + Global.quit_dialog.hide() Global.dialog_open(true) @@ -194,9 +195,9 @@ func _on_QuitDialog_confirmed() -> void: func _on_BackupConfirmation_confirmed(project_paths : Array, backup_paths : Array) -> void: OpenSave.reload_backup_file(project_paths, backup_paths) OpenSave.autosave_timer.start() - $ExportDialog.file_name = OpenSave.current_save_paths[0].get_file().trim_suffix(".pxo") - $ExportDialog.directory_path = OpenSave.current_save_paths[0].get_base_dir() - $ExportDialog.was_exported = false + Global.export_dialog.file_name = OpenSave.current_save_paths[0].get_file().trim_suffix(".pxo") + Global.export_dialog.directory_path = OpenSave.current_save_paths[0].get_base_dir() + Global.export_dialog.was_exported = false Global.file_menu.get_popup().set_item_text(3, tr("Save") + " %s" % OpenSave.current_save_paths[0].get_file()) Global.file_menu.get_popup().set_item_text(5, tr("Export")) diff --git a/src/Main.tscn b/src/Main.tscn index 00eef469f..ca2f8ff0d 100644 --- a/src/Main.tscn +++ b/src/Main.tscn @@ -43,49 +43,67 @@ __meta__ = { [node name="UI" parent="MenuAndUI" instance=ExtResource( 4 )] -[node name="BrushesPopup" parent="." instance=ExtResource( 6 )] +[node name="Dialogs" type="Control" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +mouse_filter = 2 +__meta__ = { +"_edit_use_anchors_": false +} -[node name="PatternsPopup" parent="." instance=ExtResource( 5 )] +[node name="BrushesPopup" parent="Dialogs" instance=ExtResource( 6 )] -[node name="SplashDialog" parent="." instance=ExtResource( 27 )] +[node name="PatternsPopup" parent="Dialogs" instance=ExtResource( 5 )] -[node name="CreateNewImage" parent="." instance=ExtResource( 28 )] +[node name="SplashDialog" parent="Dialogs" instance=ExtResource( 27 )] -[node name="OpenSprite" parent="." instance=ExtResource( 12 )] +[node name="CreateNewImage" parent="Dialogs" instance=ExtResource( 28 )] +margin_right = 375.0 -[node name="SaveSprite" parent="." instance=ExtResource( 11 )] +[node name="OpenSprite" parent="Dialogs" instance=ExtResource( 12 )] -[node name="SaveSpriteHTML5" parent="." instance=ExtResource( 8 )] +[node name="SaveSprite" parent="Dialogs" instance=ExtResource( 11 )] +margin_left = 108.0 +margin_top = 40.0 +margin_right = 623.0 +margin_bottom = 388.0 -[node name="ExportDialog" parent="." instance=ExtResource( 39 )] +[node name="SaveSpriteHTML5" parent="Dialogs" instance=ExtResource( 8 )] -[node name="ScaleImage" parent="." instance=ExtResource( 31 )] +[node name="ExportDialog" parent="Dialogs" instance=ExtResource( 39 )] -[node name="ResizeCanvas" parent="." instance=ExtResource( 7 )] +[node name="ScaleImage" parent="Dialogs" instance=ExtResource( 31 )] +margin_bottom = 127.0 -[node name="PreferencesDialog" parent="." instance=ExtResource( 32 )] +[node name="ResizeCanvas" parent="Dialogs" instance=ExtResource( 7 )] +margin_right = 216.0 +margin_bottom = 392.0 -[node name="RotateImage" parent="." instance=ExtResource( 38 )] +[node name="PreferencesDialog" parent="Dialogs" instance=ExtResource( 32 )] +margin_right = 617.0 -[node name="OutlineDialog" parent="." instance=ExtResource( 33 )] -visible = false +[node name="RotateImage" parent="Dialogs" instance=ExtResource( 38 )] -[node name="AboutDialog" parent="." instance=ExtResource( 34 )] +[node name="OutlineDialog" parent="Dialogs" instance=ExtResource( 33 )] +margin_right = 217.0 +margin_bottom = 106.0 -[node name="UnsavedCanvasDialog" type="ConfirmationDialog" parent="."] -margin_right = 200.0 +[node name="AboutDialog" parent="Dialogs" instance=ExtResource( 34 )] + +[node name="UnsavedCanvasDialog" type="ConfirmationDialog" parent="Dialogs"] +margin_right = 467.0 margin_bottom = 70.0 window_title = "Unsaved Image" dialog_text = "You have unsaved changes. If you proceed, the progress you have made will be lost." -[node name="QuitDialog" type="ConfirmationDialog" parent="."] -margin_right = 200.0 +[node name="QuitDialog" type="ConfirmationDialog" parent="Dialogs"] +margin_right = 243.0 margin_bottom = 70.0 resizable = true dialog_text = "Are you sure you want to exit Pixelorama?" -[node name="QuitAndSaveDialog" type="ConfirmationDialog" parent="."] -margin_right = 200.0 +[node name="QuitAndSaveDialog" type="ConfirmationDialog" parent="Dialogs"] +margin_right = 330.0 margin_bottom = 70.0 window_title = "Save before exiting?" resizable = true @@ -94,15 +112,15 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="ErrorDialog" type="AcceptDialog" parent="."] -margin_right = 76.0 +[node name="ErrorDialog" type="AcceptDialog" parent="Dialogs"] +margin_right = 151.0 margin_bottom = 60.0 window_title = "Error!" dialog_text = "This is an error message!" -[node name="HSVDialog" parent="." instance=ExtResource( 44 )] +[node name="HSVDialog" parent="Dialogs" instance=ExtResource( 44 )] -[node name="BackupConfirmation" type="ConfirmationDialog" parent="."] +[node name="BackupConfirmation" type="ConfirmationDialog" parent="Dialogs"] margin_right = 349.0 margin_bottom = 88.0 rect_min_size = Vector2( 250, 87.5 ) @@ -117,27 +135,27 @@ visible = false visible = false [node name="ModulateTween" type="Tween" parent="."] -[connection signal="popup_hide" from="SplashDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="CreateNewImage" to="." method="_can_draw_true"] -[connection signal="file_selected" from="OpenSprite" to="." method="_on_OpenSprite_file_selected"] -[connection signal="popup_hide" from="OpenSprite" to="." method="_on_OpenSprite_popup_hide"] -[connection signal="file_selected" from="SaveSprite" to="." method="_on_SaveSprite_file_selected"] -[connection signal="popup_hide" from="SaveSprite" to="." method="_can_draw_true"] -[connection signal="confirmed" from="SaveSpriteHTML5" to="." method="_on_SaveSpriteHTML5_confirmed"] -[connection signal="popup_hide" from="SaveSpriteHTML5" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="ExportDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="ScaleImage" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="ResizeCanvas" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="PreferencesDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="RotateImage" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="OutlineDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="AboutDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="UnsavedCanvasDialog" to="." method="_can_draw_true"] -[connection signal="confirmed" from="QuitDialog" to="." method="_on_QuitDialog_confirmed"] -[connection signal="popup_hide" from="QuitDialog" to="." method="_can_draw_true"] -[connection signal="confirmed" from="QuitAndSaveDialog" to="." method="_on_QuitDialog_confirmed"] -[connection signal="custom_action" from="QuitAndSaveDialog" to="." method="_on_QuitAndSaveDialog_custom_action"] -[connection signal="popup_hide" from="QuitAndSaveDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="ErrorDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="HSVDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="BackupConfirmation" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/SplashDialog" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/CreateNewImage" to="." method="_can_draw_true"] +[connection signal="file_selected" from="Dialogs/OpenSprite" to="." method="_on_OpenSprite_file_selected"] +[connection signal="popup_hide" from="Dialogs/OpenSprite" to="." method="_on_OpenSprite_popup_hide"] +[connection signal="file_selected" from="Dialogs/SaveSprite" to="." method="_on_SaveSprite_file_selected"] +[connection signal="popup_hide" from="Dialogs/SaveSprite" to="." method="_can_draw_true"] +[connection signal="confirmed" from="Dialogs/SaveSpriteHTML5" to="." method="_on_SaveSpriteHTML5_confirmed"] +[connection signal="popup_hide" from="Dialogs/SaveSpriteHTML5" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/ExportDialog" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/ScaleImage" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/ResizeCanvas" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/PreferencesDialog" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/RotateImage" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/OutlineDialog" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/AboutDialog" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/UnsavedCanvasDialog" to="." method="_can_draw_true"] +[connection signal="confirmed" from="Dialogs/QuitDialog" to="." method="_on_QuitDialog_confirmed"] +[connection signal="popup_hide" from="Dialogs/QuitDialog" to="." method="_can_draw_true"] +[connection signal="confirmed" from="Dialogs/QuitAndSaveDialog" to="." method="_on_QuitDialog_confirmed"] +[connection signal="custom_action" from="Dialogs/QuitAndSaveDialog" to="." method="_on_QuitAndSaveDialog_custom_action"] +[connection signal="popup_hide" from="Dialogs/QuitAndSaveDialog" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/ErrorDialog" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/HSVDialog" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="Dialogs/BackupConfirmation" to="." method="_can_draw_true"] diff --git a/src/UI/Dialogs/OutlineDialog.tscn b/src/UI/Dialogs/OutlineDialog.tscn index b3caa65e3..d66c8abef 100644 --- a/src/UI/Dialogs/OutlineDialog.tscn +++ b/src/UI/Dialogs/OutlineDialog.tscn @@ -2,10 +2,7 @@ [ext_resource path="res://src/UI/Dialogs/OutlineDialog.gd" type="Script" id=1] - - [node name="OutlineDialog" type="ConfirmationDialog"] -visible = true margin_right = 200.0 margin_bottom = 70.0 script = ExtResource( 1 ) diff --git a/src/UI/TopMenuContainer.gd b/src/UI/TopMenuContainer.gd index 8482d8082..a050e9b22 100644 --- a/src/UI/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer.gd @@ -324,12 +324,12 @@ func image_menu_id_pressed(id : int) -> void: func show_scale_image_popup() -> void: - Global.control.get_node("ScaleImage").popup_centered() + Global.control.get_node("Dialogs/ScaleImage").popup_centered() Global.dialog_open(true) func show_resize_canvas_popup() -> void: - Global.control.get_node("ResizeCanvas").popup_centered() + Global.control.get_node("Dialogs/ResizeCanvas").popup_centered() Global.dialog_open(true) @@ -347,25 +347,25 @@ func flip_image(horizontal : bool) -> void: func show_rotate_image_popup() -> void: var image : Image = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image - Global.control.get_node("RotateImage").set_sprite(image) - Global.control.get_node("RotateImage").popup_centered() + Global.control.get_node("Dialogs/RotateImage").set_sprite(image) + Global.control.get_node("Dialogs/RotateImage").popup_centered() Global.dialog_open(true) func show_add_outline_popup() -> void: - Global.control.get_node("OutlineDialog").popup_centered() + Global.control.get_node("Dialogs/OutlineDialog").popup_centered() Global.dialog_open(true) func show_hsv_configuration_popup() -> void: - Global.control.get_node("HSVDialog").popup_centered() + Global.control.get_node("Dialogs/HSVDialog").popup_centered() Global.dialog_open(true) func help_menu_id_pressed(id : int) -> void: match id: 0: # Splash Screen - Global.control.get_node("SplashDialog").popup_centered() + Global.control.get_node("Dialogs/SplashDialog").popup_centered() Global.dialog_open(true) 1: # Online Docs OS.shell_open("https://orama-interactive.github.io/Pixelorama-Docs/") @@ -377,5 +377,5 @@ func help_menu_id_pressed(id : int) -> void: else: OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/blob/master/CHANGELOG.md#v07---2020-05-16") 4: # About Pixelorama - Global.control.get_node("AboutDialog").popup_centered() + Global.control.get_node("Dialogs/AboutDialog").popup_centered() Global.dialog_open(true)