summaryrefslogtreecommitdiff
path: root/indra/newview/llenvironment.cpp
diff options
context:
space:
mode:
authorGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-05-09 22:20:19 +0100
committerGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-05-09 22:20:19 +0100
commit23d2a97cda93d73ae1f5cae300b0e7534868f455 (patch)
treede7bbe636c5735b7c5809b1efdd892faa9b3d609 /indra/newview/llenvironment.cpp
parent5c18b349f06457bd6da3fcb12290932fb0d44826 (diff)
parentc238fa3ac5a3f93dcbf95e3cf7a7f8b576ab751c (diff)
Merge
Diffstat (limited to 'indra/newview/llenvironment.cpp')
-rw-r--r--indra/newview/llenvironment.cpp85
1 files changed, 79 insertions, 6 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index 214ebb82b0..98da6ea22f 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -135,6 +135,17 @@ bool LLEnvironment::canEdit() const
return true;
}
+bool LLEnvironment::isExtendedEnvironmentEnabled() const
+{
+ return !gAgent.getRegionCapability("ExtEnvironment").empty();
+}
+
+bool LLEnvironment::isInventoryEnabled() const
+{
+ return (!gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty() &&
+ !gAgent.getRegionCapability("UpdateSettingsTaskInventory").empty());
+}
+
LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb)
{
@@ -202,10 +213,10 @@ bool LLEnvironment::getIsDayTime() const
}
//-------------------------------------------------------------------------
-void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition)
+void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition, bool forced)
{
mSelectedEnvironment = env;
- updateEnvironment(transition);
+ updateEnvironment(transition, forced);
}
bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env)
@@ -266,6 +277,41 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm
/*TODO: readjust environment*/
}
+void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsBase::ptr_t &settings)
+{
+ DayInstance::ptr_t environment = getEnvironmentInstance(env);
+
+ if (settings->getSettingType() == "daycycle")
+ {
+ S64Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH);
+ S64Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET);
+ if (environment)
+ {
+ daylength = environment->getDayLength();
+ dayoffset = environment->getDayOffset();
+ }
+ setEnvironment(env, std::static_pointer_cast<LLSettingsDay>(settings), daylength, dayoffset);
+ }
+ else if (settings->getSettingType() == "sky")
+ {
+ fixedEnvironment_t fixedenv(std::static_pointer_cast<LLSettingsSky>(settings), LLSettingsWater::ptr_t());
+ if (environment)
+ {
+ fixedenv.second = environment->getWater();
+ }
+ setEnvironment(env, fixedenv);
+ }
+ else if (settings->getSettingType() == "water")
+ {
+ fixedEnvironment_t fixedenv(LLSettingsSky::ptr_t(), std::static_pointer_cast<LLSettingsWater>(settings));
+ if (environment)
+ {
+ fixedenv.first = environment->getSky();
+ }
+ setEnvironment(env, fixedenv);
+ }
+}
+
void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env)
{
@@ -337,6 +383,9 @@ LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironme
if (fixed.first && fixed.second)
break;
+ if (idx == ENV_EDIT)
+ continue; // skip the edit environment.
+
DayInstance::ptr_t environment = getEnvironmentInstance(static_cast<EnvSelection_t>(idx));
if (environment)
{
@@ -379,11 +428,11 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance(
}
-void LLEnvironment::updateEnvironment(F64Seconds transition)
+void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced)
{
DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance();
- if (mCurrentEnvironment != pinstance)
+ if ((mCurrentEnvironment != pinstance) || forced)
{
DayInstance::ptr_t trans = std::make_shared<DayTransition>(
mCurrentEnvironment->getSky(), mCurrentEnvironment->getWater(), pinstance, transition);
@@ -756,7 +805,7 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI
//=========================================================================
void LLEnvironment::requestRegion()
{
- if (gAgent.getRegionCapability("ExtEnvironment").empty())
+ if (!isExtendedEnvironmentEnabled())
{
LLEnvironmentRequest::initiate();
return;
@@ -767,7 +816,7 @@ void LLEnvironment::requestRegion()
void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset)
{
- if (gAgent.getRegionCapability("ExtEnvironment").empty())
+ if (!isExtendedEnvironmentEnabled())
{
LLEnvironmentApply::initiateRequest( LLSettingsVODay::convertToLegacy(pday) );
return;
@@ -1067,6 +1116,30 @@ std::string LLEnvironment::getUserDir(const std::string &subdir)
return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "windlight\\"+subdir, "");
}
+LLSettingsWater::ptr_t LLEnvironment::createWaterFromLegacyPreset(const std::string filename)
+{
+ LLSD data = legacyLoadPreset(filename);
+ if (!data)
+ return LLSettingsWater::ptr_t();
+
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true));
+ LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset(name, data);
+
+ return water;
+}
+
+LLSettingsSky::ptr_t LLEnvironment::createSkyFromLegacyPreset(const std::string filename)
+{
+ LLSD data = legacyLoadPreset(filename);
+ if (!data)
+ return LLSettingsSky::ptr_t();
+
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(filename), true));
+ LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, data);
+
+ return sky;
+}
+
LLSD LLEnvironment::legacyLoadPreset(const std::string& path)
{
llifstream xml_file;