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

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