1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Fixed crash when choosing "no loop" after looping with 1 frame

Before this commit, if you had one frame in the timeline and clicked the loop button until it went back to no loop WHILE the animation was playing, Pixelorama would crash. Now, if you're left with only one frame, Pixelorama will stop animating. Also updated the loop button's hint tooltip.
This commit is contained in:
OverloadedOrama 2019-11-24 00:52:17 +02:00
parent 36b462c30a
commit e940029979
3 changed files with 33 additions and 17 deletions

View file

@ -482,6 +482,7 @@ mouse_default_cursor_shape = 2
text = "Vert. Mirror" text = "Vert. Mirror"
[node name="CanvasAndTimeline" type="VBoxContainer" parent="MenuAndUI/UI"] [node name="CanvasAndTimeline" type="VBoxContainer" parent="MenuAndUI/UI"]
editor/display_folded = true
margin_left = 242.0 margin_left = 242.0
margin_right = 928.0 margin_right = 928.0
margin_bottom = 620.0 margin_bottom = 620.0
@ -605,6 +606,7 @@ margin_right = 4.0
margin_bottom = 71.0 margin_bottom = 71.0
[node name="AnimationContainer" type="HBoxContainer" parent="MenuAndUI/UI/CanvasAndTimeline/AnimationTimeline"] [node name="AnimationContainer" type="HBoxContainer" parent="MenuAndUI/UI/CanvasAndTimeline/AnimationTimeline"]
editor/display_folded = true
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_left = 15.0 margin_left = 15.0
@ -616,7 +618,6 @@ margin_bottom = 138.0
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="AnimationButtons" type="Control" parent="MenuAndUI/UI/CanvasAndTimeline/AnimationTimeline/AnimationContainer/TimelineContainer"] [node name="AnimationButtons" type="Control" parent="MenuAndUI/UI/CanvasAndTimeline/AnimationTimeline/AnimationContainer/TimelineContainer"]
editor/display_folded = true
margin_right = 525.0 margin_right = 525.0
margin_bottom = 24.0 margin_bottom = 24.0
rect_min_size = Vector2( 0, 24 ) rect_min_size = Vector2( 0, 24 )
@ -690,6 +691,7 @@ mouse_default_cursor_shape = 2
texture_normal = ExtResource( 20 ) texture_normal = ExtResource( 20 )
[node name="LoopButtons" type="HBoxContainer" parent="MenuAndUI/UI/CanvasAndTimeline/AnimationTimeline/AnimationContainer/TimelineContainer/AnimationButtons"] [node name="LoopButtons" type="HBoxContainer" parent="MenuAndUI/UI/CanvasAndTimeline/AnimationTimeline/AnimationContainer/TimelineContainer/AnimationButtons"]
editor/display_folded = true
anchor_left = 1.0 anchor_left = 1.0
anchor_top = 0.5 anchor_top = 0.5
anchor_right = 1.0 anchor_right = 1.0
@ -713,9 +715,7 @@ suffix = "FPS"
margin_left = 78.0 margin_left = 78.0
margin_right = 98.0 margin_right = 98.0
margin_bottom = 24.0 margin_bottom = 24.0
hint_tooltip = "No: Animation doesn't loop hint_tooltip = "No loop"
Cycle: Animation plays again when it reaches the last frame
Ping-pong: Animation plays again but backwards when it reaches the last frame"
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
texture_normal = ExtResource( 21 ) texture_normal = ExtResource( 21 )
@ -806,6 +806,7 @@ margin_right = 671.0
margin_bottom = 138.0 margin_bottom = 138.0
[node name="LayerPanel" type="Panel" parent="MenuAndUI/UI"] [node name="LayerPanel" type="Panel" parent="MenuAndUI/UI"]
editor/display_folded = true
margin_left = 928.0 margin_left = 928.0
margin_right = 1152.0 margin_right = 1152.0
margin_bottom = 620.0 margin_bottom = 620.0

View file

@ -195,9 +195,11 @@ func undo(_canvases : Array, layer_index : int = -1) -> void:
if action_name == "Add Frame": if action_name == "Add Frame":
canvas_parent.remove_child(_canvases[0]) canvas_parent.remove_child(_canvases[0])
frame_container.remove_child(_canvases[0].frame_button) frame_container.remove_child(_canvases[0].frame_button)
if len(canvases) == 1: #This actually means that canvases.size is one, but it hasn't been updated yet
Global.remove_frame_button.disabled = true if canvases.size() == 2: #Stop animating
Global.remove_frame_button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN play_forward.pressed = false
play_backwards.pressed = false
animation_timer.stop()
elif action_name == "Remove Frame": elif action_name == "Remove Frame":
canvas_parent.add_child(_canvases[0]) canvas_parent.add_child(_canvases[0])
canvas_parent.move_child(_canvases[0], _canvases[0].frame) canvas_parent.move_child(_canvases[0], _canvases[0].frame)
@ -238,6 +240,10 @@ func redo(_canvases : Array, layer_index : int = -1) -> void:
elif action_name == "Remove Frame": elif action_name == "Remove Frame":
canvas_parent.remove_child(_canvases[0]) canvas_parent.remove_child(_canvases[0])
frame_container.remove_child(_canvases[0].frame_button) frame_container.remove_child(_canvases[0].frame_button)
if canvases.size() == 1: #Stop animating
play_forward.pressed = false
play_backwards.pressed = false
animation_timer.stop()
elif action_name == "Change Frame Order": elif action_name == "Change Frame Order":
frame_container.move_child(_canvases[0].frame_button, _canvases[0].frame) frame_container.move_child(_canvases[0].frame_button, _canvases[0].frame)
canvas_parent.move_child(_canvases[0], _canvases[0].frame) canvas_parent.move_child(_canvases[0], _canvases[0].frame)

