void CGUIWindowSettingsCategory::FillControl(CSetting *pSetting, CGUIControl *pSettingControl) { void *filler = CSettings::Get().GetSettingOptionsFiller(pSetting); if (filler == NULL) return; if (pSetting->GetType() == SettingTypeInteger) { CSettingInt *pSettingInt = (CSettingInt*)pSetting; // get the list of options and the current option IntegerSettingOptions options; int currentOption = pSettingInt->GetValue(); ((IntegerSettingOptionsFiller)filler)(pSetting, options, currentOption); // clear the spinner control CGUISpinControlEx *pSpinControl = (CGUISpinControlEx *)pSettingControl; pSpinControl->Clear(); // fill the spinner control for (IntegerSettingOptions::const_iterator option = options.begin(); option != options.end(); option++) pSpinControl->AddLabel(option->first, option->second); // set the current option pSpinControl->SetValue(currentOption); // check if the current setting has changed if (currentOption != pSettingInt->GetValue()) pSettingInt->SetValue(currentOption); } else if (pSetting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString*)pSetting; // get the list of options and the current option StringSettingOptions options; std::string currentOption = pSettingString->GetValue(); ((StringSettingOptionsFiller)filler)(pSetting, options, currentOption); // clear the spinner control CGUISpinControlEx *pSpinControl = (CGUISpinControlEx *)pSettingControl; pSpinControl->Clear(); // fill the spinner control for (StringSettingOptions::const_iterator option = options.begin(); option != options.end(); option++) pSpinControl->AddLabel(option->first, option->second); // set the current option pSpinControl->SetStringValue(currentOption); // check if the current setting has changed if (currentOption.compare(pSettingString->GetValue()) != 0) pSettingString->SetValue(currentOption); } }
bool CPeripheral::SetSetting(const CStdString &strKey, const CStdString &strValue) { bool bChanged(false); map<CStdString, CSetting *>::iterator it = m_settings.find(strKey); if (it != m_settings.end()) { if ((*it).second->GetType() == SettingTypeString) { CSettingString *stringSetting = (CSettingString *) (*it).second; if (stringSetting) { bChanged = !StringUtils::EqualsNoCase(stringSetting->GetValue(), strValue); stringSetting->SetValue(strValue); if (bChanged && m_bInitialised) m_changedSettings.insert(strKey); } } else if ((*it).second->GetType() == SettingTypeInteger) bChanged = SetSetting(strKey, (int) (strValue.empty() ? 0 : atoi(strValue.c_str()))); else if ((*it).second->GetType() == SettingTypeNumber) bChanged = SetSetting(strKey, (float) (strValue.empty() ? 0 : atof(strValue.c_str()))); else if ((*it).second->GetType() == SettingTypeBool) bChanged = SetSetting(strKey, strValue.Equals("1")); } return bChanged; }
std::string CLangInfo::GetSubtitleCharSet() const { CSettingString* charsetSetting = static_cast<CSettingString*>(CSettings::GetInstance().GetSetting(CSettings::SETTING_SUBTITLES_CHARSET)); if (charsetSetting->IsDefault()) return m_strSubtitleCharSet; return charsetSetting->GetValue(); }
std::string CLangInfo::GetSubtitleCharSet() const { CSettingString* charsetSetting = static_cast<CSettingString*>(CSettings::Get().GetSetting("subtitles.charset")); if (charsetSetting->IsDefault()) return m_strSubtitleCharSet; return charsetSetting->GetValue(); }
std::string CLangInfo::GetGuiCharSet() const { CSettingString* charsetSetting = static_cast<CSettingString*>(CSettings::GetInstance().GetSetting(CSettings::SETTING_LOCALE_CHARSET)); if (charsetSetting == NULL || charsetSetting->IsDefault()) return m_strGuiCharSet; return charsetSetting->GetValue(); }
void CPeripheral::PersistSettings(bool bExiting /* = false */) { CXBMCTinyXML doc; TiXmlElement node("settings"); doc.InsertEndChild(node); for (map<CStdString, CSetting *>::const_iterator itr = m_settings.begin(); itr != m_settings.end(); itr++) { TiXmlElement nodeSetting("setting"); nodeSetting.SetAttribute("id", itr->first.c_str()); CStdString strValue; switch ((*itr).second->GetType()) { case SettingTypeString: { CSettingString *stringSetting = (CSettingString *) (*itr).second; if (stringSetting) strValue = stringSetting->GetValue(); } break; case SettingTypeInteger: { CSettingInt *intSetting = (CSettingInt *) (*itr).second; if (intSetting) strValue = StringUtils::Format("%d", intSetting->GetValue()); } break; case SettingTypeNumber: { CSettingNumber *floatSetting = (CSettingNumber *) (*itr).second; if (floatSetting) strValue = StringUtils::Format("%.2f", floatSetting->GetValue()); } break; case SettingTypeBool: { CSettingBool *boolSetting = (CSettingBool *) (*itr).second; if (boolSetting) strValue = StringUtils::Format("%d", boolSetting->GetValue() ? 1:0); } break; default: break; } nodeSetting.SetAttribute("value", strValue.c_str()); doc.RootElement()->InsertEndChild(nodeSetting); } doc.SaveFile(m_strSettingsFile); if (!bExiting) { for (set<CStdString>::const_iterator it = m_changedSettings.begin(); it != m_changedSettings.end(); it++) OnSettingChanged(*it); } m_changedSettings.clear(); }
const CStdString CPeripheral::GetSettingString(const CStdString &strKey) const { map<CStdString, CSetting *>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second->GetType() == SettingTypeString) { CSettingString *stringSetting = (CSettingString *) (*it).second; if (stringSetting) return stringSetting->GetValue(); } return StringUtils::EmptyString; }
const std::string CPeripheral::GetSettingString(const std::string &strKey) const { std::map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeString) { CSettingString *stringSetting = (CSettingString *) (*it).second.m_setting; if (stringSetting) return stringSetting->GetValue(); } return ""; }
bool CDisplaySettings::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { if (setting == NULL) return false; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_VIDEOSCREEN_SCREENMODE) { CSettingString *screenmodeSetting = (CSettingString*)setting; std::string screenmode = screenmodeSetting->GetValue(); // in Eden there was no character ("i" or "p") indicating interlaced/progressive // at the end so we just add a "p" and assume progressive // no 3d mode existed before, so just assume std modes if (screenmode.size() == 20) return screenmodeSetting->SetValue(screenmode + "pstd"); if (screenmode.size() == 21) return screenmodeSetting->SetValue(screenmode + "std"); } else if (settingId == CSettings::SETTING_VIDEOSCREEN_VSYNC) { // This ifdef is intended to catch everything except Linux and FreeBSD #if !defined(TARGET_LINUX) || defined(TARGET_DARWIN) || defined(TARGET_ANDROID) || defined(TARGET_RASPBERRY_PI) // in the Gotham alphas through beta3 the default value for darwin and android was set incorrectly. CSettingInt *vsyncSetting = (CSettingInt*)setting; if (vsyncSetting->GetValue() == VSYNC_DRIVER) return vsyncSetting->SetValue(VSYNC_ALWAYS); #endif } else if (settingId == CSettings::SETTING_VIDEOSCREEN_PREFEREDSTEREOSCOPICMODE) { CSettingInt *stereomodeSetting = (CSettingInt*)setting; STEREOSCOPIC_PLAYBACK_MODE playbackMode = (STEREOSCOPIC_PLAYBACK_MODE) CSettings::Get().GetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE); if (stereomodeSetting->GetValue() == RENDER_STEREO_MODE_OFF) { // if preferred playback mode was OFF, update playback mode to ignore if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_PREFERRED) CSettings::Get().SetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE, STEREOSCOPIC_PLAYBACK_MODE_IGNORE); return stereomodeSetting->SetValue(RENDER_STEREO_MODE_AUTO); } else if (stereomodeSetting->GetValue() == RENDER_STEREO_MODE_MONO) { // if preferred playback mode was MONO, update playback mode if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_PREFERRED) CSettings::Get().SetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE, STEREOSCOPIC_PLAYBACK_MODE_MONO); return stereomodeSetting->SetValue(RENDER_STEREO_MODE_AUTO); } } return false; }
void CGUIControlSpinExSetting::FillControl() { m_pSpin->Clear(); switch (m_pSetting->GetControl().GetFormat()) { case SettingControlFormatNumber: { CSettingNumber *pSettingNumber = (CSettingNumber *)m_pSetting; m_pSpin->SetType(SPIN_CONTROL_TYPE_FLOAT); m_pSpin->SetFloatRange((float)pSettingNumber->GetMinimum(), (float)pSettingNumber->GetMaximum()); m_pSpin->SetFloatInterval((float)pSettingNumber->GetStep()); m_pSpin->SetFloatValue((float)pSettingNumber->GetValue()); break; } case SettingControlFormatInteger: { m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); FillIntegerSettingControl(); break; } case SettingControlFormatString: { m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); if (m_pSetting->GetType() == SettingTypeInteger) FillIntegerSettingControl(); else if (m_pSetting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString *)m_pSetting; if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic) { DynamicStringSettingOptions options = pSettingString->UpdateDynamicOptions(); for (std::vector< std::pair<std::string, std::string> >::const_iterator option = options.begin(); option != options.end(); ++option) m_pSpin->AddLabel(option->first, option->second); m_pSpin->SetStringValue(pSettingString->GetValue()); } } break; } default: break; } }
bool CDisplaySettings::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { if (setting == NULL) return false; const std::string &settingId = setting->GetId(); if (settingId == "videoscreen.screenmode") { CSettingString *screenmodeSetting = (CSettingString*)setting; std::string screenmode = screenmodeSetting->GetValue(); // in Eden there was no character ("i" or "p") indicating interlaced/progressive // at the end so we just add a "p" and assume progressive if (screenmode.size() == 20) return screenmodeSetting->SetValue(screenmode + "p"); } return false; }
bool CDisplaySettings::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { if (setting == NULL) return false; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_VIDEOSCREEN_SCREENMODE) { CSettingString *screenmodeSetting = (CSettingString*)setting; std::string screenmode = screenmodeSetting->GetValue(); // in Eden there was no character ("i" or "p") indicating interlaced/progressive // at the end so we just add a "p" and assume progressive // no 3d mode existed before, so just assume std modes if (screenmode.size() == 20) return screenmodeSetting->SetValue(screenmode + "pstd"); if (screenmode.size() == 21) return screenmodeSetting->SetValue(screenmode + "std"); } else if (settingId == CSettings::SETTING_VIDEOSCREEN_PREFEREDSTEREOSCOPICMODE) { CSettingInt *stereomodeSetting = (CSettingInt*)setting; STEREOSCOPIC_PLAYBACK_MODE playbackMode = (STEREOSCOPIC_PLAYBACK_MODE) CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE); if (stereomodeSetting->GetValue() == RENDER_STEREO_MODE_OFF) { // if preferred playback mode was OFF, update playback mode to ignore if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_PREFERRED) CSettings::GetInstance().SetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE, STEREOSCOPIC_PLAYBACK_MODE_IGNORE); return stereomodeSetting->SetValue(RENDER_STEREO_MODE_AUTO); } else if (stereomodeSetting->GetValue() == RENDER_STEREO_MODE_MONO) { // if preferred playback mode was MONO, update playback mode if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_PREFERRED) CSettings::GetInstance().SetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE, STEREOSCOPIC_PLAYBACK_MODE_MONO); return stereomodeSetting->SetValue(RENDER_STEREO_MODE_AUTO); } } return false; }
bool CGUIControlListSetting::GetItems(CSetting *setting, CFileItemList &items) { switch (setting->GetControl().GetFormat()) { case SettingControlFormatInteger: return GetIntegerItems(setting, items); case SettingControlFormatString: { if (setting->GetType() == SettingTypeInteger) return GetIntegerItems(setting, items); else if (setting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString *)setting; if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic) { DynamicStringSettingOptions options = pSettingString->UpdateDynamicOptions(); for (DynamicStringSettingOptions::const_iterator option = options.begin(); option != options.end(); ++option) { CFileItemPtr pItem = GetItem(option->first, option->second); if (StringUtils::EqualsNoCase(option->second, pSettingString->GetValue())) pItem->Select(true); items.Add(pItem); } } } break; } default: return false; } return true; }
void CGUIDialogPeripheralSettings::CreateSettings() { m_bIsInitialising = true; m_usePopupSliders = g_SkinInfo->HasSkinFile("DialogSlider.xml"); if (m_item) { CPeripheral *peripheral = g_peripherals.GetByPath(m_item->GetPath()); if (peripheral) { vector<CSetting *> settings = peripheral->GetSettings(); for (size_t iPtr = 0; iPtr < settings.size(); iPtr++) { CSetting *setting = settings[iPtr]; if (!setting->IsVisible()) { CLog::Log(LOGDEBUG, "%s - invisible", __FUNCTION__); continue; } switch(setting->GetType()) { case SettingTypeBool: { CSettingBool *boolSetting = (CSettingBool *) setting; if (boolSetting) { m_boolSettings.insert(make_pair(CStdString(boolSetting->GetId()), boolSetting->GetValue())); AddBool(m_settingId++, boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetId()], true); } } break; case SettingTypeInteger: { CSettingInt *intSetting = (CSettingInt *) setting; if (intSetting) { if (intSetting->GetControl()->GetFormat() == "integer") { m_intSettings.insert(make_pair(CStdString(intSetting->GetId()), (float) intSetting->GetValue())); AddSlider(m_settingId++, intSetting->GetLabel(), &m_intSettings[intSetting->GetId()], (float)intSetting->GetMinimum(), (float)intSetting->GetStep(), (float)intSetting->GetMaximum(), CGUIDialogVideoSettings::FormatInteger, false); } else if (intSetting->GetControl()->GetFormat() == "string") { m_intTextSettings.insert(make_pair(CStdString(intSetting->GetId()), intSetting->GetValue())); vector<pair<int, int> > entries; StaticIntegerSettingOptions::const_iterator entriesItr = intSetting->GetOptions().begin(); while (entriesItr != intSetting->GetOptions().end()) { entries.push_back(make_pair(entriesItr->first, entriesItr->second)); ++entriesItr; } AddSpin(m_settingId++, intSetting->GetLabel(), &m_intTextSettings[intSetting->GetId()], entries); } } } break; case SettingTypeNumber: { CSettingNumber *floatSetting = (CSettingNumber *) setting; if (floatSetting) { m_floatSettings.insert(make_pair(CStdString(floatSetting->GetId()), (float)floatSetting->GetValue())); AddSlider(m_settingId++, floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetId()], (float)floatSetting->GetMinimum(), (float)floatSetting->GetStep(), (float)floatSetting->GetMaximum(), CGUIDialogVideoSettings::FormatFloat, false); } } break; case SettingTypeString: { CSettingString *stringSetting = (CSettingString *) setting; if (stringSetting) { m_stringSettings.insert(make_pair(CStdString(stringSetting->GetId()), stringSetting->GetValue())); AddString(m_settingId++, stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetId()]); } } break; default: //TODO add more types if needed CLog::Log(LOGDEBUG, "%s - unknown type", __FUNCTION__); break; } } } else { CLog::Log(LOGDEBUG, "%s - no peripheral", __FUNCTION__); } } m_bIsInitialising = false; }