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.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/CMakeLists.txt | 2 + indra/newview/lldaycyclemanager.cpp | 122 +++++++++++++++++++++++++ indra/newview/lldaycyclemanager.h | 66 +++++++++++++ indra/newview/llenvmanager.cpp | 6 -- indra/newview/llenvmanager.h | 3 - indra/newview/llfloaterenvironmentsettings.cpp | 8 +- indra/newview/llfloaterregioninfo.cpp | 23 +++-- indra/newview/llwldaycycle.cpp | 11 ++- indra/newview/llwldaycycle.h | 3 + indra/newview/llwlparammanager.cpp | 20 +++- indra/newview/llwlparammanager.h | 2 +- 11 files changed, 241 insertions(+), 25 deletions(-) create mode 100644 indra/newview/lldaycyclemanager.cpp create mode 100644 indra/newview/lldaycyclemanager.h (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 81caf9fbd4..b87f3bf3d4 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -123,6 +123,7 @@ set(viewer_SOURCE_FILES llcurrencyuimanager.cpp llcylinder.cpp lldateutil.cpp + lldaycyclemanager.cpp lldebugmessagebox.cpp lldebugview.cpp lldelayedgestureerror.cpp @@ -670,6 +671,7 @@ set(viewer_HEADER_FILES llcurrencyuimanager.h llcylinder.h lldateutil.h + lldaycyclemanager.h lldebugmessagebox.h lldebugview.h lldelayedgestureerror.h diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp new file mode 100644 index 0000000000..c0eae8cd3c --- /dev/null +++ b/indra/newview/lldaycyclemanager.cpp @@ -0,0 +1,122 @@ +/** + * @file lldaycyclemanager.cpp + * @brief Implementation for the LLDayCycleManager class. + * + * $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 "lldaycyclemanager.h" + +#include "lldiriterator.h" + +const LLDayCycleManager::dc_map_t& LLDayCycleManager::getPresets() +{ + // Refresh day cycles. + loadAllPresets(); + + return mDayCycleMap; +} + +bool LLDayCycleManager::getPreset(const std::string name, LLWLDayCycle& day_cycle) +{ + dc_map_t::const_iterator it = mDayCycleMap.find(name); + if (it == mDayCycleMap.end()) + { + return false; + } + + day_cycle = it->second; + return true; +} + +bool LLDayCycleManager::getPreset(const std::string name, LLSD& day_cycle) +{ + LLWLDayCycle dc; + if (!getPreset(name, dc)) + { + return false; + } + + day_cycle = dc.asLLSD(); + return true; +} + +// virtual +void LLDayCycleManager::initSingleton() +{ + LL_DEBUGS("Windlight") << "Loading all day cycles" << LL_ENDL; + loadAllPresets(); +} + +void LLDayCycleManager::loadAllPresets() +{ + mDayCycleMap.clear(); + + // First, load system (coming out of the box) day cycles. + loadPresets(getSysDir()); + + // Then load user presets. Note that user day cycles will modify any system ones already loaded. + loadPresets(getUserDir()); +} + +void LLDayCycleManager::loadPresets(const std::string& dir) +{ + LLDirIterator dir_iter(dir, "*.xml"); + + while (1) + { + std::string file; + if (!dir_iter.next(file)) break; // no more files + loadPreset(dir + file); + } +} + +bool LLDayCycleManager::loadPreset(const std::string& path) +{ + LLSD data = LLWLDayCycle::loadDayCycleFromPath(path); + if (data.isUndefined()) + { + LL_WARNS("Windlight") << "Error loading day cycle from " << path << LL_ENDL; + return false; + } + + std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); + LLWLDayCycle day_cycle; + day_cycle.loadDayCycle(data, LLEnvKey::SCOPE_LOCAL); + mDayCycleMap[name] = day_cycle; + + return true; +} + +// static +std::string LLDayCycleManager::getSysDir() +{ + return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", ""); +} + +// static +std::string LLDayCycleManager::getUserDir() +{ + return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "windlight/days", ""); +} diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h new file mode 100644 index 0000000000..e49e4986fe --- /dev/null +++ b/indra/newview/lldaycyclemanager.h @@ -0,0 +1,66 @@ +/** + * @file lldaycyclemanager.h + * @brief Implementation for the LLDayCycleManager class. + * + * $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_LLDAYCYCLEMANAGER_H +#define LL_LLDAYCYCLEMANAGER_H + +#include +#include + +#include "llwldaycycle.h" +#include "llwlparammanager.h" + +/** + * WindLight day cycles manager class + * + * Provides interface for accessing, loading and saving day cycles. + */ +class LLDayCycleManager : public LLSingleton +{ + LOG_CLASS(LLDayCycleManager); + +public: + typedef std::map dc_map_t; + + const dc_map_t& getPresets(); + bool getPreset(const std::string name, LLWLDayCycle& day_cycle); + bool getPreset(const std::string name, LLSD& day_cycle); + +private: + friend class LLSingleton; + /*virtual*/ void initSingleton(); + + void loadAllPresets(); + void loadPresets(const std::string& dir); + bool loadPreset(const std::string& path); + + static std::string getSysDir(); + static std::string getUserDir(); + + dc_map_t mDayCycleMap; +}; + +#endif // LL_LLDAYCYCLEMANAGER_H diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index a08ca88459..f12c3e54ff 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -764,12 +764,6 @@ void LLEnvManagerNew::dumpUserPrefs() LL_DEBUGS("Windlight") << "UseDayCycle: " << gSavedSettings.getBOOL("UseDayCycle") << LL_ENDL; } -// static -LLSD LLEnvManagerNew::getDayCycleByName(const std::string name) -{ - return LLWLDayCycle::loadCycleDataFromFile(name + ".xml"); -} - void LLEnvManagerNew::requestRegionSettings() { LLEnvironmentRequest::initiate(); diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index 52b645b535..223654151b 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -293,9 +293,6 @@ public: bool use_region_settings); void dumpUserPrefs(); - // Common interface to the wl/water managers. - static LLSD getDayCycleByName(const std::string name); - // Misc. void requestRegionSettings(); bool sendRegionSettings(const LLEnvironmentSettings& new_settings); 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); + } } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index ff34e21c2f..6a5b577396 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -52,6 +52,7 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" +#include "lldaycyclemanager.h" #include "llenvmanager.h" #include "llfilepicker.h" #include "llfloaterdaycycle.h" @@ -3350,14 +3351,18 @@ void LLPanelEnvironmentInfo::populateDayCyclesList() llassert(region != NULL); LLWLParamKey key(region->getName(), LLEnvKey::SCOPE_REGION); - mDayCyclePresetCombo->add(region->getName(), key.toLLSD()); + mDayCyclePresetCombo->add(region->getName(), key.toStringVal()); mDayCyclePresetCombo->addSeparator(); } // Add local day cycles. - // *TODO: multiple local day cycles support - LLWLParamKey key("Default", LLEnvKey::SCOPE_LOCAL); - mDayCyclePresetCombo->add("Default", key.toLLSD()); + const LLDayCycleManager::dc_map_t& map = LLDayCycleManager::instance().getPresets(); + for (LLDayCycleManager::dc_map_t::const_iterator it = map.begin(); it != map.end(); ++it) + { + std::string name = it->first; + LLWLParamKey key(name, LLEnvKey::SCOPE_LOCAL); + mDayCyclePresetCombo->add(name, key.toStringVal()); + } // Current day cycle is already selected. } @@ -3421,7 +3426,8 @@ void LLPanelEnvironmentInfo::onBtnSave() } else // use day cycle { - LLWLParamKey dc(mDayCyclePresetCombo->getValue()); + std::string preset_key(mDayCyclePresetCombo->getValue().asString()); + LLWLParamKey dc(preset_key); LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle @@ -3431,8 +3437,11 @@ void LLPanelEnvironmentInfo::onBtnSave() } else // a local day cycle { - // *TODO: multiple local day cycles support - day_cycle = LLEnvManagerNew::instance().getDayCycleByName("Default"); + if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) + { + llwarns << "Error getting day cycle " << dc.name << llendl; + return; + } // Create sky map from the day cycle. { diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 7363392042..6ac63fb99e 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -100,9 +100,16 @@ void LLWLDayCycle::loadDayCycleFromFile(const std::string & fileName) // now load the file std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); - llinfos << "Loading DayCycle settings from " << pathName << llendl; + + return loadDayCycleFromPath(pathName); +} + +// static +LLSD LLWLDayCycle::loadDayCycleFromPath(const std::string& file_path) +{ + LL_INFOS("Windlight") << "Loading DayCycle settings from " << file_path << LL_ENDL; - llifstream day_cycle_xml(pathName); + llifstream day_cycle_xml(file_path); if (day_cycle_xml.is_open()) { // load and parse it diff --git a/indra/newview/llwldaycycle.h b/indra/newview/llwldaycycle.h index 36b5160a58..56bd66f114 100644 --- a/indra/newview/llwldaycycle.h +++ b/indra/newview/llwldaycycle.h @@ -68,6 +68,9 @@ public: /// load the LLSD data from a file (returns the undefined LLSD if not found) static LLSD loadCycleDataFromFile(const std::string & fileName); + /// load the LLSD data from a file specified by full path + static LLSD loadDayCycleFromPath(const std::string& file_path); + /// get the LLSD data for this day cycle LLSD asLLSD(); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index ec7889cb93..396c61b4b6 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -50,6 +50,7 @@ #include "llagent.h" #include "llviewerregion.h" +#include "lldaycyclemanager.h" #include "llenvmanager.h" #include "llwlparamset.h" #include "llpostprocess.h" @@ -613,7 +614,11 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) { if (LLEnvManagerNew::instance().getUseDayCycle()) { - applyDayCycle(LLEnvManagerNew::instance().getDayCycleName()); + if (!applyDayCycle(LLEnvManagerNew::instance().getDayCycleName())) + { + // *TODO: fix user prefs + applyDefaults(); + } } else { @@ -627,14 +632,21 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) void LLWLParamManager::applyDefaults() { - applyDayCycle("Default"); + llassert(applyDayCycle("Default") == true); } -void LLWLParamManager::applyDayCycle(const std::string& day_cycle) +bool LLWLParamManager::applyDayCycle(const std::string& day_cycle) { LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; - mDay.loadDayCycleFromFile(day_cycle + ".xml"); + + if (!LLDayCycleManager::instance().getPreset(day_cycle, mDay)) + { + llwarns << "No day cycle named " << day_cycle << llendl; + return false; + } + resetAnimator(0.5, true); // set to noon and start animator + return true; } void LLWLParamManager::resetAnimator(F32 curTime, bool run) diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 35acb7c5d6..eb810a4086 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -246,7 +246,7 @@ public: void applyDefaults(); /// apply default sky params - void applyDayCycle(const std::string& day); + bool applyDayCycle(const std::string& day); // get where the light is pointing inline LLVector4 getLightDir(void) const; -- cgit v1.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/CMakeLists.txt | 2 + indra/newview/llfloaterdeleteenvpreset.cpp | 139 +++++++++++++++++++++ indra/newview/llfloaterdeleteenvpreset.h | 55 ++++++++ indra/newview/llfloaterenvironmentsettings.cpp | 1 + indra/newview/llviewerfloaterreg.cpp | 2 + indra/newview/llviewermenu.cpp | 46 +++++++ .../default/xui/en/floater_delete_env_preset.xml | 19 ++- indra/newview/skins/default/xui/en/menu_viewer.xml | 36 +++--- 8 files changed, 277 insertions(+), 23 deletions(-) create mode 100644 indra/newview/llfloaterdeleteenvpreset.cpp create mode 100644 indra/newview/llfloaterdeleteenvpreset.h (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index b87f3bf3d4..097151d058 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -174,6 +174,7 @@ set(viewer_SOURCE_FILES llfloatercamera.cpp llfloatercolorpicker.cpp llfloaterdaycycle.cpp + llfloaterdeleteenvpreset.cpp llfloaterdisplayname.cpp llfloaterenvsettings.cpp llfloaterenvironmentsettings.cpp @@ -723,6 +724,7 @@ set(viewer_HEADER_FILES llfloatercamera.h llfloatercolorpicker.h llfloaterdaycycle.h + llfloaterdeleteenvpreset.h llfloaterdisplayname.h llfloaterenvsettings.h llfloaterenvironmentsettings.h diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp new file mode 100644 index 0000000000..e014eedeb1 --- /dev/null +++ b/indra/newview/llfloaterdeleteenvpreset.cpp @@ -0,0 +1,139 @@ +/** + * @file llfloaterdeleteenvpreset.cpp + * @brief Floater to delete a water / sky / day cycle preset. + * + * $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 "llfloaterdeleteenvpreset.h" + +// libs +#include "llbutton.h" +#include "llcombobox.h" + +// newview +#include "lldaycyclemanager.h" +#include "llwaterparammanager.h" + +LLFloaterDeleteEnvPreset::LLFloaterDeleteEnvPreset(const LLSD &key) +: LLFloater(key) +, mPresetCombo(NULL) +{ +} + +// virtual +BOOL LLFloaterDeleteEnvPreset::postBuild() +{ + mPresetCombo = getChild("preset_combo"); + + getChild("delete")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnDelete, this)); + getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnCancel, this)); + + // Deletion is not implemented yet, so disable the button for now. + getChild("delete")->setEnabled(FALSE); + + return TRUE; +} + +// virtual +void LLFloaterDeleteEnvPreset::onOpen(const LLSD& key) +{ + std::string param = key.asString(); + std::string floater_title = getString(std::string("title_") + param); + std::string combo_label = getString(std::string("label_" + param)); + + // Update floater title. + setTitle(floater_title); + + // Update the combobox label. + getChild("label")->setValue(combo_label); + + // Populate the combobox. + mPresetCombo->removeall(); + if (param == "water") + { + populateWaterPresetsList(); + } + else if (param == "sky") + { + populateSkyPresetsList(); + } + else if (param == "day_cycle") + { + populateDayCyclesList(); + } + else + { + llwarns << "Unrecognized key" << llendl; + } +} + +void LLFloaterDeleteEnvPreset::onBtnDelete() +{ + closeFloater(); +} + +void LLFloaterDeleteEnvPreset::onBtnCancel() +{ + closeFloater(); +} + +void LLFloaterDeleteEnvPreset::populateWaterPresetsList() +{ + // *TODO: Reload the list when user preferences change. + LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); + LL_DEBUGS("Windlight") << "Current water preset: " << water_mgr.mCurParams.mName << LL_ENDL; + + const std::map &water_params_map = water_mgr.mParamList; + for (std::map::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + { + std::string name = it->first; + bool enabled = (name != water_mgr.mCurParams.mName); // don't allow deleting current preset + mPresetCombo->add(name, ADD_BOTTOM, enabled); + } +} + +void LLFloaterDeleteEnvPreset::populateSkyPresetsList() +{ + LLWLParamManager& sky_mgr = LLWLParamManager::instance(); + LL_DEBUGS("Windlight") << "Current sky preset: " << sky_mgr.mCurParams.mName << LL_ENDL; + + const std::map &sky_params_map = sky_mgr.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 + bool enabled = (it->first.name != sky_mgr.mCurParams.mName); + mPresetCombo->add(it->first.name, ADD_BOTTOM, enabled); + } +} + +void LLFloaterDeleteEnvPreset::populateDayCyclesList() +{ + // *TODO: Disable current day cycle. + const LLDayCycleManager::dc_map_t& map = LLDayCycleManager::instance().getPresets(); + for (LLDayCycleManager::dc_map_t::const_iterator it = map.begin(); it != map.end(); ++it) + { + mPresetCombo->add(it->first); + } +} diff --git a/indra/newview/llfloaterdeleteenvpreset.h b/indra/newview/llfloaterdeleteenvpreset.h new file mode 100644 index 0000000000..08fd11a16d --- /dev/null +++ b/indra/newview/llfloaterdeleteenvpreset.h @@ -0,0 +1,55 @@ +/** + * @file llfloaterdeleteenvpreset.h + * @brief Floater to delete a water / sky / day cycle preset. + * + * $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_LLFLOATERDELETEENVPRESET_H +#define LL_LLFLOATERDELETEENVPRESET_H + +#include "llfloater.h" + +class LLComboBox; + +class LLFloaterDeleteEnvPreset : public LLFloater +{ + LOG_CLASS(LLFloaterDeleteEnvPreset); + +public: + LLFloaterDeleteEnvPreset(const LLSD &key); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + + void onBtnDelete(); + void onBtnCancel(); + +private: + void populateWaterPresetsList(); + void populateSkyPresetsList(); + void populateDayCyclesList(); + + LLComboBox* mPresetCombo; +}; + +#endif // LL_LLFLOATERDELETEENVPRESET_H 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); } } diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index a6dee5a553..dfa6e2e5c8 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -49,6 +49,7 @@ #include "llfloaterbump.h" #include "llfloatercamera.h" #include "llfloaterdaycycle.h" +#include "llfloaterdeleteenvpreset.h" #include "llfloaterdisplayname.h" #include "llfloaterenvironmentsettings.h" #include "llfloaterevent.h" @@ -159,6 +160,7 @@ void LLViewerFloaterReg::registerFloaters() 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); + LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("event", "floater_event.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 4d0d663e0c..437bc4c598 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7619,6 +7619,51 @@ class LLWorldEnvSettings : public view_listener_t } }; +class LLWorldEnvPreset : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + std::string item = userdata.asString(); + + if (item == "new_water") + { + } + else if (item == "edit_water") + { + } + else if (item == "delete_water") + { + LLFloaterReg::showInstance("env_delete_preset", "water"); + } + else if (item == "new_sky") + { + } + else if (item == "edit_sky") + { + } + else if (item == "delete_sky") + { + LLFloaterReg::showInstance("env_delete_preset", "sky"); + } + else if (item == "new_day_cycle") + { + } + else if (item == "edit_day_cycle") + { + } + else if (item == "delete_day_cycle") + { + LLFloaterReg::showInstance("env_delete_preset", "day_cycle"); + } + else + { + llwarns << "Unknown item selected" << llendl; + } + + return true; + } +}; + /// Post-Process callbacks class LLWorldPostProcess : public view_listener_t { @@ -7867,6 +7912,7 @@ void initialize_menus() view_listener_t::addMenu(new LLWorldCheckAlwaysRun(), "World.CheckAlwaysRun"); view_listener_t::addMenu(new LLWorldEnvSettings(), "World.EnvSettings"); + view_listener_t::addMenu(new LLWorldEnvPreset(), "World.EnvPreset"); view_listener_t::addMenu(new LLWorldPostProcess(), "World.PostProcess"); view_listener_t::addMenu(new LLWorldDayCycle(), "World.DayCycle"); diff --git a/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml index a7ab5abf38..1539c6448e 100644 --- a/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml +++ b/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml @@ -2,22 +2,31 @@ + + Delete Water Preset + Delete Sky Preset + Delete Day Cycle + + Preset: + Preset: + Day cycle: + - Setting: + Preset: + function="World.EnvPreset" + parameter="new_water"/> + function="World.EnvPreset" + parameter="edit_water"/> + function="World.EnvPreset" + parameter="delete_water"/> @@ -565,22 +565,22 @@ label="New preset..." name="new_sky_preset"> + function="World.EnvPreset" + parameter="new_sky"/> + function="World.EnvPreset" + parameter="edit_sky"/> + function="World.EnvPreset" + parameter="delete_sky"/> @@ -591,22 +591,22 @@ label="New preset..." name="new_day_preset"> + function="World.EnvPreset" + parameter="new_day_cycle"/> + function="World.EnvPreset" + parameter="edit_day_cycle"/> + function="World.EnvPreset" + parameter="delete_day_cycle"/> -- cgit v1.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 + indra/newview/llwaterparammanager.cpp | 8 +++++++- indra/newview/llwldaycycle.cpp | 2 +- indra/newview/llwlparammanager.cpp | 18 ++++++++++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) (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)); diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 81d2b92647..5df807f740 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -291,7 +291,13 @@ void LLWaterParamManager::applyUserPrefs(bool interpolate) std::string water = LLEnvManagerNew::instance().getWaterPresetName(); LL_DEBUGS("Windlight") << "Applying water preset [" << water << "]" << LL_ENDL; LLWaterParamSet params; - getParamSet(water, params); + if (!getParamSet(water, params)) + { + llwarns << "No wayer preset named " << water << ", falling back to defaults" << llendl; + getParamSet("Default", params); + + // *TODO: Fix user preferences accordingly. + } target_water_params = params.getAll(); } diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 91d2173d6d..8dca9c5ecb 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -97,7 +97,7 @@ void LLWLDayCycle::loadDayCycleFromFile(const std::string & fileName) /*static*/ LLSD LLWLDayCycle::loadCycleDataFromFile(const std::string & fileName) { - // now load the file + // *FIX: Cannot load user day cycles. std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index db81c3ead7..eb49f2b018 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -776,11 +776,25 @@ void LLWLParamManager::initSingleton() loadPresets(LLStringUtil::null); // load the day - mDay.loadDayCycleFromFile(LLEnvManagerNew::instance().getDayCycleName() + ".xml"); + std::string preferred_day = LLEnvManagerNew::instance().getDayCycleName(); + if (!LLDayCycleManager::instance().getPreset(preferred_day, mDay)) + { + // Fall back to default. + llwarns << "No day cycle named " << preferred_day << ", falling back to defaults" << llendl; + mDay.loadDayCycleFromFile("Default.xml"); + + // *TODO: Fix user preferences accordingly. + } // *HACK - sets cloud scrolling to what we want... fix this better in the future std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); - getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); + if (!getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams)) + { + llwarns << "No sky preset named " << sky << ", falling back to defaults" << llendl; + getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams); + + // *TODO: Fix user preferences accordingly. + } // set it to noon resetAnimator(0.5, LLEnvManagerNew::instance().getUseDayCycle()); -- cgit v1.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.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 ++++--- indra/newview/llfloaterregioninfo.cpp | 1 + 2 files changed, 5 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. diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 39ed2534b2..414695d40f 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3287,6 +3287,7 @@ BOOL LLPanelEnvironmentInfo::postBuild() mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); + getChild("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); -- cgit v1.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/lldaycyclemanager.cpp | 7 +++++++ indra/newview/lldaycyclemanager.h | 5 +++++ indra/newview/llfloaterdeleteenvpreset.cpp | 6 ++++++ indra/newview/llfloaterdeleteenvpreset.h | 1 + indra/newview/llfloatereditdaycycle.cpp | 11 +++++++++++ indra/newview/llfloatereditdaycycle.h | 2 ++ indra/newview/llfloaterenvironmentsettings.cpp | 7 +++++++ indra/newview/llfloaterenvironmentsettings.h | 2 ++ indra/newview/llfloaterregioninfo.cpp | 7 +++++++ indra/newview/llfloaterregioninfo.h | 2 ++ 10 files changed, 50 insertions(+) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp index 0cd23f5202..960879c32c 100644 --- a/indra/newview/lldaycyclemanager.cpp +++ b/indra/newview/lldaycyclemanager.cpp @@ -82,6 +82,7 @@ bool LLDayCycleManager::savePreset(const std::string& name, const LLSD& data) // Add it to our map. addPreset(name, data); + mModifySignal(); return true; } @@ -95,6 +96,7 @@ bool LLDayCycleManager::deletePreset(const std::string& name) if (gDirUtilp->fileExists(path)) { gDirUtilp->deleteFilesInDir(getUserDir(), filename); + mModifySignal(); return true; } @@ -102,6 +104,11 @@ bool LLDayCycleManager::deletePreset(const std::string& name) return false; } +boost::signals2::connection LLDayCycleManager::setModifyCallback(const modify_signal_t::slot_type& cb) +{ + return mModifySignal.connect(cb); +} + // virtual void LLDayCycleManager::initSingleton() { diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h index b33c0a0d39..0d4a474ac6 100644 --- a/indra/newview/lldaycyclemanager.h +++ b/indra/newview/lldaycyclemanager.h @@ -44,6 +44,7 @@ class LLDayCycleManager : public LLSingleton public: typedef std::map dc_map_t; + typedef boost::signals2::signal modify_signal_t; const dc_map_t& getPresets(); bool getPreset(const std::string name, LLWLDayCycle& day_cycle) const; @@ -53,6 +54,9 @@ public: bool savePreset(const std::string& name, const LLSD& data); bool deletePreset(const std::string& name); + /// Emitted when a preset gets added or deleted. + boost::signals2::connection setModifyCallback(const modify_signal_t::slot_type& cb); + private: friend class LLSingleton; /*virtual*/ void initSingleton(); @@ -66,6 +70,7 @@ private: static std::string getUserDir(); dc_map_t mDayCycleMap; + modify_signal_t mModifySignal; }; #endif // LL_LLDAYCYCLEMANAGER_H diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp index d2f0f6e520..d791c29a96 100644 --- a/indra/newview/llfloaterdeleteenvpreset.cpp +++ b/indra/newview/llfloaterdeleteenvpreset.cpp @@ -62,6 +62,8 @@ BOOL LLFloaterDeleteEnvPreset::postBuild() getChild("delete")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnDelete, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnCancel, this)); + LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterDeleteEnvPreset::onDayCycleListChange, this)); + return TRUE; } @@ -193,5 +195,9 @@ void LLFloaterDeleteEnvPreset::populateDayCyclesList() void LLFloaterDeleteEnvPreset::onDeleteDayCycleConfirmation() { LLDayCycleManager::instance().deletePreset(mPresetCombo->getValue().asString()); +} + +void LLFloaterDeleteEnvPreset::onDayCycleListChange() +{ populateDayCyclesList(); } diff --git a/indra/newview/llfloaterdeleteenvpreset.h b/indra/newview/llfloaterdeleteenvpreset.h index 76b23feae8..aaa4143233 100644 --- a/indra/newview/llfloaterdeleteenvpreset.h +++ b/indra/newview/llfloaterdeleteenvpreset.h @@ -50,6 +50,7 @@ private: void populateDayCyclesList(); void onDeleteDayCycleConfirmation(); + void onDayCycleListChange(); LLComboBox* mPresetCombo; }; diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp index 8c85f6833b..f77e73c30b 100644 --- a/indra/newview/llfloatereditdaycycle.cpp +++ b/indra/newview/llfloatereditdaycycle.cpp @@ -147,6 +147,9 @@ void LLFloaterEditDayCycle::initCallbacks(void) env_mgr.setRegionChangeCallback(boost::bind(&LLFloaterEditDayCycle::onRegionChange, this)); env_mgr.setRegionSettingsAppliedCallback(boost::bind(&LLFloaterEditDayCycle::onRegionSettingsApplied, this, _1)); + // Connect to day cycle manager events. + LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleListChange, this)); + // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditDayCycle::onRegionInfoUpdate, this)); } @@ -758,6 +761,14 @@ void LLFloaterEditDayCycle::onSaveConfirmed() closeFloater(); } +void LLFloaterEditDayCycle::onDayCycleListChange() +{ + if (!isNewDay()) + { + refreshDayCyclesList(); + } +} + // static std::string LLFloaterEditDayCycle::getRegionName() { diff --git a/indra/newview/llfloatereditdaycycle.h b/indra/newview/llfloatereditdaycycle.h index 0a2ba32dfe..3b467b2939 100644 --- a/indra/newview/llfloatereditdaycycle.h +++ b/indra/newview/llfloatereditdaycycle.h @@ -103,6 +103,8 @@ private: bool onSaveAnswer(const LLSD& notification, const LLSD& response); void onSaveConfirmed(); + void onDayCycleListChange(); + static std::string getRegionName(); static bool canEditRegionSettings(); 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; diff --git a/indra/newview/llfloaterenvironmentsettings.h b/indra/newview/llfloaterenvironmentsettings.h index 0953ab4a65..6d29a5d4d5 100644 --- a/indra/newview/llfloaterenvironmentsettings.h +++ b/indra/newview/llfloaterenvironmentsettings.h @@ -50,6 +50,8 @@ private: void onSelectSkyPreset(); void onSelectDayCyclePreset(); + void onDayCycleListChange(); + void onBtnOK(); void onBtnCancel(); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 414695d40f..db1eae5835 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3293,6 +3293,8 @@ BOOL LLPanelEnvironmentInfo::postBuild() LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); + LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::onDayCycleListChange, this)); + return TRUE; } @@ -3747,3 +3749,8 @@ void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) LLEnvManagerNew::instance().requestRegionSettings(); } } + +void LLPanelEnvironmentInfo::onDayCycleListChange() +{ + populateDayCyclesList(); +} diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 6075842e76..4f5222eb34 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -471,6 +471,8 @@ private: void onRegionSettingschange(); void onRegionSettingsApplied(bool ok); + void onDayCycleListChange(); + bool mEnableEditing; LLRadioGroup* mRegionSettingsRadioGroup; -- cgit v1.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/llenvmanager.cpp | 50 ++++++++++++++++++++++++++ indra/newview/llenvmanager.h | 1 + indra/newview/llfloaterenvironmentsettings.cpp | 1 + indra/newview/llfloaterregioninfo.cpp | 1 + indra/newview/llwlparammanager.cpp | 9 +++++ 5 files changed, 62 insertions(+) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 48d84fcffc..dd8db7b785 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -835,6 +835,56 @@ void LLEnvManagerNew::dumpUserPrefs() LL_DEBUGS("Windlight") << "UseDayCycle: " << gSavedSettings.getBOOL("UseDayCycle") << LL_ENDL; } +void LLEnvManagerNew::dumpPresets() +{ + const LLEnvironmentSettings& region_settings = getRegionSettings(); + std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : "Unknown region"; + + // Dump water presets. + LL_DEBUGS("Windlight") << "Waters:" << LL_ENDL; + if (region_settings.getWaterParams().size() != 0) + { + LL_DEBUGS("Windlight") << " - " << region_name << LL_ENDL; + } + const std::map &water_params_map = LLWaterParamManager::instance().mParamList; + for (std::map::const_iterator it = water_params_map.begin(); it != water_params_map.end(); it++) + { + LL_DEBUGS("Windlight") << " - " << it->first << LL_ENDL; + } + + // Dump sky presets. + LL_DEBUGS("Windlight") << "Skies:" << LL_ENDL; + 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++) + { + std::string preset_name = it->first.name; + std::string item_title; + + if (it->first.scope == LLEnvKey::SCOPE_LOCAL) // local preset + { + item_title = preset_name; + } + else // region preset + { + item_title = preset_name + " (" + region_name + ")"; + } + LL_DEBUGS("Windlight") << " - " << item_title << LL_ENDL; + } + + // Dump day cycles. + LL_DEBUGS("Windlight") << "Days:" << LL_ENDL; + const LLSD& cur_region_dc = region_settings.getWLDayCycle(); + if (cur_region_dc.size() != 0) + { + LL_DEBUGS("Windlight") << " - " << region_name << LL_ENDL; + } + const LLDayCycleManager::dc_map_t& map = LLDayCycleManager::instance().getPresets(); + for (LLDayCycleManager::dc_map_t::const_iterator it = map.begin(); it != map.end(); ++it) + { + LL_DEBUGS("Windlight") << " - " << it->first << LL_ENDL; + } +} + void LLEnvManagerNew::requestRegionSettings() { LLEnvironmentRequest::initiate(); diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index 098fc6f353..62ec08b09f 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -301,6 +301,7 @@ public: bool use_fixed_sky, bool use_region_settings); void dumpUserPrefs(); + void dumpPresets(); // Misc. void requestRegionSettings(); 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)); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index ad63300259..ab164e7db0 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3295,6 +3295,7 @@ BOOL LLPanelEnvironmentInfo::postBuild() childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); getChild("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); + getChild("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 83d9ef6fde..5980410e64 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -678,6 +678,8 @@ bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) std::map::iterator mIt = mParamList.find(key); if(mIt == mParamList.end()) { + llassert(!key.name.empty()); + // *TODO: validate params mParamList[key] = param; return true; } @@ -691,6 +693,8 @@ BOOL LLWLParamManager::addParamSet(const LLWLParamKey& key, LLSD const & param) std::map::const_iterator finder = mParamList.find(key); if(finder == mParamList.end()) { + llassert(!key.name.empty()); + // *TODO: validate params mParamList[key].setAll(param); return TRUE; } @@ -716,6 +720,8 @@ bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) { + llassert(!key.name.empty()); + // *TODO: validate params mParamList[key] = param; return true; @@ -723,6 +729,9 @@ bool LLWLParamManager::setParamSet(const LLWLParamKey& key, LLWLParamSet& param) bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) { + llassert(!key.name.empty()); + // *TODO: validate params + // quick, non robust (we won't be working with files, but assets) check // this might not actually be true anymore.... if(!param.isMap()) -- cgit v1.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/lldaycyclemanager.cpp | 16 +++++++ indra/newview/lldaycyclemanager.h | 3 ++ indra/newview/llfloaterdeleteenvpreset.cpp | 51 ++++++++++++++++++---- indra/newview/llfloaterdeleteenvpreset.h | 4 +- indra/newview/llfloatereditdaycycle.cpp | 11 +++++ indra/newview/llfloatereditdaycycle.h | 1 + indra/newview/llfloatereditsky.cpp | 22 +++++++++- indra/newview/llfloatereditsky.h | 2 + indra/newview/llfloaterenvironmentsettings.cpp | 8 +--- indra/newview/llfloaterenvironmentsettings.h | 2 - indra/newview/llfloaterregioninfo.cpp | 8 +--- indra/newview/llfloaterregioninfo.h | 2 - indra/newview/llwldaycycle.cpp | 10 ++++- indra/newview/llwldaycycle.h | 5 ++- indra/newview/llwlparammanager.cpp | 46 ++++++++++--------- indra/newview/llwlparammanager.h | 7 +++ .../default/xui/en/floater_delete_env_preset.xml | 12 +++-- 17 files changed, 148 insertions(+), 62 deletions(-) (limited to 'indra/newview/llfloaterenvironmentsettings.cpp') diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp index 07a9a72e68..ab442d7c83 100644 --- a/indra/newview/lldaycyclemanager.cpp +++ b/indra/newview/lldaycyclemanager.cpp @@ -109,6 +109,22 @@ bool LLDayCycleManager::deletePreset(const std::string& name) return true; } +bool LLDayCycleManager::isSkyPresetReferenced(const std::string& preset_name) const +{ + // We're traversing local day cycles, they can only reference local skies. + LLWLParamKey key(preset_name, LLEnvKey::SCOPE_LOCAL); + + for (dc_map_t::const_iterator it = mDayCycleMap.begin(); it != mDayCycleMap.end(); ++it) + { + if (it->second.hasReferencesTo(key)) + { + return true; + } + } + + return false; +} + boost::signals2::connection LLDayCycleManager::setModifyCallback(const modify_signal_t::slot_type& cb) { return mModifySignal.connect(cb); diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h index 0d4a474ac6..032e336491 100644 --- a/indra/newview/lldaycyclemanager.h +++ b/indra/newview/lldaycyclemanager.h @@ -54,6 +54,9 @@ public: bool savePreset(const std::string& name, const LLSD& data); bool deletePreset(const std::string& name); + /// @return true if there is a day cycle that refers to the sky preset. + bool isSkyPresetReferenced(const std::string& preset_name) const; + /// Emitted when a preset gets added or deleted. boost::signals2::connection setModifyCallback(const modify_signal_t::slot_type& cb); diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp index 74c837af53..b78e124e07 100644 --- a/indra/newview/llfloaterdeleteenvpreset.cpp +++ b/indra/newview/llfloaterdeleteenvpreset.cpp @@ -62,7 +62,9 @@ BOOL LLFloaterDeleteEnvPreset::postBuild() getChild("delete")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnDelete, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnCancel, this)); - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterDeleteEnvPreset::onDayCycleListChange, this)); + // Listen to presets addition/removal. + LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateDayCyclesList, this)); + LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeleteEnvPreset::populateSkyPresetsList, this)); return TRUE; } @@ -113,6 +115,13 @@ void LLFloaterDeleteEnvPreset::onBtnDelete() } else if (param == "sky") { + // Don't allow deleting presets referenced by local day cycles. + if (LLDayCycleManager::instance().isSkyPresetReferenced(preset_name)) + { + LLNotificationsUtil::add("GenericAlert", LLSD().with("MESSAGE", getString("msg_sky_is_referenced"))); + return; + } + LLWLParamManager& wl_mgr = LLWLParamManager::instance(); // Don't allow deleting system presets. @@ -155,6 +164,8 @@ void LLFloaterDeleteEnvPreset::onBtnCancel() void LLFloaterDeleteEnvPreset::populateWaterPresetsList() { + if (mKey.asString() != "water") return; + mPresetCombo->removeall(); // *TODO: Reload the list when user preferences change. @@ -168,10 +179,14 @@ void LLFloaterDeleteEnvPreset::populateWaterPresetsList() bool enabled = (name != water_mgr.mCurParams.mName); // don't allow deleting current preset mPresetCombo->add(name, ADD_BOTTOM, enabled); } + + postPopulate(); } void LLFloaterDeleteEnvPreset::populateSkyPresetsList() { + if (mKey.asString() != "sky") return; + mPresetCombo->removeall(); std::string cur_preset; @@ -187,14 +202,24 @@ void LLFloaterDeleteEnvPreset::populateSkyPresetsList() for (std::map::const_iterator it = sky_params_map.begin(); it != sky_params_map.end(); it++) { const LLWLParamKey& key = it->first; - if (key.scope == LLEnvKey::SCOPE_REGION) continue; // list only local presets - bool enabled = key.name != cur_preset && !sky_mgr.isSystemPreset(key.name); + + // list only local user presets + if (key.scope == LLEnvKey::SCOPE_REGION || sky_mgr.isSystemPreset(key.name)) + { + continue; + } + + bool enabled = (key.name != cur_preset); mPresetCombo->add(key.name, ADD_BOTTOM, enabled); } + + postPopulate(); } void LLFloaterDeleteEnvPreset::populateDayCyclesList() { + if (mKey.asString() != "day_cycle") return; + mPresetCombo->removeall(); // *TODO: Disable current day cycle. @@ -203,6 +228,21 @@ void LLFloaterDeleteEnvPreset::populateDayCyclesList() { mPresetCombo->add(it->first); } + + postPopulate(); +} + +void LLFloaterDeleteEnvPreset::postPopulate() +{ + // Handle empty list. + S32 n_items = mPresetCombo->getItemCount(); + + if (n_items == 0) + { + mPresetCombo->setLabel(getString("combo_label")); + } + + getChild("delete")->setEnabled(n_items > 0); } void LLFloaterDeleteEnvPreset::onDeleteDayCycleConfirmation() @@ -215,8 +255,3 @@ void LLFloaterDeleteEnvPreset::onDeleteSkyPresetConfirmation() LLWLParamKey key(mPresetCombo->getValue().asString(), LLEnvKey::SCOPE_LOCAL); LLWLParamManager::instance().removeParamSet(key, true); } - -void LLFloaterDeleteEnvPreset::onDayCycleListChange() -{ - populateDayCyclesList(); -} diff --git a/indra/newview/llfloaterdeleteenvpreset.h b/indra/newview/llfloaterdeleteenvpreset.h index 26e3b0728e..63f80d89d8 100644 --- a/indra/newview/llfloaterdeleteenvpreset.h +++ b/indra/newview/llfloaterdeleteenvpreset.h @@ -49,11 +49,11 @@ private: void populateSkyPresetsList(); void populateDayCyclesList(); + void postPopulate(); + void onDeleteDayCycleConfirmation(); void onDeleteSkyPresetConfirmation(); - void onDayCycleListChange(); - LLComboBox* mPresetCombo; }; diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp index f6bd4ad6b9..257644d80c 100644 --- a/indra/newview/llfloatereditdaycycle.cpp +++ b/indra/newview/llfloatereditdaycycle.cpp @@ -150,6 +150,9 @@ void LLFloaterEditDayCycle::initCallbacks(void) // Connect to day cycle manager events. LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEditDayCycle::onDayCycleListChange, this)); + // Connect to sky preset list changes. + LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditDayCycle::onSkyPresetListChange, this)); + // Connect to region info updates. LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditDayCycle::onRegionInfoUpdate, this)); } @@ -794,6 +797,14 @@ void LLFloaterEditDayCycle::onDayCycleListChange() } } +void LLFloaterEditDayCycle::onSkyPresetListChange() +{ + refreshSkyPresetsList(); + + // Refresh sliders from the currently visible day cycle. + loadTrack(); +} + // static std::string LLFloaterEditDayCycle::getRegionName() { diff --git a/indra/newview/llfloatereditdaycycle.h b/indra/newview/llfloatereditdaycycle.h index c6137ba432..a27bc69792 100644 --- a/indra/newview/llfloatereditdaycycle.h +++ b/indra/newview/llfloatereditdaycycle.h @@ -105,6 +105,7 @@ private: void onSaveConfirmed(); void onDayCycleListChange(); + void onSkyPresetListChange(); static std::string getRegionName(); diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp index 96dfb7a8a9..f78baf2ed5 100644 --- a/indra/newview/llfloatereditsky.cpp +++ b/indra/newview/llfloatereditsky.cpp @@ -131,6 +131,8 @@ void LLFloaterEditSky::initCallbacks(void) mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnSave, this)); getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); + LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditSky::onSkyPresetListChange, this)); + //------------------------------------------------------------------------- LLWLParamManager& param_mgr = LLWLParamManager::instance(); @@ -806,8 +808,8 @@ void LLFloaterEditSky::onSkyPresetSelected() if (!LLWLParamManager::instance().getParamSet(key, sky_params)) { - llwarns << "No sky preset named " << key.toString() << llendl; - llassert(false); + // Manually entered string? + LL_WARNS("Windlight") << "No sky preset named " << key.toString() << LL_ENDL; return; } @@ -904,3 +906,19 @@ void LLFloaterEditSky::onSaveConfirmed() closeFloater(); } + +void LLFloaterEditSky::onSkyPresetListChange() +{ + LLWLParamKey key = getSelectedSkyPreset(); // preset being edited + if (!LLWLParamManager::instance().hasParamSet(key)) + { + // Preset we've been editing doesn't exist anymore. Close the floater. + closeFloater(false); + } + else + { + // A new preset has been added. + // Refresh the presets list, though it may not make sense as the floater is about to be closed. + refreshSkyPresetsList(); + } +} diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h index 9a8feb5188..70a90fb5b3 100644 --- a/indra/newview/llfloatereditsky.h +++ b/indra/newview/llfloatereditsky.h @@ -96,6 +96,8 @@ private: void onBtnSave(); void onBtnCancel(); + void onSkyPresetListChange(); + LLLineEditor* mSkyPresetNameEditor; LLComboBox* mSkyPresetCombo; LLCheckBoxCtrl* mMakeDefaultCheckBox; 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; diff --git a/indra/newview/llfloaterenvironmentsettings.h b/indra/newview/llfloaterenvironmentsettings.h index 6d29a5d4d5..0953ab4a65 100644 --- a/indra/newview/llfloaterenvironmentsettings.h +++ b/indra/newview/llfloaterenvironmentsettings.h @@ -50,8 +50,6 @@ private: void onSelectSkyPreset(); void onSelectDayCyclePreset(); - void onDayCycleListChange(); - void onBtnOK(); void onBtnCancel(); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index ab164e7db0..567183b955 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3300,7 +3300,8 @@ BOOL LLPanelEnvironmentInfo::postBuild() LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::onDayCycleListChange, this)); + LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::populateDayCyclesList, this)); + LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateSkyPresetsList, this)); return TRUE; } @@ -3756,8 +3757,3 @@ void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) LLEnvManagerNew::instance().requestRegionSettings(); } } - -void LLPanelEnvironmentInfo::onDayCycleListChange() -{ - populateDayCyclesList(); -} diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 4f5222eb34..6075842e76 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -471,8 +471,6 @@ private: void onRegionSettingschange(); void onRegionSettingsApplied(bool ok); - void onDayCycleListChange(); - bool mEnableEditing; LLRadioGroup* mRegionSettingsRadioGroup; diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 80001525f8..e646b605a9 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -270,10 +270,10 @@ bool LLWLDayCycle::removeKeyframe(F32 time) return false; } -bool LLWLDayCycle::getKeytime(LLWLParamKey frame, F32& key_time) +bool LLWLDayCycle::getKeytime(LLWLParamKey frame, F32& key_time) const { // scroll through till we find the correct value in the map - std::map::iterator mIt = mTimeMap.begin(); + std::map::const_iterator mIt = mTimeMap.begin(); for(; mIt != mTimeMap.end(); ++mIt) { if(frame == mIt->second) @@ -315,6 +315,12 @@ bool LLWLDayCycle::getKeyedParamName(F32 time, std::string & name) return false; } +bool LLWLDayCycle::hasReferencesTo(const LLWLParamKey& keyframe) const +{ + F32 dummy; + return getKeytime(keyframe, dummy); +} + void LLWLDayCycle::removeReferencesTo(const LLWLParamKey& keyframe) { lldebugs << "Removing references to key frame " << keyframe.toLLSD() << llendl; diff --git a/indra/newview/llwldaycycle.h b/indra/newview/llwldaycycle.h index 9dbfad294a..c8585564ed 100644 --- a/indra/newview/llwldaycycle.h +++ b/indra/newview/llwldaycycle.h @@ -106,7 +106,7 @@ public: /// get the first key time for a parameter /// returns false if not there - bool getKeytime(LLWLParamKey keyFrame, F32& keyTime); + bool getKeytime(LLWLParamKey keyFrame, F32& keyTime) const; /// get the param set at a given time /// returns true if found one @@ -116,6 +116,9 @@ public: /// returns true if it found one bool getKeyedParamName(F32 time, std::string & name); + /// @return true if there are references to the given sky + bool hasReferencesTo(const LLWLParamKey& keyframe) const; + /// removes all references to the sky (paramkey) /// does nothing if the sky doesn't exist in the day void removeReferencesTo(const LLWLParamKey& keyframe); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 01aed7c0f1..df52f3328f 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -588,6 +588,7 @@ bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) llassert(!key.name.empty()); // *TODO: validate params mParamList[key] = param; + mPresetListChangeSignal(); return true; } @@ -596,19 +597,9 @@ bool LLWLParamManager::addParamSet(const LLWLParamKey& key, LLWLParamSet& param) BOOL LLWLParamManager::addParamSet(const LLWLParamKey& key, LLSD const & param) { - // add a new one if not one there already - std::map::const_iterator finder = mParamList.find(key); - if(finder == mParamList.end()) - { - llassert(!key.name.empty()); - // *TODO: validate params - mParamList[key].setAll(param); - return TRUE; - } - else - { - return FALSE; - } + LLWLParamSet param_set; + param_set.setAll(param); + return addParamSet(key, param_set); } bool LLWLParamManager::getParamSet(const LLWLParamKey& key, LLWLParamSet& param) @@ -652,14 +643,14 @@ bool LLWLParamManager::setParamSet(const LLWLParamKey& key, const LLSD & param) return false; } - mParamList[key].setAll(param); - - return true; + LLWLParamSet param_set; + param_set.setAll(param); + return setParamSet(key, param_set); } void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_disk) { - // *TODO: notify interested parties that a sky preset has been removed. + // *NOTE: Removing a sky preset invalidates day cycles that refer to it. if (key.scope == LLEnvKey::SCOPE_REGION) { @@ -669,18 +660,17 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_ } // remove from param list - std::map::iterator mIt = mParamList.find(key); - if(mIt != mParamList.end()) - { - mParamList.erase(mIt); - } - else + std::map::iterator it = mParamList.find(key); + if (it == mParamList.end()) { - LL_WARNS("WindLight") << "Unable to delete key " << key.toString() << "; not found." << LL_ENDL; + LL_WARNS("WindLight") << "No sky preset named " << key.name << LL_ENDL; + return; } + mParamList.erase(it); mDay.removeReferencesTo(key); + // remove from file system if requested if (delete_from_disk) { std::string path_name(getUserDir()); @@ -691,6 +681,9 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_ LL_WARNS("WindLight") << "Error removing sky preset " << key.name << " from disk" << LL_ENDL; } } + + // signal interested parties + mPresetListChangeSignal(); } bool LLWLParamManager::isSystemPreset(const std::string& preset_name) @@ -699,6 +692,11 @@ bool LLWLParamManager::isSystemPreset(const std::string& preset_name) return gDirUtilp->fileExists(getSysDir() + escapeString(preset_name) + ".xml"); } +boost::signals2::connection LLWLParamManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb) +{ + return mPresetListChangeSignal.connect(cb); +} + // virtual static void LLWLParamManager::initSingleton() { diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 06f56851b6..73bf97f392 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -215,7 +215,9 @@ public: class LLWLParamManager : public LLSingleton { LOG_CLASS(LLWLParamManager); + public: + typedef boost::signals2::signal preset_list_signal_t; /// save the parameter presets to file void savePreset(const LLWLParamKey key); @@ -287,6 +289,9 @@ public: /// @return true if the preset comes out of the box bool isSystemPreset(const std::string& preset_name); + /// Emitted when a preset gets added or deleted. + boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); + /// add all skies in LLSD using the given scope void addAllSkies(LLEnvKey::EScope scope, const LLSD& preset_map); @@ -370,6 +375,8 @@ private: /*virtual*/ void initSingleton(); LLWLParamManager(); ~LLWLParamManager(); + + preset_list_signal_t mPresetListChangeSignal; }; inline F32 LLWLParamManager::getDomeOffset(void) const diff --git a/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml b/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml index 82a541d40d..b5de4166f6 100644 --- a/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml +++ b/indra/newview/skins/default/xui/en/floater_delete_env_preset.xml @@ -17,7 +17,10 @@ Preset: Day cycle: - Are you sure you want to delete the selected preset? + Are you sure you want to delete the selected preset? + Cannot remove a preset that is referenced by some day cycle(s). + + -Select a preset- - - + width="200"/>