Skip to content

Commit

Permalink
allow defining multiple addon types in Skin.SetAddon and addon settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Sep 29, 2011
1 parent 78af5b9 commit 174ef75
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
19 changes: 15 additions & 4 deletions xbmc/addons/GUIDialogAddonSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,18 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
else if (strcmp(type, "addon") == 0)
{
const char *strType = setting->Attribute("addontype");
TYPE type = strType ? TranslateType(strType) : ADDON_UNKNOWN;
if (type != ADDON_UNKNOWN)
if (strType)
{
CStdStringArray addonTypes;
StringUtils::SplitString(strType, ",", addonTypes);
vector<ADDON::TYPE> types;
for (unsigned int i = 0 ; i < addonTypes.size() ; i++)
{
ADDON::TYPE type = TranslateType(addonTypes[i].Trim());
if (type != ADDON_UNKNOWN)
types.push_back(type);
}
if (types.size() > 0)
{
const char *strMultiselect = setting->Attribute("multiselect");
bool multiSelect = strMultiselect && strcmpi(strMultiselect, "true") == 0;
Expand All @@ -413,16 +423,17 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
// construct vector of addon IDs (IDs are comma seperated in single string)
CStdStringArray addonIDs;
StringUtils::SplitString(value, ",", addonIDs);
if (CGUIWindowAddonBrowser::SelectAddonID(type, addonIDs, false) == 1)
if (CGUIWindowAddonBrowser::SelectAddonID(types, addonIDs, false) == 1)
{
StringUtils::JoinString(addonIDs, ",", value);
((CGUIButtonControl*) control)->SetLabel2(GetAddonNames(value));
}
}
else // no need of string splitting/joining if we select only 1 addon
if (CGUIWindowAddonBrowser::SelectAddonID(type, value, false) == 1)
if (CGUIWindowAddonBrowser::SelectAddonID(types, value, false) == 1)
((CGUIButtonControl*) control)->SetLabel2(GetAddonNames(value));
}
}
}
m_buttonValues[id] = value;
break;
Expand Down
10 changes: 8 additions & 2 deletions xbmc/interfaces/Builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,9 +1109,15 @@ int CBuiltins::Execute(const CStdString& execString)
else if (execute.Equals("skin.setaddon") && params.size() > 1)
{
int string = g_settings.TranslateSkinString(params[0]);
ADDON::TYPE type = TranslateType(params[1]);
vector<ADDON::TYPE> types;
for (unsigned int i = 1 ; i < params.size() ; i++)
{
ADDON::TYPE type = TranslateType(params[i]);
if (type != ADDON_UNKNOWN)
types.push_back(type);
}
CStdString result;
if (CGUIWindowAddonBrowser::SelectAddonID(type, result, true) == 1)
if (types.size() > 0 && CGUIWindowAddonBrowser::SelectAddonID(types, result, true) == 1)
{
g_settings.SetSkinString(string, result);
g_settings.Save();
Expand Down

0 comments on commit 174ef75

Please sign in to comment.