1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-20 12:33:14 +00:00

Remove Global.animation_timer

This commit is contained in:
Emmanouil Papadeas 2024-10-11 16:38:35 +03:00
parent dddcfed3c4
commit b9bf8290b0
5 changed files with 24 additions and 29 deletions

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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:

View file

@ -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: