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

Rename Project.directory_path to Project.export_directory_path

This commit is contained in:
Emmanouil Papadeas 2024-03-22 14:42:47 +02:00
parent 64983b0404
commit 6c8b2ae36b
5 changed files with 31 additions and 28 deletions

View file

@ -280,15 +280,18 @@ func export_processed_images(
ignore_overwrites: bool, export_dialog: ConfirmationDialog, project := Global.current_project
) -> bool:
# Stop export if directory path or file name are not valid
var dir := DirAccess.open(project.directory_path)
if not dir.dir_exists(project.directory_path) or not project.file_name.is_valid_filename():
if not dir.dir_exists(project.directory_path) and project.file_name.is_valid_filename():
var dir := DirAccess.open(project.export_directory_path)
var dir_exists := dir.dir_exists(project.export_directory_path)
var is_valid_filename := project.file_name.is_valid_filename()
if not dir_exists:
if is_valid_filename: # Directory path not valid, file name is valid
export_dialog.open_path_validation_alert_popup(0)
elif not project.file_name.is_valid_filename() and dir.dir_exists(project.directory_path):
export_dialog.open_path_validation_alert_popup(1)
else:
else: # Both directory path and file name are invalid
export_dialog.open_path_validation_alert_popup()
return false
if not is_valid_filename: # Directory path is valid, file name is invalid
export_dialog.open_path_validation_alert_popup(1)
return false
var multiple_files := false
if current_tab == ExportTab.IMAGE and not is_single_file_format(project):
@ -309,7 +312,7 @@ func export_processed_images(
if multiple_files and new_dir_for_each_frame_tag:
var frame_tag_directory := DirAccess.open(export_path.get_base_dir())
if not frame_tag_directory.dir_exists(export_path.get_base_dir()):
frame_tag_directory = DirAccess.open(project.directory_path)
frame_tag_directory = DirAccess.open(project.export_directory_path)
frame_tag_directory.make_dir(export_path.get_base_dir().get_file())
if not ignore_overwrites: # Check if the files already exist
@ -430,8 +433,8 @@ func export_processed_images(
Global.top_menu_container.file_menu.set_item_text(
Global.FileMenu.EXPORT, tr("Export") + " %s" % file_name_with_ext
)
project.directory_path = export_paths[0].get_base_dir()
Global.config_cache.set_value("data", "current_dir", project.directory_path)
project.export_directory_path = export_paths[0].get_base_dir()
Global.config_cache.set_value("data", "current_dir", project.export_directory_path)
return true
@ -624,12 +627,12 @@ func _create_export_path(multifile: bool, project: Project, frame := 0, layer :=
)
if new_dir_for_each_frame_tag:
path += path_extras
return project.directory_path.path_join(frame_tag_dir).path_join(
return project.export_directory_path.path_join(frame_tag_dir).path_join(
path + file_format_string(project.file_format)
)
path += path_extras
return project.directory_path.path_join(path + file_format_string(project.file_format))
return project.export_directory_path.path_join(path + file_format_string(project.file_format))
func _get_proccessed_image_animation_tag_and_start_id(

View file

@ -260,7 +260,7 @@ func open_pxo_file(path: String, untitled_backup := false, replace_empty := true
# Set last opened project path and save
Global.config_cache.set_value("data", "last_project_path", path)
Global.config_cache.save("user://cache.ini")
new_project.directory_path = path.get_base_dir()
new_project.export_directory_path = path.get_base_dir()
new_project.file_name = path.get_file().trim_suffix(".pxo")
new_project.was_exported = false
Global.top_menu_container.file_menu.set_item_text(
@ -424,7 +424,7 @@ func save_pxo_file(
Global.config_cache.save("user://cache.ini")
if !project.was_exported:
project.file_name = path.get_file().trim_suffix(".pxo")
project.directory_path = path.get_base_dir()
project.export_directory_path = path.get_base_dir()
Global.top_menu_container.file_menu.set_item_text(
Global.FileMenu.SAVE, tr("Save") + " %s" % path.get_file()
)
@ -783,8 +783,8 @@ func set_new_imported_tab(project: Project, path: String) -> void:
if project.has_changed:
Global.main_window.title = Global.main_window.title + "(*)"
var file_name := path.get_basename().get_file()
var directory_path := path.get_base_dir()
project.directory_path = directory_path
var export_directory_path := path.get_base_dir()
project.export_directory_path = export_directory_path
project.file_name = file_name
project.was_exported = true
if path.get_extension().to_lower() == "png":

View file

@ -73,7 +73,7 @@ var cameras_zoom: PackedVector2Array = [
var cameras_offset: PackedVector2Array = [Vector2.ZERO, Vector2.ZERO, Vector2.ZERO]
# Export directory path and export file name
var directory_path := ""
var export_directory_path := ""
var file_name := "untitled"
var file_format := Export.FileFormat.PNG
var was_exported := false
@ -109,9 +109,9 @@ func _init(_frames: Array[Frame] = [], _name := tr("untitled"), _size := Vector2
Global.canvas.add_child(y_symmetry_axis)
if OS.get_name() == "Web":
directory_path = "user://"
export_directory_path = "user://"
else:
directory_path = Global.config_cache.get_value(
export_directory_path = Global.config_cache.get_value(
"data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
)
Global.project_created.emit(self)
@ -347,7 +347,7 @@ func serialize() -> Dictionary:
"brushes": brush_data,
"reference_images": reference_image_data,
"vanishing_points": vanishing_points,
"export_directory_path": directory_path,
"export_directory_path": export_directory_path,
"export_file_name": file_name,
"export_file_format": file_format,
"fps": fps,
@ -467,7 +467,7 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
for point in y_symmetry_axis.points.size():
y_symmetry_axis.points[point].x = floorf(x_symmetry_point / 2 + 1)
if dict.has("export_directory_path"):
directory_path = dict.export_directory_path
export_directory_path = dict.export_directory_path
if dict.has("export_file_name"):
file_name = dict.export_file_name
if dict.has("export_file_format"):

View file

@ -396,7 +396,7 @@ func _quit() -> void:
func _on_BackupConfirmation_confirmed(project_paths: Array, backup_paths: Array) -> void:
OpenSave.reload_backup_file(project_paths, backup_paths)
Global.current_project.file_name = OpenSave.current_save_paths[0].get_file().trim_suffix(".pxo")
Global.current_project.directory_path = OpenSave.current_save_paths[0].get_base_dir()
Global.current_project.export_directory_path = OpenSave.current_save_paths[0].get_base_dir()
Global.current_project.was_exported = false
Global.top_menu_container.file_menu.set_item_text(
Global.FileMenu.SAVE, tr("Save") + " %s" % OpenSave.current_save_paths[0].get_file()

View file

@ -276,18 +276,18 @@ func _on_ExportDialog_about_to_show() -> void:
# If we're on Web, don't let the user change the directory path
if OS.get_name() == "Web":
get_tree().call_group("NotHTML5", "hide")
project.directory_path = "user://"
project.export_directory_path = "user://"
if project.directory_path.is_empty():
project.directory_path = Global.config_cache.get_value(
if project.export_directory_path.is_empty():
project.export_directory_path = Global.config_cache.get_value(
"data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
)
# If export already occurred - sets GUI to show previous settings
options_resize.value = Export.resize
options_interpolation.selected = Export.interpolation
path_line_edit.text = project.directory_path
path_dialog_popup.current_dir = project.directory_path
path_line_edit.text = project.export_directory_path
path_dialog_popup.current_dir = project.export_directory_path
file_line_edit.text = project.file_name
file_format_options.selected = project.file_format
show_tab()
@ -359,7 +359,7 @@ func _on_PathButton_pressed() -> void:
func _on_PathLineEdit_text_changed(new_text: String) -> void:
Global.current_project.directory_path = new_text
Global.current_project.export_directory_path = new_text
func _on_FileLineEdit_text_changed(new_text: String) -> void:
@ -368,7 +368,7 @@ func _on_FileLineEdit_text_changed(new_text: String) -> void:
func _on_FileDialog_dir_selected(dir: String) -> void:
path_line_edit.text = dir
Global.current_project.directory_path = dir
Global.current_project.export_directory_path = dir
func _on_FileFormat_item_selected(idx: int) -> void: