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

Export multiple files in multiple directories feature (#217)

Co-authored-by: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com>
This commit is contained in:
Igor Santarek 2020-04-22 21:36:23 +02:00 committed by GitHub
parent 2d4d40c213
commit 8ac923c716
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1439 additions and 1377 deletions

View file

@ -1358,8 +1358,8 @@ resizable = true
mode = 0
access = 2
filters = PoolStringArray( "*.pxo ; Pixelorama Project" )
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
current_dir = "E:/Projekty/Godot/Pixelorama"
current_path = "E:/Projekty/Godot/Pixelorama/"
[node name="SaveSprite" type="FileDialog" parent="."]
anchor_left = 0.5
@ -1374,10 +1374,13 @@ window_title = "Save Sprite as .pxo"
resizable = true
access = 2
filters = PoolStringArray( "*.pxo ; Pixelorama Project" )
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
current_dir = "E:/Projekty/Godot/Pixelorama"
current_path = "E:/Projekty/Godot/Pixelorama/"
[node name="ImportSprites" parent="." instance=ExtResource( 29 )]
window_title = "Otwórz plik(i)"
current_dir = "E:/Projekty/Godot/Pixelorama"
current_path = "E:/Projekty/Godot/Pixelorama/"
[node name="ExportDialog" parent="." instance=ExtResource( 39 )]
@ -1427,6 +1430,7 @@ dialog_text = "This is an error message!"
[node name="PaletteImportFileDialog" parent="." instance=ExtResource( 37 )]
window_title = "Otwórz plik"
filters = PoolStringArray( "*.json ; JavaScript Object Notation", "*.gpl ; Gimp Palette Library", "*.png; Portable Network Graphics" )
current_file = "Pixelorama"
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects"
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/"

View file

@ -579,8 +579,6 @@ margin_bottom = 200.0
[node name="AnimationTimer" type="Timer" parent="."]
[node name="OnionSkinningSettings" type="WindowDialog" parent="."]
margin_right = 83.0
margin_bottom = 58.0
rect_min_size = Vector2( 136, 126 )
__meta__ = {
"_edit_use_anchors_": false

View file

@ -146,6 +146,14 @@ text = "All frames as multiple files"
items = [ "All frames as multiple files", null, false, 0, null, "All frames as a single file animation", null, false, 1, null ]
selected = 0
[node name="MultipleAnimationsDirectories" type="CheckBox" parent="VBoxContainer/AnimationOptions"]
visible = false
margin_top = 28.0
margin_right = 516.0
margin_bottom = 52.0
hint_tooltip = "Creates multiple files but every file is stored in different directory that corresponds to its frame tag"
text = "Create new directory for each frame tag"
[node name="AnimatedOptions" type="HBoxContainer" parent="VBoxContainer/AnimationOptions"]
margin_top = 28.0
margin_right = 516.0
@ -311,12 +319,12 @@ margin_bottom = 494.0
rect_min_size = Vector2( 440, 300 )
size_flags_horizontal = 0
size_flags_vertical = 0
window_title = "Open a Directory"
window_title = "Otwórz katalog"
resizable = true
mode = 2
access = 2
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
current_dir = "E:/Projekty/Godot/Pixelorama"
current_path = "E:/Projekty/Godot/Pixelorama/"
[node name="PathValidationAlert" type="AcceptDialog" parent="Popups"]
margin_left = 8.0
@ -325,6 +333,7 @@ margin_right = 448.0
margin_bottom = 280.0
size_flags_horizontal = 0
size_flags_vertical = 0
window_title = "Alarm!"
resizable = true
dialog_text = "Directory path or file name is not valid!"
__meta__ = {
@ -338,6 +347,7 @@ margin_right = 448.0
margin_bottom = 280.0
size_flags_horizontal = 0
size_flags_vertical = 0
window_title = "Alarm!"
resizable = true
dialog_text = "File %s already exists. Overwrite?"
__meta__ = {
@ -363,6 +373,7 @@ __meta__ = {
[connection signal="item_selected" from="VBoxContainer/SpritesheetOptions/Orientation/Orientation" to="." method="_on_Orientation_item_selected"]
[connection signal="value_changed" from="VBoxContainer/SpritesheetOptions/Orientation/LinesCount" to="." method="_on_LinesCount_value_changed"]
[connection signal="item_selected" from="VBoxContainer/AnimationOptions/AnimationType" to="." method="_on_AnimationType_item_selected"]
[connection signal="toggled" from="VBoxContainer/AnimationOptions/MultipleAnimationsDirectories" to="." method="_on_MultipleAnimationsDirectories_toggled"]
[connection signal="color_changed" from="VBoxContainer/AnimationOptions/AnimatedOptions/BackgroundColor" to="." method="_on_BackgroundColor_color_changed"]
[connection signal="item_selected" from="VBoxContainer/AnimationOptions/AnimatedOptions/Direction" to="." method="_on_Direction_item_selected"]
[connection signal="value_changed" from="VBoxContainer/Options/Resize" to="." method="_on_Resize_value_changed"]

View file

@ -25,6 +25,7 @@ var direction : int = AnimationDirection.Forward
# Options
var resize := 100
var interpolation := 0 # Image.Interpolation
var new_dir_for_each_frame_tag : bool = true # you don't need to store this after export
# Export directory path and export file name
var directory_path := ""
@ -255,6 +256,17 @@ func remove_previews() -> void:
child.free()
func get_proccessed_image_animation_tag_and_start_id(processed_image_id : int) -> Array:
var result_animation_tag_and_start_id = null
for animation_tag in Global.animation_tags:
# Check if processed image is in frame tag and assign frame tag and start id if yes
# Then stop
if (processed_image_id + 1) >= animation_tag[2] and (processed_image_id + 1) <= animation_tag[3]:
result_animation_tag_and_start_id = [animation_tag[0], animation_tag[2]]
break
return result_animation_tag_and_start_id
func export_processed_images(ignore_overwrites : bool) -> void:
# Stop export if directory path or file name are not valid
var dir = Directory.new()
@ -266,7 +278,14 @@ func export_processed_images(ignore_overwrites : bool) -> void:
var export_paths = []
for i in range(processed_images.size()):
stop_export = false
var export_path = create_export_path(true if (current_tab == ExportTab.Animation && animation_type == AnimationType.MultipleFiles) else false, i + 1)
var multiple_files := true if (current_tab == ExportTab.Animation && animation_type == AnimationType.MultipleFiles) else false
var export_path = create_export_path(multiple_files, i + 1)
# If user want to create new directory for each animation tag then check if directories exist and create them if not
if multiple_files and new_dir_for_each_frame_tag:
var frame_tag_directory := Directory.new()
if not frame_tag_directory.dir_exists(export_path.get_base_dir()):
frame_tag_directory.open(directory_path)
frame_tag_directory.make_dir(export_path.get_base_dir().get_file())
# Check if the file already exists
var fileCheck = File.new()
if fileCheck.file_exists(export_path):
@ -350,7 +369,26 @@ func create_export_path(multifile: bool, frame: int = 0) -> String:
var path = file_name
# Only append frame number when there are multiple files exported
if multifile:
path += "_" + String(frame)
var frame_tag_and_start_id = get_proccessed_image_animation_tag_and_start_id(frame - 1)
# Check if exported frame is in frame tag
if frame_tag_and_start_id != null:
var frame_tag = frame_tag_and_start_id[0]
var start_id = frame_tag_and_start_id[1]
# Remove unallowed characters in frame tag directory
var regex := RegEx.new()
regex.compile("[^a-zA-Z0-9_]+")
var frame_tag_dir = regex.sub(frame_tag, "", true)
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)
return directory_path.plus_file(frame_tag_dir).plus_file(path + file_format_string(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)
return directory_path.plus_file(path + file_format_string(file_format))
@ -370,12 +408,15 @@ func file_format_string(format_enum : int) -> String:
func set_file_format_selector() -> void:
$VBoxContainer/AnimationOptions/MultipleAnimationsDirectories.visible = false
match animation_type:
AnimationType.MultipleFiles:
file_format = FileFormat.PNG
$VBoxContainer/File/FileFormat.selected = FileFormat.PNG
$FrameTimer.stop()
$VBoxContainer/AnimationOptions/AnimatedOptions.hide()
$VBoxContainer/AnimationOptions/MultipleAnimationsDirectories.pressed = new_dir_for_each_frame_tag
$VBoxContainer/AnimationOptions/MultipleAnimationsDirectories.visible = true
AnimationType.Animated:
file_format = FileFormat.GIF
$VBoxContainer/File/FileFormat.selected = FileFormat.GIF
@ -577,3 +618,7 @@ func _on_FrameTimer_timeout() -> void:
func _on_ExportDialog_popup_hide() -> void:
$FrameTimer.stop()
func _on_MultipleAnimationsDirectories_toggled(button_pressed : bool) -> void:
new_dir_for_each_frame_tag = button_pressed

File diff suppressed because one or more lines are too long

View file

@ -1056,4 +1056,8 @@ msgstr ""
msgid "Opens last opened project on startup"
msgstr ""
msgid "Create new directory for each frame tag"
msgstr ""
msgid "Creates multiple files but every file is stored in different directory that corresponds to its frame tag"
msgstr ""