1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-20 12:33:14 +00:00

Add export dialog options for including the tag names in the file names, and the ability to change the separator character

The frame number digit count is now 4, so for example exported files are being named as "name_0001.png", "name_0002.png", ... "name_0010.png" and so on. The tag name is now not included in the file name by default.
This commit is contained in:
Emmanouil Papadeas 2023-06-16 04:16:19 +03:00
parent ea931c0e53
commit 494673e7bc
4 changed files with 75 additions and 24 deletions

View file

@ -813,9 +813,6 @@ msgstr ""
msgid "Center:"
msgstr ""
msgid "Radius:"
msgstr ""
msgid "Dithering pattern:"
msgstr ""
@ -2112,13 +2109,25 @@ msgid "minute(s)"
msgstr ""
#. Found in the export dialog.
msgid "Create new folder for each frame tag"
msgid "Include frame tags in the file name"
msgstr ""
#. Found in the export dialog.
msgid "Create new folder for each frame tag"
msgstr ""
#. Found in the export dialog, as a hint tooltip of the "Create new folder for each frame tag" button
msgid "Creates multiple files but every file is stored in different folder that corresponds to its frame tag"
msgstr ""
#. Found in the export dialog. Refers to text characters that acts as separators between text. For example, the "_" in "name_0001".
msgid "Separator character(s):"
msgstr ""
#. Found in the export dialog, as a hint tooltip of the separator character(s) text field.
msgid "The character(s) that separate the file name and the frame number"
msgstr ""
msgid "Close"
msgstr ""

View file

@ -28,7 +28,10 @@ var number_of_frames := 1
var direction: int = AnimationDirection.FORWARD
var resize := 100
var interpolation := 0 # Image.Interpolation
var include_tag_in_filename := false
var new_dir_for_each_frame_tag := false # we don't need to store this after export
var number_of_digits := 4
var separator_character := "_"
# Export coroutine signal
var stop_export := false
@ -47,7 +50,7 @@ func _exit_tree() -> void:
func add_file_format(name: String) -> int:
var id = FileFormat.size()
var id := FileFormat.size()
FileFormat.merge({name: id})
return id
@ -380,6 +383,7 @@ func create_export_path(multifile: bool, project: Project, frame: int = 0) -> St
var path := project.file_name
# Only append frame number when there are multiple files exported
if multifile:
var path_extras := separator_character + String(frame).pad_zeros(number_of_digits)
var frame_tag_and_start_id := get_proccessed_image_animation_tag_and_start_id(
project, frame - 1
)
@ -391,19 +395,21 @@ func create_export_path(multifile: bool, project: Project, frame: int = 0) -> St
var regex := RegEx.new()
regex.compile("[^a-zA-Z0-9_]+")
var frame_tag_dir := regex.sub(frame_tag, "", true)
if include_tag_in_filename:
# (frame - start_id + 1) makes frames id to start from 1
var tag_frame_number := String(frame - start_id + 1).pad_zeros(number_of_digits)
path_extras = (
separator_character
+ frame_tag_dir
+ separator_character
+ tag_frame_number
)
if new_dir_for_each_frame_tag:
# Add frame tag if frame has one
# (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 += path_extras
return project.directory_path.plus_file(frame_tag_dir).plus_file(
path + file_format_string(project.file_format)
)
else:
# Add frame tag if frame has one
# (frame - start_id + 1) Makes frames id to start from 1 in each frame tag
path += "_" + frame_tag_dir + "_" + String(frame - start_id + 1)
else:
path += "_" + String(frame)
path += path_extras
return project.directory_path.plus_file(path + file_format_string(project.file_format))

View file

