From ac89503027f048d0fa34234ed5ac62725f3f68e4 Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 19 Jan 2015 09:23:15 +0100 Subject: introducing skin setups --- libcore/skinsetup.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ libcore/skinsetup.h | 29 +++++++++++++++++++++++ libcore/skinsetupparameter.c | 24 +++++++++++++++++++ libcore/skinsetupparameter.h | 31 +++++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 libcore/skinsetup.c create mode 100644 libcore/skinsetup.h create mode 100644 libcore/skinsetupparameter.c create mode 100644 libcore/skinsetupparameter.h (limited to 'libcore') diff --git a/libcore/skinsetup.c b/libcore/skinsetup.c new file mode 100644 index 0000000..c01f2d7 --- /dev/null +++ b/libcore/skinsetup.c @@ -0,0 +1,55 @@ +#include "skinsetup.h" +#include "../libtemplate/xmlparser.h" + +cSkinSetup::cSkinSetup(string skin) { + this->skin = skin; +} + +void cSkinSetup::ReadFromXML(void) { + esyslog("skindesigner: reading setup for skin %s", skin.c_str()); + string xmlFile = "setup.xml"; + cXmlParser parser; + if (!parser.ReadSkinSetup(this, skin, xmlFile)) { + esyslog("skindesigner: no setup file for skin %s found", skin.c_str()); + return; + } + parser.ParseSkinSetup(skin); +} + +void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value) { + if (!type || !name || !displayText || !value) { + esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str()); + return; + } + eSetupParameterType paramType = sptUnknown; + if (!xmlStrcmp(type, (const xmlChar *) "int")) { + paramType = sptInt; + } else if (!xmlStrcmp(type, (const xmlChar *) "bool")) { + paramType = sptBool; + } + if (paramType == sptUnknown) { + esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str()); + return; + } + cSkinSetupParameter param; + param.type = paramType; + param.name = (const char*)name; + param.displayText = (const char*)displayText; + + if (min && paramType == sptInt) { + param.min = atoi((const char*)min); + } + if (max && paramType == sptInt) { + param.max = atoi((const char*)max); + } + param.value = atoi((const char*)value); + + parameters.push_back(param); +} + + +void cSkinSetup::Debug(void) { + dsyslog("skindesigner: Skin \"%s\" Setup Parameters", skin.c_str()); + for (vector::iterator p = parameters.begin(); p != parameters.end(); p++) + p->Debug(); +} diff --git a/libcore/skinsetup.h b/libcore/skinsetup.h new file mode 100644 index 0000000..4f8a93c --- /dev/null +++ b/libcore/skinsetup.h @@ -0,0 +1,29 @@ +#ifndef __SKINSETUP_H +#define __SKINSETUP_H + +#include +#include +#include +#include +#include +#include +#include +#include "skinsetupparameter.h" + +using namespace std; + +// --- cSkinSetup ----------------------------------------------------------- + +class cSkinSetup { +private: + string skin; + vector parameters; +public: + cSkinSetup(string skin); + virtual ~cSkinSetup(void) {}; + void ReadFromXML(void); + void SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value); + void Debug(void); +}; + +#endif //__SKINSETUP_H \ No newline at end of file diff --git a/libcore/skinsetupparameter.c b/libcore/skinsetupparameter.c new file mode 100644 index 0000000..6f142f6 --- /dev/null +++ b/libcore/skinsetupparameter.c @@ -0,0 +1,24 @@ +#include "skinsetupparameter.h" + +cSkinSetupParameter::cSkinSetupParameter(void) { + type = sptUnknown; + name = ""; + displayText = ""; + min = 0; + max = 1000; + value = 0; +} + +void cSkinSetupParameter::Debug(void) { + if (type == sptBool) + dsyslog("skindesigner: type bool"); + else if (type == sptInt) + dsyslog("skindesigner: type integer"); + else + dsyslog("skindesigner: type UNKNOWN"); + dsyslog("skindesigner: name %s", name.c_str()); + dsyslog("skindesigner: displayText %s", displayText.c_str()); + if (type == sptInt) + dsyslog("skindesigner: min %d, max %d", min, max); + dsyslog("skindesigner: Value %d", value); +} \ No newline at end of file diff --git a/libcore/skinsetupparameter.h b/libcore/skinsetupparameter.h new file mode 100644 index 0000000..d038159 --- /dev/null +++ b/libcore/skinsetupparameter.h @@ -0,0 +1,31 @@ +#ifndef __SKINSETUPPARAMETER_H +#define __SKINSETUPPARAMETER_H + +#include +#include + +using namespace std; + +enum eSetupParameterType { + sptInt, + sptBool, + sptUnknown +}; + +// --- cSkinSetupParameter ----------------------------------------------------------- + +class cSkinSetupParameter { +private: +public: + cSkinSetupParameter(void); + virtual ~cSkinSetupParameter(void) {}; + eSetupParameterType type; + string name; + string displayText; + int min; + int max; + int value; + void Debug(void); +}; + +#endif //__SKINSETUPPARAMETER_H \ No newline at end of file -- cgit v1.2.3