diff options
author | Armin Weatherwax | 2010-08-27 01:42:20 +0200 |
---|---|---|
committer | McCabe Maxsted | 2010-08-29 01:30:16 -0700 |
commit | d6a5375d9e490c8b03b032bbe1fc08e30ebf1cd3 (patch) | |
tree | 25f44cc8c5d301ffe56a06161fc2122e50af3d30 | |
parent | Katharine Berry: Added loading of water params from notecards. (diff) | |
download | meta-impy-d6a5375d9e490c8b03b032bbe1fc08e30ebf1cd3.zip meta-impy-d6a5375d9e490c8b03b032bbe1fc08e30ebf1cd3.tar.gz meta-impy-d6a5375d9e490c8b03b032bbe1fc08e30ebf1cd3.tar.bz2 meta-impy-d6a5375d9e490c8b03b032bbe1fc08e30ebf1cd3.tar.xz |
Katharine Berry: Save to Inventory in water floater.
-rw-r--r-- | linden/indra/newview/llfloaterwater.cpp | 75 | ||||
-rw-r--r-- | linden/indra/newview/llfloaterwater.h | 6 | ||||
-rw-r--r-- | linden/indra/newview/llwaterparammanager.cpp | 56 | ||||
-rw-r--r-- | linden/indra/newview/llwaterparammanager.h | 3 | ||||
-rw-r--r-- | linden/indra/newview/llwlparammanager.cpp | 1 | ||||
-rw-r--r-- | linden/indra/newview/skins/default/xui/en-us/floater_water.xml | 5 |
6 files changed, 144 insertions, 2 deletions
diff --git a/linden/indra/newview/llfloaterwater.cpp b/linden/indra/newview/llfloaterwater.cpp index 32c2b75..f08beea 100644 --- a/linden/indra/newview/llfloaterwater.cpp +++ b/linden/indra/newview/llfloaterwater.cpp | |||
@@ -50,6 +50,10 @@ | |||
50 | #include "llboost.h" | 50 | #include "llboost.h" |
51 | #include "llmultisliderctrl.h" | 51 | #include "llmultisliderctrl.h" |
52 | 52 | ||
53 | #include "llagent.h" | ||
54 | #include "llinventorymodel.h" | ||
55 | #include "llviewerinventory.h" | ||
56 | |||
53 | #include "v4math.h" | 57 | #include "v4math.h" |
54 | #include "llviewerdisplay.h" | 58 | #include "llviewerdisplay.h" |
55 | #include "llviewercontrol.h" | 59 | #include "llviewercontrol.h" |
@@ -157,6 +161,7 @@ void LLFloaterWater::initCallbacks(void) { | |||
157 | //childSetAction("WaterLoadPreset", onLoadPreset, comboBox); | 161 | //childSetAction("WaterLoadPreset", onLoadPreset, comboBox); |
158 | childSetAction("WaterNewPreset", onNewPreset, comboBox); | 162 | childSetAction("WaterNewPreset", onNewPreset, comboBox); |
159 | childSetAction("WaterSavePreset", onSavePreset, comboBox); | 163 | childSetAction("WaterSavePreset", onSavePreset, comboBox); |
164 | childSetAction("WaterSaveNotecard", onSaveNotecard, comboBox); | ||
160 | childSetAction("WaterDeletePreset", onDeletePreset, comboBox); | 165 | childSetAction("WaterDeletePreset", onDeletePreset, comboBox); |
161 | 166 | ||
162 | // wave direction | 167 | // wave direction |
@@ -644,6 +649,76 @@ void LLFloaterWater::onSavePreset(void* userData) | |||
644 | LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); | 649 | LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); |
645 | } | 650 | } |
646 | 651 | ||
652 | class KVFloaterWaterNotecardCreatedCallback : public LLInventoryCallback | ||
653 | { | ||
654 | public: | ||
655 | void fire(const LLUUID& inv_item); | ||
656 | }; | ||
657 | |||
658 | void LLFloaterWater::onSaveNotecard(void* userData) | ||
659 | { | ||
660 | // get the name | ||
661 | LLComboBox* comboBox = sWaterMenu->getChild<LLComboBox>("WaterPresetsCombo"); | ||
662 | |||
663 | // don't save the empty name | ||
664 | if(comboBox->getSelectedItemLabel() == "") | ||
665 | { | ||
666 | return; | ||
667 | } | ||
668 | |||
669 | // Check if this is already a notecard. | ||
670 | if(LLWaterParamManager::instance()->mCurParams.mInventoryID.notNull()) | ||
671 | { | ||
672 | LLNotifications::instance().add("KittyWLSaveNotecardAlert", LLSD(), LLSD(), saveNotecardCallback); | ||
673 | } | ||
674 | else | ||
675 | { | ||
676 | // Make sure we have a ".ww" extension. | ||
677 | std::string name = comboBox->getSelectedItemLabel(); | ||
678 | if(name.length() > 2 && name.compare(name.length() - 3, 3, ".ww") != 0) | ||
679 | { | ||
680 | name += ".ww"; | ||
681 | } | ||
682 | LLPointer<KVFloaterWaterNotecardCreatedCallback> cb = new KVFloaterWaterNotecardCreatedCallback(); | ||
683 | // Create a notecard and then save it. | ||
684 | create_inventory_item(gAgent.getID(), | ||
685 | gAgent.getSessionID(), | ||
686 | LLUUID::null, | ||
687 | LLTransactionID::tnull, | ||
688 | name, | ||
689 | "Water settings (Kitty Viewer compatible)", | ||
690 | LLAssetType::AT_NOTECARD, | ||
691 | LLInventoryType::IT_NOTECARD, | ||
692 | NOT_WEARABLE, | ||
693 | PERM_ITEM_UNRESTRICTED, | ||
694 | cb); | ||
695 | |||
696 | } | ||
697 | } | ||
698 | |||
699 | void KVFloaterWaterNotecardCreatedCallback::fire(const LLUUID& inv_item) | ||
700 | { | ||
701 | LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); | ||
702 | param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams); | ||
703 | param_mgr->mParamList[param_mgr->mCurParams.mName].mInventoryID = inv_item; | ||
704 | param_mgr->mCurParams.mInventoryID = inv_item; | ||
705 | LL_INFOS("WindLight") << "Created inventory item " << inv_item << LL_ENDL; | ||
706 | param_mgr->savePresetToNotecard(param_mgr->mCurParams.mName); | ||
707 | } | ||
708 | |||
709 | bool LLFloaterWater::saveNotecardCallback(const LLSD& notification, const LLSD& response) | ||
710 | { | ||
711 | S32 option = LLNotification::getSelectedOption(notification, response); | ||
712 | // if they choose save, do it. Otherwise, don't do anything | ||
713 | if(option == 0) | ||
714 | { | ||
715 | LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); | ||
716 | param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams); | ||
717 | param_mgr->savePresetToNotecard(param_mgr->mCurParams.mName); | ||
718 | } | ||
719 | return false; | ||
720 | } | ||
721 | |||
647 | bool LLFloaterWater::saveAlertCallback(const LLSD& notification, const LLSD& response) | 722 | bool LLFloaterWater::saveAlertCallback(const LLSD& notification, const LLSD& response) |
648 | { | 723 | { |
649 | S32 option = LLNotification::getSelectedOption(notification, response); | 724 | S32 option = LLNotification::getSelectedOption(notification, response); |
diff --git a/linden/indra/newview/llfloaterwater.h b/linden/indra/newview/llfloaterwater.h index f0944e1..0a47627 100644 --- a/linden/indra/newview/llfloaterwater.h +++ b/linden/indra/newview/llfloaterwater.h | |||
@@ -96,6 +96,12 @@ public: | |||
96 | 96 | ||
97 | /// when user hits the save preset button | 97 | /// when user hits the save preset button |
98 | static void onSavePreset(void* userData); | 98 | static void onSavePreset(void* userData); |
99 | |||
100 | /// when user hits the save to inventory button | ||
101 | static void onSaveNotecard(void* userData); | ||
102 | |||
103 | /// prompts a user when overwriting a preset notecard | ||
104 | static bool saveNotecardCallback(const LLSD& notification, const LLSD& response); | ||
99 | 105 | ||
100 | /// prompts a user when overwriting a preset | 106 | /// prompts a user when overwriting a preset |
101 | static bool saveAlertCallback(const LLSD& notification, const LLSD& response); | 107 | static bool saveAlertCallback(const LLSD& notification, const LLSD& response); |
diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp index 0b08b14..e01506e 100644 --- a/linden/indra/newview/llwaterparammanager.cpp +++ b/linden/indra/newview/llwaterparammanager.cpp | |||
@@ -298,6 +298,62 @@ void LLWaterParamManager::savePreset(const std::string & name) | |||
298 | propagateParameters(); | 298 | propagateParameters(); |
299 | } | 299 | } |
300 | 300 | ||
301 | // Yes, this function is completely identical to LLWLParamManager::savePresetToNotecard. | ||
302 | // I feel some refactoring of this whole WindLight thing would be generally beneficial. | ||
303 | // Damned if I'm going to be the one to do it, though. | ||
304 | bool LLWaterParamManager::savePresetToNotecard(const std::string & name) | ||
305 | { | ||
306 | // make an empty llsd | ||
307 | LLSD paramsData(LLSD::emptyMap()); | ||
308 | |||
309 | // fill it with LLSD windlight params | ||
310 | paramsData = mParamList[name].getAll(); | ||
311 | |||
312 | // get some XML | ||
313 | std::ostringstream presetsXML; | ||
314 | LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); | ||
315 | formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); | ||
316 | |||
317 | // Write it to a notecard | ||
318 | LLNotecard notecard; | ||
319 | notecard.setText(presetsXML.str()); | ||
320 | |||
321 | LLInventoryItem *item = gInventory.getItem(mParamList[name].mInventoryID); | ||
322 | if(!item) | ||
323 | { | ||
324 | mParamList[name].mInventoryID = LLUUID::null; | ||
325 | return false; | ||
326 | } | ||
327 | std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory"); | ||
328 | if(!agent_url.empty()) | ||
329 | { | ||
330 | LLTransactionID tid; | ||
331 | LLAssetID asset_id; | ||
332 | tid.generate(); | ||
333 | asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); | ||
334 | |||
335 | LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND); | ||
336 | |||
337 | std::ostringstream stream; | ||
338 | notecard.exportStream(stream); | ||
339 | std::string buffer = stream.str(); | ||
340 | |||
341 | S32 size = buffer.length() + 1; | ||
342 | file.setMaxSize(size); | ||
343 | file.write((U8*)buffer.c_str(), size); | ||
344 | LLSD body; | ||
345 | body["item_id"] = item->getUUID(); | ||
346 | LLHTTPClient::post(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); | ||
347 | } | ||
348 | else | ||
349 | { | ||
350 | LL_WARNS("WindLight") << "Stuff the legacy system." << LL_ENDL; | ||
351 | return false; | ||
352 | } | ||
353 | |||
354 | propagateParameters(); | ||
355 | return true; | ||
356 | } | ||
301 | 357 | ||
302 | void LLWaterParamManager::propagateParameters(void) | 358 | void LLWaterParamManager::propagateParameters(void) |
303 | { | 359 | { |
diff --git a/linden/indra/newview/llwaterparammanager.h b/linden/indra/newview/llwaterparammanager.h index baac4cf..588e436 100644 --- a/linden/indra/newview/llwaterparammanager.h +++ b/linden/indra/newview/llwaterparammanager.h | |||
@@ -245,6 +245,9 @@ public: | |||
245 | 245 | ||
246 | /// save the parameter presets to file | 246 | /// save the parameter presets to file |
247 | void savePreset(const std::string & name); | 247 | void savePreset(const std::string & name); |
248 | |||
249 | /// save the parameter presets to file | ||
250 | bool savePresetToNotecard(const std::string & name); | ||
248 | 251 | ||
249 | /// send the parameters to the shaders | 252 | /// send the parameters to the shaders |
250 | void propagateParameters(void); | 253 | void propagateParameters(void); |
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp index d7df7ae..31471d7 100644 --- a/linden/indra/newview/llwlparammanager.cpp +++ b/linden/indra/newview/llwlparammanager.cpp | |||
@@ -319,7 +319,6 @@ bool LLWLParamManager::savePresetToNotecard(const std::string & name) | |||
319 | file.write((U8*)buffer.c_str(), size); | 319 | file.write((U8*)buffer.c_str(), size); |
320 | LLSD body; | 320 | LLSD body; |
321 | body["item_id"] = item->getUUID(); | 321 | body["item_id"] = item->getUUID(); |
322 | LL_INFOS("WindLight") << body << LL_ENDL; | ||
323 | LLHTTPClient::post(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); | 322 | LLHTTPClient::post(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); |
324 | } | 323 | } |
325 | else | 324 | else |
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_water.xml b/linden/indra/newview/skins/default/xui/en-us/floater_water.xml index 7038c93..c7e5d83 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_water.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_water.xml | |||
@@ -24,9 +24,12 @@ | |||
24 | label="New" label_selected="New" left_delta="40" | 24 | label="New" label_selected="New" left_delta="40" |
25 | mouse_opaque="true" name="WaterNewPreset" scale_image="true" width="70" /> | 25 | mouse_opaque="true" name="WaterNewPreset" scale_image="true" width="70" /> |
26 | <button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20" | 26 | <button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20" |
27 | label="Save" label_selected="Save" left_delta="70" | 27 | label="Save" label_selected="Save to Disk" left_delta="70" |
28 | mouse_opaque="true" name="WaterSavePreset" scale_image="true" width="70" /> | 28 | mouse_opaque="true" name="WaterSavePreset" scale_image="true" width="70" /> |
29 | <button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20" | 29 | <button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20" |
30 | label="Save to Inventory" label_selected="Save" left_delta="70" | ||
31 | mouse_opaque="true" name="WaterSaveNotecard" scale_image="true" width="70" /> | ||
32 | <button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20" | ||
30 | label="Delete" label_selected="Delete" left_delta="70" | 33 | label="Delete" label_selected="Delete" left_delta="70" |
31 | mouse_opaque="true" name="WaterDeletePreset" scale_image="true" width="70" /> | 34 | mouse_opaque="true" name="WaterDeletePreset" scale_image="true" width="70" /> |
32 | <tab_container bottom="-240" follows="left|top" height="180" left="0" | 35 | <tab_container bottom="-240" follows="left|top" height="180" left="0" |