blob: bef97dd88e6cae4ca910619e4d57d458bef2a276 [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
Dees Troyb7ae0982013-09-10 20:47:35 +00006#ifdef HAVE_SELINUX
7#include "../minzip/Zip.h"
8#else
9#include "../minzipold/Zip.h"
10#endif
11
Dees_Troy51a0e822012-09-05 15:24:24 -040012// Base Objects
13class Resource
14{
15public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020016 Resource(xml_node<>* node, ZipArchive* pZip);
17 virtual ~Resource() {}
Dees_Troy51a0e822012-09-05 15:24:24 -040018
19public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020020 virtual void* GetResource(void) = 0;
21 std::string GetName(void) { return mName; }
Dees_Troy51a0e822012-09-05 15:24:24 -040022
23private:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020024 std::string mName;
Dees_Troy51a0e822012-09-05 15:24:24 -040025
26protected:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020027 static int ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile);
Dees_Troy51a0e822012-09-05 15:24:24 -040028};
29
30typedef enum {
Matt Mowerfb1c4ff2014-04-16 13:43:36 -050031 TOUCH_START = 0,
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020032 TOUCH_DRAG = 1,
33 TOUCH_RELEASE = 2,
Dees_Troy51a0e822012-09-05 15:24:24 -040034 TOUCH_HOLD = 3,
35 TOUCH_REPEAT = 4
36} TOUCH_STATE;
37
38class FontResource : public Resource
39{
40public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020041 FontResource(xml_node<>* node, ZipArchive* pZip);
42 virtual ~FontResource();
Dees_Troy51a0e822012-09-05 15:24:24 -040043
44public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020045 virtual void* GetResource(void) { return mFont; }
Dees_Troy51a0e822012-09-05 15:24:24 -040046
47protected:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020048 void* mFont;
Dees_Troy51a0e822012-09-05 15:24:24 -040049};
50
51class ImageResource : public Resource
52{
53public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020054 ImageResource(xml_node<>* node, ZipArchive* pZip);
55 virtual ~ImageResource();
Dees_Troy51a0e822012-09-05 15:24:24 -040056
57public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020058 virtual void* GetResource(void) { return mSurface; }
Dees_Troy51a0e822012-09-05 15:24:24 -040059
60protected:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020061 gr_surface mSurface;
Dees_Troy51a0e822012-09-05 15:24:24 -040062};
63
64class AnimationResource : public Resource
65{
66public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020067 AnimationResource(xml_node<>* node, ZipArchive* pZip);
68 virtual ~AnimationResource();
Dees_Troy51a0e822012-09-05 15:24:24 -040069
70public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020071 virtual void* GetResource(void) { return mSurfaces.at(0); }
72 virtual void* GetResource(int entry) { return mSurfaces.at(entry); }
73 virtual int GetResourceCount(void) { return mSurfaces.size(); }
Dees_Troy51a0e822012-09-05 15:24:24 -040074
75protected:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020076 std::vector<gr_surface> mSurfaces;
Dees_Troy51a0e822012-09-05 15:24:24 -040077};
78
79class ResourceManager
80{
81public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020082 ResourceManager(xml_node<>* resList, ZipArchive* pZip);
83 virtual ~ResourceManager();
Dees_Troy51a0e822012-09-05 15:24:24 -040084
85public:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020086 Resource* FindResource(std::string name);
Dees_Troy51a0e822012-09-05 15:24:24 -040087
88private:
Vojtech Bocekfafb0c52013-07-25 22:53:02 +020089 std::vector<Resource*> mResources;
Dees_Troy51a0e822012-09-05 15:24:24 -040090};
91
92#endif // _RESOURCE_HEADER