From d90366171cf7ff986c7b890d2255cbad9cc94a28 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 29 Apr 2020 22:37:19 +0200 Subject: [PATCH] Make environment quick selection comboboxes show the correct current setting and replace the non-functional and buggy sun position & time offset with a button to open the new personal lighting floater --- indra/newview/llenvironment.cpp | 14 +- indra/newview/llenvironment.h | 11 - indra/newview/quickprefs.cpp | 233 ++++-------------- indra/newview/quickprefs.h | 18 +- .../default/xui/en/floater_phototools.xml | 101 +++----- .../default/xui/en/floater_quickprefs.xml | 78 ++---- .../newview/skins/default/xui/en/strings.xml | 2 +- 7 files changed, 107 insertions(+), 350 deletions(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b7b38512a2..0e1c4f9434 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -2444,7 +2444,6 @@ LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mWater(), mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), - mDayOffsetOverride(LLSettingsDay::MINIMUM_DAYOFFSET), // KC mBlenderSky(), mBlenderWater(), mInitialized(false), @@ -2554,7 +2553,6 @@ void LLEnvironment::DayInstance::clear() mWater.reset(); mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH; mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; - mDayOffsetOverride = LLSettingsDay::MINIMUM_DAYOFFSET; // KC mBlenderSky.reset(); mBlenderWater.reset(); mSkyTrack = 1; @@ -2578,8 +2576,7 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky LLSettingsBase::TrackPosition LLEnvironment::DayInstance::getProgress() const { LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); - // now += mDayOffset; - now += mDayOffset + mDayOffsetOverride; // KC + now += mDayOffset; if ((mDayLength <= 0) || !mDayCycle) return -1.0f; // no actual day cycle. @@ -2596,8 +2593,7 @@ void LLEnvironment::DayInstance::animate() { LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); - // now += mDayOffset; - now += mDayOffset + mDayOffsetOverride; // KC + now += mDayOffset; if (!mDayCycle) return; @@ -2615,8 +2611,7 @@ void LLEnvironment::DayInstance::animate() { mWater = LLSettingsVOWater::buildDefaultWater(); mBlenderWater = std::make_shared(mWater, mDayCycle, 0, - // mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); - mDayLength, mDayOffset + mDayOffsetOverride, DEFAULT_UPDATE_THRESHOLD); // KC + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); } } @@ -2634,8 +2629,7 @@ void LLEnvironment::DayInstance::animate() { mSky = LLSettingsVOSky::buildDefaultSky(); mBlenderSky = std::make_shared(mSky, mDayCycle, 1, - // mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); - mDayLength, mDayOffset + mDayOffsetOverride, DEFAULT_UPDATE_THRESHOLD); // KC + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); mBlenderSky->switchTrack(mSkyTrack, 0.0); } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index b80a606c12..91c4b85135 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -262,11 +262,9 @@ public: LLSettingsWater::ptr_t getWater() const { return mWater; } LLSettingsDay::Seconds getDayLength() const { return mDayLength; } LLSettingsDay::Seconds getDayOffset() const { return mDayOffset; } - LLSettingsDay::Seconds getDayOffsetOverride() const { return mDayOffsetOverride; } //KC S32 getSkyTrack() const { return mSkyTrack; } void setDayOffset(LLSettingsBase::Seconds offset) { mDayOffset = offset; animate(); } - void setDayOffsetOverride(LLSettingsBase::Seconds offset) { mDayOffsetOverride = offset; animate(); } //KC virtual void animate(); @@ -293,7 +291,6 @@ public: LLSettingsDay::Seconds mDayLength; LLSettingsDay::Seconds mDayOffset; - LLSettingsDay::Seconds mDayOffsetOverride; S32 mLastTrackAltitude; LLSettingsBlender::ptr_t mBlenderSky; @@ -325,14 +322,6 @@ public: DayInstance::ptr_t getSelectedEnvironmentInstance(); DayInstance::ptr_t getSharedEnvironmentInstance(); -// -public: - LLSettingsDay::Seconds getDayLength() const { return (mCurrentEnvironment) ? mCurrentEnvironment->getDayLength() : LLSettingsDay::MINIMUM_DAYOFFSET; } - LLSettingsDay::Seconds getDayOffset() const { return (mCurrentEnvironment) ? mCurrentEnvironment->getDayOffset() : LLSettingsDay::INVALID_DAYOFFSET; } - void setDayOffsetOverride(LLSettingsBase::Seconds offset) { if (mCurrentEnvironment) mCurrentEnvironment->setDayOffsetOverride(offset); } - LLSettingsDay::Seconds getDayOffsetOverride() const { return (mCurrentEnvironment) ? mCurrentEnvironment->getDayOffsetOverride() : LLSettingsDay::MINIMUM_DAYOFFSET; } -// - protected: virtual void initSingleton() override; virtual void cleanupSingleton() override; diff --git a/indra/newview/quickprefs.cpp b/indra/newview/quickprefs.cpp index 56f67cb33e..97a666933d 100644 --- a/indra/newview/quickprefs.cpp +++ b/indra/newview/quickprefs.cpp @@ -61,6 +61,8 @@ #include "rlvhandler.h" #include +const S32 FLOATER_QUICKPREFS_UPDATE(-5); +const S32 FLOATER_PHOTOTOOLS_UPDATE(-6); std::string unescape_name(const std::string& name); class FSSettingsCollector : public LLInventoryCollectFunctor @@ -109,6 +111,7 @@ FloaterQuickPrefs::FloaterQuickPrefs(const LLSD& key) : LLTransientDockableFloater(NULL, false, key), mAvatarZOffsetSlider(NULL), mRlvBehaviorCallbackConnection(), + mEnvChangedConnection(), mRegionChangedSlot() { // For Phototools @@ -132,6 +135,11 @@ FloaterQuickPrefs::~FloaterQuickPrefs() mRegionChangedSlot.disconnect(); } + if (mEnvChangedConnection.connected()) + { + mEnvChangedConnection.disconnect(); + } + if (!getIsPhototools() && !FSCommon::isLegacySkin()) { LLTransientFloaterMgr::getInstance()->removeControlView(this); @@ -195,8 +203,6 @@ void FloaterQuickPrefs::initCallbacks() getChild("DCPrevPreset")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickDayCyclePrev, this)); getChild("DCNextPreset")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickDayCycleNext, this)); getChild("ResetToRegionDefault")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickResetToRegionDefault, this)); - getChild("time_offset")->setSliderMouseUpCallback(boost::bind(&FloaterQuickPrefs::onDayOffset, this)); - getChild("sun_rotation")->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunMoved(); }); // Phototools additions if (getIsPhototools()) @@ -269,7 +275,7 @@ void FloaterQuickPrefs::initCallbacks() mRlvBehaviorCallbackConnection = gRlvHandler.setBehaviourCallback(boost::bind(&FloaterQuickPrefs::updateRlvRestrictions, this, _1, _2)); gSavedSettings.getControl("IndirectMaxNonImpostors")->getCommitSignal()->connect(boost::bind(&FloaterQuickPrefs::updateMaxNonImpostors, this, _2)); - LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t, S32){ setSelectedEnvironment(); }); + mEnvChangedConnection = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32 version){ setSelectedEnvironment(); }); } void FloaterQuickPrefs::loadDayCyclePresets(const std::multimap& daycycle_map) @@ -292,7 +298,6 @@ void FloaterQuickPrefs::loadDayCyclePresets(const std::multimap& sky_map) { mWLPresetsCombo->operateOnAll(LLComboBox::OP_DELETE); @@ -383,136 +388,47 @@ void FloaterQuickPrefs::loadPresets() void FloaterQuickPrefs::setSelectedEnvironment() { - LL_INFOS() << "EEP: setSelectedEnvironment: " << LLEnvironment::instance().getSelectedEnvironment() << LL_ENDL; + //LL_INFOS() << "EEP: getSelectedEnvironment: " << LLEnvironment::instance().getSelectedEnvironment() << LL_ENDL; - switch (LLEnvironment::instance().getSelectedEnvironment()) + mWLPresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); + mWaterPresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); + mDayCyclePresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); + + if (LLEnvironment::instance().getSelectedEnvironment() == LLEnvironment::ENV_LOCAL) { - case LLEnvironment::ENV_REGION: - case LLEnvironment::ENV_PARCEL: + // Day cycle, fixed sky and fixed water may all be set at the same time + // Check and set day cycle first. Fixed sky and water both override + // the sky and water settings in a day cycle, so check them after the + // day cycle. If no fixed sky or fixed water is set, they are either + // defined in the day cycle or inherited from a higher environment level. + LLSettingsDay::ptr_t day = LLEnvironment::instance().getEnvironmentDay(LLEnvironment::ENV_LOCAL); + if (day && day->getAssetId().notNull()) { - LL_INFOS() << "EEP: ENV_REGION / ENV_PARCEL" << LL_ENDL; + //LL_INFOS() << "EEP: day name = " << day->getName() << " - asset id = " << day->getAssetId() << LL_ENDL; - mWLPresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); - mWaterPresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); - mDayCyclePresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); - break; + mDayCyclePresetsCombo->selectByValue(LLSD(day->getAssetId())); + + // Water is part of a day cycle + mWLPresetsCombo->selectByValue(LLSD(PRESET_NAME_DAY_CYCLE)); + mWaterPresetsCombo->selectByValue(LLSD(PRESET_NAME_DAY_CYCLE)); } - case LLEnvironment::ENV_LOCAL: + LLSettingsSky::ptr_t sky = LLEnvironment::instance().getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL); + if (sky && sky->getAssetId().notNull()) { - //LLSettingsDay::ptr_t day = LLEnvironment::instance().getCurrentDay(); - LLSettingsDay::ptr_t day = LLEnvironment::instance().getEnvironmentDay(LLEnvironment::ENV_LOCAL); - if (day) - { - LL_INFOS() << "EEP: day name = " << day->getName() << LL_ENDL; + //LL_INFOS() << "EEP: sky name = " << sky->getName() << " - asset id = " << sky->getAssetId() << LL_ENDL; - LLUUID asset_id = day->getAssetId(); - if (asset_id.notNull()) - { - mDayCyclePresetsCombo->selectByValue(LLSD(asset_id)); - - // Water is part of a day cycle - mWLPresetsCombo->selectByValue(LLSD(PRESET_NAME_DAY_CYCLE)); - mWaterPresetsCombo->selectByValue(LLSD(PRESET_NAME_DAY_CYCLE)); - } - else - { - //mDayCyclePresetsCombo->selectByValue(LLSD(day->getName())); - std::string preset_name = day->getName(); - if (preset_name == "_default_") - { - preset_name = "Default"; - } - mDayCyclePresetsCombo->selectByValue(preset_name); - - mWLPresetsCombo->selectByValue(LLSD(PRESET_NAME_DAY_CYCLE)); - - // Legacy daycycle has no water. Need to find out what is currently selected - // as water preset. Seems it will always be default fixed water ("_default_"). - LLSettingsWater::ptr_t water = LLEnvironment::instance().getEnvironmentFixedWater(LLEnvironment::ENV_LOCAL); - if (water) - { - LL_INFOS() << "EEP: water name = " << water->getName() << LL_ENDL; - - LLUUID asset_id = water->getAssetId(); - if (asset_id.notNull()) - { - mWaterPresetsCombo->selectByValue(LLSD(asset_id)); - } - else - { - //mWaterPresetsCombo->selectByValue(LLSD(water->getName())); - std::string preset_name = water->getName(); - if (preset_name == "_default_") - { - preset_name = "Default"; - } - mWaterPresetsCombo->selectByValue(preset_name); - } - } - } - } - else - { - mDayCyclePresetsCombo->selectByValue(LLSD(PRESET_NAME_NONE)); - - //LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); - LLSettingsSky::ptr_t sky = LLEnvironment::instance().getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL); - if (sky) - { - LL_INFOS() << "EEP: sky name = " << sky->getName() << LL_ENDL; - - LLUUID asset_id = sky->getAssetId(); - if (asset_id.notNull()) - { - mWLPresetsCombo->selectByValue(LLSD(asset_id)); - } - else - { - //mWLPresetsCombo->selectByValue(LLSD(sky->getName())); - std::string preset_name = sky->getName(); - if (preset_name == "_default_") - { - preset_name = "Default"; - } - mWLPresetsCombo->selectByValue(preset_name); - } - } - - // LLEnvironment::instance().getCurrentWater() will return correct preset only after - // calling updateEnvironment(), which is too late. - //LLSettingsWater::ptr_t water = LLEnvironment::instance().getCurrentWater(); - LLSettingsWater::ptr_t water = LLEnvironment::instance().getEnvironmentFixedWater(LLEnvironment::ENV_LOCAL); - if (water) - { - LL_INFOS() << "EEP: water name = " << water->getName() << LL_ENDL; - - LLUUID asset_id = water->getAssetId(); - if (asset_id.notNull()) - { - mWaterPresetsCombo->selectByValue(LLSD(asset_id)); - } - else - { - // What if preset name is empty??? - //mWaterPresetsCombo->selectByValue(LLSD(water->getName())); - std::string preset_name = water->getName(); - if (preset_name == "_default_") - { - preset_name = "Default"; - } - mWaterPresetsCombo->selectByValue(preset_name); - } - } - - } - break; + mWLPresetsCombo->selectByValue(LLSD(sky->getAssetId())); + } + + LLSettingsWater::ptr_t water = LLEnvironment::instance().getEnvironmentFixedWater(LLEnvironment::ENV_LOCAL); + if (water && water->getAssetId().notNull()) + { + //LL_INFOS() << "EEP: water name = " << water->getName() << " - asset id = " << water->getAssetId() << LL_ENDL; + + mWaterPresetsCombo->selectByValue(LLSD(water->getAssetId())); } - default: - break; } - - updateDayOffset(); } BOOL FloaterQuickPrefs::postBuild() @@ -564,9 +480,6 @@ BOOL FloaterQuickPrefs::postBuild() mWaterPresetsCombo = getChild("WaterPresetsCombo"); mWLPresetsCombo = getChild("WLPresetsCombo"); mDayCyclePresetsCombo = getChild("DCPresetsCombo"); - mWLSunRot = getChild("sun_rotation"); - mWLDayOffset = getChild("time_offset"); - mWLDayOffset->addSlider(0); initCallbacks(); loadPresets(); @@ -872,70 +785,11 @@ void FloaterQuickPrefs::onClickDayCycleNext() selectDayCyclePreset(mDayCyclePresetsCombo->getSelectedValue()); } -void FloaterQuickPrefs::draw() -{ - updateSun(); - LLTransientDockableFloater::draw(); -} - -void FloaterQuickPrefs::updateDayOffset() -{ - // KC: Limit day cycle offset max to day length if less than a full real day - LLSettingsDay::Seconds day_length = LLEnvironment::instance().getDayLength(); - if (day_length > LLSettingsDay::MINIMUM_DAYOFFSET) - { - if (day_length < LLSettingsDay::MAXIMUM_DAYOFFSET) - { - mWLDayOffset->setMaxValue(day_length); - } - else - { - mWLDayOffset->setMaxValue(LLSettingsDay::MAXIMUM_DAYOFFSET); - } - mWLDayOffset->setCurSliderValue(LLEnvironment::instance().getDayOffsetOverride()); - } - else - { - mWLDayOffset->setCurSliderValue(0); - } -} - -const F32 SUN_ROTATION_PRECISION = 0.1f; - -void FloaterQuickPrefs::updateSun() -{ - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - mWLSunRot->setRotation(psky->getSunRotation()); -} - -void FloaterQuickPrefs::onDayOffset() -{ - //KC: Forces the environment time by an additional offset - if (LLEnvironment::instance().getDayOffset() > LLSettingsDay::INVALID_DAYOFFSET) - { - LLSettingsDay::Seconds day_offset(mWLDayOffset->getCurSliderValue()); - LLEnvironment::instance().setDayOffsetOverride(day_offset); - LLEnvironment::instance().updateEnvironment(); - } -} - -void FloaterQuickPrefs::onSunMoved() -{ - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - psky->setSunRotation(mWLSunRot->getRotation()); - psky->updateSettings(); -} - void FloaterQuickPrefs::onClickResetToRegionDefault() { mWLPresetsCombo->setValue(LLSD(PRESET_NAME_REGION_DEFAULT)); mWaterPresetsCombo->setValue(LLSD(PRESET_NAME_REGION_DEFAULT)); - - LLEnvironment::instance().setDayOffsetOverride(LLSettingsDay::MINIMUM_DAYOFFSET); - mWLDayOffset->setCurSliderValue(0); - LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL); - LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); - LLEnvironment::instance().updateEnvironment(); + LLEnvironment::instance().setSharedEnvironment(); } void FloaterQuickPrefs::setSelectedSky(const std::string& preset_name) @@ -1141,10 +995,7 @@ void FloaterQuickPrefs::enableWindlightButtons(BOOL enable) childSetEnabled("DCPresetsCombo", enable); childSetEnabled("DCPrevPreset", enable); childSetEnabled("DCNextPreset", enable); - // FIRE-13448: Quickprefs daycycle slider allows evading @setenv=n - childSetEnabled("time_offset", enable); - childSetEnabled("sun_rotation", enable); - // FIRE-13448 + childSetEnabled("btn_personal_lighting", enable); if (getIsPhototools()) { diff --git a/indra/newview/quickprefs.h b/indra/newview/quickprefs.h index 102bbaad12..603b0070de 100644 --- a/indra/newview/quickprefs.h +++ b/indra/newview/quickprefs.h @@ -30,8 +30,8 @@ #ifndef QUICKPREFS_H #define QUICKPREFS_H +#include "llenvironment.h" #include "lltransientdockablefloater.h" -//#include "llwlparamset.h" // [EEPMERGE] #include "rlvdefines.h" const std::string PHOTOTOOLS_FLOATER = "phototools"; @@ -67,9 +67,6 @@ private: FloaterQuickPrefs(const LLSD& key); ~FloaterQuickPrefs(); - void onDayOffset(); - void onSunMoved(); - void selectSkyPreset(const LLSD& preset); void selectWaterPreset(const LLSD& preset); void selectDayCyclePreset(const LLSD& preset); @@ -98,12 +95,8 @@ private: void updateRlvRestrictions(ERlvBehaviour behavior, ERlvParamType type); void enableWindlightButtons(BOOL enable); - void updateSun(); - void updateDayOffset(); - public: /*virtual*/ BOOL postBuild(); - /*virtual*/ void draw(); virtual void onOpen(const LLSD& key); void setSelectedSky(const std::string& preset_name); @@ -119,9 +112,7 @@ public: private: - // Windlight controls - LLMultiSliderCtrl* mWLDayOffset; - LLVirtualTrackball* mWLSunRot; + // Windlight controls LLComboBox* mWLPresetsCombo; LLComboBox* mWaterPresetsCombo; LLComboBox* mDayCyclePresetsCombo; @@ -161,6 +152,11 @@ private: LLSliderCtrl* mMaxComplexitySlider; LLTextBox* mMaxComplexityLabel; + LLSettingsSky::ptr_t mLiveSky; + LLSettingsWater::ptr_t mLiveWater; + LLSettingsDay::ptr_t mLiveDay; + LLEnvironment::connection_t mEnvChangedConnection; + // Vignette UI callbacks void onChangeVignetteX(); void onChangeVignetteY(); diff --git a/indra/newview/skins/default/xui/en/floater_phototools.xml b/indra/newview/skins/default/xui/en/floater_phototools.xml index f2d0d0fd0e..97aeee5d01 100644 --- a/indra/newview/skins/default/xui/en/floater_phototools.xml +++ b/indra/newview/skins/default/xui/en/floater_phototools.xml @@ -92,7 +92,7 @@ top_pad="5" left="4" width="275" - height="85" + height="115" border_visible="true" background_visible="true"> - - - - - Sun Position: - - + left="5" + label="Personal Lighting..."> + + +