From 89315b7e2649015845b7649133a5a19cbba717ac Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sun, 29 Aug 2010 10:38:03 -0700 Subject: Tidied up the sky/water editors (both use a flyout_button to save now). Still some non-trivial bugs to fix, specifically: #474 and #475. Both have repros --- linden/indra/newview/llfloaterwater.cpp | 118 +++++++++++++++----------------- 1 file changed, 55 insertions(+), 63 deletions(-) (limited to 'linden/indra/newview/llfloaterwater.cpp') diff --git a/linden/indra/newview/llfloaterwater.cpp b/linden/indra/newview/llfloaterwater.cpp index f08beea..05bc001 100644 --- a/linden/indra/newview/llfloaterwater.cpp +++ b/linden/indra/newview/llfloaterwater.cpp @@ -160,9 +160,8 @@ void LLFloaterWater::initCallbacks(void) { //childSetAction("WaterLoadPreset", onLoadPreset, comboBox); childSetAction("WaterNewPreset", onNewPreset, comboBox); - childSetAction("WaterSavePreset", onSavePreset, comboBox); - childSetAction("WaterSaveNotecard", onSaveNotecard, comboBox); childSetAction("WaterDeletePreset", onDeletePreset, comboBox); + childSetCommitCallback("WaterSavePreset", onSavePreset, this); // wave direction childSetCommitCallback("WaterWave1DirX", onVector2ControlXMoved, ¶m_mgr->mWave1Dir); @@ -623,39 +622,23 @@ void LLFloaterWater::onNewPreset(void* userData) LLNotifications::instance().add("NewWaterPreset", LLSD(), LLSD(), newPromptCallback); } -void LLFloaterWater::onSavePreset(void* userData) -{ - // get the name - LLComboBox* comboBox = sWaterMenu->getChild("WaterPresetsCombo"); - - // don't save the empty name - if(comboBox->getSelectedItemLabel() == "") - { - return; - } - - LLWaterParamManager::instance()->mCurParams.mName = - comboBox->getSelectedItemLabel(); - - // check to see if it's a default and shouldn't be overwritten - std::set::iterator sIt = sDefaultPresets.find( - comboBox->getSelectedItemLabel()); - if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("WaterEditPresets")) - { - LLNotifications::instance().add("WLNoEditDefault"); - return; - } - - LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); -} - class KVFloaterWaterNotecardCreatedCallback : public LLInventoryCallback { public: void fire(const LLUUID& inv_item); }; -void LLFloaterWater::onSaveNotecard(void* userData) +void KVFloaterWaterNotecardCreatedCallback::fire(const LLUUID& inv_item) +{ + LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams); + param_mgr->mParamList[param_mgr->mCurParams.mName].mInventoryID = inv_item; + param_mgr->mCurParams.mInventoryID = inv_item; + LL_INFOS("WindLight") << "Created inventory item " << inv_item << LL_ENDL; + param_mgr->savePresetToNotecard(param_mgr->mCurParams.mName); +} + +void LLFloaterWater::onSavePreset(LLUICtrl* ctrl, void* userData) { // get the name LLComboBox* comboBox = sWaterMenu->getChild("WaterPresetsCombo"); @@ -665,47 +648,56 @@ void LLFloaterWater::onSaveNotecard(void* userData) { return; } - - // Check if this is already a notecard. - if(LLWaterParamManager::instance()->mCurParams.mInventoryID.notNull()) + + if (ctrl->getValue().asString() == "save_disk_item") { - LLNotifications::instance().add("KittyWLSaveNotecardAlert", LLSD(), LLSD(), saveNotecardCallback); + LLWaterParamManager::instance()->mCurParams.mName = + comboBox->getSelectedItemLabel(); + + // check to see if it's a default and shouldn't be overwritten + std::set::iterator sIt = sDefaultPresets.find( + comboBox->getSelectedItemLabel()); + if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("WaterEditPresets")) + { + LLNotifications::instance().add("WLNoEditDefault"); + return; + } + + LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); } - else - { - // Make sure we have a ".ww" extension. - std::string name = comboBox->getSelectedItemLabel(); - if(name.length() > 2 && name.compare(name.length() - 3, 3, ".ww") != 0) + else if (ctrl->getValue().asString() == "save_inventory_item") + { + // Check if this is already a notecard. + if(LLWaterParamManager::instance()->mCurParams.mInventoryID.notNull()) { - name += ".ww"; + LLNotifications::instance().add("KittyWLSaveNotecardAlert", LLSD(), LLSD(), saveNotecardCallback); + } + else + { + // Make sure we have a ".ww" extension. + std::string name = comboBox->getSelectedItemLabel(); + if(name.length() > 2 && name.compare(name.length() - 3, 3, ".ww") != 0) + { + name += ".ww"; + } + LLPointer cb = new KVFloaterWaterNotecardCreatedCallback(); + // Create a notecard and then save it. + create_inventory_item(gAgent.getID(), + gAgent.getSessionID(), + LLUUID::null, + LLTransactionID::tnull, + name, + "Water settings (Imprudence compatible)", + LLAssetType::AT_NOTECARD, + LLInventoryType::IT_NOTECARD, + NOT_WEARABLE, + PERM_ITEM_UNRESTRICTED, + cb); + } - LLPointer cb = new KVFloaterWaterNotecardCreatedCallback(); - // Create a notecard and then save it. - create_inventory_item(gAgent.getID(), - gAgent.getSessionID(), - LLUUID::null, - LLTransactionID::tnull, - name, - "Water settings (Kitty Viewer compatible)", - LLAssetType::AT_NOTECARD, - LLInventoryType::IT_NOTECARD, - NOT_WEARABLE, - PERM_ITEM_UNRESTRICTED, - cb); - } } -void KVFloaterWaterNotecardCreatedCallback::fire(const LLUUID& inv_item) -{ - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); - param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams); - param_mgr->mParamList[param_mgr->mCurParams.mName].mInventoryID = inv_item; - param_mgr->mCurParams.mInventoryID = inv_item; - LL_INFOS("WindLight") << "Created inventory item " << inv_item << LL_ENDL; - param_mgr->savePresetToNotecard(param_mgr->mCurParams.mName); -} - bool LLFloaterWater::saveNotecardCallback(const LLSD& notification, const LLSD& response) { S32 option = LLNotification::getSelectedOption(notification, response); -- cgit v1.1