Made a Frame class, no longer use multiple Canvases for multiple frames

The Canvas is now single node, instead of having multiple canvases for each frame. This should also be a performance optimization, since there are less canvas nodes, so there are less _input() calls. It should also fix a rare Undo/Redo issue with motion drawing and making lines. Could be unstable, needs more testing.

As a side effect, the guides are now the same for all frames, so this should also close #246.
This commit is contained in:
OverloadedOrama 2020-06-03 02:14:24 +03:00
parent d8136a3e17
commit 54b628f6cb
17 changed files with 412 additions and 459 deletions

View file

@ -4,7 +4,7 @@ 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
var last_frame : int = Global.canvases.size() - 1
var last_frame : int = Global.frames.size() - 1
var timeline_scroll : ScrollContainer
var tag_scroll_container : ScrollContainer
@ -24,47 +24,48 @@ func _h_scroll_changed(value : float) -> void:
func add_frame() -> void:
var new_canvas : Canvas = load("res://src/Canvas.tscn").instance()
new_canvas.size = Global.canvas.size
new_canvas.frame = Global.canvases.size()
var frame : Frame = Global.canvas.new_empty_frame()
var new_frames : Array = Global.frames.duplicate()
new_frames.append(frame)
var new_layers : Array = Global.layers.duplicate()
# Loop through the array to create new classes for each element, so that they
# won't be the same as the original array's classes. Needed for undo/redo to work properly.
for i in new_layers.size():
var new_linked_cels = new_layers[i].linked_cels.duplicate()
new_layers[i] = Layer.new(new_layers[i].name, new_layers[i].visible, new_layers[i].locked, new_layers[i].frame_container, new_layers[i].new_cels_linked, new_linked_cels)
var new_canvases : Array = Global.canvases.duplicate()
new_canvases.append(new_canvas)
for l_i in range(new_layers.size()):
if new_layers[l_i].new_cels_linked: # If the link button is pressed
new_layers[l_i].linked_cels.append(frame)
frame.cels[l_i].image = new_layers[l_i].linked_cels[0].cels[l_i].image
frame.cels[l_i].image_texture = new_layers[l_i].linked_cels[0].cels[l_i].image_texture
Global.undos += 1
Global.undo_redo.create_action("Add Frame")
Global.undo_redo.add_do_method(Global, "redo", [new_canvas])
Global.undo_redo.add_undo_method(Global, "undo", [new_canvas])
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.add_do_property(Global, "canvases", new_canvases)
Global.undo_redo.add_do_property(Global, "canvas", new_canvas)
Global.undo_redo.add_do_property(Global, "current_frame", new_canvases.size() - 1)
Global.undo_redo.add_do_property(Global, "frames", new_frames)
Global.undo_redo.add_do_property(Global, "current_frame", new_frames.size() - 1)
Global.undo_redo.add_do_property(Global, "layers", new_layers)
for c in Global.canvases:
Global.undo_redo.add_do_property(c, "visible", false)
Global.undo_redo.add_undo_property(c, "visible", c.visible)
for l_i in range(Global.layers.size()):
if Global.layers[l_i].new_cels_linked: # If the link button is pressed
Global.layers[l_i].linked_cels.append(new_canvas)
Global.undo_redo.add_undo_property(Global, "canvases", Global.canvases)
Global.undo_redo.add_undo_property(Global, "canvas", Global.canvas)
Global.undo_redo.add_undo_property(Global, "frames", Global.frames)
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
Global.undo_redo.commit_action()
func _on_DeleteFrame_pressed(frame := -1) -> void:
if Global.canvases.size() == 1:
if Global.frames.size() == 1:
return
if frame == -1:
frame = Global.current_frame
var canvas : Canvas = Global.canvases[frame]
var new_canvases : Array = Global.canvases.duplicate()
new_canvases.erase(canvas)
var frame_to_delete : Frame = Global.frames[frame]
var new_frames : Array = Global.frames.duplicate()
new_frames.erase(frame_to_delete)
var current_frame := Global.current_frame
if current_frame > 0 && current_frame == new_canvases.size(): # If it's the last frame
if current_frame > 0 && current_frame == new_frames.size(): # If it's the last frame
current_frame -= 1
var new_animation_tags := Global.animation_tags.duplicate()
@ -96,34 +97,24 @@ func _on_DeleteFrame_pressed(frame := -1) -> void:
for layer in new_layers:
for linked in layer.linked_cels:
if linked == Global.canvases[frame]:
if linked == Global.frames[frame]:
layer.linked_cels.erase(linked)
Global.undos += 1
Global.undo_redo.create_action("Remove Frame")
Global.undo_redo.add_do_property(Global, "canvases", new_canvases)
Global.undo_redo.add_do_property(Global, "canvas", new_canvases[current_frame])
Global.undo_redo.add_do_property(Global, "frames", new_frames)
Global.undo_redo.add_do_property(Global, "current_frame", current_frame)
Global.undo_redo.add_do_property(Global, "animation_tags", new_animation_tags)
Global.undo_redo.add_do_property(Global, "layers", new_layers)
# Change the frame value of the canvaseso on the right
# for example, if frame "3" was deleted, then "4" would have to become "3"
for i in range(frame, new_canvases.size()):
var c : Canvas = new_canvases[i]
Global.undo_redo.add_do_property(c, "frame", i)
Global.undo_redo.add_undo_property(c, "frame", c.frame)
Global.undo_redo.add_undo_property(Global, "canvases", Global.canvases)
Global.undo_redo.add_undo_property(Global, "canvas", canvas)
Global.undo_redo.add_undo_property(Global, "frames", Global.frames)
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
Global.undo_redo.add_undo_property(Global, "animation_tags", Global.animation_tags)
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
Global.undo_redo.add_do_method(Global, "redo", [canvas])
Global.undo_redo.add_undo_method(Global, "undo", [canvas])
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.commit_action()
@ -131,19 +122,16 @@ func _on_CopyFrame_pressed(frame := -1) -> void:
if frame == -1:
frame = Global.current_frame
var canvas : Canvas = Global.canvases[frame]
var new_canvas : Canvas = load("res://src/Canvas.tscn").instance()
new_canvas.size = Global.canvas.size
new_canvas.frame = Global.canvases.size()
var new_frame := Frame.new()
var new_canvases := Global.canvases.duplicate()
new_canvases.insert(frame + 1, new_canvas)
var new_frames := Global.frames.duplicate()
new_frames.insert(frame + 1, new_frame)
for layer in canvas.layers: # Copy every layer
for cel in Global.frames[frame].cels: # Copy every cel
var sprite := Image.new()
sprite.copy_from(layer.image)
sprite.copy_from(cel.image)
sprite.lock()
new_canvas.layers.append(Cel.new(sprite, layer.opacity))
new_frame.cels.append(Cel.new(sprite, cel.opacity))
var new_animation_tags := Global.animation_tags.duplicate()
# Loop through the tags to create new classes for them, so that they won't be the same
@ -158,28 +146,18 @@ func _on_CopyFrame_pressed(frame := -1) -> void:
Global.undos += 1
Global.undo_redo.create_action("Add Frame")
Global.undo_redo.add_do_method(Global, "redo", [new_canvas])
Global.undo_redo.add_undo_method(Global, "undo", [new_canvas])
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.add_do_property(Global, "canvases", new_canvases)
Global.undo_redo.add_do_property(Global, "canvas", new_canvas)
Global.undo_redo.add_do_property(Global, "frames", new_frames)
Global.undo_redo.add_do_property(Global, "current_frame", frame + 1)
Global.undo_redo.add_do_property(Global, "animation_tags", new_animation_tags)
for i in range(Global.layers.size()):
for child in Global.layers[i].frame_container.get_children():
Global.undo_redo.add_do_property(child, "pressed", false)
Global.undo_redo.add_undo_property(child, "pressed", child.pressed)
for c in Global.canvases:
Global.undo_redo.add_do_property(c, "visible", false)
Global.undo_redo.add_undo_property(c, "visible", c.visible)
for i in range(frame, new_canvases.size()):
var c : Canvas = new_canvases[i]
Global.undo_redo.add_do_property(c, "frame", i)
Global.undo_redo.add_undo_property(c, "frame", c.frame)
Global.undo_redo.add_undo_property(Global, "canvases", Global.canvases)
Global.undo_redo.add_undo_property(Global, "canvas", Global.canvas)
Global.undo_redo.add_undo_property(Global, "frames", Global.frames)
Global.undo_redo.add_undo_property(Global, "current_frame", frame)
Global.undo_redo.add_undo_property(Global, "animation_tags", Global.animation_tags)
Global.undo_redo.commit_action()
@ -276,12 +254,12 @@ func _on_AnimationTimer_timeout() -> void:
func play_animation(play : bool, forward_dir : bool) -> void:
first_frame = 0
last_frame = Global.canvases.size() - 1
last_frame = Global.frames.size() - 1
if Global.play_only_tags:
for tag in Global.animation_tags:
if Global.current_frame + 1 >= tag.from && Global.current_frame + 1 <= tag.to:
first_frame = tag.from - 1
last_frame = min(Global.canvases.size() - 1, tag.to - 1)
last_frame = min(Global.frames.size() - 1, tag.to - 1)
if first_frame == last_frame:
if forward_dir:
@ -310,7 +288,7 @@ func play_animation(play : bool, forward_dir : bool) -> void:
func _on_NextFrame_pressed() -> void:
if Global.current_frame < Global.canvases.size() - 1:
if Global.current_frame < Global.frames.size() - 1:
Global.current_frame += 1
@ -320,7 +298,7 @@ func _on_PreviousFrame_pressed() -> void:
func _on_LastFrame_pressed() -> void:
Global.current_frame = Global.canvases.size() - 1
Global.current_frame = Global.frames.size() - 1
func _on_FirstFrame_pressed() -> void:
@ -359,27 +337,27 @@ func add_layer(is_new := true) -> void:
Global.undos += 1
Global.undo_redo.create_action("Add Layer")
for c in Global.canvases:
for f in Global.frames:
var new_layer := Image.new()
if is_new:
new_layer.create(c.size.x, c.size.y, false, Image.FORMAT_RGBA8)
new_layer.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
else: # Clone layer
new_layer.copy_from(c.layers[Global.current_layer].image)
new_layer.copy_from(f.cels[Global.current_layer].image)
new_layer.lock()
var new_canvas_layers : Array = c.layers.duplicate()
new_canvas_layers.append(Cel.new(new_layer, 1))
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
Global.undo_redo.add_undo_property(c, "layers", c.layers)
var new_cels : Array = f.cels.duplicate()
new_cels.append(Cel.new(new_layer, 1))
Global.undo_redo.add_do_property(f, "cels", new_cels)
Global.undo_redo.add_undo_property(f, "cels", f.cels)
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer + 1)
Global.undo_redo.add_do_property(Global, "layers", new_layers)
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.commit_action()
@ -393,17 +371,17 @@ func _on_RemoveLayer_pressed() -> void:
else:
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer)
for c in Global.canvases:
var new_canvas_layers : Array = c.layers.duplicate()
new_canvas_layers.remove(Global.current_layer)
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
Global.undo_redo.add_undo_property(c, "layers", c.layers)
for f in Global.frames:
var new_cels : Array = f.cels.duplicate()
new_cels.remove(Global.current_layer)
Global.undo_redo.add_do_property(f, "cels", new_cels)
Global.undo_redo.add_undo_property(f, "cels", f.cels)
Global.undo_redo.add_do_property(Global, "layers", new_layers)
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.commit_action()
@ -415,21 +393,21 @@ func change_layer_order(rate : int) -> void:
new_layers[Global.current_layer] = new_layers[change]
new_layers[change] = temp
Global.undo_redo.create_action("Change Layer Order")
for c in Global.canvases:
var new_canvas_layers : Array = c.layers.duplicate()
var temp_canvas = new_canvas_layers[Global.current_layer]
new_canvas_layers[Global.current_layer] = new_canvas_layers[change]
new_canvas_layers[change] = temp_canvas
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
Global.undo_redo.add_undo_property(c, "layers", c.layers)
for f in Global.frames:
var new_cels : Array = f.cels.duplicate()
var temp_canvas = new_cels[Global.current_layer]
new_cels[Global.current_layer] = new_cels[change]
new_cels[change] = temp_canvas
Global.undo_redo.add_do_property(f, "cels", new_cels)
Global.undo_redo.add_undo_property(f, "cels", f.cels)
Global.undo_redo.add_do_property(Global, "current_layer", change)
Global.undo_redo.add_do_property(Global, "layers", new_layers)
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.commit_action()
@ -443,35 +421,35 @@ func _on_MergeDownLayer_pressed() -> void:
Global.undos += 1
Global.undo_redo.create_action("Merge Layer")
for c in Global.canvases:
var new_canvas_layers : Array = c.layers.duplicate()
for i in new_canvas_layers.size():
new_canvas_layers[i] = Cel.new(new_canvas_layers[i].image, new_canvas_layers[i].opacity)
for f in Global.frames:
var new_cels : Array = f.cels.duplicate()
for i in new_cels.size():
new_cels[i] = Cel.new(new_cels[i].image, new_cels[i].opacity)
var selected_layer := Image.new()
selected_layer.copy_from(new_canvas_layers[Global.current_layer].image)
selected_layer.copy_from(new_cels[Global.current_layer].image)
selected_layer.lock()
if c.layers[Global.current_layer].opacity < 1: # If we have layer transparency
if f.cels[Global.current_layer].opacity < 1: # If we have layer transparency
for xx in selected_layer.get_size().x:
for yy in selected_layer.get_size().y:
var pixel_color : Color = selected_layer.get_pixel(xx, yy)
var alpha : float = pixel_color.a * c.layers[Global.current_layer].opacity
var alpha : float = pixel_color.a * f.cels[Global.current_layer].opacity
selected_layer.set_pixel(xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha))
var new_layer := Image.new()
new_layer.copy_from(c.layers[Global.current_layer - 1].image)
new_layer.copy_from(f.cels[Global.current_layer - 1].image)
new_layer.lock()
DrawingAlgos.blend_rect(new_layer, selected_layer, Rect2(c.position, c.size), Vector2.ZERO)
new_canvas_layers.remove(Global.current_layer)
if !selected_layer.is_invisible() and Global.layers[Global.current_layer - 1].linked_cels.size() > 1 and (c in Global.layers[Global.current_layer - 1].linked_cels):
new_layers[Global.current_layer - 1].linked_cels.erase(c)
new_canvas_layers[Global.current_layer - 1].image = new_layer
DrawingAlgos.blend_rect(new_layer, selected_layer, Rect2(Global.canvas.location, Global.canvas.size), Vector2.ZERO)
new_cels.remove(Global.current_layer)
if !selected_layer.is_invisible() and Global.layers[Global.current_layer - 1].linked_cels.size() > 1 and (f in Global.layers[Global.current_layer - 1].linked_cels):
new_layers[Global.current_layer - 1].linked_cels.erase(f)
new_cels[Global.current_layer - 1].image = new_layer
else:
Global.undo_redo.add_do_property(c.layers[Global.current_layer - 1].image, "data", new_layer.data)
Global.undo_redo.add_undo_property(c.layers[Global.current_layer - 1].image, "data", c.layers[Global.current_layer - 1].image.data)
Global.undo_redo.add_do_property(f.cels[Global.current_layer - 1].image, "data", new_layer.data)
Global.undo_redo.add_undo_property(f.cels[Global.current_layer - 1].image, "data", f.cels[Global.current_layer - 1].image.data)
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
Global.undo_redo.add_undo_property(c, "layers", c.layers)
Global.undo_redo.add_do_property(f, "cels", new_cels)
Global.undo_redo.add_undo_property(f, "cels", f.cels)
new_layers.remove(Global.current_layer)
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer - 1)
@ -479,13 +457,13 @@ func _on_MergeDownLayer_pressed() -> void:
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
Global.undo_redo.add_undo_method(Global, "undo", Global.canvases)
Global.undo_redo.add_do_method(Global, "redo", Global.canvases)
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.commit_action()
func _on_OpacitySlider_value_changed(value) -> void:
Global.canvas.layers[Global.current_layer].opacity = value / 100
Global.frames[Global.current_frame].cels[Global.current_layer].opacity = value / 100
Global.layer_opacity_slider.value = value
Global.layer_opacity_slider.value = value
Global.layer_opacity_spinbox.value = value

