diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 35143700c..118ab87eb 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -652,7 +652,10 @@ func get_all_pixel_cels() -> Array[PixelCel]: func serialize_cel_undo_data(cels: Array[BaseCel], data: Dictionary) -> void: - for cel in cels: + var cels_to_serialize := cels + if TileSetPanel.tile_editing_mode == TileSetPanel.TileEditingMode.MANUAL: + cels_to_serialize = find_same_tileset_tilemap_cels(cels) + for cel in cels_to_serialize: if not cel is PixelCel: continue var image := (cel as PixelCel).get_image() @@ -671,6 +674,23 @@ func deserialize_cel_undo_data(redo_data: Dictionary, undo_data: Dictionary) -> (cel as CelTileMap).deserialize_undo_data(undo_data[cel], undo_redo, true) +func find_same_tileset_tilemap_cels(cels: Array[BaseCel]) -> Array[BaseCel]: + var tilemap_cels: Array[BaseCel] + var current_tilesets: Array[TileSetCustom] + for cel in cels: + tilemap_cels.append(cel) + if cel is not CelTileMap: + continue + current_tilesets.append((cel as CelTileMap).tileset) + for cel in get_all_pixel_cels(): + if cel is not CelTileMap: + continue + if (cel as CelTileMap).tileset in current_tilesets: + if cel not in cels: + tilemap_cels.append(cel) + return tilemap_cels + + ## Re-order layers to take each cel's z-index into account. If all z-indexes are 0, ## then the order of drawing is the same as the order of the layers itself. func order_layers(frame_index := current_frame) -> void: