NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_res_mng.hpp
Go to the documentation of this file.
1#pragma once
2#include <types.h>
3#include <game/bases/d_res.hpp>
4/// @file
5
6#define MAX_NUM_RES 300 ///< The maximum number of resources that can be loaded at once.
7
8/**
9 * @brief A higher-level archive resource management class.
10 * @ingroup bases
11 * @details
12 * ## Overview
13 * The dResMng_c class wraps a dRes_c instance to provide higher-level access. For more information on
14 * resource loading and management, see dRes_c.
15 *
16 * ## Bulk Resource Loading
17 * Use the ::setRes function to open multiple archives at once. Only up to ::MAX_NUM_RES archives can be
18 * open at the same time.
19 */
20class dResMng_c {
21private:
22 /// @brief A callback class for processing resources that handles loading g3d data.
24 public:
25 virtual void init(const char *name);
26 virtual void *execute(void *data, u32 folderSig, const char* path);
27 };
28
29public:
30 dResMng_c(); ///< Constructs a new dResMng_c.
31 virtual ~dResMng_c(); ///< Destroys this dResMng_c.
32
33 /**
34 * @brief Schedules multiple archives for loading.
35 * @param path The path to the folder containing the archives. See the path notes in dRes_c.
36 * @param names An array of archive names. See the path notes in dRes_c.
37 * @param count The number of archives in the array.
38 * @param heap The heap to load the archives into, or @p nullptr to use the default archive heap.
39 */
40 void setRes(const char *path, const char **names, int count, EGG::Heap *heap);
41
42 /**
43 * @brief Schedules a single archive for loading.
44 * @param path The path to the folder containing the archive. See the path notes in dRes_c.
45 * @param name The name of the archive. See the path notes in dRes_c.
46 * @param heap The heap to load the archive into, or @p nullptr to use the default archive heap.
47 * @return Whether the archive was loaded successfully.
48 */
49 bool setRes(const char *path, const char *name, EGG::Heap *heap);
50
51 dRes_c mRes; ///< The resource manager.
52
53private:
54 resCallback_c mCallback; ///< The callback for after a file has been loaded.
55
56public:
57 static dResMng_c *m_instance; ///< The instance of this class.
58};
A callback class for processing resources that handles loading g3d data.
Definition d_res_mng.hpp:23
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
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
A callback class for processing resources.
Definition d_res.hpp:82
An archive resource management class.
Definition d_res.hpp:77