View file

@ -314,7 +314,7 @@ func _on_OpenSprite_file_selected(path : String) -> void:
canvas.layers.append([image, tex, layer_name, true]) canvas.layers.append([image, tex, layer_name, true])
layer_line = file.get_line() layer_line = file.get_line()
var guide_line := file.get_line() var guide_line := file.get_line() #"guideline" no pun intended
while guide_line == "|": #Load guides while guide_line == "|": #Load guides
var guide := Guide.new() var guide := Guide.new()
guide.default_color = Color.purple guide.default_color = Color.purple
@ -723,34 +723,43 @@ func _on_LoopAnim_pressed() -> void:
#Make it loop #Make it loop
animation_loop = 1 animation_loop = 1
Global.loop_animation_button.texture_normal = preload("res://Assets/Graphics/Timeline/Loop.png") Global.loop_animation_button.texture_normal = preload("res://Assets/Graphics/Timeline/Loop.png")
Global.loop_animation_button.hint_tooltip = "Cycle loop"
"res://Assets/Graphics/Timeline/Loop.png": "res://Assets/Graphics/Timeline/Loop.png":
#Make it ping-pong #Make it ping-pong
animation_loop = 2 animation_loop = 2
Global.loop_animation_button.texture_normal = preload("res://Assets/Graphics/Timeline/Loop_PingPong.png") Global.loop_animation_button.texture_normal = preload("res://Assets/Graphics/Timeline/Loop_PingPong.png")
Global.loop_animation_button.hint_tooltip = "Ping-pong loop"
"res://Assets/Graphics/Timeline/Loop_PingPong.png": "res://Assets/Graphics/Timeline/Loop_PingPong.png":
#Make it stop #Make it stop
animation_loop = 0 animation_loop = 0
Global.loop_animation_button.texture_normal = preload("res://Assets/Graphics/Timeline/Loop_None.png") Global.loop_animation_button.texture_normal = preload("res://Assets/Graphics/Timeline/Loop_None.png")
Global.loop_animation_button.hint_tooltip = "No loop"
func _on_PlayForward_toggled(button_pressed) -> void: func _on_PlayForward_toggled(button_pressed) -> void:
Global.play_backwards.pressed = false Global.play_backwards.pressed = false
if Global.canvases.size() == 1:
Global.play_forward.pressed = !button_pressed
return
if button_pressed: if button_pressed:
$AnimationTimer.wait_time = 1 / fps Global.animation_timer.wait_time = 1 / fps
$AnimationTimer.start() Global.animation_timer.start()
animation_forward = true animation_forward = true
else: else:
$AnimationTimer.stop() Global.animation_timer.stop()
func _on_PlayBackwards_toggled(button_pressed) -> void: func _on_PlayBackwards_toggled(button_pressed) -> void:
Global.play_forward.pressed = false Global.play_forward.pressed = false
if Global.canvases.size() == 1:
Global.play_backwards.pressed = !button_pressed
return
if button_pressed: if button_pressed:
$AnimationTimer.wait_time = 1 / fps Global.animation_timer.wait_time = 1 / fps
$AnimationTimer.start() Global.animation_timer.start()
animation_forward = false animation_forward = false
else: else:
$AnimationTimer.stop() Global.animation_timer.stop()
func _on_NextFrame_pressed() -> void: func _on_NextFrame_pressed() -> void:
if Global.current_frame < Global.canvases.size() - 1: if Global.current_frame < Global.canvases.size() - 1:
@ -775,7 +784,7 @@ func _on_AnimationTimer_timeout() -> void:
0: #No loop 0: #No loop
Global.play_forward.pressed = false Global.play_forward.pressed = false
Global.play_backwards.pressed = false Global.play_backwards.pressed = false
$AnimationTimer.stop() Global.animation_timer.stop()
1: #Cycle loop 1: #Cycle loop
Global.current_frame = 0 Global.current_frame = 0
2: #Ping pong loop 2: #Ping pong loop
@ -790,7 +799,7 @@ func _on_AnimationTimer_timeout() -> void:
0: #No loop 0: #No loop
Global.play_backwards.pressed = false Global.play_backwards.pressed = false
Global.play_forward.pressed = false Global.play_forward.pressed = false
$AnimationTimer.stop() Global.animation_timer.stop()
1: #Cycle loop 1: #Cycle loop
Global.current_frame = Global.canvases.size() - 1 Global.current_frame = Global.canvases.size() - 1
2: #Ping pong loop 2: #Ping pong loop
@ -799,7 +808,7 @@ func _on_AnimationTimer_timeout() -> void:
func _on_FPSValue_value_changed(value) -> void: func _on_FPSValue_value_changed(value) -> void:
fps = float(value) fps = float(value)
$AnimationTimer.wait_time = 1 / fps Global.animation_timer.wait_time = 1 / fps
func _on_PastOnionSkinning_value_changed(value) -> void: func _on_PastOnionSkinning_value_changed(value) -> void:
Global.onion_skinning_past_rate = int(value) Global.onion_skinning_past_rate = int(value)