Bug #106 » xbmc4xbox-addonsettings-patch.2.diff
guilib/GUIInfoTypes.cpp (working copy) | ||
---|---|---|
return work;
|
||
}
|
||
CStdString CGUIInfoLabel::ReplaceAddonStrings(const CStdString &label)
|
||
{
|
||
CStdString work(label);
|
||
//FIXME why not use RE here?
|
||
// Replace all $ADDON[id number] with the real string
|
||
int pos1 = work.Find("$ADDON[");
|
||
while (pos1 >= 0)
|
||
{
|
||
int pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 7);
|
||
if (pos2 > pos1)
|
||
{
|
||
CStdString left = work.Left(pos1);
|
||
CStdString right = work.Mid(pos2 + 1);
|
||
int length = work.Find(" ", pos1 + 7) - (pos1 + 7);
|
||
CStdString id = work.substr(pos1+7, length);
|
||
int stringid = atoi(work.substr(pos1+7+id.length()+1, 5).c_str());
|
||
CStdString replace = g_localizeStringsTemp.Get(stringid);
|
||
work = left + replace + right;
|
||
}
|
||
else
|
||
{
|
||
CLog::Log(LOGERROR, "Error parsing label - missing ']'");
|
||
return "";
|
||
}
|
||
pos1 = work.Find("$ADDON[", pos1);
|
||
}
|
||
return work;
|
||
}
|
||
void CGUIInfoLabel::Parse(const CStdString &label)
|
||
{
|
||
m_info.clear();
|
||
// Step 1: Replace all $LOCALIZE[number] with the real string
|
||
CStdString work = ReplaceLocalize(label);
|
||
// Step 2: Find all $INFO[info,prefix,postfix] blocks
|
||
// Step 2: Replace all $ADDON[id number] with the real string
|
||
work = ReplaceAddonStrings(work);
|
||
// Step 3: Find all $INFO[info,prefix,postfix] blocks
|
||
int pos1 = work.Find("$INFO[");
|
||
while (pos1 >= 0)
|
||
{
|
guilib/GUIInfoTypes.h (working copy) | ||
---|---|---|
\return text with any localized strings filled in.
|
||
*/
|
||
static CStdString ReplaceLocalize(const CStdString &label);
|
||
static CStdString ReplaceAddonStrings(const CStdString &label);
|
||
private:
|
||
void Parse(const CStdString &label);
|
xbmc/GUIDialogPluginSettings.cpp (working copy) | ||
---|---|---|
m_bConfirmed = true;
|
||
SaveSettings();
|
||
}
|
||
if (iControl == ID_BUTTON_OK && !m_closeAction.IsEmpty())
|
||
{
|
||
g_applicationMessenger.ExecBuiltIn(m_closeAction);
|
||
}
|
||
Close();
|
||
return true;
|
||
}
|
||
... | ... | |
if (focusedControl >= CONTROL_START_SECTION && focusedControl < (int)(CONTROL_START_SECTION + m_totalSections) &&
|
||
focusedControl - CONTROL_START_SECTION != (int)m_currentSection)
|
||
{ // changing section
|
||
UpdateFromControls();
|
||
m_currentSection = focusedControl - CONTROL_START_SECTION;
|
||
CreateControls();
|
||
}
|
||
... | ... | |
void CGUIDialogPluginSettings::OnInitWindow()
|
||
{
|
||
m_closeAction = "";
|
||
m_currentSection = 0;
|
||
m_totalSections = 1;
|
||
CreateSections();
|
||
... | ... | |
bool bCloseDialog = false;
|
||
const TiXmlElement *setting = GetFirstSetting();
|
||
while (setting)
|
||
{
|
||
if (controlId == iControl)
|
||
{
|
||
const char *id = setting->Attribute("id");
|
||
const char *type = setting->Attribute("type");
|
||
CStdString value = m_settings[id];
|
||
const CGUIControl* control = GetControl(controlId);
|
||
if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON)
|
||
{
|
||
const char *id = setting->Attribute("id");
|
||
const char *type = setting->Attribute("type");
|
||
const char *option = setting->Attribute("option");
|
||
const char *source = setting->Attribute("source");
|
||
CStdString value = m_buttonValues[id];
|
||
CStdString label = GetString(setting->Attribute("label"));
|
||
if (strcmp(type, "text") == 0)
|
||
... | ... | |
}
|
||
else if (strcmpi(type, "action") == 0)
|
||
{
|
||
CStdString action = setting->Attribute("action");
|
||
if (!action.IsEmpty())
|
||
if (setting->Attribute("action"))
|
||
{
|
||
CStdString url = m_url.Get();
|
||
CUtil::RemoveSlashAtEnd(url);
|
||
// replace $CWD with the url of plugin/script
|
||
action.Replace("$CWD", url);
|
||
action.Replace("$ID", url);
|
||
action.Replace("/", "\\");
|
||
CStdString action = NormalizePath(setting->Attribute("action"));
|
||
if (option)
|
||
bCloseDialog = (strcmpi(option, "close") == 0);
|
||
g_applicationMessenger.ExecBuiltIn(action);
|
||
... | ... | |
((CGUIButtonControl*) control)->SetLabel2(value);
|
||
}
|
||
}
|
||
m_buttonValues[id] = value;
|
||
break;
|
||
}
|
||
}
|
||
setting = setting->NextSiblingElement("setting");
|
||
controlId++;
|
||
}
|
||
EnableControls();
|
||
return bCloseDialog;
|
||
}
|
||
void CGUIDialogPluginSettings::UpdateFromControls()
|
||
{
|
||
int controlID = CONTROL_START_SETTING;
|
||
const TiXmlElement *setting = GetFirstSetting();
|
||
while (setting)
|
||
{
|
||
CStdString id = setting->Attribute("id");
|
||
const char *type = setting->Attribute("type");
|
||
const CGUIControl* control = GetControl(controlID++);
|
||
if (control)
|
||
{
|
||
CStdString value;
|
||
switch (control->GetControlType())
|
||
else if (control->GetControlType() == CGUIControl::GUICONTROL_RADIO)
|
||
{
|
||
case CGUIControl::GUICONTROL_BUTTON:
|
||
value = m_buttonValues[id];
|
||
break;
|
||
case CGUIControl::GUICONTROL_RADIO:
|
||
value = ((CGUIRadioButtonControl*) control)->IsSelected() ? "true" : "false";
|
||
break;
|
||
case CGUIControl::GUICONTROL_SPINEX:
|
||
if (strcmpi(type, "fileenum") == 0 || strcmpi(type, "labelenum") == 0)
|
||
value = ((CGUISpinControlEx*) control)->GetLabel();
|
||
else
|
||
value.Format("%i", ((CGUISpinControlEx*) control)->GetValue());
|
||
break;
|
||
case CGUIControl::GUICONTROL_SETTINGS_SLIDER:
|
||
value.Format("%f", ((CGUISettingsSliderControl *)control)->GetFloatValue());
|
||
break;
|
||
default:
|
||
break;
|
||
value = ((CGUIRadioButtonControl*) control)->IsSelected() ? "true" : "false";
|
||
}
|
||
else if (control->GetControlType() == CGUIControl::GUICONTROL_SPINEX)
|
||
{
|
||
if (strcmpi(type, "fileenum") == 0 || strcmpi(type, "labelenum") == 0)
|
||
value = ((CGUISpinControlEx*) control)->GetLabel();
|
||
else
|
||
value.Format("%i", ((CGUISpinControlEx*) control)->GetValue());
|
||
}
|
||
else if (control->GetControlType() == CGUIControl::GUICONTROL_SETTINGS_SLIDER)
|
||
{
|
||
SetSliderTextValue(control, setting->Attribute("format"));
|
||
value.Format("%f", ((CGUISettingsSliderControl *)control)->GetFloatValue());
|
||
}
|
||
m_settings[id] = value;
|
||
SetEnabledProperty(id);
|
||
break;
|
||
}
|
||
setting = setting->NextSiblingElement("setting");
|
||
controlId++;
|
||
}
|
||
return bCloseDialog;
|
||
}
|
||
void CGUIDialogPluginSettings::SaveSettings(void)
|
||
{
|
||
UpdateFromControls();
|
||
for (map<CStdString, CStdString>::iterator i = m_settings.begin(); i != m_settings.end(); ++i)
|
||
m_addon.Set(i->first, i->second);
|
||
... | ... | |
group->ClearAll();
|
||
}
|
||
m_settings.clear();
|
||
m_buttonValues.clear();
|
||
}
|
||
void CGUIDialogPluginSettings::FreeControls()
|
||
... | ... | |
// clear the category group
|
||
FreeSections();
|
||
const TiXmlElement *settings = m_addon.GetPluginRoot();
|
||
// grab any onclose action
|
||
if (settings->Attribute("onclose"))
|
||
m_closeAction = NormalizePath(settings->Attribute("onclose"));
|
||
// grab our categories
|
||
const TiXmlElement *category = m_addon.GetPluginRoot()->FirstChildElement("category");
|
||
const TiXmlElement *category = settings->FirstChildElement("category");
|
||
if (!category) // add a default one...
|
||
category = m_addon.GetPluginRoot();
|
||
... | ... | |
{
|
||
const char *id = setting->Attribute("id");
|
||
if (id)
|
||
{
|
||
m_settings[id] = m_addon.Get(id);
|
||
SetEnabledProperty(id);
|
||
}
|
||
setting = setting->NextSiblingElement("setting");
|
||
}
|
||
category = category->NextSiblingElement("category");
|
||
... | ... | |
CGUIControl* pControl = NULL;
|
||
int controlId = CONTROL_START_SETTING;
|
||
const TiXmlElement *setting = GetFirstSetting();
|
||
while (setting)
|
||
{
|
||
const char *type = setting->Attribute("type");
|
||
... | ... | |
if (type)
|
||
{
|
||
CStdString value;
|
||
if (id)
|
||
value = m_settings[id];
|
||
if (strcmpi(type, "text") == 0 || strcmpi(type, "ipaddress") == 0 ||
|
||
strcmpi(type, "number") == 0 ||strcmpi(type, "video") == 0 ||
|
||
strcmpi(type, "audio") == 0 || strcmpi(type, "image") == 0 ||
|
||
... | ... | |
((CGUIButtonControl *)pControl)->SetLabel(label);
|
||
if (id)
|
||
{
|
||
CStdString tmpS = m_settings[id];
|
||
CStdString value = m_settings[id];
|
||
m_buttonValues[id] = value;
|
||
// get any option to test for hidden
|
||
const char *option = setting->Attribute("option");
|
||
if (option && (strstr(option, "urlencoded")))
|
||
... | ... | |
else
|
||
((CGUIButtonControl *)pControl)->SetLabel2(value);
|
||
}
|
||
else
|
||
else if (setting->Attribute("default"))
|
||
((CGUIButtonControl *)pControl)->SetLabel2(GetString(setting->Attribute("default")));
|
||
}
|
||
else if (strcmpi(type, "bool") == 0)
|
||
... | ... | |
{
|
||
for (unsigned int i = 0; i < 24; i++)
|
||
{
|
||
CDateTime time(0, 0, 0, i, 0, 0);
|
||
CDateTime time(2000, 1, 1, i, 0, 0);
|
||
valuesVec.push_back(g_infoManager.LocalizeTime(time, TIME_FORMAT_HH_MM_XX));
|
||
}
|
||
}
|
||
... | ... | |
((CGUISettingsSliderControl *)pControl)->SetFloatRange(fMin, fMax);
|
||
((CGUISettingsSliderControl *)pControl)->SetFloatInterval(fInc);
|
||
((CGUISettingsSliderControl *)pControl)->SetFloatValue((float)atof(m_settings[id]));
|
||
SetSliderTextValue(pControl, setting->Attribute("format"));
|
||
}
|
||
else if (strcmpi(type, "lsep") == 0)
|
||
{
|
||
... | ... | |
{
|
||
pControl->SetWidth(group->GetWidth());
|
||
pControl->SetVisible(true);
|
||
if (setting->Attribute("visible"))
|
||
pControl->SetVisibleCondition(g_infoManager.TranslateString(setting->Attribute("visible")), false);
|
||
if (setting->Attribute("enable"))
|
||
pControl->SetEnableCondition(g_infoManager.TranslateString(setting->Attribute("enable")));
|
||
pControl->SetID(controlId);
|
||
pControl->AllocResources();
|
||
group->AddControl(pControl);
|
||
... | ... | |
setting = setting->NextSiblingElement("setting");
|
||
controlId++;
|
||
}
|
||
EnableControls();
|
||
}
|
||
vector<CStdString> CGUIDialogPluginSettings::GetFileEnumValues(const CStdString &path, const CStdString &mask, const CStdString &options) const
|
||
{
|
||
// Create our base path, used for type "fileenum" settings
|
||
// replace $PROFILE with the profile path of the plugin/script
|
||
CStdString fullPath = path;
|
||
CStdString url = m_url.Get();
|
||
url.Replace("plugin://", "special://home/plugins/");
|
||
if (fullPath.Find("$PROFILE") >= 0)
|
||
CStdString fullPath;
|
||
// replace $CWD with the path and $PROFILE with the profile path of the addon
|
||
if (path.Find("$PROFILE") >= 0 || path.Find("$CWD") >= 0)
|
||
fullPath = NormalizePath(path);
|
||
else
|
||
{
|
||
fullPath.Replace("$PROFILE", m_profile);
|
||
CStdString url = m_url.Get();
|
||
// replace plugin:// with the plugins root path
|
||
url.Replace("plugin://", "special://home/plugins/");
|
||
fullPath = CUtil::ValidatePath(CUtil::AddFileToFolder(url, path));
|
||
}
|
||
else
|
||
fullPath = CUtil::AddFileToFolder(url, path);
|
||
bool hideExtensions = (options.CompareNoCase("hideext") == 0);
|
||
// fetch directory
|
||
... | ... | |
return values;
|
||
}
|
||
// Go over all the settings and set their enabled condition according to the values of the enabled attribute
|
||
void CGUIDialogPluginSettings::EnableControls()
|
||
void CGUIDialogPluginSettings::SetEnabledProperty(const CStdString &id)
|
||
{
|
||
int controlId = CONTROL_START_SETTING;
|
||
const TiXmlElement *setting = GetFirstSetting();
|
||
while (setting)
|
||
{
|
||
const CGUIControl* control = GetControl(controlId);
|
||
if (control)
|
||
{
|
||
// set enable status
|
||
if (setting->Attribute("enable"))
|
||
((CGUIControl*) control)->SetEnabled(GetCondition(setting->Attribute("enable"), controlId));
|
||
else
|
||
((CGUIControl*) control)->SetEnabled(true);
|
||
// set visible status
|
||
if (setting->Attribute("visible"))
|
||
((CGUIControl*) control)->SetVisible(GetCondition(setting->Attribute("visible"), controlId));
|
||
else
|
||
((CGUIControl*) control)->SetVisible(true);
|
||
}
|
||
setting = setting->NextSiblingElement("setting");
|
||
controlId++;
|
||
}
|
||
SetProperty(id, m_settings[id]);
|
||
}
|
||
bool CGUIDialogPluginSettings::GetCondition(const CStdString &condition, const int controlId)
|
||
{
|
||
if (condition.IsEmpty()) return true;
|
||
bool bCondition = true;
|
||
bool bCompare = true;
|
||
vector<CStdString> conditionVec;
|
||
if (condition.Find("+") >= 0)
|
||
CUtil::Tokenize(condition, conditionVec, "+");
|
||
else
|
||
{
|
||
bCondition = false;
|
||
bCompare = false;
|
||
CUtil::Tokenize(condition, conditionVec, "|");
|
||
}
|
||
for (unsigned int i = 0; i < conditionVec.size(); i++)
|
||
{
|
||
vector<CStdString> condVec;
|
||
if (!TranslateSingleString(conditionVec[i], condVec)) continue;
|
||
const CGUIControl* control2 = GetControl(controlId + atoi(condVec[1]));
|
||
CStdString value;
|
||
switch (control2->GetControlType())
|
||
{
|
||
case CGUIControl::GUICONTROL_BUTTON:
|
||
value = ((CGUIButtonControl*) control2)->GetLabel2();
|
||
break;
|
||
case CGUIControl::GUICONTROL_RADIO:
|
||
value = ((CGUIRadioButtonControl*) control2)->IsSelected() ? "true" : "false";
|
||
break;
|
||
case CGUIControl::GUICONTROL_SPINEX:
|
||
if (((CGUISpinControlEx*) control2)->GetFloatValue() > 0.0f)
|
||
value = ((CGUISpinControlEx*) control2)->GetLabel();
|
||
else
|
||
value.Format("%i", ((CGUISpinControlEx*) control2)->GetValue());
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
if (condVec[0].Equals("eq"))
|
||
{
|
||
if (bCompare)
|
||
bCondition &= value.Equals(condVec[2]);
|
||
else
|
||
bCondition |= value.Equals(condVec[2]);
|
||
}
|
||
else if (condVec[0].Equals("!eq"))
|
||
{
|
||
if (bCompare)
|
||
bCondition &= !value.Equals(condVec[2]);
|
||
else
|
||
bCondition |= !value.Equals(condVec[2]);
|
||
}
|
||
else if (condVec[0].Equals("gt"))
|
||
{
|
||
if (bCompare)
|
||
bCondition &= (atoi(value) > atoi(condVec[2]));
|
||
else
|
||
bCondition |= (atoi(value) > atoi(condVec[2]));
|
||
}
|
||
else if (condVec[0].Equals("lt"))
|
||
{
|
||
if (bCompare)
|
||
bCondition &= (atoi(value) < atoi(condVec[2]));
|
||
else
|
||
bCondition |= (atoi(value) < atoi(condVec[2]));
|
||
}
|
||
}
|
||
return bCondition;
|
||
}
|
||
bool CGUIDialogPluginSettings::TranslateSingleString(const CStdString &strCondition, vector<CStdString> &condVec)
|
||
{
|
||
CStdString strTest = strCondition;
|
||
strTest.ToLower();
|
||
strTest.TrimLeft(" ");
|
||
strTest.TrimRight(" ");
|
||
int pos1 = strTest.Find("(");
|
||
int pos2 = strTest.Find(",");
|
||
int pos3 = strTest.Find(")");
|
||
if (pos1 >= 0 && pos2 > pos1 && pos3 > pos2)
|
||
{
|
||
condVec.push_back(strTest.Left(pos1));
|
||
condVec.push_back(strTest.Mid(pos1 + 1, pos2 - pos1 - 1));
|
||
condVec.push_back(strTest.Mid(pos2 + 1, pos3 - pos2 - 1));
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
CStdString CGUIDialogPluginSettings::GetString(const char *value, bool subSetting) const
|
||
{
|
||
if (!value)
|
||
return "";
|
||
// Replace all $ADDON[id number] with the real string
|
||
CStdString label = ReplaceAddonStrings(value);
|
||
int id = atoi(label);
|
||
int id = atoi(value);
|
||
CStdString prefix(subSetting ? "- " : "");
|
||
if (id > 0)
|
||
return prefix + g_localizeStringsTemp.Get(id);
|
||
return prefix + label;
|
||
// localize values
|
||
CStdString strValue = CGUIInfoLabel::ReplaceLocalize(value);
|
||
strValue = CGUIInfoLabel::ReplaceAddonStrings(strValue);
|
||
return prefix + strValue;
|
||
}
|
||
CStdString CGUIDialogPluginSettings::ReplaceAddonStrings(const CStdString &label)
|
||
void CGUIDialogPluginSettings::SetSliderTextValue(const CGUIControl *control, const char *format)
|
||
{
|
||
CStdString work(label);
|
||
//FIXME why not use RE here?
|
||
// Replace all $ADDON[id number] with the real string
|
||
int pos1 = work.Find("$ADDON[");
|
||
while (pos1 >= 0)
|
||
{
|
||
int pos2 = StringUtils::FindEndBracket(work, '[', ']', pos1 + 7);
|
||
if (pos2 > pos1)
|
||
{
|
||
CStdString left = work.Left(pos1);
|
||
CStdString right = work.Mid(pos2 + 1);
|
||
int length = work.Find(" ", pos1 + 7) - (pos1 + 7);
|
||
CStdString id = work.substr(pos1+7, length);
|
||
int stringid = atoi(work.substr(pos1+7+id.length()+1, 5).c_str());
|
||
CStdString replace = g_localizeStringsTemp.Get(stringid);
|
||
work = left + replace + right;
|
||
}
|
||
else
|
||
{
|
||
CLog::Log(LOGERROR, "Error parsing label - missing ']'");
|
||
return "";
|
||
}
|
||
pos1 = work.Find("$ADDON[", pos1);
|
||
}
|
||
return work;
|
||
if (format)
|
||
{
|
||
CStdString strValue;
|
||
strValue.Format(GetString(format), ((CGUISettingsSliderControl *)control)->GetFloatValue());
|
||
((CGUISettingsSliderControl *)control)->SetTextValue(strValue);
|
||
}
|
||
}
|
||
CStdString CGUIDialogPluginSettings::NormalizePath(const char *value) const
|
||
{
|
||
CStdString normalPath = value;
|
||
CStdString path = m_url.Get();
|
||
// we need to change plugin:// protocol if we are using runscript
|
||
if (m_url.GetProtocol().Equals("plugin") && normalPath.Left(10).Equals("runscript("))
|
||
path.Replace("plugin://", "Q:\\plugins\\");
|
||
// replace $CWD with the addon's path
|
||
normalPath.Replace("$CWD", path);
|
||
// replace $PROFILE with the profile path of the addon
|
||
normalPath.Replace("$PROFILE", m_profile);
|
||
// replace $ID with the addon's path or path to default.py
|
||
if (!m_url.GetProtocol().Equals("plugin") || (m_url.GetProtocol().Equals("plugin") && normalPath.Left(10).Equals("runscript(")))
|
||
path = CUtil::AddFileToFolder(path, "default.py");
|
||
normalPath.Replace("$ID", path);
|
||
// validatePath will not work on action commands, so replace / here
|
||
normalPath.Replace("/", "\\");
|
||
return CUtil::ValidatePath(normalPath, true);
|
||
}
|
||
// Go over all the settings and set their default values
|
||
void CGUIDialogPluginSettings::SetDefaults()
|
||
{
|
||
... | ... | |
m_settings[id] = "0";
|
||
else if (0 != strcmpi(type, "action"))
|
||
m_settings[id] = "";
|
||
SetEnabledProperty(id);
|
||
}
|
||
setting = setting->NextSiblingElement("setting");
|
||
}
|
xbmc/GUIDialogPluginSettings.h (working copy) | ||
---|---|---|
#ifndef GUIDIALOG_PLUGIN_SETTINGS_
|
||
#define GUIDIALOG_PLUGIN_SETTINGS_
|
||
/*
|
||
* Copyright (C) 2005-2008 Team XBMC
|
||
* http://www.xbmc.org
|
||
*
|
||
* This Program is free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2, or (at your option)
|
||
* any later version.
|
||
*
|
||
* This Program is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU General Public License
|
||
* along with XBMC; see the file COPYING. If not, write to
|
||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
* http://www.gnu.org/copyleft/gpl.html
|
||
*
|
||
*/
|
||
/*
|
||
* Copyright (C) 2005-2008 Team XBMC
|
||
* http://www.xbmc.org
|
||
*
|
||
* This Program is free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2, or (at your option)
|
||
* any later version.
|
||
*
|
||
* This Program is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU General Public License
|
||
* along with XBMC; see the file COPYING. If not, write to
|
||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
* http://www.gnu.org/copyleft/gpl.html
|
||
*
|
||
*/
|
||
#include "GUIDialogBoxBase.h"
|
||
#include "PluginSettings.h"
|
||
... | ... | |
static bool ShowAndGetInput(SScraperInfo& info, bool saveToDisk = true);
|
||
static bool ShowAndGetInput(CStdString& path, bool saveToDisk = true);
|
||
virtual void Render();
|
||
static CStdString ReplaceAddonStrings(const CStdString &label);
|
||
protected:
|
||
virtual void OnInitWindow();
|
||
... | ... | |
void FreeSections();
|
||
void CreateControls();
|
||
void FreeControls();
|
||
void UpdateFromControls();
|
||
void EnableControls();
|
||
void SetDefaults();
|
||
bool GetCondition(const CStdString &condition, const int controlId);
|
||
void SetEnabledProperty(const CStdString &id);
|
||
void SaveSettings(void);
|
||
bool ShowVirtualKeyboard(int iControl);
|
||
bool TranslateSingleString(const CStdString &strCondition, std::vector<CStdString> &enableVec);
|
||
const TiXmlElement *GetFirstSetting();
|
||
CBasicSettings m_addon;
|
||
CStdString m_strHeading;
|
||
CStdString m_closeAction;
|
||
CStdString m_profile;
|
||
std::map<CStdString,CStdString> m_buttonValues;
|
||
bool m_changed;
|
||
bool m_saveToDisk; // whether the addon settings should be saved to disk or just stored locally in the addon
|
||
unsigned int m_currentSection;
|
||
unsigned int m_totalSections;
|
||
CStdString NormalizePath(const char *value) const;
|
||
void SetSliderTextValue(const CGUIControl *control, const char *format);
|
||
std::map<CStdString,CStdString> m_settings; // local storage of values
|
||
static CURL m_url;
|
||
};
|
||
#endif
|
||
xbmc/utils/GUIInfoManager.cpp (working copy) | ||
---|---|---|
CStdString str = strTest.Mid(8, strTest.GetLength() - 9);
|
||
return AddMultiInfo(GUIInfo(bNegate ? -STRING_IS_EMPTY : STRING_IS_EMPTY, TranslateSingleString(str)));
|
||
}
|
||
else if (strTest.Left(7).Equals("istrue("))
|
||
{
|
||
CStdString str = strTest.Mid(7, strTest.GetLength() - 8);
|
||
return AddMultiInfo(GUIInfo(bNegate ? -VALUE_IS_TRUE : VALUE_IS_TRUE, TranslateSingleString(str)));
|
||
}
|
||
else if (strTest.Left(14).Equals("addon.setting("))
|
||
{
|
||
CStdString str = strTest.Mid(14, strTest.GetLength() - 15);
|
||
return AddMultiInfo(GUIInfo(WINDOW_PROPERTY, WINDOW_DIALOG_PLUGIN_SETTINGS, ConditionalStringParameter(str)));
|
||
}
|
||
else if (strTest.Left(14).Equals("stringcompare("))
|
||
{
|
||
int pos = strTest.Find(",");
|
||
... | ... | |
if (info2 > 0)
|
||
return AddMultiInfo(GUIInfo(bNegate ? -STRING_COMPARE: STRING_COMPARE, info, -info2));
|
||
// pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
|
||
CStdString label = CGUIInfoLabel::GetLabel(original.Mid(pos + 1, original.GetLength() - (pos + 2))).ToLower();
|
||
CStdString label = CGUIInfoLabel::GetLabel(original.Mid(pos + 1, original.GetLength() - (pos + 2)));
|
||
label = CGUIInfoLabel::ReplaceAddonStrings(label).ToLower();
|
||
int compareString = ConditionalStringParameter(label);
|
||
return AddMultiInfo(GUIInfo(bNegate ? -STRING_COMPARE: STRING_COMPARE, info, compareString));
|
||
}
|
||
... | ... | |
int pos = strTest.Find(",");
|
||
int info = TranslateString(strTest.Mid(10, pos-10));
|
||
// pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
|
||
CStdString label = CGUIInfoLabel::GetLabel(original.Mid(pos + 1, original.GetLength() - (pos + 2))).ToLower();
|
||
CStdString label = CGUIInfoLabel::GetLabel(original.Mid(pos + 1, original.GetLength() - (pos + 2)));
|
||
label = CGUIInfoLabel::ReplaceAddonStrings(label).ToLower();
|
||
int compareString = ConditionalStringParameter(label);
|
||
return AddMultiInfo(GUIInfo(bNegate ? -STRING_STR: STRING_STR, info, compareString));
|
||
}
|
||
... | ... | |
{
|
||
switch (condition)
|
||
{
|
||
case VALUE_IS_TRUE:
|
||
{
|
||
CStdString value;
|
||
if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
|
||
value = GetItemImage((const CFileItem *)item, info.GetData1());
|
||
else
|
||
value = GetImage(info.GetData1(), contextWindow);
|
||
bReturn = (value.Equals("true") || value.Equals("yes") || value.Equals("on"));
|
||
}
|
||
break;
|
||
case SKIN_BOOL:
|
||
{
|
||
bReturn = g_settings.GetSkinBool(info.GetData1());
|
||
... | ... | |
bReturn = GetImage(info.GetData1(), contextWindow).Equals(compare);
|
||
}
|
||
break;
|
||
case INTEGER_GREATER_THAN:
|
||
{
|
||
CStdString value;
|
||
if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
|
||
value = GetItemImage((const CFileItem *)item, info.GetData1());
|
||
else
|
||
value = GetImage(info.GetData1(), contextWindow);
|
||
// Handle the case when a value contains time separator (:). This makes IntegerGreaterThan
|
||
// useful for Player.Time* members without adding a separate set of members returning time in seconds
|
||
if ( value.find_first_of( ':' ) != value.npos )
|
||
bReturn = StringUtils::TimeStringToSeconds( value ) > info.GetData2();
|
||
else
|
||
bReturn = atoi( value.c_str() ) > info.GetData2();
|
||
}
|
||
break;
|
||
case STRING_STR:
|
||
{
|
||
CStdString compare = m_stringParameters[info.GetData2()];
|
xbmc/utils/GUIInfoManager.h (working copy) | ||
---|---|---|
#define STRING_COMPARE 411
|
||
#define STRING_STR 412
|
||
#define INTEGER_GREATER_THAN 413
|
||
#define VALUE_IS_TRUE 414
|
||
#define SKIN_HAS_THEME_START 500
|
||
#define SKIN_HAS_THEME_END 599 // allow for max 100 themes
|