aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--linden/indra/newview/llfloaterwindlight.cpp82
-rw-r--r--linden/indra/newview/llfloaterwindlight.h8
-rw-r--r--linden/indra/newview/llwlparammanager.cpp77
-rw-r--r--linden/indra/newview/llwlparammanager.h5
-rw-r--r--linden/indra/newview/llwlparamset.h3
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/floater_windlight_options.xml7
6 files changed, 172 insertions, 10 deletions
diff --git a/linden/indra/newview/llfloaterwindlight.cpp b/linden/indra/newview/llfloaterwindlight.cpp
index 42adba8..8cdc634 100644
--- a/linden/indra/newview/llfloaterwindlight.cpp
+++ b/linden/indra/newview/llfloaterwindlight.cpp
@@ -50,6 +50,10 @@
50#include "lltabcontainer.h" 50#include "lltabcontainer.h"
51#include "llboost.h" 51#include "llboost.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"
@@ -222,6 +226,7 @@ void LLFloaterWindLight::initCallbacks(void) {
222 //childSetAction("WLLoadPreset", onLoadPreset, comboBox); 226 //childSetAction("WLLoadPreset", onLoadPreset, comboBox);
223 childSetAction("WLNewPreset", onNewPreset, comboBox); 227 childSetAction("WLNewPreset", onNewPreset, comboBox);
224 childSetAction("WLSavePreset", onSavePreset, comboBox); 228 childSetAction("WLSavePreset", onSavePreset, comboBox);
229 childSetAction("WLSaveNotecard", onSaveNotecard, comboBox);
225 childSetAction("WLDeletePreset", onDeletePreset, comboBox); 230 childSetAction("WLDeletePreset", onDeletePreset, comboBox);
226 231
227 comboBox->setCommitCallback(onChangePresetName); 232 comboBox->setCommitCallback(onChangePresetName);
@@ -837,6 +842,76 @@ void LLFloaterWindLight::onSavePreset(void* userData)
837 842
838 LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); 843 LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback);
839} 844}
845class KVFloaterWindLightNotecardCreatedCallback : public LLInventoryCallback
846{
847public:
848 void fire(const LLUUID& inv_item);
849};
850
851void LLFloaterWindLight::onSaveNotecard(void* userData)
852{
853 // get the name
854 LLComboBox* comboBox = sWindLight->getChild<LLComboBox>(
855 "WLPresetsCombo");
856
857 // don't save the empty name
858 if(comboBox->getSelectedItemLabel() == "")
859 {
860 return;
861 }
862
863 // Check if this is already a notecard.
864 if(LLWLParamManager::instance()->mCurParams.mInventoryID.notNull())
865 {
866 LLNotifications::instance().add("KittyWLSaveNotecardAlert", LLSD(), LLSD(), saveNotecardCallback);
867 }
868 else
869 {
870 // Make sure we have a ".wl" extension.
871 std::string name = comboBox->getSelectedItemLabel();
872 if(name.length() > 2 && name.compare(name.length() - 3, 3, ".wl") != 0)
873 {
874 name += ".wl";
875 }
876 LLPointer<KVFloaterWindLightNotecardCreatedCallback> cb = new KVFloaterWindLightNotecardCreatedCallback();
877 // Create a notecard and then save it.
878 create_inventory_item(gAgent.getID(),
879 gAgent.getSessionID(),
880 LLUUID::null,
881 LLTransactionID::tnull,
882 name,
883 "WindLight settings (Kitty Viewer compatible)",
884 LLAssetType::AT_NOTECARD,
885 LLInventoryType::IT_NOTECARD,
886 NOT_WEARABLE,
887 PERM_ITEM_UNRESTRICTED,
888 cb);
889
890 }
891}
892
893void KVFloaterWindLightNotecardCreatedCallback::fire(const LLUUID& inv_item)
894{
895 LLWLParamManager * param_mgr = LLWLParamManager::instance();
896 param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams);
897 param_mgr->mParamList[param_mgr->mCurParams.mName].mInventoryID = inv_item;
898 param_mgr->mCurParams.mInventoryID = inv_item;
899 LL_INFOS("WindLight") << "Created inventory item " << inv_item << LL_ENDL;
900 param_mgr->savePresetToNotecard(param_mgr->mCurParams.mName);
901}
902
903bool LLFloaterWindLight::saveNotecardCallback(const LLSD& notification, const LLSD& response)
904{
905 S32 option = LLNotification::getSelectedOption(notification, response);
906 // if they choose save, do it. Otherwise, don't do anything
907 if(option == 0)
908 {
909 LLWLParamManager * param_mgr = LLWLParamManager::instance();
910 param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams);
911 param_mgr->savePresetToNotecard(param_mgr->mCurParams.mName);
912 }
913 return false;
914}
840 915
841bool LLFloaterWindLight::saveAlertCallback(const LLSD& notification, const LLSD& response) 916bool LLFloaterWindLight::saveAlertCallback(const LLSD& notification, const LLSD& response)
842{ 917{
@@ -948,9 +1023,10 @@ void LLFloaterWindLight::onChangePresetName(LLUICtrl* ctrl, void * userData)
948 { 1023 {
949 return; 1024 return;
950 } 1025 }
951 1026 //impfixme fix of an mystherious crash? : kittyviewer: if(!data.empty())
952 LLWLParamManager::instance()->loadPreset( 1027 //
953 combo_box->getSelectedValue().asString()); 1028 LLWLParamManager::instance()->loadPreset(combo_box->getSelectedValue().asString());
1029 LL_INFOS("WindLight") << "Current inventory ID: " << LLWLParamManager::instance()->mCurParams.mInventoryID << LL_ENDL;
954 sWindLight->syncMenu(); 1030 sWindLight->syncMenu();
955} 1031}
956 1032
diff --git a/linden/indra/newview/llfloaterwindlight.h b/linden/indra/newview/llfloaterwindlight.h
index 23e3056..9656803 100644
--- a/linden/indra/newview/llfloaterwindlight.h
+++ b/linden/indra/newview/llfloaterwindlight.h
@@ -91,9 +91,15 @@ public:
91 /// when user hits the load preset button 91 /// when user hits the load preset button
92 static void onNewPreset(void* userData); 92 static void onNewPreset(void* userData);
93 93
94 /// when user hits the save preset button 94 /// when user hits the save to file button
95 static void onSavePreset(void* userData); 95 static void onSavePreset(void* userData);
96 96
97 /// when user hits the save to inventory button
98 static void onSaveNotecard(void* userData);
99
100 /// prompts a user when overwriting a preset notecard
101 static bool saveNotecardCallback(const LLSD& notification, const LLSD& response);
102
97 /// prompts a user when overwriting a preset 103 /// prompts a user when overwriting a preset
98 static bool saveAlertCallback(const LLSD& notification, const LLSD& response); 104 static bool saveAlertCallback(const LLSD& notification, const LLSD& response);
99 105
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp
index 74fa8f3..b3c2b0b 100644
--- a/linden/indra/newview/llwlparammanager.cpp
+++ b/linden/indra/newview/llwlparammanager.cpp
@@ -67,6 +67,10 @@
67#include "llmemorystream.h" 67#include "llmemorystream.h"
68#include "llnotify.h" 68#include "llnotify.h"
69#include "llagent.h" 69#include "llagent.h"
70#include "llinventorymodel.h"
71#include "llviewerinventory.h"
72#include "llviewerregion.h"
73#include "llassetuploadresponders.h"
70 74
71#include "curl/curl.h" 75#include "curl/curl.h"
72 76
@@ -243,7 +247,7 @@ void LLWLParamManager::loadPresetNotecard(const std::string& name, const LLUUID&
243 asset_id, 247 asset_id,
244 LLAssetType::AT_NOTECARD, 248 LLAssetType::AT_NOTECARD,
245 &loadWindlightNotecard, 249 &loadWindlightNotecard,
246 (void*)name.c_str()); 250 (void*)&inv_id);
247} 251}
248 252
249void LLWLParamManager::savePresets(const std::string & fileName) 253void LLWLParamManager::savePresets(const std::string & fileName)
@@ -269,6 +273,63 @@ void LLWLParamManager::savePresets(const std::string & fileName)
269 formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); 273 formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
270 274
271 presetsXML.close(); 275 presetsXML.close();
276
277 propagateParameters();
278}
279
280bool LLWLParamManager::savePresetToNotecard(const std::string & name)
281{
282 // make an empty llsd
283 LLSD paramsData(LLSD::emptyMap());
284
285 // fill it with LLSD windlight params
286 paramsData = mParamList[name].getAll();
287
288 // get some XML
289 std::ostringstream presetsXML;
290 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
291 formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
292
293 // Write it to a notecard
294 LLNotecard notecard;
295 notecard.setText(presetsXML.str());
296
297 LLInventoryItem *item = gInventory.getItem(mParamList[name].mInventoryID);
298 if(!item)
299 {
300 mParamList[name].mInventoryID = LLUUID::null;
301 return false;
302 }
303 std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory");
304 if(!agent_url.empty())
305 {
306 LLTransactionID tid;
307 LLAssetID asset_id;
308 tid.generate();
309 asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
310
311 LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND);
312
313 std::ostringstream stream;
314 notecard.exportStream(stream);
315 std::string buffer = stream.str();
316
317 S32 size = buffer.length() + 1;
318 file.setMaxSize(size);
319 file.write((U8*)buffer.c_str(), size);
320 LLSD body;
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));
324 }
325 else
326 {
327 LL_WARNS("WindLight") << "Stuff the legacy system." << LL_ENDL;
328 return false;
329 }
330
331 propagateParameters();
332 return true;
272} 333}
273 334
274void LLWLParamManager::loadPreset(const std::string & name,bool propagate) 335void LLWLParamManager::loadPreset(const std::string & name,bool propagate)
@@ -659,7 +720,14 @@ LLWLParamManager * LLWLParamManager::instance()
659 720
660void LLWLParamManager::loadWindlightNotecard(LLVFS *vfs, const LLUUID& asset_id, LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status) 721void LLWLParamManager::loadWindlightNotecard(LLVFS *vfs, const LLUUID& asset_id, LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status)
661{ 722{
662 std::string name = std::string((char*)user_data); 723 LLUUID inventory_id(*((LLUUID*)user_data));
724 std::string name = "WindLight Setting.wl";
725 LLViewerInventoryItem *item = gInventory.getItem(inventory_id);
726 if(item)
727 {
728 inventory_id = item->getUUID();
729 name = item->getName();
730 }
663 if(LL_ERR_NOERR == status) 731 if(LL_ERR_NOERR == status)
664 { 732 {
665 LLVFile file(vfs, asset_id, asset_type, LLVFile::READ); 733 LLVFile file(vfs, asset_id, asset_type, LLVFile::READ);
@@ -685,6 +753,11 @@ void LLWLParamManager::loadWindlightNotecard(LLVFS *vfs, const LLUUID& asset_id,
685 subs["NAME"] = name; 753 subs["NAME"] = name;
686 LLNotifications::getInstance()->add("KittyInvalidWindlightNotecard", subs); 754 LLNotifications::getInstance()->add("KittyInvalidWindlightNotecard", subs);
687 } 755 }
756 else
757 {
758 // We can do this because we know mCurParams
759 sInstance->mParamList[name].mInventoryID = inventory_id;
760 }
688 } 761 }
689} 762}
690 763
diff --git a/linden/indra/newview/llwlparammanager.h b/linden/indra/newview/llwlparammanager.h
index c506c11..612a507 100644
--- a/linden/indra/newview/llwlparammanager.h
+++ b/linden/indra/newview/llwlparammanager.h
@@ -154,9 +154,12 @@ public:
154 154
155 /// Load an individual preset from a notecard. 155 /// Load an individual preset from a notecard.
156 void loadPresetNotecard(const std::string& name, const LLUUID& asset_id, const LLUUID& inv_id); 156 void loadPresetNotecard(const std::string& name, const LLUUID& asset_id, const LLUUID& inv_id);
157 157
158 /// save the parameter presets to file 158 /// save the parameter presets to file
159 void savePreset(const std::string & name); 159 void savePreset(const std::string & name);
160
161 /// save the parameter presets to file
162 bool savePresetToNotecard(const std::string & name);
160 163
161 /// Set shader uniforms dirty, so they'll update automatically. 164 /// Set shader uniforms dirty, so they'll update automatically.
162 void propagateParameters(void); 165 void propagateParameters(void);
diff --git a/linden/indra/newview/llwlparamset.h b/linden/indra/newview/llwlparamset.h
index 21d646f..038490d 100644
--- a/linden/indra/newview/llwlparamset.h
+++ b/linden/indra/newview/llwlparamset.h
@@ -49,7 +49,8 @@ class LLWLParamSet {
49 friend class LLWLParamManager; 49 friend class LLWLParamManager;
50 50
51public: 51public:
52 std::string mName; 52 std::string mName;
53 LLUUID mInventoryID;
53 54
54private: 55private:
55 56
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_windlight_options.xml b/linden/indra/newview/skins/default/xui/en-us/floater_windlight_options.xml
index 471b3e5..529ed63 100644
--- a/linden/indra/newview/skins/default/xui/en-us/floater_windlight_options.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/floater_windlight_options.xml
@@ -24,10 +24,13 @@
24 label="New" label_selected="New" left_delta="40" 24 label="New" label_selected="New" left_delta="40"
25 mouse_opaque="true" name="WLNewPreset" scale_image="true" width="70" /> 25 mouse_opaque="true" name="WLNewPreset" 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="WLSavePreset" scale_image="true" width="70" /> 28 mouse_opaque="true" name="WLSavePreset" 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="Delete" label_selected="Delete" left_delta="70" 30 label="Save to Inventory" label_selected="Save" left_delta="70"
31 mouse_opaque="true" name="WLSaveNotecard" scale_image="true" width="70" />
32 <button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20"
33 label="Delete File" label_selected="Delete" left_delta="70"
31 mouse_opaque="true" name="WLDeletePreset" scale_image="true" width="70" /> 34 mouse_opaque="true" name="WLDeletePreset" scale_image="true" width="70" />
32 <button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20" 35 <button bottom_delta="0" enabled="true" font="SansSerif" halign="center" height="20"
33 label="Day Cycle Editor" label_selected="Day Cycle Editor" 36 label="Day Cycle Editor" label_selected="Day Cycle Editor"