diff --git a/project.godot b/project.godot index 7979e0032..b10078036 100644 --- a/project.godot +++ b/project.godot @@ -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] diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index fbfee1362..3016ad133 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -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: