diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 3d3112006..1f1c4a21f 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -40,6 +40,8 @@ var file_format : int = Export.FileFormat.PNG var was_exported := false var frame_button_node = preload("res://src/UI/Timeline/FrameButton.tscn") +var layer_button_node = preload("res://src/UI/Timeline/LayerButton.tscn") +var cel_button_node = preload("res://src/UI/Timeline/CelButton.tscn") func _init(_frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) -> void: @@ -123,7 +125,7 @@ func change_project() -> void: # Create new ones for i in range(layers.size() - 1, -1, -1): # Create layer buttons - var layer_container = load("res://src/UI/Timeline/LayerButton.tscn").instance() + var layer_container = layer_button_node.instance() layer_container.layer = i if layers[i].name == "": layers[i].name = tr("Layer") + " %s" % i @@ -134,7 +136,7 @@ func change_project() -> void: Global.frames_container.add_child(layers[i].frame_container) for j in range(frames.size()): # Create Cel buttons - var cel_button = load("res://src/UI/Timeline/CelButton.tscn").instance() + var cel_button = cel_button_node.instance() cel_button.frame = j cel_button.layer = i cel_button.get_child(0).texture = frames[j].cels[i].image_texture @@ -407,7 +409,7 @@ func frames_changed(value : Array) -> void: Global.frame_ids.add_child(button) for i in range(layers.size() - 1, -1, -1): - var cel_button = load("res://src/UI/Timeline/CelButton.tscn").instance() + var cel_button = cel_button_node.instance() cel_button.frame = j cel_button.layer = i cel_button.get_child(0).texture = frames[j].cels[i].image_texture @@ -431,7 +433,7 @@ func layers_changed(value : Array) -> void: remove_cel_buttons() for i in range(layers.size() - 1, -1, -1): - var layer_container = load("res://src/UI/Timeline/LayerButton.tscn").instance() + var layer_container = layer_button_node.instance() layer_container.layer = i if layers[i].name == "": layers[i].name = tr("Layer") + " %s" % i @@ -442,7 +444,7 @@ func layers_changed(value : Array) -> void: Global.frames_container.add_child(layers[i].frame_container) for j in range(frames.size()): - var cel_button = load("res://src/UI/Timeline/CelButton.tscn").instance() + var cel_button = cel_button_node.instance() cel_button.frame = j cel_button.layer = i cel_button.get_child(0).texture = frames[j].cels[i].image_texture diff --git a/src/UI/Timeline/CelButton.gd b/src/UI/Timeline/CelButton.gd index c2bb69a78..81e3a5402 100644 --- a/src/UI/Timeline/CelButton.gd +++ b/src/UI/Timeline/CelButton.gd @@ -43,7 +43,7 @@ func _on_CelButton_resized() -> void: func _on_CelButton_pressed() -> void: - var project := Global.current_project + var project = Global.current_project if Input.is_action_just_released("left_mouse"): Global.canvas.selection.transform_content_confirm() var change_cel := true @@ -128,6 +128,7 @@ func _on_PopupMenu_id_pressed(ID : int) -> void: Global.current_project.undo_redo.add_undo_method(Global, "undo") Global.current_project.undo_redo.add_do_method(Global, "redo") Global.current_project.undo_redo.commit_action() + elif popup_menu.get_item_metadata(MenuOptions.LINK) == "Link Cel": new_layers[layer].linked_cels.append(Global.current_project.frames[frame]) Global.current_project.undo_redo.create_action("Link Cel") diff --git a/src/UI/Timeline/LayerButton.gd b/src/UI/Timeline/LayerButton.gd index e2732610a..51238cc69 100644 --- a/src/UI/Timeline/LayerButton.gd +++ b/src/UI/Timeline/LayerButton.gd @@ -46,7 +46,7 @@ func _input(event : InputEvent) -> void: func _on_LayerContainer_gui_input(event : InputEvent) -> void: - var project := Global.current_project + var project = Global.current_project if event is InputEventMouseButton and event.button_index == BUTTON_LEFT: Global.canvas.selection.transform_content_confirm()