diff options
author | Nyx (Neal Orman) <nyx@lindenlab.com> | 2010-09-27 22:56:08 -0400 |
---|---|---|
committer | Nyx (Neal Orman) <nyx@lindenlab.com> | 2010-09-27 22:56:08 -0400 |
commit | e045d212d35354d679c2d2e05c6d4689f9f8ac95 (patch) | |
tree | 20ba9f542316816d82dbc092d52a63fccde3d7e7 /indra/newview/llfloaterenvsettings.cpp | |
parent | e6688f993f82d2683e3eadce96c893959c94be2d (diff) |
STORM-1126 WIP Windlight Estate Settings port from 1.23: first pass at merging in windlight estate settings to viewer-dev codebase.
not built, not tested. Probably needs a bunch of fixes to be able
to be integrated.
(resubmitted by Vadim ProductEngine)
Diffstat (limited to 'indra/newview/llfloaterenvsettings.cpp')
-rw-r--r-- | indra/newview/llfloaterenvsettings.cpp | 353 |
1 files changed, 235 insertions, 118 deletions
diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index fcaef1f34b..6d1b27db07 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -2,25 +2,31 @@ * @file llfloaterenvsettings.cpp * @brief LLFloaterEnvSettings class definition * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, 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. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * 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. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * 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 + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -28,9 +34,10 @@ #include "llfloaterenvsettings.h" -#include "llfloaterreg.h" #include "llfloaterwindlight.h" #include "llfloaterwater.h" +#include "llfloaterdaycycle.h" +#include "llfloaterregioninfo.h" #include "lluictrlfactory.h" #include "llsliderctrl.h" #include "llcombobox.h" @@ -42,57 +49,89 @@ #include "llwaterparammanager.h" #include "llmath.h" #include "llviewerwindow.h" +#include "llviewercontrol.h" + +#include "llcheckboxctrl.h" #include "pipeline.h" #include <sstream> -LLFloaterEnvSettings::LLFloaterEnvSettings(const LLSD& key) - : LLFloater(key) +LLFloaterEnvSettings* LLFloaterEnvSettings::sEnvSettings = NULL; + +LLFloaterEnvSettings::LLFloaterEnvSettings() : LLFloater(std::string("Environment Settings Floater")) { + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_env_settings.xml", NULL, FALSE); + + // load it up + initCallbacks(); } -// virtual + LLFloaterEnvSettings::~LLFloaterEnvSettings() { } -// virtual -BOOL LLFloaterEnvSettings::postBuild() -{ - // load it up - initCallbacks(); - syncMenu(); - return TRUE; + +void LLFloaterEnvSettings::onClickHelp(void* data) +{ + LLFloaterEnvSettings* self = (LLFloaterEnvSettings*)data; + LLNotifications::instance().add(self->contextualNotification("EnvSettingsHelpButton")); +} + +void LLFloaterEnvSettings::onUseRegionEnvironment(LLUICtrl* ctrl, void* data) +{ + LLFloaterEnvSettings* self = (LLFloaterEnvSettings*)data; + LLCheckBoxCtrl* checkbox = (LLCheckBoxCtrl*)self->getChildView("RegionWLOptIn"); + setOptIn(checkbox->getValue().asBoolean()); +} + +void LLFloaterEnvSettings::setOptIn(bool opt_in) +{ + if (opt_in) + { + LLEnvManager::getInstance()->setNormallyDisplayedScope(LLEnvKey::SCOPE_REGION); + } + else + { + LLEnvManager::getInstance()->setNormallyDisplayedScope(LLEnvKey::SCOPE_LOCAL); + } } void LLFloaterEnvSettings::initCallbacks(void) { // our three sliders - getChild<LLUICtrl>("EnvTimeSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeDayTime, this, _1)); - getChild<LLUICtrl>("EnvCloudSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeCloudCoverage, this, _1)); - getChild<LLUICtrl>("EnvWaterFogSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeWaterFogDensity, this, _1, &LLWaterParamManager::instance()->mFogDensity)); + childSetCommitCallback("EnvTimeSlider", onChangeDayTime, NULL); + childSetCommitCallback("EnvCloudSlider", onChangeCloudCoverage, NULL); + childSetCommitCallback("EnvWaterFogSlider", onChangeWaterFogDensity, + &LLWaterParamManager::getInstance()->mFogDensity); // color picker - getChild<LLUICtrl>("EnvWaterColor")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeWaterColor, this, _1, &LLWaterParamManager::instance()->mFogColor)); + childSetCommitCallback("EnvWaterColor", onChangeWaterColor, + &LLWaterParamManager::getInstance()->mFogColor); // WL Top - getChild<LLUICtrl>("EnvAdvancedSkyButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onOpenAdvancedSky, this)); - getChild<LLUICtrl>("EnvAdvancedWaterButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onOpenAdvancedWater, this)); - getChild<LLUICtrl>("EnvUseEstateTimeButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onUseEstateTime, this)); + childSetAction("EnvAdvancedSkyButton", onOpenAdvancedSky, NULL); + childSetAction("EnvAdvancedWaterButton", onOpenAdvancedWater, NULL); + childSetAction("EnvUseEstateTimeButton", onUseEstateTime, NULL); + childSetAction("EnvUseLocalTimeButton", onUseLocalTime, NULL); + childSetAction("EnvSettingsHelpButton", onClickHelp, this); + + childSetCommitCallback("RegionWLOptIn", onUseRegionEnvironment, this); } + // menu maintenance functions void LLFloaterEnvSettings::syncMenu() { LLSliderCtrl* sldr; - sldr = getChild<LLSliderCtrl>("EnvTimeSlider"); + sldr = sEnvSettings->getChild<LLSliderCtrl>("EnvTimeSlider"); // sync the clock - F32 val = (F32)LLWLParamManager::instance()->mAnimator.getDayTime(); - std::string timeStr = timeToString(val); + F32 val = (F32)LLWLParamManager::getInstance()->mAnimator.getDayTime(); + std::string timeStr = LLWLAnimator::timeToString(val); LLTextBox* textBox; - textBox = getChild<LLTextBox>("EnvTimeText"); + textBox = sEnvSettings->getChild<LLTextBox>("EnvTimeText"); textBox->setValue(timeStr); @@ -106,62 +145,159 @@ void LLFloaterEnvSettings::syncMenu() // sync cloud coverage bool err; - getChild<LLUICtrl>("EnvCloudSlider")->setValue(LLWLParamManager::instance()->mCurParams.getFloat("cloud_shadow", err)); + childSetValue("EnvCloudSlider", LLWLParamManager::getInstance()->mCurParams.getFloat("cloud_shadow", err)); - LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamManager * param_mgr = LLWaterParamManager::getInstance(); // sync water params LLColor4 col = param_mgr->getFogColor(); - LLColorSwatchCtrl* colCtrl = getChild<LLColorSwatchCtrl>("EnvWaterColor"); + LLColorSwatchCtrl* colCtrl = sEnvSettings->getChild<LLColorSwatchCtrl>("EnvWaterColor"); col.mV[3] = 1.0f; colCtrl->set(col); - getChild<LLUICtrl>("EnvWaterFogSlider")->setValue(param_mgr->mFogDensity.mExp); + childSetValue("EnvWaterFogSlider", param_mgr->mFogDensity.mExp); param_mgr->setDensitySliderValue(param_mgr->mFogDensity.mExp); - // turn off Use Estate Time button if it's already being used - if(LLWLParamManager::instance()->mAnimator.mUseLindenTime) + // turn off Use Estate/Local Time buttons if already being used + + if(LLWLParamManager::getInstance()->mAnimator.getUseLindenTime()) { - getChildView("EnvUseEstateTimeButton")->setEnabled(FALSE); - } else { - getChildView("EnvUseEstateTimeButton")->setEnabled(TRUE); + childDisable("EnvUseEstateTimeButton"); + } + else + { + childEnable("EnvUseEstateTimeButton"); + } + + if(LLWLParamManager::getInstance()->mAnimator.getUseLocalTime()) + { + childDisable("EnvUseLocalTimeButton"); + } + else + { + childEnable("EnvUseLocalTimeButton"); } if(!gPipeline.canUseVertexShaders()) { - getChildView("EnvWaterColor")->setEnabled(FALSE); - getChildView("EnvWaterColorText")->setEnabled(FALSE); - //getChildView("EnvAdvancedWaterButton")->setEnabled(FALSE); + childDisable("EnvWaterColor"); + childDisable("EnvWaterColorText"); + //childDisable("EnvAdvancedWaterButton"); } else { - getChildView("EnvWaterColor")->setEnabled(TRUE); - getChildView("EnvWaterColorText")->setEnabled(TRUE); - //getChildView("EnvAdvancedWaterButton")->setEnabled(TRUE); + childEnable("EnvWaterColor"); + childEnable("EnvWaterColorText"); + //childEnable("EnvAdvancedWaterButton"); } // only allow access to these if they are using windlight if(!gPipeline.canUseWindLightShaders()) { - getChildView("EnvCloudSlider")->setEnabled(FALSE); - getChildView("EnvCloudText")->setEnabled(FALSE); - //getChildView("EnvAdvancedSkyButton")->setEnabled(FALSE); + childDisable("EnvCloudSlider"); + childDisable("EnvCloudText"); + //childDisable("EnvAdvancedSkyButton"); + } + else + { + childEnable("EnvCloudSlider"); + childEnable("EnvCloudText"); + //childEnable("EnvAdvancedSkyButton"); + } +} + + +// static instance of it +LLFloaterEnvSettings* LLFloaterEnvSettings::instance() +{ + if (!sEnvSettings) + { + sEnvSettings = new LLFloaterEnvSettings(); + // sEnvSettings->open(); + // sEnvSettings->setFocus(TRUE); + } + return sEnvSettings; +} + +void LLFloaterEnvSettings::setControlsEnabled(bool enable) +{ + if(enable) + { + // reenable UI elements, resync sliders, and reload saved settings + childEnable("EnvAdvancedSkyButton"); + childEnable("EnvAdvancedWaterButton"); + childEnable("EnvUseEstateTimeButton"); + childShow("EnvTimeText"); + childShow("EnvWaterColor"); + childShow("EnvTimeSlider"); + childShow("EnvCloudSlider"); + childShow("EnvWaterFogSlider"); + syncMenu(); } else { - getChildView("EnvCloudSlider")->setEnabled(TRUE); - getChildView("EnvCloudText")->setEnabled(TRUE); - //getChildView("EnvAdvancedSkyButton")->setEnabled(TRUE); + // disable UI elements the user shouldn't be able to see to protect potentially proprietary WL region settings from being visible + LLFloaterWindLight::instance()->close(); + LLFloaterWater::instance()->close(); + LLFloaterDayCycle::instance()->close(); + childDisable("EnvAdvancedSkyButton"); + childDisable("EnvAdvancedWaterButton"); + childDisable("EnvUseEstateTimeButton"); + childHide("EnvTimeText"); + childHide("EnvWaterColor"); + childHide("EnvTimeSlider"); + childHide("EnvCloudSlider"); + childHide("EnvWaterFogSlider"); } } -void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl) + +void LLFloaterEnvSettings::show() +{ + LLFloaterEnvSettings* envSettings = instance(); + envSettings->syncMenu(); + + // comment in if you want the menu to rebuild each time + //LLUICtrlFactory::getInstance()->buildFloater(envSettings, "floater_env_settings.xml"); + //envSettings->initCallbacks(); + + // Set environment opt-in checkbox based on saved value -- only need to do once, not every time syncMenu is called + + bool opt_in = gSavedSettings.getBOOL("UseEnvironmentFromRegion"); + + sEnvSettings->childSetVisible("RegionWLOptIn", LLEnvManager::getInstance()->regionCapable()); + sEnvSettings->setOptIn(opt_in); + sEnvSettings->getChildView("RegionWLOptIn")->setValue(LLSD::Boolean(opt_in)); + sEnvSettings->getChildView("RegionWLOptIn")->setToolTip(sEnvSettings->getString("region_environment_tooltip")); + envSettings->open(); +} + +bool LLFloaterEnvSettings::isOpen() { - LLSliderCtrl* sldr = static_cast<LLSliderCtrl*>(ctrl); + if (sEnvSettings != NULL) + { + return true; + } + return false; +} + +// virtual +void LLFloaterEnvSettings::onClose(bool app_quitting) +{ + if (sEnvSettings) + { + sEnvSettings->setVisible(FALSE); + } +} + + +void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl, void* userData) +{ + LLSliderCtrl* sldr; + sldr = sEnvSettings->getChild<LLSliderCtrl>("EnvTimeSlider"); // deactivate animator - LLWLParamManager::instance()->mAnimator.mIsRunning = false; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::getInstance()->mAnimator.deactivate(); F32 val = sldr->getValueF32() + 0.25f; if(val > 1.0) @@ -169,100 +305,81 @@ void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl) val--; } - LLWLParamManager::instance()->mAnimator.setDayTime((F64)val); - LLWLParamManager::instance()->mAnimator.update( - LLWLParamManager::instance()->mCurParams); + LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val); + LLWLParamManager::getInstance()->mAnimator.update( + LLWLParamManager::getInstance()->mCurParams); } -void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl) +void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl, void* userData) { - LLSliderCtrl* sldr = static_cast<LLSliderCtrl*>(ctrl); + LLSliderCtrl* sldr; + sldr = sEnvSettings->getChild<LLSliderCtrl>("EnvCloudSlider"); // deactivate animator - //LLWLParamManager::instance()->mAnimator.mIsRunning = false; - //LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + //LLWLParamManager::getInstance()->mAnimator.mIsRunning = false; + //LLWLParamManager::getInstance()->mAnimator.mUseLindenTime = false; F32 val = sldr->getValueF32(); - LLWLParamManager::instance()->mCurParams.set("cloud_shadow", val); + LLWLParamManager::getInstance()->mCurParams.set("cloud_shadow", val); } -void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl) +void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, void* userData) { LLSliderCtrl* sldr; - sldr = getChild<LLSliderCtrl>("EnvWaterFogSlider"); + sldr = sEnvSettings->getChild<LLSliderCtrl>("EnvWaterFogSlider"); + + if(NULL == userData) + { + return; + } + + WaterExpFloatControl * expFloatControl = static_cast<WaterExpFloatControl *>(userData); F32 val = sldr->getValueF32(); expFloatControl->mExp = val; - LLWaterParamManager::instance()->setDensitySliderValue(val); + LLWaterParamManager::getInstance()->setDensitySliderValue(val); - expFloatControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + expFloatControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } -void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, WaterColorControl* colorControl) +void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, void* userData) { LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl); + WaterColorControl * colorControl = static_cast<WaterColorControl *>(userData); *colorControl = swatch->get(); - colorControl->update(LLWaterParamManager::instance()->mCurParams); - LLWaterParamManager::instance()->propagateParameters(); + colorControl->update(LLWaterParamManager::getInstance()->mCurParams); + LLWaterParamManager::getInstance()->propagateParameters(); } -void LLFloaterEnvSettings::onOpenAdvancedSky() +void LLFloaterEnvSettings::onOpenAdvancedSky(void* userData) { - LLFloaterReg::showInstance("env_windlight"); + LLFloaterWindLight::show(); } -void LLFloaterEnvSettings::onOpenAdvancedWater() +void LLFloaterEnvSettings::onOpenAdvancedWater(void* userData) { - LLFloaterReg::showInstance("env_water"); + LLFloaterWater::show(); } -void LLFloaterEnvSettings::onUseEstateTime() +void LLFloaterEnvSettings::onUseEstateTime(void* userData) { - LLFloaterWindLight* wl = LLFloaterReg::findTypedInstance<LLFloaterWindLight>("env_windlight"); - if(wl) + if(LLFloaterWindLight::isOpen()) { + // select the blank value in + LLFloaterWindLight* wl = LLFloaterWindLight::instance(); LLComboBox* box = wl->getChild<LLComboBox>("WLPresetsCombo"); box->selectByValue(""); } - LLWLParamManager::instance()->mAnimator.mIsRunning = true; - LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; + LLWLParamManager::getInstance()->mAnimator.activate(LLWLAnimator::TIME_LINDEN); } -std::string LLFloaterEnvSettings::timeToString(F32 curTime) +void LLFloaterEnvSettings::onUseLocalTime(void* userData) { - S32 hours; - S32 min; - - // get hours and minutes - hours = (S32) (24.0 * curTime); - curTime -= ((F32) hours / 24.0f); - min = llround(24.0f * 60.0f * curTime); - - // handle case where it's 60 - if(min == 60) - { - hours++; - min = 0; - } - - std::string newTime = getString("timeStr"); - struct tm * timeT; - time_t secT = time(0); - timeT = gmtime (&secT); - - timeT->tm_hour = hours; - timeT->tm_min = min; - secT = mktime (timeT); - secT -= LLStringOps::getLocalTimeOffset (); - - LLSD substitution; - substitution["datetime"] = (S32) secT; - - LLStringUtil::format (newTime, substitution); - return newTime; + LLWLParamManager::getInstance()->mAnimator.setDayTime(LLWLAnimator::getLocalTime()); + LLWLParamManager::getInstance()->mAnimator.activate(LLWLAnimator::TIME_LOCAL); } |