diff --git a/indra/newview/llfloaterwater.cpp b/indra/newview/llfloaterwater.cpp index 90a1931452..d4ec1282f6 100644 --- a/indra/newview/llfloaterwater.cpp +++ b/indra/newview/llfloaterwater.cpp @@ -628,10 +628,8 @@ void LLFloaterWater::onChangePresetName(LLUICtrl* ctrl) } // > Presets prev/next controls -WoLf -void LLFloaterWater::onPrevPreset(void* user_data) +void LLFloaterWater::onPrevPreset() { - LLFloaterWater* self = (LLFloaterWater*) user_data; - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); LLWaterParamSet & currentParams = param_mgr->mCurParams; @@ -650,14 +648,12 @@ void LLFloaterWater::onPrevPreset(void* user_data) mIt--; } param_mgr->loadPreset(mIt->first, true); - LLComboBox* WWcomboBox = self->getChild("WaterPresetsCombo"); + LLComboBox* WWcomboBox = getChild("WaterPresetsCombo"); WWcomboBox->setSimple(mIt->first); } -void LLFloaterWater::onNextPreset(void* user_data) +void LLFloaterWater::onNextPreset() { - LLFloaterWater* self = (LLFloaterWater*) user_data; - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); LLWaterParamSet& currentParams = param_mgr->mCurParams; @@ -676,7 +672,7 @@ void LLFloaterWater::onNextPreset(void* user_data) mIt++; } param_mgr->loadPreset(mIt->first, true); - LLComboBox* WWcomboBox = self->getChild("WaterPresetsCombo"); + LLComboBox* WWcomboBox = getChild("WaterPresetsCombo"); WWcomboBox->setSimple(mIt->first); } // < Presets prev/next controls -WoLf \ No newline at end of file diff --git a/indra/newview/llfloaterwater.h b/indra/newview/llfloaterwater.h index 9e7254b17e..24ba887735 100644 --- a/indra/newview/llfloaterwater.h +++ b/indra/newview/llfloaterwater.h @@ -100,8 +100,8 @@ public: void syncMenu(); /// Preset prev/next controls -WoLf - static void onPrevPreset(void* user_data); - static void onNextPreset(void* user_data); + void onPrevPreset(); + void onNextPreset(); private: static std::set sDefaultPresets; diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp index 4c16fb105b..08fe613466 100644 --- a/indra/newview/llfloaterwindlight.cpp +++ b/indra/newview/llfloaterwindlight.cpp @@ -889,12 +889,9 @@ void LLFloaterWindLight::deactivateAnimator() LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; } - // > Presets prev/next controls -WoLf -void LLFloaterWindLight::onPrevPreset(void* user_data) +void LLFloaterWindLight::onPrevPreset() { - LLFloaterWindLight* self = (LLFloaterWindLight*) user_data; - // find place of current param std::map::iterator mIt = LLWLParamManager::instance()->mParamList.find(LLWLParamManager::instance()->mCurParams.mName); @@ -918,14 +915,12 @@ void LLFloaterWindLight::onPrevPreset(void* user_data) } deactivateAnimator(); LLWLParamManager::instance()->loadPreset(mIt->first, true); - LLComboBox* WLcomboBox = self->getChild("WLPresetsCombo"); + LLComboBox* WLcomboBox = getChild("WLPresetsCombo"); WLcomboBox->setSimple(mIt->first); } -void LLFloaterWindLight::onNextPreset(void* user_data) +void LLFloaterWindLight::onNextPreset() { - LLFloaterWindLight* self = (LLFloaterWindLight*) user_data; - // find place of current param std::map::iterator mIt = LLWLParamManager::instance()->mParamList.find(LLWLParamManager::instance()->mCurParams.mName); @@ -949,7 +944,7 @@ void LLFloaterWindLight::onNextPreset(void* user_data) } deactivateAnimator(); LLWLParamManager::instance()->loadPreset(mIt->first, true); - LLComboBox* WLcomboBox = self->getChild("WLPresetsCombo"); + LLComboBox* WLcomboBox = getChild("WLPresetsCombo"); WLcomboBox->setSimple(mIt->first); } // < Presets prev/next controls -WoLf \ No newline at end of file diff --git a/indra/newview/llfloaterwindlight.h b/indra/newview/llfloaterwindlight.h index ba56bdf4e7..708923b768 100644 --- a/indra/newview/llfloaterwindlight.h +++ b/indra/newview/llfloaterwindlight.h @@ -105,8 +105,8 @@ public: static void deactivateAnimator(); /// Preset prev/next controls -WoLf - static void onPrevPreset(void* user_data); - static void onNextPreset(void* user_data); + void onPrevPreset(); + void onNextPreset(); private: static std::set sDefaultPresets; diff --git a/indra/newview/quickprefs.cpp b/indra/newview/quickprefs.cpp index 7547a859f7..1db41d9218 100644 --- a/indra/newview/quickprefs.cpp +++ b/indra/newview/quickprefs.cpp @@ -58,12 +58,10 @@ void FloaterQuickPrefs::onOpen(const LLSD& key) void FloaterQuickPrefs::initCallbacks(void) { getChild("WaterPresetsCombo")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onChangeWaterPreset, this, _1)); getChild("WLPresetsCombo")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onChangeSkyPreset, this, _1)); - getChild("WLPrevPreset")->setCommitCallback(boost::bind(&LLFloaterWindLight::onPrevPreset, this)); - getChild("WLNextPreset")->setCommitCallback(boost::bind(&LLFloaterWindLight::onNextPreset, this)); - getChild("WWPrevPreset")->setCommitCallback(boost::bind(&LLFloaterWater::onPrevPreset, this)); - getChild("WWNextPreset")->setCommitCallback(boost::bind(&LLFloaterWater::onNextPreset, this)); - - + getChild("WLPrevPreset")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickSkyPrev, this)); + getChild("WLNextPreset")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickSkyNext, this)); + getChild("WWPrevPreset")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickWaterPrev, this)); + getChild("WWNextPreset")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickWaterNext, this)); } BOOL FloaterQuickPrefs::postBuild() @@ -107,11 +105,123 @@ void FloaterQuickPrefs::onChangeWaterPreset(LLUICtrl* ctrl) void FloaterQuickPrefs::onChangeSkyPreset(LLUICtrl* ctrl) { - LLFloaterWindLight::deactivateAnimator(); + deactivateAnimator(); std::string data = ctrl->getValue().asString(); if(!data.empty()) { LLWLParamManager::instance()->loadPreset( data); } +} + +void FloaterQuickPrefs::deactivateAnimator() +{ + LLWLParamManager::instance()->mAnimator.mIsRunning = false; + LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; +} + +void FloaterQuickPrefs::onClickWaterPrev() +{ + LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamSet & currentParams = param_mgr->mCurParams; + + // find place of current param + std::map::iterator mIt = + param_mgr->mParamList.find(currentParams.mName); + + // if at the beginning, loop + if(mIt == param_mgr->mParamList.begin()) + { + std::map::iterator last = param_mgr->mParamList.end(); --last; + mIt = last; + } + else + { + mIt--; + } + param_mgr->loadPreset(mIt->first, true); + LLComboBox* WWcomboBox = getChild("WaterPresetsCombo"); + WWcomboBox->setSimple(mIt->first); +} + +void FloaterQuickPrefs::onClickWaterNext() +{ + LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamSet& currentParams = param_mgr->mCurParams; + + // find place of current param + std::map::iterator mIt = + param_mgr->mParamList.find(currentParams.mName); + + // if at the end, loop + std::map::iterator last = param_mgr->mParamList.end(); --last; + if(mIt == last) + { + mIt = param_mgr->mParamList.begin(); + } + else + { + mIt++; + } + param_mgr->loadPreset(mIt->first, true); + LLComboBox* WWcomboBox = getChild("WaterPresetsCombo"); + WWcomboBox->setSimple(mIt->first); +} + +void FloaterQuickPrefs::onClickSkyPrev() +{ + // find place of current param + std::map::iterator mIt = + LLWLParamManager::instance()->mParamList.find(LLWLParamManager::instance()->mCurParams.mName); + + // shouldn't happen unless you delete every preset but Default + if (mIt == LLWLParamManager::instance()->mParamList.end()) + { + llwarns << "No more presets left!" << llendl; + return; + } + + // if at the beginning, loop + if(mIt == LLWLParamManager::instance()->mParamList.begin()) + { + std::map::iterator last = LLWLParamManager::instance()->mParamList.end(); --last; + mIt = last; + } + else + { + mIt--; + } + deactivateAnimator(); + LLWLParamManager::instance()->loadPreset(mIt->first, true); + LLComboBox* WLcomboBox = getChild("WLPresetsCombo"); + WLcomboBox->setSimple(mIt->first); +} + +void FloaterQuickPrefs::onClickSkyNext() +{ + // find place of current param + std::map::iterator mIt = + LLWLParamManager::instance()->mParamList.find(LLWLParamManager::instance()->mCurParams.mName); + + // shouldn't happen unless you delete every preset but Default + if (mIt == LLWLParamManager::instance()->mParamList.end()) + { + llwarns << "No more presets left!" << llendl; + return; + } + + // if at the end, loop + std::map::iterator last = LLWLParamManager::instance()->mParamList.end(); --last; + if(mIt == last) + { + mIt = LLWLParamManager::instance()->mParamList.begin(); + } + else + { + mIt++; + } + deactivateAnimator(); + LLWLParamManager::instance()->loadPreset(mIt->first, true); + LLComboBox* WLcomboBox = getChild("WLPresetsCombo"); + WLcomboBox->setSimple(mIt->first); } \ No newline at end of file diff --git a/indra/newview/quickprefs.h b/indra/newview/quickprefs.h index 568d1c22e6..bed07b7b04 100644 --- a/indra/newview/quickprefs.h +++ b/indra/newview/quickprefs.h @@ -46,6 +46,11 @@ class FloaterQuickPrefs : public LLTransientDockableFloater void initCallbacks(void); void onChangeWaterPreset(LLUICtrl* ctrl); void onChangeSkyPreset(LLUICtrl* ctrl); + void deactivateAnimator(); + void onClickSkyPrev(); + void onClickSkyNext(); + void onClickWaterPrev(); + void onClickWaterNext(); }; #endif \ No newline at end of file