From ec749bb1c1fa143c6019791d6713d85f05510e53 Mon Sep 17 00:00:00 2001 From: Seth ProductEngine Date: Tue, 17 May 2011 17:09:15 +0300 Subject: STORM-1244 FIXED Environment Settings floater implementation. --- indra/newview/llfloaterenvironmentsettings.cpp | 209 +++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 indra/newview/llfloaterenvironmentsettings.cpp (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp new file mode 100644 index 0000000000..cbbbed9830 --- /dev/null +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -0,0 +1,209 @@ +/** + * @file llfloaterenvironmentsettings.cpp + * @brief LLFloaterEnvironmentSettings class definition + * + * $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 "llfloaterenvironmentsettings.h" + +#include "llcombobox.h" +#include "llradiogroup.h" + +#include "llenvmanager.h" +#include "llwaterparammanager.h" +#include "llwlparamset.h" +#include "llwlparammanager.h" + +LLFloaterEnvironmentSettings::LLFloaterEnvironmentSettings(const LLSD &key) +: LLFloater(key) + ,mRegionSettingsRadioGroup(NULL) + ,mDayCycleSettingsRadioGroup(NULL) + ,mWaterPresetCombo(NULL) + ,mSkyPresetCombo(NULL) + ,mDayCyclePresetCombo(NULL) +{ +} + +LLFloaterEnvironmentSettings::~LLFloaterEnvironmentSettings() +{ +} + +// virtual +BOOL LLFloaterEnvironmentSettings::postBuild() +{ + mRegionSettingsRadioGroup = getChild("region_settings_radio_group"); + mRegionSettingsRadioGroup->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSwitchRegionSettings, this)); + + mDayCycleSettingsRadioGroup = getChild("sky_dayc_settings_radio_group"); + mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSwitchDayCycle, this)); + + mWaterPresetCombo = getChild("water_settings_preset_combo"); + mWaterPresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectWaterPreset, this)); + + mSkyPresetCombo = getChild("sky_settings_preset_combo"); + mSkyPresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectSkyPreset, this)); + + mDayCyclePresetCombo = getChild("dayc_settings_preset_combo"); + mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectDayCyclePreset, this)); + + childSetCommitCallback("ok_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnOK, this), NULL); + childSetCommitCallback("cancel_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnCancel, this), NULL); + + setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); + + return TRUE; +} + +// virtual +void LLFloaterEnvironmentSettings::onOpen(const LLSD& key) +{ + LLEnvManagerNew *env_mgr = LLEnvManagerNew::getInstance(); + + // Save UseRegionSettings and UseFixedSky settings to restore them + // in case of "Cancel" button has been pressed. + mUseRegionSettings = env_mgr->getUseRegionSettings(); + mUseFixedSky = env_mgr->getUseFixedSky(); + + mRegionSettingsRadioGroup->setSelectedIndex(mUseRegionSettings ? 0 : 1); + mDayCycleSettingsRadioGroup->setSelectedIndex(mUseFixedSky ? 0 : 1); + + // Update other controls state based on the selected radio buttons. + onSwitchRegionSettings(); + onSwitchDayCycle(); + + // Populate the combo boxes with appropriate lists of available presets. + populateWaterPresetsList(); + populateSkyPresetsList(); + populateDayCyclePresetsList(); + + // Save water, sky and day cycle presets to restore them + // in case of "Cancel" button has been pressed. + mWaterPreset = env_mgr->getWaterPresetName(); + mSkyPreset = env_mgr->getSkyPresetName(); + mDayCyclePreset = env_mgr->getDayCycleName(); + + // Select the current presets in combo boxes. + mWaterPresetCombo->selectByValue(mWaterPreset); + mSkyPresetCombo->selectByValue(mSkyPreset); + mDayCyclePresetCombo->selectByValue(mDayCyclePreset); + + mDirty = false; +} + +void LLFloaterEnvironmentSettings::onSwitchRegionSettings() +{ + getChild("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0); + + LLEnvManagerNew::getInstance()->setUseRegionSettings(mRegionSettingsRadioGroup->getSelectedIndex() == 0); + + mDirty = true; +} + +void LLFloaterEnvironmentSettings::onSwitchDayCycle() +{ + bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + + mSkyPresetCombo->setEnabled(is_fixed_sky); + mDayCyclePresetCombo->setEnabled(!is_fixed_sky); + + if (is_fixed_sky) + { + LLEnvManagerNew::getInstance()->setUseSkyPreset(mSkyPresetCombo->getValue().asString()); + } + else + { + LLEnvManagerNew::getInstance()->setUseDayCycle(mDayCyclePresetCombo->getValue().asString()); + } + + mDirty = true; +} + +void LLFloaterEnvironmentSettings::onSelectWaterPreset() +{ + LLEnvManagerNew::getInstance()->setUseWaterPreset(mWaterPresetCombo->getValue().asString()); + mDirty = true; +} + +void LLFloaterEnvironmentSettings::onSelectSkyPreset() +{ + LLEnvManagerNew::getInstance()->setUseSkyPreset(mSkyPresetCombo->getValue().asString()); + mDirty = true; +} + +void LLFloaterEnvironmentSettings::onSelectDayCyclePreset() +{ + LLEnvManagerNew::getInstance()->setUseDayCycle(mDayCyclePresetCombo->getValue().asString()); + mDirty = true; +} + +void LLFloaterEnvironmentSettings::onBtnOK() +{ + mDirty = false; + closeFloater(); +} + +void LLFloaterEnvironmentSettings::onBtnCancel() +{ + cancel(); + closeFloater(); +} + +void LLFloaterEnvironmentSettings::cancel() +{ + if (!mDirty) return; + + // Restore the saved user prefs + LLEnvManagerNew::getInstance()->setUserPrefs(mWaterPreset, mSkyPreset, mDayCyclePreset, mUseFixedSky, mUseRegionSettings); +} + +void LLFloaterEnvironmentSettings::populateWaterPresetsList() +{ + mWaterPresetCombo->removeall(); + + const std::map &water_params_map = LLWaterParamManager::getInstance()->mParamList; + for (std::map::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + { + mWaterPresetCombo->add(it->first); + } +} + +void LLFloaterEnvironmentSettings::populateSkyPresetsList() +{ + mSkyPresetCombo->removeall(); + + const std::map &sky_params_map = LLWLParamManager::getInstance()->mParamList; + for (std::map::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + { + mSkyPresetCombo->add(it->first.name); + } +} + +void LLFloaterEnvironmentSettings::populateDayCyclePresetsList() +{ + mDayCyclePresetCombo->removeall(); + + std::string day_cycle_name = LLEnvManagerNew::getInstance()->getDayCycleName(); + mDayCyclePresetCombo->add(day_cycle_name); +} -- cgit v1.2.3 From c32b19f31d4d5d0b32fcf64cce1cebd7d79b9b05 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 26 May 2011 15:11:01 +0300 Subject: STORM-1253 WIP Implemented switching between multiple day cycles (locally and region-wide). --- indra/newview/llfloaterenvironmentsettings.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index cbbbed9830..f097f70143 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -31,6 +31,7 @@ #include "llcombobox.h" #include "llradiogroup.h" +#include "lldaycyclemanager.h" #include "llenvmanager.h" #include "llwaterparammanager.h" #include "llwlparamset.h" @@ -204,6 +205,9 @@ void LLFloaterEnvironmentSettings::populateDayCyclePresetsList() { mDayCyclePresetCombo->removeall(); - std::string day_cycle_name = LLEnvManagerNew::getInstance()->getDayCycleName(); - mDayCyclePresetCombo->add(day_cycle_name); + const LLDayCycleManager::dc_map_t& map = LLDayCycleManager::instance().getPresets(); + for (LLDayCycleManager::dc_map_t::const_iterator it = map.begin(); it != map.end(); ++it) + { + mDayCyclePresetCombo->add(it->first); + } } -- cgit v1.2.3 From ebfbf2a561a98e5af4dde319edb49a663e27de26 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 26 May 2011 23:06:41 +0300 Subject: STORM-1285 WIP Connected "Delete Water / Sky / Day Cycle" floaters (not functional) to the main menu. --- indra/newview/llfloaterenvironmentsettings.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index f097f70143..2149103792 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -197,6 +197,7 @@ void LLFloaterEnvironmentSettings::populateSkyPresetsList() const std::map &sky_params_map = LLWLParamManager::getInstance()->mParamList; for (std::map::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) { + if (it->first.scope == LLEnvKey::SCOPE_REGION) continue; // list only local presets mSkyPresetCombo->add(it->first.name); } } -- cgit v1.2.3 From 48fe54012993c095e095ed73503922275574e595 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 30 May 2011 22:34:56 +0300 Subject: STORM-1253 WIP Fixed loading user day cycle on start-up; improved error handling. --- indra/newview/llfloaterenvironmentsettings.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 2149103792..9fb44521a2 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -70,6 +70,7 @@ BOOL LLFloaterEnvironmentSettings::postBuild() mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectDayCyclePreset, this)); childSetCommitCallback("ok_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnOK, this), NULL); + getChild("ok_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); childSetCommitCallback("cancel_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnCancel, this), NULL); setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); -- cgit v1.2.3 From 3a8521c38b17adb9d3006be0d7a23f94da7bcaea Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 30 May 2011 22:44:30 +0300 Subject: STORM-1244 WIP Minor bug fix in the Environment Settings floater. Populate combo boxes *before* accessing them. --- indra/newview/llfloaterenvironmentsettings.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 9fb44521a2..49f0161bdd 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -91,15 +91,15 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key) mRegionSettingsRadioGroup->setSelectedIndex(mUseRegionSettings ? 0 : 1); mDayCycleSettingsRadioGroup->setSelectedIndex(mUseFixedSky ? 0 : 1); - // Update other controls state based on the selected radio buttons. - onSwitchRegionSettings(); - onSwitchDayCycle(); - // Populate the combo boxes with appropriate lists of available presets. populateWaterPresetsList(); populateSkyPresetsList(); populateDayCyclePresetsList(); + // Update other controls state based on the selected radio buttons. + onSwitchRegionSettings(); + onSwitchDayCycle(); + // Save water, sky and day cycle presets to restore them // in case of "Cancel" button has been pressed. mWaterPreset = env_mgr->getWaterPresetName(); -- cgit v1.2.3 From 6d4198b89a3edf28e208391bbdde90a7a000d936 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 31 May 2011 23:03:59 +0300 Subject: STORM-1244 WIP Fixed modifying user preferences when the Environment Settings floater is opened. --- indra/newview/llfloaterenvironmentsettings.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 49f0161bdd..35163d6230 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -96,9 +96,10 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key) populateSkyPresetsList(); populateDayCyclePresetsList(); - // Update other controls state based on the selected radio buttons. - onSwitchRegionSettings(); - onSwitchDayCycle(); + // Enable/disable other controls based on user preferences. + getChild("user_environment_settings")->setEnabled(!mUseRegionSettings); + mSkyPresetCombo->setEnabled(mUseFixedSky); + mDayCyclePresetCombo->setEnabled(!mUseFixedSky); // Save water, sky and day cycle presets to restore them // in case of "Cancel" button has been pressed. -- cgit v1.2.3 From 995a006b58f2be1d7236b32be3570b6d7250013b Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Wed, 1 Jun 2011 18:26:36 +0300 Subject: STORM-1253 WIP Update UI when a day cycle gets added or deleted. --- indra/newview/llfloaterenvironmentsettings.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 35163d6230..7287a2beff 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -75,6 +75,8 @@ BOOL LLFloaterEnvironmentSettings::postBuild() setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); + LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::onDayCycleListChange, this)); + return TRUE; } @@ -161,6 +163,11 @@ void LLFloaterEnvironmentSettings::onSelectDayCyclePreset() mDirty = true; } +void LLFloaterEnvironmentSettings::onDayCycleListChange() +{ + populateDayCyclePresetsList(); +} + void LLFloaterEnvironmentSettings::onBtnOK() { mDirty = false; -- cgit v1.2.3 From dda7df4ac94d1e269aa0ce9eff6c6078f756cbd9 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 2 Jun 2011 18:35:23 +0300 Subject: STORM-1253 WIP Debugging stuff. --- indra/newview/llfloaterenvironmentsettings.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 7287a2beff..15dba80b61 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -72,6 +72,7 @@ BOOL LLFloaterEnvironmentSettings::postBuild() childSetCommitCallback("ok_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnOK, this), NULL); getChild("ok_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); childSetCommitCallback("cancel_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnCancel, this), NULL); + getChild("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); -- cgit v1.2.3 From 7151a4e6b02f02155387fc595034a42aebd7ec9c Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 7 Jun 2011 17:41:26 +0300 Subject: STORM-1255 WIP Consistency pass on sky presets removal. * Update all related floaters when a sky preset gets removed. * Don't allow removing skies referenced by (local) day cycles. * Other minor fixes. --- indra/newview/llfloaterenvironmentsettings.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 15dba80b61..0ec6d1c6c8 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -76,7 +76,8 @@ BOOL LLFloaterEnvironmentSettings::postBuild() setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::onDayCycleListChange, this)); + LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); + LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); return TRUE; } @@ -164,11 +165,6 @@ void LLFloaterEnvironmentSettings::onSelectDayCyclePreset() mDirty = true; } -void LLFloaterEnvironmentSettings::onDayCycleListChange() -{ - populateDayCyclePresetsList(); -} - void LLFloaterEnvironmentSettings::onBtnOK() { mDirty = false; -- cgit v1.2.3 From ebdb41e5d630cad91dab5372ffc0b4f461a85426 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 9 Jun 2011 18:48:24 +0300 Subject: STORM-1254 WIP Implemented deleting local water presets. --- indra/newview/llfloaterenvironmentsettings.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 0ec6d1c6c8..4517063460 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -78,6 +78,7 @@ BOOL LLFloaterEnvironmentSettings::postBuild() LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); + LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); return TRUE; } -- cgit v1.2.3 From 0d1cc56eb128755ce9e63d8cdf852b0e3b6f4fb1 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 10 Jun 2011 18:21:32 +0300 Subject: STORM-1279 FIXED Changing sky preset with a keyboard shortcut now updates the Environment Settings floater. Changes: * Subscribed the floater to the "settings changed" signal of the environment manager. * Rewrote the floater to not modify settings only when the Save button is pressed. * Refactoring to eliminate code duplication. --- indra/newview/llfloaterenvironmentsettings.cpp | 141 ++++++++++++++----------- 1 file changed, 80 insertions(+), 61 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 4517063460..23da78f99f 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -47,10 +47,6 @@ LLFloaterEnvironmentSettings::LLFloaterEnvironmentSettings(const LLSD &key) { } -LLFloaterEnvironmentSettings::~LLFloaterEnvironmentSettings() -{ -} - // virtual BOOL LLFloaterEnvironmentSettings::postBuild() { @@ -76,6 +72,7 @@ BOOL LLFloaterEnvironmentSettings::postBuild() setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this)); + LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this)); LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this)); LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this)); LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this)); @@ -86,47 +83,14 @@ BOOL LLFloaterEnvironmentSettings::postBuild() // virtual void LLFloaterEnvironmentSettings::onOpen(const LLSD& key) { - LLEnvManagerNew *env_mgr = LLEnvManagerNew::getInstance(); - - // Save UseRegionSettings and UseFixedSky settings to restore them - // in case of "Cancel" button has been pressed. - mUseRegionSettings = env_mgr->getUseRegionSettings(); - mUseFixedSky = env_mgr->getUseFixedSky(); - - mRegionSettingsRadioGroup->setSelectedIndex(mUseRegionSettings ? 0 : 1); - mDayCycleSettingsRadioGroup->setSelectedIndex(mUseFixedSky ? 0 : 1); - - // Populate the combo boxes with appropriate lists of available presets. - populateWaterPresetsList(); - populateSkyPresetsList(); - populateDayCyclePresetsList(); - - // Enable/disable other controls based on user preferences. - getChild("user_environment_settings")->setEnabled(!mUseRegionSettings); - mSkyPresetCombo->setEnabled(mUseFixedSky); - mDayCyclePresetCombo->setEnabled(!mUseFixedSky); - - // Save water, sky and day cycle presets to restore them - // in case of "Cancel" button has been pressed. - mWaterPreset = env_mgr->getWaterPresetName(); - mSkyPreset = env_mgr->getSkyPresetName(); - mDayCyclePreset = env_mgr->getDayCycleName(); - - // Select the current presets in combo boxes. - mWaterPresetCombo->selectByValue(mWaterPreset); - mSkyPresetCombo->selectByValue(mSkyPreset); - mDayCyclePresetCombo->selectByValue(mDayCyclePreset); - - mDirty = false; + refresh(); } void LLFloaterEnvironmentSettings::onSwitchRegionSettings() { getChild("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0); - LLEnvManagerNew::getInstance()->setUseRegionSettings(mRegionSettingsRadioGroup->getSelectedIndex() == 0); - - mDirty = true; + apply(); } void LLFloaterEnvironmentSettings::onSwitchDayCycle() @@ -136,54 +100,109 @@ void LLFloaterEnvironmentSettings::onSwitchDayCycle() mSkyPresetCombo->setEnabled(is_fixed_sky); mDayCyclePresetCombo->setEnabled(!is_fixed_sky); - if (is_fixed_sky) - { - LLEnvManagerNew::getInstance()->setUseSkyPreset(mSkyPresetCombo->getValue().asString()); - } - else - { - LLEnvManagerNew::getInstance()->setUseDayCycle(mDayCyclePresetCombo->getValue().asString()); - } - - mDirty = true; + apply(); } void LLFloaterEnvironmentSettings::onSelectWaterPreset() { - LLEnvManagerNew::getInstance()->setUseWaterPreset(mWaterPresetCombo->getValue().asString()); - mDirty = true; + apply(); } void LLFloaterEnvironmentSettings::onSelectSkyPreset() { - LLEnvManagerNew::getInstance()->setUseSkyPreset(mSkyPresetCombo->getValue().asString()); - mDirty = true; + apply(); } void LLFloaterEnvironmentSettings::onSelectDayCyclePreset() { - LLEnvManagerNew::getInstance()->setUseDayCycle(mDayCyclePresetCombo->getValue().asString()); - mDirty = true; + apply(); } void LLFloaterEnvironmentSettings::onBtnOK() { - mDirty = false; + // Save and apply new user preferences. + bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + std::string water_preset = mWaterPresetCombo->getValue().asString(); + std::string sky_preset = mSkyPresetCombo->getValue().asString(); + std::string day_cycle = mDayCyclePresetCombo->getValue().asString(); + + LLEnvManagerNew::instance().setUserPrefs( + water_preset, + sky_preset, + day_cycle, + use_fixed_sky, + use_region_settings); + + // *TODO: This triggers applying user preferences again, which is suboptimal. closeFloater(); } void LLFloaterEnvironmentSettings::onBtnCancel() { - cancel(); closeFloater(); } -void LLFloaterEnvironmentSettings::cancel() +void LLFloaterEnvironmentSettings::refresh() { - if (!mDirty) return; + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + + bool use_region_settings = env_mgr.getUseRegionSettings(); + bool use_fixed_sky = env_mgr.getUseFixedSky(); + + // Set up radio buttons according to user preferences. + mRegionSettingsRadioGroup->setSelectedIndex(use_region_settings ? 0 : 1); + mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); + + // Populate the combo boxes with appropriate lists of available presets. + populateWaterPresetsList(); + populateSkyPresetsList(); + populateDayCyclePresetsList(); + + // Enable/disable other controls based on user preferences. + getChild("user_environment_settings")->setEnabled(!use_region_settings); + mSkyPresetCombo->setEnabled(use_fixed_sky); + mDayCyclePresetCombo->setEnabled(!use_fixed_sky); - // Restore the saved user prefs - LLEnvManagerNew::getInstance()->setUserPrefs(mWaterPreset, mSkyPreset, mDayCyclePreset, mUseFixedSky, mUseRegionSettings); + // Select the current presets in combo boxes. + mWaterPresetCombo->selectByValue(env_mgr.getWaterPresetName()); + mSkyPresetCombo->selectByValue(env_mgr.getSkyPresetName()); + mDayCyclePresetCombo->selectByValue(env_mgr.getDayCycleName()); +} + +void LLFloaterEnvironmentSettings::apply() +{ + // Update environment with the user choice. + bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + std::string water_preset = mWaterPresetCombo->getValue().asString(); + std::string sky_preset = mSkyPresetCombo->getValue().asString(); + std::string day_cycle = mDayCyclePresetCombo->getValue().asString(); + + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + if (use_region_settings) + { + env_mgr.useRegionSettings(); + } + else + { + if (use_fixed_sky) + { + env_mgr.useSkyPreset(sky_preset); + } + else + { + env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL); + } + + env_mgr.useWaterPreset(water_preset); + } +} + +void LLFloaterEnvironmentSettings::cancel() +{ + // Revert environment to user preferences. + LLEnvManagerNew::instance().usePrefs(); } void LLFloaterEnvironmentSettings::populateWaterPresetsList() -- cgit v1.2.3 From 150c18169de8b7155658e676b86014716f62aeed Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 10 Jun 2011 19:55:30 +0300 Subject: STORM-1305 WIP Made LLWaterParamManager::mParamList private and typedef'ed its type. --- indra/newview/llfloaterenvironmentsettings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 23da78f99f..8f451d7620 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -209,8 +209,8 @@ void LLFloaterEnvironmentSettings::populateWaterPresetsList() { mWaterPresetCombo->removeall(); - const std::map &water_params_map = LLWaterParamManager::getInstance()->mParamList; - for (std::map::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + const LLWaterParamManager::preset_map_t &water_params_map = LLWaterParamManager::getInstance()->getPresets(); + for (LLWaterParamManager::preset_map_t::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) { mWaterPresetCombo->add(it->first); } -- cgit v1.2.3 From 23d8fb9750afc158d97fdf51633ed59b1b36f223 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 10 Jun 2011 21:21:04 +0300 Subject: STORM-1305 WIP User water presets now go first in all lists. Besides, removed all cases of direct access to the water presets map in preparation for future lazy loading. --- indra/newview/llfloaterenvironmentsettings.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 8f451d7620..66ca3334dd 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -209,10 +209,24 @@ void LLFloaterEnvironmentSettings::populateWaterPresetsList() { mWaterPresetCombo->removeall(); - const LLWaterParamManager::preset_map_t &water_params_map = LLWaterParamManager::getInstance()->getPresets(); - for (LLWaterParamManager::preset_map_t::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + std::list user_presets, system_presets; + LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + + // Add user presets first. + for (std::list::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mWaterPresetCombo->add(*it); + } + + if (user_presets.size() > 0) + { + mWaterPresetCombo->addSeparator(); + } + + // Add system presets. + for (std::list::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) { - mWaterPresetCombo->add(it->first); + mWaterPresetCombo->add(*it); } } -- cgit v1.2.3 From 4fd946fa3e5217b8f64e0fcd91d268c7eaf1bbf5 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 10 Jun 2011 23:44:13 +0300 Subject: STORM-1305 WIP User sky presets now go first in all lists. --- indra/newview/llfloaterenvironmentsettings.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index 66ca3334dd..e8d123a955 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -234,11 +234,25 @@ void LLFloaterEnvironmentSettings::populateSkyPresetsList() { mSkyPresetCombo->removeall(); - const std::map &sky_params_map = LLWLParamManager::getInstance()->mParamList; - for (std::map::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) + LLWLParamManager::preset_name_list_t region_presets; // unused as we don't list region presets here + LLWLParamManager::preset_name_list_t user_presets, sys_presets; + LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + + // Add user presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mSkyPresetCombo->add(*it); + } + + if (!user_presets.empty()) + { + mSkyPresetCombo->addSeparator(); + } + + // Add system presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) { - if (it->first.scope == LLEnvKey::SCOPE_REGION) continue; // list only local presets - mSkyPresetCombo->add(it->first.name); + mSkyPresetCombo->add(*it); } } -- cgit v1.2.3 From ab431d1774d5b282836a3327dd0bfa8b3b91632b Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Tue, 14 Jun 2011 18:04:29 +0300 Subject: STORM-1305 WIP User day cycles now go first in all lists. --- indra/newview/llfloaterenvironmentsettings.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index e8d123a955..4dbc8cdee0 100644 --- a/indra/newview/llfloaterenvironmentsettings.cpp +++ b/indra/newview/llfloaterenvironmentsettings.cpp @@ -260,9 +260,23 @@ void LLFloaterEnvironmentSettings::populateDayCyclePresetsList() { mDayCyclePresetCombo->removeall(); - const LLDayCycleManager::dc_map_t& map = LLDayCycleManager::instance().getPresets(); - for (LLDayCycleManager::dc_map_t::const_iterator it = map.begin(); it != map.end(); ++it) + LLDayCycleManager::preset_name_list_t user_days, sys_days; + LLDayCycleManager::instance().getPresetNames(user_days, sys_days); + + // Add user days. + for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) + { + mDayCyclePresetCombo->add(*it); + } + + if (user_days.size() > 0) + { + mDayCyclePresetCombo->addSeparator(); + } + + // Add system days. + for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) { - mDayCyclePresetCombo->add(it->first); + mDayCyclePresetCombo->add(*it); } } -- cgit v1.2.3