From ab6bebd6d43a396dc41df905bde8c51a6f893e5f Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sun, 25 Oct 2020 18:02:51 +0200 Subject: [PATCH] When there are errors in opening and saving files, the errors appear in the form of a popup dialog, instead of a notification or an OS alert. --- CHANGELOG.md | 1 + .../palette_stylebox_focus.tres | 2 -- .../palette_stylebox_hover.tres | 2 -- .../palette_stylebox_normal.tres | 2 -- .../palette_stylebox_pressedr.tres | 2 -- src/Autoload/Export.gd | 4 +++- src/Autoload/OpenSave.gd | 16 ++++++++++++---- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82ab293be..6e247caca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ PinyaColada, RĂ©mi Verschelde (akien-mga) ### Changed - `~` is now used as a random brush prefix instead of `%`. ([#362](https://github.com/Orama-Interactive/Pixelorama/pull/362)) - The default path of the dialogs for opening and saving is now the user's desktop folder. +- When there are errors in opening and saving files, the errors appear in the form of a popup dialog, instead of a notification or an OS alert. ### Fixed - Made .pxo saving safer. In case of a crash while parsing JSON data, the old .pxo file, if it exists, will no longer be overwritten and corrupted. diff --git a/assets/themes/palette_styleboxes/palette_stylebox_focus.tres b/assets/themes/palette_styleboxes/palette_stylebox_focus.tres index a7a842e36..1eb1ed98d 100644 --- a/assets/themes/palette_styleboxes/palette_stylebox_focus.tres +++ b/assets/themes/palette_styleboxes/palette_stylebox_focus.tres @@ -2,8 +2,6 @@ [ext_resource path="res://assets/graphics/palette/palette_button.png" type="Texture" id=1] - - [resource] texture = ExtResource( 1 ) region_rect = Rect2( 0, 0, 8, 8 ) diff --git a/assets/themes/palette_styleboxes/palette_stylebox_hover.tres b/assets/themes/palette_styleboxes/palette_stylebox_hover.tres index 74018816a..0e718c8d1 100644 --- a/assets/themes/palette_styleboxes/palette_stylebox_hover.tres +++ b/assets/themes/palette_styleboxes/palette_stylebox_hover.tres @@ -2,8 +2,6 @@ [ext_resource path="res://assets/graphics/palette/palette_button.png" type="Texture" id=1] - - [resource] texture = ExtResource( 1 ) region_rect = Rect2( 0, 0, 8, 8 ) diff --git a/assets/themes/palette_styleboxes/palette_stylebox_normal.tres b/assets/themes/palette_styleboxes/palette_stylebox_normal.tres index 1cf1ae94b..957c7c47b 100644 --- a/assets/themes/palette_styleboxes/palette_stylebox_normal.tres +++ b/assets/themes/palette_styleboxes/palette_stylebox_normal.tres @@ -2,8 +2,6 @@ [ext_resource path="res://assets/graphics/palette/palette_button.png" type="Texture" id=1] - - [resource] texture = ExtResource( 1 ) region_rect = Rect2( 0, 0, 8, 8 ) diff --git a/assets/themes/palette_styleboxes/palette_stylebox_pressedr.tres b/assets/themes/palette_styleboxes/palette_stylebox_pressedr.tres index 3f96c331c..212e2544e 100644 --- a/assets/themes/palette_styleboxes/palette_stylebox_pressedr.tres +++ b/assets/themes/palette_styleboxes/palette_stylebox_pressedr.tres @@ -2,8 +2,6 @@ [ext_resource path="res://assets/graphics/palette/palette_button.png" type="Texture" id=1] - - [resource] texture = ExtResource( 1 ) region_rect = Rect2( 0, 0, 8, 8 ) diff --git a/src/Autoload/Export.gd b/src/Autoload/Export.gd index 1c63de86b..5ea9bd088 100644 --- a/src/Autoload/Export.gd +++ b/src/Autoload/Export.gd @@ -189,7 +189,9 @@ func export_processed_images(ignore_overwrites: bool, export_dialog: AcceptDialo else: var err = processed_images[i].save_png(export_paths[i]) if err != OK: - OS.alert("Can't save file. Error code: %s" % err) + Global.error_dialog.set_text(tr("File failed to save. Error code %s") % err) + Global.error_dialog.popup_centered() + Global.dialog_open(true) # Store settings for quick export and when the dialog is opened again was_exported = true diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index df4900696..315d2d825 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -53,7 +53,9 @@ func open_pxo_file(path : String, untitled_backup : bool = false) -> void: err = file.open(path, File.READ) # If the file is not compressed open it raw (pre-v0.7) if err != OK: - Global.notification_label(tr("File failed to open. Error code %s") % err) + Global.error_dialog.set_text(tr("File failed to open. Error code %s") % err) + Global.error_dialog.popup_centered() + Global.dialog_open(true) file.close() return @@ -267,11 +269,15 @@ func open_old_pxo_file(file : File, new_project : Project, first_line : String) func save_pxo_file(path : String, autosave : bool, use_zstd_compression := true, project : Project = Global.current_project) -> void: var serialized_data = project.serialize() if !serialized_data: - Global.notification_label(tr("File failed to save. Serialization to dictionary failed.")) + Global.error_dialog.set_text(tr("File failed to save. Converting project data to dictionary failed.")) + Global.error_dialog.popup_centered() + Global.dialog_open(true) return var to_save = JSON.print(serialized_data) if !to_save: - Global.notification_label(tr("File failed to save. Dictionary to JSON failed.")) + Global.error_dialog.set_text(tr("File failed to save. Converting dictionary to JSON failed.")) + Global.error_dialog.popup_centered() + Global.dialog_open(true) return var file : File = File.new() @@ -282,7 +288,9 @@ func save_pxo_file(path : String, autosave : bool, use_zstd_compression := true, err = file.open(path, File.WRITE) if err != OK: - Global.notification_label(tr("File failed to save. Error code %s") % err) + Global.error_dialog.set_text(tr("File failed to save. Error code %s") % err) + Global.error_dialog.popup_centered() + Global.dialog_open(true) file.close() return