diff options
Diffstat (limited to 'indra/newview/llfloatereditsky.cpp')
-rw-r--r-- | indra/newview/llfloatereditsky.cpp | 536 |
1 files changed, 214 insertions, 322 deletions
diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index d809211ea7..40f86e3778 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -28,6 +28,8 @@ #include "llfloatereditsky.h" +#include <boost/make_shared.hpp> + // libs #include "llbutton.h" #include "llcheckboxctrl.h" @@ -45,6 +47,10 @@ #include "llregioninfomodel.h" #include "llviewerregion.h" +#include "v3colorutil.h" +#include "llenvironment.h" +#include "llenvadapters.h" + static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; static const F32 WL_BLUE_HORIZON_DENSITY_SCALE = 2.0f; static const F32 WL_CLOUD_SLIDER_SCALE = 1.0f; @@ -61,12 +67,13 @@ static F32 time24_to_sun_pos(F32 time24) return sun_pos; } -LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) -: LLFloater(key) -, mSkyPresetNameEditor(NULL) -, mSkyPresetCombo(NULL) -, mMakeDefaultCheckBox(NULL) -, mSaveButton(NULL) +LLFloaterEditSky::LLFloaterEditSky(const LLSD &key): + LLFloater(key), + mSkyPresetNameEditor(NULL), + mSkyPresetCombo(NULL), + mMakeDefaultCheckBox(NULL), + mSaveButton(NULL), + mSkyAdapter() { } @@ -77,6 +84,7 @@ BOOL LLFloaterEditSky::postBuild() mSkyPresetCombo = getChild<LLComboBox>("sky_preset_combo"); mMakeDefaultCheckBox = getChild<LLCheckBoxCtrl>("make_default_cb"); mSaveButton = getChild<LLButton>("save"); + mSkyAdapter = boost::make_shared<LLSkySettingsAdapter>(); initCallbacks(); @@ -115,7 +123,7 @@ void LLFloaterEditSky::onClose(bool app_quitting) { if (!app_quitting) // there's no point to change environment if we're quitting { - LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment +// LLEnvManagerNew::instance().usePrefs(); // revert changes made to current environment } } @@ -137,71 +145,64 @@ void LLFloaterEditSky::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this)); getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); - LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditSky::onRegionSettingsChange, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); - // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditSky::onRegionInfoUpdate, this)); //------------------------------------------------------------------------- - LLWLParamManager& param_mgr = LLWLParamManager::instance(); - // blue horizon - getChild<LLUICtrl>("WLBlueHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mBlueHorizon)); + getChild<LLUICtrl>("WLBlueHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mBlueHorizon)); // haze density, horizon, mult, and altitude - getChild<LLUICtrl>("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mHazeDensity)); - getChild<LLUICtrl>("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mHazeHorizon)); - getChild<LLUICtrl>("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mDensityMult)); - getChild<LLUICtrl>("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mMaxAlt)); + getChild<LLUICtrl>("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mHazeDensity)); + getChild<LLUICtrl>("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mHazeHorizon)); + getChild<LLUICtrl>("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mDensityMult)); + getChild<LLUICtrl>("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mMaxAlt)); // blue density - getChild<LLUICtrl>("WLBlueDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mBlueDensity)); + getChild<LLUICtrl>("WLBlueDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mBlueDensity)); // Lighting // sunlight - getChild<LLUICtrl>("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mSunlight)); + getChild<LLUICtrl>("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mSunlight)); // glow - getChild<LLUICtrl>("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, ¶m_mgr.mGlow)); - getChild<LLUICtrl>("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, ¶m_mgr.mGlow)); + getChild<LLUICtrl>("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, &mSkyAdapter->mGlow)); + getChild<LLUICtrl>("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, &mSkyAdapter->mGlow)); // ambient - getChild<LLUICtrl>("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mAmbient)); + getChild<LLUICtrl>("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mAmbient)); // time of day - getChild<LLUICtrl>("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); // multi-slider + getChild<LLUICtrl>("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider getChild<LLTimeCtrl>("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl - getChild<LLUICtrl>("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); + getChild<LLUICtrl>("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // Clouds // Cloud Color - getChild<LLUICtrl>("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mCloudColor)); + getChild<LLUICtrl>("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mCloudColor)); // Cloud - getChild<LLUICtrl>("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudMain)); - getChild<LLUICtrl>("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudMain)); - getChild<LLUICtrl>("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudMain)); + getChild<LLUICtrl>("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, &mSkyAdapter->mCloudMain)); + getChild<LLUICtrl>("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, &mSkyAdapter->mCloudMain)); + getChild<LLUICtrl>("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, &mSkyAdapter->mCloudMain)); // Cloud Detail - getChild<LLUICtrl>("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudDetail)); - getChild<LLUICtrl>("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudDetail)); - getChild<LLUICtrl>("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudDetail)); + getChild<LLUICtrl>("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, &mSkyAdapter->mCloudDetail)); + getChild<LLUICtrl>("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, &mSkyAdapter->mCloudDetail)); + getChild<LLUICtrl>("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, &mSkyAdapter->mCloudDetail)); // Cloud extras - getChild<LLUICtrl>("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mCloudCoverage)); - getChild<LLUICtrl>("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mCloudScale)); - getChild<LLUICtrl>("WLCloudLockX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXToggled, this, _1)); - getChild<LLUICtrl>("WLCloudLockY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYToggled, this, _1)); + getChild<LLUICtrl>("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mCloudCoverage)); + getChild<LLUICtrl>("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mCloudScale)); getChild<LLUICtrl>("WLCloudScrollX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXMoved, this, _1)); getChild<LLUICtrl>("WLCloudScrollY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYMoved, this, _1)); - getChild<LLUICtrl>("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mDistanceMult)); + getChild<LLUICtrl>("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mDistanceMult)); // Dome - getChild<LLUICtrl>("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mWLGamma)); + getChild<LLUICtrl>("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mWLGamma)); getChild<LLUICtrl>("WLStarAlpha")->setCommitCallback(boost::bind(&LLFloaterEditSky::onStarAlphaMoved, this, _1)); } @@ -209,320 +210,250 @@ void LLFloaterEditSky::initCallbacks(void) void LLFloaterEditSky::syncControls() { - bool err; + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + mEditSettings = psky; - LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); - - LLWLParamSet& cur_params = param_mgr->mCurParams; // blue horizon - param_mgr->mBlueHorizon = cur_params.getVector(param_mgr->mBlueHorizon.mName, err); - setColorSwatch("WLBlueHorizon", param_mgr->mBlueHorizon, WL_BLUE_HORIZON_DENSITY_SCALE); + mSkyAdapter->mBlueHorizon = psky->getBlueHorizon(); + setColorSwatch("WLBlueHorizon", mSkyAdapter->mBlueHorizon, WL_BLUE_HORIZON_DENSITY_SCALE); // haze density, horizon, mult, and altitude - param_mgr->mHazeDensity = cur_params.getFloat(param_mgr->mHazeDensity.mName, err); - childSetValue("WLHazeDensity", (F32) param_mgr->mHazeDensity); - param_mgr->mHazeHorizon = cur_params.getFloat(param_mgr->mHazeHorizon.mName, err); - childSetValue("WLHazeHorizon", (F32) param_mgr->mHazeHorizon); - param_mgr->mDensityMult = cur_params.getFloat(param_mgr->mDensityMult.mName, err); - childSetValue("WLDensityMult", ((F32) param_mgr->mDensityMult) * param_mgr->mDensityMult.mult); - param_mgr->mMaxAlt = cur_params.getFloat(param_mgr->mMaxAlt.mName, err); - childSetValue("WLMaxAltitude", (F32) param_mgr->mMaxAlt); + mSkyAdapter->mHazeDensity = psky->getHazeDensity(); + childSetValue("WLHazeDensity", (F32) mSkyAdapter->mHazeDensity); + mSkyAdapter->mHazeHorizon = psky->getHazeHorizon(); + childSetValue("WLHazeHorizon", (F32) mSkyAdapter->mHazeHorizon); + mSkyAdapter->mDensityMult = psky->getDensityMultiplier(); + childSetValue("WLDensityMult", ((F32) mSkyAdapter->mDensityMult) * mSkyAdapter->mDensityMult.getMult()); + mSkyAdapter->mMaxAlt = psky->getMaxY(); + childSetValue("WLMaxAltitude", (F32) mSkyAdapter->mMaxAlt); // blue density - param_mgr->mBlueDensity = cur_params.getVector(param_mgr->mBlueDensity.mName, err); - setColorSwatch("WLBlueDensity", param_mgr->mBlueDensity, WL_BLUE_HORIZON_DENSITY_SCALE); + mSkyAdapter->mBlueDensity = psky->getBlueDensity(); + setColorSwatch("WLBlueDensity", mSkyAdapter->mBlueDensity, WL_BLUE_HORIZON_DENSITY_SCALE); // Lighting // sunlight - param_mgr->mSunlight = cur_params.getVector(param_mgr->mSunlight.mName, err); - setColorSwatch("WLSunlight", param_mgr->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); + mSkyAdapter->mSunlight = psky->getSunlightColor(); + setColorSwatch("WLSunlight", mSkyAdapter->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); // glow - param_mgr->mGlow = cur_params.getVector(param_mgr->mGlow.mName, err); - childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f); - childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f); + mSkyAdapter->mGlow = psky->getGlow(); + childSetValue("WLGlowR", 2 - mSkyAdapter->mGlow.getRed() / 20.0f); + childSetValue("WLGlowB", -mSkyAdapter->mGlow.getBlue() / 5.0f); // ambient - param_mgr->mAmbient = cur_params.getVector(param_mgr->mAmbient.mName, err); - setColorSwatch("WLAmbient", param_mgr->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); + mSkyAdapter->mAmbient = psky->getAmbientColor(); + setColorSwatch("WLAmbient", mSkyAdapter->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); + + LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl(); - F32 time24 = sun_pos_to_time24(param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); + F32 time24 = sun_pos_to_time24(azal.second / F_TWO_PI); getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE); getChild<LLTimeCtrl>("WLDayTime")->setTime24(time24); - childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); + childSetValue("WLEastAngle", azal.first / F_TWO_PI); // Clouds // Cloud Color - param_mgr->mCloudColor = cur_params.getVector(param_mgr->mCloudColor.mName, err); - setColorSwatch("WLCloudColor", param_mgr->mCloudColor, WL_CLOUD_SLIDER_SCALE); + mSkyAdapter->mCloudColor = psky->getCloudColor(); + setColorSwatch("WLCloudColor", mSkyAdapter->mCloudColor, WL_CLOUD_SLIDER_SCALE); // Cloud - param_mgr->mCloudMain = cur_params.getVector(param_mgr->mCloudMain.mName, err); - childSetValue("WLCloudX", param_mgr->mCloudMain.r); - childSetValue("WLCloudY", param_mgr->mCloudMain.g); - childSetValue("WLCloudDensity", param_mgr->mCloudMain.b); + mSkyAdapter->mCloudMain = psky->getCloudPosDensity1(); + childSetValue("WLCloudX", mSkyAdapter->mCloudMain.getRed()); + childSetValue("WLCloudY", mSkyAdapter->mCloudMain.getGreen()); + childSetValue("WLCloudDensity", mSkyAdapter->mCloudMain.getBlue()); // Cloud Detail - param_mgr->mCloudDetail = cur_params.getVector(param_mgr->mCloudDetail.mName, err); - childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r); - childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g); - childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b); + mSkyAdapter->mCloudDetail = psky->getCloudPosDensity2(); + childSetValue("WLCloudDetailX", mSkyAdapter->mCloudDetail.getRed()); + childSetValue("WLCloudDetailY", mSkyAdapter->mCloudDetail.getGreen()); + childSetValue("WLCloudDetailDensity", mSkyAdapter->mCloudDetail.getBlue()); // Cloud extras - param_mgr->mCloudCoverage = cur_params.getFloat(param_mgr->mCloudCoverage.mName, err); - param_mgr->mCloudScale = cur_params.getFloat(param_mgr->mCloudScale.mName, err); - childSetValue("WLCloudCoverage", (F32) param_mgr->mCloudCoverage); - childSetValue("WLCloudScale", (F32) param_mgr->mCloudScale); + mSkyAdapter->mCloudCoverage = psky->getCloudShadow(); + mSkyAdapter->mCloudScale = psky->getCloudScale(); + childSetValue("WLCloudCoverage", (F32) mSkyAdapter->mCloudCoverage); + childSetValue("WLCloudScale", (F32) mSkyAdapter->mCloudScale); // cloud scrolling - bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX(); - bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY(); - childSetValue("WLCloudLockX", lockX); - childSetValue("WLCloudLockY", lockY); + LLVector2 scroll_rate = psky->getCloudScrollRate(); + + // LAPRAS: These should go away... + childDisable("WLCloudLockX"); + childDisable("WLCloudLockY"); // disable if locked, enable if not - if (lockX) - { - childDisable("WLCloudScrollX"); - } - else - { - childEnable("WLCloudScrollX"); - } - if (lockY) - { - childDisable("WLCloudScrollY"); - } - else - { - childEnable("WLCloudScrollY"); - } + childEnable("WLCloudScrollX"); + childEnable("WLCloudScrollY"); // *HACK cloud scrolling is off my an additive of 10 - childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f); - childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f); + childSetValue("WLCloudScrollX", scroll_rate[0] - 10.0f); + childSetValue("WLCloudScrollY", scroll_rate[1] - 10.0f); - param_mgr->mDistanceMult = cur_params.getFloat(param_mgr->mDistanceMult.mName, err); - childSetValue("WLDistanceMult", (F32) param_mgr->mDistanceMult); + mSkyAdapter->mDistanceMult = psky->getDistanceMultiplier(); + childSetValue("WLDistanceMult", (F32) mSkyAdapter->mDistanceMult); // Tweak extras - param_mgr->mWLGamma = cur_params.getFloat(param_mgr->mWLGamma.mName, err); - childSetValue("WLGamma", (F32) param_mgr->mWLGamma); + mSkyAdapter->mWLGamma = psky->getGamma(); + childSetValue("WLGamma", (F32) mSkyAdapter->mWLGamma); - childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness()); + childSetValue("WLStarAlpha", psky->getStarBrightness()); } void LLFloaterEditSky::setColorSwatch(const std::string& name, const WLColorControl& from_ctrl, F32 k) { // Set the value, dividing it by <k> first. - LLVector4 color_vec = from_ctrl; - getChild<LLColorSwatchCtrl>(name)->set(LLColor4(color_vec / k)); + LLColor4 color = from_ctrl; + getChild<LLColorSwatchCtrl>(name)->set(color / k); } // color control callbacks void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); + //LLWLParamManager::getInstance()->mAnimator.deactivate(); LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl); - LLVector4 color_vec(swatch->get().mV); - - // Set intensity to maximum of the RGB values. - color_vec.mV[3] = llmax(color_vec.mV[0], llmax(color_vec.mV[1], color_vec.mV[2])); + LLColor4 color_vec(swatch->get().mV); // Multiply RGB values by the appropriate factor. F32 k = WL_CLOUD_SLIDER_SCALE; - if (color_ctrl->isSunOrAmbientColor) + if (color_ctrl->getIsSunOrAmbientColor()) { k = WL_SUN_AMBIENT_SLIDER_SCALE; } - if (color_ctrl->isBlueHorizonOrDensity) + else if (color_ctrl->getIsBlueHorizonOrDensity()) { k = WL_BLUE_HORIZON_DENSITY_SCALE; } color_vec *= k; // intensity isn't affected by the multiplication + // Set intensity to maximum of the RGB values. + color_vec.mV[3] = color_max(color_vec); + // Apply the new RGBI value. *color_ctrl = color_vec; - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlRMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); - color_ctrl->r = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->r *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) + F32 red_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; + + if (color_ctrl->getIsSunOrAmbientColor()) { - color_ctrl->r *= WL_BLUE_HORIZON_DENSITY_SCALE; + k = WL_SUN_AMBIENT_SLIDER_SCALE; } - - // move i if it's the max - if (color_ctrl->r >= color_ctrl->g && color_ctrl->r >= color_ctrl->b && color_ctrl->hasSliderName) + if (color_ctrl->getIsBlueHorizonOrDensity()) { - color_ctrl->i = color_ctrl->r; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->r / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->r / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->r); - } + k = WL_BLUE_HORIZON_DENSITY_SCALE; } + color_ctrl->setRed(red_value * k); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - - LLWLParamManager::getInstance()->propagateParameters(); + adjustIntensity(color_ctrl, red_value, k); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlGMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); - - color_ctrl->g = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->g *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) - { - color_ctrl->g *= WL_BLUE_HORIZON_DENSITY_SCALE; - } + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); - // move i if it's the max - if (color_ctrl->g >= color_ctrl->r && color_ctrl->g >= color_ctrl->b && color_ctrl->hasSliderName) - { - color_ctrl->i = color_ctrl->g; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->g / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->g / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->g); - } - } + F32 green_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); + if (color_ctrl->getIsSunOrAmbientColor()) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + if (color_ctrl->getIsBlueHorizonOrDensity()) + { + k = WL_BLUE_HORIZON_DENSITY_SCALE; + } + color_ctrl->setGreen(green_value * k); - LLWLParamManager::getInstance()->propagateParameters(); + adjustIntensity(color_ctrl, green_value, k); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onColorControlBMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); + F32 blue_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; - color_ctrl->b = sldr_ctrl->getValueF32(); - if (color_ctrl->isSunOrAmbientColor) - { - color_ctrl->b *= WL_SUN_AMBIENT_SLIDER_SCALE; - } - if (color_ctrl->isBlueHorizonOrDensity) - { - color_ctrl->b *= WL_BLUE_HORIZON_DENSITY_SCALE; - } + if (color_ctrl->getIsSunOrAmbientColor()) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + if (color_ctrl->getIsBlueHorizonOrDensity()) + { + k = WL_BLUE_HORIZON_DENSITY_SCALE; + } + color_ctrl->setBlue(blue_value * k); - // move i if it's the max - if (color_ctrl->b >= color_ctrl->r && color_ctrl->b >= color_ctrl->g && color_ctrl->hasSliderName) - { - color_ctrl->i = color_ctrl->b; - std::string name = color_ctrl->mSliderName; - name.append("I"); - - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(name, color_ctrl->b / WL_SUN_AMBIENT_SLIDER_SCALE); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(name, color_ctrl->b / WL_BLUE_HORIZON_DENSITY_SCALE); - } - else - { - childSetValue(name, color_ctrl->b); - } - } + adjustIntensity(color_ctrl, blue_value, k); + color_ctrl->update(mEditSettings); +} - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); +void LLFloaterEditSky::adjustIntensity(WLColorControl *ctrl, F32 val, F32 scale) +{ + if (ctrl->getHasSliderName()) + { + LLColor4 color = static_cast<LLColor4>(*ctrl); + F32 i = color_max(color) / scale; + ctrl->setIntensity(i); + std::string name = ctrl->getSliderName(); + name.append("I"); - LLWLParamManager::getInstance()->propagateParameters(); + childSetValue(name, i); + } } + /// GLOW SPECIFIC CODE void LLFloaterEditSky::onGlowRMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); // scaled by 20 - color_ctrl->r = (2 - sldr_ctrl->getValueF32()) * 20; + color_ctrl->setRed((2 - sldr_ctrl->getValueF32()) * 20); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } /// \NOTE that we want NEGATIVE (-) B void LLFloaterEditSky::onGlowBMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); /// \NOTE that we want NEGATIVE (-) B and NOT by 20 as 20 is too big - color_ctrl->b = -sldr_ctrl->getValueF32() * 5; + color_ctrl->setBlue(-sldr_ctrl->getValueF32() * 5); - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onFloatControlMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); WLFloatControl * floatControl = static_cast<WLFloatControl *>(userdata); - floatControl->x = sldr_ctrl->getValueF32() / floatControl->mult; + floatControl->setValue(sldr_ctrl->getValueF32() / floatControl->getMult()); - floatControl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); + floatControl->update(mEditSettings); } @@ -531,8 +462,6 @@ void LLFloaterEditSky::onFloatControlMoved(LLUICtrl* ctrl, void* userdata) // time of day void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLMultiSliderCtrl* sun_msldr = getChild<LLMultiSliderCtrl>("WLSunPos"); LLSliderCtrl* east_sldr = getChild<LLSliderCtrl>("WLEastAngle"); LLTimeCtrl* time_ctrl = getChild<LLTimeCtrl>("WLDayTime"); @@ -542,99 +471,44 @@ void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) time_ctrl->setTime24(time24); // sync the time ctrl with the new sun position // get the two angles - LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); - - param_mgr->mCurParams.setSunAngle(F_TWO_PI * time24_to_sun_pos(time24)); - param_mgr->mCurParams.setEastAngle(F_TWO_PI * east_sldr->getValueF32()); + F32 azimuth = F_TWO_PI * east_sldr->getValueF32(); + F32 altitude = F_TWO_PI * time24_to_sun_pos(time24); + mEditSettings->setSunRotation(azimuth, altitude); + mEditSettings->setMoonRotation(azimuth + F_PI, -altitude); - // set the sun vector - color_ctrl->r = -sin(param_mgr->mCurParams.getEastAngle()) * - cos(param_mgr->mCurParams.getSunAngle()); - color_ctrl->g = sin(param_mgr->mCurParams.getSunAngle()); - color_ctrl->b = cos(param_mgr->mCurParams.getEastAngle()) * - cos(param_mgr->mCurParams.getSunAngle()); - color_ctrl->i = 1.f; + LLVector4 sunnorm( mEditSettings->getSunDirection(), 1.f ); - color_ctrl->update(param_mgr->mCurParams); - param_mgr->propagateParameters(); + color_ctrl->update(mEditSettings); } void LLFloaterEditSky::onTimeChanged() { F32 time24 = getChild<LLTimeCtrl>("WLDayTime")->getTime24(); getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE); - onSunMoved(getChild<LLUICtrl>("WLSunPos"), &LLWLParamManager::instance().mLightnorm); + onSunMoved(getChild<LLUICtrl>("WLSunPos"), &(mSkyAdapter->mLightnorm)); } void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); - LLWLParamManager::getInstance()->mCurParams.setStarBrightness(sldr_ctrl->getValueF32()); + mEditSettings->setStarBrightness(sldr_ctrl->getValueF32()); } // Clouds void LLFloaterEditSky::onCloudScrollXMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::getInstance()->mCurParams.setCloudScrollX(sldr_ctrl->getValueF32() + 10.0f); + mEditSettings->setCloudScrollRateX(sldr_ctrl->getValueF32() + 10.0f); } void LLFloaterEditSky::onCloudScrollYMoved(LLUICtrl* ctrl) { - LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); // *HACK all cloud scrolling is off by an additive of 10. - LLWLParamManager::getInstance()->mCurParams.setCloudScrollY(sldr_ctrl->getValueF32() + 10.0f); -} - -void LLFloaterEditSky::onCloudScrollXToggled(LLUICtrl* ctrl) -{ - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLCheckBoxCtrl* cb_ctrl = static_cast<LLCheckBoxCtrl*>(ctrl); - - bool lock = cb_ctrl->get(); - LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollX(!lock); - - LLSliderCtrl* sldr = getChild<LLSliderCtrl>("WLCloudScrollX"); - - if (cb_ctrl->get()) - { - sldr->setEnabled(false); - } - else - { - sldr->setEnabled(true); - } - -} - -void LLFloaterEditSky::onCloudScrollYToggled(LLUICtrl* ctrl) -{ - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLCheckBoxCtrl* cb_ctrl = static_cast<LLCheckBoxCtrl*>(ctrl); - bool lock = cb_ctrl->get(); - LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollY(!lock); - - LLSliderCtrl* sldr = getChild<LLSliderCtrl>("WLCloudScrollY"); - - if (cb_ctrl->get()) - { - sldr->setEnabled(false); - } - else - { - sldr->setEnabled(true); - } + mEditSettings->setCloudScrollRateY(sldr_ctrl->getValueF32() + 10.0f); } //================================================================================================= @@ -662,6 +536,7 @@ bool LLFloaterEditSky::isNewPreset() const void LLFloaterEditSky::refreshSkyPresetsList() { +#if 0 mSkyPresetCombo->removeall(); LLWLParamManager::preset_name_list_t region_presets, user_presets, sys_presets; @@ -698,6 +573,7 @@ void LLFloaterEditSky::refreshSkyPresetsList() } mSkyPresetCombo->setLabel(getString("combo_label")); +#endif } void LLFloaterEditSky::enableEditing(bool enable) @@ -718,6 +594,7 @@ void LLFloaterEditSky::enableEditing(bool enable) void LLFloaterEditSky::saveRegionSky() { +#if 0 LLWLParamKey key(getSelectedSkyPreset()); llassert(key.scope == LLEnvKey::SCOPE_REGION); @@ -728,44 +605,48 @@ void LLFloaterEditSky::saveRegionSky() // *TODO: save to cached region settings. LL_WARNS("Windlight") << "Saving region sky is not fully implemented yet" << LL_ENDL; +#endif } -LLWLParamKey LLFloaterEditSky::getSelectedSkyPreset() -{ - LLWLParamKey key; - - if (mSkyPresetNameEditor->getVisible()) - { - key.name = mSkyPresetNameEditor->getText(); - key.scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - LLSD combo_val = mSkyPresetCombo->getValue(); - - if (!combo_val.isArray()) // manually typed text - { - key.name = combo_val.asString(); - key.scope = LLEnvKey::SCOPE_LOCAL; - } - else - { - key.fromLLSD(combo_val); - } - } - - return key; -} +// LLWLParamKey LLFloaterEditSky::getSelectedSkyPreset() +// { +// LLWLParamKey key; +// +// if (mSkyPresetNameEditor->getVisible()) +// { +// key.name = mSkyPresetNameEditor->getText(); +// key.scope = LLEnvKey::SCOPE_LOCAL; +// } +// else +// { +// LLSD combo_val = mSkyPresetCombo->getValue(); +// +// if (!combo_val.isArray()) // manually typed text +// { +// key.name = combo_val.asString(); +// key.scope = LLEnvKey::SCOPE_LOCAL; +// } +// else +// { +// key.fromLLSD(combo_val); +// } +// } +// +// return key; +// } void LLFloaterEditSky::onSkyPresetNameEdited() { +#if 0 // Disable saving a sky preset having empty name. LLWLParamKey key = getSelectedSkyPreset(); mSaveButton->setEnabled(!key.name.empty()); +#endif } void LLFloaterEditSky::onSkyPresetSelected() { +#if 0 LLWLParamKey key = getSelectedSkyPreset(); LLWLParamSet sky_params; @@ -783,6 +664,7 @@ void LLFloaterEditSky::onSkyPresetSelected() enableEditing(can_edit); mMakeDefaultCheckBox->setEnabled(key.scope == LLEnvKey::SCOPE_LOCAL); +#endif } bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response) @@ -800,6 +682,7 @@ bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& respon void LLFloaterEditSky::onSaveConfirmed() { +#if 0 // Save current params to the selected preset. LLWLParamKey key(getSelectedSkyPreset()); @@ -824,10 +707,12 @@ void LLFloaterEditSky::onSaveConfirmed() } closeFloater(); +#endif } void LLFloaterEditSky::onBtnSave() { +#if 0 LLWLParamKey selected_sky = getSelectedSkyPreset(); LLWLParamManager& wl_mgr = LLWLParamManager::instance(); @@ -863,6 +748,7 @@ void LLFloaterEditSky::onBtnSave() // new preset, hence no confirmation needed onSaveConfirmed(); } +#endif } void LLFloaterEditSky::onBtnCancel() @@ -872,6 +758,7 @@ void LLFloaterEditSky::onBtnCancel() void LLFloaterEditSky::onSkyPresetListChange() { +#if 0 LLWLParamKey key = getSelectedSkyPreset(); // preset being edited if (!LLWLParamManager::instance().hasParamSet(key)) { @@ -884,10 +771,12 @@ void LLFloaterEditSky::onSkyPresetListChange() // Refresh the presets list, though it may not make sense as the floater is about to be closed. refreshSkyPresetsList(); } +#endif } void LLFloaterEditSky::onRegionSettingsChange() { +#if 0 // If creating a new sky, don't bother. if (isNewPreset()) { @@ -905,10 +794,12 @@ void LLFloaterEditSky::onRegionSettingsChange() { refreshSkyPresetsList(); } +#endif } void LLFloaterEditSky::onRegionInfoUpdate() { +#if 0 bool can_edit = true; // If we've selected a region sky preset for editing. @@ -919,4 +810,5 @@ void LLFloaterEditSky::onRegionInfoUpdate() } enableEditing(can_edit); +#endif } |