1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Frame properties (#357)

* Sync for my local files to my repository

* This is frame properties update, it works but I can't be stored while
saving or loading and that makes crashes just the beggining :)

* I forgot this files :P

* Frame Properties update.

* Updating frame properties

* Update Translations.pot

* Changes to CanvasPreview and CelButton change
This commit is contained in:
PinyaColada 2020-10-19 16:57:40 +02:00 committed by GitHub
parent f5cf3f3ca7
commit 852365c38f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 183 additions and 20 deletions

View file

@ -1064,6 +1064,9 @@ msgstr ""
msgid "Unlink Cel"
msgstr ""
msgid "Frame properties"
msgstr ""
msgid "Layer"
msgstr ""
@ -1197,6 +1200,12 @@ msgstr ""
msgid "Redo: Delete Frame Tag"
msgstr ""
msgid "Undo: Change frame duration"
msgstr ""
msgid "Redo: Change frame duration"
msgstr ""
msgid "Move Guide"
msgstr ""
@ -1428,3 +1437,6 @@ msgstr ""
msgid "Move the selected frame to the right."
msgstr ""
msgid "Frame duration"
msgstr ""

View file

@ -213,16 +213,16 @@ func export_gif(args: Dictionary) -> void:
match direction:
AnimationDirection.FORWARD:
for i in range(processed_images.size()):
write_frame_to_gif(processed_images[i], Global.animation_timer.wait_time, exporter, args["export_dialog"])
write_frame_to_gif(processed_images[i], Global.current_project.frame_duration[i] * (1 / Global.animation_timeline.fps), exporter, args["export_dialog"])
AnimationDirection.BACKWARDS:
for i in range(processed_images.size() - 1, -1, -1):
write_frame_to_gif(processed_images[i], Global.animation_timer.wait_time, exporter, args["export_dialog"])
write_frame_to_gif(processed_images[i], Global.current_project.frame_duration[i] * (1 / Global.animation_timeline.fps), exporter, args["export_dialog"])
AnimationDirection.PING_PONG:
export_progress_fraction = 100 / (processed_images.size() * 2)
for i in range(0, processed_images.size()):
write_frame_to_gif(processed_images[i], Global.animation_timer.wait_time, exporter, args["export_dialog"])
write_frame_to_gif(processed_images[i], Global.current_project.frame_duration[i] * (1 / Global.animation_timeline.fps), exporter, args["export_dialog"])
for i in range(processed_images.size() - 2, 0, -1):
write_frame_to_gif(processed_images[i], Global.animation_timer.wait_time, exporter, args["export_dialog"])
write_frame_to_gif(processed_images[i], Global.current_project.frame_duration[i] * (1 / Global.animation_timeline.fps), exporter, args["export_dialog"])
if OS.get_name() == "HTML5":
Html5FileExchange.save_gif(exporter.export_file_data(), args["export_paths"][0])

View file

@ -127,6 +127,7 @@ var patterns_popup : Popup
var animation_timeline : Panel
var animation_timer : Timer
var frame_properties : ConfirmationDialog
var frame_ids : HBoxContainer
var current_frame_mark_label : Label
var onion_skinning_button : BaseButton
@ -221,6 +222,7 @@ func _ready() -> void:
patterns_popup = find_node_by_name(root, "PatternsPopup")
animation_timeline = find_node_by_name(root, "AnimationTimeline")
frame_properties = find_node_by_name(root, "FrameProperties")
layers_container = find_node_by_name(animation_timeline, "LayersContainer")
frames_container = find_node_by_name(animation_timeline, "FramesContainer")

View file

@ -8,6 +8,7 @@ var undo_redo : UndoRedo
var undos := 0 # The number of times we added undo properties
var has_changed := false setget has_changed_changed
var frames := [] setget frames_changed # Array of Frames (that contain Cels)
var frame_duration := []
var layers := [] setget layers_changed # Array of Layers
var current_frame := 0 setget frame_changed
var current_layer := 0 setget layer_changed
@ -271,6 +272,7 @@ func serialize() -> Dictionary:
"export_directory_path" : directory_path,
"export_file_name" : file_name,
"export_file_format" : file_format,
"frame_duration" : frame_duration,
}
return project_data
@ -332,7 +334,8 @@ func deserialize(dict : Dictionary) -> void:
file_name = dict.export_file_name
if dict.has("export_file_format"):
file_format = dict.export_file_format
if dict.has("frame_duration"):
frame_duration = dict.frame_duration
func name_changed(value : String) -> void:
name = value

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=2]
[gd_scene load_steps=17 format=2]
[ext_resource path="res://assets/themes/dark/theme.tres" type="Theme" id=1]
[ext_resource path="res://src/Main.gd" type="Script" id=2]
@ -8,6 +8,7 @@
[ext_resource path="res://src/UI/BrushesPopup.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/UI/Dialogs/ImageEffects/ImageEffects.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/UI/Dialogs/SaveSpriteHTML5.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/UI/Timeline/FrameProperties.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/UI/Dialogs/SaveSprite.tscn" type="PackedScene" id=11]
[ext_resource path="res://src/UI/Dialogs/OpenSprite.tscn" type="PackedScene" id=12]
[ext_resource path="res://src/UI/Dialogs/SplashDialog.tscn" type="PackedScene" id=27]
@ -109,6 +110,8 @@ popup_exclusive = true
dialog_text = "Autosaved backup for %s was found.
Do you want to reload it?"
[node name="FrameProperties" parent="Dialogs" instance=ExtResource( 9 )]
[node name="LeftCursor" type="Sprite" parent="."]
visible = false

View file

@ -9,7 +9,7 @@ func _draw() -> void:
if frame >= current_project.frames.size():
frame = current_project.current_frame
$AnimationTimer.wait_time = Global.animation_timer.wait_time
$AnimationTimer.wait_time = Global.current_project.frame_duration[frame] * (1 / Global.animation_timeline.fps)
if animation_timer.is_stopped():
frame = current_project.current_frame
@ -24,9 +24,12 @@ func _draw() -> void:
func _on_AnimationTimer_timeout() -> void:
var current_project : Project = Global.current_project
if frame < current_project.frames.size() - 1:
frame += 1
else:
frame = 0
$AnimationTimer.set_one_shot(true)
$AnimationTimer.wait_time = Global.current_project.frame_duration[frame] * (1 / Global.animation_timeline.fps)
$AnimationTimer.start()
update()

View file

@ -148,6 +148,8 @@ func add_animated_preview() -> void:
container.add_child(preview)
previews.add_child(container)
frame_timer.set_one_shot(true) #The wait_time it can't change correctly if it is playing
frame_timer.wait_time = Global.current_project.frame_duration[animated_preview_current_frame] * (1 / Global.animation_timeline.fps)
frame_timer.start()
@ -186,7 +188,6 @@ func set_file_format_selector() -> void:
Export.AnimationType.ANIMATED:
Export.file_format = Export.FileFormat.GIF
file_file_format.selected = Export.FileFormat.GIF
frame_timer.wait_time = Global.animation_timer.wait_time
animation_options_animation_options.show()
@ -362,13 +363,15 @@ func _on_FrameTimer_timeout() -> void:
animated_preview_current_frame = 0
else:
animated_preview_current_frame += 1
frame_timer.wait_time = Global.current_project.frame_duration[(animated_preview_current_frame - 1) % (animated_preview_frames.size())] * (1 / Global.animation_timeline.fps)
frame_timer.start()
Export.AnimationDirection.BACKWARDS:
if animated_preview_current_frame == 0:
animated_preview_current_frame = Export.processed_images.size() - 1
else:
animated_preview_current_frame -= 1
frame_timer.wait_time = Global.current_project.frame_duration[(animated_preview_current_frame + 1) % (animated_preview_frames.size())] * (1 / Global.animation_timeline.fps)
frame_timer.start()
Export.AnimationDirection.PING_PONG:
match pingpong_direction:
Export.AnimationDirection.FORWARD:
@ -379,6 +382,8 @@ func _on_FrameTimer_timeout() -> void:
animated_preview_current_frame = 0
else:
animated_preview_current_frame += 1
frame_timer.wait_time = Global.current_project.frame_duration[(animated_preview_current_frame - 1) % (animated_preview_frames.size())] * (1 / Global.animation_timeline.fps)
frame_timer.start()
Export.AnimationDirection.BACKWARDS:
if animated_preview_current_frame == 0:
animated_preview_current_frame += 1
@ -387,6 +392,9 @@ func _on_FrameTimer_timeout() -> void:
pingpong_direction = Export.AnimationDirection.FORWARD
else:
animated_preview_current_frame -= 1
frame_timer.wait_time = Global.current_project.frame_duration[(animated_preview_current_frame + 1) % (animated_preview_frames.size())] * (1 / Global.animation_timeline.fps)
frame_timer.start()
func _on_ExportDialog_popup_hide() -> void:

