mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 13:44:42 -04:00
Make FPS project-specific and store it in the pxo files
This commit is contained in:
parent
05c9ef70d4
commit
031efc0cdb
7 changed files with 52 additions and 32 deletions
|
@ -9,7 +9,7 @@ func _draw() -> void:
|
|||
if frame >= current_project.frames.size():
|
||||
frame = current_project.current_frame
|
||||
|
||||
$AnimationTimer.wait_time = current_project.frames[frame].duration * (1 / Global.animation_timeline.fps)
|
||||
$AnimationTimer.wait_time = current_project.frames[frame].duration * (1 / Global.current_project.fps)
|
||||
|
||||
if animation_timer.is_stopped():
|
||||
frame = current_project.current_frame
|
||||
|
@ -30,6 +30,6 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
frame = 0
|
||||
|
||||
$AnimationTimer.set_one_shot(true)
|
||||
$AnimationTimer.wait_time = Global.current_project.frames[frame].duration * (1 / Global.animation_timeline.fps)
|
||||
$AnimationTimer.wait_time = Global.current_project.frames[frame].duration * (1 / Global.current_project.fps)
|
||||
$AnimationTimer.start()
|
||||
update()
|
||||
|
|
|
@ -149,7 +149,7 @@ func add_animated_preview() -> void:
|
|||
|
||||
previews.add_child(container)
|
||||
frame_timer.set_one_shot(true) #The wait_time it can't change correctly if it is playing
|
||||
frame_timer.wait_time = Global.current_project.frames[animated_preview_current_frame].duration * (1 / Global.animation_timeline.fps)
|
||||
frame_timer.wait_time = Global.current_project.frames[animated_preview_current_frame].duration * (1 / Global.current_project.fps)
|
||||
frame_timer.start()
|
||||
|
||||
|
||||
|
@ -363,14 +363,14 @@ func _on_FrameTimer_timeout() -> void:
|
|||
animated_preview_current_frame = 0
|
||||
else:
|
||||
animated_preview_current_frame += 1
|
||||
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame - 1) % (animated_preview_frames.size())].duration * (1 / Global.animation_timeline.fps)
|
||||
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame - 1) % (animated_preview_frames.size())].duration * (1 / Global.current_project.fps)
|
||||
frame_timer.start()
|
||||
Export.AnimationDirection.BACKWARDS:
|
||||
if animated_preview_current_frame == 0:
|
||||
animated_preview_current_frame = Export.processed_images.size() - 1
|
||||
else:
|
||||
animated_preview_current_frame -= 1
|
||||
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame + 1) % (animated_preview_frames.size())].duration * (1 / Global.animation_timeline.fps)
|
||||
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame + 1) % (animated_preview_frames.size())].duration * (1 / Global.current_project.fps)
|
||||
frame_timer.start()
|
||||
Export.AnimationDirection.PING_PONG:
|
||||
match pingpong_direction:
|
||||
|
@ -382,7 +382,7 @@ func _on_FrameTimer_timeout() -> void:
|
|||
animated_preview_current_frame = 0
|
||||
else:
|
||||
animated_preview_current_frame += 1
|
||||
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame - 1) % (animated_preview_frames.size())].duration * (1 / Global.animation_timeline.fps)
|
||||
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame - 1) % (animated_preview_frames.size())].duration * (1 / Global.current_project.fps)
|
||||
frame_timer.start()
|
||||
Export.AnimationDirection.BACKWARDS:
|
||||
if animated_preview_current_frame == 0:
|
||||
|
@ -392,7 +392,7 @@ func _on_FrameTimer_timeout() -> void:
|
|||
pingpong_direction = Export.AnimationDirection.FORWARD
|
||||
else:
|
||||
animated_preview_current_frame -= 1
|
||||
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame + 1) % (animated_preview_frames.size())].duration * (1 / Global.animation_timeline.fps)
|
||||
frame_timer.wait_time = Global.current_project.frames[(animated_preview_current_frame + 1) % (animated_preview_frames.size())].duration * (1 / Global.current_project.fps)
|
||||
frame_timer.start()
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
extends Panel
|
||||
|
||||
var fps := 6.0
|
||||
var animation_loop := 1 # 0 is no loop, 1 is cycle loop, 2 is ping-pong loop
|
||||
var animation_forward := true
|
||||
var first_frame := 0
|
||||
|
@ -8,13 +7,15 @@ var last_frame := 0
|
|||
|
||||
var timeline_scroll : ScrollContainer
|
||||
var tag_scroll_container : ScrollContainer
|
||||
var fps_spinbox : SpinBox
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
timeline_scroll = Global.find_node_by_name(self, "TimelineScroll")
|
||||
tag_scroll_container = Global.find_node_by_name(self, "TagScroll")
|
||||
fps_spinbox = find_node("FPSValue")
|
||||
timeline_scroll.get_h_scrollbar().connect("value_changed", self, "_h_scroll_changed")
|
||||
Global.animation_timer.wait_time = 1 / fps
|
||||
Global.animation_timer.wait_time = 1 / Global.current_project.fps
|
||||
|
||||
|
||||
func _h_scroll_changed(value : float) -> void:
|
||||
|
@ -230,6 +231,7 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
$AnimationTimer.stop()
|
||||
return
|
||||
|
||||
var fps = Global.current_project.fps
|
||||
if animation_forward:
|
||||
if Global.current_project.current_frame < last_frame:
|
||||
Global.current_project.current_frame += 1
|
||||
|
@ -299,6 +301,7 @@ func play_animation(play : bool, forward_dir : bool) -> void:
|
|||
if play:
|
||||
Global.animation_timer.set_one_shot(true) # The wait_time can't change correctly if it is playing
|
||||
var duration : float = Global.current_project.frames[Global.current_project.current_frame].duration
|
||||
var fps = Global.current_project.fps
|
||||
Global.animation_timer.wait_time = duration * (1 / fps)
|
||||
Global.animation_timer.start()
|
||||
animation_forward = forward_dir
|
||||
|
@ -325,8 +328,8 @@ func _on_FirstFrame_pressed() -> void:
|
|||
|
||||
|
||||
func _on_FPSValue_value_changed(value : float) -> void:
|
||||
fps = float(value)
|
||||
Global.animation_timer.wait_time = 1 / fps
|
||||
Global.current_project.fps = float(value)
|
||||
Global.animation_timer.wait_time = 1 / Global.current_project.fps
|
||||
|
||||
|
||||
func _on_PastOnionSkinning_value_changed(value : float) -> void:
|
||||
|
|
|
@ -23,6 +23,17 @@
|
|||
[ext_resource path="res://assets/graphics/dark_themes/tools/zoom.png" type="Texture" id=21]
|
||||
[ext_resource path="res://src/UI/ViewportContainer.gd" type="Script" id=23]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 9 )
|
||||
shader_param/size = 10.0
|
||||
shader_param/color1 = Color( 0.7, 0.7, 0.7, 1 )
|
||||
shader_param/color2 = Color( 1, 1, 1, 1 )
|
||||
shader_param/offset = Vector2( 0, 0 )
|
||||
shader_param/scale = Vector2( 0, 0 )
|
||||
shader_param/rect_size = Vector2( 0, 0 )
|
||||
shader_param/follow_movement = false
|
||||
shader_param/follow_scale = false
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=2]
|
||||
shader = ExtResource( 9 )
|
||||
shader_param/size = 10.0
|
||||
|
@ -34,18 +45,7 @@ shader_param/rect_size = Vector2( 0, 0 )
|
|||
shader_param/follow_movement = false
|
||||
shader_param/follow_scale = false
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=3]
|
||||
shader = ExtResource( 9 )
|
||||
shader_param/size = 10.0
|
||||
shader_param/color1 = Color( 0.7, 0.7, 0.7, 1 )
|
||||
shader_param/color2 = Color( 1, 1, 1, 1 )
|
||||
shader_param/offset = Vector2( 0, 0 )
|
||||
shader_param/scale = Vector2( 0, 0 )
|
||||
shader_param/rect_size = Vector2( 0, 0 )
|
||||
shader_param/follow_movement = false
|
||||
shader_param/follow_scale = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.0627451, 0.0627451, 0.0627451, 1 )
|
||||
expand_margin_top = 6.0
|
||||
|
||||
|
@ -299,7 +299,7 @@ usage = 0
|
|||
render_target_update_mode = 3
|
||||
|
||||
[node name="TransparentChecker" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportandVerticalRuler/ViewportContainer/Viewport" instance=ExtResource( 5 )]
|
||||
material = SubResource( 2 )
|
||||
material = SubResource( 1 )
|
||||
|
||||
[node name="Canvas" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportandVerticalRuler/ViewportContainer/Viewport" instance=ExtResource( 19 )]
|
||||
|
||||
|
@ -331,7 +331,7 @@ handle_input_locally = false
|
|||
render_target_update_mode = 3
|
||||
|
||||
[node name="TransparentChecker" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportContainer2/Viewport" instance=ExtResource( 5 )]
|
||||
material = SubResource( 3 )
|
||||
material = SubResource( 2 )
|
||||
|
||||
[node name="CanvasPreview" parent="CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportContainer2/Viewport" instance=ExtResource( 2 )]
|
||||
|
||||
|
@ -343,7 +343,7 @@ script = ExtResource( 7 )
|
|||
[node name="AnimationTimeline" parent="CanvasAndTimeline" instance=ExtResource( 18 )]
|
||||
margin_top = 492.0
|
||||
margin_bottom = 692.0
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
custom_styles/panel = SubResource( 3 )
|
||||
|
||||
[node name="RightPanel" type="Panel" parent="."]
|
||||
margin_left = 950.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue