– Move all file reading to the FileReader class, which was weirdly not doing that before
– Add support for loading assets from zip files
– Turn the FileReader into a singleton
– When initialising the FileReader scan all the files (and asset packages) and keep track from where to lead each file
Relates to #95
Hello! This commit is quite a bit more elaborate than the last one. Ignoring the actual implementation details, this means that it is now possible to drop a “asset pack” (read: a ZIP file) into the assets directory. The contents of those will be scanned and made available transparently when using the FileReader class, every file path is considered unique, so whatever specific file path gets scanned first will be the source for it, with files on the actual file system taking precedence.
The asset packs are read in reversed alphanumeric search order, so the behaviour remains predictable. While I would like to take credit for this approach, I blatantly stole that idea one from the id Tech family of engines. 🙂
In practical terms, should there be a specific texture with a path like assests/texture/blank.png (which there actually is) and it is loaded through the FileReader (as everything now is), the FileReader will transparently pick the correct source as described in the first paragraph, so all the configuration files remain forwards compatible to this.
As for the why of it, this is for scenarios which should be self-contained, meaning also contain their preview picture or any other assets they may require without polluting the actual assets directory. Furthermore this is also in preparation for save files, which once again should also definitely be self-contained .
All of this seems to work fine besides one minor detail, the Windows build. This should be no problem in itself really, however I could not be bothered yet to actually build libzip as well as its lovely dependency zlib on Windows yet. Furthermore, this broke the CI process, as it does not appreciate the failing Windows build. Not to fear though, fixing that is the next item on the never-ending to-do list. Byeeee. 🙂