From 8c2249e0119a4e4ad19d66b4201ffe943d6f457d Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Fri, 30 Sep 2011 01:30:56 -0700 Subject: [PATCH] Fixed: Thoroughly search an addon's fallback skin folder for the closest skin resolution. Before, if 1. 720p is the current resolution and skin.id is the current skin 2. addon.id/skins/skin.id/720p/script-window.xml doesn't exist 3. addon.id/skins/skin.id/ntsc/script-window.xml exists then #3 would be skipped and the addon would instead be loaded from the default skin folder (i.e. addon.id/skins/default/...). This commit fixes this behavior; XBMC will attempt to load the closest resolution from the folder of the current skin (if it exists) instead of skipping to the default. --- xbmc/interfaces/python/xbmcmodule/winxml.cpp | 19 ++++++++++++----- .../python/xbmcmodule/winxmldialog.cpp | 21 +++++++++++++------ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/xbmc/interfaces/python/xbmcmodule/winxml.cpp b/xbmc/interfaces/python/xbmcmodule/winxml.cpp index 37ce244ff67d3..7690686c45d6f 100644 --- a/xbmc/interfaces/python/xbmcmodule/winxml.cpp +++ b/xbmc/interfaces/python/xbmcmodule/winxml.cpp @@ -74,18 +74,27 @@ namespace PYXBMC if (!XFILE::CFile::Exists(strSkinPath)) { - // Check for the matching folder for the skin in the fallback skins folder + CStdString str("none"); + AddonProps props(str, ADDON_SKIN, "", ""); + CSkinInfo::TranslateResolution(resolution, res); + CStdString fallbackPath = URIUtils::AddFileToFolder(strFallbackPath, "resources"); fallbackPath = URIUtils::AddFileToFolder(fallbackPath, "skins"); CStdString basePath = URIUtils::AddFileToFolder(fallbackPath, g_SkinInfo->ID()); - strSkinPath = g_SkinInfo->GetSkinPath(strXMLname, &res, basePath); + + // Check for the matching folder for the skin in the fallback skins folder (if it exists) + if (XFILE::CFile::Exists(basePath)) + { + props.path = basePath; + CSkinInfo skinInfo(props, res); + skinInfo.Start(); + strSkinPath = skinInfo.GetSkinPath(strXMLname, &res); + } + if (!XFILE::CFile::Exists(strSkinPath)) { // Finally fallback to the DefaultSkin as it didn't exist in either the XBMC Skin folder or the fallback skin folder - CStdString str("none"); - AddonProps props(str, ADDON_SKIN, "", ""); props.path = URIUtils::AddFileToFolder(fallbackPath, strDefault); - CSkinInfo::TranslateResolution(resolution, res); CSkinInfo skinInfo(props, res); skinInfo.Start(); diff --git a/xbmc/interfaces/python/xbmcmodule/winxmldialog.cpp b/xbmc/interfaces/python/xbmcmodule/winxmldialog.cpp index da8719c28c81a..76aeb6b9a8d17 100644 --- a/xbmc/interfaces/python/xbmcmodule/winxmldialog.cpp +++ b/xbmc/interfaces/python/xbmcmodule/winxmldialog.cpp @@ -75,22 +75,31 @@ namespace PYXBMC if (!XFILE::CFile::Exists(strSkinPath)) { - // Check for the matching folder for the skin in the fallback skins folder + CStdString str("none"); + AddonProps props(str, ADDON_SKIN, "", ""); + CSkinInfo::TranslateResolution(resolution, res); + CStdString fallbackPath = URIUtils::AddFileToFolder(strFallbackPath, "resources"); fallbackPath = URIUtils::AddFileToFolder(fallbackPath, "skins"); CStdString basePath = URIUtils::AddFileToFolder(fallbackPath, g_SkinInfo->ID()); - strSkinPath = g_SkinInfo->GetSkinPath(strXMLname, &res, basePath); + + // Check for the matching folder for the skin in the fallback skins folder (if it exists) + if (XFILE::CFile::Exists(basePath)) + { + props.path = basePath; + CSkinInfo skinInfo(props, res); + skinInfo.Start(); + strSkinPath = skinInfo.GetSkinPath(strXMLname, &res); + } + if (!XFILE::CFile::Exists(strSkinPath)) { // Finally fallback to the DefaultSkin as it didn't exist in either the XBMC Skin folder or the fallback skin folder - CStdString str("none"); - AddonProps props(str, ADDON_SKIN, "", ""); props.path = URIUtils::AddFileToFolder(fallbackPath, strDefault); - CSkinInfo::TranslateResolution(resolution, res); CSkinInfo skinInfo(props, res); skinInfo.Start(); - strSkinPath = skinInfo.GetSkinPath(strXMLname, &res); + strSkinPath = skinInfo.GetSkinPath(strXMLname, &res); if (!XFILE::CFile::Exists(strSkinPath)) { PyErr_SetString(PyExc_TypeError, "XML File for Window is missing");