View file

@ -15,6 +15,7 @@ func _ready() -> void:
tag_scroll_container = Global.find_node_by_name(self, "TagScroll")
timeline_scroll.get_h_scrollbar().connect("value_changed", self, "_h_scroll_changed")
Global.animation_timer.wait_time = 1 / fps
Global.current_project.frame_duration.append(1)
func _h_scroll_changed(value : float) -> void:
@ -24,10 +25,12 @@ func _h_scroll_changed(value : float) -> void:
func add_frame() -> void:
var frame_duration : Array = Global.current_project.frame_duration.duplicate()
var frame : Frame = Global.canvas.new_empty_frame()
var new_frames : Array = Global.current_project.frames.duplicate()
new_frames.append(frame)
var new_layers : Array = Global.current_project.layers.duplicate()
frame_duration.insert(Global.current_project.current_frame + 1, 1)
new_frames.insert(Global.current_project.current_frame + 1, frame)
# Loop through the array to create new classes for each element, so that they
# won't be the same as the original array's classes. Needed for undo/redo to work properly.
for i in new_layers.size():
@ -46,12 +49,14 @@ func add_frame() -> void:
Global.current_project.undo_redo.add_undo_method(Global, "undo")
Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames)
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", new_frames.size() - 1)
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", Global.current_project.current_frame + 1)
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
Global.current_project.undo_redo.add_do_property(Global.current_project, "frame_duration", frame_duration) #Add a 1 in the list of frame_duration
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame )
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frame_duration", Global.current_project.frame_duration)
Global.current_project.undo_redo.commit_action()
@ -61,6 +66,8 @@ func _on_DeleteFrame_pressed(frame := -1) -> void:
if frame == -1:
frame = Global.current_project.current_frame
var frame_duration : Array = Global.current_project.frame_duration.duplicate()
frame_duration.remove(frame)
var frame_to_delete : Frame = Global.current_project.frames[frame]
var new_frames : Array = Global.current_project.frames.duplicate()
new_frames.erase(frame_to_delete)
@ -107,11 +114,13 @@ func _on_DeleteFrame_pressed(frame := -1) -> void:
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", current_frame)
Global.current_project.undo_redo.add_do_property(Global.current_project, "animation_tags", new_animation_tags)
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
Global.current_project.undo_redo.add_do_property(Global.current_project, "frame_duration", frame_duration) #Remove the element of the list of the frame selected
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "animation_tags", Global.current_project.animation_tags)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frame_duration", Global.current_project.frame_duration)
Global.current_project.undo_redo.add_do_method(Global, "redo")
Global.current_project.undo_redo.add_undo_method(Global, "undo")
@ -123,7 +132,8 @@ func _on_CopyFrame_pressed(frame := -1) -> void:
frame = Global.current_project.current_frame
var new_frame := Frame.new()
var frame_duration : Array = Global.current_project.frame_duration.duplicate()
frame_duration.insert(frame + 1, 1)
var new_frames := Global.current_project.frames.duplicate()
new_frames.insert(frame + 1, new_frame)
@ -152,6 +162,7 @@ func _on_CopyFrame_pressed(frame := -1) -> void:
Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames)
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", frame + 1)
Global.current_project.undo_redo.add_do_property(Global.current_project, "animation_tags", new_animation_tags)
Global.current_project.undo_redo.add_do_property(Global.current_project, "frame_duration", frame_duration)
for i in range(Global.current_project.layers.size()):
for child in Global.current_project.layers[i].frame_container.get_children():
Global.current_project.undo_redo.add_do_property(child, "pressed", false)
@ -160,6 +171,7 @@ func _on_CopyFrame_pressed(frame := -1) -> void:
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", frame)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "animation_tags", Global.current_project.animation_tags)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frame_duration", Global.current_project.frame_duration)
Global.current_project.undo_redo.commit_action()
@ -234,6 +246,8 @@ func _on_AnimationTimer_timeout() -> void:
if animation_forward:
if Global.current_project.current_frame < last_frame:
Global.current_project.current_frame += 1
Global.animation_timer.wait_time = Global.current_project.frame_duration[Global.current_project.current_frame] * (1/fps)
Global.animation_timer.start() #Change the frame, change the wait time and start a cycle, this is the best way to do it
else:
match animation_loop:
0: # No loop
@ -242,6 +256,8 @@ func _on_AnimationTimer_timeout() -> void:
Global.animation_timer.stop()
1: # Cycle loop
Global.current_project.current_frame = first_frame
Global.animation_timer.wait_time = Global.current_project.frame_duration[Global.current_project.current_frame] * (1/fps)
Global.animation_timer.start()
2: # Ping pong loop
animation_forward = false
_on_AnimationTimer_timeout()
@ -249,6 +265,8 @@ func _on_AnimationTimer_timeout() -> void:
else:
if Global.current_project.current_frame > first_frame:
Global.current_project.current_frame -= 1
Global.animation_timer.wait_time = Global.current_project.frame_duration[Global.current_project.current_frame] * (1/fps)
Global.animation_timer.start()
else:
match animation_loop:
0: # No loop
@ -257,6 +275,8 @@ func _on_AnimationTimer_timeout() -> void:
Global.animation_timer.stop()
1: # Cycle loop
Global.current_project.current_frame = last_frame
Global.animation_timer.wait_time = Global.current_project.frame_duration[Global.current_project.current_frame] * (1/fps)
Global.animation_timer.start()
2: # Ping pong loop
animation_forward = true
_on_AnimationTimer_timeout()
@ -290,7 +310,8 @@ func play_animation(play : bool, forward_dir : bool) -> void:
Global.play_forward.connect("toggled", self, "_on_PlayForward_toggled")
if play:
Global.animation_timer.wait_time = 1 / fps
Global.animation_timer.set_one_shot(true) #The wait_time it can't change correctly if it is playing
Global.animation_timer.wait_time = Global.current_project.frame_duration[Global.current_project.current_frame] * (1 / fps)
Global.animation_timer.start()
animation_forward = forward_dir
else:

