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