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

Minor open/save dialog path related code cleaning

This commit is contained in:
Emmanouil Papadeas 2024-03-22 15:12:27 +02:00
parent 60af6b27e3
commit ad85c8dd3e
3 changed files with 7 additions and 14 deletions

View file

@ -242,6 +242,7 @@ func open_pxo_file(path: String, untitled_backup := false, replace_empty := true
else: else:
new_project.tiles.reset_mask() new_project.tiles.reset_mask()
zip_reader.close() zip_reader.close()
new_project.export_directory_path = path.get_basename()
if empty_project: if empty_project:
new_project.change_project() new_project.change_project()
@ -258,6 +259,7 @@ func open_pxo_file(path: String, untitled_backup := false, replace_empty := true
Global.main_window.title = path.get_file() + " - Pixelorama " + Global.current_version Global.main_window.title = path.get_file() + " - Pixelorama " + Global.current_version
Global.save_sprites_dialog.current_path = path Global.save_sprites_dialog.current_path = path
# Set last opened project path and save # Set last opened project path and save
Global.config_cache.set_value("data", "current_dir", path.get_base_dir())
Global.config_cache.set_value("data", "last_project_path", path) Global.config_cache.set_value("data", "last_project_path", path)
Global.config_cache.save("user://cache.ini") Global.config_cache.save("user://cache.ini")
new_project.export_directory_path = path.get_base_dir() new_project.export_directory_path = path.get_base_dir()
@ -420,6 +422,7 @@ func save_pxo_file(
Global.main_window.title = path.get_file() + " - Pixelorama " + Global.current_version Global.main_window.title = path.get_file() + " - Pixelorama " + Global.current_version
# Set last opened project path and save # Set last opened project path and save
Global.config_cache.set_value("data", "current_dir", path.get_base_dir())
Global.config_cache.set_value("data", "last_project_path", path) Global.config_cache.set_value("data", "last_project_path", path)
Global.config_cache.save("user://cache.ini") Global.config_cache.save("user://cache.ini")
if !project.was_exported: if !project.was_exported:

View file

@ -217,12 +217,11 @@ func change_project() -> void:
if has_changed: if has_changed:
Global.main_window.title = Global.main_window.title + "(*)" Global.main_window.title = Global.main_window.title + "(*)"
var save_path := OpenSave.current_save_paths[Global.current_project_index] if export_directory_path != "":
if save_path != "": Global.open_sprites_dialog.current_path = export_directory_path
Global.open_sprites_dialog.current_path = save_path Global.save_sprites_dialog.current_path = export_directory_path
Global.save_sprites_dialog.current_path = save_path
Global.top_menu_container.file_menu.set_item_text( Global.top_menu_container.file_menu.set_item_text(
Global.FileMenu.SAVE, tr("Save") + " %s" % save_path.get_file() Global.FileMenu.SAVE, tr("Save") + " %s" % file_name
) )
else: else:
Global.top_menu_container.file_menu.set_item_text(Global.FileMenu.SAVE, tr("Save")) Global.top_menu_container.file_menu.set_item_text(Global.FileMenu.SAVE, tr("Save"))
@ -347,7 +346,6 @@ func serialize() -> Dictionary:
"brushes": brush_data, "brushes": brush_data,
"reference_images": reference_image_data, "reference_images": reference_image_data,
"vanishing_points": vanishing_points, "vanishing_points": vanishing_points,
"export_directory_path": export_directory_path,
"export_file_name": file_name, "export_file_name": file_name,
"export_file_format": file_format, "export_file_format": file_format,
"fps": fps, "fps": fps,
@ -466,8 +464,6 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
x_symmetry_axis.points[point].y = floorf(y_symmetry_point / 2 + 1) x_symmetry_axis.points[point].y = floorf(y_symmetry_point / 2 + 1)
for point in y_symmetry_axis.points.size(): for point in y_symmetry_axis.points.size():
y_symmetry_axis.points[point].x = floorf(x_symmetry_point / 2 + 1) y_symmetry_axis.points[point].x = floorf(x_symmetry_point / 2 + 1)
if dict.has("export_directory_path"):
export_directory_path = dict.export_directory_path
if dict.has("export_file_name"): if dict.has("export_file_name"):
file_name = dict.export_file_name file_name = dict.export_file_name
if dict.has("export_file_format"): if dict.has("export_file_format"):

View file

@ -263,10 +263,6 @@ func load_recent_project_file(path: String) -> void:
# Check if file still exists on disk # Check if file still exists on disk
if FileAccess.file_exists(path): # If yes then load the file if FileAccess.file_exists(path): # If yes then load the file
OpenSave.handle_loading_file(path) OpenSave.handle_loading_file(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: else:
# If file doesn't exist on disk then warn user about this # If file doesn't exist on disk then warn user about this
Global.popup_error("Cannot find project file.") Global.popup_error("Cannot find project file.")
@ -276,7 +272,6 @@ func _on_OpenSprite_files_selected(paths: PackedStringArray) -> void:
for path in paths: for path in paths:
OpenSave.handle_loading_file(path) OpenSave.handle_loading_file(path)
Global.save_sprites_dialog.current_dir = paths[0].get_base_dir() Global.save_sprites_dialog.current_dir = paths[0].get_base_dir()
Global.config_cache.set_value("data", "current_dir", paths[0].get_base_dir())
func show_save_dialog(project := Global.current_project) -> void: func show_save_dialog(project := Global.current_project) -> void:
@ -311,7 +306,6 @@ func save_project(path: String) -> void:
var success := OpenSave.save_pxo_file(path, false, include_blended, project_to_save) var success := OpenSave.save_pxo_file(path, false, include_blended, project_to_save)
if success: if success:
Global.open_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())
if is_quitting_on_save: if is_quitting_on_save:
changed_projects_on_quit.pop_front() changed_projects_on_quit.pop_front()
_save_on_quit_confirmation() _save_on_quit_confirmation()