From 3bcda748cd72927a5a43cc33b7bf864994be8659 Mon Sep 17 00:00:00 2001 From: louis Date: Tue, 20 Jan 2015 09:29:16 +0100 Subject: [PATCH] adapted plugin setup to support skin setups --- Makefile | 1 - config.c | 72 +++++++++++++- config.h | 21 +++- designer.c | 1 + displaymenu.c | 4 + libcore/skinsetup.c | 134 ++++++++++++++++++++++--- libcore/skinsetup.h | 37 ++++++- libcore/skinsetupparameter.c | 21 ---- libcore/skinsetupparameter.h | 31 ------ po/de_DE.po | 24 +++-- setup.c | 187 ++++++++++++++++++++++++++--------- setup.h | 46 +++++++-- skindesigner.c | 12 +++ skins/blackhole/setup.xml | 6 +- views/displaychannelview.c | 3 +- 15 files changed, 451 insertions(+), 149 deletions(-) delete mode 100644 libcore/skinsetupparameter.c delete mode 100644 libcore/skinsetupparameter.h diff --git a/Makefile b/Makefile index a43351a..d2d77aa 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,6 @@ OBJS = $(PLUGIN).o \ libcore/helpers.o \ libcore/imageloader.o \ libcore/recfolderinfo.o \ - libcore/skinsetupparameter.o \ libcore/skinsetup.o \ libcore/extrecinfo.o \ libcore/timers.o \ diff --git a/config.c b/config.c index b77a164..48605a3 100644 --- a/config.c +++ b/config.c @@ -3,6 +3,7 @@ #include "libcore/imageloader.h" cDesignerConfig::cDesignerConfig() { + tmplGlobals = NULL; epgImagePathSet = false; skinPathSet = false; logoPathSet = false; @@ -27,9 +28,7 @@ cDesignerConfig::cDesignerConfig() { } cDesignerConfig::~cDesignerConfig() { - for (map < string, cSkinSetup* >::iterator it = skinSetups.begin(); it != skinSetups.end(); it++) { - delete it->second; - } + ClearSkinSetups(); } void cDesignerConfig::SetPathes(void) { @@ -78,6 +77,12 @@ void cDesignerConfig::ReadSkins(void) { dsyslog("skindesigner %ld skins found in %s", skins.size(), *skinPath); } +void cDesignerConfig::ClearSkinSetups(void) { + for (map < string, cSkinSetup* >::iterator it = skinSetups.begin(); it != skinSetups.end(); it++) { + delete it->second; + } +} + void cDesignerConfig::ReadSkinSetup(string skin) { cSkinSetup *skinSetup = new cSkinSetup(skin); if (skinSetup->ReadFromXML()) { @@ -103,6 +108,59 @@ cSkinSetup* cDesignerConfig::GetSkinSetup(string &skin) { return NULL; } +cSkinSetup* cDesignerConfig::GetSkinSetup(void) { + if (setupIt == skinSetups.end()) { + return NULL; + } + cSkinSetup* skinSetup = setupIt->second; + setupIt++; + return skinSetup; +} + +void cDesignerConfig::TranslateSetup(void) { + for (map< string, cSkinSetup* >::iterator it = skinSetups.begin(); it != skinSetups.end(); it++) { + (it->second)->TranslateSetup(); + } +} + +void cDesignerConfig::CheckUnknownSetupParameters(void) { + for (vector < pair >::iterator it = unknownSetupParameters.begin(); it != unknownSetupParameters.end(); it++) { + string name = (*it).first; + int value = (*it).second; + + InitSkinIterator(); + string activeSkin = ""; + bool skinFound = false; + while (GetSkin(activeSkin)) { + size_t hit = name.find(activeSkin); + if (hit != 0) + continue; + skinFound = true; + break; + } + if (skinFound) { + cSkinSetup* skinSetup = GetSkinSetup(activeSkin); + if (skinSetup != NULL) { + string paramName = name.substr(activeSkin.size()+1); + cSkinSetupParameter *skinSetupParam = skinSetup->GetParameter(paramName); + if (skinSetupParam) { + skinSetupParam->value = value; + continue; + } + } + } + esyslog("skindesigner: ERROR Unknown Setup Parameter %s", name.c_str()); + } +} + +void cDesignerConfig::UpdateGlobals(void) { + string activeSkin = Setup.OSDSkin; + cSkinSetup *skinSetupActiveSkin = GetSkinSetup(activeSkin); + if (skinSetupActiveSkin && tmplGlobals) { + dsyslog("skindesigner: globals for skin %s adapted to skin setup", activeSkin.c_str()); + skinSetupActiveSkin->AddToGlobals(tmplGlobals); + } +} void cDesignerConfig::CheckDecimalPoint(void) { struct lconv *pLocInfo; @@ -216,6 +274,7 @@ cString cDesignerConfig::CheckSlashAtEnd(std::string path) { } bool cDesignerConfig::SetupParse(const char *Name, const char *Value) { + bool pluginSetupParam = true; if (!strcasecmp(Name, "DebugImageLoading")) debugImageLoading = atoi(Value); else if (!strcasecmp(Name, "LimitChannelLogoCache")) limitLogoCache = atoi(Value); else if (!strcasecmp(Name, "NumberLogosInitially")) numLogosPerSizeInitial = atoi(Value); @@ -224,6 +283,11 @@ bool cDesignerConfig::SetupParse(const char *Name, const char *Value) { else if (!strcasecmp(Name, "RerunDistance")) rerunDistance = atoi(Value); else if (!strcasecmp(Name, "RerunMaxChannel")) rerunMaxChannel = atoi(Value); else if (!strcasecmp(Name, "BlockFlush")) blockFlush = atoi(Value); - else return false; + else pluginSetupParam = false; + + if (!pluginSetupParam) { + unknownSetupParameters.push_back(pair (Name, atoi(Value))); + } + return true; } diff --git a/config.h b/config.h index 36c67e3..31dd065 100644 --- a/config.h +++ b/config.h @@ -27,9 +27,12 @@ private: string fontOsd; string fontSml; string osdLanguage; + cGlobals *tmplGlobals; map < string, map < int, string > > plugins; map < string, map < int, string > >::iterator plugIt; - map< string, cSkinSetup* > skinSetups; + map < string, cSkinSetup* > skinSetups; + map < string, cSkinSetup* >::iterator setupIt; + vector < pair > unknownSetupParameters; public: cDesignerConfig(); ~cDesignerConfig(); @@ -42,7 +45,14 @@ public: void ReadSkinSetup(string skin); void InitSkinIterator(void) { skinIterator = skins.begin(); }; bool GetSkin(string &skin); + void ClearSkinSetups(void); cSkinSetup* GetSkinSetup(string &skin); + cSkinSetup* GetSkinSetup(void); + void InitSetupIterator(void) { setupIt = skinSetups.begin(); }; + void TranslateSetup(void); + void CheckUnknownSetupParameters(void); + void SetGlobals(cGlobals *globals) { tmplGlobals = globals; }; + void UpdateGlobals(void); void CheckDecimalPoint(void); void SetSkin(void); bool SkinChanged(void); @@ -58,14 +68,15 @@ public: cString skinPath; cString logoPath; cString epgImagePath; + vector skins; + vector::iterator skinIterator; + bool replaceDecPoint; + char decPoint; + //Setup Parameter int numLogosPerSizeInitial; int limitLogoCache; int numLogosMax; int debugImageLoading; - bool replaceDecPoint; - char decPoint; - vector skins; - vector::iterator skinIterator; int rerunAmount; int rerunDistance; int rerunMaxChannel; diff --git a/designer.c b/designer.c index 7d70d07..27108d2 100644 --- a/designer.c +++ b/designer.c @@ -262,6 +262,7 @@ bool cSkinDesigner::LoadTemplates(void) { esyslog("skindesigner: error parsing globals, aborting"); return false; } + config.SetGlobals(globals); cSkinSetup *skinSetup = config.GetSkinSetup(skin); if (skinSetup) { diff --git a/displaymenu.c b/displaymenu.c index 2d922cd..510cb2f 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -19,6 +19,7 @@ cSDDisplayMenu::cSDDisplayMenu(cTemplate *menuTemplate) { doOutput = false; return; } + esyslog("skindesigner: menu opened"); } cSDDisplayMenu::~cSDDisplayMenu() { @@ -26,6 +27,7 @@ cSDDisplayMenu::~cSDDisplayMenu() { delete rootView; if (textAreaFont) delete textAreaFont; + esyslog("skindesigner: menu closed"); } void cSDDisplayMenu::Scroll(bool Up, bool Page) { @@ -69,6 +71,7 @@ void cSDDisplayMenu::SetPluginMenu(string name, int menu, int type, bool init) { void cSDDisplayMenu::SetTitle(const char *Title) { if (!doOutput) return; + esyslog("skindesigner: --------------- Set Title %s", Title); rootView->SetTitle(Title); } @@ -184,6 +187,7 @@ bool cSDDisplayMenu::SetItemPlugin(map *stringTokens, map" : "", Text); if (!doOutput) return; cDisplayMenuListView *list = rootView->GetListView(); diff --git a/libcore/skinsetup.c b/libcore/skinsetup.c index a1484f3..ceeb687 100644 --- a/libcore/skinsetup.c +++ b/libcore/skinsetup.c @@ -1,10 +1,40 @@ #include "skinsetup.h" #include "../libtemplate/xmlparser.h" +// --- cSkinSetupParameter ----------------------------------------------------------- + +cSkinSetupParameter::cSkinSetupParameter(void) { + type = sptUnknown; + name = ""; + displayText = ""; + min = 0; + max = 1000; + value = 0; +} + +void cSkinSetupParameter::Debug(void) { + string sType = "unknown"; + if (type == sptBool) + sType = "bool"; + else if (type == sptInt) + sType = "int"; + dsyslog("skindesigner: name \"%s\", type %s, displayText \"%s\", Value %d", name.c_str(), sType.c_str(), displayText.c_str(), value); + if (type == sptInt) + dsyslog("skindesigner: min %d, max %d", min, max); +} + +// --- cSkinSetup ----------------------------------------------------------- + cSkinSetup::cSkinSetup(string skin) { this->skin = skin; } +cSkinSetup::~cSkinSetup() { + for (map < string, cSkinSetupParameter* >::iterator p = parameters.begin(); p != parameters.end(); p++) { + delete p->second; + } +} + bool cSkinSetup::ReadFromXML(void) { string xmlFile = "setup.xml"; cXmlParser parser; @@ -30,22 +60,39 @@ void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText 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; + + cSkinSetupParameter *param = new cSkinSetupParameter(); + param->type = paramType; + param->name = (const char*)name; + param->displayText = (const char*)displayText; if (min && paramType == sptInt) { - param.min = atoi((const char*)min); + param->min = atoi((const char*)min); } if (max && paramType == sptInt) { - param.max = atoi((const char*)max); + param->max = atoi((const char*)max); } - param.value = atoi((const char*)value); + param->value = atoi((const char*)value); - parameters.insert(pair(param.name, param)); + parameters.insert(pair< string, cSkinSetupParameter* >(param->name, param)); } +cSkinSetupParameter *cSkinSetup::GetParameter(void) { + if (paramIt == parameters.end()) + return NULL; + cSkinSetupParameter *param = paramIt->second; + paramIt++; + return param; +} + +cSkinSetupParameter *cSkinSetup::GetParameter(string name) { + map < string, cSkinSetupParameter* >::iterator hit = parameters.find(name); + if (hit != parameters.end()) + return hit->second; + return NULL; +} + + void cSkinSetup::SetTranslation(string translationToken, map < string, string > transl) { translations.insert(pair >(translationToken, transl)); } @@ -53,19 +100,73 @@ void cSkinSetup::SetTranslation(string translationToken, map < string, string > void cSkinSetup::AddToGlobals(cGlobals *globals) { if (!globals) return; - for (map::iterator p = parameters.begin(); p != parameters.end(); p++) { - string paramName = p->first; - cSkinSetupParameter param = p->second; - globals->intVars.erase(paramName); - globals->intVars.insert(pair(paramName, param.value)); + for (map < string, cSkinSetupParameter* >::iterator p = parameters.begin(); p != parameters.end(); p++) { + cSkinSetupParameter *param = p->second; + globals->intVars.erase(param->name); + globals->intVars.insert(pair(param->name, param->value)); } } +void cSkinSetup::TranslateSetup(void) { + InitParameterIterator(); + cSkinSetupParameter *param = NULL; + while (param = GetParameter()) { + string transl = ""; + if (Translate(param->displayText, transl)) { + param->displayText = transl; + } + } +} + +bool cSkinSetup::Translate(string text, string &translation) { + string transStart = "{tr("; + string transEnd = ")}"; + size_t foundStart = text.find(transStart); + size_t foundEnd = text.find(transEnd); + bool translated = false; + + while (foundStart != string::npos && foundEnd != string::npos) { + string token = text.substr(foundStart + 1, foundEnd - foundStart); + string transToken = DoTranslate(token); + if (transToken.size() > 0) + translated = true; + else + return false; + text.replace(foundStart, foundEnd - foundStart + 2, transToken); + foundStart = text.find(transStart); + foundEnd = text.find(transEnd); + } + if (translated) + translation = text; + return translated; +} + +string cSkinSetup::DoTranslate(string token) { + string translation = ""; + map >::iterator hit = translations.find(token); + if (hit == translations.end()) { + esyslog("skindesigner: invalid translation token %s", token.c_str()); + return translation; + } + map< string, string > translats = hit->second; + map< string, string >::iterator trans = translats.find(Setup.OSDLanguage); + if (trans != translats.end()) { + translation = trans->second; + } else { + map< string, string >::iterator transDefault = translats.find("en_EN"); + if (transDefault != translats.end()) { + translation = transDefault->second; + } + } + return translation; +} + void cSkinSetup::Debug(void) { dsyslog("skindesigner: Skin \"%s\" Setup Parameters", skin.c_str()); - for (map::iterator p = parameters.begin(); p != parameters.end(); p++) { - (p->second).Debug(); + for (map < string, cSkinSetupParameter* >::iterator p = parameters.begin(); p != parameters.end(); p++) { + (p->second)->Debug(); } + dsyslog("skindesigner: Skin \"%s\" Setup Parameter Translations", skin.c_str()); for (map >::iterator trans = translations.begin(); trans != translations.end(); trans++) { dsyslog("skindesigner: translation token %s", (trans->first).c_str()); @@ -73,5 +174,6 @@ void cSkinSetup::Debug(void) { for (map::iterator trans2 = transValues.begin(); trans2 != transValues.end(); trans2++) { dsyslog("skindesigner: translation language %s value \"%s\"", (trans2->first).c_str(), (trans2->second).c_str()); } - } + } + } diff --git a/libcore/skinsetup.h b/libcore/skinsetup.h index e5fcdc8..4b0082d 100644 --- a/libcore/skinsetup.h +++ b/libcore/skinsetup.h @@ -9,24 +9,53 @@ #include #include #include "../libtemplate/globals.h" -#include "skinsetupparameter.h" 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); +}; + // --- cSkinSetup ----------------------------------------------------------- class cSkinSetup { private: string skin; - map parameters; - map > translations; + map < string, cSkinSetupParameter* > parameters; + map < string, cSkinSetupParameter* >::iterator paramIt; + map < string, map< string, string > > translations; + string DoTranslate(string token); + bool Translate(string text, string &translation); public: cSkinSetup(string skin); - virtual ~cSkinSetup(void) {}; + virtual ~cSkinSetup(void); bool ReadFromXML(void); 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 TranslateSetup(void); + void InitParameterIterator(void) { paramIt = parameters.begin(); }; + cSkinSetupParameter *GetParameter(void); + cSkinSetupParameter *GetParameter(string name); + string GetSkin(void) { return skin; }; void Debug(void); }; diff --git a/libcore/skinsetupparameter.c b/libcore/skinsetupparameter.c deleted file mode 100644 index e6c3672..0000000 --- a/libcore/skinsetupparameter.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "skinsetupparameter.h" - -cSkinSetupParameter::cSkinSetupParameter(void) { - type = sptUnknown; - name = ""; - displayText = ""; - min = 0; - max = 1000; - value = 0; -} - -void cSkinSetupParameter::Debug(void) { - string sType = "unknown"; - if (type == sptBool) - sType = "bool"; - else if (type == sptInt) - sType = "int"; - dsyslog("skindesigner: name \"%s\", type %s, displayText \"%s\", Value %d", name.c_str(), sType.c_str(), displayText.c_str(), value); - if (type == sptInt) - dsyslog("skindesigner: min %d, max %d", min, max); -} \ No newline at end of file diff --git a/libcore/skinsetupparameter.h b/libcore/skinsetupparameter.h deleted file mode 100644 index d038159..0000000 --- a/libcore/skinsetupparameter.h +++ /dev/null @@ -1,31 +0,0 @@ -#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 diff --git a/po/de_DE.po b/po/de_DE.po index 6f131e3..ff7d3d1 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-skindesigner 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-10-18 07:30+0200\n" +"POT-Creation-Date: 2015-01-19 17:09+0100\n" "PO-Revision-Date: 2014-09-27 11:02+0200\n" "Last-Translator: Louis Braun \n" "Language-Team: \n" @@ -21,12 +21,12 @@ msgstr "eines nach dem anderen" msgid "at one go" msgstr "alle auf einmal" +msgid "Skin" +msgstr "" + msgid "Menu Item display method" msgstr "Art der Ausgabe der Menüelemente" -msgid "Reruns" -msgstr "Wiederholungen" - msgid "Maximum number of reruns to display" msgstr "Anzahl anzuzeigender Wiederholungen" @@ -36,9 +36,6 @@ msgstr "Zeitl. Abstand der Wiederholung (in h)" msgid "Limit Channel Numbers (0 = no limit)" msgstr "Kanalnummern begrenzen (0 = unbegrenzt)" -msgid "Image Loading" -msgstr "Bilder" - msgid "Debug Image Loading" msgstr "Debugausgabe für das Laden der Bilder" @@ -51,8 +48,8 @@ msgstr "Anzahl der initial zu cachenden Logos" msgid "Number to cache in maximum" msgstr "Maximale Anzahl zu cachender Logos" -msgid "Cache Statistics" -msgstr "Cache Statistik" +msgid "has no setup" +msgstr "" msgid "cached" msgstr "cached" @@ -71,3 +68,12 @@ msgstr "Logos" msgid "skinparts" msgstr "Skinparts" + +#~ msgid "Reruns" +#~ msgstr "Wiederholungen" + +#~ msgid "Image Loading" +#~ msgstr "Bilder" + +#~ msgid "Cache Statistics" +#~ msgstr "Cache Statistik" diff --git a/setup.c b/setup.c index 20796c5..bfffd59 100644 --- a/setup.c +++ b/setup.c @@ -1,7 +1,14 @@ #include "setup.h" cSkinDesignerSetup::cSkinDesignerSetup() { - data = config; + numLogosPerSizeInitial = config.numLogosPerSizeInitial; + limitLogoCache = config.limitLogoCache; + numLogosMax = config.numLogosMax; + debugImageLoading = config.debugImageLoading; + rerunAmount = config.rerunAmount; + rerunDistance = config.rerunDistance; + rerunMaxChannel = config.rerunMaxChannel; + blockFlush = config.blockFlush; menuDisplayStyle[0] = tr("after one another"); menuDisplayStyle[1] = tr("at one go"); Setup(); @@ -15,36 +22,117 @@ void cSkinDesignerSetup::Setup(void) { int current = Current(); Clear(); - Add(new cMenuEditStraItem(tr("Menu Item display method"), &data.blockFlush, 2, menuDisplayStyle)); + SkinSetup(); + PluginSetup(); + ImageCacheStatistics(); - cString message = cString::sprintf("---------------- %s ----------------", tr("Reruns")); - Add(new cOsdItem(*message)); - cList::Last()->SetSelectable(false); + SetCurrent(Get(current)); + Display(); +} - Add(new cMenuEditIntItem(tr("Maximum number of reruns to display"), &data.rerunAmount, 1, 100)); - Add(new cMenuEditIntItem(tr("Minimum timely distance of rerun (in hours)"), &data.rerunDistance, 0, 1000)); - Add(new cMenuEditIntItem(tr("Limit Channel Numbers (0 = no limit)"), &data.rerunMaxChannel, 0, 1000)); +eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) { + bool hadSubMenu = HasSubMenu(); + eOSState state = cMenuSetupPage::ProcessKey(Key); + if (hadSubMenu && Key == kOk) { + esyslog("skindesigner: store submenu"); + } + if (!hadSubMenu && (state == osUnknown || Key == kOk)) { + if ((Key == kOk && !hadSubMenu)) { + switch (Key) { + case kOk: { + string itemText = Get(Current())->Text(); + size_t hit = itemText.find(tr("Skin")); + if (hit == 0) { + string skin = itemText.substr(strlen(tr("Skin"))+1); + state = AddSubMenu(new cSkindesignerSkinSetup(skin)); + } + break; + } default: + break; + } + } + } + return state; +} - message = cString::sprintf("---------------- %s ----------------", tr("Image Loading")); - Add(new cOsdItem(*message)); - cList::Last()->SetSelectable(false); +void cSkinDesignerSetup::Store(void) { + config.numLogosPerSizeInitial = numLogosPerSizeInitial; + config.limitLogoCache = limitLogoCache; + config.numLogosMax = numLogosMax; + config.debugImageLoading = debugImageLoading; + config.rerunAmount = rerunAmount; + config.rerunDistance = rerunDistance; + config.rerunMaxChannel = rerunMaxChannel; + config.blockFlush = blockFlush; - Add(new cMenuEditBoolItem(tr("Debug Image Loading"), &data.debugImageLoading)); + config.InitSetupIterator(); + cSkinSetup *skinSetup = NULL; + while (skinSetup = config.GetSkinSetup()) { + string skin = skinSetup->GetSkin(); + skinSetup->InitParameterIterator(); + cSkinSetupParameter *param = NULL; + while (param = skinSetup->GetParameter()) { + SetupStore(*cString::sprintf("%s.%s", skin.c_str(), param->name.c_str()), param->value); + } + } + config.UpdateGlobals(); - Add(new cMenuEditBoolItem(tr("Limit Channel Logo Cache"), &data.limitLogoCache)); - Add(new cMenuEditIntItem(tr("Number to cache initially (per size)"), &data.numLogosPerSizeInitial, 0, 1000)); - Add(new cMenuEditIntItem(tr("Number to cache in maximum"), &data.numLogosMax, 0, 1000)); + SetupStore("DebugImageLoading", debugImageLoading); + SetupStore("LimitChannelLogoCache", limitLogoCache); + SetupStore("NumberLogosInitially", numLogosPerSizeInitial); + SetupStore("NumberLogosMax", numLogosMax); + SetupStore("RerunAmount", rerunAmount); + SetupStore("RerunDistance", rerunDistance); + SetupStore("RerunMaxChannel", rerunMaxChannel); + SetupStore("BlockFlush", blockFlush); +} +cOsdItem *cSkinDesignerSetup::InfoItem(const char *label) { + cOsdItem *item; + item = new cOsdItem(cString::sprintf("---------------- %s ----------------", tr(label))); + item->SetSelectable(false); + return item; +} + +void cSkinDesignerSetup::PluginSetup(void) { + Add(InfoItem("Plugin Setup")); + + Add(new cMenuEditStraItem(tr("Menu Item display method"), &blockFlush, 2, menuDisplayStyle)); + + Add(InfoItem("Reruns")); + Add(new cMenuEditIntItem(tr("Maximum number of reruns to display"), &rerunAmount, 1, 100)); + Add(new cMenuEditIntItem(tr("Minimum timely distance of rerun (in hours)"), &rerunDistance, 0, 1000)); + Add(new cMenuEditIntItem(tr("Limit Channel Numbers (0 = no limit)"), &rerunMaxChannel, 0, 1000)); + + Add(InfoItem("Image Loading")); + Add(new cMenuEditBoolItem(tr("Debug Image Loading"), &debugImageLoading)); + Add(new cMenuEditBoolItem(tr("Limit Channel Logo Cache"), &limitLogoCache)); + Add(new cMenuEditIntItem(tr("Number to cache initially (per size)"), &numLogosPerSizeInitial, 0, 1000)); + Add(new cMenuEditIntItem(tr("Number to cache in maximum"), &numLogosMax, 0, 1000)); +} + +void cSkinDesignerSetup::SkinSetup(void) { + Add(InfoItem("Skin Setup")); + + config.InitSkinIterator(); + string skin = ""; + while (config.GetSkin(skin)) { + cSkinSetup *skinSetup = config.GetSkinSetup(skin); + if (!skinSetup) { + Add(new cOsdItem(cString::sprintf("%s %s %s", tr("Skin"), skin.c_str(), tr("has no setup")))); + cList::Last()->SetSelectable(false); + } else { + Add(new cOsdItem(cString::sprintf("%s %s", tr("Skin"), skin.c_str()))); + } + } +} + +void cSkinDesignerSetup::ImageCacheStatistics(void) { if (!imgCache) { - SetCurrent(Get(current)); - Display(); return; } - message = cString::sprintf("---------------- %s ----------------", tr("Cache Statistics")); - Add(new cOsdItem(*message)); - cList::Last()->SetSelectable(false); - + Add(InfoItem("Cache Statistics")); int sizeIconCache = 0; int numIcons = 0; imgCache->GetIconCacheSize(numIcons, sizeIconCache); @@ -65,35 +153,44 @@ void cSkinDesignerSetup::Setup(void) { cString skinpartCacheInfo = cString::sprintf("%s %d %s - %s %d %s", tr("cached"), numSkinparts, tr("skinparts"), tr("size"), sizeSkinpartCache, tr("byte")); Add(new cOsdItem(*skinpartCacheInfo)); cList::Last()->SetSelectable(false); - - SetCurrent(Get(current)); - Display(); } -eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) { - eOSState state = cMenuSetupPage::ProcessKey(Key); - switch (state) { - case osContinue: { - if (NORMALKEY(Key) == kUp || NORMALKEY(Key) == kDown) { - cOsdItem* item = Get(Current()); - if (item) - item->ProcessKey(kNone); - } - break; } - default: break; +// --- cSkindesignerSkinSetup ----------------------------------------------------------- + +cSkindesignerSkinSetup::cSkindesignerSkinSetup(string skin) : cOsdMenu(*cString::sprintf("%s: %s \"%s\"", trVDR("Setup"), tr("Skin"), skin.c_str()), 30) { + this->skin = skin; + Set(); +} + +cSkindesignerSkinSetup::~cSkindesignerSkinSetup() { +} + +eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) { + eOSState state = cOsdMenu::ProcessKey(Key); + if (state == osUnknown) { + switch (Key) { + case kOk: + return osBack; + default: + break; + } } return state; } -void cSkinDesignerSetup::Store(void) { - config = data; +void cSkindesignerSkinSetup::Set(void) { + cSkinSetup *skinSetup = config.GetSkinSetup(skin); + if (!skinSetup) + return; + + skinSetup->InitParameterIterator(); + cSkinSetupParameter *param = NULL; + while (param = skinSetup->GetParameter()) { + if (param->type == sptInt) { + Add(new cMenuEditIntItem(param->displayText.c_str(), ¶m->value, param->min, param->max)); + } else if (param->type == sptBool) { + Add(new cMenuEditBoolItem(param->displayText.c_str(), ¶m->value)); + } + } - SetupStore("DebugImageLoading", config.debugImageLoading); - SetupStore("LimitChannelLogoCache", config.limitLogoCache); - SetupStore("NumberLogosInitially", config.numLogosPerSizeInitial); - SetupStore("NumberLogosMax", config.numLogosMax); - SetupStore("RerunAmount", config.rerunAmount); - SetupStore("RerunDistance", config.rerunDistance); - SetupStore("RerunMaxChannel", config.rerunMaxChannel); - SetupStore("BlockFlush", config.blockFlush); } \ No newline at end of file diff --git a/setup.h b/setup.h index 627f173..f831d74 100644 --- a/setup.h +++ b/setup.h @@ -3,15 +3,43 @@ #include "config.h" +// --- cSkinDesignerSetup ----------------------------------------------------------- + class cSkinDesignerSetup : public cMenuSetupPage { - public: - cSkinDesignerSetup(void); - virtual ~cSkinDesignerSetup(); - private: - cDesignerConfig data; - const char *menuDisplayStyle[2]; - void Setup(void); - virtual eOSState ProcessKey(eKeys Key); - virtual void Store(void); +private: + int numLogosPerSizeInitial; + int limitLogoCache; + int numLogosMax; + int debugImageLoading; + int rerunAmount; + int rerunDistance; + int rerunMaxChannel; + int blockFlush; + const char *menuDisplayStyle[2]; + + void Setup(void); + virtual void Store(void); + virtual eOSState ProcessKey(eKeys Key); + cOsdItem *InfoItem(const char *label); + void PluginSetup(void); + void SkinSetup(void); + void ImageCacheStatistics(void); +public: + cSkinDesignerSetup(void); + virtual ~cSkinDesignerSetup(); }; + +// --- cSkindesignerSkinSetup ----------------------------------------------------------- + +class cSkindesignerSkinSetup : public cOsdMenu { +private: + string skin; +protected: + virtual eOSState ProcessKey(eKeys Key); + void Set(void); +public: + cSkindesignerSkinSetup(string skin); + virtual ~cSkindesignerSkinSetup(); +}; + #endif //__SKINDESIGNER_SETUP_H \ No newline at end of file diff --git a/skindesigner.c b/skindesigner.c index b416a87..60fa0b9 100644 --- a/skindesigner.c +++ b/skindesigner.c @@ -98,6 +98,7 @@ bool cPluginSkinDesigner::Start(void) { cXmlParser::InitLibXML(); cImageImporterSVG::InitLibRSVG(); bool trueColorAvailable = true; + if (!cOsdProvider::SupportsTrueColor()) { esyslog("skindesigner: No TrueColor OSD found! Using default Skin LCARS!"); trueColorAvailable = false; @@ -115,6 +116,9 @@ bool cPluginSkinDesigner::Start(void) { newSkin->ActivateBackupSkin(); } } + config.TranslateSetup(); + config.CheckUnknownSetupParameters(); + if (skins.size() == 0) { esyslog("skindesigner: no skins found! Using default Skin LCARS!"); } @@ -218,6 +222,14 @@ cString cPluginSkinDesigner::SVDRPCommand(const char *Command, const char *Optio } if (strcasecmp(Command, "RELD") == 0) { + config.ClearSkinSetups(); + config.InitSkinIterator(); + string skin = ""; + while (config.GetSkin(skin)) { + config.ReadSkinSetup(skin); + } + config.TranslateSetup(); + config.CheckUnknownSetupParameters(); activeSkin->Reload(); ReplyCode = 250; return "SKINDESIGNER reload of templates and caches forced."; diff --git a/skins/blackhole/setup.xml b/skins/blackhole/setup.xml index db097f9..7202d58 100644 --- a/skins/blackhole/setup.xml +++ b/skins/blackhole/setup.xml @@ -12,9 +12,9 @@ "displayname" is used to display the option in the setup menu. --> - 0 - 1 - 300 + 0 + 1 + 300