From 438609699b838924becee89fa9d8ec83552f3236 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 30 Apr 2018 16:37:08 -0700 Subject: New water settings dialog. --- indra/newview/llenvironment.cpp | 35 ++++++++- indra/newview/llenvironment.h | 9 ++- indra/newview/llfloaterfixedenvironment.cpp | 115 +++++++++++++++++++++++++--- indra/newview/llfloaterfixedenvironment.h | 27 +++++-- indra/newview/llpaneleditwater.cpp | 3 +- 5 files changed, 167 insertions(+), 22 deletions(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 214ebb82b0..50f3f4f979 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -202,10 +202,10 @@ bool LLEnvironment::getIsDayTime() const } //------------------------------------------------------------------------- -void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition) +void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition, bool forced) { mSelectedEnvironment = env; - updateEnvironment(transition); + updateEnvironment(transition, forced); } bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env) @@ -337,6 +337,9 @@ LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironme if (fixed.first && fixed.second) break; + if (idx == ENV_EDIT) + continue; // skip the edit environment. + DayInstance::ptr_t environment = getEnvironmentInstance(static_cast(idx)); if (environment) { @@ -379,11 +382,11 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance( } -void LLEnvironment::updateEnvironment(F64Seconds transition) +void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced) { DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance(); - if (mCurrentEnvironment != pinstance) + if ((mCurrentEnvironment != pinstance) || forced) { DayInstance::ptr_t trans = std::make_shared( mCurrentEnvironment->getSky(), mCurrentEnvironment->getWater(), pinstance, transition); @@ -1067,6 +1070,30 @@ std::string LLEnvironment::getUserDir(const std::string &subdir) return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "windlight\\"+subdir, ""); } +LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename) +{ + LLSD data = legacyLoadPreset(filename); + if (!data) + return LLSettingsWater::ptr_t(); + + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data); + + return water; +} + +LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename) +{ + LLSD data = legacyLoadPreset(filename); + if (!data) + return LLSettingsSky::ptr_t(); + + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true)); + LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data); + + return sky; +} + LLSD LLEnvironment::legacyLoadPreset(const std::string& path) { llifstream xml_file; diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 95b24314cb..cb6cd11608 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -143,7 +143,7 @@ public: void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); void updateShaderUniforms(LLGLSLShader *shader); - void setSelectedEnvironment(EnvSelection_t env, F64Seconds transition = TRANSITION_DEFAULT); + void setSelectedEnvironment(EnvSelection_t env, F64Seconds transition = TRANSITION_DEFAULT, bool forced = false); EnvSelection_t getSelectedEnvironment() const { return mSelectedEnvironment; } bool hasEnvironment(EnvSelection_t env); @@ -159,7 +159,7 @@ public: LLSettingsSky::ptr_t getEnvironmentFixedSky(EnvSelection_t env) { return getEnvironmentFixed(env).first; }; LLSettingsWater::ptr_t getEnvironmentFixedWater(EnvSelection_t env) { return getEnvironmentFixed(env).second; }; - void updateEnvironment(F64Seconds transition = TRANSITION_DEFAULT); + void updateEnvironment(F64Seconds transition = TRANSITION_DEFAULT, bool forced = false); void addSky(const LLSettingsSky::ptr_t &sky); void addWater(const LLSettingsWater::ptr_t &sky); @@ -187,6 +187,9 @@ public: inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentEnvironment->getSky()->getClampedLightDirection(), 0.0f); } inline LLVector4 getRotatedLight() const { return mRotatedLight; } + static LLSettingsWater::ptr_t createWaterFromLegacyPreset(const std::string filename); + static LLSettingsSky::ptr_t createSkyFromLegacyPreset(const std::string filename); + //------------------------------------------- connection_t setSkyListChange(const change_signal_t::slot_type& cb); connection_t setWaterListChange(const change_signal_t::slot_type& cb); @@ -356,7 +359,7 @@ private: void onTransitionDone(const LLSettingsBlender::ptr_t, bool isSky); //========================================================================= void legacyLoadAllPresets(); - LLSD legacyLoadPreset(const std::string& path); + static LLSD legacyLoadPreset(const std::string& path); static std::string getSysDir(const std::string &subdir); static std::string getUserDir(const std::string &subdir); diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index d5162ef622..6c883b2534 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -36,6 +36,7 @@ #include "llnotificationsutil.h" #include "llsliderctrl.h" #include "lltabcontainer.h" +#include "llfilepicker.h" // newview #include "llpaneleditwater.h" @@ -44,6 +45,9 @@ #include "llsettingswater.h" #include "llenvironment.h" +#include "llagent.h" + +#include "llsettingsvo.h" namespace { @@ -70,22 +74,41 @@ BOOL LLFloaterFixedEnvironment::postBuild() mTxtName->setCommitOnFocusLost(TRUE); mTxtName->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNameChanged(mTxtName->getValue().asString()); }); + getChild(BUTTON_NAME_LOAD)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonLoad(); }); + getChild(BUTTON_NAME_IMPORT)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonImport(); }); + getChild(BUTTON_NAME_COMMIT)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonApply(); }); + getChild(BUTTON_NAME_CANCEL)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonCancel(); }); + return TRUE; } void LLFloaterFixedEnvironment::onFocusReceived() { updateEditEnvironment(); - LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); } void LLFloaterFixedEnvironment::onFocusLost() { + // *TODO*: If the window receiving focus is from a select color or select image control... + // We have technically not changed out of what we are doing so don't change back to displaying + // the local environment. (unfortunately the focus manager has LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } void LLFloaterFixedEnvironment::refresh() { + if (!mSettings) + { + // disable everything. + return; + } + + bool enableApplyAndLoad = canUseInventory(); + + getChild(BUTTON_NAME_LOAD)->setEnabled(enableApplyAndLoad); + getChild(BUTTON_NAME_COMMIT)->setEnabled(enableApplyAndLoad); + mTxtName->setValue(mSettings->getName()); S32 count = mTab->getTabCount(); @@ -115,6 +138,33 @@ void LLFloaterFixedEnvironment::onNameChanged(const std::string &name) mSettings->setName(name); } +void LLFloaterFixedEnvironment::onButtonLoad() +{ + doLoadFromInventory(); +} + +void LLFloaterFixedEnvironment::onButtonImport() +{ + doImportFromDisk(); +} + +void LLFloaterFixedEnvironment::onButtonApply() +{ + doApplyFixedSettings(); +} + +void LLFloaterFixedEnvironment::onButtonCancel() +{ + // *TODO*: If changed issue a warning? + this->closeFloater(); +} + +//------------------------------------------------------------------------- +bool LLFloaterFixedEnvironment::canUseInventory() const +{ + return !gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty(); +} + //========================================================================= LLFloaterFixedEnvironmentWater::LLFloaterFixedEnvironmentWater(const LLSD &key): LLFloaterFixedEnvironment(key) @@ -131,22 +181,69 @@ BOOL LLFloaterFixedEnvironmentWater::postBuild() panel->setWater(std::static_pointer_cast(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(); + return TRUE; +} - mSettings->setName("Snapshot water (new)"); +void LLFloaterFixedEnvironmentWater::updateEditEnvironment(void) +{ + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, + std::static_pointer_cast(mSettings)); +} - mTxtName->setValue(mSettings->getName()); +void LLFloaterFixedEnvironmentWater::onOpen(const LLSD& key) +{ + if (!mSettings) + { + // Initialize the settings, take a snapshot of the current water. + mSettings = LLEnvironment::instance().getEnvironmentFixedWater(LLEnvironment::ENV_CURRENT)->buildClone(); + mSettings->setName("Snapshot water (new)"); + // TODO: Should we grab sky and keep it around for reference? + } + + updateEditEnvironment(); syncronizeTabs(); refresh(); - return TRUE; + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); } -void LLFloaterFixedEnvironmentWater::updateEditEnvironment(void) +void LLFloaterFixedEnvironmentWater::onClose(bool app_quitting) { - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, - std::static_pointer_cast(mSettings)); + mSettings.reset(); + syncronizeTabs(); +} + +void LLFloaterFixedEnvironmentWater::doLoadFromInventory() +{ + +} + +void LLFloaterFixedEnvironmentWater::doImportFromDisk() +{ // Load a a legacy Windlight XML from disk. + + LLFilePicker& picker = LLFilePicker::instance(); + if (picker.getOpenFile(LLFilePicker::FFLOAD_XML)) + { + std::string filename = picker.getFirstFile(); + + LL_WARNS("LAPRAS") << "Selected file: " << filename << LL_ENDL; + LLSettingsWater::ptr_t legacywater = LLEnvironment::createWaterFromLegacyPreset(filename); + + if (!legacywater) + { // *TODO* Put up error dialog here. Could not create water from filename + return; + } + + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, legacywater); + this->setEditSettings(legacywater); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_FAST, true); + } +} + +void LLFloaterFixedEnvironmentWater::doApplyFixedSettings() +{ + LLSettingsVOBase::createInventoryItem(mSettings); + } //========================================================================= diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h index 0d2d21533e..9eb03e0b3a 100644 --- a/indra/newview/llfloaterfixedenvironment.h +++ b/indra/newview/llfloaterfixedenvironment.h @@ -49,7 +49,7 @@ public: virtual void onFocusReceived() override; virtual void onFocusLost() override; - void setEditSettings(LLSettingsBase::ptr_t &settings) { mSettings = settings; syncronizeTabs(); } + void setEditSettings(const LLSettingsBase::ptr_t &settings) { mSettings = settings; syncronizeTabs(); refresh(); } LLSettingsBase::ptr_t getEditSettings() const { return mSettings; } protected: @@ -63,9 +63,19 @@ protected: LLSettingsBase::ptr_t mSettings; + virtual void doLoadFromInventory() = 0; + virtual void doImportFromDisk() = 0; + virtual void doApplyFixedSettings() = 0; + + bool canUseInventory() const; private: - void onNameChanged(const std::string &name); + void onNameChanged(const std::string &name); + + void onButtonLoad(); + void onButtonImport(); + void onButtonApply(); + void onButtonCancel(); #if 0 @@ -146,10 +156,17 @@ class LLFloaterFixedEnvironmentWater : public LLFloaterFixedEnvironment public: LLFloaterFixedEnvironmentWater(const LLSD &key); - BOOL postBuild() override; + BOOL postBuild() override; + + virtual void onOpen(const LLSD& key) override; + virtual void onClose(bool app_quitting) override; + +protected: + virtual void updateEditEnvironment() override; -protected: - virtual void updateEditEnvironment() override; + virtual void doLoadFromInventory() override; + virtual void doImportFromDisk() override; + virtual void doApplyFixedSettings() override; private: }; diff --git a/indra/newview/llpaneleditwater.cpp b/indra/newview/llpaneleditwater.cpp index 08ba198894..3cb1dcfda4 100644 --- a/indra/newview/llpaneleditwater.cpp +++ b/indra/newview/llpaneleditwater.cpp @@ -80,11 +80,12 @@ BOOL LLPanelSettingsWaterMainTab::postBuild() mClrFogColor = getChild(FIELD_WATER_FOG_COLOR); mTxtNormalMap = getChild(FIELD_WATER_NORMAL_MAP); - mClrFogColor->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogColorChanged(); }); getChild(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(); }); // getChild(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(getChild(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); }); getChild(FIELD_WATER_UNDERWATER_MOD)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogUnderWaterChanged(); }); + + mTxtNormalMap->setDefaultImageAssetID(LLSettingsWater::DEFAULT_WATER_NORMAL_ID); mTxtNormalMap->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalMapChanged(); }); getChild(FIELD_WATER_WAVE1_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLargeWaveChanged(); }); -- cgit v1.2.3 From 081d90c98950a083ba4466fbb3a91b8c6a1ed5e2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 30 Apr 2018 16:47:06 -0700 Subject: Refresh is defined in LLPanel. Must be marked override here also --- indra/newview/llfloaterfixedenvironment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h index 9eb03e0b3a..be1ba4a58b 100644 --- a/indra/newview/llfloaterfixedenvironment.h +++ b/indra/newview/llfloaterfixedenvironment.h @@ -54,7 +54,7 @@ public: protected: virtual void updateEditEnvironment() = 0; - virtual void refresh(); + virtual void refresh() override; virtual void syncronizeTabs(); @@ -176,7 +176,7 @@ class LLSettingsEditPanel : public LLPanel public: virtual void setSettings(LLSettingsBase::ptr_t &) = 0; - virtual void refresh() = 0; +// virtual void refresh() override; protected: LLSettingsEditPanel() : -- cgit v1.2.3 From 9dd5e4a5a7521f2576537738263196cfb88bb01d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 1 May 2018 09:58:57 -0700 Subject: Mac is not fond at all of unused variables. --- indra/newview/llpaneleditwater.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/indra/newview/llpaneleditwater.h b/indra/newview/llpaneleditwater.h index 5c700c7231..72ffa05767 100644 --- a/indra/newview/llpaneleditwater.h +++ b/indra/newview/llpaneleditwater.h @@ -72,26 +72,26 @@ protected: private: LLColorSwatchCtrl * mClrFogColor; - LLSlider * mSldFogDensity; - LLSlider * mSldUnderWaterMod; +// 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; +// // 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(); -- cgit v1.2.3 From 03da2bc1a1c7674514c967b0e7408258dba25d77 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 2 May 2018 17:07:06 -0700 Subject: Fixed sky editing floater. --- indra/llinventory/llsettingssky.h | 20 ++ indra/newview/CMakeLists.txt | 2 + indra/newview/llfloaterfixedenvironment.cpp | 91 +++++ indra/newview/llfloaterfixedenvironment.h | 22 ++ indra/newview/llpaneleditsky.cpp | 388 +++++++++++++++++++++ indra/newview/llpaneleditsky.h | 124 +++++++ indra/newview/llviewerfloaterreg.cpp | 1 + indra/newview/llviewermenu.cpp | 10 +- .../default/xui/en/floater_fixedenvironment.xml | 7 +- .../default/xui/en/panel_settings_sky_atmos.xml | 240 +++++++++++++ .../default/xui/en/panel_settings_sky_clouds.xml | 255 ++++++++++++++ .../default/xui/en/panel_settings_sky_sunmoon.xml | 234 +++++++++++++ 12 files changed, 1386 insertions(+), 8 deletions(-) create mode 100644 indra/newview/llpaneleditsky.cpp create mode 100644 indra/newview/llpaneleditsky.h create mode 100644 indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml create mode 100644 indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml create mode 100644 indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index d08e2bbd03..1451162744 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -189,6 +189,11 @@ public: return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); } + void setCloudNoiseTextureId(const LLUUID &id) + { + setValue(SETTING_CLOUD_TEXTUREID, id); + } + LLColor3 getCloudPosDensity1() const { return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); @@ -300,6 +305,11 @@ public: return mSettings[SETTING_MAX_Y].asReal(); } + void setMaxY(F32 val) + { + setValue(SETTING_MAX_Y, val); + } + LLQuaternion getMoonRotation() const { return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); @@ -324,6 +334,11 @@ public: return mSettings[SETTING_MOON_TEXTUREID].asUUID(); } + void setMoonTextureId(LLUUID id) + { + setValue(SETTING_MOON_TEXTUREID, id); + } + F32 getStarBrightness() const { return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); @@ -368,6 +383,11 @@ public: return mSettings[SETTING_SUN_TEXTUREID].asUUID(); } + void setSunTextureId(LLUUID id) + { + setValue(SETTING_SUN_TEXTUREID, id); + } + // Internal/calculated settings LLVector3 getLightDirection() const { diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 109001f82e..654487b8fb 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -421,6 +421,7 @@ set(viewer_SOURCE_FILES llpanelblockedlist.cpp llpanelclassified.cpp llpanelcontents.cpp + llpaneleditsky.cpp llpaneleditwater.cpp llpaneleditwearable.cpp llpanelenvironment.cpp @@ -1031,6 +1032,7 @@ set(viewer_HEADER_FILES llpanelblockedlist.h llpanelclassified.h llpanelcontents.h + llpaneleditsky.h llpaneleditwater.h llpaneleditwearable.h llpanelenvironment.h diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index 6c883b2534..ec8e2c8965 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -40,6 +40,7 @@ // newview #include "llpaneleditwater.h" +#include "llpaneleditsky.h" #include "llsettingssky.h" #include "llsettingswater.h" @@ -246,6 +247,96 @@ void LLFloaterFixedEnvironmentWater::doApplyFixedSettings() } +//========================================================================= +LLFloaterFixedEnvironmentSky::LLFloaterFixedEnvironmentSky(const LLSD &key) : + LLFloaterFixedEnvironment(key) +{} + +BOOL LLFloaterFixedEnvironmentSky::postBuild() +{ + if (!LLFloaterFixedEnvironment::postBuild()) + return FALSE; + + LLPanelSettingsSky * panel; + panel = new LLPanelSettingsSkyAtmosTab; + panel->buildFromFile("panel_settings_sky_atmos.xml"); + panel->setSky(std::static_pointer_cast(mSettings)); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(true)); + + panel = new LLPanelSettingsSkyCloudTab; + panel->buildFromFile("panel_settings_sky_clouds.xml"); + panel->setSky(std::static_pointer_cast(mSettings)); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + + panel = new LLPanelSettingsSkySunMoonTab; + panel->buildFromFile("panel_settings_sky_sunmoon.xml"); + panel->setSky(std::static_pointer_cast(mSettings)); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + + return TRUE; +} + +void LLFloaterFixedEnvironmentSky::updateEditEnvironment(void) +{ + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, + std::static_pointer_cast(mSettings)); +} + +void LLFloaterFixedEnvironmentSky::onOpen(const LLSD& key) +{ + if (!mSettings) + { + // Initialize the settings, take a snapshot of the current water. + mSettings = LLEnvironment::instance().getEnvironmentFixedSky(LLEnvironment::ENV_CURRENT)->buildClone(); + mSettings->setName("Snapshot sky (new)"); + + // TODO: Should we grab sky and keep it around for reference? + } + + updateEditEnvironment(); + syncronizeTabs(); + refresh(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST); +} + +void LLFloaterFixedEnvironmentSky::onClose(bool app_quitting) +{ + mSettings.reset(); + syncronizeTabs(); +} + +void LLFloaterFixedEnvironmentSky::doLoadFromInventory() +{ + +} + +void LLFloaterFixedEnvironmentSky::doImportFromDisk() +{ // Load a a legacy Windlight XML from disk. + + LLFilePicker& picker = LLFilePicker::instance(); + if (picker.getOpenFile(LLFilePicker::FFLOAD_XML)) + { + std::string filename = picker.getFirstFile(); + + LL_WARNS("LAPRAS") << "Selected file: " << filename << LL_ENDL; + LLSettingsSky::ptr_t legacysky = LLEnvironment::createSkyFromLegacyPreset(filename); + + if (!legacysky) + { // *TODO* Put up error dialog here. Could not create water from filename + return; + } + + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, legacysky); + this->setEditSettings(legacysky); + LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_FAST, true); + } +} + +void LLFloaterFixedEnvironmentSky::doApplyFixedSettings() +{ + LLSettingsVOBase::createInventoryItem(mSettings); +} + //========================================================================= #if 0 diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h index be1ba4a58b..590be08169 100644 --- a/indra/newview/llfloaterfixedenvironment.h +++ b/indra/newview/llfloaterfixedenvironment.h @@ -171,6 +171,28 @@ protected: private: }; +class LLFloaterFixedEnvironmentSky : public LLFloaterFixedEnvironment +{ + LOG_CLASS(LLFloaterFixedEnvironmentSky); + +public: + LLFloaterFixedEnvironmentSky(const LLSD &key); + + BOOL postBuild() override; + + virtual void onOpen(const LLSD& key) override; + virtual void onClose(bool app_quitting) override; + +protected: + virtual void updateEditEnvironment() override; + + virtual void doLoadFromInventory() override; + virtual void doImportFromDisk() override; + virtual void doApplyFixedSettings() override; + +private: +}; + class LLSettingsEditPanel : public LLPanel { public: diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp new file mode 100644 index 0000000000..e10af29e82 --- /dev/null +++ b/indra/newview/llpaneleditsky.cpp @@ -0,0 +1,388 @@ +/** +* @file llpaneleditsky.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 "llpaneleditsky.h" + +#include "llslider.h" +#include "lltexturectrl.h" +#include "llcolorswatch.h" +#include "lljoystickbutton.h" + +namespace +{ + // Atmosphere Tab + const std::string FIELD_SKY_AMBIENT_LIGHT("ambient_light"); + const std::string FIELD_SKY_BLUE_HORIZON("blue_horizon"); + const std::string FIELD_SKY_BLUE_DENSITY("blue_density"); + const std::string FIELD_SKY_HAZE_HORIZON("haze_horizon"); + const std::string FIELD_SKY_HAZE_DENSITY("haze_density"); + const std::string FIELD_SKY_SCENE_GAMMA("scene_gamma"); + const std::string FIELD_SKY_DENSITY_MULTIP("density_multip"); + const std::string FIELD_SKY_DISTANCE_MULTIP("distance_multip"); + const std::string FIELD_SKY_MAX_ALT("max_alt"); + + const std::string FIELD_SKY_CLOUD_COLOR("cloud_color"); + const std::string FIELD_SKY_CLOUD_COVERAGE("cloud_coverage"); + const std::string FIELD_SKY_CLOUD_SCALE("cloud_scale"); + const std::string FIELD_SKY_CLOUD_SCROLL_X("cloud_scroll_x"); + const std::string FIELD_SKY_CLOUD_SCROLL_Y("cloud_scroll_y"); + const std::string FIELD_SKY_CLOUD_MAP("cloud_map"); + const std::string FIELD_SKY_CLOUD_DENSITY_X("cloud_density_x"); + const std::string FIELD_SKY_CLOUD_DENSITY_Y("cloud_density_y"); + const std::string FIELD_SKY_CLOUD_DENSITY_D("cloud_density_d"); + const std::string FIELD_SKY_CLOUD_DETAIL_X("cloud_detail_x"); + const std::string FIELD_SKY_CLOUD_DETAIL_Y("cloud_detail_y"); + const std::string FIELD_SKY_CLOUD_DETAIL_D("cloud_detail_d"); + + const std::string FIELD_SKY_SUN_MOON_COLOR("sun_moon_color"); + const std::string FIELD_SKY_GLOW_FOCUS("glow_focus"); + const std::string FIELD_SKY_GLOW_SIZE("glow_size"); + const std::string FIELD_SKY_STAR_BRIGHTNESS("star_brightness"); + const std::string FIELD_SKY_SUN_ROTATION("sun_rotation"); + const std::string FIELD_SKY_SUN_IMAGE("sun_image"); + const std::string FIELD_SKY_MOON_ROTATION("moon_rotation"); + const std::string FIELD_SKY_MOON_IMAGE("moon_image"); + + const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f); + const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f); + const F32 SLIDER_SCALE_GLOW_R(20.0f); + const F32 SLIDER_SCALE_GLOW_B(-5.0f); +} + +//========================================================================== +LLPanelSettingsSky::LLPanelSettingsSky() : + LLSettingsEditPanel(), + mSkySettings() +{ + +} + + +//========================================================================== +LLPanelSettingsSkyAtmosTab::LLPanelSettingsSkyAtmosTab() : + LLPanelSettingsSky() +{ +} + + +BOOL LLPanelSettingsSkyAtmosTab::postBuild() +{ + getChild(FIELD_SKY_AMBIENT_LIGHT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAmbientLightChanged(); }); + getChild(FIELD_SKY_BLUE_HORIZON)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlueHorizonChanged(); }); + getChild(FIELD_SKY_BLUE_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlueDensityChanged(); }); + getChild(FIELD_SKY_HAZE_HORIZON)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onHazeHorizonChanged(); }); + getChild(FIELD_SKY_HAZE_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onHazeDensityChanged(); }); + getChild(FIELD_SKY_SCENE_GAMMA)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSceneGammaChanged(); }); + getChild(FIELD_SKY_DENSITY_MULTIP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDensityMultipChanged(); }); + getChild(FIELD_SKY_DISTANCE_MULTIP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDistanceMultipChanged(); }); + getChild(FIELD_SKY_MAX_ALT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMaxAltChanged(); }); + + refresh(); + + return TRUE; +} + +void LLPanelSettingsSkyAtmosTab::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + getChild(FIELD_SKY_AMBIENT_LIGHT)->set(mSkySettings->getAmbientColor() / SLIDER_SCALE_SUN_AMBIENT); + getChild(FIELD_SKY_BLUE_HORIZON)->set(mSkySettings->getBlueHorizon() / SLIDER_SCALE_BLUE_HORIZON_DENSITY); + getChild(FIELD_SKY_BLUE_DENSITY)->set(mSkySettings->getBlueDensity() / SLIDER_SCALE_BLUE_HORIZON_DENSITY); + + getChild(FIELD_SKY_HAZE_HORIZON)->setValue(mSkySettings->getHazeHorizon()); + getChild(FIELD_SKY_HAZE_DENSITY)->setValue(mSkySettings->getHazeDensity()); + getChild(FIELD_SKY_SCENE_GAMMA)->setValue(mSkySettings->getGamma()); + getChild(FIELD_SKY_DENSITY_MULTIP)->setValue(mSkySettings->getDensityMultiplier()); + getChild(FIELD_SKY_DISTANCE_MULTIP)->setValue(mSkySettings->getDistanceMultiplier()); + getChild(FIELD_SKY_MAX_ALT)->setValue(mSkySettings->getMaxY()); + +} + +//------------------------------------------------------------------------- +void LLPanelSettingsSkyAtmosTab::onAmbientLightChanged() +{ + mSkySettings->setAmbientColor(LLColor3(getChild(FIELD_SKY_AMBIENT_LIGHT)->get() * SLIDER_SCALE_SUN_AMBIENT)); +} + +void LLPanelSettingsSkyAtmosTab::onBlueHorizonChanged() +{ + mSkySettings->setBlueHorizon(LLColor3(getChild(FIELD_SKY_BLUE_HORIZON)->get() * SLIDER_SCALE_BLUE_HORIZON_DENSITY)); +} + +void LLPanelSettingsSkyAtmosTab::onBlueDensityChanged() +{ + mSkySettings->setBlueDensity(LLColor3(getChild(FIELD_SKY_BLUE_DENSITY)->get() * SLIDER_SCALE_BLUE_HORIZON_DENSITY)); +} + +void LLPanelSettingsSkyAtmosTab::onHazeHorizonChanged() +{ + mSkySettings->setHazeHorizon(getChild(FIELD_SKY_HAZE_HORIZON)->getValue().asReal()); +} + +void LLPanelSettingsSkyAtmosTab::onHazeDensityChanged() +{ + mSkySettings->setHazeDensity(getChild(FIELD_SKY_HAZE_DENSITY)->getValue().asReal()); +} + +void LLPanelSettingsSkyAtmosTab::onSceneGammaChanged() +{ + mSkySettings->setGamma(getChild(FIELD_SKY_SCENE_GAMMA)->getValue().asReal()); +} + +void LLPanelSettingsSkyAtmosTab::onDensityMultipChanged() +{ + mSkySettings->setDensityMultiplier(getChild(FIELD_SKY_DENSITY_MULTIP)->getValue().asReal()); +} + +void LLPanelSettingsSkyAtmosTab::onDistanceMultipChanged() +{ + mSkySettings->setDistanceMultiplier(getChild(FIELD_SKY_DISTANCE_MULTIP)->getValue().asReal()); +} + +void LLPanelSettingsSkyAtmosTab::onMaxAltChanged() +{ + mSkySettings->setMaxY(getChild(FIELD_SKY_MAX_ALT)->getValue().asReal()); +} + +//========================================================================== +LLPanelSettingsSkyCloudTab::LLPanelSettingsSkyCloudTab() : + LLPanelSettingsSky() +{ +} + + +BOOL LLPanelSettingsSkyCloudTab::postBuild() +{ + getChild(FIELD_SKY_CLOUD_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudColorChanged(); }); + getChild(FIELD_SKY_CLOUD_COVERAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudCoverageChanged(); }); + getChild(FIELD_SKY_CLOUD_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScaleChanged(); }); + getChild(FIELD_SKY_CLOUD_SCROLL_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScrollChanged(); }); + getChild(FIELD_SKY_CLOUD_SCROLL_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScrollChanged(); }); + getChild(FIELD_SKY_CLOUD_MAP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudMapChanged(); }); +// getChild(FIELD_SKY_CLOUD_MAP)->setDefaultImageAssetID(LLSettingsSky::DEFAULT_CLOUD_TEXTURE_ID); + + getChild(FIELD_SKY_CLOUD_DENSITY_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); + getChild(FIELD_SKY_CLOUD_DENSITY_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); + getChild(FIELD_SKY_CLOUD_DENSITY_D)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); + getChild(FIELD_SKY_CLOUD_DETAIL_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); + getChild(FIELD_SKY_CLOUD_DETAIL_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); + getChild(FIELD_SKY_CLOUD_DETAIL_D)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); + + refresh(); + + return TRUE; +} + +void LLPanelSettingsSkyCloudTab::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + getChild(FIELD_SKY_CLOUD_COLOR)->set(mSkySettings->getCloudColor()); + getChild(FIELD_SKY_CLOUD_COVERAGE)->setValue(mSkySettings->getCloudShadow()); + getChild(FIELD_SKY_CLOUD_SCALE)->setValue(mSkySettings->getCloudScale()); + + LLVector2 cloudScroll(mSkySettings->getCloudScrollRate()); + getChild(FIELD_SKY_CLOUD_SCROLL_X)->setValue(cloudScroll[0]); + getChild(FIELD_SKY_CLOUD_SCROLL_Y)->setValue(cloudScroll[1]); + + getChild(FIELD_SKY_CLOUD_MAP)->setValue(mSkySettings->getCloudNoiseTextureId()); + + LLVector3 cloudDensity(mSkySettings->getCloudPosDensity1().getValue()); + getChild(FIELD_SKY_CLOUD_DENSITY_X)->setValue(cloudDensity[0]); + getChild(FIELD_SKY_CLOUD_DENSITY_Y)->setValue(cloudDensity[1]); + getChild(FIELD_SKY_CLOUD_DENSITY_D)->setValue(cloudDensity[2]); + + LLVector3 cloudDetail(mSkySettings->getCloudPosDensity1().getValue()); + getChild(FIELD_SKY_CLOUD_DETAIL_X)->setValue(cloudDetail[0]); + getChild(FIELD_SKY_CLOUD_DETAIL_Y)->setValue(cloudDetail[1]); + getChild(FIELD_SKY_CLOUD_DETAIL_D)->setValue(cloudDetail[2]); +} + +//------------------------------------------------------------------------- +void LLPanelSettingsSkyCloudTab::onCloudColorChanged() +{ + mSkySettings->setCloudColor(LLColor3(getChild(FIELD_SKY_CLOUD_COLOR)->get())); +} + +void LLPanelSettingsSkyCloudTab::onCloudCoverageChanged() +{ + mSkySettings->setCloudShadow(getChild(FIELD_SKY_CLOUD_COVERAGE)->getValue().asReal()); +} + +void LLPanelSettingsSkyCloudTab::onCloudScaleChanged() +{ + mSkySettings->setCloudScale(getChild(FIELD_SKY_CLOUD_SCALE)->getValue().asReal()); +} + +void LLPanelSettingsSkyCloudTab::onCloudScrollChanged() +{ + LLVector2 scroll(getChild(FIELD_SKY_CLOUD_SCROLL_X)->getValue().asReal(), + getChild(FIELD_SKY_CLOUD_SCROLL_Y)->getValue().asReal()); + + mSkySettings->setCloudScrollRate(scroll); +} + +void LLPanelSettingsSkyCloudTab::onCloudMapChanged() +{ + mSkySettings->setCloudNoiseTextureId(getChild(FIELD_SKY_CLOUD_MAP)->getValue().asUUID()); +} + +void LLPanelSettingsSkyCloudTab::onCloudDensityChanged() +{ + LLColor3 density(getChild(FIELD_SKY_CLOUD_DENSITY_X)->getValue().asReal(), + getChild(FIELD_SKY_CLOUD_DENSITY_Y)->getValue().asReal(), + getChild(FIELD_SKY_CLOUD_DENSITY_D)->getValue().asReal()); + + mSkySettings->setCloudPosDensity1(density); +} + +void LLPanelSettingsSkyCloudTab::onCloudDetailChanged() +{ + LLColor3 detail(getChild(FIELD_SKY_CLOUD_DETAIL_X)->getValue().asReal(), + getChild(FIELD_SKY_CLOUD_DETAIL_Y)->getValue().asReal(), + getChild(FIELD_SKY_CLOUD_DETAIL_D)->getValue().asReal()); + + mSkySettings->setCloudPosDensity2(detail); +} + +//========================================================================== +LLPanelSettingsSkySunMoonTab::LLPanelSettingsSkySunMoonTab() : + LLPanelSettingsSky() +{ +} + + +BOOL LLPanelSettingsSkySunMoonTab::postBuild() +{ + getChild(FIELD_SKY_SUN_MOON_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunMoonColorChanged(); }); + getChild(FIELD_SKY_GLOW_FOCUS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); + getChild(FIELD_SKY_GLOW_SIZE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); + getChild(FIELD_SKY_STAR_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onStarBrightnessChanged(); }); + getChild(FIELD_SKY_SUN_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunRotationChanged(); }); + getChild(FIELD_SKY_SUN_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunImageChanged(); }); +// getChild(FIELD_SKY_SUN_IMAGE)->setDefaultImageAssetID(LLSettingsSky:: ); + getChild(FIELD_SKY_MOON_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonRotationChanged(); }); + getChild(FIELD_SKY_MOON_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonImageChanged(); }); +// getChild(FIELD_SKY_MOON_IMAGE)->setDefaultImageAssetID(LLSettingsSky:: ); + + refresh(); + + return TRUE; +} + +void LLPanelSettingsSkySunMoonTab::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + getChild(FIELD_SKY_SUN_MOON_COLOR)->set(mSkySettings->getSunlightColor() / SLIDER_SCALE_SUN_AMBIENT); + + LLColor3 glow(mSkySettings->getGlow()); + + glow.mV[0] = 2 - (glow.mV[0] / SLIDER_SCALE_GLOW_R); + glow.mV[2] /= SLIDER_SCALE_GLOW_B; + + getChild(FIELD_SKY_GLOW_FOCUS)->setValue(glow.mV[0]); + getChild(FIELD_SKY_GLOW_SIZE)->setValue(glow.mV[2]); + + getChild(FIELD_SKY_STAR_BRIGHTNESS)->setValue(mSkySettings->getStarBrightness()); + getChild(FIELD_SKY_SUN_ROTATION)->setRotation(mSkySettings->getSunRotation()); + getChild(FIELD_SKY_SUN_IMAGE)->setValue(mSkySettings->getSunTextureId()); + getChild(FIELD_SKY_MOON_ROTATION)->setRotation(mSkySettings->getMoonRotation()); + getChild(FIELD_SKY_MOON_IMAGE)->setValue(mSkySettings->getMoonTextureId()); +} + +//------------------------------------------------------------------------- +void LLPanelSettingsSkySunMoonTab::onSunMoonColorChanged() +{ + LLColor3 color(getChild(FIELD_SKY_SUN_MOON_COLOR)->get()); + + color *= SLIDER_SCALE_SUN_AMBIENT; + + mSkySettings->setSunlightColor(color); +} + +void LLPanelSettingsSkySunMoonTab::onGlowChanged() +{ + LLColor3 glow(getChild(FIELD_SKY_GLOW_FOCUS)->getValue().asReal(), 0.0f, + getChild(FIELD_SKY_GLOW_SIZE)->getValue().asReal()); + + glow.mV[0] = (2 - glow.mV[0]) * SLIDER_SCALE_GLOW_R; + glow.mV[2] *= SLIDER_SCALE_GLOW_B; + + mSkySettings->setGlow(glow); +} + +void LLPanelSettingsSkySunMoonTab::onStarBrightnessChanged() +{ + mSkySettings->setStarBrightness(getChild(FIELD_SKY_STAR_BRIGHTNESS)->getValue().asReal()); +} + +void LLPanelSettingsSkySunMoonTab::onSunRotationChanged() +{ + mSkySettings->setSunRotation(getChild(FIELD_SKY_SUN_ROTATION)->getRotation()); +} + +void LLPanelSettingsSkySunMoonTab::onSunImageChanged() +{ + mSkySettings->setSunTextureId(getChild(FIELD_SKY_SUN_IMAGE)->getValue().asUUID()); +} + +void LLPanelSettingsSkySunMoonTab::onMoonRotationChanged() +{ + mSkySettings->setMoonRotation(getChild(FIELD_SKY_MOON_ROTATION)->getRotation()); +} + +void LLPanelSettingsSkySunMoonTab::onMoonImageChanged() +{ + mSkySettings->setMoonTextureId(getChild(FIELD_SKY_MOON_IMAGE)->getValue().asUUID()); +} diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h new file mode 100644 index 0000000000..497c98af1f --- /dev/null +++ b/indra/newview/llpaneleditsky.h @@ -0,0 +1,124 @@ +/** +* @file llpaneleditsky.h +* @brief Panels for sky 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_SKY_H +#define LLPANEL_EDIT_SKY_H + +#include "llpanel.h" +#include "llsettingssky.h" + +#include "llfloaterfixedenvironment.h" + +//========================================================================= +class LLSlider; +class LLColorSwatchCtrl; +class LLTextureCtrl; + +//========================================================================= +class LLPanelSettingsSky : public LLSettingsEditPanel +{ + LOG_CLASS(LLPanelSettingsSky); + +public: + LLPanelSettingsSky(); + + virtual void setSettings(LLSettingsBase::ptr_t &settings) override { setSky(std::static_pointer_cast(settings)); } + + LLSettingsSky::ptr_t getSky() const { return mSkySettings; } + void setSky(const LLSettingsSky::ptr_t &sky) { mSkySettings = sky; refresh(); } + +protected: + LLSettingsSky::ptr_t mSkySettings; +}; + +class LLPanelSettingsSkyAtmosTab : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsSkyAtmosTab); + +public: + LLPanelSettingsSkyAtmosTab(); + + virtual BOOL postBuild() override; + +protected: + virtual void refresh() override; + +private: + void onAmbientLightChanged(); + void onBlueHorizonChanged(); + void onBlueDensityChanged(); + void onHazeHorizonChanged(); + void onHazeDensityChanged(); + void onSceneGammaChanged(); + void onDensityMultipChanged(); + void onDistanceMultipChanged(); + void onMaxAltChanged(); +}; + +class LLPanelSettingsSkyCloudTab : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsSkyCloudTab); + +public: + LLPanelSettingsSkyCloudTab(); + + virtual BOOL postBuild() override; + +protected: + virtual void refresh() override; + +private: + void onCloudColorChanged(); + void onCloudCoverageChanged(); + void onCloudScaleChanged(); + void onCloudScrollChanged(); + void onCloudMapChanged(); + void onCloudDensityChanged(); + void onCloudDetailChanged(); +}; + +class LLPanelSettingsSkySunMoonTab : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsSkySunMoonTab); + +public: + LLPanelSettingsSkySunMoonTab(); + + virtual BOOL postBuild() override; + +protected: + virtual void refresh() override; + +private: + void onSunMoonColorChanged(); + void onGlowChanged(); + void onStarBrightnessChanged(); + void onSunRotationChanged(); + void onSunImageChanged(); + void onMoonRotationChanged(); + void onMoonImageChanged(); +}; +#endif // LLPANEL_EDIT_SKY_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 1af6ecb8b6..7e0a3a5fd8 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -228,6 +228,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_fixed_environmentent_water", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("env_fixed_environmentent_sky", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); //LLFloaterReg::add("env_fixed_environmentent", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_edit_extdaycycle", "floater_edit_ext_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9f25890917..6bc28ad284 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8476,22 +8476,20 @@ class LLWorldEnvPreset : public view_listener_t if (item == "new_water") { - //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_fixed_environmentent_water", "edit"); } else if (item == "new_sky") { - LLFloaterReg::showInstance("env_edit_sky", "new"); - } + LLFloaterReg::showInstance("env_fixed_environmentent_sky", "new"); + } else if (item == "edit_sky") { - LLFloaterReg::showInstance("env_edit_sky", "edit"); - } + LLFloaterReg::showInstance("env_fixed_environmentent_sky", "edit"); + } else if (item == "new_day_cycle") { LLFloaterReg::showInstance("env_edit_day_cycle", "new"); diff --git a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml index 03bbc05dad..2590bb3410 100644 --- a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml +++ b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml @@ -26,7 +26,6 @@ - + + + + + + + + + + + Ambient Color: + + + + Blue Horizon: + + + + Blue Density: + + + + + + + + Haze Horizon: + + + + Haze Density: + + + + Scene Gamma: + + + + + + Density Multiplier: + + + + Distance Multiplier: + + + + Maximum Altitude: + + + + + + + \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml new file mode 100644 index 0000000000..2a52f1a96e --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml @@ -0,0 +1,255 @@ + + + + + + Cloud Color: + + + + Cloud Coverage: + + + + Cloud Scale: + + + + Cloud Scroll: + + + + placeholder + + + + + + Cloud Image: + + + + + + Cloud Density: + + + + + + Cloud Detail: + + + + + + + \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml new file mode 100644 index 0000000000..c0bd123fbc --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml @@ -0,0 +1,234 @@ + + + + + + Sun Color: + + + + Glow Focus: + + + + Glow Size: + + + + Star Brightness: + + + + + + + + Sun + + + Position: + + + + Image: + + + + + + Moon + + + Position: + + + + Image: + + + + + + + -- cgit v1.2.3 From 3e33fc9130cdd5dc63cc6cc7b9f0e38b6e552f12 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 3 May 2018 14:59:29 -0700 Subject: Inventory context menus and increment attrib for settings panels. --- indra/newview/llenvironment.cpp | 15 ++++++++-- indra/newview/llenvironment.h | 2 ++ indra/newview/llinventorybridge.cpp | 10 +++++++ indra/newview/llviewerinventory.cpp | 35 ++++++++++++++++++++++ .../skins/default/xui/en/menu_inventory.xml | 29 ++++++++++++++++++ .../skins/default/xui/en/menu_inventory_add.xml | 29 ++++++++++++++++++ .../default/xui/en/panel_settings_sky_atmos.xml | 6 ++++ .../default/xui/en/panel_settings_sky_clouds.xml | 10 +++++++ .../default/xui/en/panel_settings_sky_sunmoon.xml | 3 ++ .../skins/default/xui/en/panel_settings_water.xml | 9 ++++++ indra/newview/skins/default/xui/en/strings.xml | 5 ++++ 11 files changed, 151 insertions(+), 2 deletions(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 50f3f4f979..ad4a1fca6a 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -135,6 +135,17 @@ bool LLEnvironment::canEdit() const return true; } +bool LLEnvironment::isExtendedEnvironmentEnabled() const +{ + return !gAgent.getRegionCapability("ExtEnvironment").empty(); +} + +bool LLEnvironment::isInventoryEnabled() const +{ + return (!gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty() && + !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty()); +} + LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb) { @@ -759,7 +770,7 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI //========================================================================= void LLEnvironment::requestRegion() { - if (gAgent.getRegionCapability("ExtEnvironment").empty()) + if (!isExtendedEnvironmentEnabled()) { LLEnvironmentRequest::initiate(); return; @@ -770,7 +781,7 @@ void LLEnvironment::requestRegion() void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) { - if (gAgent.getRegionCapability("ExtEnvironment").empty()) + if (!isExtendedEnvironmentEnabled()) { LLEnvironmentApply::initiateRequest( LLSettingsVODay::convertToLegacy(pday) ); return; diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index cb6cd11608..d8cb61d0bb 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -134,6 +134,8 @@ public: const UserPrefs & getPreferences() const { return mUserPrefs; } bool canEdit() const; + bool isExtendedEnvironmentEnabled() const; + bool isInventoryEnabled() const; LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentEnvironment->getSky(); } LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentEnvironment->getWater(); } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index fbc35e9192..9311861d83 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -82,6 +82,8 @@ #include "lllandmarkactions.h" #include "llpanellandmarks.h" +#include "llenvironment.h" + #include void copy_slurl_to_clipboard_callback_inv(const std::string& slurl); @@ -4029,10 +4031,18 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items items.push_back(std::string("New Gesture")); items.push_back(std::string("New Clothes")); items.push_back(std::string("New Body Parts")); + items.push_back(std::string("New Settings")); items.push_back(std::string("upload_def")); + + if (!LLEnvironment::instance().isInventoryEnabled()) + { + disabled_items.push_back("New Settings"); + } + } } getClipboardEntries(false, items, disabled_items, flags); + } else { diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index f5c08a4b0f..8665fb3234 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -70,6 +70,7 @@ #include "llfloaterperms.h" #include "llclipboard.h" #include "llhttpretrypolicy.h" +#include "llsettingsvo.h" // do-nothing ops for use in callbacks. void no_op_inventory_func(const LLUUID&) {} @@ -1820,6 +1821,40 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, LLInventoryType::IT_GESTURE, PERM_ALL); // overridden in create_new_item } + else if (("sky" == type_name) || ("water" == type_name) || ("daycycle" == type_name)) + { + LL_WARNS("LAPRAS") << "Creating settings object of type: '" << type_name << "'" << LL_ENDL; + + LLSettingsBase::ptr_t settings; + std::string name; + + if ("sky" == type_name) + { + settings = LLSettingsVOSky::buildDefaultSky(); + name = LLTrans::getString("New Sky"); + } + else if ("water" == type_name) + { + settings = LLSettingsVOWater::buildDefaultWater(); + name = LLTrans::getString("New Water"); + } + else if ("daycycle" == type_name) + { + settings = LLSettingsVODay::buildDefaultDayCycle(); + name = LLTrans::getString("New Daycycle"); + } + else + LL_ERRS(LOG_INV) << "Unknown settings type: '" << type_name << "'" << LL_ENDL; + + if (!settings) + { + LL_WARNS(LOG_INV) << "Unable to create a default setting object of type '" << type_name << "'" << LL_ENDL; + return; + } + + settings->setName(name); + LLSettingsVOBase::createInventoryItem(settings); + } else { // Use for all clothing and body parts. Adding new wearable types requires updating LLWearableDictionary. diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml index 5b45364127..29915788f1 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory.xml @@ -321,6 +321,35 @@ parameter="eyes" /> + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml index 643994b6b1..ffa7df209b 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml @@ -113,6 +113,7 @@ decimal_digits="2" follows="left|top" height="10" + increment="0.01" initial_value="0" layout="topleft" left_delta="5" @@ -134,6 +135,7 @@ decimal_digits="2" follows="left|top" height="10" + increment="0.01" initial_value="0" layout="topleft" left_delta="5" @@ -155,6 +157,7 @@ decimal_digits="2" follows="left|top" height="10" + increment="0.01" initial_value="0" layout="topleft" left_delta="5" @@ -183,6 +186,7 @@ decimal_digits="2" follows="left|top" height="10" + increment="0.01" initial_value="0" layout="topleft" left_delta="5" @@ -204,6 +208,7 @@ decimal_digits="2" follows="left|top" height="10" + increment="0.01" initial_value="0" layout="topleft" left_delta="5" @@ -225,6 +230,7 @@ decimal_digits="1" follows="left|top" height="10" + increment="0.01" initial_value="0" layout="topleft" left_delta="5" diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml index 2a52f1a96e..b88ac64323 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml @@ -54,6 +54,7 @@ decimal_digits="2" follows="left|top" height="10" + increment="0.01" initial_value="0" layout="topleft" left_delta="5" @@ -75,6 +76,7 @@ decimal_digits="2" follows="left|top" height="10" + increment="0.01" initial_value="0" layout="topleft" left_delta="5" @@ -107,6 +109,7 @@ Female - Shrug Female - Stick tongue out Female - Wow + + New Daycycle + New Water + New Sky + /bow /clap -- cgit v1.2.3 From c238fa3ac5a3f93dcbf95e3cf7a7f8b576ab751c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 8 May 2018 16:57:14 -0700 Subject: Add save/update functionality hooks to fixed editor. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llenvironment.cpp | 35 + indra/newview/llenvironment.h | 1 + indra/newview/llfloaterfixedenvironment.cpp | 765 ++------------ indra/newview/llfloaterfixedenvironment.h | 84 +- indra/newview/llflyoutcombobtn.cpp | 127 +++ indra/newview/llflyoutcombobtn.h | 71 ++ .../default/xui/en/floater_fixedenvironment.xml | 86 +- .../skins/default/xui/en/menu_save_settings.xml | 43 + .../skins/default/xui/en/panel_outfit_edit.xml | 1048 ++++++++++---------- 10 files changed, 964 insertions(+), 1298 deletions(-) create mode 100644 indra/newview/llflyoutcombobtn.cpp create mode 100644 indra/newview/llflyoutcombobtn.h create mode 100644 indra/newview/skins/default/xui/en/menu_save_settings.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 654487b8fb..1a08bb6d74 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -320,6 +320,7 @@ set(viewer_SOURCE_FILES llfolderviewmodelinventory.cpp llfollowcam.cpp llfriendcard.cpp + llflyoutcombobtn.cpp llgesturelistener.cpp llgesturemgr.cpp llgiveinventory.cpp @@ -941,6 +942,7 @@ set(viewer_HEADER_FILES llfolderviewmodelinventory.h llfollowcam.h llfriendcard.h + llflyoutcombobtn.h llgesturelistener.h llgesturemgr.h llgiveinventory.h diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ad4a1fca6a..98da6ea22f 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -277,6 +277,41 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm /*TODO: readjust environment*/ } +void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsBase::ptr_t &settings) +{ + DayInstance::ptr_t environment = getEnvironmentInstance(env); + + if (settings->getSettingType() == "daycycle") + { + S64Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); + S64Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET); + if (environment) + { + daylength = environment->getDayLength(); + dayoffset = environment->getDayOffset(); + } + setEnvironment(env, std::static_pointer_cast(settings), daylength, dayoffset); + } + else if (settings->getSettingType() == "sky") + { + fixedEnvironment_t fixedenv(std::static_pointer_cast(settings), LLSettingsWater::ptr_t()); + if (environment) + { + fixedenv.second = environment->getWater(); + } + setEnvironment(env, fixedenv); + } + else if (settings->getSettingType() == "water") + { + fixedEnvironment_t fixedenv(LLSettingsSky::ptr_t(), std::static_pointer_cast(settings)); + if (environment) + { + fixedenv.first = environment->getSky(); + } + setEnvironment(env, fixedenv); + } +} + void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) { diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index d8cb61d0bb..ad7d93c3c8 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -151,6 +151,7 @@ public: bool hasEnvironment(EnvSelection_t env); void setEnvironment(EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset); void setEnvironment(EnvSelection_t env, fixedEnvironment_t fixed); + void setEnvironment(EnvSelection_t env, const LLSettingsBase::ptr_t &fixed); void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); } void setEnvironment(EnvSelection_t env, const LLSettingsWater::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(LLSettingsSky::ptr_t(), fixed)); } void clearEnvironment(EnvSelection_t env); diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index ec8e2c8965..f95e41408f 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -60,11 +60,23 @@ namespace const std::string BUTTON_NAME_IMPORT("btn_import"); const std::string BUTTON_NAME_COMMIT("btn_commit"); const std::string BUTTON_NAME_CANCEL("btn_cancel"); + + const std::string ACTION_SAVE("save_settings"); + const std::string ACTION_SAVEAS("save_as_new_settings"); + const std::string ACTION_APPLY_LOCAL("apply_local"); + const std::string ACTION_APPLY_PARCEL("apply_parcel"); + const std::string ACTION_APPLY_REGION("apply_region"); } LLFloaterFixedEnvironment::LLFloaterFixedEnvironment(const LLSD &key) : - LLFloater(key) + LLFloater(key), + mFlyoutControl(nullptr) +{ +} + +LLFloaterFixedEnvironment::~LLFloaterFixedEnvironment() { + delete mFlyoutControl; } BOOL LLFloaterFixedEnvironment::postBuild() @@ -77,9 +89,11 @@ BOOL LLFloaterFixedEnvironment::postBuild() getChild(BUTTON_NAME_LOAD)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonLoad(); }); getChild(BUTTON_NAME_IMPORT)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonImport(); }); - getChild(BUTTON_NAME_COMMIT)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonApply(); }); getChild(BUTTON_NAME_CANCEL)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonCancel(); }); + mFlyoutControl = new LLFlyoutComboBtn(this, "btn_commit", "btn_flyout", "menu_save_settings.xml"); + mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); + return TRUE; } @@ -107,8 +121,10 @@ void LLFloaterFixedEnvironment::refresh() bool enableApplyAndLoad = canUseInventory(); + mFlyoutControl->setMenuItemEnabled(ACTION_SAVE, enableApplyAndLoad); + mFlyoutControl->setMenuItemEnabled(ACTION_SAVEAS, enableApplyAndLoad); + getChild(BUTTON_NAME_LOAD)->setEnabled(enableApplyAndLoad); - getChild(BUTTON_NAME_COMMIT)->setEnabled(enableApplyAndLoad); mTxtName->setValue(mSettings->getName()); @@ -149,9 +165,28 @@ void LLFloaterFixedEnvironment::onButtonImport() doImportFromDisk(); } -void LLFloaterFixedEnvironment::onButtonApply() +void LLFloaterFixedEnvironment::onButtonApply(LLUICtrl *ctrl, const LLSD &data) { - doApplyFixedSettings(); + std::string ctrl_action = ctrl->getName(); + + if (ctrl_action == ACTION_SAVE) + { + doApplyCreateNewInventory(); + } + else if (ctrl_action == ACTION_SAVEAS) + { + doApplyUpdateInventory(); + } + else if ((ctrl_action == ACTION_APPLY_LOCAL) || + (ctrl_action == ACTION_APPLY_PARCEL) || + (ctrl_action == ACTION_APPLY_REGION)) + { + doApplyEnvironment(ctrl_action); + } + else + { + LL_WARNS("ENVIRONMENT") << "Unknown settings action '" << ctrl_action << "'" << LL_ENDL; + } } void LLFloaterFixedEnvironment::onButtonCancel() @@ -160,12 +195,57 @@ void LLFloaterFixedEnvironment::onButtonCancel() this->closeFloater(); } +void LLFloaterFixedEnvironment::doApplyCreateNewInventory() +{ + // This method knows what sort of settings object to create. + LLSettingsVOBase::createInventoryItem(mSettings); +} + +void LLFloaterFixedEnvironment::doApplyUpdateInventory() +{ + // todo update existing inventory object. +} + +void LLFloaterFixedEnvironment::doApplyEnvironment(const std::string &where) +{ + LLEnvironment::EnvSelection_t env(LLEnvironment::ENV_DEFAULT); + bool updateSimulator( where != ACTION_APPLY_LOCAL ); + + if (where == ACTION_APPLY_LOCAL) + env = LLEnvironment::ENV_LOCAL; + else if (where == ACTION_APPLY_PARCEL) + env = LLEnvironment::ENV_PARCEL; + else if (where == ACTION_APPLY_REGION) + env = LLEnvironment::ENV_REGION; + else + { + LL_WARNS("ENVIRONMENT") << "Unknown apply '" << where << "'" << LL_ENDL; + return; + } + + LLEnvironment::instance().setEnvironment(env, mSettings); + if (updateSimulator) + { + LL_WARNS("ENVIRONMENT") << "Attempting apply" << LL_ENDL; + } +} + //------------------------------------------------------------------------- bool LLFloaterFixedEnvironment::canUseInventory() const { return !gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty(); } +bool LLFloaterFixedEnvironment::canApplyRegion() const +{ + return true; +} + +bool LLFloaterFixedEnvironment::canApplyParcel() const +{ + return false; +} + //========================================================================= LLFloaterFixedEnvironmentWater::LLFloaterFixedEnvironmentWater(const LLSD &key): LLFloaterFixedEnvironment(key) @@ -241,12 +321,6 @@ void LLFloaterFixedEnvironmentWater::doImportFromDisk() } } -void LLFloaterFixedEnvironmentWater::doApplyFixedSettings() -{ - LLSettingsVOBase::createInventoryItem(mSettings); - -} - //========================================================================= LLFloaterFixedEnvironmentSky::LLFloaterFixedEnvironmentSky(const LLSD &key) : LLFloaterFixedEnvironment(key) @@ -332,674 +406,5 @@ void LLFloaterFixedEnvironmentSky::doImportFromDisk() } } -void LLFloaterFixedEnvironmentSky::doApplyFixedSettings() -{ - LLSettingsVOBase::createInventoryItem(mSettings); -} - //========================================================================= -#if 0 -// virtual -BOOL LLFloaterEditSky::postBuild() -{ - mSkyPresetNameEditor = getChild("sky_preset_name"); - mSkyPresetCombo = getChild("sky_preset_combo"); - mMakeDefaultCheckBox = getChild("make_default_cb"); - mSaveButton = getChild("save"); - mSkyAdapter = boost::make_shared(); - - LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); - - initCallbacks(); - -// // Create the sun position scrubber on the slider. -// getChild("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("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("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); - - // Connect to region info updates. - LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditSky::onRegionInfoUpdate, this)); - - //------------------------------------------------------------------------- -// LEGACY_ATMOSPHERICS - // ambient - getChild("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mAmbient)); - - // blue horizon/density - getChild("WLBlueHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mBlueHorizon)); - getChild("WLBlueDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mBlueDensity)); - - // haze density, horizon, mult, and altitude - getChild("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mHazeDensity)); - getChild("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mHazeHorizon)); - getChild("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mDensityMult)); - getChild("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mDistanceMult)); - getChild("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mMaxAlt)); - - // sunlight - getChild("WLSunlight")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mSunlight)); - - // glow - getChild("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowRMoved, this, _1, &mSkyAdapter->mGlow)); - getChild("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterEditSky::onGlowBMoved, this, _1, &mSkyAdapter->mGlow)); - - // time of day -// getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider -// getChild("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl -// getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); - getChild("WLSunRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunRotationChanged, this)); - getChild("WLMoonRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onMoonRotationChanged, this)); - - // Clouds - - // Cloud Color - getChild("WLCloudColor")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mCloudColor)); - - // Cloud - getChild("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, &mSkyAdapter->mCloudMain)); - getChild("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, &mSkyAdapter->mCloudMain)); - getChild("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, &mSkyAdapter->mCloudMain)); - - // Cloud Detail - getChild("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlRMoved, this, _1, &mSkyAdapter->mCloudDetail)); - getChild("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlGMoved, this, _1, &mSkyAdapter->mCloudDetail)); - getChild("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlBMoved, this, _1, &mSkyAdapter->mCloudDetail)); - - // Cloud extras - getChild("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mCloudCoverage)); - getChild("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mCloudScale)); - getChild("WLCloudScrollX")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollXMoved, this, _1)); - getChild("WLCloudScrollY")->setCommitCallback(boost::bind(&LLFloaterEditSky::onCloudScrollYMoved, this, _1)); - - - // Dome - getChild("WLGamma")->setCommitCallback(boost::bind(&LLFloaterEditSky::onFloatControlMoved, this, _1, &mSkyAdapter->mWLGamma)); - getChild("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("WLSunPos")->setCurSliderValue(time24, TRUE); -// getChild("WLDayTime")->setTime24(time24); -// childSetValue("WLEastAngle", azal.first / F_TWO_PI); - getChild("WLSunRotation")->setRotation(psky->getSunRotation()); - getChild("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 first. - LLColor4 color = from_ctrl.getColor4(); - getChild(name)->set(color / k); -} - -// color control callbacks -void LLFloaterEditSky::onColorControlMoved(LLUICtrl* ctrl, WLColorControl* color_ctrl) -{ - LLColorSwatchCtrl* swatch = static_cast(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(ctrl); - WLColorControl* color_ctrl = static_cast(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(ctrl); - WLColorControl* color_ctrl = static_cast(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(ctrl); - WLColorControl* color_ctrl = static_cast(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(ctrl); - WLColorControl* color_ctrl = static_cast(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(ctrl); - WLColorControl* color_ctrl = static_cast(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(ctrl); - WLFloatControl * floatControl = static_cast(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("WLSunPos"); - LLSliderCtrl* east_sldr = getChild("WLEastAngle"); - LLTimeCtrl* time_ctrl = getChild("WLDayTime"); - WLColorControl* color_ctrl = static_cast(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("WLDayTime")->getTime24(); - getChild("WLSunPos")->setCurSliderValue(time24, TRUE); - onSunMoved(getChild("WLSunPos"), &(mSkyAdapter->mLightnorm)); -} - -void LLFloaterEditSky::onSunRotationChanged() -{ - LLJoystickQuaternion* sun_spinner = getChild("WLSunRotation"); - LLQuaternion sunrot(sun_spinner->getRotation()); - - mEditSettings->setSunRotation(sunrot); -} - -void LLFloaterEditSky::onMoonRotationChanged() -{ - LLJoystickQuaternion* moon_spinner = getChild("WLMoonRotation"); - LLQuaternion moonrot(moon_spinner->getRotation()); - - mEditSettings->setMoonRotation(moonrot); -} - -void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast(ctrl); - - mEditSettings->setStarBrightness(sldr_ctrl->getValueF32()); -} - -// Clouds -void LLFloaterEditSky::onCloudScrollXMoved(LLUICtrl* ctrl) -{ - LLSliderCtrl* sldr_ctrl = static_cast(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(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("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 index 590be08169..22ce167244 100644 --- a/indra/newview/llfloaterfixedenvironment.h +++ b/indra/newview/llfloaterfixedenvironment.h @@ -29,6 +29,7 @@ #include "llfloater.h" #include "llsettingsbase.h" +#include "llflyoutcombobtn.h" class LLTabContainer; class LLButton; @@ -43,6 +44,7 @@ class LLFloaterFixedEnvironment : public LLFloater public: LLFloaterFixedEnvironment(const LLSD &key); + ~LLFloaterFixedEnvironment(); virtual BOOL postBuild() override; @@ -65,88 +67,24 @@ protected: virtual void doLoadFromInventory() = 0; virtual void doImportFromDisk() = 0; - virtual void doApplyFixedSettings() = 0; + virtual void doApplyCreateNewInventory(); + virtual void doApplyUpdateInventory(); + virtual void doApplyEnvironment(const std::string &where); bool canUseInventory() const; + bool canApplyRegion() const; + bool canApplyParcel() const; + + LLFlyoutComboBtn * mFlyoutControl; private: void onNameChanged(const std::string &name); void onButtonLoad(); void onButtonImport(); - void onButtonApply(); + void onButtonApply(LLUICtrl *ctrl, const LLSD &data); void onButtonCancel(); -#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 @@ -166,7 +104,6 @@ protected: virtual void doLoadFromInventory() override; virtual void doImportFromDisk() override; - virtual void doApplyFixedSettings() override; private: }; @@ -188,7 +125,6 @@ protected: virtual void doLoadFromInventory() override; virtual void doImportFromDisk() override; - virtual void doApplyFixedSettings() override; private: }; diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp new file mode 100644 index 0000000000..efe76b5653 --- /dev/null +++ b/indra/newview/llflyoutcombobtn.cpp @@ -0,0 +1,127 @@ +/** + * @file llsaveoutfitcombobtn.cpp + * @brief Represents outfit save/save as combo button. + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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 "llflyoutcombobtn.h" +#include "llviewermenu.h" + +LLFlyoutComboBtn::LLFlyoutComboBtn(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file) : + mParent(parent), + mActionButton(action_button), + mFlyoutButton(flyout_button) +{ + // register action mapping before creating menu + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar save_registar; + save_registar.add("FlyoutCombo.Button.Action", [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutItemSelected(ctrl, data); }); + + mParent->childSetAction(flyout_button, [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutButton(ctrl, data); }); + mParent->childSetAction(action_button, [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutAction(ctrl, data); }); + + mFlyoutMenu = LLUICtrlFactory::getInstance()->createFromFile (menu_file, gMenuHolder, + LLViewerMenuHolderGL::child_registry_t::instance()); + + // select the first item in the list. + setSelectedItem(0); +} + +void LLFlyoutComboBtn::setAction(LLUICtrl::commit_callback_t cb) +{ + mActionSignal.connect(cb); +} + + +U32 LLFlyoutComboBtn::getItemCount() +{ + return mFlyoutMenu->getItemCount(); +} + +void LLFlyoutComboBtn::setSelectedItem(S32 itemno) +{ + LLMenuItemGL *pitem = mFlyoutMenu->getItem(itemno); + setSelectedItem(pitem); +} + +void LLFlyoutComboBtn::setSelectedItem(const std::string &item) +{ + LLMenuItemGL *pitem = mFlyoutMenu->getChild(item, false); + setSelectedItem(pitem); +} + +void LLFlyoutComboBtn::setSelectedItem(LLMenuItemGL *pitem) +{ + if (!pitem) + { + LL_WARNS("INTERFACE") << "NULL item selected" << LL_ENDL; + return; + } + + mSelectedName = pitem->getName(); + + LLButton *action_button = mParent->getChild(mActionButton); + action_button->setEnabled(pitem->getEnabled()); + action_button->setLabel(pitem->getLabel()); +} + +void LLFlyoutComboBtn::setMenuItemEnabled(const std::string& item, bool enabled) +{ + mFlyoutMenu->setItemEnabled(item, enabled); + if (item == mSelectedName) + { + mParent->getChildView(mActionButton)->setEnabled(enabled); + } +} + +void LLFlyoutComboBtn::setShownBtnEnabled(bool enabled) +{ + mParent->getChildView(mActionButton)->setEnabled(enabled); +} + +void LLFlyoutComboBtn::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) +{ + S32 x, y; + LLUI::getMousePositionLocal(mParent, &x, &y); + + mFlyoutMenu->updateParent(LLMenuGL::sMenuContainer); + LLMenuGL::showPopup(mParent, mFlyoutMenu, x, y); +} + +void LLFlyoutComboBtn::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) +{ + LLMenuItemGL *pmenuitem = static_cast(ctrl); + setSelectedItem(pmenuitem); + + onFlyoutAction(pmenuitem, data); +} + +void LLFlyoutComboBtn::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data) +{ + LLMenuItemGL *pmenuitem = mFlyoutMenu->getChild(mSelectedName); + + if (!mActionSignal.empty()) + mActionSignal(pmenuitem, data); +} + diff --git a/indra/newview/llflyoutcombobtn.h b/indra/newview/llflyoutcombobtn.h new file mode 100644 index 0000000000..ebf7564422 --- /dev/null +++ b/indra/newview/llflyoutcombobtn.h @@ -0,0 +1,71 @@ +/** + * @file llsaveoutfitcombobtn.h + * @brief Represents outfit save/save as combo button. + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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_LLSAVECOMBOBTN_H +#define LL_LLSAVECOMBOBTN_H + +/*TODO: Make this button generic */ + +class LLButton; + +#include "lltoggleablemenu.h" + +/** + * Represents outfit Save/Save As combo button. + */ +class LLFlyoutComboBtn +{ + LOG_CLASS(LLFlyoutComboBtn); +public: + LLFlyoutComboBtn(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file); + + void setMenuItemEnabled(const std::string &item, bool enabled); + void setShownBtnEnabled(bool enabled); + + U32 getItemCount(); + void setSelectedItem(S32 itemno); + void setSelectedItem(const std::string &item); + + void setAction(LLUICtrl::commit_callback_t cb); + +protected: + void onFlyoutButton(LLUICtrl *, const LLSD &); + void onFlyoutItemSelected(LLUICtrl *, const LLSD &); + void onFlyoutAction(LLUICtrl *, const LLSD &); + + void setSelectedItem(LLMenuItemGL *pitem); + +private: + LLPanel * mParent; + LLToggleableMenu * mFlyoutMenu; + std::string mActionButton; + std::string mFlyoutButton; + + std::string mSelectedName; + + LLUICtrl::commit_signal_t mActionSignal; +}; +#endif // LL_LLSAVEOUTFITCOMBOBTN_H diff --git a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml index 2590bb3410..38ce131dc2 100644 --- a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml +++ b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml @@ -34,7 +34,7 @@ width="35" height="20" font="SansSerif"> - Name: + Name: - + @@ -93,25 +93,71 @@ user_resize="false" height="40" visible="true"> -