diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaterwindlight.cpp | 82 |
1 files changed, 79 insertions, 3 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 | } |
845 | class KVFloaterWindLightNotecardCreatedCallback : public LLInventoryCallback | ||
846 | { | ||
847 | public: | ||
848 | void fire(const LLUUID& inv_item); | ||
849 | }; | ||
850 | |||
851 | void 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 | |||
893 | void 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 | |||
903 | bool 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 | ||
841 | bool LLFloaterWindLight::saveAlertCallback(const LLSD& notification, const LLSD& response) | 916 | bool 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 | ||