tmxlite icon indicating copy to clipboard operation
tmxlite copied to clipboard

Add improved file loading API (feedback wanted)

Open fallahn opened this issue 4 years ago • 2 comments

By default tmxlite uses fstream to open tmx files. As noted in #76 this does not work on android, the current work-around being loading the entire file into a string and passing to Map::loadFromString().

In #80 it is also noted that there is currently no support for zstd compressed maps as this requires including external dependencies.

The idea then is to create an API for tmxlite which allows a user to define a file loading mechanism of their choice. tmxlite itself could include file loading functions for android, for example, as well as optional file loaders for zstd and other potential sources such as PhysFS.

If anyone has any feedback on this idea, or ideas for API design, please comment! The current thinking would be similar to that of SFML's InputStream.

fallahn avatar Apr 25 '21 11:04 fallahn

I had a similar need, all my files are managed by a resource manager that may read from an archive. I added an optional callback to the library that my manager can install to handle loading and unloading files. I did not use streams, but a simple reader callback, that more closely matches what the XML library wants (a big buffer). It's in this branch here. https://github.com/JeffM2501/tmxlite/tree/file_callbacks

JeffM2501 avatar Nov 10 '24 15:11 JeffM2501

Thanks for the feedback! I'll take a look when I have a spare moment 😄

fallahn avatar Nov 10 '24 16:11 fallahn