aboutsummaryrefslogtreecommitdiff
path: root/include/hgeresource.h
blob: ace8f21a09192e0020ca649dda899f9077653f83 (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
** Haaf's Game Engine 1.7
** Copyright (C) 2003-2007, Relish Games
** hge.relishgames.com
**
** hgeResourceManager helper class header
*/


#ifndef HGERESOURCE_H
#define HGERESOURCE_H


#include "hge.h"
#include "hgesprite.h"
#include "hgeanim.h"
#include "hgefont.h"
#include "hgeparticle.h"
#include "hgedistort.h"
#include "hgestrings.h"


#define RESTYPES 13
#define MAXRESCHARS 128


class hgeResourceManager;

struct ResDesc
{
	char		name[MAXRESCHARS];
	int			resgroup;
	size_t		handle;
	ResDesc*	next;

	ResDesc()	{ hge=hgeCreate(HGE_VERSION); }
	~ResDesc()	{ hge->Release(); }

	virtual DWORD Get(hgeResourceManager *rm) = 0;
	virtual void  Free() = 0;

protected:
	static HGE	*hge;
};

/*
** HGE Resource manager class
*/
class hgeResourceManager
{
public:
	hgeResourceManager(const char *scriptname=0);
	~hgeResourceManager();

	void				ChangeScript(const char *scriptname=0);
	bool				Precache(int groupid=0);
	void				Purge(int groupid=0);

	void*				GetResource(const char *name, int resgroup=0);
	HTEXTURE			GetTexture(const char *name, int resgroup=0);
	HEFFECT				GetEffect(const char *name, int resgroup=0);
	HMUSIC				GetMusic(const char *name, int resgroup=0);
	HSTREAM				GetStream(const char *name, int resgroup=0);
	HTARGET				GetTarget(const char *name);

	hgeSprite*			GetSprite(const char *name);
	hgeAnimation*		GetAnimation(const char *name);
	hgeFont*			GetFont(const char *name);
	hgeParticleSystem*	GetParticleSystem(const char *name);
	hgeDistortionMesh*	GetDistortionMesh(const char *name);
	hgeStringTable*		GetStringTable(const char *name, int resgroup=0);

	ResDesc*			res[RESTYPES];

private:
	hgeResourceManager(const hgeResourceManager &);
	hgeResourceManager&	operator= (const hgeResourceManager&);
	void				_remove_all();
	void				_parse_script(const char *scriptname=0);

	static HGE			*hge;
};


#endif