Skip to content

Commit

Permalink
fix start time with chaining animations
Browse files Browse the repository at this point in the history
  • Loading branch information
ceceppa committed Sep 2, 2024
1 parent 64dccf6 commit 42a5b7e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 30 deletions.
8 changes: 4 additions & 4 deletions addons/anima/core/declaration/anima_declaration_for_base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ func anima_on_completed(target: Callable, on_completed_value = null, on_backward

return self

func anima_with(new_class = null) -> AnimaDeclarationNode:
return _parent_class._with(new_class)
func anima_with(new_class = null, delay = null) -> AnimaDeclarationNode:
return _parent_class._with(new_class, delay)

func anima_then(new_class = null) -> AnimaDeclarationNode:
return _parent_class._then(new_class)
func anima_then(new_class = null, delay = null) -> AnimaDeclarationNode:
return _parent_class._then(new_class, delay)

func play() -> AnimaNode:
return _parent_class.play()
Expand Down
19 changes: 13 additions & 6 deletions addons/anima/core/declaration/anima_declaration_node.gd
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ func clear():

return self

func _then(new_class):
return _nested_animation("_then", new_class)
func _then(new_class, delay):
return _nested_animation("_then", new_class, delay)

func _with(new_class):
return _nested_animation("_with", new_class)
func _with(new_class, delay):
return _nested_animation("_with", new_class, delay)

func _nested_animation(key, new_class):
func _nested_animation(key, new_class, delay):
if not _target_data.has(key):
_target_data[key] = {}

Expand All @@ -266,6 +266,9 @@ func _nested_animation(key, new_class):
elif _target_data.has("group"):
_target_data[key].group = _target_data.group

if delay:
_target_data[key].delay = delay

var has_duration = _target_data.has("duration")
var duration = _target_data.duration if has_duration else null

Expand Down Expand Up @@ -305,6 +308,10 @@ func _init_anima_node(data, mode):

if mode == "with":
_anima_node.with(data)
elif mode == "then":
_anima_node.then(data)
else:
printerr("Unsupported mode", mode)

if data.has("_with"):
_init_anima_node(data._with, "with")
Expand All @@ -313,7 +320,7 @@ func _init_anima_node(data, mode):
_init_anima_node(data._then, "then")

func _do_play(action: PlayAction, param = null) -> AnimaNode:
_init_anima_node(_data, "with")
_init_anima_node(_data, "then")

var single_shot = _is_single_shot if action < PlayAction.LOOP else false
_anima_node.set_single_shot(single_shot)
Expand Down
39 changes: 19 additions & 20 deletions addons/anima/ui/AnimationPicker/AnimationPicker.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
[ext_resource type="Texture2D" uid="uid://ca72ljjcye5v1" path="res://addons/anima/resources/anima-preview.png" id="2_pk6n6"]
[ext_resource type="PackedScene" uid="uid://0luo7c2dwb4l" path="res://addons/anima/ui/AnimationPicker/CTASecondaryButton.tscn" id="3_qvnfb"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0ikkc"]
bg_color = Color(1, 1, 1, 1)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4yg3m"]
content_margin_left = 12.0
content_margin_right = 12.0
Expand All @@ -23,6 +20,9 @@ content_margin_left = 12.0
content_margin_right = 12.0
bg_color = Color(0.14902, 0.27451, 0.32549, 1)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0ikkc"]
bg_color = Color(1, 1, 1, 1)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0op83"]
bg_color = Color(0.215686, 0.215686, 0.215686, 1)
corner_radius_bottom_right = 8
Expand Down Expand Up @@ -55,11 +55,10 @@ layout_mode = 2
size_flags_vertical = 3
theme_override_colors/font_hovered_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 18
theme_override_styles/panel = SubResource("StyleBoxFlat_0ikkc")
theme_override_styles/tab_selected = SubResource("StyleBoxFlat_4yg3m")
theme_override_styles/tab_hovered = SubResource("StyleBoxFlat_0tlf5")
theme_override_styles/tab_unselected = SubResource("StyleBoxFlat_5ixaa")
current_tab = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_0ikkc")

[node name="Animations" type="HBoxContainer" parent="TabContainer"]
layout_mode = 2
Expand Down Expand Up @@ -219,20 +218,20 @@ auto_brace_completion_highlight_matching = true
[connection signal="item_rect_changed" from="." to="." method="_on_item_rect_changed"]
[connection signal="text_submitted" from="TabContainer/Animations/Control/Panel/MarginContainer/HBoxContainer/AnimationSpeed" to="." method="_on_animation_speed_text_submitted"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/HeaderButton" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/HeaderButton" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22453" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22453" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22463" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22463" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22473" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22473" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22485" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22485" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22497" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22497" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22527" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22527" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22555" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22555" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22565" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22565" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22577" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22577" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22589" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22589" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22599" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22599" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22609" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22609" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22619" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22619" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22623" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22623" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22643" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22643" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18802" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18802" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18812" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18812" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18822" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18822" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18834" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18834" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18846" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18846" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18876" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18876" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18904" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18904" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18914" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18914" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18926" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18926" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18938" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18938" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18948" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18948" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18958" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18958" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18968" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18968" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18972" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18972" method="_on_toggled"]
[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18992" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@18992" method="_on_toggled"]
[connection signal="pressed" from="TabContainer/Animations/VBoxContainer/MarginContainer/HBoxContainer/UseAnimation" to="." method="_on_use_animation_pressed"]
[connection signal="pressed" from="TabContainer/Animations/VBoxContainer/MarginContainer/HBoxContainer/CloseButton" to="." method="_on_close_button_pressed"]
2 changes: 2 additions & 0 deletions addons/anima/ui/EventItem.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ layout_mode = 2
size_flags_horizontal = 3
item_count = 3
popup/item_0/text = "Forward"
popup/item_0/id = 0
popup/item_1/text = "Backwards"
popup/item_1/id = 1
popup/item_2/text = "Loop"
Expand Down Expand Up @@ -131,6 +132,7 @@ layout_mode = 2
size_flags_horizontal = 3
item_count = 3
popup/item_0/text = "Forward"
popup/item_0/id = 0
popup/item_1/text = "Backward"
popup/item_1/id = 1
popup/item_2/text = "In circle"
Expand Down

0 comments on commit 42a5b7e

Please sign in to comment.