blob: 6cb5da26389b5e0238faef2edc7a4bea2f5c798f [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001// resources.hpp - Base classes for resource management of GUI
2
3#ifndef _RESOURCE_HEADER
4#define _RESOURCE_HEADER
5
6// Base Objects
7class Resource
8{
9public:
10 Resource(xml_node<>* node, ZipArchive* pZip);
11 virtual ~Resource() {}
12
13public:
14 virtual void* GetResource(void) = 0;
15 std::string GetName(void) { return mName; }
16
17private:
18 std::string mName;
19
20protected:
21 static int ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile);
22};
23
24typedef enum {
25 TOUCH_START = 0,
26 TOUCH_DRAG = 1,
27 TOUCH_RELEASE = 2,
28 TOUCH_HOLD = 3,
29 TOUCH_REPEAT = 4
30} TOUCH_STATE;
31
32class FontResource : public Resource
33{
34public:
35 FontResource(xml_node<>* node, ZipArchive* pZip);
36 virtual ~FontResource();
37
38public:
39 virtual void* GetResource(void) { return mFont; }
40
41protected:
42 void* mFont;
43};
44
45class ImageResource : public Resource
46{
47public:
48 ImageResource(xml_node<>* node, ZipArchive* pZip);
49 virtual ~ImageResource();
50
51public:
52 virtual void* GetResource(void) { return mSurface; }
53
54protected:
55 gr_surface mSurface;
56};
57
58class AnimationResource : public Resource
59{
60public:
61 AnimationResource(xml_node<>* node, ZipArchive* pZip);
62 virtual ~AnimationResource();
63
64public:
65 virtual void* GetResource(void) { return mSurfaces.at(0); }
66 virtual void* GetResource(int entry) { return mSurfaces.at(entry); }
67 virtual int GetResourceCount(void) { return mSurfaces.size(); }
68
69protected:
70 std::vector<gr_surface> mSurfaces;
71};
72
73class ResourceManager
74{
75public:
76 ResourceManager(xml_node<>* resList, ZipArchive* pZip);
77 virtual ~ResourceManager();
78
79public:
80 Resource* FindResource(std::string name);
81
82private:
83 std::vector<Resource*> mResources;
84};
85
86#endif // _RESOURCE_HEADER
87