mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-07 10:59:49 +00:00
Remove duplicate project-specific variables from Export
Removed `directory_path`, `file_name`, `file_format` and `was_exported` from Export.gd. These variables already exist on Project.gd, no need to have them twice.
This commit is contained in:
parent
c50239ff18
commit
7e15fc9d15
|
@ -24,13 +24,6 @@ var resize := 100
|
||||||
var interpolation := 0 # Image.Interpolation
|
var interpolation := 0 # Image.Interpolation
|
||||||
var new_dir_for_each_frame_tag := false # we don't need to store this after export
|
var new_dir_for_each_frame_tag := false # we don't need to store this after export
|
||||||
|
|
||||||
# Export directory path and export file name
|
|
||||||
var directory_path := ""
|
|
||||||
var file_name := "untitled"
|
|
||||||
var file_format: int = FileFormat.PNG
|
|
||||||
|
|
||||||
var was_exported := false
|
|
||||||
|
|
||||||
# Export coroutine signal
|
# Export coroutine signal
|
||||||
var stop_export := false
|
var stop_export := false
|
||||||
|
|
||||||
|
@ -151,17 +144,17 @@ func export_processed_images(
|
||||||
) -> bool:
|
) -> bool:
|
||||||
# Stop export if directory path or file name are not valid
|
# Stop export if directory path or file name are not valid
|
||||||
var dir := Directory.new()
|
var dir := Directory.new()
|
||||||
if not dir.dir_exists(directory_path) or not file_name.is_valid_filename():
|
if not dir.dir_exists(project.directory_path) or not project.file_name.is_valid_filename():
|
||||||
if not dir.dir_exists(directory_path) and file_name.is_valid_filename():
|
if not dir.dir_exists(project.directory_path) and project.file_name.is_valid_filename():
|
||||||
export_dialog.open_path_validation_alert_popup(0)
|
export_dialog.open_path_validation_alert_popup(0)
|
||||||
elif not file_name.is_valid_filename() and dir.dir_exists(directory_path):
|
elif not project.file_name.is_valid_filename() and dir.dir_exists(project.directory_path):
|
||||||
export_dialog.open_path_validation_alert_popup(1)
|
export_dialog.open_path_validation_alert_popup(1)
|
||||||
else:
|
else:
|
||||||
export_dialog.open_path_validation_alert_popup()
|
export_dialog.open_path_validation_alert_popup()
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var multiple_files := false
|
var multiple_files := false
|
||||||
if current_tab == ExportTab.IMAGE and not is_single_file_format():
|
if current_tab == ExportTab.IMAGE and not is_single_file_format(project):
|
||||||
multiple_files = true if processed_images.size() > 1 else false
|
multiple_files = true if processed_images.size() > 1 else false
|
||||||
# Check export paths
|
# Check export paths
|
||||||
var export_paths := []
|
var export_paths := []
|
||||||
|
@ -174,7 +167,7 @@ func export_processed_images(
|
||||||
if multiple_files and new_dir_for_each_frame_tag:
|
if multiple_files and new_dir_for_each_frame_tag:
|
||||||
var frame_tag_directory := Directory.new()
|
var frame_tag_directory := Directory.new()
|
||||||
if not frame_tag_directory.dir_exists(export_path.get_base_dir()):
|
if not frame_tag_directory.dir_exists(export_path.get_base_dir()):
|
||||||
frame_tag_directory.open(directory_path)
|
frame_tag_directory.open(project.directory_path)
|
||||||
frame_tag_directory.make_dir(export_path.get_base_dir().get_file())
|
frame_tag_directory.make_dir(export_path.get_base_dir().get_file())
|
||||||
|
|
||||||
if not ignore_overwrites: # Check if the files already exist
|
if not ignore_overwrites: # Check if the files already exist
|
||||||
|
@ -185,7 +178,7 @@ func export_processed_images(
|
||||||
paths_of_existing_files += export_path
|
paths_of_existing_files += export_path
|
||||||
export_paths.append(export_path)
|
export_paths.append(export_path)
|
||||||
# Only get one export path if single file animated image is exported
|
# Only get one export path if single file animated image is exported
|
||||||
if is_single_file_format():
|
if is_single_file_format(project):
|
||||||
break
|
break
|
||||||
|
|
||||||
if not paths_of_existing_files.empty(): # If files already exist
|
if not paths_of_existing_files.empty(): # If files already exist
|
||||||
|
@ -198,9 +191,9 @@ func export_processed_images(
|
||||||
|
|
||||||
scale_processed_images()
|
scale_processed_images()
|
||||||
|
|
||||||
if is_single_file_format():
|
if is_single_file_format(project):
|
||||||
var exporter: BaseAnimationExporter
|
var exporter: BaseAnimationExporter
|
||||||
if file_format == FileFormat.APNG:
|
if project.file_format == FileFormat.APNG:
|
||||||
exporter = APNGAnimationExporter.new()
|
exporter = APNGAnimationExporter.new()
|
||||||
else:
|
else:
|
||||||
exporter = GIFAnimationExporter.new()
|
exporter = GIFAnimationExporter.new()
|
||||||
|
@ -232,19 +225,19 @@ func export_processed_images(
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
|
|
||||||
# Store settings for quick export and when the dialog is opened again
|
# Store settings for quick export and when the dialog is opened again
|
||||||
was_exported = true
|
var file_name_with_ext := project.file_name + file_format_string(project.file_format)
|
||||||
project.was_exported = true
|
project.was_exported = true
|
||||||
if project.export_overwrite:
|
if project.export_overwrite:
|
||||||
Global.top_menu_container.file_menu.set_item_text(
|
Global.top_menu_container.file_menu.set_item_text(
|
||||||
6, tr("Overwrite") + " %s" % (file_name + Export.file_format_string(file_format))
|
Global.FileMenu.EXPORT, tr("Overwrite") + " %s" % file_name_with_ext
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
Global.top_menu_container.file_menu.set_item_text(
|
Global.top_menu_container.file_menu.set_item_text(
|
||||||
6, tr("Export") + " %s" % (file_name + file_format_string(file_format))
|
Global.FileMenu.EXPORT, tr("Export") + " %s" % file_name_with_ext
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only show when not exporting gif - gif export finishes in thread
|
# Only show when not exporting gif - gif export finishes in thread
|
||||||
if not is_single_file_format():
|
if not is_single_file_format(project):
|
||||||
Global.notification_label("File(s) exported")
|
Global.notification_label("File(s) exported")
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
@ -318,14 +311,14 @@ func file_format_description(format_enum: int) -> String:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
func is_single_file_format(format_enum: int = file_format) -> bool:
|
func is_single_file_format(project := Global.current_project) -> bool:
|
||||||
# True when exporting to .gif and .apng (and potentially video formats in the future)
|
# True when exporting to .gif and .apng (and potentially video formats in the future)
|
||||||
# False when exporting to .png, and other non-animated formats in the future
|
# False when exporting to .png, and other non-animated formats in the future
|
||||||
return format_enum == FileFormat.GIF or format_enum == FileFormat.APNG
|
return project.file_format == FileFormat.GIF or project.file_format == FileFormat.APNG
|
||||||
|
|
||||||
|
|
||||||
func create_export_path(multifile: bool, project: Project, frame: int = 0) -> String:
|
func create_export_path(multifile: bool, project: Project, frame: int = 0) -> String:
|
||||||
var path := file_name
|
var path := project.file_name
|
||||||
# Only append frame number when there are multiple files exported
|
# Only append frame number when there are multiple files exported
|
||||||
if multifile:
|
if multifile:
|
||||||
var frame_tag_and_start_id := get_proccessed_image_animation_tag_and_start_id(
|
var frame_tag_and_start_id := get_proccessed_image_animation_tag_and_start_id(
|
||||||
|
@ -343,8 +336,8 @@ func create_export_path(multifile: bool, project: Project, frame: int = 0) -> St
|
||||||
# Add frame tag if frame has one
|
# Add frame tag if frame has one
|
||||||
# (frame - start_id + 1) Makes frames id to start from 1 in each frame tag directory
|
# (frame - start_id + 1) Makes frames id to start from 1 in each frame tag directory
|
||||||
path += "_" + frame_tag_dir + "_" + String(frame - start_id + 1)
|
path += "_" + frame_tag_dir + "_" + String(frame - start_id + 1)
|
||||||
return directory_path.plus_file(frame_tag_dir).plus_file(
|
return project.directory_path.plus_file(frame_tag_dir).plus_file(
|
||||||
path + file_format_string(file_format)
|
path + file_format_string(project.file_format)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Add frame tag if frame has one
|
# Add frame tag if frame has one
|
||||||
|
@ -353,7 +346,7 @@ func create_export_path(multifile: bool, project: Project, frame: int = 0) -> St
|
||||||
else:
|
else:
|
||||||
path += "_" + String(frame)
|
path += "_" + String(frame)
|
||||||
|
|
||||||
return directory_path.plus_file(path + file_format_string(file_format))
|
return project.directory_path.plus_file(path + file_format_string(project.file_format))
|
||||||
|
|
||||||
|
|
||||||
func get_proccessed_image_animation_tag_and_start_id(
|
func get_proccessed_image_animation_tag_and_start_id(
|
||||||
|
|
|
@ -148,13 +148,13 @@ func open_pxo_file(path: String, untitled_backup: bool = false, replace_empty: b
|
||||||
# Set last opened project path and save
|
# Set last opened project path and save
|
||||||
Global.config_cache.set_value("preferences", "last_project_path", path)
|
Global.config_cache.set_value("preferences", "last_project_path", path)
|
||||||
Global.config_cache.save("user://cache.ini")
|
Global.config_cache.save("user://cache.ini")
|
||||||
Export.file_name = path.get_file().trim_suffix(".pxo")
|
new_project.directory_path = path.get_base_dir()
|
||||||
Export.directory_path = path.get_base_dir()
|
new_project.file_name = path.get_file().trim_suffix(".pxo")
|
||||||
new_project.directory_path = Export.directory_path
|
new_project.was_exported = false
|
||||||
new_project.file_name = Export.file_name
|
Global.top_menu_container.file_menu.set_item_text(
|
||||||
Export.was_exported = false
|
Global.FileMenu.SAVE, tr("Save") + " %s" % path.get_file()
|
||||||
Global.top_menu_container.file_menu.set_item_text(4, tr("Save") + " %s" % path.get_file())
|
)
|
||||||
Global.top_menu_container.file_menu.set_item_text(6, tr("Export"))
|
Global.top_menu_container.file_menu.set_item_text(Global.FileMenu.EXPORT, tr("Export"))
|
||||||
|
|
||||||
save_project_to_recent_list(path)
|
save_project_to_recent_list(path)
|
||||||
|
|
||||||
|
@ -396,9 +396,11 @@ func save_pxo_file(
|
||||||
Global.config_cache.set_value("preferences", "last_project_path", path)
|
Global.config_cache.set_value("preferences", "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:
|
||||||
Export.file_name = path.get_file().trim_suffix(".pxo")
|
project.file_name = path.get_file().trim_suffix(".pxo")
|
||||||
Export.directory_path = path.get_base_dir()
|
project.directory_path = path.get_base_dir()
|
||||||
Global.top_menu_container.file_menu.set_item_text(4, tr("Save") + " %s" % path.get_file())
|
Global.top_menu_container.file_menu.set_item_text(
|
||||||
|
Global.FileMenu.SAVE, tr("Save") + " %s" % path.get_file()
|
||||||
|
)
|
||||||
|
|
||||||
save_project_to_recent_list(path)
|
save_project_to_recent_list(path)
|
||||||
|
|
||||||
|
@ -635,9 +637,6 @@ func set_new_imported_tab(project: Project, path: String) -> void:
|
||||||
project.was_exported = true
|
project.was_exported = true
|
||||||
if path.get_extension().to_lower() == "png":
|
if path.get_extension().to_lower() == "png":
|
||||||
project.export_overwrite = true
|
project.export_overwrite = true
|
||||||
Export.directory_path = directory_path
|
|
||||||
Export.file_name = file_name
|
|
||||||
Export.was_exported = true
|
|
||||||
|
|
||||||
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
|
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
|
||||||
Global.canvas.camera_zoom()
|
Global.canvas.camera_zoom()
|
||||||
|
|
|
@ -194,26 +194,23 @@ func change_project() -> void:
|
||||||
Global.open_sprites_dialog.current_path = save_path
|
Global.open_sprites_dialog.current_path = save_path
|
||||||
Global.save_sprites_dialog.current_path = save_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(
|
||||||
4, tr("Save") + " %s" % save_path.get_file()
|
Global.FileMenu.SAVE, tr("Save") + " %s" % save_path.get_file()
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
Global.top_menu_container.file_menu.set_item_text(4, tr("Save"))
|
Global.top_menu_container.file_menu.set_item_text(Global.FileMenu.SAVE, tr("Save"))
|
||||||
|
|
||||||
Export.directory_path = directory_path
|
|
||||||
Export.file_name = file_name
|
|
||||||
Export.file_format = file_format
|
|
||||||
Export.was_exported = was_exported
|
|
||||||
|
|
||||||
if !was_exported:
|
if !was_exported:
|
||||||
Global.top_menu_container.file_menu.set_item_text(6, tr("Export"))
|
Global.top_menu_container.file_menu.set_item_text(Global.FileMenu.EXPORT, tr("Export"))
|
||||||
else:
|
else:
|
||||||
if export_overwrite:
|
if export_overwrite:
|
||||||
Global.top_menu_container.file_menu.set_item_text(
|
Global.top_menu_container.file_menu.set_item_text(
|
||||||
6, tr("Overwrite") + " %s" % (file_name + Export.file_format_string(file_format))
|
Global.FileMenu.EXPORT,
|
||||||
|
tr("Overwrite") + " %s" % (file_name + Export.file_format_string(file_format))
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
Global.top_menu_container.file_menu.set_item_text(
|
Global.top_menu_container.file_menu.set_item_text(
|
||||||
6, tr("Export") + " %s" % (file_name + Export.file_format_string(file_format))
|
Global.FileMenu.EXPORT,
|
||||||
|
tr("Export") + " %s" % (file_name + Export.file_format_string(file_format))
|
||||||
)
|
)
|
||||||
|
|
||||||
for j in Tiles.MODE.values():
|
for j in Tiles.MODE.values():
|
||||||
|
|
10
src/Main.gd
10
src/Main.gd
|
@ -364,13 +364,13 @@ func _quit() -> void:
|
||||||
|
|
||||||
func _on_BackupConfirmation_confirmed(project_paths: Array, backup_paths: Array) -> void:
|
func _on_BackupConfirmation_confirmed(project_paths: Array, backup_paths: Array) -> void:
|
||||||
OpenSave.reload_backup_file(project_paths, backup_paths)
|
OpenSave.reload_backup_file(project_paths, backup_paths)
|
||||||
Export.file_name = OpenSave.current_save_paths[0].get_file().trim_suffix(".pxo")
|
Global.current_project.file_name = OpenSave.current_save_paths[0].get_file().trim_suffix(".pxo")
|
||||||
Export.directory_path = OpenSave.current_save_paths[0].get_base_dir()
|
Global.current_project.directory_path = OpenSave.current_save_paths[0].get_base_dir()
|
||||||
Export.was_exported = false
|
Global.current_project.was_exported = false
|
||||||
Global.top_menu_container.file_menu.set_item_text(
|
Global.top_menu_container.file_menu.set_item_text(
|
||||||
4, tr("Save") + " %s" % OpenSave.current_save_paths[0].get_file()
|
Global.FileMenu.SAVE, tr("Save") + " %s" % OpenSave.current_save_paths[0].get_file()
|
||||||
)
|
)
|
||||||
Global.top_menu_container.file_menu.set_item_text(6, tr("Export"))
|
Global.top_menu_container.file_menu.set_item_text(Global.FileMenu.EXPORT, tr("Export"))
|
||||||
|
|
||||||
|
|
||||||
func _on_BackupConfirmation_custom_action(
|
func _on_BackupConfirmation_custom_action(
|
||||||
|
|
|
@ -165,16 +165,17 @@ func set_file_format_selector() -> void:
|
||||||
# Updates the suitable list of file formats. First is preferred.
|
# Updates the suitable list of file formats. First is preferred.
|
||||||
# Note that if the current format is in the list, it stays for consistency.
|
# Note that if the current format is in the list, it stays for consistency.
|
||||||
func _set_file_format_selector_suitable_file_formats(formats: Array) -> void:
|
func _set_file_format_selector_suitable_file_formats(formats: Array) -> void:
|
||||||
|
var project: Project = Global.current_project
|
||||||
file_format_options.clear()
|
file_format_options.clear()
|
||||||
var needs_update := true
|
var needs_update := true
|
||||||
for i in formats:
|
for i in formats:
|
||||||
if Export.file_format == i:
|
if project.file_format == i:
|
||||||
needs_update = false
|
needs_update = false
|
||||||
var label := Export.file_format_string(i) + "; " + Export.file_format_description(i)
|
var label := Export.file_format_string(i) + "; " + Export.file_format_description(i)
|
||||||
file_format_options.add_item(label, i)
|
file_format_options.add_item(label, i)
|
||||||
if needs_update:
|
if needs_update:
|
||||||
Export.file_format = formats[0]
|
project.file_format = formats[0]
|
||||||
file_format_options.selected = file_format_options.get_item_index(Export.file_format)
|
file_format_options.selected = file_format_options.get_item_index(project.file_format)
|
||||||
|
|
||||||
|
|
||||||
func create_frame_tag_list() -> void:
|
func create_frame_tag_list() -> void:
|
||||||
|
@ -242,23 +243,24 @@ func set_export_progress_bar(value: float) -> void:
|
||||||
|
|
||||||
func _on_ExportDialog_about_to_show() -> void:
|
func _on_ExportDialog_about_to_show() -> void:
|
||||||
Global.canvas.selection.transform_content_confirm()
|
Global.canvas.selection.transform_content_confirm()
|
||||||
|
var project: Project = Global.current_project
|
||||||
# If we're on HTML5, don't let the user change the directory path
|
# If we're on HTML5, don't let the user change the directory path
|
||||||
if OS.get_name() == "HTML5":
|
if OS.get_name() == "HTML5":
|
||||||
get_tree().call_group("NotHTML5", "hide")
|
get_tree().call_group("NotHTML5", "hide")
|
||||||
Export.directory_path = "user://"
|
project.directory_path = "user://"
|
||||||
|
|
||||||
if Export.directory_path.empty():
|
if project.directory_path.empty():
|
||||||
Export.directory_path = Global.config_cache.get_value(
|
project.directory_path = Global.config_cache.get_value(
|
||||||
"data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
|
"data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
|
||||||
)
|
)
|
||||||
|
|
||||||
# If export already occurred - sets GUI to show previous settings
|
# If export already occurred - sets GUI to show previous settings
|
||||||
options_resize.value = Export.resize
|
options_resize.value = Export.resize
|
||||||
options_interpolation.selected = Export.interpolation
|
options_interpolation.selected = Export.interpolation
|
||||||
path_line_edit.text = Export.directory_path
|
path_line_edit.text = project.directory_path
|
||||||
path_dialog_popup.current_dir = Export.directory_path
|
path_dialog_popup.current_dir = project.directory_path
|
||||||
file_line_edit.text = Export.file_name
|
file_line_edit.text = project.file_name
|
||||||
file_format_options.selected = Export.file_format
|
file_format_options.selected = project.file_format
|
||||||
show_tab()
|
show_tab()
|
||||||
|
|
||||||
# Set the size of the preview checker
|
# Set the size of the preview checker
|
||||||
|
@ -317,24 +319,20 @@ func _on_PathButton_pressed() -> void:
|
||||||
|
|
||||||
func _on_PathLineEdit_text_changed(new_text: String) -> void:
|
func _on_PathLineEdit_text_changed(new_text: String) -> void:
|
||||||
Global.current_project.directory_path = new_text
|
Global.current_project.directory_path = new_text
|
||||||
Export.directory_path = new_text
|
|
||||||
|
|
||||||
|
|
||||||
func _on_FileLineEdit_text_changed(new_text: String) -> void:
|
func _on_FileLineEdit_text_changed(new_text: String) -> void:
|
||||||
Global.current_project.file_name = new_text
|
Global.current_project.file_name = new_text
|
||||||
Export.file_name = new_text
|
|
||||||
|
|
||||||
|
|
||||||
func _on_FileDialog_dir_selected(dir: String) -> void:
|
func _on_FileDialog_dir_selected(dir: String) -> void:
|
||||||
path_line_edit.text = dir
|
path_line_edit.text = dir
|
||||||
Global.current_project.directory_path = dir
|
Global.current_project.directory_path = dir
|
||||||
Export.directory_path = dir
|
|
||||||
|
|
||||||
|
|
||||||
func _on_FileFormat_item_selected(idx: int) -> void:
|
func _on_FileFormat_item_selected(idx: int) -> void:
|
||||||
var id := file_format_options.get_item_id(idx)
|
var id := file_format_options.get_item_id(idx)
|
||||||
Global.current_project.file_format = id
|
Global.current_project.file_format = id
|
||||||
Export.file_format = id
|
|
||||||
if not Export.is_single_file_format():
|
if not Export.is_single_file_format():
|
||||||
multiple_animations_directories.disabled = false
|
multiple_animations_directories.disabled = false
|
||||||
frame_timer.stop()
|
frame_timer.stop()
|
||||||
|
|
|
@ -392,7 +392,7 @@ func _save_project_file_as() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _export_file() -> void:
|
func _export_file() -> void:
|
||||||
if Export.was_exported == false:
|
if Global.current_project.was_exported == false:
|
||||||
_popup_dialog(Global.export_dialog)
|
_popup_dialog(Global.export_dialog)
|
||||||
else:
|
else:
|
||||||
Export.external_export()
|
Export.external_export()
|
||||||
|
|
Loading…
Reference in a new issue