diff options
Diffstat (limited to 'linden/indra/newview/llwlparammanager.cpp')
-rw-r--r-- | linden/indra/newview/llwlparammanager.cpp | 76 |
1 files changed, 61 insertions, 15 deletions
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp index cf6744f..5f80283 100644 --- a/linden/indra/newview/llwlparammanager.cpp +++ b/linden/indra/newview/llwlparammanager.cpp | |||
@@ -159,6 +159,66 @@ void LLWLParamManager::loadPresets(const std::string& file_name) | |||
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | bool LLWLParamManager::loadPresetXML(const std::string& name, std::istream& preset_stream, bool check_if_real /* = false */) | ||
163 | { | ||
164 | LLSD paramsData(LLSD::emptyMap()); | ||
165 | |||
166 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | ||
167 | |||
168 | if(parser->parse(preset_stream, paramsData, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE) | ||
169 | { | ||
170 | return false; | ||
171 | } | ||
172 | |||
173 | if(check_if_real) | ||
174 | { | ||
175 | static const char* expected_windlight_settings[] = { | ||
176 | "ambient", | ||
177 | "blue_density", | ||
178 | "blue_horizon", | ||
179 | "cloud_color", | ||
180 | "cloud_pos_density1", | ||
181 | "cloud_pos_density2", | ||
182 | "cloud_scale", | ||
183 | "cloud_scroll_rate", | ||
184 | "cloud_shadow", | ||
185 | "density_multiplier", | ||
186 | "distance_multiplier", | ||
187 | "east_angle", | ||
188 | "enable_cloud_scroll", | ||
189 | "gamma", | ||
190 | "glow", | ||
191 | "haze_density", | ||
192 | "haze_horizon", | ||
193 | "lightnorm", | ||
194 | "max_y", | ||
195 | "star_brightness", | ||
196 | "sun_angle", | ||
197 | "sunlight_color" | ||
198 | }; | ||
199 | static S32 expected_count = LL_ARRAY_SIZE(expected_windlight_settings); | ||
200 | for(S32 i = 0; i < expected_count; ++i) | ||
201 | { | ||
202 | if(!paramsData.has(expected_windlight_settings[i])) | ||
203 | { | ||
204 | LL_WARNS("WindLight") << "Attempted to load WindLight param set without " << expected_windlight_settings[i] << LL_ENDL; | ||
205 | return false; | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | |||
210 | std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name); | ||
211 | if(mIt == mParamList.end()) | ||
212 | { | ||
213 | addParamSet(name, paramsData); | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | setParamSet(name, paramsData); | ||
218 | } | ||
219 | return true; | ||
220 | } | ||
221 | |||
162 | void LLWLParamManager::savePresets(const std::string & fileName) | 222 | void LLWLParamManager::savePresets(const std::string & fileName) |
163 | { | 223 | { |
164 | //Nobody currently calls me, but if they did, then its reasonable to write the data out to the user's folder | 224 | //Nobody currently calls me, but if they did, then its reasonable to write the data out to the user's folder |
@@ -211,21 +271,7 @@ void LLWLParamManager::loadPreset(const std::string & name,bool propagate) | |||
211 | 271 | ||
212 | if (presetsXML) | 272 | if (presetsXML) |
213 | { | 273 | { |
214 | LLSD paramsData(LLSD::emptyMap()); | 274 | loadPresetXML(name, presetsXML); |
215 | |||
216 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | ||
217 | |||
218 | parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); | ||
219 | |||
220 | std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name); | ||
221 | if(mIt == mParamList.end()) | ||
222 | { | ||
223 | addParamSet(name, paramsData); | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | setParamSet(name, paramsData); | ||
228 | } | ||
229 | presetsXML.close(); | 275 | presetsXML.close(); |
230 | } | 276 | } |
231 | else | 277 | else |