Skip to content

Commit

Permalink
fix with animation
Browse files Browse the repository at this point in the history
  • Loading branch information
ceceppa committed Aug 30, 2024
1 parent bce606f commit 5f490c9
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 383 deletions.
231 changes: 0 additions & 231 deletions addons/anima/core/declaration/anima_declaration_base.gd

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class_name AnimaDeclarationForAnimation
extends AnimaDeclarationBase
extends AnimaDeclarationForBase

# We can't use _init otherwise Godot complains with this nonsense
# Too few arguments for "_init()". Expected at least 1
Expand Down
144 changes: 144 additions & 0 deletions addons/anima/core/declaration/anima_declaration_for_base.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
extends Object
class_name AnimaDeclarationForBase

var _parent_class

func _add(key, value):
_parent_class._add(key, value)

func get_data() -> Dictionary:
return _parent_class.get_data()

func _init(parent_class):
_parent_class = parent_class

func _init_me(data: Dictionary):
for key in data:
var value = data[key]

if value != null:
_parent_class._add(key, data[key])

func anima_from(from) -> Variant:
if from == null:
return self

_parent_class._add("from", from)

return self

func anima_to(to) -> Variant:
if to == null:
return self

_parent_class._add("to", to)

return self

func anima_delay(delay: float) -> Variant:
_parent_class._add("delay", delay)

return self

func anima_visibility_strategy(strategy: int) -> Variant:
_parent_class._add("visibility_strategy", strategy)

return self

func anima_initial_value(initial_value) -> Variant:
var values := {}
values[_parent_class.get("property")] = initial_value

_parent_class._add("initial_values", values)

return self

func anima_on_started(target: Callable, on_started_value = null, on_backwards_completed_value = null) -> Variant:
if typeof(on_started_value) != TYPE_ARRAY:
if on_started_value == null:
on_started_value = []
else:
on_started_value = [on_started_value]

if typeof(on_backwards_completed_value) != TYPE_ARRAY:
if on_backwards_completed_value == null:
on_backwards_completed_value = []
else:
on_backwards_completed_value = [on_backwards_completed_value]

_parent_class._add("on_started", {
target = target,
value = on_started_value,
backwards_value = on_backwards_completed_value
})

return self

func anima_on_completed(target: Callable, on_completed_value = null, on_backwards_completed_value = null) -> Variant:
_parent_class._add("on_completed", {
target = target,
value = on_completed_value,
backwards_value = on_backwards_completed_value
})

return self

func anima_with() -> AnimaDeclarationNode:
return _parent_class._with()

func play() -> AnimaNode:
return _parent_class.play()

func play_with_delay(delay: float) -> AnimaNode:
return _parent_class.play_with_delay(delay)

func play_with_speed(speed: float) -> AnimaNode:
return _parent_class.play_with_speed(speed)

func play_backwards() -> AnimaNode:
return _parent_class.play_backwards()

func play_backwards_with_delay(delay: float) -> AnimaNode:
return _parent_class.play_backwards_with_delay(delay)

func play_backwards_with_speed(speed: float) -> AnimaNode:
return _parent_class.play_backwards_with_speed(speed)

func loop(times: int = -1) -> AnimaNode:
return _parent_class.loop(times)

func loop_in_circle(times: int = -1) -> AnimaNode:
return _parent_class.loop_in_circle(times)

func loop_in_circle_with_delay(delay: float, times: int = -1) -> AnimaNode:
return _parent_class.loop_in_circle_with_delay(delay, times)

func loop_in_circle_with_speed(speed: float, times: int = -1) -> AnimaNode:
return _parent_class.loop_in_circle_with_speed(speed, times)

func loop_in_circle_with_delay_and_speed(delay: float, speed: float, times: int = -1) -> AnimaNode:
return _parent_class.loop_in_circle_with_delay_and_speed(delay, speed, times)

func loop_backwards(times: int = -1) -> AnimaNode:
return _parent_class.loop_backwards(times)

func loop_backwards_with_speed(speed: float, times: int = -1) -> AnimaNode:
return _parent_class.loop_backwards_with_speed(speed, times)

func loop_backwards_with_delay(delay: float, times: int = -1) -> AnimaNode:
return _parent_class.loop_backwards_with_delay(delay, times)

func loop_backwards_with_delay_and_speed(delay: float, speed: float, times: int = -1) -> AnimaNode:
return _parent_class.loop_backwards_with_delay_and_speed(delay, speed, times)

func loop_with_delay(delay: float, times: int = -1) -> AnimaNode:
return _parent_class.loop_with_delay(delay, times)

func loop_with_speed(speed: float, times: int = -1) -> AnimaNode:
return _parent_class.loop_with_speed(speed, times)

func loop_times_with_delay(times: float, delay: float) -> AnimaNode:
return _parent_class.loop_times_with_delay(times, delay)

func loop_times_with_delay_and_speed(times: int, delay: float, speed: float) -> AnimaNode:
return _parent_class.loop_times_with_delay_and_speed(times, delay, speed)
Loading

0 comments on commit 5f490c9

Please sign in to comment.