diff options
author | Armin Weatherwax | 2010-08-27 01:16:13 +0200 |
---|---|---|
committer | McCabe Maxsted | 2010-08-29 01:30:00 -0700 |
commit | 7c878691db12df71b6924a8337f8e4c821189eb7 (patch) | |
tree | 4026339fecfc064991d0a9956803006f181323ca | |
parent | Katharine Berry: Added understanding of .ww notecards to inventory panel. (diff) | |
download | meta-impy-7c878691db12df71b6924a8337f8e4c821189eb7.zip meta-impy-7c878691db12df71b6924a8337f8e4c821189eb7.tar.gz meta-impy-7c878691db12df71b6924a8337f8e4c821189eb7.tar.bz2 meta-impy-7c878691db12df71b6924a8337f8e4c821189eb7.tar.xz |
Katharine Berry: Added loading of water params from notecards.
-rw-r--r-- | linden/indra/newview/llinventorybridge.cpp | 11 | ||||
-rw-r--r-- | linden/indra/newview/llwaterparammanager.cpp | 147 | ||||
-rw-r--r-- | linden/indra/newview/llwaterparammanager.h | 13 | ||||
-rw-r--r-- | linden/indra/newview/llwaterparamset.h | 3 | ||||
-rw-r--r-- | linden/indra/newview/llwlparammanager.cpp | 1 |
5 files changed, 157 insertions, 18 deletions
diff --git a/linden/indra/newview/llinventorybridge.cpp b/linden/indra/newview/llinventorybridge.cpp index a3a6e78..712d2fe 100644 --- a/linden/indra/newview/llinventorybridge.cpp +++ b/linden/indra/newview/llinventorybridge.cpp | |||
@@ -78,6 +78,7 @@ | |||
78 | #include "llviewerobjectlist.h" | 78 | #include "llviewerobjectlist.h" |
79 | #include "llviewerwindow.h" | 79 | #include "llviewerwindow.h" |
80 | #include "llvoavatar.h" | 80 | #include "llvoavatar.h" |
81 | #include "llwaterparammanager.h" | ||
81 | #include "llwearable.h" | 82 | #include "llwearable.h" |
82 | #include "llwearablelist.h" | 83 | #include "llwearablelist.h" |
83 | #include "llviewermessage.h" | 84 | #include "llviewermessage.h" |
@@ -3068,7 +3069,11 @@ void LLNotecardBridge::openItem() | |||
3068 | if(isSkySetting()) | 3069 | if(isSkySetting()) |
3069 | { | 3070 | { |
3070 | LLWLParamManager::instance()->loadPresetNotecard(item->getName(), item->getAssetUUID(), mUUID); | 3071 | LLWLParamManager::instance()->loadPresetNotecard(item->getName(), item->getAssetUUID(), mUUID); |
3071 | } | 3072 | } |
3073 | else if(isWaterSetting()) | ||
3074 | { | ||
3075 | LLWaterParamManager::instance()->loadPresetNotecard(item->getName(), item->getAssetUUID(), mUUID); | ||
3076 | } | ||
3072 | else | 3077 | else |
3073 | { | 3078 | { |
3074 | open_notecard(item, getPrefix() + item->getName(), LLUUID::null, FALSE); | 3079 | open_notecard(item, getPrefix() + item->getName(), LLUUID::null, FALSE); |
@@ -3123,6 +3128,10 @@ void LLNotecardBridge::performAction(LLFolderView* folder, LLInventoryModel* mod | |||
3123 | { | 3128 | { |
3124 | LLWLParamManager::instance()->loadPresetNotecard(itemp->getName(), itemp->getAssetUUID(), mUUID); | 3129 | LLWLParamManager::instance()->loadPresetNotecard(itemp->getName(), itemp->getAssetUUID(), mUUID); |
3125 | } | 3130 | } |
3131 | else if ("load_waterlight" == action) | ||
3132 | { | ||
3133 | LLWaterParamManager::instance()->loadPresetNotecard(itemp->getName(), itemp->getAssetUUID(), mUUID); | ||
3134 | } | ||
3126 | else if ("edit_windlight" == action) | 3135 | else if ("edit_windlight" == action) |
3127 | { | 3136 | { |
3128 | open_notecard(itemp, getPrefix() + itemp->getName(), LLUUID::null, FALSE); | 3137 | open_notecard(itemp, getPrefix() + itemp->getName(), LLUUID::null, FALSE); |
diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp index 4a61b78..0b08b14 100644 --- a/linden/indra/newview/llwaterparammanager.cpp +++ b/linden/indra/newview/llwaterparammanager.cpp | |||
@@ -48,6 +48,17 @@ | |||
48 | #include "lllineeditor.h" | 48 | #include "lllineeditor.h" |
49 | #include "llsdserialize.h" | 49 | #include "llsdserialize.h" |
50 | 50 | ||
51 | // For notecard loading | ||
52 | #include "llvfile.h" | ||
53 | #include "llnotecard.h" | ||
54 | #include "llmemorystream.h" | ||
55 | #include "llnotify.h" | ||
56 | #include "llagent.h" | ||
57 | #include "llinventorymodel.h" | ||
58 | #include "llviewerinventory.h" | ||
59 | #include "llviewerregion.h" | ||
60 | #include "llassetuploadresponders.h" | ||
61 | |||
51 | #include "v4math.h" | 62 | #include "v4math.h" |
52 | #include "llviewerdisplay.h" | 63 | #include "llviewerdisplay.h" |
53 | #include "llviewercontrol.h" | 64 | #include "llviewercontrol.h" |
@@ -141,6 +152,17 @@ void LLWaterParamManager::loadAllPresets(const std::string& file_name) | |||
141 | 152 | ||
142 | void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) | 153 | void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) |
143 | { | 154 | { |
155 | // Check if we already have the preset before we try loading it again. | ||
156 | if(mParamList.find(name) != mParamList.end()) | ||
157 | { | ||
158 | if(propagate) | ||
159 | { | ||
160 | getParamSet(name, mCurParams); | ||
161 | propagateParameters(); | ||
162 | } | ||
163 | return; | ||
164 | } | ||
165 | |||
144 | // bugfix for SL-46920: preventing filenames that break stuff. | 166 | // bugfix for SL-46920: preventing filenames that break stuff. |
145 | char * curl_str = curl_escape(name.c_str(), name.size()); | 167 | char * curl_str = curl_escape(name.c_str(), name.size()); |
146 | std::string escaped_filename(curl_str); | 168 | std::string escaped_filename(curl_str); |
@@ -165,21 +187,7 @@ void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) | |||
165 | 187 | ||
166 | if (presetsXML) | 188 | if (presetsXML) |
167 | { | 189 | { |
168 | LLSD paramsData(LLSD::emptyMap()); | 190 | loadPresetXML(name, presetsXML); |
169 | |||
170 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | ||
171 | |||
172 | parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); | ||
173 | |||
174 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); | ||
175 | if(mIt == mParamList.end()) | ||
176 | { | ||
177 | addParamSet(name, paramsData); | ||
178 | } | ||
179 | else | ||
180 | { | ||
181 | setParamSet(name, paramsData); | ||
182 | } | ||
183 | presetsXML.close(); | 191 | presetsXML.close(); |
184 | } | 192 | } |
185 | else | 193 | else |
@@ -193,7 +201,76 @@ void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) | |||
193 | getParamSet(name, mCurParams); | 201 | getParamSet(name, mCurParams); |
194 | propagateParameters(); | 202 | propagateParameters(); |
195 | } | 203 | } |
196 | } | 204 | } |
205 | |||
206 | bool LLWaterParamManager::loadPresetXML(const std::string& name, std::istream& preset_stream, bool propagate /* = false */, bool check_if_real /* = false */) | ||
207 | { | ||
208 | LLSD paramsData(LLSD::emptyMap()); | ||
209 | |||
210 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | ||
211 | |||
212 | if(parser->parse(preset_stream, paramsData, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE) | ||
213 | { | ||
214 | return false; | ||
215 | } | ||
216 | |||
217 | if(check_if_real) | ||
218 | { | ||
219 | static const char* expected_windlight_settings[] = { | ||
220 | "blurMultiplier", | ||
221 | "fresnelOffset", | ||
222 | "fresnelScale", | ||
223 | "normScale", | ||
224 | "normalMap", | ||
225 | "scaleAbove", | ||
226 | "scaleBelow", | ||
227 | "waterFogColor", | ||
228 | "waterFogDensity", | ||
229 | "wave1Dir", | ||
230 | "wave2Dir" | ||
231 | }; | ||
232 | static S32 expected_count = LL_ARRAY_SIZE(expected_windlight_settings); | ||
233 | for(S32 i = 0; i < expected_count; ++i) | ||
234 | { | ||
235 | if(!paramsData.has(expected_windlight_settings[i])) | ||
236 | { | ||
237 | LL_WARNS("WindLight") << "Attempted to load WindLight water param set without " << expected_windlight_settings[i] << LL_ENDL; | ||
238 | return false; | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | |||
243 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); | ||
244 | if(mIt == mParamList.end()) | ||
245 | { | ||
246 | addParamSet(name, paramsData); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | setParamSet(name, paramsData); | ||
251 | } | ||
252 | |||
253 | if(propagate) | ||
254 | { | ||
255 | getParamSet(name, mCurParams); | ||
256 | propagateParameters(); | ||
257 | } | ||
258 | return true; | ||
259 | } | ||
260 | |||
261 | void LLWaterParamManager::loadPresetNotecard(const std::string& name, const LLUUID& asset_id, const LLUUID& inv_id) | ||
262 | { | ||
263 | gAssetStorage->getInvItemAsset(LLHost::invalid, | ||
264 | gAgent.getID(), | ||
265 | gAgent.getSessionID(), | ||
266 | gAgent.getID(), | ||
267 | LLUUID::null, | ||
268 | inv_id, | ||
269 | asset_id, | ||
270 | LLAssetType::AT_NOTECARD, | ||
271 | &loadWaterNotecard, | ||
272 | (void*)&inv_id); | ||
273 | } | ||
197 | 274 | ||
198 | void LLWaterParamManager::savePreset(const std::string & name) | 275 | void LLWaterParamManager::savePreset(const std::string & name) |
199 | { | 276 | { |
@@ -457,3 +534,41 @@ LLWaterParamManager * LLWaterParamManager::instance() | |||
457 | 534 | ||
458 | return sInstance; | 535 | return sInstance; |
459 | } | 536 | } |
537 | |||
538 | // static | ||
539 | void LLWaterParamManager::loadWaterNotecard(LLVFS *vfs, const LLUUID& asset_id, LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status) | ||
540 | { | ||
541 | LLUUID inventory_id(*((LLUUID*)user_data)); | ||
542 | std::string name = "WindLight Setting.ww"; | ||
543 | LLViewerInventoryItem *item = gInventory.getItem(inventory_id); | ||
544 | if(item) | ||
545 | { | ||
546 | inventory_id = item->getUUID(); | ||
547 | name = item->getName(); | ||
548 | } | ||
549 | if(LL_ERR_NOERR == status) | ||
550 | { | ||
551 | LLVFile file(vfs, asset_id, asset_type, LLVFile::READ); | ||
552 | S32 file_length = file.getSize(); | ||
553 | std::vector<char> buffer(file_length + 1); | ||
554 | file.read((U8*)&buffer[0], file_length); | ||
555 | buffer[file_length] = 0; | ||
556 | LLNotecard notecard(LLNotecard::MAX_SIZE); | ||
557 | LLMemoryStream str((U8*)&buffer[0], file_length + 1); | ||
558 | notecard.importStream(str); | ||
559 | std::string settings = notecard.getText(); | ||
560 | LLMemoryStream settings_str((U8*)settings.c_str(), settings.length()); | ||
561 | bool is_real_setting = sInstance->loadPresetXML(name, settings_str, true, true); | ||
562 | if(!is_real_setting) | ||
563 | { | ||
564 | LLSD subs; | ||
565 | subs["NAME"] = name; | ||
566 | LLNotifications::instance().add("KittyInvalidWaterlightNotecard", subs); | ||
567 | } | ||
568 | else | ||
569 | { | ||
570 | // We can do this because we know mCurParams | ||
571 | sInstance->mParamList[name].mInventoryID = inventory_id; | ||
572 | } | ||
573 | } | ||
574 | } | ||
diff --git a/linden/indra/newview/llwaterparammanager.h b/linden/indra/newview/llwaterparammanager.h index babaf00..baac4cf 100644 --- a/linden/indra/newview/llwaterparammanager.h +++ b/linden/indra/newview/llwaterparammanager.h | |||
@@ -39,6 +39,10 @@ | |||
39 | #include "llviewercamera.h" | 39 | #include "llviewercamera.h" |
40 | #include "v4color.h" | 40 | #include "v4color.h" |
41 | 41 | ||
42 | #include "llassettype.h" // Ugh. | ||
43 | |||
44 | class LLVFS; | ||
45 | |||
42 | const F32 WATER_FOG_LIGHT_CLAMP = 0.3f; | 46 | const F32 WATER_FOG_LIGHT_CLAMP = 0.3f; |
43 | 47 | ||
44 | // color control | 48 | // color control |
@@ -231,6 +235,13 @@ public: | |||
231 | /// load an individual preset into the sky | 235 | /// load an individual preset into the sky |
232 | 236 | ||
233 | void loadPreset(const std::string & name,bool propagate=true); | 237 | void loadPreset(const std::string & name,bool propagate=true); |
238 | |||
239 | /// load an individual preset into the sky from an LLSD stream | ||
240 | /// Returns whether the stream was actually reasonable XML to load from. | ||
241 | bool loadPresetXML(const std::string& name, std::istream& preset_stream, bool propogate=false, bool check_if_real=false); | ||
242 | |||
243 | /// Load an individual preset from a notecard. | ||
244 | void loadPresetNotecard(const std::string& name, const LLUUID& asset_id, const LLUUID& inv_id); | ||
234 | 245 | ||
235 | /// save the parameter presets to file | 246 | /// save the parameter presets to file |
236 | void savePreset(const std::string & name); | 247 | void savePreset(const std::string & name); |
@@ -322,6 +333,8 @@ private: | |||
322 | 333 | ||
323 | // our parameter manager singleton instance | 334 | // our parameter manager singleton instance |
324 | static LLWaterParamManager * sInstance; | 335 | static LLWaterParamManager * sInstance; |
336 | |||
337 | static void loadWaterNotecard(LLVFS *vfs, const LLUUID& asset_id, LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status); | ||
325 | }; | 338 | }; |
326 | 339 | ||
327 | inline void LLWaterParamManager::setDensitySliderValue(F32 val) | 340 | inline void LLWaterParamManager::setDensitySliderValue(F32 val) |
diff --git a/linden/indra/newview/llwaterparamset.h b/linden/indra/newview/llwaterparamset.h index 9087843..efbad31 100644 --- a/linden/indra/newview/llwaterparamset.h +++ b/linden/indra/newview/llwaterparamset.h | |||
@@ -49,7 +49,8 @@ class LLWaterParamSet | |||
49 | friend class LLWaterParamManager; | 49 | friend class LLWaterParamManager; |
50 | 50 | ||
51 | public: | 51 | public: |
52 | std::string mName; | 52 | std::string mName; |
53 | LLUUID mInventoryID; | ||
53 | 54 | ||
54 | private: | 55 | private: |
55 | 56 | ||
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp index b3c2b0b..d7df7ae 100644 --- a/linden/indra/newview/llwlparammanager.cpp +++ b/linden/indra/newview/llwlparammanager.cpp | |||
@@ -718,6 +718,7 @@ LLWLParamManager * LLWLParamManager::instance() | |||
718 | return sInstance; | 718 | return sInstance; |
719 | } | 719 | } |
720 | 720 | ||
721 | // static | ||
721 | void LLWLParamManager::loadWindlightNotecard(LLVFS *vfs, const LLUUID& asset_id, LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status) | 722 | void LLWLParamManager::loadWindlightNotecard(LLVFS *vfs, const LLUUID& asset_id, LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status) |
722 | { | 723 | { |
723 | LLUUID inventory_id(*((LLUUID*)user_data)); | 724 | LLUUID inventory_id(*((LLUUID*)user_data)); |