Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed: finished moving skins to addon framework

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@29545 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
commit 553d21336e6f95a2f397d5c768ee390a18761cdc 1 parent 4d165b4
alcoheca authored
View
2  guilib/GUIColorManager.cpp
@@ -54,7 +54,7 @@ void CGUIColorManager::Load(const CStdString &colorFile)
// first load the default color map if it exists
CStdString path, basePath;
- CUtil::AddFileToFolder(g_SkinInfo->GetBaseDir(), "colors", basePath);
+ CUtil::AddFileToFolder(g_SkinInfo->Path(), "colors", basePath);
CUtil::AddFileToFolder(basePath, "defaults.xml", path);
if (xmlDoc.LoadFile(PTH_IC(path)))
View
56 xbmc/Application.cpp
@@ -1007,8 +1007,8 @@ bool CApplication::Initialize()
g_windowManager.Add(new CGUIWindowHome); // window id = 0
- CLog::Log(LOGNOTICE, "load default skin:[%s]", g_guiSettings.GetString("lookandfeel.skin").c_str());
- LoadSkin(g_guiSettings.GetString("lookandfeel.skin"));
+ if (!LoadSkin(g_guiSettings.GetString("lookandfeel.skin")))
+ LoadSkin(DEFAULT_SKIN);
g_windowManager.Add(new CGUIWindowPrograms); // window id = 1
g_windowManager.Add(new CGUIWindowPictures); // window id = 2
@@ -1484,8 +1484,27 @@ void CApplication::ReloadSkin()
}
}
-void CApplication::LoadSkin(const CStdString& strSkin)
+bool CApplication::LoadSkin(const CStdString& skinID)
{
+ AddonPtr addon;
+ if (CAddonMgr::Get()->GetAddon(skinID, addon))
+ {
+ LoadSkin(boost::dynamic_pointer_cast<ADDON::CSkinInfo>(addon));
+ return true;
+ }
+ return false;
+}
+
+void CApplication::LoadSkin(const SkinPtr& skin)
+{
+ if (!skin)
+ {
+ CLog::Log(LOGERROR, "failed to load requested skin, fallback to \"%s\" skin", DEFAULT_SKIN);
+ g_guiSettings.SetString("lookandfeel.skin", DEFAULT_SKIN);
+ LoadSkin(DEFAULT_SKIN);
+ return ;
+ }
+
bool bPreviousPlayingState=false;
bool bPreviousRenderingState=false;
if (g_application.m_pPlayer && g_application.IsPlayingVideo())
@@ -1507,9 +1526,6 @@ void CApplication::LoadSkin(const CStdString& strSkin)
// close the music and video overlays (they're re-opened automatically later)
CSingleLock lock(g_graphicsContext);
- CStdString strSkinPath = g_settings.GetSkinFolder(strSkin);
- CLog::Log(LOGINFO, " load skin from:%s", strSkinPath.c_str());
-
// save the current window details
int currentWindow = g_windowManager.GetActiveWindow();
vector<int> currentModelessWindows;
@@ -1518,12 +1534,14 @@ void CApplication::LoadSkin(const CStdString& strSkin)
CLog::Log(LOGINFO, " delete old skin...");
UnloadSkin();
- // Load in the skin.xml file if it exists
- g_SkinInfo->Load(strSkinPath);
+ CLog::Log(LOGINFO, " load skin from:%s", skin->Path().c_str());
+
+ g_SkinInfo = skin;
+ g_SkinInfo->Start();
CLog::Log(LOGINFO, " load fonts for skin...");
- g_graphicsContext.SetMediaDir(strSkinPath);
- g_directoryCache.ClearSubPaths(strSkinPath);
+ g_graphicsContext.SetMediaDir(skin->Path());
+ g_directoryCache.ClearSubPaths(skin->Path());
if (g_langInfo.ForceUnicodeFont() && !g_fontManager.IsFontSetUnicode(g_guiSettings.GetString("lookandfeel.font")))
{
CLog::Log(LOGINFO, " language needs a ttf font, loading first ttf font available");
@@ -1542,16 +1560,16 @@ void CApplication::LoadSkin(const CStdString& strSkin)
g_fontManager.LoadFonts(g_guiSettings.GetString("lookandfeel.font"));
// load in the skin strings
- CStdString skinPath, skinEnglishPath;
- CUtil::AddFileToFolder(strSkinPath, "language", skinPath);
- CUtil::AddFileToFolder(skinPath, g_guiSettings.GetString("locale.language"), skinPath);
- CUtil::AddFileToFolder(skinPath, "strings.xml", skinPath);
+ CStdString langPath, skinEnglishPath;
+ CUtil::AddFileToFolder(skin->Path(), "language", langPath);
+ CUtil::AddFileToFolder(langPath, g_guiSettings.GetString("locale.language"), langPath);
+ CUtil::AddFileToFolder(langPath, "strings.xml", langPath);
- CUtil::AddFileToFolder(strSkinPath, "language", skinEnglishPath);
+ CUtil::AddFileToFolder(skin->Path(), "language", skinEnglishPath);
CUtil::AddFileToFolder(skinEnglishPath, "English", skinEnglishPath);
CUtil::AddFileToFolder(skinEnglishPath, "strings.xml", skinEnglishPath);
- g_localizeStrings.LoadSkinStrings(skinPath, skinEnglishPath);
+ g_localizeStrings.LoadSkinStrings(langPath, skinEnglishPath);
int64_t start;
start = CurrentHostCounter();
@@ -1562,11 +1580,11 @@ void CApplication::LoadSkin(const CStdString& strSkin)
{
// failed to load home.xml
// fallback to default skin
- if ( strcmpi(strSkin.c_str(), DEFAULT_SKIN) != 0)
+ if ( strcmpi(skin->ID().c_str(), DEFAULT_SKIN) != 0)
{
- CLog::Log(LOGERROR, "failed to load home.xml for skin:%s, fallback to \"%s\" skin", strSkin.c_str(), DEFAULT_SKIN);
+ CLog::Log(LOGERROR, "failed to load home.xml for skin:%s, fallback to \"%s\" skin", skin->ID().c_str(), DEFAULT_SKIN);
g_guiSettings.SetString("lookandfeel.skin", DEFAULT_SKIN);
- LoadSkin(g_guiSettings.GetString("lookandfeel.skin"));
+ LoadSkin(DEFAULT_SKIN);
return ;
}
}
View
7 xbmc/Application.h
@@ -28,6 +28,10 @@
class CFileItem;
class CFileItemList;
+namespace ADDON
+{
+ class CSkinInfo;
+}
#include "GUIDialogSeekBar.h"
#include "GUIDialogKaiToast.h"
@@ -116,7 +120,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool IsCurrentThread() const;
void Stop();
void RestartApp();
- void LoadSkin(const CStdString& strSkin);
+ bool LoadSkin(const CStdString& skinID);
void UnloadSkin();
bool LoadUserWindows();
void ReloadSkin();
@@ -274,6 +278,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
protected:
void RenderScreenSaver();
+ void LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin);
friend class CApplicationMessenger;
// screensaver
View
2  xbmc/GUIWindowSettingsCategory.cpp
@@ -2667,7 +2667,7 @@ void CGUIWindowSettingsCategory::FillInSkinColors(CSetting *pSetting)
vector<CStdString> vecColors;
CStdString strPath;
- CUtil::AddFileToFolder(g_SkinInfo->GetBaseDir(),"colors",strPath);
+ CUtil::AddFileToFolder(g_SkinInfo->Path(),"colors",strPath);
CFileItemList items;
CDirectory::GetDirectory(PTH_IC(strPath), items, ".xml");
View
2  xbmc/Settings.h
@@ -22,7 +22,7 @@
#define PRE_SKIN_VERSION_9_10_COMPATIBILITY 1
-#define DEFAULT_SKIN "Confluence"
+#define DEFAULT_SKIN "org.xbmc.addons.confluence"
#define DEFAULT_FANART_HEIGHT 0
#ifdef MID
#define DEFAULT_VSYNC VSYNC_DISABLED
View
7 xbmc/addons/Addon.cpp
@@ -137,6 +137,12 @@ const CStdString TranslateType(const ADDON::TYPE &type, bool pretty/*=false*/)
return g_localizeStrings.Get(24009);
return "script";
}
+ case ADDON::ADDON_SKIN:
+ {
+ if (pretty)
+ return g_localizeStrings.Get(166);
+ return "skin";
+ }
case ADDON::ADDON_SCRIPT_LIBRARY:
{
return "script-library";
@@ -164,6 +170,7 @@ const ADDON::TYPE TranslateType(const CStdString &string)
else if (string.Equals("visualization-library")) return ADDON_VIZ_LIBRARY;
else if (string.Equals("plugin")) return ADDON_PLUGIN;
else if (string.Equals("script")) return ADDON_SCRIPT;
+ else if (string.Equals("skin")) return ADDON_SKIN;
else if (string.Equals("script-library")) return ADDON_SCRIPT_LIBRARY;
else if (string.Equals("addon-repository")) return ADDON_REPOSITORY;
else return ADDON_UNKNOWN;
View
5 xbmc/addons/AddonManager.cpp
@@ -45,6 +45,7 @@
#include "Scraper.h"
//#endif
#include "Repository.h"
+#include "Skin.h"
using namespace std;
@@ -129,6 +130,8 @@ bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabledOnly/*= true*/)
addons.insert(addons.end(), temp.begin(), temp.end());
if (CAddonMgr::Get()->GetAddons(ADDON_SCRIPT, temp, CONTENT_NONE, enabledOnly))
addons.insert(addons.end(), temp.begin(), temp.end());
+ if (CAddonMgr::Get()->GetAddons(ADDON_SKIN, temp, CONTENT_NONE, enabledOnly))
+ addons.insert(addons.end(), temp.begin(), temp.end());
if (CAddonMgr::Get()->GetAddons(ADDON_VIZ, temp, CONTENT_NONE, enabledOnly))
addons.insert(addons.end(), temp.begin(), temp.end());
return !addons.empty();
@@ -684,6 +687,8 @@ AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
return AddonPtr(new CAddon(addonProps));
case ADDON_SCRAPER:
return AddonPtr(new CScraper(addonProps));
+ case ADDON_SKIN:
+ return AddonPtr(new CSkinInfo(addonProps));
case ADDON_VIZ:
return AddonPtr(new CVisualisation(addonProps));
case ADDON_SCREENSAVER:
View
26 xbmc/addons/Skin.cpp
@@ -51,7 +51,6 @@ CSkinInfo::~CSkinInfo()
void CSkinInfo::SetDefaults()
{
- m_strBaseDir = "";
m_DefaultResolution = RES_PAL_4x3;
m_DefaultResolutionWide = RES_INVALID;
m_effectsSlowDown = 1.0f;
@@ -60,14 +59,14 @@ void CSkinInfo::SetDefaults()
m_onlyAnimateToHome = true;
}
-void CSkinInfo::Load(const CStdString& strSkinDir, bool loadIncludes)
+void CSkinInfo::Start(const CStdString& strSkinDir /* = "" */)
{
+ bool loadIncludes = true;
SetDefaults();
- m_strBaseDir = strSkinDir;
// Load from skin.xml
TiXmlDocument xmlDoc;
- CStdString strFile = m_strBaseDir + "\\skin.xml";
+ CStdString strFile = Path() + "\\skin.xml";
if (xmlDoc.LoadFile(strFile))
{ // ok - get the default skin folder out of it...
const TiXmlNode* root = xmlDoc.RootElement();
@@ -77,8 +76,8 @@ void CSkinInfo::Load(const CStdString& strSkinDir, bool loadIncludes)
if (!GetResolution(root, "defaultwideresolution", m_DefaultResolutionWide))
m_DefaultResolutionWide = m_DefaultResolution;
- CLog::Log(LOGINFO, "Default 4:3 resolution directory is %s", CUtil::AddFileToFolder(m_strBaseDir, GetDirFromRes(m_DefaultResolution)).c_str());
- CLog::Log(LOGINFO, "Default 16:9 resolution directory is %s", CUtil::AddFileToFolder(m_strBaseDir, GetDirFromRes(m_DefaultResolutionWide)).c_str());
+ CLog::Log(LOGINFO, "Default 4:3 resolution directory is %s", CUtil::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolution)).c_str());
+ CLog::Log(LOGINFO, "Default 16:9 resolution directory is %s", CUtil::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolutionWide)).c_str());
XMLUtils::GetDouble(root, "version", m_Version);
XMLUtils::GetFloat(root, "effectslowdown", m_effectsSlowDown);
@@ -97,7 +96,7 @@ void CSkinInfo::Load(const CStdString& strSkinDir, bool loadIncludes)
CStdString CSkinInfo::GetSkinPath(const CStdString& strFile, RESOLUTION *res, const CStdString& strBaseDir /* = "" */) const
{
- CStdString strPathToUse = m_strBaseDir;
+ CStdString strPathToUse = Path();
if (!strBaseDir.IsEmpty())
strPathToUse = strBaseDir;
@@ -197,11 +196,6 @@ CStdString CSkinInfo::GetDirFromRes(RESOLUTION res) const
return strRes;
}
-CStdString CSkinInfo::GetBaseDir() const
-{
- return m_strBaseDir;
-}
-
double CSkinInfo::GetMinVersion()
{
return SKIN_MIN_VERSION;
@@ -293,13 +287,13 @@ void CSkinInfo::GetSkinPaths(std::vector<CStdString> &paths) const
RESOLUTION resToUse = RES_INVALID;
GetSkinPath("Home.xml", &resToUse);
if (resToUse == RES_HDTV_1080i)
- paths.push_back(CUtil::AddFileToFolder(m_strBaseDir, GetDirFromRes(RES_HDTV_1080i)));
+ paths.push_back(CUtil::AddFileToFolder(Path(), GetDirFromRes(RES_HDTV_1080i)));
if (resToUse == RES_HDTV_720p)
- paths.push_back(CUtil::AddFileToFolder(m_strBaseDir, GetDirFromRes(RES_HDTV_720p)));
+ paths.push_back(CUtil::AddFileToFolder(Path(), GetDirFromRes(RES_HDTV_720p)));
if (resToUse != m_DefaultResolutionWide && IsWide(resToUse))
- paths.push_back(CUtil::AddFileToFolder(m_strBaseDir, GetDirFromRes(m_DefaultResolutionWide)));
+ paths.push_back(CUtil::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolutionWide)));
if (resToUse != m_DefaultResolution && (!IsWide(resToUse) || m_DefaultResolutionWide != m_DefaultResolution))
- paths.push_back(CUtil::AddFileToFolder(m_strBaseDir, GetDirFromRes(m_DefaultResolution)));
+ paths.push_back(CUtil::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolution)));
}
bool CSkinInfo::GetResolution(const TiXmlNode *root, const char *tag, RESOLUTION &res) const
View
7 xbmc/addons/Skin.h
@@ -49,10 +49,9 @@ class CSkinInfo : public CAddon
virtual ~CSkinInfo();
/*! \brief Load information regarding the skin from the given skin directory
- \param skinDir folder of the skin to load
- \param loadIncludes whether the includes from the skin should also be loaded (defaults to true)
+ \param skinDir folder of the skin to load (defaults to this skin's basedir)
*/
- void Load(const CStdString& skinDir, bool loadIncludes = true);
+ void Start(const CStdString& skinDir = "");
bool HasSkinFile(const CStdString &strFile) const;
@@ -65,7 +64,6 @@ class CSkinInfo : public CAddon
*/
CStdString GetSkinPath(const CStdString& file, RESOLUTION *res = NULL, const CStdString& baseDir = "") const;
- CStdString GetBaseDir() const;
double GetVersion() const { return m_Version; };
/*! \brief Return whether skin debugging is enabled
@@ -123,7 +121,6 @@ class CSkinInfo : public CAddon
RESOLUTION m_DefaultResolution; // default resolution for the skin in 4:3 modes
RESOLUTION m_DefaultResolutionWide; // default resolution for the skin in 16:9 modes
- CStdString m_strBaseDir;
double m_Version;
float m_effectsSlowDown;
View
4 xbmc/lib/libPython/xbmcmodule/winxml.cpp
@@ -100,7 +100,7 @@ namespace PYXBMC
CStdString basePath;
CUtil::AddFileToFolder(strFallbackPath, "resources", basePath);
CUtil::AddFileToFolder(basePath, "skins", basePath);
- CUtil::AddFileToFolder(basePath, CUtil::GetFileName(g_SkinInfo->GetBaseDir()), basePath);
+ CUtil::AddFileToFolder(basePath, CUtil::GetFileName(g_SkinInfo->Path()), basePath);
strSkinPath = g_SkinInfo->GetSkinPath(strXMLname, &res, basePath);
if (!XFILE::CFile::Exists(strSkinPath))
{
@@ -121,7 +121,7 @@ namespace PYXBMC
CUtil::AddFileToFolder(basePath, "skins", basePath);
CUtil::AddFileToFolder(basePath, strDefault, basePath);
- skinInfo.Load(basePath);
+ skinInfo.Start(basePath);
strSkinPath = skinInfo.GetSkinPath(strXMLname, &res, basePath);
if (!XFILE::CFile::Exists(strSkinPath))
View
4 xbmc/lib/libPython/xbmcmodule/winxmldialog.cpp
@@ -100,7 +100,7 @@ namespace PYXBMC
CStdString basePath;
CUtil::AddFileToFolder(strFallbackPath, "resources", basePath);
CUtil::AddFileToFolder(basePath, "skins", basePath);
- CUtil::AddFileToFolder(basePath, CUtil::GetFileName(g_SkinInfo->GetBaseDir()), basePath);
+ CUtil::AddFileToFolder(basePath, CUtil::GetFileName(g_SkinInfo->Path()), basePath);
strSkinPath = g_SkinInfo->GetSkinPath(strXMLname, &res, basePath);
if (!XFILE::CFile::Exists(strSkinPath))
{
@@ -121,7 +121,7 @@ namespace PYXBMC
CUtil::AddFileToFolder(basePath, "skins", basePath);
CUtil::AddFileToFolder(basePath, strDefault, basePath);
- skinInfo.Load(basePath);
+ skinInfo.Start(basePath);
strSkinPath = skinInfo.GetSkinPath(strXMLname, &res, basePath);
if (!XFILE::CFile::Exists(strSkinPath))
Please sign in to comment.
Something went wrong with that request. Please try again.