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/CMakeLists.txt | 2 + indra/newview/llenvmanager.cpp | 20 ++ indra/newview/llenvmanager.h | 6 + indra/newview/llfloaterenvironmentsettings.cpp | 209 +++++++++++++++++++++ indra/newview/llfloaterenvironmentsettings.h | 78 ++++++++ indra/newview/llviewerfloaterreg.cpp | 4 +- indra/newview/llviewermenu.cpp | 42 +---- indra/newview/llwlparammanager.cpp | 2 +- .../xui/en/floater_environment_settings.xml | 131 +++++++------ indra/newview/skins/default/xui/en/menu_viewer.xml | 32 +--- 10 files changed, 398 insertions(+), 128 deletions(-) create mode 100644 indra/newview/llfloaterenvironmentsettings.cpp create mode 100644 indra/newview/llfloaterenvironmentsettings.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 45bb07acfa..81caf9fbd4 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -175,6 +175,7 @@ set(viewer_SOURCE_FILES llfloaterdaycycle.cpp llfloaterdisplayname.cpp llfloaterenvsettings.cpp + llfloaterenvironmentsettings.cpp llfloaterevent.cpp llfloaterfonttest.cpp llfloatergesture.cpp @@ -722,6 +723,7 @@ set(viewer_HEADER_FILES llfloaterdaycycle.h llfloaterdisplayname.h llfloaterenvsettings.h + llfloaterenvironmentsettings.h llfloaterevent.h llfloaterfonttest.h llfloatergesture.h diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index dfec6c4b9d..bc1e0f8b14 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -82,6 +82,7 @@ void LLEnvManager::changedRegion(bool interp) mInterpNextChangeMessage = interp; mPendingOutgoingMessage = false; + LLFloaterReg::hideInstance("old_env_settings"); LLFloaterReg::hideInstance("env_settings"); resetInternalsToDefault(LLEnvKey::SCOPE_REGION); @@ -733,6 +734,25 @@ void LLEnvManagerNew::saveUserPrefs() gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle()); } +void LLEnvManagerNew::setUserPrefs( + const std::string& water_preset, + const std::string& sky_preset, + const std::string& day_cycle_preset, + bool use_fixed_sky, + bool use_region_settings) +{ + // operate on members directly to avoid side effects + mUserPrefs.mWaterPresetName = water_preset; + mUserPrefs.mSkyPresetName = sky_preset; + mUserPrefs.mDayCycleName = day_cycle_preset; + + mUserPrefs.mUseDefaults = use_region_settings; + mUserPrefs.mUseDayCycle = !use_fixed_sky; + + saveUserPrefs(); + updateManagersFromPrefs(false); +} + void LLEnvManagerNew::dumpUserPrefs() { LL_DEBUGS("Windlight") << "WaterPresetName: " << gSavedSettings.getString("WaterPresetName") << LL_ENDL; diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index b871ebc06f..1f005ecce2 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -276,6 +276,12 @@ public: void loadUserPrefs(); void saveUserPrefs(); + void setUserPrefs( + const std::string& water_preset, + const std::string& sky_preset, + const std::string& day_cycle_preset, + bool use_fixed_sky, + bool use_region_settings); void dumpUserPrefs(); void onRegionCrossing(); 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); +} diff --git a/indra/newview/llfloaterenvironmentsettings.h b/indra/newview/llfloaterenvironmentsettings.h new file mode 100644 index 0000000000..0953ab4a65 --- /dev/null +++ b/indra/newview/llfloaterenvironmentsettings.h @@ -0,0 +1,78 @@ +/** + * @file llfloaterenvironmentsettings.h + * @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$ + */ + +#ifndef LL_LLFLOATERENVIRONMENTSETTINGS_H +#define LL_LLFLOATERENVIRONMENTSETTINGS_H + +#include "llfloater.h" + +class LLComboBox; +class LLRadioGroup; + +class LLFloaterEnvironmentSettings : public LLFloater +{ + LOG_CLASS(LLFloaterEnvironmentSettings); + +public: + LLFloaterEnvironmentSettings(const LLSD &key); + /*virtual*/ ~LLFloaterEnvironmentSettings(); + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + +private: + void onSwitchRegionSettings(); + void onSwitchDayCycle(); + + void onSelectWaterPreset(); + void onSelectSkyPreset(); + void onSelectDayCyclePreset(); + + void onBtnOK(); + void onBtnCancel(); + + void cancel(); + + void populateWaterPresetsList(); + void populateSkyPresetsList(); + void populateDayCyclePresetsList(); + + LLRadioGroup* mRegionSettingsRadioGroup; + LLRadioGroup* mDayCycleSettingsRadioGroup; + + LLComboBox* mWaterPresetCombo; + LLComboBox* mSkyPresetCombo; + LLComboBox* mDayCyclePresetCombo; + + std::string mWaterPreset; + std::string mSkyPreset; + std::string mDayCyclePreset; + + bool mUseRegionSettings; + bool mUseFixedSky; + bool mDirty; +}; + +#endif // LL_LLFLOATERENVIRONMENTSETTINGS_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 6dc85799ce..a6dee5a553 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -50,6 +50,7 @@ #include "llfloatercamera.h" #include "llfloaterdaycycle.h" #include "llfloaterdisplayname.h" +#include "llfloaterenvironmentsettings.h" #include "llfloaterevent.h" #include "llfloatersearch.h" #include "llfloaterenvsettings.h" @@ -154,7 +155,8 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("env_day_cycle", "floater_day_cycle_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::add("env_settings", "floater_env_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("old_env_settings", "floater_env_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_water", "floater_water.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_windlight", "floater_windlight_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 4acf9a1fad..0edba58755 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7579,10 +7579,16 @@ class LLWorldEnvSettings : public view_listener_t std::string tod = userdata.asString(); LLVector3 sun_direction; - if (tod == "editor") + if (tod == "old_editor") { // if not there or is hidden, show it // *TODO replace with LLFloaterWindLight::show(LLEnvKey::SCOPE_LOCAL) to make sure we're using the right scope? + LLFloaterReg::toggleInstance("old_env_settings"); + return true; + } + + if (tod == "editor") + { LLFloaterReg::toggleInstance("env_settings"); return true; } @@ -7612,38 +7618,6 @@ class LLWorldEnvSettings : public view_listener_t } }; -class LLWorldCheckEnvironment : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - const std::string& item = userdata.asString(); - - if (item == "use_region_settings") - { - // Check whether we're using region environment settings. - return LLEnvManagerNew::instance().getUseRegionSettings(); - } - - return true; - } -}; - -class LLWorldEnvironment : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - const std::string& item = userdata.asString(); - - if (item == "use_region_settings") - { - bool cur_val = LLEnvManagerNew::instance().getUseRegionSettings(); - LLEnvManagerNew::instance().setUseRegionSettings(!cur_val); - } - - return true; - } -}; - /// Post-Process callbacks class LLWorldPostProcess : public view_listener_t { @@ -7892,8 +7866,6 @@ void initialize_menus() view_listener_t::addMenu(new LLWorldCheckAlwaysRun(), "World.CheckAlwaysRun"); view_listener_t::addMenu(new LLWorldEnvSettings(), "World.EnvSettings"); - view_listener_t::addEnable(new LLWorldCheckEnvironment(), "World.CheckEnvironment"); - view_listener_t::addMenu(new LLWorldEnvironment(), "World.Environment"); view_listener_t::addMenu(new LLWorldPostProcess(), "World.PostProcess"); view_listener_t::addMenu(new LLWorldDayCycle(), "World.DayCycle"); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 0913c4dec2..7af17a8d0b 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -547,7 +547,7 @@ void LLWLParamManager::update(LLViewerCamera * cam) { dlfloater->syncMenu(); } - LLFloaterEnvSettings* envfloater = LLFloaterReg::findTypedInstance("env_settings"); + LLFloaterEnvSettings* envfloater = LLFloaterReg::findTypedInstance("old_env_settings"); if (envfloater) { envfloater->syncMenu(); diff --git a/indra/newview/skins/default/xui/en/floater_environment_settings.xml b/indra/newview/skins/default/xui/en/floater_environment_settings.xml index 77cad2a2bd..8460530f97 100644 --- a/indra/newview/skins/default/xui/en/floater_environment_settings.xml +++ b/indra/newview/skins/default/xui/en/floater_environment_settings.xml @@ -1,7 +1,7 @@ - - + - Water - - - - + - + + name="use_my_settings" + top_pad="20"/> + + + + + + Water Setting + + name="item0"/> - + - Sky / Day Cycle - - - - - - @@ -124,17 +104,34 @@ width="200"> + name="item0"/> - - + name="item0"/> + + + +