From 4e33476a4d9e589057853d197e95cbd647b4dedd Mon Sep 17 00:00:00 2001
From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com>
Date: Sun, 25 Oct 2020 00:58:37 +0300
Subject: [PATCH] Fixed "Export" option in the File menu not working properly
when switching between projects
Export.was_reported was keeping its value when switching projects, instead of being project-specific. Also fixed issue where imported images were not remembering the directory_path and file_name when switching projects.
---
CHANGELOG.md | 3 ++-
src/Autoload/Export.gd | 1 +
src/Autoload/OpenSave.gd | 3 +++
src/Classes/Project.gd | 4 +++-
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 37574476e..a65b4627b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,7 +9,7 @@ This update has been brought to you by the contributions of:
PinyaColada, Rémi Verschelde (akien-mga)
### Added
-- Added a "frame properties" option on the popupmenu that appears when right-clicking on a cel. This lets the user choose a custom frame delay for that specific frame. ([#357](https://github.com/Orama-Interactive/Pixelorama/pull/357))
+- Added a "frame properties" option on the popup menu that appears when right-clicking on a cel. This lets the user choose a custom frame delay for that specific frame. ([#357](https://github.com/Orama-Interactive/Pixelorama/pull/357))
- You can now select if you want rotation to apply in the selection, the current cel, the entire frame, all frames or even all projects (tabs)!
### Changed
@@ -19,6 +19,7 @@ PinyaColada, Rémi Verschelde (akien-mga)
- 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.
- Fixed issue where the user could grab, and could not let go of, the focus of guides even when they were invisible.
- Fixed issues where fully transparent color could not be picked. One of these cases was ([#364](https://github.com/Orama-Interactive/Pixelorama/issues/364)).
+- Fixed "Export" option in the File menu not working properly when switching between projects, and not remembering the directory path and file name, if the project is an imported image and the tabs were switched.
- Fixed crash when importing an incorrectly formatted GIMP Color Palette file. ([#363](https://github.com/Orama-Interactive/Pixelorama/issues/363))
diff --git a/src/Autoload/Export.gd b/src/Autoload/Export.gd
index 3c7d34f8a..1c63de86b 100644
--- a/src/Autoload/Export.gd
+++ b/src/Autoload/Export.gd
@@ -193,6 +193,7 @@ func export_processed_images(ignore_overwrites: bool, export_dialog: AcceptDialo
# Store settings for quick export and when the dialog is opened again
was_exported = true
+ Global.current_project.was_exported = true
Global.file_menu.get_popup().set_item_text(5, tr("Export") + " %s" % (file_name + file_format_string(file_format)))
# Only show when not exporting gif - gif export finishes in thread
diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd
index 38f3b61ba..df4900696 100644
--- a/src/Autoload/OpenSave.gd
+++ b/src/Autoload/OpenSave.gd
@@ -326,6 +326,7 @@ func save_pxo_file(path : String, autosave : bool, use_zstd_compression := true,
Export.file_name = path.get_file().trim_suffix(".pxo")
Export.directory_path = path.get_base_dir()
Export.was_exported = false
+ project.was_exported = false
Global.file_menu.get_popup().set_item_text(3, tr("Save") + " %s" % path.get_file())
@@ -454,6 +455,8 @@ func set_new_tab(project : Project, path : String) -> void:
Global.window_title = Global.window_title + "(*)"
var file_name := path.get_basename().get_file()
var directory_path := path.get_basename().replace(file_name, "")
+ project.directory_path = directory_path
+ project.file_name = file_name
Export.directory_path = directory_path
Export.file_name = file_name
diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd
index 0261c6c62..01e46225c 100644
--- a/src/Classes/Project.gd
+++ b/src/Classes/Project.gd
@@ -33,6 +33,7 @@ var cameras_offset := [Vector2.ZERO, Vector2.ZERO, Vector2.ZERO] # Array of Vect
var directory_path := ""
var file_name := "untitled"
var file_format : int = Export.FileFormat.PNG
+var was_exported := false
func _init(_frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) -> void:
@@ -197,8 +198,9 @@ func change_project() -> void:
Export.directory_path = directory_path
Export.file_name = file_name
Export.file_format = file_format
+ Export.was_exported = was_exported
- if directory_path.empty():
+ if !was_exported:
Global.file_menu.get_popup().set_item_text(5, tr("Export"))
else:
Global.file_menu.get_popup().set_item_text(5, tr("Export") + " %s" % (file_name + Export.file_format_string(file_format)))