diff options
author | alcoheca <alcoheca@svn> | 2010-05-05 13:39:33 +0000 |
---|---|---|
committer | alcoheca <alcoheca@svn> | 2010-05-05 13:39:33 +0000 |
commit | 5ff028ac245d013eba963660cf4ffed2d3e0285a (patch) | |
tree | 99a2c71befbf070c0d1db3cae60b5d1eafc15684 | |
parent | 3c621898002bbacb30a2c22661afee7e88986ef3 (diff) |
added: skin support via cpluff
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@29814 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | addons/skin.confluence/addon.xml | 14 | ||||
-rw-r--r-- | addons/skin.pm3-hd/addon.xml | 14 | ||||
-rw-r--r-- | addons/xbmc.core/addon.xml | 6 | ||||
-rw-r--r-- | addons/xbmc.gui/addon.xml | 8 | ||||
-rw-r--r-- | addons/xbmc.gui/skin.xsd | 23 | ||||
-rw-r--r-- | xbmc/addons/Addon.cpp | 4 | ||||
-rw-r--r-- | xbmc/addons/AddonManager.cpp | 7 | ||||
-rw-r--r-- | xbmc/addons/Skin.cpp | 125 | ||||
-rw-r--r-- | xbmc/addons/Skin.h | 15 |
9 files changed, 126 insertions, 90 deletions
diff --git a/addons/skin.confluence/addon.xml b/addons/skin.confluence/addon.xml new file mode 100644 index 0000000000..ebd1091f65 --- /dev/null +++ b/addons/skin.confluence/addon.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<addon + id="skin.confluence" + version="1.1.0" + name="Confluence" + provider-name="Jezz_X, Team XBMC"> + <requires> + <import addon="xbmc.gui" version="2.11"/> + </requires> + <extension point="xbmc.gui.skin" + defaultresolution="720p" defaultresolutionwide="720p" + defaultthemename="textures.xpr" effectslowdown="0.75" + debugging="false"/> +</addon> diff --git a/addons/skin.pm3-hd/addon.xml b/addons/skin.pm3-hd/addon.xml new file mode 100644 index 0000000000..76592cc844 --- /dev/null +++ b/addons/skin.pm3-hd/addon.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<addon + id="skin.pm-hd" + version="1.1.0" + name="PM3.HD" + provider-name="Jezz_X, Team XBMC"> + <requires> + <import addon="xbmc.gui" version="2.11"/> + </requires> + <extension + point="xbmc.gui.skin" + defaultresolution="720p" defaultresolutionwide="720p" + defaultthemename="textures.xpr" effectslowdown="0.75"/> +</addon> diff --git a/addons/xbmc.core/addon.xml b/addons/xbmc.core/addon.xml new file mode 100644 index 0000000000..bc9f67d8f8 --- /dev/null +++ b/addons/xbmc.core/addon.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<addon id="xbmc.core" version="0.1" provider-name="Team XBMC"/> + <requires> + <c-pluff version="0.1"/> + </requires> +</addon> diff --git a/addons/xbmc.gui/addon.xml b/addons/xbmc.gui/addon.xml new file mode 100644 index 0000000000..a5001e90f8 --- /dev/null +++ b/addons/xbmc.gui/addon.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<addon id="xbmc.gui" version="2.11" provider-name="Team XBMC"/> + <backwards-compatibility abi="2.1"/> + <requires> + <import addon="xbmc.core" version="0.1"/> + </requires> + <extension-point id="skin" schema="skin.xsd"/> +</addon> diff --git a/addons/xbmc.gui/skin.xsd b/addons/xbmc.gui/skin.xsd new file mode 100644 index 0000000000..83ca37733c --- /dev/null +++ b/addons/xbmc.gui/skin.xsd @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd"> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="extension"> + <xs:complexType> + <xs:attribute name="point" type="xs:string" use="required"/> + <xs:attribute name="id" type="simpleIdentifier"/> + <xs:attribute name="name" type="xs:string"/> + + <xs:attribute name="defaultresolution" type="xs:string" use="required"/> + <xs:attribute name="defaultresolutionwide" type="xs:string" use="required"/> + <xs:attribute name="defaultthemename" type="xs:string" use="required"/> + <xs:attribute name="effectslowdown" type="xs:float"/> + <xs:attribute name="debugging" type="xs:boolean"/> + + </xs:complexType> + </xs:element> + <xs:simpleType name="simpleIdentifier"> + <xs:restriction base="xs:string"> + <xs:pattern value="[^.]+"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/xbmc/addons/Addon.cpp b/xbmc/addons/Addon.cpp index 56450d7d82..a584e913e4 100644 --- a/xbmc/addons/Addon.cpp +++ b/xbmc/addons/Addon.cpp @@ -141,7 +141,7 @@ const CStdString TranslateType(const ADDON::TYPE &type, bool pretty/*=false*/) { if (pretty) return g_localizeStrings.Get(166); - return "skin"; + return "xbmc.gui.skin"; } case ADDON::ADDON_SCRIPT_LIBRARY: { @@ -170,7 +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("xbmc.gui.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; diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index 82a3e0474b..e8647a40b9 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -77,6 +77,8 @@ AddonPtr AddonFactory(const cp_extension_t *props) return AddonPtr(new CVisualisation(props->plugin)); case ADDON_SCREENSAVER: return AddonPtr(new CScreenSaver(props->plugin)); + case ADDON_SKIN: + return AddonPtr(new CSkinInfo(props->plugin)); case ADDON_SCRAPER_LIBRARY: case ADDON_VIZ_LIBRARY: return AddonPtr(new CAddonLibrary(props->plugin)); @@ -187,7 +189,7 @@ bool CAddonMgr::Init() bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/) { - if (type == ADDON_SCREENSAVER) + if (type == ADDON_SCREENSAVER || type == ADDON_SKIN) { cp_status_t status; int num; @@ -233,7 +235,7 @@ bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYP { CSingleLock lock(m_critSection); addons.clear(); - if (type == ADDON_SCREENSAVER) + if (type == ADDON_SCREENSAVER || type == ADDON_SKIN) { cp_status_t status; int num; @@ -272,6 +274,7 @@ bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &typ CSingleLock lock(m_critSection); if (type != ADDON_UNKNOWN && type != ADDON_SCREENSAVER + && type != ADDON_SKIN && m_addons.find(type) == m_addons.end()) return false; diff --git a/xbmc/addons/Skin.cpp b/xbmc/addons/Skin.cpp index 91c40398b8..b647009b06 100644 --- a/xbmc/addons/Skin.cpp +++ b/xbmc/addons/Skin.cpp @@ -20,6 +20,7 @@ */ #include "Skin.h" +#include "AddonManager.h" #include "GUIWindowManager.h" #include "GUISettings.h" #include "FileSystem/File.h" @@ -40,78 +41,36 @@ boost::shared_ptr<ADDON::CSkinInfo> g_SkinInfo; namespace ADDON { -CSkinInfo::CSkinInfo(const ADDON::AddonProps &props) +CSkinInfo::CSkinInfo(cp_plugin_info_t *props) : CAddon(props) { - SetDefaults(); -} + GetDefaultResolution(props, "@defaultresolution", m_DefaultResolution, RES_PAL_4x3); + GetDefaultResolution(props, "@defaultresolutionwide", m_DefaultResolutionWide, RES_INVALID); + 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()); + + CStdString str = CAddonMgr::Get()->GetExtValue(props->extensions->configuration, "@effectslowdown"); + if (!str.IsEmpty()) + m_effectsSlowDown = (float)atof(str.c_str()); + else + m_effectsSlowDown = 1.f; -CSkinInfo::~CSkinInfo() -{} + str = CAddonMgr::Get()->GetExtValue(props->extensions->configuration, "@debugging"); + m_debugging = !strcmp(str.c_str(), "true"); -void CSkinInfo::SetDefaults() -{ - m_DefaultResolution = RES_PAL_4x3; - m_DefaultResolutionWide = RES_INVALID; - m_effectsSlowDown = 1.0f; - m_Version = 1.0; - m_debugging = false; m_onlyAnimateToHome = true; + LoadStartupWindows(props); + m_Version = 2.11; } +CSkinInfo::~CSkinInfo() +{} + void CSkinInfo::Start(const CStdString& strSkinDir /* = "" */) { - CStdString dir2(strSkinDir); - if (dir2.IsEmpty()) - dir2 = Path(); - SetDefaults(); - - // Load from skin.xml - TiXmlDocument xmlDoc; - CStdString strFile = CUtil::AddFileToFolder(dir2,"skin.xml"); - if (xmlDoc.LoadFile(strFile)) - { // ok - get the default skin folder out of it... - const TiXmlNode* root = xmlDoc.RootElement(); - if (root && root->ValueStr() == "skin") - { - GetResolution(root, "defaultresolution", m_DefaultResolution); - if (!GetResolution(root, "defaultwideresolution", m_DefaultResolutionWide)) - m_DefaultResolutionWide = m_DefaultResolution; - - 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); - XMLUtils::GetBoolean(root, "debugging", m_debugging); - - // now load the startupwindow information - LoadStartupWindows(root->FirstChildElement("startupwindows")); - } - else - CLog::Log(LOGERROR, "%s - %s doesnt contain <skin>", __FUNCTION__, strFile.c_str()); - } - // Load the skin includes LoadIncludes(); } -/*bool CSkinInfo::Check(const CStdString& strSkinDir) -{ - CSkinInfo info; - info.Load(strSkinDir, false); - if (info.GetVersion() < GetMinVersion()) - { - CLog::Log(LOGERROR, "%s(%s) version is to old (%f versus %f)", __FUNCTION__, strSkinDir.c_str(), info.GetVersion(), GetMinVersion()); - return false; - } - if (!info.HasSkinFile("Home.xml") || !info.HasSkinFile("Font.xml")) - { - CLog::Log(LOGERROR, "%s(%s) does not contain Home.xml or Font.xml", __FUNCTION__, strSkinDir.c_str()); - return false; - } - return true; -}*/ - CStdString CSkinInfo::GetSkinPath(const CStdString& strFile, RESOLUTION *res, const CStdString& strBaseDir /* = "" */) const { CStdString strPathToUse = Path(); @@ -261,11 +220,10 @@ int CSkinInfo::GetStartWindow() const return m_startupWindows[0].m_id; } -bool CSkinInfo::LoadStartupWindows(const TiXmlElement *startup) +bool CSkinInfo::LoadStartupWindows(cp_plugin_info_t *props) { m_startupWindows.clear(); - if (startup) - { // yay, run through and grab the startup windows + /*{ // yay, run through and grab the startup windows const TiXmlElement *window = startup->FirstChildElement("window"); while (window && window->FirstChild()) { @@ -275,7 +233,7 @@ bool CSkinInfo::LoadStartupWindows(const TiXmlElement *startup) m_startupWindows.push_back(CStartupWindow(id + WINDOW_HOME, name)); window = window->NextSiblingElement("window"); } - } + }*/ // ok, now see if we have any startup windows if (!m_startupWindows.size()) @@ -314,32 +272,41 @@ void CSkinInfo::GetSkinPaths(std::vector<CStdString> &paths) const paths.push_back(CUtil::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolution))); } -bool CSkinInfo::GetResolution(const TiXmlNode *root, const char *tag, RESOLUTION &res) const +void CSkinInfo::GetDefaultResolution(cp_plugin_info_t *props, const char *tag, RESOLUTION &res, const RESOLUTION &def) const { - CStdString strRes; - if (XMLUtils::GetString(root, tag, strRes)) + //FIXME! only respects one extension per addon + CStdString strRes(CAddonMgr::Get()->GetExtValue(props->extensions->configuration, tag)); + if (!strRes.empty()) { strRes.ToLower(); - if (strRes == "pal") + if (strRes == "pal") { res = RES_PAL_4x3; - else if (strRes == "pal16x9") + return; + } + else if (strRes == "pal16x9") { res = RES_PAL_16x9; - else if (strRes == "ntsc") + return; + } + else if (strRes == "ntsc") { res = RES_NTSC_4x3; - else if (strRes == "ntsc16x9") + return; + } + else if (strRes == "ntsc16x9") { res = RES_NTSC_16x9; - else if (strRes == "720p") + return; + } + else if (strRes == "720p") { res = RES_HDTV_720p; - else if (strRes == "1080i") + return; + } + else if (strRes == "1080i") { res = RES_HDTV_1080i; - else - { - CLog::Log(LOGERROR, "%s invalid resolution specified for <%s>, %s", __FUNCTION__, tag, strRes.c_str()); - return false; + return; } - return true; } - return false; + + CLog::Log(LOGERROR, "%s invalid resolution specified for <%s>, %s", __FUNCTION__, tag, strRes.c_str()); + res = def; } int CSkinInfo::GetFirstWindow() const diff --git a/xbmc/addons/Skin.h b/xbmc/addons/Skin.h index 40987c4a4e..23aa0e157f 100644 --- a/xbmc/addons/Skin.h +++ b/xbmc/addons/Skin.h @@ -45,7 +45,9 @@ public: CStdString m_name; }; - CSkinInfo(const ADDON::AddonProps &props); + //FIXME remove this, kept for current repo handling + CSkinInfo(const ADDON::AddonProps &props) : CAddon(props) {} + CSkinInfo(cp_plugin_info_t *props); virtual ~CSkinInfo(); /*! \brief Load information regarding the skin from the given skin directory @@ -106,17 +108,16 @@ protected: */ CStdString GetDirFromRes(RESOLUTION res) const; - /*! \brief grab a resolution tag from an XML node - \param node XML node to look for the given tag + /*! \brief grab a resolution tag from a skin's configuration data + \param props passed addoninfo structure to check for resolution \param tag name of the tag to look for \param res resolution to return - \return true if we find a valid XML node containing a valid resolution, false otherwise + \return true if we find a valid resolution, false otherwise */ - bool GetResolution(const TiXmlNode *node, const char *tag, RESOLUTION &res) const; + void GetDefaultResolution(cp_plugin_info_t *props, const char *tag, RESOLUTION &res, const RESOLUTION &def) const; - void SetDefaults(); void LoadIncludes(); - bool LoadStartupWindows(const TiXmlElement *startup); + bool LoadStartupWindows(cp_plugin_info_t *startup); bool IsWide(RESOLUTION res) const; RESOLUTION m_DefaultResolution; // default resolution for the skin in 4:3 modes |