Page 1 of 1

Support reading from generic stream objects.

Posted: Thu Apr 01, 2010 05:31
by simpleton
I haven't been keeping up much with the CEGUI development so I don't know if this is already present in 0.7x. I've kept up with the Secret Maryo project and even submitted a few patches to it myself. One of the topics discussed was the ability to compress level files. The project writes XML files directly so can easily add a compression layer, but uses CEGUI to read the XML. I had and idea for a feature for CEGUI, if it could read not only from files, but from any generic stream object that had a read method, not only for XML files, but images and anything else needed. Perhaps load methods could take a object such as CEGUI::InputStream derived object with a member Read(void* buf, size_t bytes). Or maybe even some type of all-out virtual file system (for instance so all CEGUI items, image sets, layouts, etc could be stored in a zip file, and if an XML file references an image set relatively, it would access it with the appropriate file system decoder or application defined file system decoder.

I'm not sure how such would be implemented. Perhaps a unique string could be used, such as file:///path/to/zip#zip:///path/to/entry, this would use a file decoder for reading /path/to/zip, and create a zip decoder wrapping that file decoder and set to read /path/to/entry from the file. Well, I don't know how it could really be implemented, but it would be a nice feature to be able to load resources from any application-defined stream and not just directly from disk.

Re: Support reading from generic stream objects.

Posted: Thu Apr 01, 2010 09:19
by CrazyEddie
Hi,

CEGUI reads all files via a ResourceProvider system. This loads data having been given a filename and a resource group identifier. The default implementation is just based on the underlying file system, but custom implementations are able to load from anywhere - including doing such things as decompression on the fly.

In fact, we've just added a MinizipResourceProvider to the v0-7 codebase, which was contributed by Jamarr. This can have a .zip file set as a data source, can have relative data paths set for resource groups within the .zip file, and so - for example - it's possible to zip up the datafiles directory for CEGUI and have all resources loaded from that zip. The zip could just as easily have a location that contains the level XML data and be loaded from a resource group identifier that points to that subdir within the zip.

If MinizipResourceProvider should be unsuitable, it would almost certainly be possible to create a customised ResourceProvider that would work in an acceptable way.

CE.