mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
added skinsetup to globals
This commit is contained in:
parent
f2f7246c0b
commit
f72a1856cb
19
config.c
19
config.c
@ -27,7 +27,9 @@ cDesignerConfig::cDesignerConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cDesignerConfig::~cDesignerConfig() {
|
cDesignerConfig::~cDesignerConfig() {
|
||||||
esyslog("skindesigner: config destruktor");
|
for (map < string, cSkinSetup* >::iterator it = skinSetups.begin(); it != skinSetups.end(); it++) {
|
||||||
|
delete it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDesignerConfig::SetPathes(void) {
|
void cDesignerConfig::SetPathes(void) {
|
||||||
@ -78,8 +80,10 @@ void cDesignerConfig::ReadSkins(void) {
|
|||||||
|
|
||||||
void cDesignerConfig::ReadSkinSetup(string skin) {
|
void cDesignerConfig::ReadSkinSetup(string skin) {
|
||||||
cSkinSetup *skinSetup = new cSkinSetup(skin);
|
cSkinSetup *skinSetup = new cSkinSetup(skin);
|
||||||
skinSetup->ReadFromXML();
|
if (skinSetup->ReadFromXML()) {
|
||||||
skinSetup->Debug();
|
//skinSetup->Debug();
|
||||||
|
skinSetups.insert(pair<string, cSkinSetup* >(skin, skinSetup));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cDesignerConfig::GetSkin(string &skin) {
|
bool cDesignerConfig::GetSkin(string &skin) {
|
||||||
@ -91,6 +95,15 @@ bool cDesignerConfig::GetSkin(string &skin) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cSkinSetup* cDesignerConfig::GetSkinSetup(string &skin) {
|
||||||
|
map< string, cSkinSetup* >::iterator hit = skinSetups.find(skin);
|
||||||
|
if (hit != skinSetups.end()) {
|
||||||
|
return hit->second;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cDesignerConfig::CheckDecimalPoint(void) {
|
void cDesignerConfig::CheckDecimalPoint(void) {
|
||||||
struct lconv *pLocInfo;
|
struct lconv *pLocInfo;
|
||||||
pLocInfo = localeconv();
|
pLocInfo = localeconv();
|
||||||
|
2
config.h
2
config.h
@ -29,6 +29,7 @@ private:
|
|||||||
string osdLanguage;
|
string osdLanguage;
|
||||||
map < string, map < int, string > > plugins;
|
map < string, map < int, string > > plugins;
|
||||||
map < string, map < int, string > >::iterator plugIt;
|
map < string, map < int, string > >::iterator plugIt;
|
||||||
|
map< string, cSkinSetup* > skinSetups;
|
||||||
public:
|
public:
|
||||||
cDesignerConfig();
|
cDesignerConfig();
|
||||||
~cDesignerConfig();
|
~cDesignerConfig();
|
||||||
@ -41,6 +42,7 @@ public:
|
|||||||
void ReadSkinSetup(string skin);
|
void ReadSkinSetup(string skin);
|
||||||
void InitSkinIterator(void) { skinIterator = skins.begin(); };
|
void InitSkinIterator(void) { skinIterator = skins.begin(); };
|
||||||
bool GetSkin(string &skin);
|
bool GetSkin(string &skin);
|
||||||
|
cSkinSetup* GetSkinSetup(string &skin);
|
||||||
void CheckDecimalPoint(void);
|
void CheckDecimalPoint(void);
|
||||||
void SetSkin(void);
|
void SetSkin(void);
|
||||||
bool SkinChanged(void);
|
bool SkinChanged(void);
|
||||||
|
11
designer.c
11
designer.c
@ -263,14 +263,11 @@ bool cSkinDesigner::LoadTemplates(void) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
cSkinSetup *skinSetup = config.GetSkinSetup(skin);
|
||||||
cSkinSetup *skinSetups = new cSkinSetup();
|
if (skinSetup) {
|
||||||
config.InitSkinIterator();
|
skinSetup->AddToGlobals(globals);
|
||||||
string skin = "";
|
|
||||||
while (config.GetSkin(skin)) {
|
|
||||||
skinSetups->ReadFromXML(skin);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
DeleteTemplates();
|
DeleteTemplates();
|
||||||
|
|
||||||
channelTemplate = new cTemplate(vtDisplayChannel);
|
channelTemplate = new cTemplate(vtDisplayChannel);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?xml encoding="UTF-8"?>
|
<?xml encoding="UTF-8"?>
|
||||||
|
|
||||||
<!ELEMENT setup (parameters)>
|
<!ELEMENT setup (parameters,translations)>
|
||||||
<!ELEMENT parameters (parameter)*>
|
<!ELEMENT parameters (parameter)*>
|
||||||
|
<!ELEMENT translations (token)*>
|
||||||
|
|
||||||
<!ELEMENT parameter (#PCDATA)>
|
<!ELEMENT parameter (#PCDATA)>
|
||||||
<!ATTLIST parameter
|
<!ATTLIST parameter
|
||||||
@ -12,3 +13,10 @@
|
|||||||
displaytext CDATA #REQUIRED
|
displaytext CDATA #REQUIRED
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<!ELEMENT token (trans)+>
|
||||||
|
<!ATTLIST token
|
||||||
|
name CDATA #REQUIRED>
|
||||||
|
|
||||||
|
<!ELEMENT trans (#PCDATA)>
|
||||||
|
<!ATTLIST trans
|
||||||
|
lang NMTOKEN #REQUIRED>
|
||||||
|
@ -5,15 +5,14 @@ cSkinSetup::cSkinSetup(string skin) {
|
|||||||
this->skin = skin;
|
this->skin = skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSkinSetup::ReadFromXML(void) {
|
bool cSkinSetup::ReadFromXML(void) {
|
||||||
esyslog("skindesigner: reading setup for skin %s", skin.c_str());
|
|
||||||
string xmlFile = "setup.xml";
|
string xmlFile = "setup.xml";
|
||||||
cXmlParser parser;
|
cXmlParser parser;
|
||||||
if (!parser.ReadSkinSetup(this, skin, xmlFile)) {
|
if (!parser.ReadSkinSetup(this, skin, xmlFile)) {
|
||||||
esyslog("skindesigner: no setup file for skin %s found", skin.c_str());
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
parser.ParseSkinSetup(skin);
|
parser.ParseSkinSetup(skin);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value) {
|
void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value) {
|
||||||
@ -44,12 +43,35 @@ void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText
|
|||||||
}
|
}
|
||||||
param.value = atoi((const char*)value);
|
param.value = atoi((const char*)value);
|
||||||
|
|
||||||
parameters.push_back(param);
|
parameters.insert(pair<string, cSkinSetupParameter>(param.name, param));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cSkinSetup::SetTranslation(string translationToken, map < string, string > transl) {
|
||||||
|
translations.insert(pair<string, map < string, string > >(translationToken, transl));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSkinSetup::AddToGlobals(cGlobals *globals) {
|
||||||
|
if (!globals)
|
||||||
|
return;
|
||||||
|
for (map<string, cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++) {
|
||||||
|
string paramName = p->first;
|
||||||
|
cSkinSetupParameter param = p->second;
|
||||||
|
globals->intVars.erase(paramName);
|
||||||
|
globals->intVars.insert(pair<string,int>(paramName, param.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cSkinSetup::Debug(void) {
|
void cSkinSetup::Debug(void) {
|
||||||
dsyslog("skindesigner: Skin \"%s\" Setup Parameters", skin.c_str());
|
dsyslog("skindesigner: Skin \"%s\" Setup Parameters", skin.c_str());
|
||||||
for (vector<cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++)
|
for (map<string, cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++) {
|
||||||
p->Debug();
|
(p->second).Debug();
|
||||||
|
}
|
||||||
|
dsyslog("skindesigner: Skin \"%s\" Setup Parameter Translations", skin.c_str());
|
||||||
|
for (map<string, map<string,string> >::iterator trans = translations.begin(); trans != translations.end(); trans++) {
|
||||||
|
dsyslog("skindesigner: translation token %s", (trans->first).c_str());
|
||||||
|
map<string,string> transValues = trans->second;
|
||||||
|
for (map<string,string>::iterator trans2 = transValues.begin(); trans2 != transValues.end(); trans2++) {
|
||||||
|
dsyslog("skindesigner: translation language %s value \"%s\"", (trans2->first).c_str(), (trans2->second).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vdr/plugin.h>
|
#include <vdr/plugin.h>
|
||||||
#include <libxml/xmlstring.h>
|
#include <libxml/xmlstring.h>
|
||||||
|
#include "../libtemplate/globals.h"
|
||||||
#include "skinsetupparameter.h"
|
#include "skinsetupparameter.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -17,12 +18,15 @@ using namespace std;
|
|||||||
class cSkinSetup {
|
class cSkinSetup {
|
||||||
private:
|
private:
|
||||||
string skin;
|
string skin;
|
||||||
vector<cSkinSetupParameter> parameters;
|
map <string, cSkinSetupParameter> parameters;
|
||||||
|
map <string, map< string, string > > translations;
|
||||||
public:
|
public:
|
||||||
cSkinSetup(string skin);
|
cSkinSetup(string skin);
|
||||||
virtual ~cSkinSetup(void) {};
|
virtual ~cSkinSetup(void) {};
|
||||||
void ReadFromXML(void);
|
bool ReadFromXML(void);
|
||||||
void SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value);
|
void SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value);
|
||||||
|
void SetTranslation(string translationToken, map < string, string > transl);
|
||||||
|
void AddToGlobals(cGlobals *globals);
|
||||||
void Debug(void);
|
void Debug(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,15 +10,12 @@ cSkinSetupParameter::cSkinSetupParameter(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cSkinSetupParameter::Debug(void) {
|
void cSkinSetupParameter::Debug(void) {
|
||||||
|
string sType = "unknown";
|
||||||
if (type == sptBool)
|
if (type == sptBool)
|
||||||
dsyslog("skindesigner: type bool");
|
sType = "bool";
|
||||||
else if (type == sptInt)
|
else if (type == sptInt)
|
||||||
dsyslog("skindesigner: type integer");
|
sType = "int";
|
||||||
else
|
dsyslog("skindesigner: name \"%s\", type %s, displayText \"%s\", Value %d", name.c_str(), sType.c_str(), displayText.c_str(), value);
|
||||||
dsyslog("skindesigner: type UNKNOWN");
|
|
||||||
dsyslog("skindesigner: name %s", name.c_str());
|
|
||||||
dsyslog("skindesigner: displayText %s", displayText.c_str());
|
|
||||||
if (type == sptInt)
|
if (type == sptInt)
|
||||||
dsyslog("skindesigner: min %d, max %d", min, max);
|
dsyslog("skindesigner: min %d, max %d", min, max);
|
||||||
dsyslog("skindesigner: Value %d", value);
|
|
||||||
}
|
}
|
@ -128,11 +128,8 @@ bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string skin, string xmlFil
|
|||||||
this->skinSetup = skinSetup;
|
this->skinSetup = skinSetup;
|
||||||
string xmlPath = *cString::sprintf("%s%s/%s", *config.skinPath, skin.c_str(), xmlFile.c_str());
|
string xmlPath = *cString::sprintf("%s%s/%s", *config.skinPath, skin.c_str(), xmlFile.c_str());
|
||||||
|
|
||||||
esyslog("skindesigner: reading skin setup %s", xmlPath.c_str());
|
|
||||||
|
|
||||||
if (!FileExists(xmlPath))
|
if (!FileExists(xmlPath))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ctxt == NULL) {
|
if (ctxt == NULL) {
|
||||||
esyslog("skindesigner: Failed to allocate parser context");
|
esyslog("skindesigner: Failed to allocate parser context");
|
||||||
return false;
|
return false;
|
||||||
@ -151,12 +148,9 @@ bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string skin, string xmlFil
|
|||||||
esyslog("skindesigner: Failed to validate %s", xmlPath.c_str());
|
esyslog("skindesigner: Failed to validate %s", xmlPath.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root == NULL) {
|
if (root == NULL) {
|
||||||
esyslog("skindesigner: ERROR: Skin Setup %s is empty", xmlPath.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xmlStrcmp(root->name, (const xmlChar *) "setup")) {
|
if (xmlStrcmp(root->name, (const xmlChar *) "setup")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -271,8 +265,6 @@ bool cXmlParser::ParseGlobals(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool cXmlParser::ParseSkinSetup(string skin) {
|
bool cXmlParser::ParseSkinSetup(string skin) {
|
||||||
esyslog("skindesigner: parsing skinsetup from %s", skin.c_str());
|
|
||||||
|
|
||||||
xmlNodePtr node = root->xmlChildrenNode;
|
xmlNodePtr node = root->xmlChildrenNode;
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
@ -284,6 +276,10 @@ bool cXmlParser::ParseSkinSetup(string skin) {
|
|||||||
ParseSetupParameter(node->xmlChildrenNode);
|
ParseSetupParameter(node->xmlChildrenNode);
|
||||||
node = node->next;
|
node = node->next;
|
||||||
continue;
|
continue;
|
||||||
|
} else if (!xmlStrcmp(node->name, (const xmlChar *) "translations")) {
|
||||||
|
ParseTranslations(node->xmlChildrenNode);
|
||||||
|
node = node->next;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
@ -610,7 +606,11 @@ void cXmlParser::ParseTranslations(xmlNodePtr node) {
|
|||||||
xmlFree(value);
|
xmlFree(value);
|
||||||
nodeTrans = nodeTrans->next;
|
nodeTrans = nodeTrans->next;
|
||||||
}
|
}
|
||||||
globals->translations.insert(pair<string, map < string, string > >((const char*)tokenName, tokenTranslations));
|
if (globals) {
|
||||||
|
globals->translations.insert(pair<string, map < string, string > >((const char*)tokenName, tokenTranslations));
|
||||||
|
} else if (skinSetup) {
|
||||||
|
skinSetup->SetTranslation((const char*)tokenName, tokenTranslations);
|
||||||
|
}
|
||||||
xmlFree(tokenName);
|
xmlFree(tokenName);
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,26 @@
|
|||||||
"displayname" is used to display the option in the setup menu.
|
"displayname" is used to display the option in the setup menu.
|
||||||
-->
|
-->
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter type="bool" name="showsignal" displaytext="Show Signalstrength and -quality when switching channel">0</parameter>
|
<parameter type="bool" name="showsignal" displaytext="tr(showsignaltext)">0</parameter>
|
||||||
<parameter type="bool" name="showposter" displaytext="Show Poster when switching channel">1</parameter>
|
<parameter type="bool" name="showposter" displaytext="tr(showpostertext)">1</parameter>
|
||||||
<parameter type="int" name="fadetime" min="0" max="1000" displaytext="Fade In and Out time in ms">300</parameter>
|
<parameter type="int" name="fadetime" min="0" max="1000" displaytext="tr(fadetext)">300</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
translations of displaytexts
|
||||||
|
-->
|
||||||
|
<translations>
|
||||||
|
<token name="tr(showsignaltext)">
|
||||||
|
<trans lang="en_EN">Show Signalstrength and -quality when switching channel</trans>
|
||||||
|
<trans lang="de_DE">Signalstärke und -qualität beim Umschalten anzeigen</trans>
|
||||||
|
</token>
|
||||||
|
<token name="tr(showpostertext)">
|
||||||
|
<trans lang="en_EN">Show Poster when switching channel</trans>
|
||||||
|
<trans lang="de_DE">Poster beim Umschalten anzeigen</trans>
|
||||||
|
</token>
|
||||||
|
<token name="tr(fadetext)">
|
||||||
|
<trans lang="en_EN">Fade In and Out time in ms</trans>
|
||||||
|
<trans lang="de_DE">Fade In and Out Zeit in ms</trans>
|
||||||
|
</token>
|
||||||
|
</translations>
|
||||||
</setup>
|
</setup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user