A zip-archive based ResourceProvider for CEGUI

Create issue
Issue #345 resolved
Former user created an issue

Automatic migration. Original reporter: "Jamarr"

I eventually got around to writing a zip-archive based resource provider for CEGUI. I originally mentioned this in 'The Development of CEGUI 0.7.x' thread and there seemed to be a little interest in this, so I figured I would add this to mantis to see if it can be added into the library. As initially hinted at I decided to use zlib, along with the minizip contribution accompanying zlib, since these use MIT style licenses.

I wanted a resource provider that could provide the same functionality as the default resource provider, with the additional capability to load resources from an archive. By providing backwards compatability with the default resource provider, users can easily test new resources without having to recompile the archive. In addition, the new resource provider can be dropped into an existing project (that uses the default resource provider) without any noticable difference in functionality. The user can also turn off loading of local resources, so that only resources from the archive can be loaded.

I only tested this class with v0.6.2. But looking at the default resource provider for v0.7, I see no reason why it would not also work with v0.7.

Reproducibility: N/A

Additional information: This actually only required a very small portion of code. Probably less than 15 or so lines of glue code. The remaining 200 lines in the header/source being mostly fluff.

It appears that zlib is already included in the CEGUI v0.7 dependency package. The minzip dependencies would need to be added to the project. Minizip is included in the zlib distribution and can be located at zlib/contrib/minizip. Creating a minizip.lib from the source for distribution should be trivial; just create a library-project with all files in the minizip directory excluding minizip.c and miniunz.c and link to zlib.

I have only tested this on windows, as that is the only development platform I am currently familiar with, but minizip includes file-io routines for both win32 and linux (and so I presume will run on mac).

It should be noted that I inherited CEGUI::MinizipResourceProvider from CEGUI::DefaultResourceProvider since the MRP is ment as a drop-in replacement for the DRP, with the added capability to load resources from an archive. An issue with this is that the DRP does not have a virtual destructor, so the DRP needs to be updated or the user should know not to delete an MRP casted to a DRP.

Comments (3)

  1. Former user Account Deleted

    Original reporter: Jamarr

    I forgot to add the CEGUIEXPORT macro on the class definition. I was not building this into the cegui library, so the macro was not needed at the time. If the class is included within the cegui library, the macro should be added.

  2. Paul Turner

    I am working on this at the moment, so thought I would update on my progress.

    I see this going into branches/v0-7 with some minor mods and 1 enhancement.

    Aside from a minor style changes, I will be incorporating a copy of parts of the minizip code into the CEGUI tree to save adding a new external dependency.

    I made small changes to remove the unzip.h dependency from the public header.

    The enhancement is for a 0.7.x only thing for pattern matched file loading (where you can basically load all fonts by saying "*.font").

    Should be done and committed in a couple of days :)

  3. Log in to comment