1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Fix loading project with linked cels

Regression from #1146.
This commit is contained in:
Emmanouil Papadeas 2024-12-09 16:30:53 +02:00
parent 3c3de7823a
commit 11e05ac471

View file

@ -367,21 +367,6 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
Global.LayerTypes.TILEMAP: Global.LayerTypes.TILEMAP:
layers.append(LayerTileMap.new(self, null)) layers.append(LayerTileMap.new(self, null))
# Parent references to other layers are created when deserializing
# a layer, so loop again after creating them:
for layer_i in dict.layers.size():
layers[layer_i].index = layer_i
var layer_dict: Dictionary = dict.layers[layer_i]
# Ensure that loaded pxo files from v1.0-v1.0.3 have the correct
# blend mode, after the addition of the Erase mode in v1.0.4.
if pxo_version < 4 and layer_dict.has("blend_mode"):
var blend_mode: int = layer_dict.get("blend_mode")
if blend_mode >= BaseLayer.BlendModes.ERASE:
blend_mode += 1
layer_dict["blend_mode"] = blend_mode
layers[layer_i].deserialize(layer_dict)
_deserialize_metadata(layers[layer_i], dict.layers[layer_i])
var frame_i := 0 var frame_i := 0
for frame in dict.frames: for frame in dict.frames:
var cels: Array[BaseCel] = [] var cels: Array[BaseCel] = []
@ -401,7 +386,9 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
cels.append(Cel3D.new(size, true)) cels.append(Cel3D.new(size, true))
Global.LayerTypes.TILEMAP: Global.LayerTypes.TILEMAP:
var image := _load_image_from_pxo(frame_i, cel_i, zip_reader, file) var image := _load_image_from_pxo(frame_i, cel_i, zip_reader, file)
var new_cel := (layer as LayerTileMap).new_cel_from_image(image) var tileset_index = dict.layers[cel_i].tileset_index
var tileset := tilesets[tileset_index]
var new_cel := CelTileMap.new(tileset, image)
cels.append(new_cel) cels.append(new_cel)
cel["pxo_version"] = pxo_version cel["pxo_version"] = pxo_version
cels[cel_i].deserialize(cel) cels[cel_i].deserialize(cel)
@ -418,6 +405,21 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
_deserialize_metadata(frame_class, frame) _deserialize_metadata(frame_class, frame)
frames.append(frame_class) frames.append(frame_class)
frame_i += 1 frame_i += 1
# Parent references to other layers are created when deserializing
# a layer, so loop again after creating them:
for layer_i in dict.layers.size():
layers[layer_i].index = layer_i
var layer_dict: Dictionary = dict.layers[layer_i]
# Ensure that loaded pxo files from v1.0-v1.0.3 have the correct
# blend mode, after the addition of the Erase mode in v1.0.4.
if pxo_version < 4 and layer_dict.has("blend_mode"):
var blend_mode: int = layer_dict.get("blend_mode")
if blend_mode >= BaseLayer.BlendModes.ERASE:
blend_mode += 1
layer_dict["blend_mode"] = blend_mode
layers[layer_i].deserialize(layer_dict)
_deserialize_metadata(layers[layer_i], dict.layers[layer_i])
if dict.has("tags"): if dict.has("tags"):
for tag in dict.tags: for tag in dict.tags:
var new_tag := AnimationTag.new(tag.name, Color(tag.color), tag.from, tag.to) var new_tag := AnimationTag.new(tag.name, Color(tag.color), tag.from, tag.to)