summaryrefslogtreecommitdiff
path: root/indra/newview/llenvmanager.cpp
diff options
context:
space:
mode:
authorVadim ProductEngine <vsavchuk@productengine.com>2011-05-16 17:17:01 +0300
committerVadim ProductEngine <vsavchuk@productengine.com>2011-05-16 17:17:01 +0300
commitcccca566bd2365c88cca819729c5432af9dfa52f (patch)
tree8d81a737b1c6bf087a4d7330f1948155f554fcf2 /indra/newview/llenvmanager.cpp
parent0d7ea0e5abb4df0a18f1d8b73cce81dc2070afad (diff)
STORM-1245 WIP Reimplementing management of local presets according to the new spec.
User environment preferences are now persistent. TODO: Implement applying region env. settings.
Diffstat (limited to 'indra/newview/llenvmanager.cpp')
-rw-r--r--indra/newview/llenvmanager.cpp231
1 files changed, 231 insertions, 0 deletions
diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp
index c855d8597c..49bbf1a77c 100644
--- a/indra/newview/llenvmanager.cpp
+++ b/indra/newview/llenvmanager.cpp
@@ -52,6 +52,8 @@ extern LLControlGroup gSavedSettings;
/*virtual*/ void LLEnvManager::initSingleton()
{
+ LL_DEBUGS("Windlight") << "Initializing LLEnvManager" << LL_ENDL;
+
mOrigSettingStore[LLEnvKey::SCOPE_LOCAL] = lindenDefaults();
mCurNormalScope = (gSavedSettings.getBOOL("UseEnvironmentFromRegion") ? LLEnvKey::SCOPE_REGION : LLEnvKey::SCOPE_LOCAL);
mInterpNextChangeMessage = true;
@@ -557,3 +559,232 @@ void LLEnvManager::dumpScopes()
scope_dump = makePacket(LLEnvKey::SCOPE_REGION, LLSD());
LL_DEBUGS("Windlight") << "Region scope:" << scope_dump << LL_ENDL;
}
+
+
+//=============================================================================
+
+std::string LLEnvPrefs::getWaterPresetName() const
+{
+ if (mWaterPresetName.empty())
+ {
+ llwarns << "Water preset name is empty" << llendl;
+ }
+
+ return mWaterPresetName;
+}
+
+std::string LLEnvPrefs::getSkyPresetName() const
+{
+ if (mSkyPresetName.empty())
+ {
+ llwarns << "Sky preset name is empty" << llendl;
+ }
+
+ return mSkyPresetName;
+}
+
+std::string LLEnvPrefs::getDayCycleName() const
+{
+ if (mDayCycleName.empty())
+ {
+ llwarns << "Day cycle name is empty" << llendl;
+ }
+
+ return mDayCycleName;
+}
+
+void LLEnvPrefs::setUseDefaults(bool val)
+{
+ mUseDefaults = val;
+}
+
+void LLEnvPrefs::setUseWaterPreset(const std::string& name)
+{
+ setUseDefaults(false);
+ mWaterPresetName = name;
+}
+
+void LLEnvPrefs::setUseSkyPreset(const std::string& name)
+{
+ setUseDefaults(false);
+ mUseDayCycle = false;
+ mSkyPresetName = name;
+}
+
+void LLEnvPrefs::setUseDayCycle(const std::string& name)
+{
+ setUseDefaults(false);
+ mUseDayCycle = true;
+ mDayCycleName = name;
+}
+
+//=============================================================================
+LLEnvManagerNew::LLEnvManagerNew()
+{
+ mInterpNextChangeMessage = true;
+
+ // Set default environment settings.
+ mUserPrefs.mUseDefaults = true;
+ mUserPrefs.mUseDayCycle = true;
+ mUserPrefs.mWaterPresetName = "Default";
+ mUserPrefs.mSkyPresetName = "Default";
+ mUserPrefs.mDayCycleName = "Default";
+}
+
+bool LLEnvManagerNew::getUseRegionSettings() const
+{
+ return mUserPrefs.getUseDefaults();
+}
+
+bool LLEnvManagerNew::getUseDayCycle() const
+{
+ return mUserPrefs.getUseDayCycle();
+}
+
+bool LLEnvManagerNew::getUseFixedSky() const
+{
+ return mUserPrefs.getUseFixedSky();
+}
+
+std::string LLEnvManagerNew::getWaterPresetName() const
+{
+ return mUserPrefs.getWaterPresetName();
+}
+
+std::string LLEnvManagerNew::getSkyPresetName() const
+{
+ return mUserPrefs.getSkyPresetName();
+}
+
+std::string LLEnvManagerNew::getDayCycleName() const
+{
+ return mUserPrefs.getDayCycleName();
+}
+
+void LLEnvManagerNew::setUseRegionSettings(bool val)
+{
+ mUserPrefs.setUseDefaults(val);
+ saveUserPrefs();
+ updateManagersFromPrefs();
+}
+
+void LLEnvManagerNew::setUseWaterPreset(const std::string& name)
+{
+ if (name.empty())
+ {
+ llwarns << "Empty water preset name passed" << llendl;
+ return;
+ }
+
+ mUserPrefs.setUseWaterPreset(name);
+ saveUserPrefs();
+ updateManagersFromPrefs();
+}
+
+void LLEnvManagerNew::setUseSkyPreset(const std::string& name)
+{
+ if (name.empty())
+ {
+ llwarns << "Empty sky preset name passed" << llendl;
+ return;
+ }
+
+ mUserPrefs.setUseSkyPreset(name);
+ saveUserPrefs();
+ updateManagersFromPrefs();
+}
+
+void LLEnvManagerNew::setUseDayCycle(const std::string& name)
+{
+ if (name.empty())
+ {
+ llwarns << "Empty day cycle name passed" << llendl;
+ return;
+ }
+
+ mUserPrefs.setUseDayCycle(name);
+ saveUserPrefs();
+ updateManagersFromPrefs();
+}
+
+void LLEnvManagerNew::loadUserPrefs()
+{
+ // operate on members directly to avoid side effects
+ mUserPrefs.mWaterPresetName = gSavedSettings.getString("WaterPresetName");
+ mUserPrefs.mSkyPresetName = gSavedSettings.getString("SkyPresetName");
+ mUserPrefs.mDayCycleName = gSavedSettings.getString("DayCycleName");
+
+ mUserPrefs.mUseDefaults = gSavedSettings.getBOOL("UseEnvironmentFromRegion");
+ mUserPrefs.mUseDayCycle = gSavedSettings.getBOOL("UseDayCycle");
+}
+
+void LLEnvManagerNew::saveUserPrefs()
+{
+ gSavedSettings.setString("WaterPresetName", getWaterPresetName());
+ gSavedSettings.setString("SkyPresetName", getSkyPresetName());
+ gSavedSettings.setString("DayCycleName", getDayCycleName());
+
+ gSavedSettings.setBOOL("UseEnvironmentFromRegion", getUseRegionSettings());
+ gSavedSettings.setBOOL("UseDayCycle", getUseDayCycle());
+}
+
+void LLEnvManagerNew::onRegionCrossing()
+{
+ LL_DEBUGS("Windlight") << "Crossed region" << LL_ENDL;
+ onRegionChange(true);
+}
+
+void LLEnvManagerNew::onLogin()
+{
+ LL_DEBUGS("Windlight") << "Logged in" << LL_ENDL;
+ onRegionChange(false);
+}
+
+void LLEnvManagerNew::onTeleport()
+{
+ LL_DEBUGS("Windlight") << "Teleported" << LL_ENDL;
+ onRegionChange(false);
+}
+
+//-- private methods ----------------------------------------------------------
+
+// virtual
+void LLEnvManagerNew::initSingleton()
+{
+ LL_DEBUGS("Windlight") << "Initializing LLEnvManagerNew" << LL_ENDL;
+
+ loadUserPrefs();
+}
+
+void LLEnvManagerNew::updateManagersFromPrefs()
+{
+ // *TODO: apply region settings if user preferences say to do so.
+
+ // Apply water settings.
+ LLWaterParamManager::instance().applyUserPrefs();
+
+ // Apply sky settings.
+ LLWLParamManager::instance().applyUserPrefs();
+}
+
+void LLEnvManagerNew::sendRegionSettingsRequest()
+{
+}
+
+void LLEnvManagerNew::onRegionChange(bool interpolate)
+{
+ mInterpNextChangeMessage = interpolate;
+ sendRegionSettingsRequest();
+}
+
+void LLEnvManagerNew::onRegionSettingsResponse()
+{
+ // 1. Refresh cached region settings.
+ // ...
+
+ // 2. If using server settings, update managers.
+ if (mUserPrefs.getUseDefaults())
+ {
+ updateManagersFromPrefs();
+ }
+}