diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 2e504068d..bb8dcd207 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -626,8 +626,6 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn") @onready var cursor_position_label: Label = top_menu_container.find_child("CursorPosition") ## The animation timeline. It has the [param AnimationTimeline.gd] script attached. @onready var animation_timeline: Panel = control.find_child("Animation Timeline") -## The timer used by the animation timeline. -@onready var animation_timer: Timer = animation_timeline.find_child("AnimationTimer") ## The container of frame buttons @onready var frame_hbox: HBoxContainer = animation_timeline.find_child("FrameHBox") ## The container of layer buttons diff --git a/src/Tools/BaseDraw.gd b/src/Tools/BaseDraw.gd index 295ca9dfa..83ff42273 100644 --- a/src/Tools/BaseDraw.gd +++ b/src/Tools/BaseDraw.gd @@ -238,7 +238,7 @@ func commit_undo() -> void: var project := Global.current_project var frame := -1 var layer := -1 - if Global.animation_timer.is_stopped() and project.selected_cels.size() == 1: + if Global.animation_timeline.animation_timer.is_stopped() and project.selected_cels.size() == 1: frame = project.current_frame layer = project.current_layer @@ -694,7 +694,7 @@ func _get_undo_data() -> Dictionary: var data := {} var project := Global.current_project var cels: Array[BaseCel] = [] - if Global.animation_timer.is_stopped(): + if Global.animation_timeline.animation_timer.is_stopped(): for cel_index in project.selected_cels: cels.append(project.frames[cel_index[0]].cels[cel_index[1]]) else: diff --git a/src/Tools/DesignTools/Bucket.gd b/src/Tools/DesignTools/Bucket.gd index 1862f256c..794ed5422 100644 --- a/src/Tools/DesignTools/Bucket.gd +++ b/src/Tools/DesignTools/Bucket.gd @@ -487,7 +487,7 @@ func commit_undo() -> void: var project := Global.current_project var frame := -1 var layer := -1 - if Global.animation_timer.is_stopped() and project.selected_cels.size() == 1: + if Global.animation_timeline.animation_timer.is_stopped() and project.selected_cels.size() == 1: frame = project.current_frame layer = project.current_layer @@ -502,7 +502,7 @@ func commit_undo() -> void: func _get_undo_data() -> Dictionary: var data := {} - if Global.animation_timer.is_stopped(): + if Global.animation_timeline.animation_timer.is_stopped(): var images := _get_selected_draw_images() for image in images: data[image] = image.data diff --git a/src/Tools/UtilityTools/Move.gd b/src/Tools/UtilityTools/Move.gd index dcca36e9f..0520dcc6c 100644 --- a/src/Tools/UtilityTools/Move.gd +++ b/src/Tools/UtilityTools/Move.gd @@ -128,7 +128,7 @@ func _commit_undo(action: String) -> void: var project := Global.current_project var frame := -1 var layer := -1 - if Global.animation_timer.is_stopped() and project.selected_cels.size() == 1: + if Global.animation_timeline.animation_timer.is_stopped() and project.selected_cels.size() == 1: frame = project.current_frame layer = project.current_layer @@ -145,7 +145,7 @@ func _get_undo_data() -> Dictionary: var data := {} var project := Global.current_project var cels: Array[BaseCel] = [] - if Global.animation_timer.is_stopped(): + if Global.animation_timeline.animation_timer.is_stopped(): for cel_index in project.selected_cels: cels.append(project.frames[cel_index[0]].cels[cel_index[1]]) else: diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index e16cc793c..d495a2522 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -28,6 +28,7 @@ var global_layer_visibility := true var global_layer_lock := false var global_layer_expand := true +@onready var animation_timer := $AnimationTimer as Timer @onready var old_scroll := 0 ## The previous scroll state of $ScrollContainer. @onready var tag_spacer := %TagSpacer as Control @onready var layer_settings_container := %LayerSettingsContainer as VBoxContainer @@ -69,7 +70,7 @@ func _ready() -> void: cel_size_slider.value = cel_size add_layer_list.get_popup().id_pressed.connect(add_layer) frame_scroll_bar.value_changed.connect(_frame_scroll_changed) - Global.animation_timer.wait_time = 1 / Global.current_project.fps + animation_timer.wait_time = 1 / Global.current_project.fps fps_spinbox.value = Global.current_project.fps _fill_blend_modes_option_button() # Config loading. @@ -651,7 +652,7 @@ func _on_AnimationTimer_timeout() -> void: if first_frame == last_frame: play_forward.button_pressed = false play_backwards.button_pressed = false - Global.animation_timer.stop() + animation_timer.stop() return Global.canvas.selection.transform_content_confirm() @@ -661,25 +662,23 @@ func _on_AnimationTimer_timeout() -> void: if project.current_frame < last_frame: project.selected_cels.clear() project.change_cel(project.current_frame + 1, -1) - Global.animation_timer.wait_time = ( - project.frames[project.current_frame].duration * (1 / fps) - ) - Global.animation_timer.start() # Change the frame, change the wait time and start a cycle + animation_timer.wait_time = project.frames[project.current_frame].duration * (1.0 / fps) + animation_timer.start() # Change the frame, change the wait time and start a cycle else: match animation_loop: 0: # No loop play_forward.button_pressed = false play_backwards.button_pressed = false - Global.animation_timer.stop() + animation_timer.stop() animation_finished.emit() is_animation_running = false 1: # Cycle loop project.selected_cels.clear() project.change_cel(first_frame, -1) - Global.animation_timer.wait_time = ( + animation_timer.wait_time = ( project.frames[project.current_frame].duration * (1 / fps) ) - Global.animation_timer.start() + animation_timer.start() 2: # Ping pong loop animation_forward = false _on_AnimationTimer_timeout() @@ -688,25 +687,23 @@ func _on_AnimationTimer_timeout() -> void: if project.current_frame > first_frame: project.selected_cels.clear() project.change_cel(project.current_frame - 1, -1) - Global.animation_timer.wait_time = ( - project.frames[project.current_frame].duration * (1 / fps) - ) - Global.animation_timer.start() + animation_timer.wait_time = project.frames[project.current_frame].duration * (1.0 / fps) + animation_timer.start() else: match animation_loop: 0: # No loop play_backwards.button_pressed = false play_forward.button_pressed = false - Global.animation_timer.stop() + animation_timer.stop() animation_finished.emit() is_animation_running = false 1: # Cycle loop project.selected_cels.clear() project.change_cel(last_frame, -1) - Global.animation_timer.wait_time = ( + animation_timer.wait_time = ( project.frames[project.current_frame].duration * (1 / fps) ) - Global.animation_timer.start() + animation_timer.start() 2: # Ping pong loop animation_forward = true _on_AnimationTimer_timeout() @@ -746,16 +743,16 @@ func play_animation(play: bool, forward_dir: bool) -> void: play_forward.toggled.connect(_on_PlayForward_toggled) if play: - Global.animation_timer.set_one_shot(true) # wait_time can't change correctly if it's playing + animation_timer.set_one_shot(true) # wait_time can't change correctly if it's playing var duration: float = ( Global.current_project.frames[Global.current_project.current_frame].duration ) - Global.animation_timer.wait_time = duration * (1 / Global.current_project.fps) - Global.animation_timer.start() + animation_timer.wait_time = duration * (1 / Global.current_project.fps) + animation_timer.start() animation_forward = forward_dir animation_started.emit(forward_dir) else: - Global.animation_timer.stop() + animation_timer.stop() animation_finished.emit() is_animation_running = play @@ -791,7 +788,7 @@ func _on_FirstFrame_pressed() -> void: func _on_FPSValue_value_changed(value: float) -> void: Global.current_project.fps = value - Global.animation_timer.wait_time = 1 / Global.current_project.fps + animation_timer.wait_time = 1 / Global.current_project.fps func _on_PastOnionSkinning_value_changed(value: float) -> void: