summaryrefslogtreecommitdiff
path: root/src/wmresourcemng.h
blob: 910acf151833b60e2b8572ae3cb78e172954d5e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef __NEWER_WMRESOURCEMNG_H
#define __NEWER_WMRESOURCEMNG_H

struct WMResSetEntry {
	u32 key;
	u32 offset;
};

struct WMResSetHeader {
	u32 magic;
	u32 count;
	WMResSetEntry entries[1]; // dynamic size

	char *getName(int index) {
		return (char*)((u32)this + entries[index].offset);
	}
};

class dWMResourceMng_c {
private:
	bool hasSetPath;
	bool isSetLoaded;
	bool isLoadingComplete;

	char setPath[0x40];
	dDvdLoader_c setLoader;
	dDvdLoader_c *resLoaders;

	WMResSetHeader *setData;

	void prepareResources();

public:
	dWMResourceMng_c();
	~dWMResourceMng_c();

	bool loadSet(const char *setName);
	void *operator[](u32 key);

	bool isLoaded();


	u32 resCount() {
		return setData->count;
	}

	u32 keyForIndex(u32 index) {
		return setData->entries[index].key;
	}

	void *dataForIndex(u32 index) {
		return resLoaders[index].buffer;
	}
};

#endif