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

Bump pxo file version to 4 to fix blend mode compatibility with older pxo files

The addition of the erase blend mode from #1117 resulted in loading pxo files from v1.0-v1.0.3 to have incorrect blend modes in their layers, if they are set to anything below normal, because the values of the `BaseLayer.BlendModes` enumerator changed.
This commit is contained in:
Emmanouil Papadeas 2024-10-22 15:39:30 +03:00
parent 66f150122a
commit e2b54f70f7
2 changed files with 14 additions and 4 deletions

View file

@ -25,7 +25,7 @@ config/icon="res://assets/graphics/icons/icon.png"
config/macos_native_icon="res://assets/graphics/icons/icon.icns"
config/windows_native_icon="res://assets/graphics/icons/icon.ico"
config/ExtensionsAPI_Version=5
config/Pxo_Version=3
config/Pxo_Version=4
[audio]

View file

@ -278,6 +278,9 @@ func serialize() -> Dictionary:
func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAccess = null) -> void:
about_to_deserialize.emit(dict)
var pxo_version = dict.get(
"pxo_version", ProjectSettings.get_setting("application/config/Pxo_Version")
)
if dict.has("size_x") and dict.has("size_y"):
size.x = dict.size_x
size.y = dict.size_y
@ -327,8 +330,7 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
# Don't do anything with it, just read it so that the file can move on
file.get_buffer(size.x * size.y * 4)
cels.append(Cel3D.new(size, true))
if dict.has("pxo_version"):
cel["pxo_version"] = dict["pxo_version"]
cel["pxo_version"] = pxo_version
cels[cel_i].deserialize(cel)
_deserialize_metadata(cels[cel_i], cel)
cel_i += 1
@ -348,7 +350,15 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
# a layer, so loop again after creating them:
for layer_i in dict.layers.size():
layers[layer_i].index = layer_i
layers[layer_i].deserialize(dict.layers[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"):
for tag in dict.tags: