blob: 4e05e4186974e06fa176b74702067558b8010de6 [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:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020010 Resource(xml_node<>* node, ZipArchive* pZip);
11 virtual ~Resource() {}
Dees_Troy51a0e822012-09-05 15:24:24 -040012
13public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020014 virtual void* GetResource(void) = 0;
15 std::string GetName(void) { return mName; }
Dees_Troy51a0e822012-09-05 15:24:24 -040016
17private:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020018 std::string mName;
Dees_Troy51a0e822012-09-05 15:24:24 -040019
20protected:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020021 static int ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile);
Dees_Troy51a0e822012-09-05 15:24:24 -040022};
23
24typedef enum {
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020025 TOUCH_START = 0,
26 TOUCH_DRAG = 1,
27 TOUCH_RELEASE = 2,
Dees_Troy51a0e822012-09-05 15:24:24 -040028 TOUCH_HOLD = 3,
29 TOUCH_REPEAT = 4
30} TOUCH_STATE;
31
32class FontResource : public Resource
33{
34public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020035 FontResource(xml_node<>* node, ZipArchive* pZip);
36 virtual ~FontResource();
Dees_Troy51a0e822012-09-05 15:24:24 -040037
38public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020039 virtual void* GetResource(void) { return mFont; }
Dees_Troy51a0e822012-09-05 15:24:24 -040040
41protected:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020042 void* mFont;
Dees_Troy51a0e822012-09-05 15:24:24 -040043};
44
45class ImageResource : public Resource
46{
47public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020048 ImageResource(xml_node<>* node, ZipArchive* pZip);
49 virtual ~ImageResource();
Dees_Troy51a0e822012-09-05 15:24:24 -040050
51public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020052 virtual void* GetResource(void) { return mSurface; }
Dees_Troy51a0e822012-09-05 15:24:24 -040053
54protected:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020055 gr_surface mSurface;
Dees_Troy51a0e822012-09-05 15:24:24 -040056};
57
58class AnimationResource : public Resource
59{
60public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020061 AnimationResource(xml_node<>* node, ZipArchive* pZip);
62 virtual ~AnimationResource();
Dees_Troy51a0e822012-09-05 15:24:24 -040063
64public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020065 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(); }
Dees_Troy51a0e822012-09-05 15:24:24 -040068
69protected:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020070 std::vector<gr_surface> mSurfaces;
Dees_Troy51a0e822012-09-05 15:24:24 -040071};
72
73class ResourceManager
74{
75public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020076 ResourceManager(xml_node<>* resList, ZipArchive* pZip);
77 virtual ~ResourceManager();
Dees_Troy51a0e822012-09-05 15:24:24 -040078
79public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020080 Resource* FindResource(std::string name);
Dees_Troy51a0e822012-09-05 15:24:24 -040081
82private:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020083 std::vector<Resource*> mResources;
Dees_Troy51a0e822012-09-05 15:24:24 -040084};
85
86#endif // _RESOURCE_HEADER