Replace godot-gifexporter with godot-gdgifexporter (#295)

Add exporting in a separate thread and a progress bar
Remove background color option from gif export
This commit is contained in:
Martin Novák 2020-08-07 07:13:04 +02:00 committed by GitHub
parent e4aa17b01c
commit f3bce3857a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1073 additions and 80 deletions

View file

@ -11,8 +11,12 @@ 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
onready var export_progress_popup = $Popups/ExportProgressBar
onready var export_progress_bar = $Popups/ExportProgressBar/MarginContainer/ProgressBar
onready var animation_options_multiple_animations_directories = $VBoxContainer/AnimationOptions/MultipleAnimationsDirectories
onready var previews = $VBoxContainer/PreviewScroll/Previews
onready var frame_timer = $FrameTimer
onready var frame_options = $VBoxContainer/FrameOptions
onready var frame_options_frame_number = $VBoxContainer/FrameOptions/FrameNumber/FrameNumber
@ -26,10 +30,8 @@ onready var spritesheet_options_lines_count_label = $VBoxContainer/SpritesheetOp
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_background_color = $VBoxContainer/AnimationOptions/AnimatedOptions/BackgroundColor
onready var animation_options_direction = $VBoxContainer/AnimationOptions/AnimatedOptions/Direction
onready var frame_timer = $FrameTimer
onready var options_resize = $VBoxContainer/Options/Resize
onready var options_interpolation = $VBoxContainer/Options/Interpolation
@ -38,8 +40,6 @@ onready var path_line_edit = $VBoxContainer/Path/PathLineEdit
onready var file_line_edit = $VBoxContainer/File/FileLineEdit
onready var file_file_format = $VBoxContainer/File/FileFormat
onready var animation_options_multiple_animations_directories = $VBoxContainer/AnimationOptions/MultipleAnimationsDirectories
func _ready() -> void:
tabs.add_tab("Frame")
@ -52,10 +52,8 @@ func _ready() -> void:
add_button("Cancel", false, "cancel")
file_exists_alert_popup.add_button("Cancel Export", false, "cancel")
# Disable GIF export for unsupported platforms
if not $GifExporter.is_platform_supported():
animation_options_animation_type.selected = Export.AnimationType.MULTIPLE_FILES
animation_options_animation_type.disabled = true
# Remove close button from export progress bar
export_progress_popup.get_close_button().hide()
func show_tab() -> void:
@ -95,7 +93,6 @@ func show_tab() -> void:
set_file_format_selector()
Export.process_animation()
animation_options_animation_type.selected = Export.animation_type
animation_options_background_color.color = Export.background_color
animation_options_direction.selected = Export.direction
animation_options.show()
set_preview()
@ -111,7 +108,7 @@ func external_export() -> void:
Export.process_spritesheet()
Export.ExportTab.ANIMATION:
Export.process_animation()
if Export.export_processed_images(true, path_validation_alert_popup, file_exists_alert_popup, self):
if Export.export_processed_images(true, self):
hide()
@ -216,6 +213,26 @@ func create_frame_tag_list() -> void:
spritesheet_options_frames.add_item(item.name)
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
func _on_ExportDialog_about_to_show() -> void:
# If export already occured - fill the dialog with previous export settings
if Export.was_exported:
@ -278,10 +295,6 @@ func _on_AnimationType_item_selected(id : int) -> void:
set_preview()
func _on_BackgroundColor_color_changed(color : Color) -> void:
Export.background_color = color
func _on_Direction_item_selected(id : int) -> void:
Export.direction = id
match id:
@ -303,7 +316,7 @@ func _on_Interpolation_item_selected(id: int) -> void:
func _on_ExportDialog_confirmed() -> void:
if Export.export_processed_images(false, path_validation_alert_popup, file_exists_alert_popup, self):
if Export.export_processed_images(false, self):
hide()

View file

@ -1,7 +1,6 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/UI/Dialogs/ExportDialog.gd" type="Script" id=1]
[ext_resource path="res://addons/godot-gifexporter/src/GifExporter.gd" type="Script" id=2]
[node name="ExportDialog" type="AcceptDialog"]
margin_right = 532.0
@ -183,31 +182,14 @@ margin_right = 516.0
margin_bottom = 52.0
rect_min_size = Vector2( 0, 24 )
[node name="BackgroundColorLabel" type="Label" parent="VBoxContainer/AnimationOptions/AnimatedOptions"]
margin_top = 5.0
margin_right = 78.0
margin_bottom = 19.0
text = "Background:"
valign = 1
[node name="BackgroundColor" type="ColorPickerButton" parent="VBoxContainer/AnimationOptions/AnimatedOptions"]
margin_left = 82.0
margin_right = 263.0
margin_bottom = 24.0
mouse_default_cursor_shape = 2
size_flags_horizontal = 7
color = Color( 1, 1, 1, 1 )
edit_alpha = false
[node name="DirectionLabel" type="Label" parent="VBoxContainer/AnimationOptions/AnimatedOptions"]
margin_left = 267.0
margin_top = 5.0
margin_right = 330.0
margin_right = 63.0
margin_bottom = 19.0
text = "Direction:"
[node name="Direction" type="OptionButton" parent="VBoxContainer/AnimationOptions/AnimatedOptions"]
margin_left = 334.0
margin_left = 67.0
margin_right = 516.0
margin_bottom = 24.0
rect_min_size = Vector2( 100, 0 )
@ -365,10 +347,10 @@ __meta__ = {
}
[node name="FileExistsAlert" type="AcceptDialog" parent="Popups"]
margin_left = 8.0
margin_top = 180.0
margin_right = 448.0
margin_bottom = 280.0
margin_left = 10.5227
margin_top = 176.636
margin_right = 450.523
margin_bottom = 276.636
size_flags_horizontal = 0
size_flags_vertical = 0
window_title = "Alarm!"
@ -378,16 +360,41 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="ExportProgressBar" type="WindowDialog" parent="Popups"]
margin_left = 63.0
margin_top = 215.0
margin_right = 402.0
margin_bottom = 256.0
popup_exclusive = true
window_title = "Exporting in progress..."
__meta__ = {
"_edit_group_": true,
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="Popups/ExportProgressBar"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 5.0
margin_top = 5.0
margin_right = -5.0
margin_bottom = -5.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ProgressBar" type="ProgressBar" parent="Popups/ExportProgressBar/MarginContainer"]
margin_right = 329.0
margin_bottom = 14.0
size_flags_horizontal = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="FrameTimer" type="Timer" parent="."]
__meta__ = {
"_editor_description_": "Timer to advance animation frames in animation preview."
}
[node name="GifExporter" type="Node" parent="."]
script = ExtResource( 2 )
__meta__ = {
"_editor_description_": ""
}
[connection signal="about_to_show" from="." to="." method="_on_ExportDialog_about_to_show"]
[connection signal="confirmed" from="." to="." method="_on_ExportDialog_confirmed"]
[connection signal="custom_action" from="." to="." method="_on_ExportDialog_custom_action"]
@ -399,7 +406,6 @@ __meta__ = {
[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"]
[connection signal="item_selected" from="VBoxContainer/Options/Interpolation" to="." method="_on_Interpolation_item_selected"]