View file

@ -101,10 +101,22 @@ func _on_PopupMenu_id_pressed(ID : int) -> void:
Global.current_project.undo_redo.add_undo_method(Global, "undo")
Global.current_project.undo_redo.add_do_method(Global, "redo")
Global.current_project.undo_redo.commit_action()
5: #Frame Properties
Global.frame_properties.popup_centered()
Global.dialog_open(true)
Global.frame_properties.set_frame_label(frame)
Global.frame_properties.set_frame_dur(Global.current_project.frame_duration[frame])
func change_frame_order(rate : int) -> void:
var change = frame + rate
var frame_duration : Array = Global.current_project.frame_duration.duplicate()
if rate > 0: #There is no function in the class Array in godot to make this quickly and this is the fastest way to swap positions I think of
frame_duration.insert(change + 1, frame_duration[frame])
frame_duration.remove(frame)
else:
frame_duration.insert(change, frame_duration[frame])
frame_duration.remove(frame + 1)
var new_frames : Array = Global.current_project.frames.duplicate()
var temp = new_frames[frame]
new_frames[frame] = new_frames[change]
@ -112,12 +124,14 @@ func change_frame_order(rate : int) -> void:
Global.current_project.undo_redo.create_action("Change Frame Order")
Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames)
Global.current_project.undo_redo.add_do_property(Global.current_project, "frame_duration", frame_duration)
if Global.current_project.current_frame == frame:
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", change)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frame_duration", Global.current_project.frame_duration)
Global.current_project.undo_redo.add_undo_method(Global, "undo")
Global.current_project.undo_redo.add_do_method(Global, "redo")

