1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-19 09:39:48 +00:00

Layer/frame cloning works.

This commit is contained in:
Emmanouil Papadeas 2024-11-29 01:30:46 +02:00
parent 0997fa8536
commit de6784202e
2 changed files with 19 additions and 3 deletions

View file

@ -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:

View file

@ -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()