From fe1016fed662261cb79577b47133f2921e287d28 Mon Sep 17 00:00:00 2001 From: louis Date: Tue, 12 Apr 2016 16:26:42 +0200 Subject: [PATCH] enlarged svgtemplates for menuicons and skinparts --- extensions/imagecache.c | 4 +-- extensions/imageloader.c | 26 +++++++++++++++---- extensions/imageloader.h | 4 ++- .../plug-weatherforecast-weatherforecast.xml | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/extensions/imagecache.c b/extensions/imagecache.c index fc05f5f..016022c 100644 --- a/extensions/imagecache.c +++ b/extensions/imagecache.c @@ -433,7 +433,7 @@ bool cImageCache::LoadIcon(eImageType type, string name) { return LoadImage(*subIconSkinPath, name, "png"); //and finally check if a svg template exists - cSVGTemplate svgTemplate(name, svgTemplatePath); + cSVGTemplate svgTemplate(name, *subdir, svgTemplatePath); if (!svgTemplate.Exists()) return false; svgTemplate.ReadTemplate(); @@ -484,7 +484,7 @@ bool cImageCache::LoadSkinpart(string name) { return LoadImage(skinPartsPathSkin.c_str(), name, "png"); //check if a svg template exists - cSVGTemplate svgTemplate(name, svgTemplatePath); + cSVGTemplate svgTemplate(name, "skinparts", svgTemplatePath); if (!svgTemplate.Exists()) return false; svgTemplate.ReadTemplate(); diff --git a/extensions/imageloader.c b/extensions/imageloader.c index 62d284f..bd2d268 100644 --- a/extensions/imageloader.c +++ b/extensions/imageloader.c @@ -405,21 +405,37 @@ void cImageImporterJPG::GetImageSize(int &width, int &height) { // SVG Template class // -cSVGTemplate::cSVGTemplate(string imageName, string templatePath) { +cSVGTemplate::cSVGTemplate(string imageName, string imagePath, string templatePath) { this->imageName = imageName; + this->imagePath = imagePath; this->templatePath = templatePath; + filePath = CreateImagePath(); startTokenColor = "{sdcol("; startTokenOpac = "{sdopac("; endToken = ")}"; - filePath = templatePath; - filePath += imageName + ".svg"; } cSVGTemplate::~cSVGTemplate(void) { } +string cSVGTemplate::CreateImagePath(void) { + //check if imageName is a path + if (imageName.find("/") != string::npos) { + splitstring s(imageName.c_str()); + vector flds = s.split('/', 1); + int num = flds.size() - 1; + for (int i=0; i < num; i++) { + imagePath = *cString::sprintf("%s/%s", imagePath.c_str(), flds[i].c_str()); + } + imageName = flds[num]; + } + string path = templatePath; + path += imagePath + "/" + imageName + ".svg"; + return path; +} + bool cSVGTemplate::Exists(void) { - return FileExists(templatePath, imageName, "svg"); + return FileExists(filePath); } void cSVGTemplate::ReadTemplate(void) { @@ -464,7 +480,7 @@ bool cSVGTemplate::ParseTemplate(void) { } string cSVGTemplate::WriteImage(void) { - string tempPath = *cString::sprintf("/tmp/skindesigner/svg/%s/%s/", Setup.OSDSkin, Setup.OSDTheme); + string tempPath = *cString::sprintf("/tmp/skindesigner/svg/%s/%s/%s/", Setup.OSDSkin, Setup.OSDTheme, imagePath.c_str()); CreateFolder(tempPath); string fileName = tempPath + imageName + ".svg"; ofstream tmpimg; diff --git a/extensions/imageloader.h b/extensions/imageloader.h index 12bd8d2..bb81102 100644 --- a/extensions/imageloader.h +++ b/extensions/imageloader.h @@ -95,16 +95,18 @@ public: class cSVGTemplate { private: string imageName; + string imagePath; string templatePath; string filePath; string startTokenColor; string startTokenOpac; string endToken; vector svgTemplate; + string CreateImagePath(void); string GetColorName(string line, size_t tokenStart, size_t tokenEnd); void ReplaceTokens(string &line, size_t tokenStart, size_t tokenEnd, tColor color); public: - cSVGTemplate(string imageName, string templatePath); + cSVGTemplate(string imageName, string imagePath, string templatePath); virtual ~cSVGTemplate(void); bool Exists(void); void ReadTemplate(void); diff --git a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecast.xml b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecast.xml index 078353c..2b1aa38 100644 --- a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecast.xml +++ b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecast.xml @@ -105,7 +105,7 @@ - +