Skip to content
Permalink
Browse files

added: Support for <res width="1280" height="960" aspect="4:3" defaul…

…t="true" folder="960p" /> in skin addon.xml for arbitrary skin resolutions.
  • Loading branch information
Jonathan Marshall
Jonathan Marshall committed Feb 19, 2011
1 parent bdbb50c commit 194db82a1f73ad53772be66c0073f059fe8d34c2
Showing with 43 additions and 12 deletions.
  1. +43 −12 xbmc/addons/Skin.cpp
@@ -23,14 +23,16 @@
#include "AddonManager.h"
#include "filesystem/File.h"
#include "filesystem/SpecialProtocol.h"
#include "filesystem/Directory.h"
#include "guilib/Key.h"
#include "utils/URIUtils.h"
#include "settings/Settings.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "settings/GUISettings.h"

// fallback for new skin resolution code
#include "filesystem/Directory.h"

using namespace std;
using namespace XFILE;

@@ -49,10 +51,36 @@ CSkinInfo::CSkinInfo(const AddonProps &props, const RESOLUTION_INFO &resolution)
CSkinInfo::CSkinInfo(const cp_extension_t *ext)
: CAddon(ext)
{
CStdString defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultwideresolution");
if (defaultWide.IsEmpty())
defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultresolution");
TranslateResolution(defaultWide, m_defaultRes);
ELEMENTS elements;
if (CAddonMgr::Get().GetExtElements(ext->configuration, "res", elements))
{
for (ELEMENTS::iterator i = elements.begin(); i != elements.end(); ++i)
{
float width = (float)atof(CAddonMgr::Get().GetExtValue(*i, "@width"));
float height = (float)atof(CAddonMgr::Get().GetExtValue(*i, "@height"));
bool defRes = CAddonMgr::Get().GetExtValue(*i, "@default").Equals("true");
CStdString folder = CAddonMgr::Get().GetExtValue(*i, "@folder");
float aspect = 0;
CStdStringArray fracs;
StringUtils::SplitString(CAddonMgr::Get().GetExtValue(*i, "@aspect"), ":", fracs);
if (fracs.size() == 2)
aspect = (float)atof(fracs[0].c_str())/atof(fracs[1].c_str());
if (width > 0 && height > 0)
{
RESOLUTION_INFO res(width, height, aspect, folder);
if (defRes)
m_defaultRes = res;
m_resolutions.push_back(res);
}
}
}
else
{ // no resolutions specified -> backward compatibility
CStdString defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultwideresolution");
if (defaultWide.IsEmpty())
defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultresolution");
TranslateResolution(defaultWide, m_defaultRes);
}

CStdString str = CAddonMgr::Get().GetExtValue(ext->configuration, "@effectslowdown");
if (!str.IsEmpty())
@@ -74,13 +102,16 @@ CSkinInfo::~CSkinInfo()

void CSkinInfo::Start(const CStdString &strBaseDir)
{
CFileItemList items;
CDirectory::GetDirectory(Path(), items, "", false);
for (int i = 0; i < items.Size(); i++)
{
RESOLUTION_INFO res;
if (items[i]->m_bIsFolder && TranslateResolution(items[i]->GetLabel(), res))
m_resolutions.push_back(res);
if (!m_resolutions.size())
{ // try falling back to whatever resolutions exist in the directory
CFileItemList items;
CDirectory::GetDirectory(Path(), items, "", false);
for (int i = 0; i < items.Size(); i++)
{
RESOLUTION_INFO res;
if (items[i]->m_bIsFolder && TranslateResolution(items[i]->GetLabel(), res))
m_resolutions.push_back(res);
}
}
LoadIncludes();
}

0 comments on commit 194db82

Please sign in to comment.
You can’t perform that action at this time.