@ -27,7 +27,6 @@ onready var path_line_edit: LineEdit = $"%PathLineEdit"
onready var file_line_edit: LineEdit = $"%FileLineEdit"
onready var file_format_options: OptionButton = $"%FileFormat"
onready var multiple_animations_directories: CheckBox = $"%MultipleAnimationsDirectories"
onready var options_interpolation: OptionButton = $"%Interpolation"
onready var file_exists_alert_popup: AcceptDialog = $Popups/FileExistsAlert
@ -64,7 +63,12 @@ func show_tab() -> void:
Export.ExportTab.IMAGE:
Export.process_animation()
get_tree().call_group("ExportImageOptions", "show")
multiple_animations_directories.disabled = Export.is_single_file_format()
get_tree().set_group(
"ExportMultipleFilesOptions", "disabled", Export.is_single_file_format()
)
get_tree().set_group(
"ExportMultipleFilesEditableOptions", "editable", !Export.is_single_file_format()
)
Export.ExportTab.SPRITESHEET:
frame_timer.stop()
Export.process_spritesheet()
@ -348,10 +352,12 @@ func _on_FileFormat_item_selected(idx: int) -> void:
var id := file_format_options.get_item_id(idx)
Global.current_project.file_format = id
if not Export.is_single_file_format():
multiple_animations_directories.disabled = false
get_tree().set_group("ExportMultipleFilesOptions", "disabled", false)
get_tree().set_group("ExportMultipleFilesEditableOptions", "editable", true)
frame_timer.stop()
else:
multiple_animations_directories.disabled = true
get_tree().set_group("ExportMultipleFilesOptions", "disabled", true)
get_tree().set_group("ExportMultipleFilesEditableOptions", "editable", false)
set_preview()
@ -390,6 +396,10 @@ func _on_ExportDialog_popup_hide() -> void:
frame_timer.stop()
func _on_IncludeTagsInFilename_toggled(button_pressed: bool) -> void:
Export.include_tag_in_filename = button_pressed
func _on_MultipleAnimationsDirectories_toggled(button_pressed: bool) -> void:
Export.new_dir_for_each_frame_tag = button_pressed
@ -406,3 +416,7 @@ func _on_Layers_item_selected(id: int) -> void:
Export.export_layers = id
Export.process_data()
set_preview()
func _on_SeparatorCharacter_text_changed(new_text: String) -> void:
Export.separator_character = new_text

View file

@ -335,16 +335,36 @@ text = "Nearest"
items = [ "Nearest", null, false, 0, null, "Bilinear", null, false, 1, null, "Cubic", null, false, 2, null, "Trilinear", null, false, 3, null, "Lanczos", null, false, 4, null ]
selected = 0
[node name="MultipleAnimationsDirectories" type="CheckBox" parent="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer" groups=["ExportImageOptions"]]
unique_name_in_owner = true
visible = false
margin_top = 48.0
[node name="IncludeTagsInFilename" type="CheckBox" parent="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/GridContainer" groups=["ExportImageOptions", "ExportMultipleFilesOptions"]]
margin_top = 24.0
margin_right = 516.0
margin_bottom = 72.0
margin_bottom = 48.0
mouse_default_cursor_shape = 2
text = "Include frame tags in the file name"
[node name="MultipleAnimationsDirectories" type="CheckBox" parent="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/GridContainer" groups=["ExportImageOptions", "ExportMultipleFilesOptions"]]
visible = false
margin_top = 24.0
margin_right = 516.0
margin_bottom = 48.0
hint_tooltip = "Creates multiple files but every file is stored in different folder that corresponds to its frame tag"
mouse_default_cursor_shape = 2
text = "Create new folder for each frame tag"
[node name="SeparatorCharacterLabel" type="Label" parent="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/GridContainer" groups=["ExportImageOptions"]]
margin_top = 3.0
margin_right = 256.0
margin_bottom = 17.0
rect_min_size = Vector2( 30, 0 )
size_flags_horizontal = 3
text = "Separator character(s):"
[node name="SeparatorCharacter" type="LineEdit" parent="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/GridContainer" groups=["ExportImageOptions", "ExportMultipleFilesEditableOptions"]]
margin_right = 58.0
margin_bottom = 24.0
hint_tooltip = "The character(s) that separate the file name and the frame number"
text = "_"
[node name="Popups" type="Control" parent="."]
margin_left = 8.0
margin_top = 8.0
@ -446,7 +466,9 @@ __meta__ = {
[connection signal="item_selected" from="VBoxContainer/VSplitContainer/VBoxContainer/FilePath/FileFormat" to="." method="_on_FileFormat_item_selected"]
[connection signal="meta_clicked" from="VBoxContainer/VSplitContainer/VBoxContainer/GifWarning" to="." method="_on_GifWarning_meta_clicked"]
[connection signal="item_selected" from="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/GridContainer/Interpolation" to="." method="_on_Interpolation_item_selected"]
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/MultipleAnimationsDirectories" to="." method="_on_MultipleAnimationsDirectories_toggled"]
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/GridContainer/IncludeTagsInFilename" to="." method="_on_IncludeTagsInFilename_toggled"]
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/GridContainer/MultipleAnimationsDirectories" to="." method="_on_MultipleAnimationsDirectories_toggled"]
[connection signal="text_changed" from="VBoxContainer/VSplitContainer/VBoxContainer/CollapsibleContainer/GridContainer/SeparatorCharacter" to="." method="_on_SeparatorCharacter_text_changed"]
[connection signal="dir_selected" from="Popups/PathDialog" to="." method="_on_FileDialog_dir_selected"]
[connection signal="confirmed" from="Popups/FileExistsAlert" to="." method="_on_FileExistsAlert_confirmed"]
[connection signal="custom_action" from="Popups/FileExistsAlert" to="." method="_on_FileExistsAlert_custom_action"]