diff options
author | Oz Linden <oz@lindenlab.com> | 2011-05-26 20:26:36 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-05-26 20:26:36 -0400 |
commit | a99941a7fd55ad56144793957792cdb8bb0e5df6 (patch) | |
tree | 13fd8b6717f3d668f117957a136de33c9753ca44 | |
parent | 01ec64a1bc88ed0b1a18c559c136b32476309100 (diff) | |
parent | 6bc23e1be7e055b4f80f5c5de9dcd186a92a21a4 (diff) |
merge changes for latest windlight integration project repo
28 files changed, 1246 insertions, 142 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5a9ee92b0c..4921f2164c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -129,6 +129,7 @@ set(viewer_SOURCE_FILES llcurrencyuimanager.cpp llcylinder.cpp lldateutil.cpp + lldaycyclemanager.cpp lldebugmessagebox.cpp lldebugview.cpp lldelayedgestureerror.cpp @@ -179,7 +180,11 @@ set(viewer_SOURCE_FILES llfloatercamera.cpp llfloatercolorpicker.cpp llfloaterdaycycle.cpp + llfloaterdeleteenvpreset.cpp llfloaterdisplayname.cpp + llfloatereditdaycycle.cpp + llfloatereditsky.cpp + llfloatereditwater.cpp llfloaterenvsettings.cpp llfloaterenvironmentsettings.cpp llfloaterevent.cpp @@ -681,6 +686,7 @@ set(viewer_HEADER_FILES llcurrencyuimanager.h llcylinder.h lldateutil.h + lldaycyclemanager.h lldebugmessagebox.h lldebugview.h lldelayedgestureerror.h @@ -732,7 +738,11 @@ set(viewer_HEADER_FILES llfloatercamera.h llfloatercolorpicker.h llfloaterdaycycle.h + llfloaterdeleteenvpreset.h llfloaterdisplayname.h + llfloatereditdaycycle.h + llfloatereditsky.h + llfloatereditwater.h llfloaterenvsettings.h llfloaterenvironmentsettings.h llfloaterevent.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 <map> +#include <string> + +#include "llwldaycycle.h" +#include "llwlparammanager.h" + +/** + * WindLight day cycles manager class + * + * Provides interface for accessing, loading and saving day cycles. + */ +class LLDayCycleManager : public LLSingleton<LLDayCycleManager> +{ + LOG_CLASS(LLDayCycleManager); + +public: + typedef std::map<std::string, LLWLDayCycle> 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<LLDayCycleManager>; + /*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..d5d03ff1e5 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -37,6 +37,7 @@ #include "llagent.h" #include "llviewerregion.h" +#include "lldaycyclemanager.h" #include "llfloaterreg.h" #include "llfloaterwindlight.h" #include "llfloaterwater.h" @@ -668,6 +669,74 @@ const LLEnvironmentSettings& LLEnvManagerNew::getRegionSettings() const return mCachedRegionPrefs; } +bool LLEnvManagerNew::usePrefs() +{ + LL_DEBUGS("Windlight") << "Displaying preferred environment" << LL_ENDL; + updateManagersFromPrefs(false); + return true; +} + +bool LLEnvManagerNew::useDefaults() +{ + bool rslt = useWaterPreset("Default") && useDayCycle("Default", LLEnvKey::SCOPE_LOCAL); + return rslt; +} + +bool LLEnvManagerNew::useWaterPreset(const std::string& name) +{ + LL_DEBUGS("Windlight") << "Displaying water preset " << name << LL_ENDL; + LLWaterParamManager& water_mgr = LLWaterParamManager::instance(); + bool rslt = water_mgr.getParamSet(name, water_mgr.mCurParams); + llassert(rslt == true); + return rslt; +} + +bool LLEnvManagerNew::useWaterParams(const LLSD& params) +{ + LL_DEBUGS("Windlight") << "Displaying water params" << LL_ENDL; + LLWaterParamManager::instance().mCurParams.setAll(params); + return true; +} + +bool LLEnvManagerNew::useSkyParams(const LLSD& params) +{ + LL_DEBUGS("Windlight") << "Displaying sky params" << LL_ENDL; + LLWLParamManager::instance().applySkyParams(params); + return true; +} + +bool LLEnvManagerNew::useDayCycle(const std::string& name, LLEnvKey::EScope scope) +{ + LLSD params; + + if (scope == LLEnvKey::SCOPE_REGION) + { + LL_DEBUGS("Windlight") << "Displaying region day cycle " << name << LL_ENDL; + params = getRegionSettings().getWLDayCycle(); + } + else + { + LL_DEBUGS("Windlight") << "Displaying local day cycle " << name << LL_ENDL; + + if (!LLDayCycleManager::instance().getPreset(name, params)) + { + llwarns << "No day cycle named " << name << llendl; + return false; + } + } + + bool rslt = LLWLParamManager::instance().applyDayCycleParams(params, scope); + llassert(rslt == true); + return rslt; +} + +bool LLEnvManagerNew::useDayCycleParams(const LLSD& params, LLEnvKey::EScope scope) +{ + LL_DEBUGS("Windlight") << "Displaying day cycle params" << LL_ENDL; + LLWLParamManager::instance().applyDayCycleParams(params, scope); + return true; +} + void LLEnvManagerNew::setUseRegionSettings(bool val) { mUserPrefs.setUseDefaults(val); @@ -764,12 +833,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(); @@ -824,9 +887,14 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); mCachedRegionPrefs = new_settings; + // Load region sky presets. + LLWLParamManager::instance().refreshRegionPresets(); + // If using server settings, update managers. - // This also adds server skies to the WL param mgr. - updateManagersFromPrefs(mInterpNextChangeMessage); + if (getUseRegionSettings()) + { + updateManagersFromPrefs(mInterpNextChangeMessage); + } // Let interested parties know about the region settings update. mRegionSettingsChangeSignal(); diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index 52b645b535..21b771bed8 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -276,6 +276,15 @@ public: /// @return cached env. settings of the current region. const LLEnvironmentSettings& getRegionSettings() const; + // Change environment w/o changing user preferences. + bool usePrefs(); + bool useDefaults(); + bool useWaterPreset(const std::string& name); + bool useWaterParams(const LLSD& params); + bool useSkyParams(const LLSD& params); + bool useDayCycle(const std::string& name, LLEnvKey::EScope scope); + bool useDayCycleParams(const LLSD& params, LLEnvKey::EScope scope); + // setters for user env. preferences void setUseRegionSettings(bool val); void setUseWaterPreset(const std::string& name); @@ -293,9 +302,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/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<LLComboBox>("preset_combo"); + + getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnDelete, this)); + getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeleteEnvPreset::onBtnCancel, this)); + + // Deletion is not implemented yet, so disable the button for now. + getChild<LLButton>("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<LLUICtrl>("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<std::string, LLWaterParamSet> &water_params_map = water_mgr.mParamList; + for (std::map<std::string, LLWaterParamSet>::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<LLWLParamKey, LLWLParamSet> &sky_params_map = sky_mgr.mParamList; + for (std::map<LLWLParamKey, LLWLParamSet>::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/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp new file mode 100644 index 0000000000..6275b48203 --- /dev/null +++ b/indra/newview/llfloatereditdaycycle.cpp @@ -0,0 +1,73 @@ +/** + * @file llfloatereditdaycycle.cpp + * @brief Floater to create or edit a day cycle + * + * $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 "llfloatereditdaycycle.h" + +// libs +#include "llbutton.h" + +// newview + +LLFloaterEditDayCycle::LLFloaterEditDayCycle(const LLSD &key) +: LLFloater(key) +{ +} + +// virtual +BOOL LLFloaterEditDayCycle::postBuild() +{ + getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditDayCycle::onBtnCancel, this)); + + // Disable some non-functional controls. + getChildView("day_cycle_combo")->setEnabled(FALSE); + getChildView("save")->setEnabled(FALSE); + + return TRUE; +} + +// virtual +void LLFloaterEditDayCycle::onOpen(const LLSD& key) +{ + std::string param = key.asString(); + std::string floater_title = getString(std::string("title_") + param); + std::string hint = getString(std::string("hint_" + param)); + + // Update floater title. + setTitle(floater_title); + + // Update the hint at the top. + getChild<LLUICtrl>("hint")->setValue(hint); + + // Hide the hint to the right of the combo if we're invoked to create a new preset. + getChildView("note")->setVisible(param == "edit"); +} + +void LLFloaterEditDayCycle::onBtnCancel() +{ + closeFloater(); +} diff --git a/indra/newview/llfloatereditdaycycle.h b/indra/newview/llfloatereditdaycycle.h new file mode 100644 index 0000000000..d1caa05888 --- /dev/null +++ b/indra/newview/llfloatereditdaycycle.h @@ -0,0 +1,45 @@ +/** + * @file llfloatereditdaycycle.h + * @brief Floater to create or edit a day cycle + * + * $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_LLFLOATEREDITDAYCYCLE_H +#define LL_LLFLOATEREDITDAYCYCLE_H + +#include "llfloater.h" + +class LLFloaterEditDayCycle : public LLFloater +{ + LOG_CLASS(LLFloaterEditDayCycle); + +public: + LLFloaterEditDayCycle(const LLSD &key); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + + void onBtnCancel(); +}; + +#endif // LL_LLFLOATEREDITDAYCYCLE_H diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp new file mode 100644 index 0000000000..312479951e --- /dev/null +++ b/indra/newview/llfloatereditsky.cpp @@ -0,0 +1,73 @@ +/** + * @file llfloatereditsky.h + * @brief Floater to create or edit a sky 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 "llfloatereditsky.h" + +// libs +#include "llbutton.h" + +// newview + +LLFloaterEditSky::LLFloaterEditSky(const LLSD &key) +: LLFloater(key) +{ +} + +// virtual +BOOL LLFloaterEditSky::postBuild() +{ + getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditSky::onBtnCancel, this)); + + // Disable some non-functional controls. + getChildView("sky_preset_combo")->setEnabled(FALSE); + getChildView("save")->setEnabled(FALSE); + + return TRUE; +} + +// virtual +void LLFloaterEditSky::onOpen(const LLSD& key) +{ + std::string param = key.asString(); + std::string floater_title = getString(std::string("title_") + param); + std::string hint = getString(std::string("hint_" + param)); + + // Update floater title. + setTitle(floater_title); + + // Update the hint at the top. + getChild<LLUICtrl>("hint")->setValue(hint); + + // Hide the hint to the right of the combo if we're invoked to create a new preset. + getChildView("note")->setVisible(param == "edit"); +} + +void LLFloaterEditSky::onBtnCancel() +{ + closeFloater(); +} diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h new file mode 100644 index 0000000000..a78f049d84 --- /dev/null +++ b/indra/newview/llfloatereditsky.h @@ -0,0 +1,45 @@ +/** + * @file llfloatereditsky.h + * @brief Floater to create or edit a sky 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_LLFLOATEREDITSKY_H +#define LL_LLFLOATEREDITSKY_H + +#include "llfloater.h" + +class LLFloaterEditSky : public LLFloater +{ + LOG_CLASS(LLFloaterEditSky); + +public: + LLFloaterEditSky(const LLSD &key); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + + void onBtnCancel(); +}; + +#endif // LL_LLFLOATEREDITSKY_H diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp new file mode 100644 index 0000000000..4007c27066 --- /dev/null +++ b/indra/newview/llfloatereditwater.cpp @@ -0,0 +1,73 @@ +/** + * @file llfloatereditwater.cpp + * @brief Floater to create or edit a water 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 "llfloatereditwater.h" + +// libs +#include "llbutton.h" + +// newview + +LLFloaterEditWater::LLFloaterEditWater(const LLSD &key) +: LLFloater(key) +{ +} + +// virtual +BOOL LLFloaterEditWater::postBuild() +{ + getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditWater::onBtnCancel, this)); + + // Disable some non-functional controls. + getChildView("water_preset_combo")->setEnabled(FALSE); + getChildView("save")->setEnabled(FALSE); + + return TRUE; +} + +// virtual +void LLFloaterEditWater::onOpen(const LLSD& key) +{ + std::string param = key.asString(); + std::string floater_title = getString(std::string("title_") + param); + std::string hint = getString(std::string("hint_" + param)); + + // Update floater title. + setTitle(floater_title); + + // Update the hint at the top. + getChild<LLUICtrl>("hint")->setValue(hint); + + // Hide the hint to the right of the combo if we're invoked to create a new preset. + getChildView("note")->setVisible(param == "edit"); +} + +void LLFloaterEditWater::onBtnCancel() +{ + closeFloater(); +} diff --git a/indra/newview/llfloatereditwater.h b/indra/newview/llfloatereditwater.h new file mode 100644 index 0000000000..a904555787 --- /dev/null +++ b/indra/newview/llfloatereditwater.h @@ -0,0 +1,45 @@ +/** + * @file llfloatereditwater.h + * @brief Floater to create or edit a water 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_LLFLOATEREDITWATER_H +#define LL_LLFLOATEREDITWATER_H + +#include "llfloater.h" + +class LLFloaterEditWater : public LLFloater +{ + LOG_CLASS(LLFloaterEditWater); + +public: + LLFloaterEditWater(const LLSD &key); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + + void onBtnCancel(); +}; + +#endif // LL_LLFLOATEREDITWATER_H diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp index cbbbed9830..2149103792 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" @@ -196,6 +197,7 @@ void LLFloaterEnvironmentSettings::populateSkyPresetsList() const std::map<LLWLParamKey, LLWLParamSet> &sky_params_map = LLWLParamManager::getInstance()->mParamList; for (std::map<LLWLParamKey, LLWLParamSet>::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); } } @@ -204,6 +206,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 7c26b3e29d..e2f661c809 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" @@ -1204,7 +1205,7 @@ F32 LLPanelRegionTerrainInfo::getSunHour() // virtual bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) { - LLEnvManager::instance().maybeClearEditingScope(LLEnvKey::SCOPE_REGION, false, false); + //LLEnvManager::instance().maybeClearEditingScope(LLEnvKey::SCOPE_REGION, false, false); BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); @@ -2168,7 +2169,7 @@ void LLFloaterRegionInfo::onClose(bool app_quitting) { if(!app_quitting) { - LLEnvManager::getInstance()->maybeClearEditingScope(true, false); + //LLEnvManager::getInstance()->maybeClearEditingScope(true, false); LLPanelRegionTerrainInfo::onFloaterClose(app_quitting); } } @@ -3278,10 +3279,15 @@ BOOL LLPanelEnvironmentInfo::postBuild() mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDayCycle, this)); mWaterPresetCombo = getChild<LLComboBox>("water_settings_preset_combo"); + mWaterPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectWaterPreset, this)); + mSkyPresetCombo = getChild<LLComboBox>("sky_settings_preset_combo"); + mSkyPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectSkyPreset, this)); + mDayCyclePresetCombo = getChild<LLComboBox>("dayc_settings_preset_combo"); + mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); - childSetCommitCallback("save_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnSave, this), NULL); + childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); @@ -3298,6 +3304,17 @@ void LLPanelEnvironmentInfo::onOpen(const LLSD& key) } // virtual +void LLPanelEnvironmentInfo::handleVisibilityChange(BOOL new_visibility) +{ + // If hiding (user switched to another tab or closed the floater), + // display user's preferred environment. + if (!new_visibility) + { + LLEnvManagerNew::instance().usePrefs(); + } +} + +// virtual bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) { LL_DEBUGS("Windlight") << "Region updated, enabling/disabling controls" << LL_ENDL; @@ -3337,14 +3354,18 @@ void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) mSkyPresetCombo->setEnabled(enabled); mDayCyclePresetCombo->setEnabled(enabled); - getChildView("save_btn")->setEnabled(enabled); + getChildView("apply_btn")->setEnabled(enabled); getChildView("cancel_btn")->setEnabled(enabled); if (enabled) { // Enable/disable some controls based on currently selected radio buttons. - LLPanelEnvironmentInfo::onSwitchRegionSettings(); - LLPanelEnvironmentInfo::onSwitchDayCycle(); + bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); + + bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + mSkyPresetCombo->setEnabled(is_fixed_sky); + mDayCyclePresetCombo->setEnabled(!is_fixed_sky); } } @@ -3431,21 +3452,113 @@ 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. } +bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params) +{ + LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); + + if (water_key.scope == LLEnvKey::SCOPE_REGION) + { + water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams(); + } + else + { + LLWaterParamSet param_set; + if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) + { + llwarns << "Error getting water preset: " << water_key.name << llendl; + return false; + } + + water_params = param_set.getAll(); + } + + return true; +} + +bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& preset_name) +{ + std::string preset_key(mSkyPresetCombo->getValue().asString()); + LLWLParamKey preset(preset_key); + + // Get the preset sky params. + LLWLParamSet param_set; + if (!LLWLParamManager::instance().getParamSet(preset, param_set)) + { + llwarns << "Error getting sky params: " << preset.toLLSD() << llendl; + return false; + } + + sky_params = param_set.getAll(); + preset_name = preset.name; + return true; +} + +bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope) +{ + 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 + { + const LLEnvironmentSettings& cur_region_settings = LLEnvManagerNew::instance().getRegionSettings(); + day_cycle = cur_region_settings.getWLDayCycle(); + sky_map = cur_region_settings.getSkyMap(); + } + else // a local day cycle + { + if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) + { + llwarns << "Error getting day cycle " << dc.name << llendl; + return false; + } + + // Create sky map from the day cycle. + { + std::map<LLWLParamKey, LLWLParamSet> refs; + LLWLDayCycle tmp_day; + + tmp_day.loadDayCycle(day_cycle, dc.scope); + tmp_day.getSkyRefs(refs); + + sky_map = LLWLParamManager::createSkyMap(refs); + } + } + + scope = dc.scope; + + return true; +} void LLPanelEnvironmentInfo::onSwitchRegionSettings() { - getChild<LLView>("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0); + bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); + + if (use_defaults) + { + LLEnvManagerNew::instance().useDefaults(); + } + else + { + onSelectWaterPreset(); + onSwitchDayCycle(); + } } void LLPanelEnvironmentInfo::onSwitchDayCycle() @@ -3454,13 +3567,52 @@ void LLPanelEnvironmentInfo::onSwitchDayCycle() mSkyPresetCombo->setEnabled(is_fixed_sky); mDayCyclePresetCombo->setEnabled(!is_fixed_sky); + + if (is_fixed_sky) + { + onSelectSkyPreset(); + } + else + { + onSelectDayCycle(); + } } -void LLPanelEnvironmentInfo::onBtnSave() +void LLPanelEnvironmentInfo::onSelectWaterPreset() { - LL_DEBUGS("Windlight") << "About to save region settings" << LL_ENDL; + LLSD water_params; + + if (getSelectedWaterParams(water_params)) + { + LLEnvManagerNew::instance().useWaterParams(water_params); + } +} + +void LLPanelEnvironmentInfo::onSelectSkyPreset() +{ + LLSD params; + std::string dummy; + + if (getSelectedSkyParams(params, dummy)) + { + LLEnvManagerNew::instance().useSkyParams(params); + } +} - const LLEnvironmentSettings& old_region_settings = LLEnvManagerNew::instance().getRegionSettings(); +void LLPanelEnvironmentInfo::onSelectDayCycle() +{ + LLSD day_cycle; + LLSD sky_map; // unused + short scope; + + if (getSelectedDayCycleParams(day_cycle, sky_map, scope)) + { + LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); + } +} + +void LLPanelEnvironmentInfo::onBtnApply() +{ const bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; const bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; @@ -3478,75 +3630,54 @@ void LLPanelEnvironmentInfo::onBtnSave() if (use_fixed_sky) { LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL; - std::string preset_key(mSkyPresetCombo->getValue().asString()); - LLWLParamKey preset(preset_key); - // Get the preset sky params. - LLWLParamSet params; - if (!LLWLParamManager::instance().getParamSet(preset, params)) + // Get selected sky params. + LLSD params; + std::string preset_name; + if (!getSelectedSkyParams(params, preset_name)) { - llwarns << "Error getting sky params: " << preset.toLLSD() << llendl; return; } // Create a day cycle consisting of a single sky preset. LLSD key(LLSD::emptyArray()); key.append(-1.0f); // indicate that user preference is actually fixed sky, not a day cycle - key.append(preset.name); + key.append(preset_name); day_cycle.append(key); // Create a sky map consisting of only the sky preset. std::map<LLWLParamKey, LLWLParamSet> refs; - refs[preset] = params; + LLWLParamSet param_set; + param_set.setAll(params); + refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here sky_map = LLWLParamManager::createSkyMap(refs); } else // use day cycle { - LLWLParamKey dc(mDayCyclePresetCombo->getValue()); - LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; + LL_DEBUGS("Windlight") << "Use day cycle" << LL_ENDL; - if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle + short scope; // unused + if (!getSelectedDayCycleParams(day_cycle, sky_map, scope)) { - day_cycle = old_region_settings.getWLDayCycle(); - sky_map = old_region_settings.getSkyMap(); + return; } - else // a local day cycle - { - // *TODO: multiple local day cycles support - day_cycle = LLEnvManagerNew::instance().getDayCycleByName("Default"); - - // Create sky map from the day cycle. - { - std::map<LLWLParamKey, LLWLParamSet> refs; - LLWLDayCycle tmp_day; - - tmp_day.loadDayCycle(day_cycle, dc.scope); - tmp_day.getSkyRefs(refs); - sky_map = LLWLParamManager::createSkyMap(refs); - } - - LL_DEBUGS("Windlight") << "day_cycle: " << day_cycle << LL_ENDL; - LL_DEBUGS("Windlight") << "sky_map: " << sky_map << LL_ENDL; + // If it's a special single-preset day cycle meaning using a fixed sky, + // reset the frame time to a non-negative value, + // so that the region setting is displayed in the floater as + // a day cycle, not a preset. (STORM-1289) + if (day_cycle.size() == 1 && day_cycle[0][0].asReal() < 0.0f) + { + LL_DEBUGS("Windlight") << "Fixing negative time" << LL_ENDL; + day_cycle[0][0] = 0.0f; } } // Get water params. - LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); - if (water_key.scope == LLEnvKey::SCOPE_REGION) - { - water_params = old_region_settings.getWaterParams(); - } - else + if (!getSelectedWaterParams(water_params)) { - LLWaterParamSet param_set; - if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) - { - llwarns << "Error getting water preset: " << water_key.name << llendl; - return; - } - - water_params = param_set.getAll(); + // *TODO: show a notification? + return; } } @@ -3564,8 +3695,16 @@ void LLPanelEnvironmentInfo::onBtnSave() void LLPanelEnvironmentInfo::onBtnCancel() { - // Reload current region settings. + // Reload last saved region settings. refresh(); + + // Apply them. + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + const LLEnvironmentSettings& cur_settings = env_mgr.getRegionSettings(); + const LLSD& region_day_cycle = cur_settings.getWLDayCycle(); + const LLSD& region_water = cur_settings.getWaterParams(); + env_mgr.useWaterParams(region_water); + env_mgr.useDayCycleParams(region_day_cycle, LLEnvKey::SCOPE_REGION); } void LLPanelEnvironmentInfo::onRegionSettingschange() diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 31b68ec030..324b3fb157 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -438,6 +438,9 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); + // LLView + /*virtual*/ void handleVisibilityChange(BOOL new_visibility); + // LLPanelRegionInfo /*virtual*/ bool refreshFromRegion(LLViewerRegion* region); @@ -450,10 +453,18 @@ private: void populateSkyPresetsList(); void populateDayCyclesList(); + bool getSelectedWaterParams(LLSD& water_params); + bool getSelectedSkyParams(LLSD& sky_params, std::string& preset_name); + bool getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope); + void onSwitchRegionSettings(); void onSwitchDayCycle(); - void onBtnSave(); + void onSelectWaterPreset(); + void onSelectSkyPreset(); + void onSelectDayCycle(); + + void onBtnApply(); void onBtnCancel(); void onRegionSettingschange(); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 3678bd905d..670b35aa71 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -49,7 +49,11 @@ #include "llfloaterbump.h" #include "llfloatercamera.h" #include "llfloaterdaycycle.h" +#include "llfloaterdeleteenvpreset.h" #include "llfloaterdisplayname.h" +#include "llfloatereditdaycycle.h" +#include "llfloatereditsky.h" +#include "llfloatereditwater.h" #include "llfloaterenvironmentsettings.h" #include "llfloaterevent.h" #include "llfloatersearch.h" @@ -186,6 +190,10 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEnvironmentSettings>); LLFloaterReg::add("env_water", "floater_water.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWater>); LLFloaterReg::add("env_windlight", "floater_windlight_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWindLight>); + LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteEnvPreset>); + LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditSky>); + LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>); + LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>); LLFloaterReg::add("event", "floater_event.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEvent>); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 87cfcbef05..36c14ca938 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7650,6 +7650,57 @@ 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") + { + LLFloaterReg::showInstance("env_edit_water", "new"); + } + else if (item == "edit_water") + { + LLFloaterReg::showInstance("env_edit_water", "edit"); + } + else if (item == "delete_water") + { + LLFloaterReg::showInstance("env_delete_preset", "water"); + } + else if (item == "new_sky") + { + LLFloaterReg::showInstance("env_edit_sky", "new"); + } + else if (item == "edit_sky") + { + LLFloaterReg::showInstance("env_edit_sky", "edit"); + } + else if (item == "delete_sky") + { + LLFloaterReg::showInstance("env_delete_preset", "sky"); + } + else if (item == "new_day_cycle") + { + LLFloaterReg::showInstance("env_edit_day_cycle", "new"); + } + else if (item == "edit_day_cycle") + { + LLFloaterReg::showInstance("env_edit_day_cycle", "edit"); + } + 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 { @@ -7898,6 +7949,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/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..db81c3ead7 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" @@ -255,6 +256,15 @@ void LLWLParamManager::addAllSkies(const LLWLParamKey::EScope scope, const LLSD& } } +void LLWLParamManager::refreshRegionPresets() +{ + // Remove all region sky presets because they may belong to a previously visited region. + clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); + + // Add all sky presets belonging to the current region. + addAllSkies(LLEnvKey::SCOPE_REGION, LLEnvManagerNew::instance().getRegionSettings().getSkyMap()); +} + void LLWLParamManager::loadPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); @@ -586,16 +596,11 @@ void LLWLParamManager::update(LLViewerCamera * cam) void LLWLParamManager::applyUserPrefs(bool interpolate) { - // Remove all region sky presets because they may belong to a previously visited region. - clearParamSetsOfScope(LLEnvKey::SCOPE_REGION); + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - // Add all sky presets belonging to the current region. - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap()); - - if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings + if (env_mgr.getUseRegionSettings()) // apply region-wide settings { - if (region_settings.getSkyMap().size() == 0) + if (env_mgr.getRegionSettings().getSkyMap().size() == 0) { applyDefaults(); } @@ -605,36 +610,58 @@ void LLWLParamManager::applyUserPrefs(bool interpolate) LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL; // Apply region day cycle. - mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION); - resetAnimator(region_settings.getDayTime(), true); + const LLEnvironmentSettings& region_settings = env_mgr.getRegionSettings(); + applyDayCycleParams( + region_settings.getWLDayCycle(), + LLEnvKey::SCOPE_REGION, + region_settings.getDayTime()); } } else // apply user-specified settings { - if (LLEnvManagerNew::instance().getUseDayCycle()) + if (env_mgr.getUseDayCycle()) { - applyDayCycle(LLEnvManagerNew::instance().getDayCycleName()); + if (!env_mgr.useDayCycle(env_mgr.getDayCycleName(), LLEnvKey::SCOPE_LOCAL)) + { + // *TODO: fix user prefs + applyDefaults(); + } } else { - mAnimator.deactivate(); - std::string sky = LLEnvManagerNew::instance().getSkyPresetName(); - LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; - getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams); + LLWLParamSet param_set; + std::string sky = env_mgr.getSkyPresetName(); + + if (!getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), param_set)) + { + llwarns << "No sky named " << sky << llendl; + } + else + { + LL_DEBUGS("Windlight") << "Loading fixed sky " << sky << LL_ENDL; + applySkyParams(param_set.getAll()); + } } } } void LLWLParamManager::applyDefaults() { - applyDayCycle("Default"); + LLEnvManagerNew::instance().useDayCycle("Default", LLEnvKey::SCOPE_LOCAL); } -void LLWLParamManager::applyDayCycle(const std::string& day_cycle) +bool LLWLParamManager::applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time) { - LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL; - mDay.loadDayCycleFromFile(day_cycle + ".xml"); - resetAnimator(0.5, true); // set to noon and start animator + mDay.loadDayCycle(params, scope); + resetAnimator(time, true); // set to specified time and start animator + return true; +} + +bool LLWLParamManager::applySkyParams(const LLSD& params) +{ + mAnimator.deactivate(); + mCurParams.setAll(params); + return true; } void LLWLParamManager::resetAnimator(F32 curTime, bool run) diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 35acb7c5d6..7903661a7e 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -245,8 +245,11 @@ public: /// apply default sky params void applyDefaults(); - /// apply default sky params - void applyDayCycle(const std::string& day); + /// apply specified day cycle, setting time to noon by default + bool applyDayCycleParams(const LLSD& params, LLEnvKey::EScope scope, F32 time = 0.5); + + /// apply specified fixed sky params + bool applySkyParams(const LLSD& params); // get where the light is pointing inline LLVector4 getLightDir(void) const; @@ -288,6 +291,9 @@ public: /// add all skies in LLSD using the given scope void addAllSkies(LLEnvKey::EScope scope, const LLSD& preset_map); + /// refresh region-scope presets + void refreshRegionPresets(); + // returns all skies referenced by the current day cycle (in mDay), with their final names // side effect: applies changes to all internal structures! (trashes all unreferenced skies in scope, keys in day cycle rescoped to scope, etc.) std::map<LLWLParamKey, LLWLParamSet> finalizeFromDayCycle(LLWLParamKey::EScope scope); 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 @@ <floater legacy_header_height="18" height="130" - help_topic="environment_editor_floater" + help_topic="" layout="topleft" - name="Environment Editor Floater" + name="Delete Env Preset" save_rect="true" - title="DELETE PRESETS" + title="DELETE ENV PRESET" width="550"> + + <string name="title_water">Delete Water Preset</string> + <string name="title_sky">Delete Sky Preset</string> + <string name="title_day_cycle">Delete Day Cycle</string> + + <string name="label_water">Preset:</string> + <string name="label_sky">Preset:</string> + <string name="label_day_cycle">Day cycle:</string> + <text follows="top|left|right" font="SansSerif" height="10" layout="topleft" left="50" - name="delete_preset" + name="label" top="60" width="60"> - Setting: + Preset: </text> <combo_box follows="top|left" diff --git a/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml index e76059751e..7572efea05 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_day_cycle.xml @@ -3,17 +3,23 @@ legacy_header_height="18" height="450" layout="topleft" - name="Environment Editor Floater" - help_topic="environment_editor_floater" + name="Edit Day cycle" + help_topic="" save_rect="true" title="Edit Day Cycle" width="800"> + + <string name="title_new">Create a New Day Cycle</string> + <string name="title_edit">Edit Day Cycle</string> + <string name="hint_new">Name your day cycle, adjust the controls to create it, and click "Save".</string> + <string name="hint_edit">To edit your day cycle, adjust the controls below and click "Save".</string> + <text follows="top|left|right" height="10" layout="topleft" left="30" - name="info_string" + name="hint" top="25" width="700"> To edit your preset, adjust the controls then click "Save" @@ -24,7 +30,7 @@ height="10" layout="topleft" left="30" - name="info_string" + name="label" top_pad="25" width="120"> Preset Name: @@ -34,7 +40,7 @@ follows="top|left" layout="topleft" left_pad="10" - name="water_preset_combo" + name="day_cycle_combo" top_delta="-5" width="200"> <combo_box.item @@ -47,7 +53,7 @@ height="40" layout="topleft" left_pad="10" - name="info_string" + name="note" top_delta="0" width="405" wrap="true"> @@ -452,7 +458,7 @@ <check_box follows="top|left" height="10" - label="Make this preset my new water setting" + label="Make this my new day cycle" layout="topleft" left="330" name="new_water_preset_chb" diff --git a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml index 7ddb7ac1e1..ae7e83ee56 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml @@ -3,17 +3,23 @@ legacy_header_height="18" height="375" layout="topleft" - name="Environment Editor Floater" - help_topic="environment_editor_floater" + name="Edit Sky Preset" + help_topic="" save_rect="true" title="Edit Sky Preset" width="900"> + + <string name="title_new">Create a New Sky Preset</string> + <string name="title_edit">Edit Sky Preset</string> + <string name="hint_new">Name your preset, adjust the controls to create it, and click "Save".</string> + <string name="hint_edit">To edit your sky preset, adjust the controls and click "Save".</string> + <text follows="top|left|right" height="10" layout="topleft" left="30" - name="info_string" + name="hint" top="25" width="700"> To edit your preset, adjust the controls then click "Save" @@ -24,7 +30,7 @@ height="10" layout="topleft" left="30" - name="info_string" + name="label" top_pad="25" width="120"> Preset Name: @@ -34,7 +40,7 @@ follows="top|left" layout="topleft" left_pad="10" - name="water_preset_combo" + name="sky_preset_combo" top_delta="-5" width="200"> <combo_box.item @@ -47,7 +53,7 @@ height="40" layout="topleft" left_pad="10" - name="info_string" + name="note" top_delta="0" width="405" wrap="true"> diff --git a/indra/newview/skins/default/xui/en/floater_edit_water_preset.xml b/indra/newview/skins/default/xui/en/floater_edit_water_preset.xml index a29c725ee9..cf4e224835 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_water_preset.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_water_preset.xml @@ -3,18 +3,23 @@ legacy_header_height="18" height="450" layout="topleft" - name="Environment Editor Floater" - help_topic="environment_editor_floater" + name="Edit Water Preset" + help_topic="" save_rect="true" title="Edit Water Preset" width="900"> - + + <string name="title_new">Create a New Water Preset</string> + <string name="title_edit">Edit a Water Preset</string> + <string name="hint_new">Name your preset, adjust the controls to create it, and click "Save".</string> + <string name="hint_edit">To edit your water preset, adjust the controls and click "Save".</string> + <text follows="top|left|right" height="10" layout="topleft" left="30" - name="info_string" + name="hint" top="25" width="700"> To edit your preset, adjust the controls then click "Save" @@ -26,7 +31,7 @@ height="10" layout="topleft" left="30" - name="info_string" + name="label" top_pad="25" width="120"> Preset Name: @@ -51,7 +56,7 @@ height="40" layout="topleft" left_pad="10" - name="info_string" + name="note" top_delta="0" width="405" wrap="true"> diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 093a5e36d3..d8aec81eba 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -539,22 +539,22 @@ label="New preset..." name="new_water_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="new_water"/> </menu_item_call> <menu_item_call label="Edit preset..." name="edit_water_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="edit_water"/> </menu_item_call> <menu_item_call label="Delete preset..." name="delete_water_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="delete_water"/> </menu_item_call> </menu> @@ -565,22 +565,22 @@ label="New preset..." name="new_sky_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="new_sky"/> </menu_item_call> <menu_item_call label="Edit preset..." name="edit_sky_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="edit_sky"/> </menu_item_call> <menu_item_call label="Delete preset..." name="delete_sky_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="delete_sky"/> </menu_item_call> </menu> @@ -591,22 +591,22 @@ label="New preset..." name="new_day_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="new_day_cycle"/> </menu_item_call> <menu_item_call label="Edit preset..." name="edit_day_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="edit_day_cycle"/> </menu_item_call> <menu_item_call label="Delete preset..." name="delete_day_preset"> <menu_item_call.on_click - function="stub" - parameter="stub"/> + function="World.EnvPreset" + parameter="delete_day_cycle"/> </menu_item_call> </menu> </menu> diff --git a/indra/newview/skins/default/xui/en/panel_region_environment.xml b/indra/newview/skins/default/xui/en/panel_region_environment.xml index 956ba53a26..91d0bbe6bf 100644 --- a/indra/newview/skins/default/xui/en/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml @@ -123,10 +123,10 @@ <button follows="left|top" height="23" - label="Save" + label="Apply" layout="topleft" right="-160" - name="save_btn" + name="apply_btn" top_pad="150" width="100" /> <button |