void SettingsManager::setValue(const std::string& _path, const std::string& _value) { pugi::xpath_node node = mUserDocument->document_element().select_single_node(_path.c_str()); if (!node.node().empty()) { node.node().text().set(_value.c_str()); } else { std::vector<std::string> names; std::string delims("/"); names = MyGUI::utility::split(_path, delims); pugi::xml_node currentNode = mUserDocument->document_element(); for (std::vector<std::string>::const_iterator name = names.begin(); name != names.end(); name ++) { pugi::xml_node childNode = currentNode.child((*name).c_str()); if (childNode.empty()) childNode = currentNode.append_child((*name).c_str()); currentNode = childNode; } currentNode.text().set(_value.c_str()); } eventSettingsChanged(_path); }
void SettingsSector::setPropertyValueList(const MyGUI::UString& _propertyName, const VectorUString& _propertyValues) { clearProperty(_propertyName); for (size_t index = 0; index < _propertyValues.size(); ++ index) setPropertyValueImpl(MyGUI::utility::toString(_propertyName, '.', index), _propertyValues[index]); eventSettingsChanged(this, _propertyName); }
void SettingsManager::setValueList(const std::string& _path, const VectorString& _values) { if (!MyGUI::utility::endWith(_path, ".List")) return; std::string itemName = "Value"; pugi::xml_node targetNode; pugi::xpath_node node = mUserDocument->document_element().select_single_node(_path.c_str()); if (!node.node().empty()) { targetNode = node.node(); while (!targetNode.first_child().empty()) targetNode.remove_child(targetNode.first_child()); } else { std::vector<std::string> names; std::string delims("/"); names = MyGUI::utility::split(_path, delims); pugi::xml_node currentNode = mUserDocument->document_element(); for (std::vector<std::string>::const_iterator name = names.begin(); name != names.end(); name ++) { pugi::xml_node childNode = currentNode.child((*name).c_str()); if (childNode.empty()) childNode = currentNode.append_child((*name).c_str()); currentNode = childNode; } targetNode = currentNode; } for (VectorString::const_iterator value = _values.begin(); value != _values.end(); value ++) targetNode.append_child(itemName.c_str()).text().set((*value).c_str()); eventSettingsChanged(_path); }
void SettingsSector::setPropertyValue(const MyGUI::UString& _propertyName, const MyGUI::UString& _propertyValue) { setPropertyValueImpl(_propertyName, _propertyValue); eventSettingsChanged(this, _propertyName); }
void SettingsManager::notifySettingsChanged(SettingsSector* _sector, const MyGUI::UString& _propertyName) { eventSettingsChanged(_sector->getName(), _propertyName); }