1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Cache Save/Open Sprite Dialog's directory, and keep dialogs synced (#559)

* Open/Save Sprite Dialogs now have their directory cached so when reopening Pixelorama they will be set to that directory. Load last project and load recent project also syncs with the open/save dialogs and caches that directory

* Sets a projects default file path to the cached file directory (not sure about) and if the export directory is blank, use the cached file directory

* Changed 'file_dialog_dir' to 'current_dir'

Co-authored-by: MrTriPie <MrTriPie>
This commit is contained in:
mrtripie 2021-11-16 17:17:02 -05:00 committed by GitHub
parent 752703878d
commit 969aed8070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View file

@ -82,7 +82,7 @@ func _init(_frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) ->
if OS.get_name() == "HTML5":
directory_path = "user://"
else:
directory_path = OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
directory_path = Global.config_cache.get_value("data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP))
func commit_undo() -> void:

View file

@ -46,8 +46,8 @@ func _ready() -> void:
Global.quit_and_save_dialog.add_button("Save & Exit", false, "Save")
Global.quit_and_save_dialog.get_ok().text = "Exit without saving"
Global.open_sprites_dialog.current_dir = OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
Global.save_sprites_dialog.current_dir = OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
Global.open_sprites_dialog.current_dir = Global.config_cache.get_value("data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP))
Global.save_sprites_dialog.current_dir = Global.config_cache.get_value("data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP))
# FIXME: OS.get_system_dir does not grab the correct directory for Ubuntu Touch.
# Additionally, AppArmor policies prevent the app from writing to the /home
@ -313,6 +313,10 @@ func load_last_project() -> void:
var file_check := File.new()
if file_check.file_exists(file_path): # If yes then load the file
OpenSave.open_pxo_file(file_path)
# Sync file dialogs
Global.save_sprites_dialog.current_dir = file_path.get_base_dir()
Global.open_sprites_dialog.current_dir = file_path.get_base_dir()
Global.config_cache.set_value("data", "current_dir", file_path.get_base_dir())
else:
# If file doesn't exist on disk then warn user about this
Global.error_dialog.set_text("Cannot find last project file.")
@ -328,6 +332,10 @@ func load_recent_project_file(path : String) -> void:
var file_check := File.new()
if file_check.file_exists(path): # If yes then load the file
OpenSave.handle_loading_files([path])
# Sync file dialogs
Global.save_sprites_dialog.current_dir = path.get_base_dir()
Global.open_sprites_dialog.current_dir = path.get_base_dir()
Global.config_cache.set_value("data", "current_dir", path.get_base_dir())
else:
# If file doesn't exist on disk then warn user about this
Global.error_dialog.set_text("Cannot find project file.")
@ -337,11 +345,15 @@ func load_recent_project_file(path : String) -> void:
func _on_OpenSprite_file_selected(path : String) -> void:
OpenSave.handle_loading_files([path])
Global.save_sprites_dialog.current_dir = path.get_base_dir()
Global.config_cache.set_value("data", "current_dir", path.get_base_dir())
func _on_SaveSprite_file_selected(path : String) -> void:
var zstd = Global.save_sprites_dialog.get_vbox().get_node("ZSTDCompression").pressed
OpenSave.save_pxo_file(path, false, zstd)
Global.open_sprites_dialog.current_dir = path.get_base_dir()
Global.config_cache.set_value("data", "current_dir", path.get_base_dir())
if is_quitting_on_save:
_on_QuitDialog_confirmed()

View file

@ -229,7 +229,7 @@ func _on_ExportDialog_about_to_show() -> void:
Export.directory_path = "user://"
if Export.directory_path.empty():
Export.directory_path = OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
Export.directory_path = Global.config_cache.get_value("data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP))
# If export already occured - sets gui to show previous settings
options_resize.value = Export.resize