View file

@ -43,10 +43,12 @@ margin_bottom = 0.0
margin_right = 20.0
margin_bottom = 20.0
mouse_default_cursor_shape = 2
items = [ "Remove Frame", null, 0, false, true, -1, 0, null, "", false, "Clone Frame", null, 0, false, false, -1, 0, null, "", false, "Move Left", null, 0, false, true, -1, 0, null, "", false, "Move Right", null, 0, false, true, -1, 0, null, "", false, "Link Cel", null, 0, false, false, -1, 0, null, "", false ]
items = [ "Remove Frame", null, 0, false, true, -1, 0, null, "", false, "Clone Frame", null, 0, false, false, -1, 0, null, "", false, "Move Left", null, 0, false, true, -1, 0, null, "", false, "Move Right", null, 0, false, true, -1, 0, null, "", false, "Link Cel", null, 0, false, false, -1, 0, null, "", false, "Frame Properties", null, 0, false, false, 5, 0, null, "", false ]
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LinkedIndicator" type="Polygon2D" parent="."]
visible = false
color = Color( 0.0627451, 0.741176, 0.215686, 1 )
invert_enable = true
invert_border = 1.0

View file

@ -0,0 +1,29 @@
extends ConfirmationDialog
onready var frame_num = $VBoxContainer/GridContainer/FrameNum
onready var frame_dur = $VBoxContainer/GridContainer/FrameTime
func set_frame_label(frame : int) -> void:
frame_num.set_text(str(frame + 1))
func set_frame_dur(duration : float) -> void:
frame_dur.set_value(duration)
func _on_FrameProperties_popup_hide() -> void:
Global.dialog_open(false)
func _on_FrameProperties_confirmed():
var frame : int = int(frame_num.get_text())
var duration : float = frame_dur.get_value()
var frame_duration = Global.current_project.frame_duration.duplicate()
frame_duration[frame - 1] = duration
Global.current_project.undos += 1
Global.current_project.undo_redo.create_action("Change frame duration")
Global.current_project.undo_redo.add_do_property(Global.current_project, "frame_duration", frame_duration)
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frame_duration", Global.current_project.frame_duration)
Global.current_project.undo_redo.add_do_method(Global, "redo")
Global.current_project.undo_redo.add_undo_method(Global, "undo")
Global.current_project.undo_redo.commit_action()

View file

@ -0,0 +1,66 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/UI/Timeline/FrameProperties.gd" type="Script" id=1]
[node name="FrameProperties" type="ConfirmationDialog"]
margin_right = 209.0
margin_bottom = 137.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_left = 8.0
margin_top = 8.0
margin_right = 201.0
margin_bottom = 101.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="VBoxContainer"]
margin_right = 193.0
margin_bottom = 14.0
text = "Frame properties"
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
margin_top = 18.0
margin_right = 193.0
margin_bottom = 22.0
[node name="GridContainer" type="GridContainer" parent="VBoxContainer"]
margin_top = 26.0
margin_right = 193.0
margin_bottom = 68.0
columns = 2
[node name="Frame" type="Label" parent="VBoxContainer/GridContainer"]
margin_right = 97.0
margin_bottom = 14.0
text = "Frame"
[node name="FrameNum" type="Label" parent="VBoxContainer/GridContainer"]
margin_left = 101.0
margin_right = 193.0
margin_bottom = 14.0
text = "1"
[node name="FrameDuration" type="Label" parent="VBoxContainer/GridContainer"]
margin_top = 23.0
margin_right = 97.0
margin_bottom = 37.0
text = "Frame duration"
[node name="FrameTime" type="SpinBox" parent="VBoxContainer/GridContainer"]
margin_left = 101.0
margin_top = 18.0
margin_right = 193.0
margin_bottom = 42.0
size_flags_horizontal = 3
step = 0.05
value = 2.0
allow_greater = true
suffix = "x"
[connection signal="confirmed" from="." to="." method="_on_FrameProperties_confirmed"]
[connection signal="popup_hide" from="." to="." method="_on_FrameProperties_popup_hide"]