NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_res_mng.cpp
2#include <lib/nw4r/g3d/res_file.h>
4
6
11
13 m_instance = nullptr;
14}
15
16void dResMng_c::resCallback_c::init(const char *name) {}
17
18void *dResMng_c::resCallback_c::execute(void *data, u32 folderSig, const char* path) {
19 if (folderSig == 'g3d ') {
20 // If it's a g3d file, create a ResFile for it
21 nw4r::g3d::ResFile resFile(data);
22 if (resFile.CheckRevision()) {
23 resFile.Init();
24 resFile.Bind(resFile);
25 }
26 }
27 // The data doesn't need to be changed, just return it
28 return data;
29}
30
31void dResMng_c::setRes(const char *path, const char **names, int count, EGG::Heap *heap) {
32 for (int i = 0; i < count; i++) {
33 mRes.setRes(names[i], path, MEM_EXPHEAP_ALLOC_DIR_FRONT, heap);
34 }
35}
36
37bool dResMng_c::setRes(const char *path, const char *name, EGG::Heap *heap) {
38 return mRes.setRes(name, path, MEM_EXPHEAP_ALLOC_DIR_FRONT, heap);
39}
@ MEM_EXPHEAP_ALLOC_DIR_FRONT
Allocates from the bottom of the free memory region.
Definition MEMExpHeap.h:11
virtual void * execute(void *data, u32 folderSig, const char *path)
Executes the callback.
Definition d_res_mng.cpp:18
virtual void init(const char *name)
Initializes the callback with the resource name.
Definition d_res_mng.cpp:16
A higher-level archive resource management class.
Definition d_res_mng.hpp:20
static dResMng_c * m_instance
The instance of this class.
Definition d_res_mng.hpp:57
virtual ~dResMng_c()
Destroys this dResMng_c.
Definition d_res_mng.cpp:12
dRes_c mRes
The resource manager.
Definition d_res_mng.hpp:51
dResMng_c()
Constructs a new dResMng_c.
Definition d_res_mng.cpp:7
resCallback_c mCallback
The callback for after a file has been loaded.
Definition d_res_mng.hpp:54
void setRes(const char *path, const char **names, int count, EGG::Heap *heap)
Schedules multiple archives for loading.
Definition d_res_mng.cpp:31
bool setRes(const char *arcName, const char *containingFolder, u8 allocDir, EGG::Heap *heap)
Schedules an archive for loading.
Definition d_res.cpp:32
bool init(u16 maxCount, callback_c *callback)
Initializes the manager by allocating the archive holders and setting the callback.
Definition d_res.cpp:21
#define MAX_NUM_RES
The maximum number of resources that can be loaded at once.
Definition d_res_mng.hpp:6