1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

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.

This commit is contained in:
Manolis Papadeas 2020-10-25 18:02:51 +02:00
parent 9be6248024
commit ab6bebd6d4
7 changed files with 16 additions and 13 deletions

View file

@ -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.

View file

@ -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 )

View file

@ -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 )

View file

@ -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 )

View file

@ -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 )

View file

@ -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

View file

@ -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