diff options
author | louis <louis.braun@gmx.de> | 2014-10-03 15:54:23 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2014-10-03 15:54:23 +0200 |
commit | 91a0681ab8b2752b5ebd7cfebdd1456708d6ed69 (patch) | |
tree | 24c0d8bb48829882bdec0ec7717cc0cba91551c6 /libcore | |
parent | 7766972eece16b450621d0e5c72f35733af5b238 (diff) | |
download | vdr-plugin-skindesigner-91a0681ab8b2752b5ebd7cfebdd1456708d6ed69.tar.gz vdr-plugin-skindesigner-91a0681ab8b2752b5ebd7cfebdd1456708d6ed69.tar.bz2 |
changed skin handling and added themes support for skins
Diffstat (limited to 'libcore')
-rw-r--r-- | libcore/helpers.c | 5 | ||||
-rw-r--r-- | libcore/helpers.h | 1 | ||||
-rw-r--r-- | libcore/imagecache.c | 34 | ||||
-rw-r--r-- | libcore/imagecache.h | 4 | ||||
-rw-r--r-- | libcore/imageloader.c | 8 |
5 files changed, 40 insertions, 12 deletions
diff --git a/libcore/helpers.c b/libcore/helpers.c index 81880a0..b4b507a 100644 --- a/libcore/helpers.c +++ b/libcore/helpers.c @@ -97,6 +97,11 @@ bool FileExists(const string &path, const string &name, const string &ext) { return (stat (fileName.str().c_str(), &buffer) == 0); } +bool FolderExists(const string &path) { + struct stat buffer; + return stat(path.c_str(), &buffer) == 0 && S_ISDIR(buffer.st_mode); +} + bool FirstFileInFolder(string &path, string &extension, string &fileName) { DIR *folder = NULL; struct dirent *file; diff --git a/libcore/helpers.h b/libcore/helpers.h index 60f3345..74ddf94 100644 --- a/libcore/helpers.h +++ b/libcore/helpers.h @@ -13,6 +13,7 @@ std::string CutText(string &text, int width, string fontName, int fontSize); std::string StrToLowerCase(string str); bool isNumber(const string& s); bool FileExists(const string &path, const string &name, const string &ext); +bool FolderExists(const string &path); bool FirstFileInFolder(string &path, string &extension, string &fileName); class splitstring : public std::string { diff --git a/libcore/imagecache.c b/libcore/imagecache.c index 7347c0a..c32c4e6 100644 --- a/libcore/imagecache.c +++ b/libcore/imagecache.c @@ -26,6 +26,21 @@ cImageCache::~cImageCache() { } } +void cImageCache::SetPathes(void) { + string logoPathSkin = *cString::sprintf("%s%s/themes/%s/logos/", *config.skinPath, Setup.OSDSkin, Setup.OSDTheme); + if (FolderExists(logoPathSkin)) { + logoPath = logoPathSkin; + } else { + logoPath = *config.logoPath; + } + iconPath = *cString::sprintf("%s%s/themes/%s/", *config.skinPath, Setup.OSDSkin, Setup.OSDTheme); + skinPartsPath = *cString::sprintf("%s%s/themes/%s/skinparts/", *config.skinPath, Setup.OSDSkin, Setup.OSDTheme); + + dsyslog("skindesigner: using channel logo path %s", logoPath.c_str()); + dsyslog("skindesigner: using icon path %s", iconPath.c_str()); + dsyslog("skindesigner: using skinparts path %s", skinPartsPath.c_str()); +} + void cImageCache::CacheLogo(int width, int height) { if (config.numLogosPerSizeInitial == 0) return; @@ -125,14 +140,13 @@ bool cImageCache::LogoExists(string channelID) { const cChannel *channel = Channels.GetByChannelID(chanID); if (!channel) return false; - string logoPath = *cString::sprintf("%s%s/logos/", *config.skinPath, Setup.OSDTheme); string logoLower = StrToLowerCase(channel->Name()); string logoExt = *config.logoExtension; - bool logoExists = FileExists(logoPath, logoLower, logoExt); + bool logoExists = FileExists(logoPath.c_str(), logoLower, logoExt); if (logoExists) { return true; } - logoExists = FileExists(logoPath, channelID, logoExt); + logoExists = FileExists(logoPath.c_str(), channelID, logoExt); if (logoExists) { return true; } @@ -265,8 +279,8 @@ bool cImageCache::LoadIcon(eImageType type, string name) { subdir = "menuicons"; else if (type == itIcon) subdir = "icons"; - cString iconPath = cString::sprintf("%s%s/graphics/%s/", *config.skinPath, Setup.OSDTheme, *subdir); - success = LoadImage(name, *iconPath, "png"); + cString subIconPath = cString::sprintf("%s%s/", iconPath.c_str(), *subdir); + success = LoadImage(name, *subIconPath, "png"); if (success) { return true; } @@ -276,21 +290,20 @@ bool cImageCache::LoadIcon(eImageType type, string name) { bool cImageCache::LoadLogo(const cChannel *channel) { if (!channel) return false; - cString logoPath = cString::sprintf("%s%s/logos/", *config.skinPath, Setup.OSDTheme); string channelID = StrToLowerCase(*(channel->GetChannelID().ToString())); string logoLower = StrToLowerCase(channel->Name()); bool success = false; - success = LoadImage(channelID.c_str(), *logoPath, *config.logoExtension); + success = LoadImage(channelID.c_str(), logoPath.c_str(), *config.logoExtension); if (success) return true; - success = LoadImage(logoLower.c_str(), *logoPath, *config.logoExtension); + success = LoadImage(logoLower.c_str(), logoPath.c_str(), *config.logoExtension); if (success) return true; return false; } bool cImageCache::LoadSeparatorLogo(string name) { - cString separatorPath = cString::sprintf("%s%s/logos/separatorlogos/", *config.skinPath, Setup.OSDTheme); + cString separatorPath = cString::sprintf("%sseparatorlogos/", logoPath.c_str()); string nameLower = StrToLowerCase(name.c_str()); bool success = false; success = LoadImage(nameLower.c_str(), *separatorPath, *config.logoExtension); @@ -301,8 +314,7 @@ bool cImageCache::LoadSeparatorLogo(string name) { bool cImageCache::LoadSkinpart(string name) { bool success = false; - cString iconPath = cString::sprintf("%s%s/graphics/skinparts/", *config.skinPath, Setup.OSDTheme); - success = LoadImage(name, *iconPath, "png"); + success = LoadImage(name, skinPartsPath.c_str(), "png"); if (success) { return true; } diff --git a/libcore/imagecache.h b/libcore/imagecache.h index 9e700bf..a0264d8 100644 --- a/libcore/imagecache.h +++ b/libcore/imagecache.h @@ -18,6 +18,7 @@ public: ~cImageCache(); void Lock(void) { mutex.Lock(); } void Unlock(void) { mutex.Unlock(); } + void SetPathes(void); //channel logos void CacheLogo(int width, int height); cImage *GetLogo(string channelID, int width, int height); @@ -41,6 +42,9 @@ private: static cMutex mutex; static string items[16]; cImage *tempStaticLogo; + string logoPath; + string iconPath; + string skinPartsPath; map<string, cImage*> iconCache; map<string, cImage*> channelLogoCache; map<string, cImage*> skinPartsCache; diff --git a/libcore/imageloader.c b/libcore/imageloader.c index 1b220a6..61e8076 100644 --- a/libcore/imageloader.c +++ b/libcore/imageloader.c @@ -27,7 +27,13 @@ bool cImageLoader::LoadImage(const char *path, int width, int height) { } void cImageLoader::DeterminateChannelLogoSize(int &width, int &height) { - cString logoPath = cString::sprintf("%s%s/logos/", *config.skinPath, Setup.OSDTheme); + cString logoPath; + cString logoPathSkin = cString::sprintf("%s%s/themes/%s/logos/", *config.skinPath, Setup.OSDSkin, Setup.OSDTheme); + if (FolderExists(*logoPathSkin)) { + logoPath = logoPathSkin; + } else { + logoPath = config.logoPath; + } cString logoExt = config.logoExtension; DIR *folder = NULL; struct dirent *file; |