View file

@ -8,7 +8,7 @@ onready var popup_menu : PopupMenu = $PopupMenu
func _ready() -> void:
hint_tooltip = "Frame: %s, Layer: %s" % [frame + 1, layer]
if Global.canvases[frame] in Global.layers[layer].linked_cels:
if Global.frames[frame] in Global.layers[layer].linked_cels:
get_node("LinkedIndicator").visible = true
popup_menu.set_item_text(4, "Unlink Cel")
popup_menu.set_item_metadata(4, "Unlink Cel")
@ -23,7 +23,7 @@ func _on_CelButton_pressed() -> void:
Global.current_frame = frame
Global.current_layer = layer
elif Input.is_action_just_released("right_mouse"):
if Global.canvases.size() == 1:
if Global.frames.size() == 1:
popup_menu.set_item_disabled(0, true)
popup_menu.set_item_disabled(2, true)
popup_menu.set_item_disabled(3, true)
@ -31,7 +31,7 @@ func _on_CelButton_pressed() -> void:
popup_menu.set_item_disabled(0, false)
if frame > 0:
popup_menu.set_item_disabled(2, false)
if frame < Global.canvases.size() - 1:
if frame < Global.frames.size() - 1:
popup_menu.set_item_disabled(3, false)
popup_menu.popup(Rect2(get_global_mouse_position(), Vector2.ONE))
pressed = !pressed
@ -53,73 +53,68 @@ func _on_PopupMenu_id_pressed(ID : int) -> void:
3: # Move Right
change_frame_order(1)
4: # Unlink Cel
var cel_index : int = Global.layers[layer].linked_cels.find(Global.canvases[frame])
var c = Global.canvases[frame]
var cel_index : int = Global.layers[layer].linked_cels.find(Global.frames[frame])
var f = Global.frames[frame]
var new_layers : Array = Global.layers.duplicate()
# Loop through the array to create new classes for each element, so that they
# won't be the same as the original array's classes. Needed for undo/redo to work properly.
for i in new_layers.size():
var new_linked_cels = new_layers[i].linked_cels.duplicate()
new_layers[i] = Layer.new(new_layers[i].name, new_layers[i].visible, new_layers[i].locked, new_layers[i].frame_container, new_layers[i].new_cels_linked, new_linked_cels)
var new_canvas_layers : Array = c.layers.duplicate()
for i in new_canvas_layers.size():
new_canvas_layers[i] = Cel.new(new_canvas_layers[i].image, new_canvas_layers[i].opacity)
var new_cels : Array = f.cels.duplicate()
for i in new_cels.size():
new_cels[i] = Cel.new(new_cels[i].image, new_cels[i].opacity)
if popup_menu.get_item_metadata(4) == "Unlink Cel":
new_layers[layer].linked_cels.remove(cel_index)
var sprite := Image.new()
sprite.copy_from(Global.canvases[frame].layers[layer].image)
sprite.copy_from(Global.frames[frame].cels[layer].image)
sprite.lock()
new_canvas_layers[layer].image = sprite
new_cels[layer].image = sprite
Global.undo_redo.create_action("Unlink Cel")
Global.undo_redo.add_do_property(Global, "layers", new_layers)
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
Global.undo_redo.add_do_property(f, "cels", new_cels)
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
Global.undo_redo.add_undo_property(c, "layers", c.layers)
Global.undo_redo.add_undo_property(f, "cels", f.cels)
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]], layer)
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]], layer)
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.commit_action()
elif popup_menu.get_item_metadata(4) == "Link Cel":
new_layers[layer].linked_cels.append(Global.canvases[frame])
new_layers[layer].linked_cels.append(Global.frames[frame])
Global.undo_redo.create_action("Link Cel")
Global.undo_redo.add_do_property(Global, "layers", new_layers)
if new_layers[layer].linked_cels.size() > 1:
# If there are already linked cels, set the current cel's image
# to the first linked cel's image
new_canvas_layers[layer].image = new_layers[layer].linked_cels[0].layers[layer].image
new_canvas_layers[layer].image_texture = new_layers[layer].linked_cels[0].layers[layer].image_texture
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
Global.undo_redo.add_undo_property(c, "layers", c.layers)
new_cels[layer].image = new_layers[layer].linked_cels[0].cels[layer].image
new_cels[layer].image_texture = new_layers[layer].linked_cels[0].cels[layer].image_texture
Global.undo_redo.add_do_property(f, "cels", new_cels)
Global.undo_redo.add_undo_property(f, "cels", f.cels)
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]], layer)
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]], layer)
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.commit_action()
func change_frame_order(rate : int) -> void:
var change = frame + rate
var new_canvases : Array = Global.canvases.duplicate()
var temp = new_canvases[frame]
new_canvases[frame] = new_canvases[change]
new_canvases[change] = temp
var new_frames : Array = Global.frames.duplicate()
var temp = new_frames[frame]
new_frames[frame] = new_frames[change]
new_frames[change] = temp
Global.undo_redo.create_action("Change Frame Order")
Global.undo_redo.add_do_property(Global, "canvases", new_canvases)
Global.undo_redo.add_do_property(Global.canvases[frame], "frame", change)
Global.undo_redo.add_do_property(Global.canvases[change], "frame", frame)
Global.undo_redo.add_do_property(Global, "frames", new_frames)
if Global.current_frame == frame:
Global.undo_redo.add_do_property(Global, "current_frame", change)
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
Global.undo_redo.add_undo_property(Global, "canvases", Global.canvases)
Global.undo_redo.add_undo_property(Global.canvases[frame], "frame", frame)
Global.undo_redo.add_undo_property(Global.canvases[change], "frame", change)
Global.undo_redo.add_undo_property(Global, "frames", Global.frames)
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvases[frame]])
Global.undo_redo.add_do_method(Global, "redo", [Global.canvases[frame]])
Global.undo_redo.add_undo_method(Global, "undo")
Global.undo_redo.add_do_method(Global, "redo")
Global.undo_redo.commit_action()

View file

@ -86,8 +86,8 @@ func _on_TagOptions_confirmed() -> void:
var tag_from : int = options_dialog.get_node("GridContainer/FromSpinBox").value
var tag_to : int = options_dialog.get_node("GridContainer/ToSpinBox").value
if tag_to > Global.canvases.size():
tag_to = Global.canvases.size()
if tag_to > Global.frames.size():
tag_to = Global.frames.size()
if tag_from > tag_to:
tag_from = tag_to

View file

@ -74,5 +74,6 @@ func _on_LockButton_pressed() -> void:
func _on_LinkButton_pressed() -> void:
Global.layers[i].new_cels_linked = !Global.layers[i].new_cels_linked
if Global.layers[i].new_cels_linked && !Global.layers[i].linked_cels:
Global.layers[i].linked_cels.append(Global.canvas)
# If button is pressed and there are no linked cels in the layer
Global.layers[i].linked_cels.append(Global.frames[Global.current_frame])
Global.layers[i].frame_container.get_child(Global.current_frame)._ready()