From 4c9a58a3333c29e7745b7de9dee1543fe7ad35ff Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 11 Apr 2020 20:10:07 +0300 Subject: [PATCH] Animation only plays on frames of the same tag If there are no tags, the animation plays on all frames, as before. Currently no front-end way of toggling this behavior. --- Scripts/AnimationTimeline.gd | 16 ++++++++++++---- Scripts/FrameButton.gd | 2 +- Scripts/Global.gd | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Scripts/AnimationTimeline.gd b/Scripts/AnimationTimeline.gd index 4737c1469..5c4ad063b 100644 --- a/Scripts/AnimationTimeline.gd +++ b/Scripts/AnimationTimeline.gd @@ -132,8 +132,16 @@ func _on_FirstFrame_pressed() -> void: Global.current_frame = 0 func _on_AnimationTimer_timeout() -> void: + var first_frame := 0 + var last_frame := Global.canvases.size() - 1 + if Global.play_only_tags: + for tag in Global.animation_tags: + if Global.current_frame + 1 >= tag[2] && Global.current_frame + 1 <= tag[3]: + first_frame = tag[2] - 1 + last_frame = min(Global.canvases.size() - 1, tag[3] - 1) + if animation_forward: - if Global.current_frame < Global.canvases.size() - 1: + if Global.current_frame < last_frame: Global.current_frame += 1 else: match animation_loop: @@ -142,13 +150,13 @@ func _on_AnimationTimer_timeout() -> void: Global.play_backwards.pressed = false Global.animation_timer.stop() 1: # Cycle loop - Global.current_frame = 0 + Global.current_frame = first_frame 2: # Ping pong loop animation_forward = false _on_AnimationTimer_timeout() else: - if Global.current_frame > 0: + if Global.current_frame > first_frame: Global.current_frame -= 1 else: match animation_loop: @@ -157,7 +165,7 @@ func _on_AnimationTimer_timeout() -> void: Global.play_forward.pressed = false Global.animation_timer.stop() 1: # Cycle loop - Global.current_frame = Global.canvases.size() - 1 + Global.current_frame = last_frame 2: # Ping pong loop animation_forward = true _on_AnimationTimer_timeout() diff --git a/Scripts/FrameButton.gd b/Scripts/FrameButton.gd index 430dd0b97..e40740cbc 100644 --- a/Scripts/FrameButton.gd +++ b/Scripts/FrameButton.gd @@ -6,7 +6,7 @@ var layer := 0 onready var popup_menu := $PopupMenu func _ready() -> void: - hint_tooltip = "Frame: %s, Layer: %s" % [frame, layer] + hint_tooltip = "Frame: %s, Layer: %s" % [frame + 1, layer] if Global.canvases[frame] in Global.layers[layer][5]: get_node("LinkedIndicator").visible = true popup_menu.set_item_disabled(4, false) # Unlink cel diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 800c45d43..6952238e0 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -35,6 +35,7 @@ var transparent_background : ImageTexture var selected_pixels := [] var image_clipboard : Image var animation_tags := [] setget animation_tags_changed # [Name, Color, From, To] +var play_only_tags := true # warning-ignore:unused_class_variable var theme_type := "Dark"