diff options
Diffstat (limited to 'indra/newview/llfloaterdaycycle.cpp')
-rw-r--r-- | indra/newview/llfloaterdaycycle.cpp | 406 |
1 files changed, 200 insertions, 206 deletions
diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp index 22816ee802..9fcfc41f77 100644 --- a/indra/newview/llfloaterdaycycle.cpp +++ b/indra/newview/llfloaterdaycycle.cpp @@ -41,6 +41,8 @@ #include "llcombobox.h" #include "lllineeditor.h" #include "llwlanimator.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "v4math.h" #include "llviewerdisplay.h" @@ -51,34 +53,29 @@ #include "llwlparammanager.h" #include "llpostprocess.h" #include "llfloaterwindlight.h" +//#include "llwindlightscrubbers.h" // *HACK commented out since this code isn't released (yet) +#include "llenvmanager.h" +#include "llfloaterreg.h" - -std::map<std::string, LLWLSkyKey> LLFloaterDayCycle::sSliderToKey; +LLFloaterDayCycle* LLFloaterDayCycle::sDayCycle = NULL; const F32 LLFloaterDayCycle::sHoursPerDay = 24.0f; +std::map<std::string, LLWLCycleSliderKey> LLFloaterDayCycle::sSliderToKey; +LLEnvKey::EScope LLFloaterDayCycle::sScope; +std::string LLFloaterDayCycle::sOriginalTitle; +LLWLAnimator::ETime LLFloaterDayCycle::sPreviousTimeType = LLWLAnimator::TIME_LINDEN; -LLFloaterDayCycle::LLFloaterDayCycle(const LLSD& key) -: LLFloater(key) +LLFloaterDayCycle::LLFloaterDayCycle(const LLSD &key) : LLFloater(key) { } +// virtual BOOL LLFloaterDayCycle::postBuild() { - // add the combo boxes - LLComboBox* keyCombo = getChild<LLComboBox>("WLKeyPresets"); - - if(keyCombo != NULL) - { - keyCombo->removeall(); - std::map<std::string, LLWLParamSet>::iterator mIt = - LLWLParamManager::instance()->mParamList.begin(); - for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) - { - keyCombo->add(std::string(mIt->first)); - } + sOriginalTitle = getTitle(); - // set defaults on combo boxes - keyCombo->selectFirstItem(); - } + // *HACK commented out since this code isn't released (yet) + //llassert(LLWLPacketScrubber::MAX_LOCAL_KEY_FRAMES <= getChild<LLMultiSliderCtrl>("WLDayCycleKeys")->getMaxValue() && + // LLWLPacketScrubber::MAX_REGION_KEY_FRAMES <= getChild<LLMultiSliderCtrl>("WLDayCycleKeys")->getMaxValue()); // add the time slider LLMultiSliderCtrl* sldr = getChild<LLMultiSliderCtrl>("WLTimeSlider"); @@ -88,9 +85,6 @@ BOOL LLFloaterDayCycle::postBuild() // load it up initCallbacks(); - syncMenu(); - syncSliderTrack(); - return TRUE; } @@ -98,79 +92,64 @@ LLFloaterDayCycle::~LLFloaterDayCycle() { } +void LLFloaterDayCycle::onClickHelp(void* data) +{ + std::string xml_alert = *(std::string *) data; + LLNotifications::instance().add(xml_alert, LLSD(), LLSD()); +} + +void LLFloaterDayCycle::initHelpBtn(const std::string& name, const std::string& xml_alert) +{ + childSetAction(name, onClickHelp, new std::string(xml_alert)); +} + void LLFloaterDayCycle::initCallbacks(void) { + initHelpBtn("WLDayCycleHelp", "HelpDayCycle"); + // WL Day Cycle - getChild<LLUICtrl>("WLTimeSlider")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onTimeSliderMoved, this, _1)); - getChild<LLUICtrl>("WLDayCycleKeys")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onKeyTimeMoved, this, _1)); - getChild<LLUICtrl>("WLCurKeyHour")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onKeyTimeChanged, this, _1)); - getChild<LLUICtrl>("WLCurKeyMin")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onKeyTimeChanged, this, _1)); - getChild<LLUICtrl>("WLKeyPresets")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onKeyPresetChanged, this, _1)); - - getChild<LLUICtrl>("WLLengthOfDayHour")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onTimeRateChanged, this, _1)); - getChild<LLUICtrl>("WLLengthOfDayMin")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onTimeRateChanged, this, _1)); - getChild<LLUICtrl>("WLLengthOfDaySec")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onTimeRateChanged, this, _1)); - getChild<LLUICtrl>("WLUseLindenTime")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onUseLindenTime, this, _1)); - getChild<LLUICtrl>("WLAnimSky")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onRunAnimSky, this, _1)); - getChild<LLUICtrl>("WLStopAnimSky")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onStopAnimSky, this, _1)); - - getChild<LLUICtrl>("WLLoadDayCycle")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onLoadDayCycle, this, _1)); - getChild<LLUICtrl>("WLSaveDayCycle")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onSaveDayCycle, this, _1)); - - getChild<LLUICtrl>("WLAddKey")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onAddKey, this, _1)); - getChild<LLUICtrl>("WLDeleteKey")->setCommitCallback(boost::bind(&LLFloaterDayCycle::onDeleteKey, this, _1)); + childSetCommitCallback("WLTimeSlider", onTimeSliderMoved, NULL); + childSetCommitCallback("WLDayCycleKeys", onKeyTimeMoved, NULL); + childSetCommitCallback("WLCurKeyHour", onKeyTimeChanged, NULL); + childSetCommitCallback("WLCurKeyMin", onKeyTimeChanged, NULL); + childSetCommitCallback("WLKeyPresets", onKeyPresetChanged, NULL); + + childSetAction("WLAddKey", onAddKey, NULL); + childSetAction("WLDeleteKey", onDeleteKey, NULL); } void LLFloaterDayCycle::syncMenu() { -// std::map<std::string, LLVector4> & currentParams = LLWLParamManager::instance()->mCurParams.mParamValues; - // set time - LLMultiSliderCtrl* sldr = getChild<LLMultiSliderCtrl>("WLTimeSlider"); - sldr->setCurSliderValue((F32)LLWLParamManager::instance()->mAnimator.getDayTime() * sHoursPerDay); - - LLSpinCtrl* secSpin = getChild<LLSpinCtrl>("WLLengthOfDaySec"); - LLSpinCtrl* minSpin = getChild<LLSpinCtrl>("WLLengthOfDayMin"); - LLSpinCtrl* hourSpin = getChild<LLSpinCtrl>("WLLengthOfDayHour"); - - F32 curRate; - F32 hours, min, sec; - - // get the current rate - curRate = LLWLParamManager::instance()->mDay.mDayRate; - hours = (F32)((int)(curRate / 60 / 60)); - curRate -= (hours * 60 * 60); - min = (F32)((int)(curRate / 60)); - curRate -= (min * 60); - sec = curRate; - - hourSpin->setValue(hours); - minSpin->setValue(min); - secSpin->setValue(sec); + LLMultiSliderCtrl* sldr = LLFloaterDayCycle::sDayCycle->getChild<LLMultiSliderCtrl>("WLTimeSlider"); + sldr->setCurSliderValue((F32)LLWLParamManager::getInstance()->mAnimator.getDayTime() * sHoursPerDay); // turn off Use Estate Time button if it's already being used - if( LLWLParamManager::instance()->mAnimator.mUseLindenTime == true) + if( LLWLParamManager::getInstance()->mAnimator.getUseLindenTime()) { - getChildView("WLUseLindenTime")->setEnabled(FALSE); + LLFloaterDayCycle::sDayCycle->childDisable("WLUseLindenTime"); } else { - getChildView("WLUseLindenTime")->setEnabled(TRUE); + LLFloaterDayCycle::sDayCycle->childEnable("WLUseLindenTime"); } } void LLFloaterDayCycle::syncSliderTrack() { // clear the slider - LLMultiSliderCtrl* kSldr = getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); + LLMultiSliderCtrl* kSldr = sDayCycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); kSldr->clear(); sSliderToKey.clear(); // add sliders - std::map<F32, std::string>::iterator mIt = - LLWLParamManager::instance()->mDay.mTimeMap.begin(); - for(; mIt != LLWLParamManager::instance()->mDay.mTimeMap.end(); mIt++) + + lldebugs << "Adding " << LLWLParamManager::getInstance()->mDay.mTimeMap.size() << " keys to slider" << llendl; + + std::map<F32, LLWLParamKey>::iterator mIt = + LLWLParamManager::getInstance()->mDay.mTimeMap.begin(); + for(; mIt != LLWLParamManager::getInstance()->mDay.mTimeMap.end(); mIt++) { addSliderKey(mIt->first * sHoursPerDay, mIt->second); } @@ -178,136 +157,151 @@ void LLFloaterDayCycle::syncSliderTrack() void LLFloaterDayCycle::syncTrack() { + lldebugs << "Syncing track (" << sSliderToKey.size() << ")" << llendl; + // if no keys, do nothing if(sSliderToKey.size() == 0) { + lldebugs << "No keys, not syncing" << llendl; return; } LLMultiSliderCtrl* sldr; - sldr = getChild<LLMultiSliderCtrl>( + sldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLDayCycleKeys"); llassert_always(sSliderToKey.size() == sldr->getValue().size()); LLMultiSliderCtrl* tSldr; - tSldr = getChild<LLMultiSliderCtrl>( + tSldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLTimeSlider"); // create a new animation track - LLWLParamManager::instance()->mDay.clearKeys(); + LLWLParamManager::getInstance()->mDay.clearKeyframes(); // add the keys one by one - std::map<std::string, LLWLSkyKey>::iterator mIt = sSliderToKey.begin(); + std::map<std::string, LLWLCycleSliderKey>::iterator mIt = sSliderToKey.begin(); for(; mIt != sSliderToKey.end(); mIt++) { - LLWLParamManager::instance()->mDay.addKey(mIt->second.time / sHoursPerDay, - mIt->second.presetName); + LLWLParamManager::getInstance()->mDay.addKeyframe(mIt->second.time / sHoursPerDay, + mIt->second.keyframe); } // set the param manager's track to the new one - LLWLParamManager::instance()->resetAnimator( + LLWLParamManager::getInstance()->resetAnimator( tSldr->getCurSliderValue() / sHoursPerDay, false); - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } -void LLFloaterDayCycle::onRunAnimSky(LLUICtrl* ctrl) +void LLFloaterDayCycle::refreshPresetsFromParamManager() { - // if no keys, do nothing - if(sSliderToKey.size() == 0) - { - return; - } - - LLMultiSliderCtrl* sldr; - sldr = getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); - llassert_always(sSliderToKey.size() == sldr->getValue().size()); + LLComboBox* keyCombo = sDayCycle->getChild<LLComboBox>("WLKeyPresets"); - LLMultiSliderCtrl* tSldr; - tSldr = getChild<LLMultiSliderCtrl>("WLTimeSlider"); - - // turn off linden time - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; - - // set the param manager's track to the new one - LLWLParamManager::instance()->resetAnimator( - tSldr->getCurSliderValue() / sHoursPerDay, true); + if(keyCombo != NULL) + { + LLWLParamManager::preset_key_list_t preset_keys; + LLWLParamManager::instance().getPresetKeys(preset_keys); + for (LLWLParamManager::preset_key_list_t::const_iterator it = preset_keys.begin(); it != preset_keys.end(); ++it) + { + if (it->scope <= sScope) + { + const LLWLParamKey& key = *it; + llinfos << "Adding key: " << key.toString() << llendl; + keyCombo->add(key.toString(), LLSD(key.toStringVal())); + } + } - llassert_always(LLWLParamManager::instance()->mAnimator.mTimeTrack.size() == sldr->getValue().size()); + // set defaults on combo boxes + keyCombo->selectFirstItem(); + } } -void LLFloaterDayCycle::onStopAnimSky(LLUICtrl* ctrl) +// static +LLFloaterDayCycle* LLFloaterDayCycle::instance() { - // if no keys, do nothing - if(sSliderToKey.size() == 0) { - return; + if (!sDayCycle) + { + lldebugs << "Instantiating Day Cycle floater" << llendl; + sDayCycle = LLFloaterReg::getTypedInstance<LLFloaterDayCycle>("env_day_cycle"); + llassert(sDayCycle); + // sDayCycle->open(); + // sDayCycle->setFocus(TRUE); } - - // turn off animation and using linden time - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + return sDayCycle; } -void LLFloaterDayCycle::onUseLindenTime(LLUICtrl* ctrl) +bool LLFloaterDayCycle::isOpen() { - LLComboBox* box = getChild<LLComboBox>("WLPresetsCombo"); - box->selectByValue(""); - - LLWLParamManager::instance()->mAnimator.mIsRunning = true; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; + if (sDayCycle != NULL) + { + return true; + } + return false; } -void LLFloaterDayCycle::onLoadDayCycle(LLUICtrl* ctrl) +void LLFloaterDayCycle::show(LLEnvKey::EScope scope) { - LLWLParamManager::instance()->mDay.loadDayCycle("Default.xml"); - - // sync it all up + LLFloaterDayCycle* dayCycle = instance(); + if(scope != sScope && ((LLView*)dayCycle)->getVisible()) + { + LLNotifications::instance().add("EnvOtherScopeAlreadyOpen", LLSD(), LLSD()); + return; + } + sScope = scope; + std::string title = sOriginalTitle + " (" + LLEnvManager::getScopeString(sScope) + ")"; + dayCycle->setTitle(title); + refreshPresetsFromParamManager(); + dayCycle->syncMenu(); syncSliderTrack(); - syncMenu(); - // set the param manager's track to the new one - LLMultiSliderCtrl* tSldr; - tSldr = getChild<LLMultiSliderCtrl>( - "WLTimeSlider"); - LLWLParamManager::instance()->resetAnimator( - tSldr->getCurSliderValue() / sHoursPerDay, false); + // set drop-down menu to match preset of currently-selected keyframe (one is automatically selected initially) + const std::string& curSldr = sDayCycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys")->getCurSlider(); + if(strlen(curSldr.c_str()) > 0) // only do this if there is a curSldr, otherwise we put an invalid entry into the map + { + sDayCycle->getChild<LLComboBox>("WLKeyPresets")->selectByValue(sSliderToKey[curSldr].keyframe.toStringVal()); + } + + // comment in if you want the menu to rebuild each time + //LLUICtrlFactory::getInstance()->buildFloater(dayCycle, "floater_day_cycle_options.xml"); + //dayCycle->initCallbacks(); - // and draw it - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + dayCycle->openFloater(); } -void LLFloaterDayCycle::onSaveDayCycle(LLUICtrl* ctrl) +// virtual +void LLFloaterDayCycle::onClose(bool app_quitting) { - LLWLParamManager::instance()->mDay.saveDayCycle("Default.xml"); + if (sDayCycle) + { + lldebugs << "Destorying Day Cycle floater" << llendl; + sDayCycle = NULL; + } } - -void LLFloaterDayCycle::onTimeSliderMoved(LLUICtrl* ctrl) +void LLFloaterDayCycle::onTimeSliderMoved(LLUICtrl* ctrl, void* userData) { - LLMultiSliderCtrl* sldr = getChild<LLMultiSliderCtrl>( + LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLTimeSlider"); /// get the slider value F32 val = sldr->getCurSliderValue() / sHoursPerDay; // set the value, turn off animation - LLWLParamManager::instance()->mAnimator.setDayTime((F64)val); - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val); + LLWLParamManager::getInstance()->mAnimator.deactivate(); // then call update once - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } -void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl) +void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl, void* userData) { - LLComboBox* comboBox = getChild<LLComboBox>("WLKeyPresets"); - LLMultiSliderCtrl* sldr = getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); - LLSpinCtrl* hourSpin = getChild<LLSpinCtrl>("WLCurKeyHour"); - LLSpinCtrl* minSpin = getChild<LLSpinCtrl>("WLCurKeyMin"); + LLComboBox* comboBox = sDayCycle->getChild<LLComboBox>("WLKeyPresets"); + LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); + LLSpinCtrl* hourSpin = sDayCycle->getChild<LLSpinCtrl>("WLCurKeyHour"); + LLSpinCtrl* minSpin = sDayCycle->getChild<LLSpinCtrl>("WLCurKeyMin"); if(sldr->getValue().size() == 0) { return; @@ -322,11 +316,11 @@ void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl) F32 time = sldr->getCurSliderValue(); // check to see if a key exists - std::string presetName = sSliderToKey[curSldr].presetName; + LLWLParamKey key = sSliderToKey[curSldr].keyframe; sSliderToKey[curSldr].time = time; // if it exists, turn on check box - comboBox->selectByValue(presetName); + comboBox->selectByValue(key.toStringVal()); // now set the spinners F32 hour = (F32)((S32)time); @@ -345,18 +339,18 @@ void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl) } -void LLFloaterDayCycle::onKeyTimeChanged(LLUICtrl* ctrl) +void LLFloaterDayCycle::onKeyTimeChanged(LLUICtrl* ctrl, void* userData) { // if no keys, skipped if(sSliderToKey.size() == 0) { return; } - LLMultiSliderCtrl* sldr = getChild<LLMultiSliderCtrl>( + LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLDayCycleKeys"); - LLSpinCtrl* hourSpin = getChild<LLSpinCtrl>( + LLSpinCtrl* hourSpin = sDayCycle->getChild<LLSpinCtrl>( "WLCurKeyHour"); - LLSpinCtrl* minSpin = getChild<LLSpinCtrl>( + LLSpinCtrl* minSpin = sDayCycle->getChild<LLSpinCtrl>( "WLCurKeyMin"); F32 hour = hourSpin->get(); @@ -368,18 +362,17 @@ void LLFloaterDayCycle::onKeyTimeChanged(LLUICtrl* ctrl) F32 time = sldr->getCurSliderValue() / sHoursPerDay; // now set the key's time in the sliderToKey map - std::string presetName = sSliderToKey[curSldr].presetName; sSliderToKey[curSldr].time = time; syncTrack(); } -void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl) +void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl, void* userData) { // get the time - LLComboBox* comboBox = getChild<LLComboBox>( + LLComboBox* comboBox = sDayCycle->getChild<LLComboBox>( "WLKeyPresets"); - LLMultiSliderCtrl* sldr = getChild<LLMultiSliderCtrl>( + LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLDayCycleKeys"); // do nothing if no sliders @@ -388,7 +381,9 @@ void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl) } // change the map - std::string newPreset(comboBox->getSelectedValue().asString()); + + std::string stringVal = comboBox->getSelectedValue().asString(); + LLWLParamKey newKey(stringVal); const std::string& curSldr = sldr->getCurSlider(); // if null, don't use @@ -396,62 +391,57 @@ void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl) return; } - sSliderToKey[curSldr].presetName = newPreset; + sSliderToKey[curSldr].keyframe = newKey; syncTrack(); } -void LLFloaterDayCycle::onTimeRateChanged(LLUICtrl* ctrl) +void LLFloaterDayCycle::onAddKey(void* userData) { - // get the time - LLSpinCtrl* secSpin = getChild<LLSpinCtrl>( - "WLLengthOfDaySec"); - - LLSpinCtrl* minSpin = getChild<LLSpinCtrl>( - "WLLengthOfDayMin"); - - LLSpinCtrl* hourSpin = getChild<LLSpinCtrl>( - "WLLengthOfDayHour"); - - F32 hour; - hour = (F32)hourSpin->getValue().asReal(); - F32 min; - min = (F32)minSpin->getValue().asReal(); - F32 sec; - sec = (F32)secSpin->getValue().asReal(); - - F32 time = 60.0f * 60.0f * hour + 60.0f * min + sec; - if(time <= 0) { - time = 1; - } - LLWLParamManager::instance()->mDay.mDayRate = time; - - syncTrack(); -} - -void LLFloaterDayCycle::onAddKey(LLUICtrl* ctrl) -{ - LLComboBox* comboBox = getChild<LLComboBox>( + LLComboBox* comboBox = sDayCycle->getChild<LLComboBox>( "WLKeyPresets"); - LLMultiSliderCtrl* kSldr = getChild<LLMultiSliderCtrl>( + LLMultiSliderCtrl* kSldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLDayCycleKeys"); - LLMultiSliderCtrl* tSldr = getChild<LLMultiSliderCtrl>( + LLMultiSliderCtrl* tSldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLTimeSlider"); llassert_always(sSliderToKey.size() == kSldr->getValue().size()); + S32 max_sliders; + switch(sScope) + { + case LLEnvKey::SCOPE_LOCAL: + max_sliders = 20; // *HACK this should be LLWLPacketScrubber::MAX_LOCAL_KEY_FRAMES; + break; + case LLEnvKey::SCOPE_REGION: + max_sliders = 12; // *HACK this should be LLWLPacketScrubber::MAX_REGION_KEY_FRAMES; + break; + default: + max_sliders = (S32)kSldr->getMaxValue(); + break; + } + + if ((S32)sSliderToKey.size() >= max_sliders) + { + LLSD args; + args["SCOPE"] = LLEnvManager::getScopeString(sScope); + args["MAX"] = max_sliders; + LLNotificationsUtil::add("DayCycleTooManyKeyframes", args, LLSD(), LLNotificationFunctorRegistry::instance().DONOTHING); + return; + } + // get the values - std::string newPreset(comboBox->getSelectedValue().asString()); + LLWLParamKey newKeyframe(comboBox->getSelectedValue()); // add the slider key - addSliderKey(tSldr->getCurSliderValue(), newPreset); + addSliderKey(tSldr->getCurSliderValue(), newKeyframe); syncTrack(); } -void LLFloaterDayCycle::addSliderKey(F32 time, const std::string & presetName) +void LLFloaterDayCycle::addSliderKey(F32 time, LLWLParamKey keyframe) { - LLMultiSliderCtrl* kSldr = getChild<LLMultiSliderCtrl>( + LLMultiSliderCtrl* kSldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLDayCycleKeys"); // make a slider @@ -461,30 +451,28 @@ void LLFloaterDayCycle::addSliderKey(F32 time, const std::string & presetName) } // set the key - LLWLSkyKey newKey; - newKey.presetName = presetName; - newKey.time = kSldr->getCurSliderValue(); + LLWLCycleSliderKey newKey(keyframe, kSldr->getCurSliderValue()); llassert_always(sldrName != LLStringUtil::null); // add to map - sSliderToKey.insert(std::pair<std::string, LLWLSkyKey>(sldrName, newKey)); + sSliderToKey.insert(std::pair<std::string, LLWLCycleSliderKey>(sldrName, newKey)); llassert_always(sSliderToKey.size() == kSldr->getValue().size()); } -void LLFloaterDayCycle::deletePreset(std::string& presetName) +void LLFloaterDayCycle::deletePreset(LLWLParamKey keyframe) { - LLMultiSliderCtrl* sldr = getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); + LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); /// delete any reference - std::map<std::string, LLWLSkyKey>::iterator curr_preset, next_preset; + std::map<std::string, LLWLCycleSliderKey>::iterator curr_preset, next_preset; for(curr_preset = sSliderToKey.begin(); curr_preset != sSliderToKey.end(); curr_preset = next_preset) { next_preset = curr_preset; ++next_preset; - if (curr_preset->second.presetName == presetName) + if (curr_preset->second.keyframe == keyframe) { sldr->deleteSlider(curr_preset->first); sSliderToKey.erase(curr_preset); @@ -492,19 +480,25 @@ void LLFloaterDayCycle::deletePreset(std::string& presetName) } } -void LLFloaterDayCycle::onDeleteKey(LLUICtrl* ctrl) +void LLFloaterDayCycle::onDeleteKey(void* userData) { - if(sSliderToKey.size() == 0) { + if(sSliderToKey.size() == 0) + { + return; + } + else if(sSliderToKey.size() == 1) + { + LLNotifications::instance().add("EnvCannotDeleteLastDayCycleKey", LLSD(), LLSD()); return; } - LLComboBox* comboBox = getChild<LLComboBox>( + LLComboBox* comboBox = sDayCycle->getChild<LLComboBox>( "WLKeyPresets"); - LLMultiSliderCtrl* sldr = getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); + LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); // delete from map const std::string& sldrName = sldr->getCurSlider(); - std::map<std::string, LLWLSkyKey>::iterator mIt = sSliderToKey.find(sldrName); + std::map<std::string, LLWLCycleSliderKey>::iterator mIt = sSliderToKey.find(sldrName); sSliderToKey.erase(mIt); sldr->deleteCurSlider(); @@ -514,11 +508,11 @@ void LLFloaterDayCycle::onDeleteKey(LLUICtrl* ctrl) } const std::string& name = sldr->getCurSlider(); - comboBox->selectByValue(sSliderToKey[name].presetName); + comboBox->selectByValue(sSliderToKey[name].keyframe.toLLSD()); F32 time = sSliderToKey[name].time; - LLSpinCtrl* hourSpin = getChild<LLSpinCtrl>("WLCurKeyHour"); - LLSpinCtrl* minSpin = getChild<LLSpinCtrl>("WLCurKeyMin"); + LLSpinCtrl* hourSpin = sDayCycle->getChild<LLSpinCtrl>("WLCurKeyHour"); + LLSpinCtrl* minSpin = sDayCycle->getChild<LLSpinCtrl>("WLCurKeyMin"); // now set the spinners F32 hour = (F32)((S32)time); |