An archive resource management class.
The dRes_c class manages resource archives ( .arc
files). It does so by storing multiple archive holders. The class is instantiated automatically by dResMng_c, whose usage is recommended for basic resource loading.
Path Notes
Resource paths are subject to the following restrictions:
- The
.arc
extension is appended automatically to archive names and therefore must not be included.
- The
/
character is prepended automatically to archive paths and therefore must not be included.
- Archive names (excluding the file extension) cannot exceed 32 characters.
- Full paths to archive files (including the appended extension and prepended slash) cannot exceed 80 characters.
- Full paths to resources inside an archive should not exceed 250 characters.
Opening Archives
Use the setRes function to open an archive. For opening multiple archives at once, see the dResMng_c equivalent. Only up to mNumArcs archives can be open at the same time.
- Note
- Many kinds of assets are loaded automatically, therefore doing so manually is not necessary. These include:
- Stages
- Tilesets
- Backgrounds
- Actor resources
- Worldmaps and their resources
Notes for BRRES Resources
The game automatically handles the initialization of any BRRES files within an archive, as long as their parent directory is named g3d
.
Notes for Layout Resources
For layout archives, it's recommended to use the dedicated LytBase_c functions instead of this class.
Loading Archives
Use the syncAllRes function to perform the actual archive file loading. The function will return true
until all opened archives are loaded successfully.
Getting Archive Resources
Use the getRes function to obtain a resource inside a specific archive once it has been loaded. Overloads are provided to obtain the size of the resource and optionally detect compressed resources.
If the file could not be found under the archive, a warning is printed to the console. Use getResSilently if this behaviour is undesired (such as with an optional file).
- Note
- No overload for getResSilently with compression support is available.
Compressed Resources
While the getRes function can detect compression and return the decompressed data size, it does not actually perform the decompression itself. This can be achieved by calling the copyRes function with the compressed data and the compression type returned by the previous function, plus a buffer to store the decompressed data into.
- Note
- Only LZ77 compression is supported.
Deleting Archives
Use the deleteRes function to mark an archive as no longer needed by the calling entity. This ensures that archives no longer in use are properly disposed of.
Unused Content
- mSetCallback is an unused callback for when an archive is added to the class. It was probably used to debug resource loading.
Definition at line 77 of file d_res.hpp.
|
| dRes_c () |
| Constructs a new manager.
|
|
| ~dRes_c () |
| Destroys the manager.
|
|
bool | init (u16 maxCount, callback_c *callback) |
| Initializes the manager by allocating the archive holders and setting the callback.
|
|
bool | setRes (const char *arcName, const char *containingFolder, u8 allocDir, EGG::Heap *heap) |
| Schedules an archive for loading.
|
|
bool | deleteRes (const char *arcName) |
| Marks an archive as no longer needed.
|
|
void * | getRes (const char *arcName, const char *resPath) const |
| Gets a resource.
|
|
void * | getRes (const char *arcName, const char *resPath, unsigned long *size) const |
| Gets a resource.
|
|
void * | getRes (const char *arcName, const char *resPath, unsigned long *size, int *compressionType) const |
| Gets a resource which may optionally be compressed.
|
|
void * | getResSilently (const char *arcName, const char *resPath) const |
| Gets a resource without logging a message if the resource is not found.
|
|
void * | getResSilently (const char *arcName, const char *resPath, unsigned long *size) const |
| Gets a resource without logging a message if the resource is not found.
|
|
bool | syncAllRes () |
| Attempts to load the resources of an archive that has finished loading since the last call to this function. The callback is executed on all files and folders.
|
|