mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Only popup a single files dialog for multiple files - implements #585
This replaces the previous behavior, which used to popup multiple dialogs for each existing file, making the users click "OK" for each exported image.
This commit is contained in:
parent
4989e3e33a
commit
5e90b740e7
|
@ -376,7 +376,8 @@ msgstr ""
|
||||||
msgid "File Exists, Overwrite?"
|
msgid "File Exists, Overwrite?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "File %s already exists. Overwrite?"
|
msgid "The following files already exist. Do you wish to overwrite them?\n"
|
||||||
|
"%s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Directory path is not valid!"
|
msgid "Directory path is not valid!"
|
||||||
|
|
|
@ -34,7 +34,7 @@ var was_exported := false
|
||||||
# Export coroutine signal
|
# Export coroutine signal
|
||||||
var stop_export := false
|
var stop_export := false
|
||||||
|
|
||||||
var file_exists_alert := "File %s already exists. Overwrite?"
|
var file_exists_alert := "The following files already exist. Do you wish to overwrite them?\n%s"
|
||||||
|
|
||||||
# Export progress variables
|
# Export progress variables
|
||||||
var export_progress_fraction := 0.0
|
var export_progress_fraction := 0.0
|
||||||
|
@ -165,34 +165,37 @@ func export_processed_images(
|
||||||
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 := []
|
||||||
|
var paths_of_existing_files := ""
|
||||||
for i in range(processed_images.size()):
|
for i in range(processed_images.size()):
|
||||||
stop_export = false
|
stop_export = false
|
||||||
var export_path := create_export_path(multiple_files, project, i + 1)
|
var export_path := create_export_path(multiple_files, project, i + 1)
|
||||||
# If user want to create new directory for each animation tag then check
|
# If the user wants to create a new directory for each animation tag then check
|
||||||
# if directories exist and create them if not
|
# if directories exist, and create them if not
|
||||||
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(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())
|
||||||
# Check if the file already exists
|
|
||||||
|
if not ignore_overwrites: # Check if the files already exist
|
||||||
var file_check: File = File.new()
|
var file_check: File = File.new()
|
||||||
if file_check.file_exists(export_path):
|
if file_check.file_exists(export_path):
|
||||||
# Ask user if they want to overwrite the file
|
if not paths_of_existing_files.empty():
|
||||||
if not was_exported or (was_exported and not ignore_overwrites):
|
paths_of_existing_files += "\n"
|
||||||
# Overwrite existing file?
|
paths_of_existing_files += export_path
|
||||||
export_dialog.open_file_exists_alert_popup(file_exists_alert % export_path)
|
|
||||||
# Stops the function until the user decides if they want to overwrite
|
|
||||||
yield(export_dialog, "resume_export_function")
|
|
||||||
if stop_export:
|
|
||||||
# User decided to stop export
|
|
||||||
return
|
|
||||||
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():
|
||||||
break
|
break
|
||||||
|
|
||||||
# Scale images that are to export
|
if not paths_of_existing_files.empty(): # If files already exist
|
||||||
|
# Ask user if they want to overwrite the files
|
||||||
|
export_dialog.open_file_exists_alert_popup(tr(file_exists_alert) % paths_of_existing_files)
|
||||||
|
# Stops the function until the user decides if they want to overwrite
|
||||||
|
yield(export_dialog, "resume_export_function")
|
||||||
|
if stop_export: # User decided to stop export
|
||||||
|
return
|
||||||
|
|
||||||
scale_processed_images()
|
scale_processed_images()
|
||||||
|
|
||||||
if is_single_file_format():
|
if is_single_file_format():
|
||||||
|
|
|
@ -213,13 +213,14 @@ func update_dimensions_label() -> void:
|
||||||
|
|
||||||
func open_path_validation_alert_popup(path_or_name: int = -1) -> void:
|
func open_path_validation_alert_popup(path_or_name: int = -1) -> void:
|
||||||
# 0 is invalid path, 1 is invalid name
|
# 0 is invalid path, 1 is invalid name
|
||||||
|
var error_text := "Directory path and file name are not valid!"
|
||||||
if path_or_name == 0:
|
if path_or_name == 0:
|
||||||
path_validation_alert_popup.dialog_text = "Directory path is not valid!"
|
error_text = "Directory path is not valid!"
|
||||||
elif path_or_name == 1:
|
elif path_or_name == 1:
|
||||||
path_validation_alert_popup.dialog_text = "File name is not valid!"
|
error_text = "File name is not valid!"
|
||||||
else:
|
|
||||||
path_validation_alert_popup.dialog_text = "Directory path and file name are not valid!"
|
|
||||||
|
|
||||||
|
path_validation_alert_popup.dialog_text = error_text
|
||||||
|
print(error_text)
|
||||||
path_validation_alert_popup.popup_centered()
|
path_validation_alert_popup.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,7 +261,6 @@ func _on_ExportDialog_about_to_show() -> void:
|
||||||
file_format_options.selected = Export.file_format
|
file_format_options.selected = Export.file_format
|
||||||
show_tab()
|
show_tab()
|
||||||
|
|
||||||
Export.file_exists_alert = tr("File %s already exists. Overwrite?") # Update translation
|
|
||||||
# Set the size of the preview checker
|
# Set the size of the preview checker
|
||||||
checker.rect_size = checker.get_parent().rect_size
|
checker.rect_size = checker.get_parent().rect_size
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue