From de6784202eaddc87c80b6d2dba3c36d17b8803ff Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 29 Nov 2024 01:30:46 +0200 Subject: [PATCH] Layer/frame cloning works. --- src/Classes/Cels/CelTileMap.gd | 12 ++++++++++-- src/UI/Timeline/AnimationTimeline.gd | 10 +++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Classes/Cels/CelTileMap.gd b/src/Classes/Cels/CelTileMap.gd index 3db8fd070..1a020477a 100644 --- a/src/Classes/Cels/CelTileMap.gd +++ b/src/Classes/Cels/CelTileMap.gd @@ -74,7 +74,7 @@ class Cell: transpose = dict.get("transpose", transpose) -func _init(_tileset: TileSetCustom, _image: ImageExtended, _opacity := 1.0) -> void: +func _init(_tileset: TileSetCustom, _image := ImageExtended.new(), _opacity := 1.0) -> void: super._init(_image, _opacity) tileset = _tileset @@ -359,7 +359,9 @@ func _is_redo() -> bool: ## If the tileset has been modified by another tile, make sure to also update it here. func _on_tileset_updated(cel: CelTileMap) -> void: - if cel == self or not is_instance_valid(cel) or cel in link_set["cels"]: + if cel == self or not is_instance_valid(cel): + return + if link_set != null and cel in link_set["cels"]: return _update_cel_portions() Global.canvas.update_all_layers = true @@ -367,6 +369,12 @@ func _on_tileset_updated(cel: CelTileMap) -> void: # Overridden Methods: +func set_content(content, texture: ImageTexture = null) -> void: + super.set_content(content, texture) + _resize_cells(image.get_size()) + _re_index_all_cells() + + func update_texture(undo := false) -> void: var tile_editing_mode := TileSetPanel.tile_editing_mode if undo or _is_redo() or tile_editing_mode != TileSetPanel.TileEditingMode.MANUAL: diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index 7ef569173..16dc18a9d 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -476,6 +476,8 @@ func copy_frames( ) if src_cel.selected != null: selected_id = src_cel.selected.id + elif src_cel is CelTileMap: + new_cel = CelTileMap.new(src_cel.tileset) else: new_cel = src_cel.get_script().new() @@ -897,7 +899,11 @@ func _on_CloneLayer_pressed() -> void: var clones: Array[BaseLayer] = [] var cels := [] # 2D Array of Cels for src_layer in source_layers: - var cl_layer: BaseLayer = src_layer.get_script().new(project) + var cl_layer: BaseLayer + if src_layer is LayerTileMap: + cl_layer = LayerTileMap.new(project, src_layer.tileset) + else: + cl_layer = src_layer.get_script().new(project) cl_layer.project = project cl_layer.index = src_layer.index var src_layer_data: Dictionary = src_layer.serialize() @@ -915,6 +921,8 @@ func _on_CloneLayer_pressed() -> void: new_cel = Cel3D.new( src_cel.size, false, src_cel.object_properties, src_cel.scene_properties ) + elif src_cel is CelTileMap: + new_cel = CelTileMap.new(src_cel.tileset) else: new_cel = src_cel.get_script().new()