From bbde07245bdcedd05bd37863d573c94c2af4c6f7 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 26 May 2011 23:09:30 +0300 Subject: STORM-1285 WIP Connected "Create/Edit Water / Sky / Day Cycle" floaters (not functional) to the main menu. --- indra/newview/llfloatereditsky.cpp | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 indra/newview/llfloatereditsky.cpp (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp new file mode 100644 index 0000000000..312479951e --- /dev/null +++ b/indra/newview/llfloatereditsky.cpp @@ -0,0 +1,73 @@ +/** + * @file llfloatereditsky.h + * @brief Floater to create or edit a sky preset + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatereditsky.h" + +// libs +#include "llbutton.h" + +// newview + +LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) +: LLFloater(key) +{ +} + +// virtual +BOOL LLFloaterEditSky::postBuild() +{ + getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); + + // Disable some non-functional controls. + getChildView("sky_preset_combo")->setEnabled(FALSE); + getChildView("save")->setEnabled(FALSE); + + return TRUE; +} + +// virtual +void LLFloaterEditSky::onOpen(const LLSD& key) +{ + std::string param = key.asString(); + std::string floater_title = getString(std::string("title_") + param); + std::string hint = getString(std::string("hint_" + param)); + + // Update floater title. + setTitle(floater_title); + + // Update the hint at the top. + getChild("hint")->setValue(hint); + + // Hide the hint to the right of the combo if we're invoked to create a new preset. + getChildView("note")->setVisible(param == "edit"); +} + +void LLFloaterEditSky::onBtnCancel() +{ + closeFloater(); +} -- cgit v1.2.3 From 4e05ea6ebda88f3e2af4b585f629b11f3729096e Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 00:17:21 +0300 Subject: STORM-1255 WIP Implemented creating, editing and removing local sky presets. --- indra/newview/llfloatereditsky.cpp | 843 ++++++++++++++++++++++++++++++++++++- 1 file changed, 838 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 312479951e..96dfb7a8a9 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -30,22 +30,41 @@ // libs #include "llbutton.h" +#include "llcheckboxctrl.h" +#include "llcombobox.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" +#include "llsliderctrl.h" +#include "lltabcontainer.h" // newview +#include "llagent.h" +#include "llviewerregion.h" + +#undef max + +static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; + +//================================================================================================= LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) : LLFloater(key) +, mSkyPresetNameEditor(NULL) +, mSkyPresetCombo(NULL) +, mMakeDefaultCheckBox(NULL) +, mSaveButton(NULL) { } // virtual BOOL LLFloaterEditSky::postBuild() { - getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); + mSkyPresetNameEditor = getChild("sky_preset_name"); + mSkyPresetCombo = getChild("sky_preset_combo"); + mMakeDefaultCheckBox = getChild("make_default_cb"); + mSaveButton = getChild("save"); - // Disable some non-functional controls. - getChildView("sky_preset_combo")->setEnabled(FALSE); - getChildView("save")->setEnabled(FALSE); + initCallbacks(); return TRUE; } @@ -53,6 +72,7 @@ BOOL LLFloaterEditSky::postBuild() // virtual void LLFloaterEditSky::onOpen(const LLSD& key) { + bool new_preset = isNewPreset(); std::string param = key.asString(); std::string floater_title = getString(std::string("title_") + param); std::string hint = getString(std::string("hint_" + param)); @@ -64,10 +84,823 @@ void LLFloaterEditSky::onOpen(const LLSD& key) getChild("hint")->setValue(hint); // Hide the hint to the right of the combo if we're invoked to create a new preset. - getChildView("note")->setVisible(param == "edit"); + getChildView("note")->setVisible(!new_preset); + + // Switch between the sky presets combobox and preset name input field. + mSkyPresetCombo->setVisible(!new_preset); + mSkyPresetNameEditor->setVisible(new_preset); + + if (isNewPreset()) + { + mSkyPresetNameEditor->setValue(LLSD()); + mSaveButton->setEnabled(FALSE); // will be enabled as soon as users enters a name + } + else + { + refreshSkyPresetsList(); + + // Disable controls until a sky preset to edit is selected. + enableEditing(false); + } +} + +// virtual +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 + } +} + +// virtual +void LLFloaterEditSky::draw() +{ + syncControls(); + LLFloater::draw(); +} + +void LLFloaterEditSky::initCallbacks(void) +{ + // *TODO: warn user if a region environment update comes while we're editing a region sky preset. + + mSkyPresetNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetNameEdited, this), NULL); + mSkyPresetCombo->setCommitCallback(boost::bind(&LLFloaterEditSky::onSkyPresetSelected, this)); + mSkyPresetCombo->setTextEntryCallback(boost::bind(&LLFloaterEditSky::onSkyPresetNameEdited, this)); + + mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this)); + getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); + + //------------------------------------------------------------------------- + + LLWLParamManager& param_mgr = LLWLParamManager::instance(); + + // blue horizon + getChild("WLBlueHorizonR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mBlueHorizon)); + getChild("WLBlueHorizonR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mBlueHorizon)); + getChild("WLBlueHorizonG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mBlueHorizon)); + getChild("WLBlueHorizonB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mBlueHorizon)); + getChild("WLBlueHorizonI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mBlueHorizon)); + + // haze density, horizon, mult, and altitude + getChild("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mHazeDensity)); + getChild("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mHazeHorizon)); + getChild("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mDensityMult)); + getChild("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mMaxAlt)); + + // blue density + getChild("WLBlueDensityR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mBlueDensity)); + getChild("WLBlueDensityG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mBlueDensity)); + getChild("WLBlueDensityB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mBlueDensity)); + getChild("WLBlueDensityI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mBlueDensity)); + + // Lighting + + // sunlight + getChild("WLSunlightR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mSunlight)); + getChild("WLSunlightG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mSunlight)); + getChild("WLSunlightB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mSunlight)); + getChild("WLSunlightI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mSunlight)); + + // glow + getChild("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, ¶m_mgr.mGlow)); + getChild("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, ¶m_mgr.mGlow)); + + // ambient + getChild("WLAmbientR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mAmbient)); + getChild("WLAmbientG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mAmbient)); + getChild("WLAmbientB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mAmbient)); + getChild("WLAmbientI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mAmbient)); + + // time of day + getChild("WLSunAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); + getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); + + // Clouds + + // Cloud Color + getChild("WLCloudColorR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudColor)); + getChild("WLCloudColorG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudColor)); + getChild("WLCloudColorB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudColor)); + getChild("WLCloudColorI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mCloudColor)); + + // Cloud + getChild("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudMain)); + getChild("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudMain)); + getChild("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudMain)); + + // Cloud Detail + getChild("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudDetail)); + getChild("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudDetail)); + getChild("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudDetail)); + + // Cloud extras + getChild("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mCloudCoverage)); + getChild("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mCloudScale)); + getChild("WLCloudLockX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXToggled, this, _1)); + getChild("WLCloudLockY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYToggled, this, _1)); + getChild("WLCloudScrollX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXMoved, this, _1)); + getChild("WLCloudScrollY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYMoved, this, _1)); + getChild("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mDistanceMult)); + + // Dome + getChild("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mWLGamma)); + getChild("WLStarAlpha")->setCommitCallback(boost::bind(&LLFloaterEditSky::onStarAlphaMoved, this, _1)); +} + +void LLFloaterEditSky::syncControls() +{ + bool err; + + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); + + LLWLParamSet& cur_params = param_mgr->mCurParams; + + // blue horizon + param_mgr->mBlueHorizon = cur_params.getVector(param_mgr->mBlueHorizon.mName, err); + childSetValue("WLBlueHorizonR", param_mgr->mBlueHorizon.r / 2.0); + childSetValue("WLBlueHorizonG", param_mgr->mBlueHorizon.g / 2.0); + childSetValue("WLBlueHorizonB", param_mgr->mBlueHorizon.b / 2.0); + childSetValue("WLBlueHorizonI", + std::max(param_mgr->mBlueHorizon.r / 2.0, + std::max(param_mgr->mBlueHorizon.g / 2.0, + param_mgr->mBlueHorizon.b / 2.0))); + + // haze density, horizon, mult, and altitude + param_mgr->mHazeDensity = cur_params.getVector(param_mgr->mHazeDensity.mName, err); + childSetValue("WLHazeDensity", param_mgr->mHazeDensity.r); + param_mgr->mHazeHorizon = cur_params.getVector(param_mgr->mHazeHorizon.mName, err); + childSetValue("WLHazeHorizon", param_mgr->mHazeHorizon.r); + param_mgr->mDensityMult = cur_params.getVector(param_mgr->mDensityMult.mName, err); + childSetValue("WLDensityMult", param_mgr->mDensityMult.x * + param_mgr->mDensityMult.mult); + param_mgr->mMaxAlt = cur_params.getVector(param_mgr->mMaxAlt.mName, err); + childSetValue("WLMaxAltitude", param_mgr->mMaxAlt.x); + + // blue density + param_mgr->mBlueDensity = cur_params.getVector(param_mgr->mBlueDensity.mName, err); + childSetValue("WLBlueDensityR", param_mgr->mBlueDensity.r / 2.0); + childSetValue("WLBlueDensityG", param_mgr->mBlueDensity.g / 2.0); + childSetValue("WLBlueDensityB", param_mgr->mBlueDensity.b / 2.0); + childSetValue("WLBlueDensityI", + std::max(param_mgr->mBlueDensity.r / 2.0, + std::max(param_mgr->mBlueDensity.g / 2.0, param_mgr->mBlueDensity.b / 2.0))); + + // Lighting + + // sunlight + param_mgr->mSunlight = cur_params.getVector(param_mgr->mSunlight.mName, err); + childSetValue("WLSunlightR", param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLSunlightG", param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLSunlightB", param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLSunlightI", + std::max(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE, + std::max(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mSunlight.b / 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); + + // ambient + param_mgr->mAmbient = cur_params.getVector(param_mgr->mAmbient.mName, err); + childSetValue("WLAmbientR", param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLAmbientG", param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLAmbientB", param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE); + childSetValue("WLAmbientI", + std::max(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE, + std::max(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE))); + + childSetValue("WLSunAngle", param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); + childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); + + // Clouds + + // Cloud Color + param_mgr->mCloudColor = cur_params.getVector(param_mgr->mCloudColor.mName, err); + childSetValue("WLCloudColorR", param_mgr->mCloudColor.r); + childSetValue("WLCloudColorG", param_mgr->mCloudColor.g); + childSetValue("WLCloudColorB", param_mgr->mCloudColor.b); + childSetValue("WLCloudColorI", + std::max(param_mgr->mCloudColor.r, + std::max(param_mgr->mCloudColor.g, param_mgr->mCloudColor.b))); + + // 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); + + // 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); + + // Cloud extras + param_mgr->mCloudCoverage = cur_params.getVector(param_mgr->mCloudCoverage.mName, err); + param_mgr->mCloudScale = cur_params.getVector(param_mgr->mCloudScale.mName, err); + childSetValue("WLCloudCoverage", param_mgr->mCloudCoverage.x); + childSetValue("WLCloudScale", param_mgr->mCloudScale.x); + + // cloud scrolling + bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX(); + bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY(); + childSetValue("WLCloudLockX", lockX); + childSetValue("WLCloudLockY", lockY); + + // disable if locked, enable if not + if (lockX) + { + childDisable("WLCloudScrollX"); + } + else + { + childEnable("WLCloudScrollX"); + } + if (lockY) + { + childDisable("WLCloudScrollY"); + } + else + { + 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); + + param_mgr->mDistanceMult = cur_params.getVector(param_mgr->mDistanceMult.mName, err); + childSetValue("WLDistanceMult", param_mgr->mDistanceMult.x); + + // Tweak extras + + param_mgr->mWLGamma = cur_params.getVector(param_mgr->mWLGamma.mName, err); + childSetValue("WLGamma", param_mgr->mWLGamma.x); + + childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness()); +} + + +// color control callbacks +void LLFloaterEditSky::onColorControlRMoved(LLUICtrl* ctrl, void* userdata) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLColorControl* color_ctrl = static_cast(userdata); + + color_ctrl->r = sldr_ctrl->getValueF32(); + if (color_ctrl->isSunOrAmbientColor) + { + color_ctrl->r *= 3; + } + if (color_ctrl->isBlueHorizonOrDensity) + { + color_ctrl->r *= 2; + } + + // move i if it's the max + if (color_ctrl->r >= color_ctrl->g && color_ctrl->r >= color_ctrl->b && color_ctrl->hasSliderName) + { + color_ctrl->i = color_ctrl->r; + std::string name = color_ctrl->mSliderName; + name.append("I"); + + if (color_ctrl->isSunOrAmbientColor) + { + childSetValue(name, color_ctrl->r / 3); + } + else if (color_ctrl->isBlueHorizonOrDensity) + { + childSetValue(name, color_ctrl->r / 2); + } + else + { + childSetValue(name, color_ctrl->r); + } + } + + color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); + + LLWLParamManager::getInstance()->propagateParameters(); +} + +void LLFloaterEditSky::onColorControlGMoved(LLUICtrl* ctrl, void* userdata) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLColorControl* color_ctrl = static_cast(userdata); + + color_ctrl->g = sldr_ctrl->getValueF32(); + if (color_ctrl->isSunOrAmbientColor) + { + color_ctrl->g *= 3; + } + if (color_ctrl->isBlueHorizonOrDensity) + { + color_ctrl->g *= 2; + } + + // 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 / 3); + } + else if (color_ctrl->isBlueHorizonOrDensity) + { + childSetValue(name, color_ctrl->g / 2); + } + else + { + childSetValue(name, color_ctrl->g); + } + } + + color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); + + LLWLParamManager::getInstance()->propagateParameters(); +} + +void LLFloaterEditSky::onColorControlBMoved(LLUICtrl* ctrl, void* userdata) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLColorControl* color_ctrl = static_cast(userdata); + + color_ctrl->b = sldr_ctrl->getValueF32(); + if (color_ctrl->isSunOrAmbientColor) + { + color_ctrl->b *= 3; + } + if (color_ctrl->isBlueHorizonOrDensity) + { + color_ctrl->b *= 2; + } + + // 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 / 3); + } + else if (color_ctrl->isBlueHorizonOrDensity) + { + childSetValue(name, color_ctrl->b / 2); + } + else + { + childSetValue(name, color_ctrl->b); + } + } + + color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); + + LLWLParamManager::getInstance()->propagateParameters(); +} + +void LLFloaterEditSky::onColorControlIMoved(LLUICtrl* ctrl, void* userdata) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLColorControl* color_ctrl = static_cast(userdata); + + color_ctrl->i = sldr_ctrl->getValueF32(); + + // only for sliders where we pass a name + if (color_ctrl->hasSliderName) + { + // set it to the top + F32 maxVal = std::max(std::max(color_ctrl->r, color_ctrl->g), color_ctrl->b); + F32 iVal; + + if (color_ctrl->isSunOrAmbientColor) + { + iVal = color_ctrl->i * 3; + } + else if (color_ctrl->isBlueHorizonOrDensity) + { + iVal = color_ctrl->i * 2; + } + else + { + iVal = color_ctrl->i; + } + + // get the names of the other sliders + std::string rName = color_ctrl->mSliderName; + rName.append("R"); + std::string gName = color_ctrl->mSliderName; + gName.append("G"); + std::string bName = color_ctrl->mSliderName; + bName.append("B"); + + // handle if at 0 + if (iVal == 0) + { + color_ctrl->r = 0; + color_ctrl->g = 0; + color_ctrl->b = 0; + + // if all at the start + // set them all to the intensity + } + else if (maxVal == 0) + { + color_ctrl->r = iVal; + color_ctrl->g = iVal; + color_ctrl->b = iVal; + + } + else + { + // add delta amounts to each + F32 delta = (iVal - maxVal) / maxVal; + color_ctrl->r *= (1.0f + delta); + color_ctrl->g *= (1.0f + delta); + color_ctrl->b *= (1.0f + delta); + } + + // divide sun color vals by three + if (color_ctrl->isSunOrAmbientColor) + { + childSetValue(rName, color_ctrl->r/3); + childSetValue(gName, color_ctrl->g/3); + childSetValue(bName, color_ctrl->b/3); + } + else if (color_ctrl->isBlueHorizonOrDensity) + { + childSetValue(rName, color_ctrl->r/2); + childSetValue(gName, color_ctrl->g/2); + childSetValue(bName, color_ctrl->b/2); + } + else + { + // set the sliders to the new vals + childSetValue(rName, color_ctrl->r); + childSetValue(gName, color_ctrl->g); + childSetValue(bName, color_ctrl->b); + } + } + + // now update the current parameters and send them to shaders + color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); +} + +/// GLOW SPECIFIC CODE +void LLFloaterEditSky::onGlowRMoved(LLUICtrl* ctrl, void* userdata) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLColorControl* color_ctrl = static_cast(userdata); + + // scaled by 20 + color_ctrl->r = (2 - sldr_ctrl->getValueF32()) * 20; + + color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); +} + +/// \NOTE that we want NEGATIVE (-) B +void LLFloaterEditSky::onGlowBMoved(LLUICtrl* ctrl, void* userdata) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLColorControl* color_ctrl = static_cast(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->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); +} + +void LLFloaterEditSky::onFloatControlMoved(LLUICtrl* ctrl, void* userdata) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + WLFloatControl * floatControl = static_cast(userdata); + + floatControl->x = sldr_ctrl->getValueF32() / floatControl->mult; + + floatControl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); +} + + +// Lighting callbacks + +// time of day +void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sun_sldr = getChild("WLSunAngle"); + LLSliderCtrl* east_sldr = getChild("WLEastAngle"); + + WLColorControl* color_ctrl = static_cast(userdata); + + // get the two angles + LLWLParamManager * param_mgr = LLWLParamManager::getInstance(); + + param_mgr->mCurParams.setSunAngle(F_TWO_PI * sun_sldr->getValueF32()); + param_mgr->mCurParams.setEastAngle(F_TWO_PI * east_sldr->getValueF32()); + + // 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; + + color_ctrl->update(param_mgr->mCurParams); + param_mgr->propagateParameters(); +} + +void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + + LLWLParamManager::getInstance()->mCurParams.setStarBrightness(sldr_ctrl->getValueF32()); +} + +// Clouds +void LLFloaterEditSky::onCloudScrollXMoved(LLUICtrl* ctrl) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(ctrl); + // *HACK all cloud scrolling is off by an additive of 10. + LLWLParamManager::getInstance()->mCurParams.setCloudScrollX(sldr_ctrl->getValueF32() + 10.0f); +} + +void LLFloaterEditSky::onCloudScrollYMoved(LLUICtrl* ctrl) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLSliderCtrl* sldr_ctrl = static_cast(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(ctrl); + + bool lock = cb_ctrl->get(); + LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollX(!lock); + + LLSliderCtrl* sldr = getChild("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(ctrl); + bool lock = cb_ctrl->get(); + LLWLParamManager::getInstance()->mCurParams.setEnableCloudScrollY(!lock); + + LLSliderCtrl* sldr = getChild("WLCloudScrollY"); + + if (cb_ctrl->get()) + { + sldr->setEnabled(false); + } + else + { + sldr->setEnabled(true); + } +} + +//================================================================================================= + +bool LLFloaterEditSky::isNewPreset() const +{ + return mKey.asString() == "new"; +} + +void LLFloaterEditSky::refreshSkyPresetsList() +{ + mSkyPresetCombo->removeall(); + + std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); + const std::map &sky_params_map = LLWLParamManager::getInstance()->mParamList; + for (std::map::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + { + const LLWLParamKey& key = it->first; + std::string item_title = key.name; + if (key.scope == LLEnvKey::SCOPE_REGION) + { + item_title += " (" + region_name + ")"; + } + mSkyPresetCombo->add(item_title, key.toLLSD()); + } + + mSkyPresetCombo->setLabel(getString("combo_label")); +} + +void LLFloaterEditSky::enableEditing(bool enable) +{ + // Enable/disable the tab and their contents. + LLTabContainer* tab_container = getChild("WindLight Tabs"); + tab_container->setEnabled(enable); + for (S32 i = 0; i < tab_container->getTabCount(); ++i) + { + tab_container->enableTabButton(i, enable); + tab_container->getPanelByIndex(i)->setCtrlsEnabled(enable); + } + + // Enable/disable saving. + mSaveButton->setEnabled(enable); + mMakeDefaultCheckBox->setEnabled(enable); +} + +void LLFloaterEditSky::saveRegionSky() +{ + LLWLParamKey key(getSelectedSkyPreset()); + llassert(key.scope == LLEnvKey::SCOPE_REGION); + + LL_DEBUGS("Windlight") << "Saving region sky preset: " << key.name << llendl; + LLWLParamManager& wl_mgr = LLWLParamManager::instance(); + wl_mgr.mCurParams.mName = key.name; + wl_mgr.setParamSet(key, wl_mgr.mCurParams); + + // *TODO: save to cached region settings. + LL_WARNS("Windlight") << "Saving region sky is not fully implemented yet" << LL_ENDL; +} + +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() +{ + // Disable saving a sky preset having empty name. + LLWLParamKey key = getSelectedSkyPreset(); + mSaveButton->setEnabled(!key.name.empty()); +} + +void LLFloaterEditSky::onSkyPresetSelected() +{ + LLWLParamKey key = getSelectedSkyPreset(); + LLWLParamSet sky_params; + + if (!LLWLParamManager::instance().getParamSet(key, sky_params)) + { + llwarns << "No sky preset named " << key.toString() << llendl; + llassert(false); + return; + } + + LLEnvManagerNew::instance().useSkyParams(sky_params.getAll()); + //syncControls(); + + bool can_edit = (key.scope == LLEnvKey::SCOPE_LOCAL || LLEnvManagerNew::canEditRegionSettings()); + enableEditing(can_edit); + + mMakeDefaultCheckBox->setEnabled(key.scope == LLEnvKey::SCOPE_LOCAL); +} + +void LLFloaterEditSky::onBtnSave() +{ + LLWLParamKey selected_sky = getSelectedSkyPreset(); + LLWLParamManager& wl_mgr = LLWLParamManager::instance(); + + if (selected_sky.scope == LLEnvKey::SCOPE_REGION) + { + saveRegionSky(); + closeFloater(); + return; + } + + std::string name = selected_sky.name; + if (name.empty()) + { + // *TODO: show an alert + llwarns << "Empty sky preset name" << llendl; + return; + } + + // Don't allow overwriting system presets. + if (wl_mgr.isSystemPreset(name)) + { + LLNotificationsUtil::add("WLNoEditDefault"); + return; + } + + // Save, ask for confirmation for overwriting an existing preset. + if (wl_mgr.hasParamSet(selected_sky)) + { + LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterEditSky::onSaveAnswer, this, _1, _2)); + } + else + { + // new preset, hence no confirmation needed + onSaveConfirmed(); + } } void LLFloaterEditSky::onBtnCancel() { closeFloater(); } + +bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + + // If they choose save, do it. Otherwise, don't do anything + if (option == 0) + { + onSaveConfirmed(); + } + + return false; +} + +void LLFloaterEditSky::onSaveConfirmed() +{ + // Save current params to the selected preset. + LLWLParamKey key(getSelectedSkyPreset()); + + LL_DEBUGS("Windlight") << "Saving sky preset " << key.name << LL_ENDL; + LLWLParamManager& wl_mgr = LLWLParamManager::instance(); + if (wl_mgr.hasParamSet(key)) + { + wl_mgr.setParamSet(key, wl_mgr.mCurParams); + } + else + { + wl_mgr.addParamSet(key, wl_mgr.mCurParams); + } + + wl_mgr.savePreset(key); + + // Change preference if requested. + if (mMakeDefaultCheckBox->getValue()) + { + LL_DEBUGS("Windlight") << key.name << " is now the new preferred sky preset" << llendl; + LLEnvManagerNew::instance().setUseSkyPreset(key.name); + } + + closeFloater(); +} -- cgit v1.2.3 From 7151a4e6b02f02155387fc595034a42aebd7ec9c Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 17:41:26 +0300 Subject: STORM-1255 WIP Consistency pass on sky presets removal. * Update all related floaters when a sky preset gets removed. * Don't allow removing skies referenced by (local) day cycles. * Other minor fixes. --- indra/newview/llfloatereditsky.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 96dfb7a8a9..f78baf2ed5 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -131,6 +131,8 @@ void LLFloaterEditSky::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); + LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); + //------------------------------------------------------------------------- LLWLParamManager& param_mgr = LLWLParamManager::instance(); @@ -806,8 +808,8 @@ void LLFloaterEditSky::onSkyPresetSelected() if (!LLWLParamManager::instance().getParamSet(key, sky_params)) { - llwarns << "No sky preset named " << key.toString() << llendl; - llassert(false); + // Manually entered string? + LL_WARNS("Windlight") << "No sky preset named " << key.toString() << LL_ENDL; return; } @@ -904,3 +906,19 @@ void LLFloaterEditSky::onSaveConfirmed() closeFloater(); } + +void LLFloaterEditSky::onSkyPresetListChange() +{ + LLWLParamKey key = getSelectedSkyPreset(); // preset being edited + if (!LLWLParamManager::instance().hasParamSet(key)) + { + // Preset we've been editing doesn't exist anymore. Close the floater. + closeFloater(false); + } + else + { + // A new preset has been added. + // Refresh the presets list, though it may not make sense as the floater is about to be closed. + refreshSkyPresetsList(); + } +} -- cgit v1.2.3 From 3ce8ea1dff578511344c453b281ddfc592a56c58 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 17:46:56 +0300 Subject: STORM-1255 WIP Moved stuff around for consistency between the header and the .cpp. --- indra/newview/llfloatereditsky.cpp | 86 +++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index f78baf2ed5..da3f684ba2 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -45,8 +45,6 @@ static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; -//================================================================================================= - LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) : LLFloater(key) , mSkyPresetNameEditor(NULL) @@ -210,6 +208,8 @@ void LLFloaterEditSky::initCallbacks(void) getChild("WLStarAlpha")->setCommitCallback(boost::bind(&LLFloaterEditSky::onStarAlphaMoved, this, _1)); } +//================================================================================================= + void LLFloaterEditSky::syncControls() { bool err; @@ -822,6 +822,47 @@ void LLFloaterEditSky::onSkyPresetSelected() mMakeDefaultCheckBox->setEnabled(key.scope == LLEnvKey::SCOPE_LOCAL); } +bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + + // If they choose save, do it. Otherwise, don't do anything + if (option == 0) + { + onSaveConfirmed(); + } + + return false; +} + +void LLFloaterEditSky::onSaveConfirmed() +{ + // Save current params to the selected preset. + LLWLParamKey key(getSelectedSkyPreset()); + + LL_DEBUGS("Windlight") << "Saving sky preset " << key.name << LL_ENDL; + LLWLParamManager& wl_mgr = LLWLParamManager::instance(); + if (wl_mgr.hasParamSet(key)) + { + wl_mgr.setParamSet(key, wl_mgr.mCurParams); + } + else + { + wl_mgr.addParamSet(key, wl_mgr.mCurParams); + } + + wl_mgr.savePreset(key); + + // Change preference if requested. + if (mMakeDefaultCheckBox->getValue()) + { + LL_DEBUGS("Windlight") << key.name << " is now the new preferred sky preset" << llendl; + LLEnvManagerNew::instance().setUseSkyPreset(key.name); + } + + closeFloater(); +} + void LLFloaterEditSky::onBtnSave() { LLWLParamKey selected_sky = getSelectedSkyPreset(); @@ -866,47 +907,6 @@ void LLFloaterEditSky::onBtnCancel() closeFloater(); } -bool LLFloaterEditSky::onSaveAnswer(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - - // If they choose save, do it. Otherwise, don't do anything - if (option == 0) - { - onSaveConfirmed(); - } - - return false; -} - -void LLFloaterEditSky::onSaveConfirmed() -{ - // Save current params to the selected preset. - LLWLParamKey key(getSelectedSkyPreset()); - - LL_DEBUGS("Windlight") << "Saving sky preset " << key.name << LL_ENDL; - LLWLParamManager& wl_mgr = LLWLParamManager::instance(); - if (wl_mgr.hasParamSet(key)) - { - wl_mgr.setParamSet(key, wl_mgr.mCurParams); - } - else - { - wl_mgr.addParamSet(key, wl_mgr.mCurParams); - } - - wl_mgr.savePreset(key); - - // Change preference if requested. - if (mMakeDefaultCheckBox->getValue()) - { - LL_DEBUGS("Windlight") << key.name << " is now the new preferred sky preset" << llendl; - LLEnvManagerNew::instance().setUseSkyPreset(key.name); - } - - closeFloater(); -} - void LLFloaterEditSky::onSkyPresetListChange() { LLWLParamKey key = getSelectedSkyPreset(); // preset being edited -- cgit v1.2.3 From f39b7cffc6d75a231d00c5bb17e450f21fe36ae0 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 18:48:04 +0300 Subject: STORM-1255 WIP When region environment changes, update the Edit Sky floater. --- indra/newview/llfloatereditsky.cpp | 51 +++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index da3f684ba2..a35b7cb003 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -88,18 +88,7 @@ void LLFloaterEditSky::onOpen(const LLSD& key) mSkyPresetCombo->setVisible(!new_preset); mSkyPresetNameEditor->setVisible(new_preset); - if (isNewPreset()) - { - mSkyPresetNameEditor->setValue(LLSD()); - mSaveButton->setEnabled(FALSE); // will be enabled as soon as users enters a name - } - else - { - refreshSkyPresetsList(); - - // Disable controls until a sky preset to edit is selected. - enableEditing(false); - } + reset(); } // virtual @@ -129,6 +118,7 @@ void LLFloaterEditSky::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); + LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditSky::onRegionSettingsChange, this)); LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); //------------------------------------------------------------------------- @@ -712,6 +702,22 @@ void LLFloaterEditSky::onCloudScrollYToggled(LLUICtrl* ctrl) //================================================================================================= +void LLFloaterEditSky::reset() +{ + if (isNewPreset()) + { + mSkyPresetNameEditor->setValue(LLSD()); + mSaveButton->setEnabled(FALSE); // will be enabled as soon as users enters a name + } + else + { + refreshSkyPresetsList(); + + // Disable controls until a sky preset to edit is selected. + enableEditing(false); + } +} + bool LLFloaterEditSky::isNewPreset() const { return mKey.asString() == "new"; @@ -922,3 +928,24 @@ void LLFloaterEditSky::onSkyPresetListChange() refreshSkyPresetsList(); } } + +void LLFloaterEditSky::onRegionSettingsChange() +{ + // If creating a new sky, don't bother. + if (isNewPreset()) + { + return; + } + + if (getSelectedSkyPreset().scope == LLEnvKey::SCOPE_REGION) // if editing a region sky + { + // reset the floater to its initial state + reset(); + + // *TODO: Notify user? + } + else // editing a local sky + { + refreshSkyPresetsList(); + } +} -- cgit v1.2.3 From f69912267aa73e158d34b75797410dd6b4694084 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 19:02:52 +0300 Subject: STORM-1255 WIP Re-check for region skies editing permission when region info gets updated. --- indra/newview/llfloatereditsky.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index a35b7cb003..538d6cfa39 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -39,6 +39,7 @@ // newview #include "llagent.h" +#include "llregioninfomodel.h" #include "llviewerregion.h" #undef max @@ -121,6 +122,9 @@ void LLFloaterEditSky::initCallbacks(void) 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(); @@ -949,3 +953,17 @@ void LLFloaterEditSky::onRegionSettingsChange() refreshSkyPresetsList(); } } + +void LLFloaterEditSky::onRegionInfoUpdate() +{ + bool can_edit = true; + + // If we've selected the region day cycle for editing. + if (getSelectedSkyPreset().scope == LLEnvKey::SCOPE_REGION) + { + // check whether we have the access + can_edit = LLEnvManagerNew::canEditRegionSettings(); + } + + enableEditing(can_edit); +} -- cgit v1.2.3 From 3519c6cd6bc0e8b572c3f92ba8baa4e44e0fec50 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 19:11:50 +0300 Subject: STORM-1255 WIP Disable editing region skies until the workflow is clear enough. --- indra/newview/llfloatereditsky.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 538d6cfa39..7b8e3b89ca 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -739,7 +739,11 @@ void LLFloaterEditSky::refreshSkyPresetsList() std::string item_title = key.name; if (key.scope == LLEnvKey::SCOPE_REGION) { +#if 1 // Disable editing region skies until the workflow is clear enough. + continue; +#else item_title += " (" + region_name + ")"; +#endif } mSkyPresetCombo->add(item_title, key.toLLSD()); } -- cgit v1.2.3 From 173b9d11c41d32c52c4cd64c23e0a5b0f3ef09fc Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 9 Jun 2011 16:38:51 +0300 Subject: STORM-1254 WIP Implemented created and editing local water presets. --- indra/newview/llfloatereditsky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 7b8e3b89ca..27280565c7 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -962,7 +962,7 @@ void LLFloaterEditSky::onRegionInfoUpdate() { bool can_edit = true; - // If we've selected the region day cycle for editing. + // If we've selected a region sky preset for editing. if (getSelectedSkyPreset().scope == LLEnvKey::SCOPE_REGION) { // check whether we have the access -- cgit v1.2.3 From 4fd946fa3e5217b8f64e0fcd91d268c7eaf1bbf5 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 10 Jun 2011 23:44:13 +0300 Subject: STORM-1305 WIP User sky presets now go first in all lists. --- indra/newview/llfloatereditsky.cpp | 40 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 27280565c7..053208202d 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -731,21 +731,37 @@ void LLFloaterEditSky::refreshSkyPresetsList() { mSkyPresetCombo->removeall(); + LLWLParamManager::preset_name_list_t region_presets, user_presets, sys_presets; + LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + +#if 0 // Disable editing region skies until the workflow is clear enough. + // Add region presets. std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); - const std::map &sky_params_map = LLWLParamManager::getInstance()->mParamList; - for (std::map::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) { - const LLWLParamKey& key = it->first; - std::string item_title = key.name; - if (key.scope == LLEnvKey::SCOPE_REGION) - { -#if 1 // Disable editing region skies until the workflow is clear enough. - continue; -#else - item_title += " (" + region_name + ")"; + std::string item_title = *it + " (" + region_name + ")"; + mSkyPresetCombo->add(item_title, LLWLParamKey(*it, LLEnvKey::SCOPE_REGION).toLLSD()); + } + if (region_presets.size() > 0) + { + mSkyPresetCombo->addSeparator(); + } #endif - } - mSkyPresetCombo->add(item_title, key.toLLSD()); + + // Add user presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); + } + if (user_presets.size() > 0) + { + mSkyPresetCombo->addSeparator(); + } + + // Add system presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) + { + mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); } mSkyPresetCombo->setLabel(getString("combo_label")); -- cgit v1.2.3 From b5be90d0d2f26792f0044286f9b64126446dc101 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 28 Jun 2011 16:59:09 +0300 Subject: STORM-1345 FIXED Replaced sliders with color pickers in the Edit Sky Preset floater. TODO: Find out why the color picker widget has higher precision than the old sliders, and decide whether to "fix" that. --- indra/newview/llfloatereditsky.cpp | 218 +++++++++++-------------------------- 1 file changed, 61 insertions(+), 157 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 053208202d..60b6fd7cf1 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -1,5 +1,5 @@ /** - * @file llfloatereditsky.h + * @file llfloatereditsky.cpp * @brief Floater to create or edit a sky preset * * $LicenseInfo:firstyear=2011&license=viewerlgpl$ @@ -39,12 +39,13 @@ // newview #include "llagent.h" +#include "llcolorswatch.h" #include "llregioninfomodel.h" #include "llviewerregion.h" -#undef max - 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; LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) : LLFloater(key) @@ -130,11 +131,7 @@ void LLFloaterEditSky::initCallbacks(void) LLWLParamManager& param_mgr = LLWLParamManager::instance(); // blue horizon - getChild("WLBlueHorizonR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mBlueHorizon)); - getChild("WLBlueHorizonR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mBlueHorizon)); - getChild("WLBlueHorizonG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mBlueHorizon)); - getChild("WLBlueHorizonB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mBlueHorizon)); - getChild("WLBlueHorizonI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mBlueHorizon)); + getChild("WLBlueHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mBlueHorizon)); // haze density, horizon, mult, and altitude getChild("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mHazeDensity)); @@ -143,28 +140,19 @@ void LLFloaterEditSky::initCallbacks(void) getChild("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, ¶m_mgr.mMaxAlt)); // blue density - getChild("WLBlueDensityR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mBlueDensity)); - getChild("WLBlueDensityG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mBlueDensity)); - getChild("WLBlueDensityB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mBlueDensity)); - getChild("WLBlueDensityI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mBlueDensity)); + getChild("WLBlueDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mBlueDensity)); // Lighting // sunlight - getChild("WLSunlightR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mSunlight)); - getChild("WLSunlightG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mSunlight)); - getChild("WLSunlightB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mSunlight)); - getChild("WLSunlightI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mSunlight)); + getChild("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mSunlight)); // glow getChild("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, ¶m_mgr.mGlow)); getChild("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, ¶m_mgr.mGlow)); // ambient - getChild("WLAmbientR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mAmbient)); - getChild("WLAmbientG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mAmbient)); - getChild("WLAmbientB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mAmbient)); - getChild("WLAmbientI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mAmbient)); + getChild("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mAmbient)); // time of day getChild("WLSunAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); @@ -173,10 +161,7 @@ void LLFloaterEditSky::initCallbacks(void) // Clouds // Cloud Color - getChild("WLCloudColorR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudColor)); - getChild("WLCloudColorG")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, ¶m_mgr.mCloudColor)); - getChild("WLCloudColorB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, ¶m_mgr.mCloudColor)); - getChild("WLCloudColorI")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlIMoved, this, _1, ¶m_mgr.mCloudColor)); + getChild("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mCloudColor)); // Cloud getChild("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, ¶m_mgr.mCloudMain)); @@ -214,13 +199,7 @@ void LLFloaterEditSky::syncControls() // blue horizon param_mgr->mBlueHorizon = cur_params.getVector(param_mgr->mBlueHorizon.mName, err); - childSetValue("WLBlueHorizonR", param_mgr->mBlueHorizon.r / 2.0); - childSetValue("WLBlueHorizonG", param_mgr->mBlueHorizon.g / 2.0); - childSetValue("WLBlueHorizonB", param_mgr->mBlueHorizon.b / 2.0); - childSetValue("WLBlueHorizonI", - std::max(param_mgr->mBlueHorizon.r / 2.0, - std::max(param_mgr->mBlueHorizon.g / 2.0, - param_mgr->mBlueHorizon.b / 2.0))); + setColorSwatch("WLBlueHorizon", param_mgr->mBlueHorizon, WL_BLUE_HORIZON_DENSITY_SCALE); // haze density, horizon, mult, and altitude param_mgr->mHazeDensity = cur_params.getVector(param_mgr->mHazeDensity.mName, err); @@ -235,23 +214,13 @@ void LLFloaterEditSky::syncControls() // blue density param_mgr->mBlueDensity = cur_params.getVector(param_mgr->mBlueDensity.mName, err); - childSetValue("WLBlueDensityR", param_mgr->mBlueDensity.r / 2.0); - childSetValue("WLBlueDensityG", param_mgr->mBlueDensity.g / 2.0); - childSetValue("WLBlueDensityB", param_mgr->mBlueDensity.b / 2.0); - childSetValue("WLBlueDensityI", - std::max(param_mgr->mBlueDensity.r / 2.0, - std::max(param_mgr->mBlueDensity.g / 2.0, param_mgr->mBlueDensity.b / 2.0))); + setColorSwatch("WLBlueDensity", param_mgr->mBlueDensity, WL_BLUE_HORIZON_DENSITY_SCALE); // Lighting // sunlight param_mgr->mSunlight = cur_params.getVector(param_mgr->mSunlight.mName, err); - childSetValue("WLSunlightR", param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE); - childSetValue("WLSunlightG", param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE); - childSetValue("WLSunlightB", param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE); - childSetValue("WLSunlightI", - std::max(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE, - std::max(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE))); + setColorSwatch("WLSunlight", param_mgr->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); // glow param_mgr->mGlow = cur_params.getVector(param_mgr->mGlow.mName, err); @@ -260,12 +229,7 @@ void LLFloaterEditSky::syncControls() // ambient param_mgr->mAmbient = cur_params.getVector(param_mgr->mAmbient.mName, err); - childSetValue("WLAmbientR", param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE); - childSetValue("WLAmbientG", param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE); - childSetValue("WLAmbientB", param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE); - childSetValue("WLAmbientI", - std::max(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE, - std::max(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE))); + setColorSwatch("WLAmbient", param_mgr->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); childSetValue("WLSunAngle", param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); @@ -274,12 +238,7 @@ void LLFloaterEditSky::syncControls() // Cloud Color param_mgr->mCloudColor = cur_params.getVector(param_mgr->mCloudColor.mName, err); - childSetValue("WLCloudColorR", param_mgr->mCloudColor.r); - childSetValue("WLCloudColorG", param_mgr->mCloudColor.g); - childSetValue("WLCloudColorB", param_mgr->mCloudColor.b); - childSetValue("WLCloudColorI", - std::max(param_mgr->mCloudColor.r, - std::max(param_mgr->mCloudColor.g, param_mgr->mCloudColor.b))); + setColorSwatch("WLCloudColor", param_mgr->mCloudColor, WL_CLOUD_SLIDER_SCALE); // Cloud param_mgr->mCloudMain = cur_params.getVector(param_mgr->mCloudMain.mName, err); @@ -338,8 +297,43 @@ void LLFloaterEditSky::syncControls() childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness()); } +void LLFloaterEditSky::setColorSwatch(const std::string& name, const WLColorControl& from_ctrl, F32 k) +{ + // Set the value, dividing it by first. + LLVector4 color_vec = from_ctrl; + getChild(name)->set(LLColor4(color_vec / k)); +} // color control callbacks +void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) +{ + LLWLParamManager::getInstance()->mAnimator.deactivate(); + + LLColorSwatchCtrl* swatch = static_cast(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])); + + // Multiply RGB values by the appropriate factor. + F32 k = WL_CLOUD_SLIDER_SCALE; + if (color_ctrl->isSunOrAmbientColor) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + if (color_ctrl->isBlueHorizonOrDensity) + { + k = WL_BLUE_HORIZON_DENSITY_SCALE; + } + + color_vec *= k; // intensity isn't affected by the multiplication + + // Apply the new RGBI value. + *color_ctrl = color_vec; + color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); +} + void LLFloaterEditSky::onColorControlRMoved(LLUICtrl* ctrl, void* userdata) { LLWLParamManager::getInstance()->mAnimator.deactivate(); @@ -350,11 +344,11 @@ void LLFloaterEditSky::onColorControlRMoved(LLUICtrl* ctrl, void* userdata) color_ctrl->r = sldr_ctrl->getValueF32(); if (color_ctrl->isSunOrAmbientColor) { - color_ctrl->r *= 3; + color_ctrl->r *= WL_SUN_AMBIENT_SLIDER_SCALE; } if (color_ctrl->isBlueHorizonOrDensity) { - color_ctrl->r *= 2; + color_ctrl->r *= WL_BLUE_HORIZON_DENSITY_SCALE; } // move i if it's the max @@ -366,11 +360,11 @@ void LLFloaterEditSky::onColorControlRMoved(LLUICtrl* ctrl, void* userdata) if (color_ctrl->isSunOrAmbientColor) { - childSetValue(name, color_ctrl->r / 3); + childSetValue(name, color_ctrl->r / WL_SUN_AMBIENT_SLIDER_SCALE); } else if (color_ctrl->isBlueHorizonOrDensity) { - childSetValue(name, color_ctrl->r / 2); + childSetValue(name, color_ctrl->r / WL_BLUE_HORIZON_DENSITY_SCALE); } else { @@ -393,11 +387,11 @@ void LLFloaterEditSky::onColorControlGMoved(LLUICtrl* ctrl, void* userdata) color_ctrl->g = sldr_ctrl->getValueF32(); if (color_ctrl->isSunOrAmbientColor) { - color_ctrl->g *= 3; + color_ctrl->g *= WL_SUN_AMBIENT_SLIDER_SCALE; } if (color_ctrl->isBlueHorizonOrDensity) { - color_ctrl->g *= 2; + color_ctrl->g *= WL_BLUE_HORIZON_DENSITY_SCALE; } // move i if it's the max @@ -409,11 +403,11 @@ void LLFloaterEditSky::onColorControlGMoved(LLUICtrl* ctrl, void* userdata) if (color_ctrl->isSunOrAmbientColor) { - childSetValue(name, color_ctrl->g / 3); + childSetValue(name, color_ctrl->g / WL_SUN_AMBIENT_SLIDER_SCALE); } else if (color_ctrl->isBlueHorizonOrDensity) { - childSetValue(name, color_ctrl->g / 2); + childSetValue(name, color_ctrl->g / WL_BLUE_HORIZON_DENSITY_SCALE); } else { @@ -436,11 +430,11 @@ void LLFloaterEditSky::onColorControlBMoved(LLUICtrl* ctrl, void* userdata) color_ctrl->b = sldr_ctrl->getValueF32(); if (color_ctrl->isSunOrAmbientColor) { - color_ctrl->b *= 3; + color_ctrl->b *= WL_SUN_AMBIENT_SLIDER_SCALE; } if (color_ctrl->isBlueHorizonOrDensity) { - color_ctrl->b *= 2; + color_ctrl->b *= WL_BLUE_HORIZON_DENSITY_SCALE; } // move i if it's the max @@ -452,11 +446,11 @@ void LLFloaterEditSky::onColorControlBMoved(LLUICtrl* ctrl, void* userdata) if (color_ctrl->isSunOrAmbientColor) { - childSetValue(name, color_ctrl->b / 3); + childSetValue(name, color_ctrl->b / WL_SUN_AMBIENT_SLIDER_SCALE); } else if (color_ctrl->isBlueHorizonOrDensity) { - childSetValue(name, color_ctrl->b / 2); + childSetValue(name, color_ctrl->b / WL_BLUE_HORIZON_DENSITY_SCALE); } else { @@ -469,96 +463,6 @@ void LLFloaterEditSky::onColorControlBMoved(LLUICtrl* ctrl, void* userdata) LLWLParamManager::getInstance()->propagateParameters(); } -void LLFloaterEditSky::onColorControlIMoved(LLUICtrl* ctrl, void* userdata) -{ - LLWLParamManager::getInstance()->mAnimator.deactivate(); - - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - WLColorControl* color_ctrl = static_cast(userdata); - - color_ctrl->i = sldr_ctrl->getValueF32(); - - // only for sliders where we pass a name - if (color_ctrl->hasSliderName) - { - // set it to the top - F32 maxVal = std::max(std::max(color_ctrl->r, color_ctrl->g), color_ctrl->b); - F32 iVal; - - if (color_ctrl->isSunOrAmbientColor) - { - iVal = color_ctrl->i * 3; - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - iVal = color_ctrl->i * 2; - } - else - { - iVal = color_ctrl->i; - } - - // get the names of the other sliders - std::string rName = color_ctrl->mSliderName; - rName.append("R"); - std::string gName = color_ctrl->mSliderName; - gName.append("G"); - std::string bName = color_ctrl->mSliderName; - bName.append("B"); - - // handle if at 0 - if (iVal == 0) - { - color_ctrl->r = 0; - color_ctrl->g = 0; - color_ctrl->b = 0; - - // if all at the start - // set them all to the intensity - } - else if (maxVal == 0) - { - color_ctrl->r = iVal; - color_ctrl->g = iVal; - color_ctrl->b = iVal; - - } - else - { - // add delta amounts to each - F32 delta = (iVal - maxVal) / maxVal; - color_ctrl->r *= (1.0f + delta); - color_ctrl->g *= (1.0f + delta); - color_ctrl->b *= (1.0f + delta); - } - - // divide sun color vals by three - if (color_ctrl->isSunOrAmbientColor) - { - childSetValue(rName, color_ctrl->r/3); - childSetValue(gName, color_ctrl->g/3); - childSetValue(bName, color_ctrl->b/3); - } - else if (color_ctrl->isBlueHorizonOrDensity) - { - childSetValue(rName, color_ctrl->r/2); - childSetValue(gName, color_ctrl->g/2); - childSetValue(bName, color_ctrl->b/2); - } - else - { - // set the sliders to the new vals - childSetValue(rName, color_ctrl->r); - childSetValue(gName, color_ctrl->g); - childSetValue(bName, color_ctrl->b); - } - } - - // now update the current parameters and send them to shaders - color_ctrl->update(LLWLParamManager::getInstance()->mCurParams); - LLWLParamManager::getInstance()->propagateParameters(); -} - /// GLOW SPECIFIC CODE void LLFloaterEditSky::onGlowRMoved(LLUICtrl* ctrl, void* userdata) { -- cgit v1.2.3 From 76acc754370580e7e60ac2a929e165b79c24a7c3 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Wed, 29 Jun 2011 23:48:36 +0300 Subject: STORM-1305 WIP Edit Sky floater UI changes. * Implemented new layout (made the floater smaller, moved widgets around). * Implemented new sun phase slider, bound to 24h time. --- indra/newview/llfloatereditsky.cpp | 55 +++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 60b6fd7cf1..96289be31e 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -32,10 +32,12 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" +#include "llmultisliderctrl.h" #include "llnotifications.h" #include "llnotificationsutil.h" #include "llsliderctrl.h" #include "lltabcontainer.h" +#include "lltimectrl.h" // newview #include "llagent.h" @@ -47,6 +49,18 @@ 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; +static F32 sun_pos_to_time24(F32 sun_pos) +{ + return fmodf(sun_pos * 24.0f + 6, 24.0f); +} + +static F32 time24_to_sun_pos(F32 time24) +{ + F32 sun_pos = fmodf((time24 - 6) / 24.0f, 1.0f); + if (sun_pos < 0) ++sun_pos; + return sun_pos; +} + LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) : LLFloater(key) , mSkyPresetNameEditor(NULL) @@ -66,6 +80,9 @@ BOOL LLFloaterEditSky::postBuild() initCallbacks(); + // Create the sun position scrubber on the slider. + getChild("WLSunPos")->addSlider(12.f); + return TRUE; } @@ -155,7 +172,9 @@ void LLFloaterEditSky::initCallbacks(void) getChild("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mAmbient)); // time of day - getChild("WLSunAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); + getChild("WLSunAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); // old slider + getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); // multi-slider + getChild("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); // Clouds @@ -231,7 +250,9 @@ void LLFloaterEditSky::syncControls() param_mgr->mAmbient = cur_params.getVector(param_mgr->mAmbient.mName, err); setColorSwatch("WLAmbient", param_mgr->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); - childSetValue("WLSunAngle", param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); + F32 sun_pos = param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI; + getChild("WLSunAngle")->setValue(sun_pos); + getChild("WLSunPos")->setCurSliderValue(sun_pos_to_time24(sun_pos), TRUE); childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); // Clouds @@ -515,14 +536,35 @@ void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) LLWLParamManager::getInstance()->mAnimator.deactivate(); LLSliderCtrl* sun_sldr = getChild("WLSunAngle"); + LLMultiSliderCtrl* sun_msldr = getChild("WLSunPos"); LLSliderCtrl* east_sldr = getChild("WLEastAngle"); + LLTimeCtrl* time_ctrl = getChild("WLDayTime"); WLColorControl* color_ctrl = static_cast(userdata); + F32 sun_pos = 0.0f; // 0..1 + F32 time24 = 0.0f; // 0..24 + if (ctrl == sun_msldr) // new slider moved + { + time24 = sun_msldr->getCurSliderValue(); + sun_pos = time24_to_sun_pos(time24); + + sun_sldr->setValue(sun_pos); // update the old slider + } + else + { + sun_pos = sun_sldr->getValueF32(); + time24 = sun_pos_to_time24(sun_pos); + + sun_msldr->setCurSliderValue(time24, TRUE); // update the new slider + } + + 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 * sun_sldr->getValueF32()); + param_mgr->mCurParams.setSunAngle(F_TWO_PI * sun_pos); param_mgr->mCurParams.setEastAngle(F_TWO_PI * east_sldr->getValueF32()); // set the sun vector @@ -537,6 +579,13 @@ void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) param_mgr->propagateParameters(); } +void LLFloaterEditSky::onTimeChanged() +{ + F32 time24 = getChild("WLDayTime")->getTime24(); + getChild("WLSunPos")->setCurSliderValue(time24, TRUE); + onSunMoved(getChild("WLSunPos"), &LLWLParamManager::instance().mLightnorm); +} + void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) { LLWLParamManager::getInstance()->mAnimator.deactivate(); -- cgit v1.2.3 From 3be8ae9d4274ca16ff2dbf8fa10a23f48c2e7022 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 30 Jun 2011 01:19:14 +0300 Subject: STORM-1305 WIP Edit Sky floater: removed the old sun position slider, added hour marks to the new one. --- indra/newview/llfloatereditsky.cpp | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 96289be31e..0163dfbf30 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -172,7 +172,6 @@ void LLFloaterEditSky::initCallbacks(void) getChild("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, ¶m_mgr.mAmbient)); // time of day - getChild("WLSunAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); // old slider getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); // multi-slider getChild("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, ¶m_mgr.mLightnorm)); @@ -251,7 +250,6 @@ void LLFloaterEditSky::syncControls() setColorSwatch("WLAmbient", param_mgr->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); F32 sun_pos = param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI; - getChild("WLSunAngle")->setValue(sun_pos); getChild("WLSunPos")->setCurSliderValue(sun_pos_to_time24(sun_pos), TRUE); childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); @@ -535,36 +533,18 @@ void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) { LLWLParamManager::getInstance()->mAnimator.deactivate(); - LLSliderCtrl* sun_sldr = getChild("WLSunAngle"); LLMultiSliderCtrl* sun_msldr = getChild("WLSunPos"); LLSliderCtrl* east_sldr = getChild("WLEastAngle"); LLTimeCtrl* time_ctrl = getChild("WLDayTime"); - WLColorControl* color_ctrl = static_cast(userdata); - F32 sun_pos = 0.0f; // 0..1 - F32 time24 = 0.0f; // 0..24 - if (ctrl == sun_msldr) // new slider moved - { - time24 = sun_msldr->getCurSliderValue(); - sun_pos = time24_to_sun_pos(time24); - - sun_sldr->setValue(sun_pos); // update the old slider - } - else - { - sun_pos = sun_sldr->getValueF32(); - time24 = sun_pos_to_time24(sun_pos); - - sun_msldr->setCurSliderValue(time24, TRUE); // update the new slider - } - + F32 time24 = sun_msldr->getCurSliderValue(); 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 * sun_pos); + param_mgr->mCurParams.setSunAngle(F_TWO_PI * time24_to_sun_pos(time24)); param_mgr->mCurParams.setEastAngle(F_TWO_PI * east_sldr->getValueF32()); // set the sun vector -- cgit v1.2.3 From 62e7b3d3c71cbd777633525595b87991d797ef65 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 1 Jul 2011 16:31:02 +0300 Subject: STORM-1470 FIXED Sky setting / Lighting preset position controls were inconsistent. --- indra/newview/llfloatereditsky.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatereditsky.cpp') diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 0163dfbf30..abee7b5dc9 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -249,8 +249,9 @@ void LLFloaterEditSky::syncControls() param_mgr->mAmbient = cur_params.getVector(param_mgr->mAmbient.mName, err); setColorSwatch("WLAmbient", param_mgr->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); - F32 sun_pos = param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI; - getChild("WLSunPos")->setCurSliderValue(sun_pos_to_time24(sun_pos), TRUE); + F32 time24 = sun_pos_to_time24(param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); + getChild("WLSunPos")->setCurSliderValue(time24, TRUE); + getChild("WLDayTime")->setTime24(time24); childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); // Clouds -- cgit v1.2.3