diff options
author | Armin Weatherwax | 2010-08-26 14:58:21 +0200 |
---|---|---|
committer | McCabe Maxsted | 2010-08-29 01:24:48 -0700 |
commit | 5ba57500f0df4cb6808a9d588dcb4c00dd5da4d6 (patch) | |
tree | 00acffe57da2d6122a38f5e85832e018c0be2160 /linden/indra/newview | |
parent | Leveled up the easter egg a little (can you sense a theme?) (diff) | |
download | meta-impy-5ba57500f0df4cb6808a9d588dcb4c00dd5da4d6.zip meta-impy-5ba57500f0df4cb6808a9d588dcb4c00dd5da4d6.tar.gz meta-impy-5ba57500f0df4cb6808a9d588dcb4c00dd5da4d6.tar.bz2 meta-impy-5ba57500f0df4cb6808a9d588dcb4c00dd5da4d6.tar.xz |
Katharine Berry: Allow loading of windlight parameters from arbitrary XML streams.
Diffstat (limited to 'linden/indra/newview')
-rw-r--r-- | linden/indra/newview/llwlparammanager.cpp | 76 | ||||
-rw-r--r-- | linden/indra/newview/llwlparammanager.h | 4 |
2 files changed, 65 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 |
diff --git a/linden/indra/newview/llwlparammanager.h b/linden/indra/newview/llwlparammanager.h index 6b6300c..141af3c 100644 --- a/linden/indra/newview/llwlparammanager.h +++ b/linden/indra/newview/llwlparammanager.h | |||
@@ -145,6 +145,10 @@ public: | |||
145 | /// load an individual preset into the sky | 145 | /// load an individual preset into the sky |
146 | void loadPreset(const std::string & name,bool propogate=true); | 146 | void loadPreset(const std::string & name,bool propogate=true); |
147 | 147 | ||
148 | /// load an individual preset into the sky from an LLSD stream | ||
149 | /// Returns whether the stream was actually reasonable XML to load from. | ||
150 | bool loadPresetXML(const std::string& name, std::istream& preset_stream, bool check_if_real=false); | ||
151 | |||
148 | /// save the parameter presets to file | 152 | /// save the parameter presets to file |
149 | void savePreset(const std::string & name); | 153 | void savePreset(const std::string & name); |
150 | 154 | ||