NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_res_mng.cpp
1#include <dol/bases/d_res_mng.hpp>
2#include <lib/nw4r/g3d/res_file.h>
3
5
7 m_instance = this;
8 mRes.init(MAX_NUM_RES, &mCallback);
9}
10
12 m_instance = nullptr;
13}
14
15void dResMng_c::resCallback_c::init(const char *name) {}
16
17void *dResMng_c::resCallback_c::execute(void *data, u32 folderSig) {
18 if (folderSig == 'g3d ') {
19 // If it's a g3d file, create a ResFile for it
20 nw4r::g3d::ResFile resFile = { data };
21 if (resFile.CheckRevision()) {
22 resFile.Init();
23 resFile.Bind(resFile);
24 }
25 }
26 // The data doesn't need to be changed, just return it
27 return data;
28}
29
30void dResMng_c::setRes(const char *path, char **names, int count, EGG::Heap *heap) {
31 for (int i = 0; i < count; i++) {
32 mRes.setRes(names[i], path, 0, heap);
33 }
34}
35
36bool dResMng_c::setRes(const char *path, const char *name, EGG::Heap *heap) {
37 return mRes.setRes(name, path, 0, heap);
38}
virtual void * execute(void *data, u32 folderSig)
Executes the callback.
Definition d_res_mng.cpp:17
virtual void init(const char *name)
Initializes the callback with the resource name.
Definition d_res_mng.cpp:15
A singleton class that manages loading resource files (files contained within a .arc file).
Definition d_res_mng.hpp:9
static dResMng_c * m_instance
The instance of this class.
Definition d_res_mng.hpp:48
virtual ~dResMng_c()
Destroys this dResMng_c.
Definition d_res_mng.cpp:11
dRes_c mRes
The resource manager.
Definition d_res_mng.hpp:42
dResMng_c()
Constructs a new dResMng_c.
Definition d_res_mng.cpp:6
void setRes(const char *path, char **names, int count, EGG::Heap *heap)
Registers multiple archives to be loaded.
Definition d_res_mng.cpp:30
resCallback_c mCallback
The callback for after a file has been loaded.
Definition d_res_mng.hpp:45
bool setRes(const char *arcName, const char *containingFolder, u8 allocDir, EGG::Heap *heap)
Registers an archive to be loaded next.
Definition d_res.cpp:32
bool init(u16 maxCount, callback_c *callback)
Initializes the dRes_c.
Definition d_res.cpp:21