2020-03-23 22:09:37 +00:00
|
|
|
extends AcceptDialog
|
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
# called when user resumes export after filename collision
|
2020-03-23 22:09:37 +00:00
|
|
|
signal resume_export_function()
|
|
|
|
|
2020-04-06 16:51:47 +00:00
|
|
|
var animated_preview_current_frame := 0
|
|
|
|
var animated_preview_frames = []
|
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
onready var tabs = $VBoxContainer/Tabs
|
|
|
|
onready var popups = $Popups
|
|
|
|
onready var file_exists_alert_popup = $Popups/FileExistsAlert
|
|
|
|
onready var path_validation_alert_popup = $Popups/PathValidationAlert
|
|
|
|
onready var path_dialog_popup = $Popups/PathDialog
|
2020-08-07 05:13:04 +00:00
|
|
|
onready var export_progress_popup = $Popups/ExportProgressBar
|
|
|
|
onready var export_progress_bar = $Popups/ExportProgressBar/MarginContainer/ProgressBar
|
2020-07-31 20:26:52 +00:00
|
|
|
|
2020-08-07 05:13:04 +00:00
|
|
|
onready var animation_options_multiple_animations_directories = $VBoxContainer/AnimationOptions/MultipleAnimationsDirectories
|
2020-08-26 09:45:32 +00:00
|
|
|
onready var previews = $VBoxContainer/PreviewPanel/PreviewScroll/Previews
|
2020-08-07 05:13:04 +00:00
|
|
|
onready var frame_timer = $FrameTimer
|
2020-07-31 20:26:52 +00:00
|
|
|
|
|
|
|
onready var frame_options = $VBoxContainer/FrameOptions
|
|
|
|
onready var frame_options_frame_number = $VBoxContainer/FrameOptions/FrameNumber/FrameNumber
|
|
|
|
|
|
|
|
onready var spritesheet_options = $VBoxContainer/SpritesheetOptions
|
|
|
|
onready var spritesheet_options_frames = $VBoxContainer/SpritesheetOptions/Frames/Frames
|
|
|
|
onready var spritesheet_options_orientation = $VBoxContainer/SpritesheetOptions/Orientation/Orientation
|
|
|
|
onready var spritesheet_options_lines_count = $VBoxContainer/SpritesheetOptions/Orientation/LinesCount
|
|
|
|
onready var spritesheet_options_lines_count_label = $VBoxContainer/SpritesheetOptions/Orientation/LinesCountLabel
|
|
|
|
|
|
|
|
onready var animation_options = $VBoxContainer/AnimationOptions
|
|
|
|
onready var animation_options_animation_type = $VBoxContainer/AnimationOptions/AnimationType
|
|
|
|
onready var animation_options_animation_options = $VBoxContainer/AnimationOptions/AnimatedOptions
|
|
|
|
onready var animation_options_direction = $VBoxContainer/AnimationOptions/AnimatedOptions/Direction
|
|
|
|
|
|
|
|
|
|
|
|
onready var options_resize = $VBoxContainer/Options/Resize
|
|
|
|
onready var options_interpolation = $VBoxContainer/Options/Interpolation
|
|
|
|
onready var path_container = $VBoxContainer/Path
|
|
|
|
onready var path_line_edit = $VBoxContainer/Path/PathLineEdit
|
|
|
|
onready var file_line_edit = $VBoxContainer/File/FileLineEdit
|
|
|
|
onready var file_file_format = $VBoxContainer/File/FileFormat
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _ready() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
tabs.add_tab("Frame")
|
|
|
|
tabs.add_tab("Spritesheet")
|
|
|
|
tabs.add_tab("Animation")
|
2020-03-25 16:22:29 +00:00
|
|
|
if OS.get_name() == "Windows":
|
|
|
|
add_button("Cancel", true, "cancel")
|
2020-07-31 20:26:52 +00:00
|
|
|
file_exists_alert_popup.add_button("Cancel Export", true, "cancel")
|
2020-03-25 16:22:29 +00:00
|
|
|
else:
|
|
|
|
add_button("Cancel", false, "cancel")
|
2020-07-31 20:26:52 +00:00
|
|
|
file_exists_alert_popup.add_button("Cancel Export", false, "cancel")
|
2020-03-23 22:09:37 +00:00
|
|
|
|
2020-08-07 05:13:04 +00:00
|
|
|
# Remove close button from export progress bar
|
|
|
|
export_progress_popup.get_close_button().hide()
|
2020-04-06 16:51:47 +00:00
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func show_tab() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
frame_options.hide()
|
|
|
|
spritesheet_options.hide()
|
|
|
|
animation_options.hide()
|
|
|
|
|
|
|
|
match Export.current_tab:
|
|
|
|
Export.ExportTab.FRAME:
|
|
|
|
Export.file_format = Export.FileFormat.PNG
|
|
|
|
file_file_format.selected = Export.FileFormat.PNG
|
|
|
|
frame_timer.stop()
|
|
|
|
if not Export.was_exported:
|
|
|
|
Export.frame_number = Global.current_project.current_frame + 1
|
|
|
|
frame_options_frame_number.max_value = Global.current_project.frames.size() + 1
|
|
|
|
var prev_frame_number = frame_options_frame_number.value
|
|
|
|
frame_options_frame_number.value = Export.frame_number
|
|
|
|
if prev_frame_number == Export.frame_number:
|
|
|
|
Export.process_frame()
|
|
|
|
frame_options.show()
|
|
|
|
Export.ExportTab.SPRITESHEET:
|
2020-05-08 23:46:51 +00:00
|
|
|
create_frame_tag_list()
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.file_format = Export.FileFormat.PNG
|
|
|
|
if not Export.was_exported:
|
|
|
|
Export.orientation = Export.Orientation.ROWS
|
|
|
|
Export.lines_count = int(ceil(sqrt(Export.number_of_frames)))
|
|
|
|
Export.process_spritesheet()
|
|
|
|
file_file_format.selected = Export.FileFormat.PNG
|
|
|
|
spritesheet_options_frames.select(Export.frame_current_tag)
|
|
|
|
frame_timer.stop()
|
|
|
|
spritesheet_options_orientation.selected = Export.orientation
|
|
|
|
spritesheet_options_lines_count.max_value = Export.number_of_frames
|
|
|
|
spritesheet_options_lines_count.value = Export.lines_count
|
|
|
|
spritesheet_options_lines_count_label.text = "Columns:"
|
|
|
|
spritesheet_options.show()
|
|
|
|
Export.ExportTab.ANIMATION:
|
2020-04-06 16:51:47 +00:00
|
|
|
set_file_format_selector()
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.process_animation()
|
|
|
|
animation_options_animation_type.selected = Export.animation_type
|
|
|
|
animation_options_direction.selected = Export.direction
|
|
|
|
animation_options.show()
|
2020-03-23 22:09:37 +00:00
|
|
|
set_preview()
|
2020-07-31 20:26:52 +00:00
|
|
|
tabs.current_tab = Export.current_tab
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
func set_preview() -> void:
|
|
|
|
remove_previews()
|
2020-07-31 20:26:52 +00:00
|
|
|
if Export.processed_images.size() == 1 and Export.current_tab != Export.ExportTab.ANIMATION:
|
|
|
|
previews.columns = 1
|
|
|
|
add_image_preview(Export.processed_images[0])
|
2020-03-23 22:09:37 +00:00
|
|
|
else:
|
2020-07-31 20:26:52 +00:00
|
|
|
match Export.animation_type:
|
|
|
|
Export.AnimationType.MULTIPLE_FILES:
|
|
|
|
previews.columns = ceil(sqrt(Export.processed_images.size()))
|
|
|
|
for i in range(Export.processed_images.size()):
|
|
|
|
add_image_preview(Export.processed_images[i], i + 1)
|
|
|
|
Export.AnimationType.ANIMATED:
|
|
|
|
previews.columns = 1
|
2020-04-06 16:51:47 +00:00
|
|
|
add_animated_preview()
|
|
|
|
|
|
|
|
|
|
|
|
func add_image_preview(image: Image, canvas_number: int = -1) -> void:
|
|
|
|
var container = create_preview_container()
|
|
|
|
var preview = create_preview_rect()
|
|
|
|
preview.texture = ImageTexture.new()
|
|
|
|
preview.texture.create_from_image(image, 0)
|
|
|
|
container.add_child(preview)
|
|
|
|
|
|
|
|
if canvas_number != -1:
|
|
|
|
var label = Label.new()
|
|
|
|
label.align = Label.ALIGN_CENTER
|
|
|
|
label.text = String(canvas_number)
|
|
|
|
container.add_child(label)
|
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
previews.add_child(container)
|
2020-04-06 16:51:47 +00:00
|
|
|
|
2020-03-23 22:09:37 +00:00
|
|
|
|
2020-04-06 16:51:47 +00:00
|
|
|
func add_animated_preview() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
animated_preview_current_frame = Export.processed_images.size() - 1 if Export.direction == Export.AnimationDirection.BACKWARDS else 0
|
2020-04-06 16:51:47 +00:00
|
|
|
animated_preview_frames = []
|
2020-03-23 22:09:37 +00:00
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
for processed_image in Export.processed_images:
|
2020-04-06 16:51:47 +00:00
|
|
|
var texture = ImageTexture.new()
|
|
|
|
texture.create_from_image(processed_image, 0)
|
|
|
|
animated_preview_frames.push_back(texture)
|
|
|
|
|
|
|
|
var container = create_preview_container()
|
|
|
|
container.name = "PreviewContainer"
|
|
|
|
var preview = create_preview_rect()
|
|
|
|
preview.name = "Preview"
|
|
|
|
preview.texture = animated_preview_frames[animated_preview_current_frame]
|
|
|
|
container.add_child(preview)
|
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
previews.add_child(container)
|
2020-10-19 14:57:40 +00:00
|
|
|
frame_timer.set_one_shot(true) #The wait_time it can't change correctly if it is playing
|
2020-12-16 20:54:08 +00:00
|
|
|
frame_timer.wait_time = Global.current_project.frames[animated_preview_current_frame].duration * (1 / Global.animation_timeline.fps)
|
2020-07-31 20:26:52 +00:00
|
|
|
frame_timer.start()
|
2020-04-06 16:51:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
func create_preview_container() -> VBoxContainer:
|
2020-03-23 22:09:37 +00:00
|
|
|
var container = VBoxContainer.new()
|
|
|
|
container.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
container.size_flags_vertical = SIZE_EXPAND_FILL
|
|
|
|
container.rect_min_size = Vector2(0, 128)
|
2020-04-06 16:51:47 +00:00
|
|
|
return container
|
|
|
|
|
2020-03-23 22:09:37 +00:00
|
|
|
|
2020-04-06 16:51:47 +00:00
|
|
|
func create_preview_rect() -> TextureRect:
|
2020-03-23 22:09:37 +00:00
|
|
|
var preview = TextureRect.new()
|
|
|
|
preview.expand = true
|
|
|
|
preview.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
|
|
preview.size_flags_vertical = SIZE_EXPAND_FILL
|
|
|
|
preview.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
2020-04-06 16:51:47 +00:00
|
|
|
return preview
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func remove_previews() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
for child in previews.get_children():
|
2020-04-06 16:51:47 +00:00
|
|
|
child.free()
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-04-06 16:51:47 +00:00
|
|
|
func set_file_format_selector() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
animation_options_multiple_animations_directories.visible = false
|
|
|
|
match Export.animation_type:
|
|
|
|
Export.AnimationType.MULTIPLE_FILES:
|
|
|
|
Export.file_format = Export.FileFormat.PNG
|
|
|
|
file_file_format.selected = Export.FileFormat.PNG
|
|
|
|
frame_timer.stop()
|
|
|
|
animation_options_animation_options.hide()
|
|
|
|
animation_options_multiple_animations_directories.pressed = Export.new_dir_for_each_frame_tag
|
|
|
|
animation_options_multiple_animations_directories.visible = true
|
|
|
|
Export.AnimationType.ANIMATED:
|
|
|
|
Export.file_format = Export.FileFormat.GIF
|
|
|
|
file_file_format.selected = Export.FileFormat.GIF
|
|
|
|
animation_options_animation_options.show()
|
2020-04-06 16:51:47 +00:00
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2020-05-08 23:46:51 +00:00
|
|
|
func create_frame_tag_list() -> void:
|
|
|
|
# Clear existing tag list from entry if it exists
|
2020-07-31 20:26:52 +00:00
|
|
|
spritesheet_options_frames.clear()
|
|
|
|
spritesheet_options_frames.add_item("All Frames", 0) # Re-add removed 'All Frames' item
|
2020-05-08 23:46:51 +00:00
|
|
|
|
|
|
|
# Repopulate list with current tag list
|
2020-06-04 18:05:36 +00:00
|
|
|
for item in Global.current_project.animation_tags:
|
2020-07-31 20:26:52 +00:00
|
|
|
spritesheet_options_frames.add_item(item.name)
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-08-07 05:13:04 +00:00
|
|
|
func open_path_validation_alert_popup() -> void:
|
|
|
|
path_validation_alert_popup.popup_centered()
|
|
|
|
|
|
|
|
|
|
|
|
func open_file_exists_alert_popup(dialog_text: String) -> void:
|
|
|
|
file_exists_alert_popup.dialog_text = dialog_text
|
|
|
|
file_exists_alert_popup.popup_centered()
|
|
|
|
|
|
|
|
|
|
|
|
func toggle_export_progress_popup(open: bool) -> void:
|
|
|
|
if open:
|
|
|
|
export_progress_popup.popup_centered()
|
|
|
|
else:
|
|
|
|
export_progress_popup.hide()
|
|
|
|
|
|
|
|
|
|
|
|
func set_export_progress_bar(value: float) -> void:
|
|
|
|
export_progress_bar.value = value
|
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_ExportDialog_about_to_show() -> void:
|
2020-06-30 19:36:03 +00:00
|
|
|
# If we're on HTML5, don't let the user change the directory path
|
|
|
|
if OS.get_name() == "HTML5":
|
2020-07-31 20:26:52 +00:00
|
|
|
path_container.visible = false
|
|
|
|
Export.directory_path = "user://"
|
2020-06-30 19:36:03 +00:00
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
if Export.directory_path.empty():
|
|
|
|
Export.directory_path = OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
# If export already occured - sets gui to show previous settings
|
2020-07-31 20:26:52 +00:00
|
|
|
options_resize.value = Export.resize
|
|
|
|
options_interpolation.selected = Export.interpolation
|
|
|
|
path_line_edit.text = Export.directory_path
|
|
|
|
path_dialog_popup.current_dir = Export.directory_path
|
|
|
|
file_line_edit.text = Export.file_name
|
|
|
|
file_file_format.selected = Export.file_format
|
2020-03-23 22:09:37 +00:00
|
|
|
show_tab()
|
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
for child in popups.get_children(): # Set the theme for the popups
|
2020-03-25 01:17:01 +00:00
|
|
|
child.theme = Global.control.theme
|
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.file_exists_alert = tr("File %s already exists. Overwrite?") # Update translation
|
2020-03-23 22:09:37 +00:00
|
|
|
|
2020-08-26 09:45:32 +00:00
|
|
|
# Set the size of the preview checker
|
|
|
|
var checker = $VBoxContainer/PreviewPanel/TransparentChecker
|
|
|
|
checker.rect_size = checker.get_parent().rect_size
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_Tabs_tab_clicked(tab : int) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.current_tab = tab
|
2020-03-23 22:09:37 +00:00
|
|
|
show_tab()
|
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_Frame_value_changed(value: float) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.frame_number = value
|
|
|
|
Export.process_frame()
|
2020-03-23 22:09:37 +00:00
|
|
|
set_preview()
|
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_Orientation_item_selected(id : int) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.orientation = id
|
|
|
|
if Export.orientation == Export.Orientation.ROWS:
|
|
|
|
spritesheet_options_lines_count_label.text = "Columns:"
|
2020-03-23 22:09:37 +00:00
|
|
|
else:
|
2020-07-31 20:26:52 +00:00
|
|
|
spritesheet_options_lines_count_label.text = "Rows:"
|
|
|
|
spritesheet_options_lines_count.value = Export.frames_divided_by_spritesheet_lines()
|
|
|
|
Export.process_spritesheet()
|
2020-03-23 22:09:37 +00:00
|
|
|
set_preview()
|
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_LinesCount_value_changed(value : float) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.lines_count = value
|
|
|
|
Export.process_spritesheet()
|
2020-03-23 22:09:37 +00:00
|
|
|
set_preview()
|
|
|
|
|
|
|
|
|
2020-04-06 16:51:47 +00:00
|
|
|
func _on_AnimationType_item_selected(id : int) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.animation_type = id
|
2020-04-06 16:51:47 +00:00
|
|
|
set_file_format_selector()
|
|
|
|
set_preview()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_Direction_item_selected(id : int) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.direction = id
|
2020-04-06 16:51:47 +00:00
|
|
|
match id:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.AnimationDirection.FORWARD:
|
2020-04-06 16:51:47 +00:00
|
|
|
animated_preview_current_frame = 0
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.AnimationDirection.BACKWARDS:
|
|
|
|
animated_preview_current_frame = Export.processed_images.size() - 1
|
|
|
|
Export.AnimationDirection.PING_PONG:
|
2020-04-06 16:51:47 +00:00
|
|
|
animated_preview_current_frame = 0
|
2020-07-31 20:26:52 +00:00
|
|
|
pingpong_direction = Export.AnimationDirection.FORWARD
|
2020-04-06 16:51:47 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_Resize_value_changed(value : float) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.resize = value
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Interpolation_item_selected(id: int) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.interpolation = id
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_ExportDialog_confirmed() -> void:
|
2020-08-07 05:13:04 +00:00
|
|
|
if Export.export_processed_images(false, self):
|
2020-07-31 20:26:52 +00:00
|
|
|
hide()
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_ExportDialog_custom_action(action : String) -> void:
|
2020-03-23 22:09:37 +00:00
|
|
|
if action == "cancel":
|
|
|
|
hide()
|
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_PathButton_pressed() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
path_dialog_popup.popup_centered()
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_PathLineEdit_text_changed(new_text : String) -> void:
|
2020-08-28 15:05:49 +00:00
|
|
|
Global.current_project.directory_path = new_text
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.directory_path = new_text
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_FileLineEdit_text_changed(new_text : String) -> void:
|
2020-08-28 15:05:49 +00:00
|
|
|
Global.current_project.file_name = new_text
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.file_name = new_text
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_FileDialog_dir_selected(dir : String) -> void:
|
2020-08-08 14:21:52 +00:00
|
|
|
path_line_edit.text = dir
|
2020-08-28 15:05:49 +00:00
|
|
|
Global.current_project.directory_path = dir
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.directory_path = dir
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_FileFormat_item_selected(id : int) -> void:
|
2020-08-28 15:05:49 +00:00
|
|
|
Global.current_project.file_format = id
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.file_format = id
|
2020-03-23 22:09:37 +00:00
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_FileExistsAlert_confirmed() -> void:
|
2020-03-23 22:09:37 +00:00
|
|
|
# Overwrite existing file
|
2020-07-31 20:26:52 +00:00
|
|
|
file_exists_alert_popup.dialog_text = Export.file_exists_alert
|
|
|
|
Export.stop_export = false
|
2020-03-23 22:09:37 +00:00
|
|
|
emit_signal("resume_export_function")
|
|
|
|
|
|
|
|
|
2020-03-25 01:17:01 +00:00
|
|
|
func _on_FileExistsAlert_custom_action(action : String) -> void:
|
2020-03-23 22:09:37 +00:00
|
|
|
if action == "cancel":
|
|
|
|
# Cancel export
|
2020-07-31 20:26:52 +00:00
|
|
|
file_exists_alert_popup.dialog_text = Export.file_exists_alert
|
|
|
|
Export.stop_export = true
|
2020-03-23 22:09:37 +00:00
|
|
|
emit_signal("resume_export_function")
|
2020-07-31 20:26:52 +00:00
|
|
|
file_exists_alert_popup.hide()
|
2020-04-06 16:51:47 +00:00
|
|
|
|
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
var pingpong_direction = Export.AnimationDirection.FORWARD
|
2020-04-06 16:51:47 +00:00
|
|
|
func _on_FrameTimer_timeout() -> void:
|
2020-08-26 09:45:32 +00:00
|
|
|
$VBoxContainer/PreviewPanel/PreviewScroll/Previews/PreviewContainer/Preview.texture = animated_preview_frames[animated_preview_current_frame]
|
2020-04-06 16:51:47 +00:00
|
|
|
|
2020-07-31 20:26:52 +00:00
|
|
|
match Export.direction:
|
|
|
|
Export.AnimationDirection.FORWARD:
|
2020-04-06 16:51:47 +00:00
|
|
|
if animated_preview_current_frame == animated_preview_frames.size() - 1:
|
|
|
|
animated_preview_current_frame = 0
|
|
|
|
else:
|
|
|
|
animated_preview_current_frame += 1
|
2020-12-16 20:54:08 +00:00
|
|
|
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame - 1) % (animated_preview_frames.size())].duration * (1 / Global.animation_timeline.fps)
|
2020-10-19 14:57:40 +00:00
|
|
|
frame_timer.start()
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.AnimationDirection.BACKWARDS:
|
2020-04-06 16:51:47 +00:00
|
|
|
if animated_preview_current_frame == 0:
|
2020-07-31 20:26:52 +00:00
|
|
|
animated_preview_current_frame = Export.processed_images.size() - 1
|
2020-04-06 16:51:47 +00:00
|
|
|
else:
|
|
|
|
animated_preview_current_frame -= 1
|
2020-12-16 20:54:08 +00:00
|
|
|
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame + 1) % (animated_preview_frames.size())].duration * (1 / Global.animation_timeline.fps)
|
2020-10-19 14:57:40 +00:00
|
|
|
frame_timer.start()
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.AnimationDirection.PING_PONG:
|
2020-04-06 16:51:47 +00:00
|
|
|
match pingpong_direction:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.AnimationDirection.FORWARD:
|
2020-04-06 16:51:47 +00:00
|
|
|
if animated_preview_current_frame == animated_preview_frames.size() - 1:
|
2020-07-31 20:26:52 +00:00
|
|
|
pingpong_direction = Export.AnimationDirection.BACKWARDS
|
2020-04-06 16:51:47 +00:00
|
|
|
animated_preview_current_frame -= 1
|
|
|
|
if animated_preview_current_frame <= 0:
|
|
|
|
animated_preview_current_frame = 0
|
|
|
|
else:
|
|
|
|
animated_preview_current_frame += 1
|
2020-12-16 20:54:08 +00:00
|
|
|
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame - 1) % (animated_preview_frames.size())].duration * (1 / Global.animation_timeline.fps)
|
2020-10-19 14:57:40 +00:00
|
|
|
frame_timer.start()
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.AnimationDirection.BACKWARDS:
|
2020-04-06 16:51:47 +00:00
|
|
|
if animated_preview_current_frame == 0:
|
|
|
|
animated_preview_current_frame += 1
|
|
|
|
if animated_preview_current_frame >= animated_preview_frames.size() - 1:
|
|
|
|
animated_preview_current_frame = 0
|
2020-07-31 20:26:52 +00:00
|
|
|
pingpong_direction = Export.AnimationDirection.FORWARD
|
2020-04-06 16:51:47 +00:00
|
|
|
else:
|
|
|
|
animated_preview_current_frame -= 1
|
2020-12-16 20:54:08 +00:00
|
|
|
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame + 1) % (animated_preview_frames.size())].duration * (1 / Global.animation_timeline.fps)
|
2020-10-19 14:57:40 +00:00
|
|
|
frame_timer.start()
|
|
|
|
|
2020-04-06 16:51:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_ExportDialog_popup_hide() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
frame_timer.stop()
|
2020-04-22 19:36:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_MultipleAnimationsDirectories_toggled(button_pressed : bool) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.new_dir_for_each_frame_tag = button_pressed
|
2020-05-08 23:46:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Frames_item_selected(id : int) -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
Export.frame_current_tag = id
|
|
|
|
Export.process_spritesheet()
|
2020-05-08 23:46:51 +00:00
|
|
|
set_preview()
|
2020-07-31 20:26:52 +00:00
|
|
|
spritesheet_options_lines_count.max_value = Export.number_of_frames
|
|
|
|
spritesheet_options_lines_count.value = Export.lines_count
|