diff options
author | Rider Linden <rider@lindenlab.com> | 2018-04-27 17:12:13 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2018-04-27 17:12:13 -0700 |
commit | cf0e4f79f52b4fb24769aa6e355ec8c95c6d2afc (patch) | |
tree | dfcbc227522579c602240cf643a2960c3956688d | |
parent | 2fe4b5169f5d8846b1c6cd4e2aaaf2f41a7b7629 (diff) |
Adding fixed water edit dialog.
-rw-r--r-- | indra/newview/CMakeLists.txt | 4 | ||||
-rw-r--r-- | indra/newview/llenvironment.cpp | 24 | ||||
-rw-r--r-- | indra/newview/llenvironment.h | 3 | ||||
-rw-r--r-- | indra/newview/llfloaterfixedenvironment.cpp | 817 | ||||
-rw-r--r-- | indra/newview/llfloaterfixedenvironment.h | 171 | ||||
-rw-r--r-- | indra/newview/llpaneleditwater.cpp | 212 | ||||
-rw-r--r-- | indra/newview/llpaneleditwater.h | 113 | ||||
-rw-r--r-- | indra/newview/llviewerfloaterreg.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 8 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_fixedenvironment.xml | 114 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_settings_water.xml | 399 |
11 files changed, 1865 insertions, 4 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 1a19e81010..109001f82e 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -234,6 +234,7 @@ set(viewer_SOURCE_FILES llfloaterexperienceprofile.cpp llfloaterexperiences.cpp llfloaterfacebook.cpp + llfloaterfixedenvironment.cpp llfloaterflickr.cpp llfloaterfonttest.cpp llfloatergesture.cpp @@ -420,6 +421,7 @@ set(viewer_SOURCE_FILES llpanelblockedlist.cpp llpanelclassified.cpp llpanelcontents.cpp + llpaneleditwater.cpp llpaneleditwearable.cpp llpanelenvironment.cpp llpanelexperiencelisteditor.cpp @@ -849,6 +851,7 @@ set(viewer_HEADER_FILES llfloaterexperienceprofile.h llfloaterexperiences.h llfloaterfacebook.h + llfloaterfixedenvironment.h llfloaterflickr.h llfloaterfonttest.h llfloatergesture.h @@ -1028,6 +1031,7 @@ set(viewer_HEADER_FILES llpanelblockedlist.h llpanelclassified.h llpanelcontents.h + llpaneleditwater.h llpaneleditwearable.h llpanelenvironment.h llpanelexperiencelisteditor.h diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index c5a1af8747..214ebb82b0 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -329,6 +329,30 @@ S64Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env) LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironment::EnvSelection_t env) { + if (env == ENV_CURRENT) + { + fixedEnvironment_t fixed; + for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx) + { + if (fixed.first && fixed.second) + break; + + DayInstance::ptr_t environment = getEnvironmentInstance(static_cast<EnvSelection_t>(idx)); + if (environment) + { + if (!fixed.first) + fixed.first = environment->getSky(); + if (!fixed.second) + fixed.second = environment->getWater(); + } + } + + if (!fixed.first || !fixed.second) + LL_WARNS("ENVIRONMENT") << "Can not construct complete fixed environment. Missing Sky and/or Water." << LL_ENDL; + + return fixed; + } + if ((env < ENV_EDIT) || (env > ENV_DEFAULT)) { LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL; diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index a7159ca84d..95b24314cb 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -82,7 +82,8 @@ public: ENV_PARCEL, ENV_REGION, ENV_DEFAULT, - ENV_END + ENV_END, + ENV_CURRENT = -1 }; typedef boost::signals2::connection connection_t; diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp new file mode 100644 index 0000000000..d5162ef622 --- /dev/null +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -0,0 +1,817 @@ +/** + * @file llfloaterfixedenvironment.cpp + * @brief Floaters to create and edit fixed settings for sky and water. + * + * $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 "llfloaterfixedenvironment.h" + +#include <boost/make_shared.hpp> + +// libs +#include "llbutton.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" +#include "llsliderctrl.h" +#include "lltabcontainer.h" + +// newview +#include "llpaneleditwater.h" + +#include "llsettingssky.h" +#include "llsettingswater.h" + +#include "llenvironment.h" + +namespace +{ + const std::string FIELD_SETTINGS_NAME("settings_name"); + + const std::string CONTROL_TAB_AREA("tab_settings"); + + const std::string BUTTON_NAME_LOAD("btn_load"); + const std::string BUTTON_NAME_IMPORT("btn_import"); + const std::string BUTTON_NAME_COMMIT("btn_commit"); + const std::string BUTTON_NAME_CANCEL("btn_cancel"); +} + +LLFloaterFixedEnvironment::LLFloaterFixedEnvironment(const LLSD &key) : + LLFloater(key) +{ +} + +BOOL LLFloaterFixedEnvironment::postBuild() +{ + mTab = getChild<LLTabContainer>(CONTROL_TAB_AREA); + mTxtName = getChild<LLLineEditor>(FIELD_SETTINGS_NAME); + + mTxtName->setCommitOnFocusLost(TRUE); + mTxtName->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNameChanged(mTxtName->getValue().asString()); }); + + return TRUE; +} + +void LLFloaterFixedEnvironment::onFocusReceived() +{ + updateEditEnvironment(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); +} + +void LLFloaterFixedEnvironment::onFocusLost() +{ + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); +} + +void LLFloaterFixedEnvironment::refresh() +{ + mTxtName->setValue(mSettings->getName()); + + S32 count = mTab->getTabCount(); + + for (S32 idx = 0; idx < count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(mTab->getPanelByIndex(idx)); + if (panel) + panel->refresh(); + } +} + +void LLFloaterFixedEnvironment::syncronizeTabs() +{ + S32 count = mTab->getTabCount(); + + for (S32 idx = 0; idx < count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(mTab->getPanelByIndex(idx)); + if (panel) + panel->setSettings(mSettings); + } +} + +void LLFloaterFixedEnvironment::onNameChanged(const std::string &name) +{ + mSettings->setName(name); +} + +//========================================================================= +LLFloaterFixedEnvironmentWater::LLFloaterFixedEnvironmentWater(const LLSD &key): + LLFloaterFixedEnvironment(key) +{} + +BOOL LLFloaterFixedEnvironmentWater::postBuild() +{ + if (!LLFloaterFixedEnvironment::postBuild()) + return FALSE; + + LLPanelSettingsWater * panel; + panel = new LLPanelSettingsWaterMainTab; + panel->buildFromFile("panel_settings_water.xml"); + panel->setWater(std::static_pointer_cast<LLSettingsWater>(mSettings)); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(true)); + + // Initialize the settings, take a snapshot of the current water. + mSettings = LLEnvironment::instance().getEnvironmentFixedWater(LLEnvironment::ENV_CURRENT)->buildClone(); + + mSettings->setName("Snapshot water (new)"); + + mTxtName->setValue(mSettings->getName()); + + syncronizeTabs(); + refresh(); + return TRUE; +} + +void LLFloaterFixedEnvironmentWater::updateEditEnvironment(void) +{ + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, + std::static_pointer_cast<LLSettingsWater>(mSettings)); +} + +//========================================================================= + +#if 0 +// virtual +BOOL LLFloaterEditSky::postBuild() +{ + mSkyPresetNameEditor = getChild<LLLineEditor>("sky_preset_name"); + mSkyPresetCombo = getChild<LLComboBox>("sky_preset_combo"); + mMakeDefaultCheckBox = getChild<LLCheckBoxCtrl>("make_default_cb"); + mSaveButton = getChild<LLButton>("save"); + mSkyAdapter = boost::make_shared<LLSkySettingsAdapter>(); + + LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); + + initCallbacks(); + +// // Create the sun position scrubber on the slider. +// getChild<LLMultiSliderCtrl>("WLSunPos")->addSlider(12.f); + + return TRUE; +} + +// 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)); + + // Update floater title. + setTitle(floater_title); + + // Update the hint at the top. + getChild<LLUICtrl>("hint")->setValue(hint); + + // Hide the hint to the right of the combo if we're invoked to create a new preset. + getChildView("note")->setVisible(!new_preset); + + // Switch between the sky presets combobox and preset name input field. + mSkyPresetCombo->setVisible(!new_preset); + mSkyPresetNameEditor->setVisible(new_preset); + + reset(); +} + +// virtual +void LLFloaterEditSky::onClose(bool app_quitting) +{ + if (!app_quitting) // there's no point to change environment if we're quitting + { + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + } +} + +// 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<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); + + // Connect to region info updates. + LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditSky::onRegionInfoUpdate, this)); + + //------------------------------------------------------------------------- +// LEGACY_ATMOSPHERICS + // ambient + getChild<LLUICtrl>("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mAmbient)); + + // blue horizon/density + getChild<LLUICtrl>("WLBlueHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mBlueHorizon)); + getChild<LLUICtrl>("WLBlueDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mBlueDensity)); + + // haze density, horizon, mult, and altitude + 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>("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mDistanceMult)); + getChild<LLUICtrl>("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mMaxAlt)); + + // sunlight + getChild<LLUICtrl>("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mSunlight)); + + // glow + getChild<LLUICtrl>("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, &mSkyAdapter->mGlow)); + getChild<LLUICtrl>("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, &mSkyAdapter->mGlow)); + + // time of day +// 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, &mSkyAdapter->mLightnorm)); + getChild<LLJoystickQuaternion>("WLSunRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunRotationChanged, this)); + getChild<LLJoystickQuaternion>("WLMoonRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onMoonRotationChanged, this)); + + // Clouds + + // Cloud Color + getChild<LLUICtrl>("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mCloudColor)); + + // Cloud + 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, &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, &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)); + + + // Dome + getChild<LLUICtrl>("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mWLGamma)); + getChild<LLUICtrl>("WLStarAlpha")->setCommitCallback(boost::bind(&LLFloaterEditSky::onStarAlphaMoved, this, _1)); +} + +//================================================================================================= + +void LLFloaterEditSky::syncControls() +{ + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + mEditSettings = psky; + + std::string name = psky->getName(); + + mSkyPresetNameEditor->setText(name); + mSkyPresetCombo->setValue(name); + +// LEGACY_ATMOSPHERICS + // ambient + mSkyAdapter->mAmbient.setColor3( psky->getAmbientColor() ); + setColorSwatch("WLAmbient", mSkyAdapter->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE); + + // blue horizon / density + mSkyAdapter->mBlueHorizon.setColor3( psky->getBlueHorizon() ); + setColorSwatch("WLBlueHorizon", mSkyAdapter->mBlueHorizon, WL_BLUE_HORIZON_DENSITY_SCALE); + mSkyAdapter->mBlueDensity.setColor3( psky->getBlueDensity() ); + setColorSwatch("WLBlueDensity", mSkyAdapter->mBlueDensity, WL_BLUE_HORIZON_DENSITY_SCALE); + + // haze density, horizon, mult, and altitude + 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(); + mSkyAdapter->mDistanceMult = psky->getDistanceMultiplier(); + childSetValue("WLDistanceMult", (F32) mSkyAdapter->mDistanceMult); + childSetValue("WLMaxAltitude", (F32) mSkyAdapter->mMaxAlt); + + // Lighting + + // sunlight + mSkyAdapter->mSunlight.setColor3( psky->getSunlightColor() ); + setColorSwatch("WLSunlight", mSkyAdapter->mSunlight, WL_SUN_AMBIENT_SLIDER_SCALE); + + // glow + mSkyAdapter->mGlow.setColor3( psky->getGlow() ); + childSetValue("WLGlowR", 2 - mSkyAdapter->mGlow.getRed() / 20.0f); + childSetValue("WLGlowB", -mSkyAdapter->mGlow.getBlue() / 5.0f); + + + +// LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl(); +// +// F32 time24 = sun_pos_to_time24(azal.second / F_TWO_PI); +// getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE); +// getChild<LLTimeCtrl>("WLDayTime")->setTime24(time24); +// childSetValue("WLEastAngle", azal.first / F_TWO_PI); + getChild<LLJoystickQuaternion>("WLSunRotation")->setRotation(psky->getSunRotation()); + getChild<LLJoystickQuaternion>("WLMoonRotation")->setRotation(psky->getMoonRotation()); + + // Clouds + + // Cloud Color + mSkyAdapter->mCloudColor.setColor3( psky->getCloudColor() ); + setColorSwatch("WLCloudColor", mSkyAdapter->mCloudColor, WL_CLOUD_SLIDER_SCALE); + + // Cloud + mSkyAdapter->mCloudMain.setColor3( psky->getCloudPosDensity1() ); + childSetValue("WLCloudX", mSkyAdapter->mCloudMain.getRed()); + childSetValue("WLCloudY", mSkyAdapter->mCloudMain.getGreen()); + childSetValue("WLCloudDensity", mSkyAdapter->mCloudMain.getBlue()); + + // Cloud Detail + mSkyAdapter->mCloudDetail.setColor3( psky->getCloudPosDensity2() ); + childSetValue("WLCloudDetailX", mSkyAdapter->mCloudDetail.getRed()); + childSetValue("WLCloudDetailY", mSkyAdapter->mCloudDetail.getGreen()); + childSetValue("WLCloudDetailDensity", mSkyAdapter->mCloudDetail.getBlue()); + + // Cloud extras + mSkyAdapter->mCloudCoverage = psky->getCloudShadow(); + mSkyAdapter->mCloudScale = psky->getCloudScale(); + childSetValue("WLCloudCoverage", (F32) mSkyAdapter->mCloudCoverage); + childSetValue("WLCloudScale", (F32) mSkyAdapter->mCloudScale); + + // cloud scrolling + LLVector2 scroll_rate = psky->getCloudScrollRate(); + + // LAPRAS: These should go away... + childDisable("WLCloudLockX"); + childDisable("WLCloudLockY"); + + // disable if locked, enable if not + childEnable("WLCloudScrollX"); + childEnable("WLCloudScrollY"); + + // *HACK cloud scrolling is off my an additive of 10 + childSetValue("WLCloudScrollX", scroll_rate[0] - 10.0f); + childSetValue("WLCloudScrollY", scroll_rate[1] - 10.0f); + + // Tweak extras + + mSkyAdapter->mWLGamma = psky->getGamma(); + childSetValue("WLGamma", (F32) mSkyAdapter->mWLGamma); + + 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. + LLColor4 color = from_ctrl.getColor4(); + getChild<LLColorSwatchCtrl>(name)->set(color / k); +} + +// color control callbacks +void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) +{ + LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl); + LLColor4 color_vec(swatch->get().mV); + + // Multiply RGB values by the appropriate factor. + F32 k = WL_CLOUD_SLIDER_SCALE; + if (color_ctrl->getIsSunOrAmbientColor()) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + 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->setColor4(color_vec); + color_ctrl->update(mEditSettings); +} + +void LLFloaterEditSky::onColorControlRMoved(LLUICtrl* ctrl, void* userdata) +{ + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); + + F32 red_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; + + if (color_ctrl->getIsSunOrAmbientColor()) + { + k = WL_SUN_AMBIENT_SLIDER_SCALE; + } + if (color_ctrl->getIsBlueHorizonOrDensity()) + { + k = WL_BLUE_HORIZON_DENSITY_SCALE; + } + color_ctrl->setRed(red_value * k); + + adjustIntensity(color_ctrl, red_value, k); + color_ctrl->update(mEditSettings); +} + +void LLFloaterEditSky::onColorControlGMoved(LLUICtrl* ctrl, void* userdata) +{ + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); + + F32 green_value = sldr_ctrl->getValueF32(); + F32 k = 1.0f; + + 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); + + adjustIntensity(color_ctrl, green_value, k); + color_ctrl->update(mEditSettings); +} + +void LLFloaterEditSky::onColorControlBMoved(LLUICtrl* ctrl, void* 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; + + 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); + + adjustIntensity(color_ctrl, blue_value, k); + color_ctrl->update(mEditSettings); +} + +void LLFloaterEditSky::adjustIntensity(WLColorControl *ctrl, F32 val, F32 scale) +{ + if (ctrl->getHasSliderName()) + { + LLColor4 color = ctrl->getColor4(); + F32 i = color_max(color) / scale; + ctrl->setIntensity(i); + std::string name = ctrl->getSliderName(); + name.append("I"); + + childSetValue(name, i); + } +} + + +/// GLOW SPECIFIC CODE +void LLFloaterEditSky::onGlowRMoved(LLUICtrl* ctrl, void* userdata) +{ + + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); + + // scaled by 20 + color_ctrl->setRed((2 - sldr_ctrl->getValueF32()) * 20); + + color_ctrl->update(mEditSettings); +} + +/// \NOTE that we want NEGATIVE (-) B +void LLFloaterEditSky::onGlowBMoved(LLUICtrl* ctrl, void* userdata) +{ + 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->setBlue(-sldr_ctrl->getValueF32() * 5); + + color_ctrl->update(mEditSettings); +} + +void LLFloaterEditSky::onFloatControlMoved(LLUICtrl* ctrl, void* userdata) +{ + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + WLFloatControl * floatControl = static_cast<WLFloatControl *>(userdata); + + floatControl->setValue(sldr_ctrl->getValueF32() / floatControl->getMult()); + + floatControl->update(mEditSettings); +} + + +// Lighting callbacks + +// time of day +void LLFloaterEditSky::onSunMoved(LLUICtrl* ctrl, void* userdata) +{ + LLMultiSliderCtrl* sun_msldr = getChild<LLMultiSliderCtrl>("WLSunPos"); + LLSliderCtrl* east_sldr = getChild<LLSliderCtrl>("WLEastAngle"); + LLTimeCtrl* time_ctrl = getChild<LLTimeCtrl>("WLDayTime"); + WLColorControl* color_ctrl = static_cast<WLColorControl *>(userdata); + + F32 time24 = sun_msldr->getCurSliderValue(); + time_ctrl->setTime24(time24); // sync the time ctrl with the new sun position + + // get the two angles + 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); + + LLVector4 sunnorm( mEditSettings->getSunDirection(), 1.f ); + + color_ctrl->update(mEditSettings); +} + +void LLFloaterEditSky::onTimeChanged() +{ + F32 time24 = getChild<LLTimeCtrl>("WLDayTime")->getTime24(); + getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE); + onSunMoved(getChild<LLUICtrl>("WLSunPos"), &(mSkyAdapter->mLightnorm)); +} + +void LLFloaterEditSky::onSunRotationChanged() +{ + LLJoystickQuaternion* sun_spinner = getChild<LLJoystickQuaternion>("WLSunRotation"); + LLQuaternion sunrot(sun_spinner->getRotation()); + + mEditSettings->setSunRotation(sunrot); +} + +void LLFloaterEditSky::onMoonRotationChanged() +{ + LLJoystickQuaternion* moon_spinner = getChild<LLJoystickQuaternion>("WLMoonRotation"); + LLQuaternion moonrot(moon_spinner->getRotation()); + + mEditSettings->setMoonRotation(moonrot); +} + +void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) +{ + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + + mEditSettings->setStarBrightness(sldr_ctrl->getValueF32()); +} + +// Clouds +void LLFloaterEditSky::onCloudScrollXMoved(LLUICtrl* ctrl) +{ + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + // *HACK all cloud scrolling is off by an additive of 10. + mEditSettings->setCloudScrollRateX(sldr_ctrl->getValueF32() + 10.0f); +} + +void LLFloaterEditSky::onCloudScrollYMoved(LLUICtrl* ctrl) +{ + LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl); + + // *HACK all cloud scrolling is off by an additive of 10. + mEditSettings->setCloudScrollRateY(sldr_ctrl->getValueF32() + 10.0f); +} + +//================================================================================================= + +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"; +} + +void LLFloaterEditSky::refreshSkyPresetsList() +{ + mSkyPresetCombo->removeall(); + + LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList(); + + for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it) + { + mSkyPresetCombo->add((*it).first, LLSDArray((*it).first)((*it).second)); + } + + mSkyPresetCombo->setLabel(getString("combo_label")); +} + +void LLFloaterEditSky::enableEditing(bool enable) +{ + // Enable/disable the tab and their contents. + LLTabContainer* tab_container = getChild<LLTabContainer>("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() +{ +#if 0 + LLWLParamKey key(getSelectedSkyPreset()); + llassert(key.scope == LLEnvKey::SCOPE_REGION); + + LL_DEBUGS("Windlight") << "Saving region sky preset: " << key.name << LL_ENDL; + 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; +#endif +} + +std::string LLFloaterEditSky::getSelectedPresetName() const +{ + std::string name; + if (mSkyPresetNameEditor->getVisible()) + { + name = mSkyPresetNameEditor->getText(); + } + else + { + LLSD combo_val = mSkyPresetCombo->getValue(); + name = combo_val[0].asString(); + } + + return name; +} + +void LLFloaterEditSky::onSkyPresetNameEdited() +{ + std::string name = mSkyPresetNameEditor->getText(); + LLSettingsWater::ptr_t psky = LLEnvironment::instance().getCurrentWater(); + + psky->setName(name); +} + +void LLFloaterEditSky::onSkyPresetSelected() +{ + std::string name; + + name = getSelectedPresetName(); + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(name); + + if (!psky) + { + LL_WARNS("WATEREDIT") << "Could not find water preset" << LL_ENDL; + enableEditing(false); + return; + } + + psky = psky->buildClone(); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, psky); + mEditSettings = psky; + + syncControls(); + enableEditing(true); + +} + +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 currently displayed water params to the selected preset. + std::string name = mEditSettings->getName(); + + LL_DEBUGS("Windlight") << "Saving sky preset " << name << LL_ENDL; + + LLEnvironment::instance().addSky(mEditSettings); + + // Change preference if requested. + if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue()) + { + LL_DEBUGS("Windlight") << name << " is now the new preferred sky preset" << LL_ENDL; + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings); + } + + closeFloater(); +} + +void LLFloaterEditSky::onBtnSave() +{ + LLEnvironment::instance().addSky(mEditSettings); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings); + + closeFloater(); +} + +void LLFloaterEditSky::onBtnCancel() +{ + closeFloater(); +} + +void LLFloaterEditSky::onSkyPresetListChange() +{ + refreshSkyPresetsList(); +} + +void LLFloaterEditSky::onRegionSettingsChange() +{ +#if 0 + // 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(); + } +#endif +} + +void LLFloaterEditSky::onRegionInfoUpdate() +{ +#if 0 + bool can_edit = true; + + // If we've selected a region sky preset for editing. + if (getSelectedSkyPreset().scope == LLEnvKey::SCOPE_REGION) + { + // check whether we have the access + can_edit = LLEnvManagerNew::canEditRegionSettings(); + } + + enableEditing(can_edit); +#endif +} +#endif + diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h new file mode 100644 index 0000000000..0d2d21533e --- /dev/null +++ b/indra/newview/llfloaterfixedenvironment.h @@ -0,0 +1,171 @@ +/** + * @file llfloaterfixedenvironment.h + * @brief Floaters to create and edit fixed settings for sky and water. + * + * $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$ + */ + +#ifndef LL_FLOATERFIXEDENVIRONMENT_H +#define LL_FLOATERFIXEDENVIRONMENT_H + +#include "llfloater.h" +#include "llsettingsbase.h" + +class LLTabContainer; +class LLButton; +class LLLineEditor; + +/** + * Floater container for creating and editing fixed environment settings. + */ +class LLFloaterFixedEnvironment : public LLFloater +{ + LOG_CLASS(LLFloaterFixedEnvironment); + +public: + LLFloaterFixedEnvironment(const LLSD &key); + + virtual BOOL postBuild() override; + + virtual void onFocusReceived() override; + virtual void onFocusLost() override; + + void setEditSettings(LLSettingsBase::ptr_t &settings) { mSettings = settings; syncronizeTabs(); } + LLSettingsBase::ptr_t getEditSettings() const { return mSettings; } + +protected: + virtual void updateEditEnvironment() = 0; + virtual void refresh(); + + virtual void syncronizeTabs(); + + LLTabContainer * mTab; + LLLineEditor * mTxtName; + + LLSettingsBase::ptr_t mSettings; + + +private: + void onNameChanged(const std::string &name); + +#if 0 + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + /*virtual*/ void onClose(bool app_quitting); + /*virtual*/ void draw(); + + + //-- WL stuff begins ------------------------------------------------------ + + void syncControls(); /// sync up sliders with parameters + + void setColorSwatch(const std::string& name, const WLColorControl& from_ctrl, F32 k); + + // general purpose callbacks for dealing with color controllers + void onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl); + void onColorControlRMoved(LLUICtrl* ctrl, void* userdata); + void onColorControlGMoved(LLUICtrl* ctrl, void* userdata); + void onColorControlBMoved(LLUICtrl* ctrl, void* userdata); + void onFloatControlMoved(LLUICtrl* ctrl, void* userdata); + + void adjustIntensity(WLColorControl *ctrl, F32 color, F32 scale); + + // lighting callbacks for glow + void onGlowRMoved(LLUICtrl* ctrl, void* userdata); + void onGlowBMoved(LLUICtrl* ctrl, void* userdata); + + // lighting callbacks for sun + void onSunMoved(LLUICtrl* ctrl, void* userdata); + void onTimeChanged(); + + void onSunRotationChanged(); + void onMoonRotationChanged(); + + // for handling when the star slider is moved to adjust the alpha + void onStarAlphaMoved(LLUICtrl* ctrl); + + // handle cloud scrolling + void onCloudScrollXMoved(LLUICtrl* ctrl); + void onCloudScrollYMoved(LLUICtrl* ctrl); + + //-- WL stuff ends -------------------------------------------------------- + + void reset(); /// reset the floater to its initial state + bool isNewPreset() const; + void refreshSkyPresetsList(); + void enableEditing(bool enable); + void saveRegionSky(); + std::string getSelectedPresetName() const; + + void onSkyPresetNameEdited(); + void onSkyPresetSelected(); + bool onSaveAnswer(const LLSD& notification, const LLSD& response); + void onSaveConfirmed(); + + void onBtnSave(); + void onBtnCancel(); + + void onSkyPresetListChange(); + void onRegionSettingsChange(); + void onRegionInfoUpdate(); + + LLSettingsSky::ptr_t mEditSettings; + + LLLineEditor* mSkyPresetNameEditor; + LLComboBox* mSkyPresetCombo; + LLCheckBoxCtrl* mMakeDefaultCheckBox; + LLButton* mSaveButton; + LLSkySettingsAdapterPtr mSkyAdapter; +#endif +}; + +class LLFloaterFixedEnvironmentWater : public LLFloaterFixedEnvironment +{ + LOG_CLASS(LLFloaterFixedEnvironmentWater); + +public: + LLFloaterFixedEnvironmentWater(const LLSD &key); + + BOOL postBuild() override; + +protected: + virtual void updateEditEnvironment() override; + +private: +}; + +class LLSettingsEditPanel : public LLPanel +{ +public: + virtual void setSettings(LLSettingsBase::ptr_t &) = 0; + + virtual void refresh() = 0; + +protected: + LLSettingsEditPanel() : + LLPanel() + {} + +}; + +#endif // LL_FLOATERFIXEDENVIRONMENT_H diff --git a/indra/newview/llpaneleditwater.cpp b/indra/newview/llpaneleditwater.cpp new file mode 100644 index 0000000000..08ba198894 --- /dev/null +++ b/indra/newview/llpaneleditwater.cpp @@ -0,0 +1,212 @@ +/** +* @file llpaneleditwater.cpp +* @brief Floaters to create and edit fixed settings for sky and water. +* +* $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 "llpaneleditwater.h" + +#include "llslider.h" +#include "lltexturectrl.h" +#include "llcolorswatch.h" + +namespace +{ + const std::string FIELD_WATER_FOG_COLOR("water_fog_color"); + const std::string FIELD_WATER_FOG_DENSITY("water_fog_density"); + const std::string FIELD_WATER_UNDERWATER_MOD("water_underwater_mod"); + const std::string FIELD_WATER_NORMAL_MAP("water_normal_map"); + + const std::string FIELD_WATER_WAVE1_X("water_wave1_x"); + const std::string FIELD_WATER_WAVE1_Y("water_wave1_y"); + + const std::string FIELD_WATER_WAVE2_X("water_wave2_x"); + const std::string FIELD_WATER_WAVE2_Y("water_wave2_y"); + + const std::string FIELD_WATER_NORMAL_SCALE_X("water_normal_scale_x"); + const std::string FIELD_WATER_NORMAL_SCALE_Y("water_normal_scale_y"); + const std::string FIELD_WATER_NORMAL_SCALE_Z("water_normal_scale_z"); + + const std::string FIELD_WATER_FRESNEL_SCALE("water_fresnel_scale"); + const std::string FIELD_WATER_FRESNEL_OFFSET("water_fresnel_offset"); + + const std::string FIELD_WATER_SCALE_ABOVE("water_scale_above"); + const std::string FIELD_WATER_SCALE_BELOW("water_scale_below"); + const std::string FIELD_WATER_BLUR_MULTIP("water_blur_multip"); +} + +//========================================================================== +LLPanelSettingsWater::LLPanelSettingsWater() : + LLSettingsEditPanel(), + mWaterSettings() +{ + +} + + +//========================================================================== +LLPanelSettingsWaterMainTab::LLPanelSettingsWaterMainTab(): + LLPanelSettingsWater(), + mClrFogColor(nullptr), + mTxtNormalMap(nullptr) +{ +} + + +BOOL LLPanelSettingsWaterMainTab::postBuild() +{ + mClrFogColor = getChild<LLColorSwatchCtrl>(FIELD_WATER_FOG_COLOR); + mTxtNormalMap = getChild<LLTextureCtrl>(FIELD_WATER_NORMAL_MAP); + + + mClrFogColor->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogColorChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(); }); +// getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); }); + getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogUnderWaterChanged(); }); + mTxtNormalMap->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalMapChanged(); }); + + getChild<LLUICtrl>(FIELD_WATER_WAVE1_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLargeWaveChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_WAVE1_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLargeWaveChanged(); }); + + getChild<LLUICtrl>(FIELD_WATER_WAVE2_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSmallWaveChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_WAVE2_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSmallWaveChanged(); }); + + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalScaleChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalScaleChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalScaleChanged(); }); + + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFresnelScaleChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFresnelOffsetChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onScaleAboveChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onScaleBelowChanged(); }); + getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlurMultipChanged(); }); + + refresh(); + + return TRUE; +} + +//========================================================================== +void LLPanelSettingsWaterMainTab::refresh() +{ + if (!mWaterSettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + mClrFogColor->set(mWaterSettings->getFogColor()); + getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setValue(mWaterSettings->getFogDensity()); + getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->setValue(mWaterSettings->getFogMod()); + mTxtNormalMap->setValue(mWaterSettings->getNormalMapID()); + LLVector2 vect2 = mWaterSettings->getWave1Dir(); + getChild<LLUICtrl>(FIELD_WATER_WAVE1_X)->setValue(vect2[0]); + getChild<LLUICtrl>(FIELD_WATER_WAVE1_Y)->setValue(vect2[1]); + vect2 = mWaterSettings->getWave2Dir(); + getChild<LLUICtrl>(FIELD_WATER_WAVE2_X)->setValue(vect2[0]); + getChild<LLUICtrl>(FIELD_WATER_WAVE2_Y)->setValue(vect2[1]); + LLVector3 vect3 = mWaterSettings->getNormalScale(); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->setValue(vect3[0]); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->setValue(vect3[1]); + getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->setValue(vect3[2]); + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->setValue(mWaterSettings->getFresnelOffset()); + getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->setValue(mWaterSettings->getFresnelOffset()); + getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->setValue(mWaterSettings->getScaleAbove()); + getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->setValue(mWaterSettings->getScaleBelow()); + getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->setValue(mWaterSettings->getBlurMultiplier()); +} + +//========================================================================== + +void LLPanelSettingsWaterMainTab::onFogColorChanged() +{ + mWaterSettings->setFogColor(LLColor3(mClrFogColor->get())); +} + +void LLPanelSettingsWaterMainTab::onFogDensityChanged() +{ + mWaterSettings->setFogDensity(getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); +} + +void LLPanelSettingsWaterMainTab::onFogUnderWaterChanged() +{ + mWaterSettings->setFogMod(getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->getValue().asReal()); +} + +void LLPanelSettingsWaterMainTab::onNormalMapChanged() +{ + mWaterSettings->setNormalMapID(mTxtNormalMap->getImageAssetID()); +} + + +void LLPanelSettingsWaterMainTab::onLargeWaveChanged() +{ + LLVector2 vect(getChild<LLUICtrl>(FIELD_WATER_WAVE1_X)->getValue().asReal(), getChild<LLUICtrl>(FIELD_WATER_WAVE1_Y)->getValue().asReal()); + LL_WARNS("LAPRAS") << "Changing Large Wave from " << mWaterSettings->getWave1Dir() << " -> " << vect << LL_ENDL; + mWaterSettings->setWave1Dir(vect); +} + +void LLPanelSettingsWaterMainTab::onSmallWaveChanged() +{ + LLVector2 vect(getChild<LLUICtrl>(FIELD_WATER_WAVE2_X)->getValue().asReal(), getChild<LLUICtrl>(FIELD_WATER_WAVE2_Y)->getValue().asReal()); + LL_WARNS("LAPRAS") << "Changing Small Wave from " << mWaterSettings->getWave2Dir() << " -> " << vect << LL_ENDL; + mWaterSettings->setWave2Dir(vect); +} + + +void LLPanelSettingsWaterMainTab::onNormalScaleChanged() +{ + LLVector3 vect(getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->getValue().asReal(), getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->getValue().asReal(), getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->getValue().asReal()); + LL_WARNS("LAPRAS") << "Changing normal scale from " << mWaterSettings->getNormalScale() << " -> " << vect << LL_ENDL; + mWaterSettings->setNormalScale(vect); +} + +void LLPanelSettingsWaterMainTab::onFresnelScaleChanged() +{ + mWaterSettings->setFresnelScale(getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->getValue().asReal()); +} + +void LLPanelSettingsWaterMainTab::onFresnelOffsetChanged() +{ + mWaterSettings->setFresnelOffset(getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->getValue().asReal()); +} + +void LLPanelSettingsWaterMainTab::onScaleAboveChanged() +{ + mWaterSettings->setScaleAbove(getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->getValue().asReal()); +} + +void LLPanelSettingsWaterMainTab::onScaleBelowChanged() +{ + mWaterSettings->setScaleBelow(getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->getValue().asReal()); +} + +void LLPanelSettingsWaterMainTab::onBlurMultipChanged() +{ + mWaterSettings->setBlurMultiplier(getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->getValue().asReal()); +} diff --git a/indra/newview/llpaneleditwater.h b/indra/newview/llpaneleditwater.h new file mode 100644 index 0000000000..5c700c7231 --- /dev/null +++ b/indra/newview/llpaneleditwater.h @@ -0,0 +1,113 @@ +/** +* @file llpaneleditwater.h +* @brief Panels for water settings +* +* $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$ +*/ + +#ifndef LLPANEL_EDIT_WATER_H +#define LLPANEL_EDIT_WATER_H + +#include "llpanel.h" +#include "llsettingswater.h" + +#include "llfloaterfixedenvironment.h" + +//========================================================================= +class LLSlider; +class LLColorSwatchCtrl; +class LLTextureCtrl; + +//========================================================================= +class LLPanelSettingsWater : public LLSettingsEditPanel +{ + LOG_CLASS(LLPanelSettingsWater); + +public: + LLPanelSettingsWater(); + + virtual void setSettings(LLSettingsBase::ptr_t &settings) override { setWater(std::static_pointer_cast<LLSettingsWater>(settings)); } + + LLSettingsWater::ptr_t getWater() const { return mWaterSettings; } + void setWater(const LLSettingsWater::ptr_t &water) { mWaterSettings = water; refresh(); } + +protected: + LLSettingsWater::ptr_t mWaterSettings; +}; + +// *RIDER* In this case this split is unecessary since there is only a single +// tab page for water settings at this point. However more may be added in the +// future and I want to reinforce the pattern used for sky/atmosphere tabs. +class LLPanelSettingsWaterMainTab : public LLPanelSettingsWater +{ + LOG_CLASS(LLPanelSettingsWaterMainTab); + +public: + LLPanelSettingsWaterMainTab(); + + virtual BOOL postBuild() override; + +protected: + virtual void refresh() override; + +private: + + LLColorSwatchCtrl * mClrFogColor; + LLSlider * mSldFogDensity; + LLSlider * mSldUnderWaterMod; + LLTextureCtrl * mTxtNormalMap; + + // Temp until XY control + LLSlider * mSldWave1X; + LLSlider * mSldWave1Y; + + // Temp until XY control + LLSlider * mSldWave2X; + LLSlider * mSldWave2Y; + + LLSlider * mSldNormalScaleX; + LLSlider * mSldNormalScaleY; + LLSlider * mSldNormalScaleZ; + LLSlider * mSldFresnelScale; + LLSlider * mSldFresnelOffset; + LLSlider * mSldScaleAbove; + LLSlider * mSldScaleBelow; + LLSlider * mSldBlurMultip; + + void onFogColorChanged(); + void onFogDensityChanged(); + void onFogUnderWaterChanged(); + void onNormalMapChanged(); + + void onLargeWaveChanged(); + void onSmallWaveChanged(); + + void onNormalScaleChanged(); + void onFresnelScaleChanged(); + void onFresnelOffsetChanged(); + void onScaleAboveChanged(); + void onScaleBelowChanged(); + void onBlurMultipChanged(); +}; + + +#endif // LLPANEL_EDIT_WATER_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 63166fe4a8..1af6ecb8b6 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -67,6 +67,7 @@ #include "llfloaterexperiencepicker.h" #include "llfloaterevent.h" #include "llfloaterfacebook.h" +#include "llfloaterfixedenvironment.h" #include "llfloaterflickr.h" #include "llfloaterfonttest.h" #include "llfloatergesture.h" @@ -226,6 +227,9 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>); LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>); + LLFloaterReg::add("env_fixed_environmentent_water", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFixedEnvironmentWater>); + //LLFloaterReg::add("env_fixed_environmentent", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFixedEnvironment>); + LLFloaterReg::add("env_edit_extdaycycle", "floater_edit_ext_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditExtDayCycle>); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 456c080f8a..9f25890917 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8476,12 +8476,14 @@ class LLWorldEnvPreset : public view_listener_t if (item == "new_water") { - LLFloaterReg::showInstance("env_edit_water", "new"); + //LLFloaterReg::showInstance("env_edit_water", "new"); + LLFloaterReg::showInstance("env_fixed_environmentent_water", "new"); } else if (item == "edit_water") { - LLFloaterReg::showInstance("env_edit_water", "edit"); - } + //LLFloaterReg::showInstance("env_edit_water", "edit"); + LLFloaterReg::showInstance("env_fixed_environmentent_water", "edit"); + } else if (item == "new_sky") { LLFloaterReg::showInstance("env_edit_sky", "new"); diff --git a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml new file mode 100644 index 0000000000..03bbc05dad --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + can_minimize="false" + can_tear_off="false" + can_resize="true" + can_drag_on_left="false" + can_close="true" + can_dock="true" + bevel_style="in" + height="500" + layout="topleft" + name="Fixed Environment" + save_rect="true" + title="Fixed Environment" + save_dock_state="true" + save_visibility="true" + single_instance="true" + width="650"> + <layout_stack name="floater_stack" + left="5" + top="5" + right="-5" + bottom="-5" + follows="left|top|right|bottom" + orientation="vertical"> + <layout_panel name="info_panel" + auto_resize="false" + user_resize="false" + bg_alpha_color="blue" + min_height="60"> + <text + follows="left|top" + top_delta="30" + left_delta="10" + width="35" + height="20" + font="SansSerif"> + Name: + </text> + <line_editor + follows="left|top" + top_delta="-2" + left_delta="45" + width="250" + name="settings_name" + max_length_chars="32" + height="20"/> + <button + height="23" + label="Load" + follows="left|top" + left_delta="260" + font="SansSerif" + top_delta="-2" + name="btn_load" + tool_tip="Load a settings from inventory" + width="96" /> + <button + height="23" + label="Import" + follows="right|top" + right="-10" + font="SansSerif" + top_delta="0" + name="btn_import" + tool_tip="Import legacy settings from disk." + width="96" /> + </layout_panel> + <layout_panel name="tab_area" + auto_resize="true" + user_resize="true" + height="11" + min_height="0" + visible="true"> + <tab_container + follows="all" + halign="left" + layout="topleft" + left="0" + name="tab_settings" + tab_position="top" + tab_width="120" + tab_padding_right="3"> + <!-- move to own file --> + </tab_container> + </layout_panel> + <layout_panel name="button_panel" + follows="left|top|right|bottom" + auto_resize="false" + user_resize="false" + height="40" + visible="true"> + <button + height="23" + label="Save" + follows="left|top" + font="SansSerif" + name="btn_commit" + tool_tip="Load a settings from inventory" + width="96" /> + <button + height="23" + label="Cancel" + follows="right|top" + right="-10" + top_delta="0" + font="SansSerif" + name="btn_cancel" + tool_tip="Load a settings from inventory" + width="96" /> + + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/en/panel_settings_water.xml b/indra/newview/skins/default/xui/en/panel_settings_water.xml new file mode 100644 index 0000000000..fe088d98cf --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_water.xml @@ -0,0 +1,399 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + border="true" + follows="all" + label="Water" + layout="topleft" + left="0" + help_topic="land_general_tab" + name="panel_settings_water" + top="0"> + <layout_stack name="water_stack1" + left="5" + top="5" + right="-5" + bottom="-5" + follows="left|top|right|bottom" + orientation="vertical"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="false" + user_resize="false" + visible="true" + height="105"> + <text + follows="left|top" + height="20" + font="SansSerif" + layout="topleft" + left="5" + top="5" + width="215"> + Water Fog: + </text> + <text + follows="left|top" + height="10" + layout="left|top" + left_delta="15" + top_delta="0" + width="60"> + Color: + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="37" + label_height="0" + layout="topleft" + left_delta="0" + name="water_fog_color" + top_pad="5" + width="60" /> + <text + follows="left|top" + height="10" + top_delta="-15" + left_delta="80" + width="200"> + Density Exponent: + </text> + <slider + decimal_digits="1" + follows="left|top|right" + height="10" + initial_value="0" + layout="top" + left_delta="15" + max_val="10" + name="water_fog_density" + top_delta="5" + width="200"/> + <text + follows="left|top" + height="10" + top_delta="25" + left_delta="-15" + width="200"> + Underwater Modifier:</text> + <slider + decimal_digits="1" + follows="left|top|right" + height="10" + initial_value="0" + layout="top" + left_delta="15" + max_val="10" + name="water_underwater_mod" + top_delta="20" + width="200"/> + </layout_panel> + <layout_panel + auto_resize="true" + user_resize="true" + visible="true"> + <layout_stack name="water_stack2" + left="5" + top="5" + right="-5" + bottom="-5" + follows="left|top|right|bottom" + orientation="horizontal"> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="true" + visible="true" + min_width="375" + width="50"> + <text + follows="left|top" + height="20" + font="SansSerif" + layout="topleft" + left="5" + top="5" + width="215"> + Waves: + </text> + <text + follows="left|top|right" + height="16" + layout="topleft" + left="15" + top_delta="20" + width="215"> + Normal Map + </text> + <texture_picker + height="100" + layout="topleft" + left_delta="0" + name="water_normal_map" + top_pad="5" + width="100"/> + + <text + follows="left|top" + height="16" + layout="topleft" + top_delta="-20" + left_delta="120"> + Large Wave Speed + </text> + <panel + follows="left|top" + border="true" + bg_alpha_color="red" + background_visible="true" + width="100" + height="100" + left_delta="0" + top_delta="21"> + <text> + placeholder + </text> + <slider + decimal_digits="1" + follows="left|top" + initial_value="0" + layout="topleft" + label="X:" + left_delta="10" + max_val="4" + min_val="-4" + name="water_wave1_x" + top_pad="5" + width="100"/> + <slider + decimal_digits="1" + follows="left|top" + initial_value="0" + layout="topleft" + label="Y:" + left_delta="0" + max_val="4" + min_val="-4" + name="water_wave1_y" + top_pad="5" + orientation="vertical" + height="70"/> + </panel> + <text + follows="left|top" + height="16" + layout="topleft" + top_delta="-20" + left_delta="120"> + Small Wave Speed + </text> + <panel + follows="left|top" + border="true" + bg_alpha_color="red" + background_visible="true" + width="100" + height="100" + left_delta="0" + top_delta="21" + > + <text> + placeholder + </text> + <slider + decimal_digits="1" + follows="left|top" + initial_value="0" + layout="topleft" + label="X:" + left_delta="10" + max_val="4" + min_val="-4" + name="water_wave2_x" + top_pad="5" + width="100"/> + <slider + decimal_digits="1" + follows="left|top" + initial_value="0" + layout="topleft" + label="Y:" + left_delta="0" + max_val="4" + min_val="-4" + name="water_wave2_y" + top_pad="5" + orientation="vertical" + height="70"/> + </panel> + + <text + follows="left|top|right" + height="16" + layout="topleft" + left="15" + top_pad="10" + width="215"> + Reflection Wavelet Scale + </text> + <slider + decimal_digits="1" + follows="left|top" + initial_value="0.7" + layout="topleft" + label="X:" + left_delta="10" + max_val="10" + name="water_normal_scale_x" + top_pad="5" + width="150"/> + <slider + decimal_digits="1" + follows="left|top" + initial_value="0.7" + layout="topleft" + max_val="10" + name="water_normal_scale_y" + top_pad="6" + label="Y:" + width="150"/> + <slider + decimal_digits="1" + follows="left|top" + initial_value="0.7" + layout="topleft" + max_val="10" + name="water_normal_scale_z" + top_pad="6" + label="Z:" + width="150"/> + + <text + follows="left|top|right" + height="16" + layout="topleft" + left_delta="175" + top_delta="-52" + width="150"> + Fresnel Scale: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="10" + increment="0.01" + initial_value="0.7" + layout="topleft" + left_delta="5" + name="water_fresnel_scale" + top_pad="5" + width="150"/> + <text + follows="left|top|right" + layout="topleft" + left_delta="-5" + name="FresnelOffsetText" + top_pad="10" + width="150"> + Fresnel Offset: + </text> + <slider + decimal_digits="2" + follows="left|top|right" + increment="0.01" + initial_value="0.7" + layout="topleft" + left_delta="5" + name="water_fresnel_offset" + top_pad="5" + width="150"/> + </layout_panel> + <layout_panel + border="true" + bevel_style="in" + auto_resize="true" + user_resize="true" + width="50" + visible="true"> + <text + follows="left|top" + height="20" + font="SansSerif" + layout="topleft" + left="5" + top="5" + width="215"> + Refraction And Blur: + </text> + <text + follows="left|top|right" + height="16" + layout="topleft" + top_delta="25" + left_delta="5" + width="215"> + Refraction Scale (Above) + </text> + <slider + control_name="water_scale_above" + decimal_digits="2" + follows="left|top" + increment="0.01" + initial_value="0.1" + layout="topleft" + left_delta="5" + name="water_scale_above" + top_pad="5" + width="200" /> + <text + type="string" + length="1" + follows="left|top|right" + height="16" + layout="topleft" + left_delta="-5" + top_pad="15" + width="215"> + Refraction Scale (Below) + </text> + <slider + control_name="water_scale_below" + decimal_digits="2" + follows="left|top" + height="10" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + name="water_scale_below" + top_pad="5" + width="200"/> + <text + follows="left|top|right" + font="SansSerif" + height="16" + layout="topleft" + left_delta="-5" + top_pad="5" + width="215"> + Blur Multiplier + </text> + <slider + control_name="water_blur_multip" + follows="left|top" + height="10" + increment="0.001" + initial_value="0" + layout="topleft" + left_delta="5" + max_val="0.16" + name="water_blur_multip" + top_pad="5" + width="200"/> + </layout_panel> + </layout_stack> + </layout_panel> + </layout_stack> +</panel> |