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: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 10 | Resource(xml_node<>* node, ZipArchive* pZip); |
| 11 | virtual ~Resource() {} |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 12 | |
| 13 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 14 | virtual void* GetResource(void) = 0; |
| 15 | std::string GetName(void) { return mName; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 16 | |
| 17 | private: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 18 | std::string mName; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 19 | |
| 20 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 21 | static int ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 22 | }; |
| 23 | |
| 24 | typedef enum { |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 25 | TOUCH_START = 0, |
| 26 | TOUCH_DRAG = 1, |
| 27 | TOUCH_RELEASE = 2, |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 28 | TOUCH_HOLD = 3, |
| 29 | TOUCH_REPEAT = 4 |
| 30 | } TOUCH_STATE; |
| 31 | |
| 32 | class FontResource : public Resource |
| 33 | { |
| 34 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 35 | FontResource(xml_node<>* node, ZipArchive* pZip); |
| 36 | virtual ~FontResource(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 37 | |
| 38 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 39 | virtual void* GetResource(void) { return mFont; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 40 | |
| 41 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 42 | void* mFont; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | class ImageResource : public Resource |
| 46 | { |
| 47 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 48 | ImageResource(xml_node<>* node, ZipArchive* pZip); |
| 49 | virtual ~ImageResource(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 50 | |
| 51 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 52 | virtual void* GetResource(void) { return mSurface; } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 53 | |
| 54 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 55 | gr_surface mSurface; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | class AnimationResource : public Resource |
| 59 | { |
| 60 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 61 | AnimationResource(xml_node<>* node, ZipArchive* pZip); |
| 62 | virtual ~AnimationResource(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 63 | |
| 64 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 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(); } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 68 | |
| 69 | protected: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 70 | std::vector<gr_surface> mSurfaces; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | class ResourceManager |
| 74 | { |
| 75 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 76 | ResourceManager(xml_node<>* resList, ZipArchive* pZip); |
| 77 | virtual ~ResourceManager(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 78 | |
| 79 | public: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 80 | Resource* FindResource(std::string name); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 81 | |
| 82 | private: |
Vojtech Bocek | fafb0c5 | 2013-07-25 22:53:02 +0200 | [diff] [blame] | 83 | std::vector<Resource*> mResources; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | #endif // _RESOURCE_HEADER |