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

Removed remove_frame() from FrameButton.gd

Use _on_DeleteFrame_pressed() on AnimationTimeline.gd instead
This commit is contained in:
OverloadedOrama 2020-04-18 00:35:42 +03:00
parent feea931e22
commit 4e539e5e29
2 changed files with 11 additions and 33 deletions

View file

@ -51,10 +51,13 @@ func add_frame() -> void:
Global.undo_redo.commit_action()
func _on_DeleteFrame_pressed() -> void:
func _on_DeleteFrame_pressed(frame := -1) -> void:
if Global.canvases.size() == 1:
return
var canvas : Canvas = Global.canvases[Global.current_frame]
if frame == -1:
frame = Global.current_frame
var canvas : Canvas = Global.canvases[frame]
var new_canvases := Global.canvases.duplicate()
new_canvases.erase(canvas)
var current_frame := Global.current_frame
@ -68,7 +71,7 @@ func _on_DeleteFrame_pressed() -> void:
Global.undo_redo.add_do_property(Global, "canvas", new_canvases[current_frame])
Global.undo_redo.add_do_property(Global, "current_frame", current_frame)
for i in range(Global.current_frame, new_canvases.size()):
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)

View file

@ -5,6 +5,7 @@ var layer := 0
onready var popup_menu := $PopupMenu
func _ready() -> void:
hint_tooltip = "Frame: %s, Layer: %s" % [frame + 1, layer]
if Global.canvases[frame] in Global.layers[layer][5]:
@ -14,6 +15,7 @@ func _ready() -> void:
get_node("LinkedIndicator").visible = false
popup_menu.set_item_disabled(4, true) # Unlink cel
func _on_FrameButton_pressed() -> void:
if Input.is_action_just_released("left_mouse"):
Global.current_frame = frame
@ -33,13 +35,13 @@ func _on_FrameButton_pressed() -> void:
pressed = !pressed
else: # Middle mouse click
pressed = !pressed
if Global.canvases.size() > 1:
remove_frame()
Global.animation_timeline._on_DeleteFrame_pressed(frame)
func _on_PopupMenu_id_pressed(ID : int) -> void:
match ID:
0: # Remove Frame
remove_frame()
Global.animation_timeline._on_DeleteFrame_pressed(frame)
1: # Clone Frame
Global.animation_timeline._on_CopyFrame_pressed(frame)
2: # Move Left
@ -60,33 +62,6 @@ func _on_PopupMenu_id_pressed(ID : int) -> void:
Global.canvases[frame].layers[layer][1] = tex
Global.canvases[frame].update()
func remove_frame() -> void:
var canvas : Canvas = Global.canvases[frame]
var new_canvases := Global.canvases.duplicate()
new_canvases.erase(canvas)
var current_frame := Global.current_frame
if current_frame > 0 && current_frame == new_canvases.size(): # If it's the last frame
current_frame -= 1
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, "current_frame", current_frame)
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, "current_frame", Global.current_frame)
Global.undo_redo.add_do_method(Global, "redo", [canvas])
Global.undo_redo.add_undo_method(Global, "undo", [canvas])
Global.undo_redo.commit_action()
func change_frame_order(rate : int) -> void:
var change = frame + rate