Change the file format of pxo to be a ZIP #952
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements #939, solution 1. This PR makes .pxo files be .zip files in disguise, i.e., changing the extension from pxo to zip actually lets you open the file in a archive manager and view its content. Breaks forward compatibility with 0.x, meaning that pxo files exported with 1.x will not be able to be imported in 0.x. The opposite is true, however, pxos made with 0.x can be imported in 1.x.
Also provides an option to include the final blended images of each layer for easier importing by other software, and exporting with CLI, when it gets implemented. The option is disabled by default so save disk space and to reduce saving time.
The main reasons I think this solution is better than going with SQLite is that Godot already supports zip packing and reading, while SQLite would require a GDExtension which could be troublesome for cross-platform support, such as Web, and the second reason is that zips should be easier to import by other software. Any Godot 4-made software/addons can read zip files, for example.
Most project files seem to be smaller as zips compared to the previous pxo format. A 200x128 project with 15 layers and 159 frames when exported to the previous pxo format, with ZSTD compression, takes 3.1MB of space. The same project takes just 1.6MB as a zip, and 2.2MB as a zip when the final blended images are included. However, both loading and saving seems to be taking longer than the previous format. Saving could perhaps get optimized by just overwriting only the files that have new changes, and not remaking the entire file from scratch, but that's something for the future. This optimization is something that couldn't have been done so easily with the previous format, if at all.
The structure of the zip is the following (files are in italic, the rest are directories):
root
├── image_data
│ ├── frames
│ │ └── 1
│ │ | └── layer_1
│ │ | └── layer_2
│ │ | └── layer_3... etc for each layer
│ │ └── 2
│ │ └── 3... etc for each frame
│ └── brushes
│ │ └── brush_1 (etc for each project brush)
│ └── final_images (only included if "Include blended images" is enabled when saving)
│ │ └── 1
│ │ └── 2
│ │ └── 3... etc for each frame
│ └── tile_mask
├── data.json
Note that saving doesn't currently work on the Web version due to godotengine/godot#85564.