summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llenvironment.cpp35
-rw-r--r--indra/newview/llenvironment.h9
-rw-r--r--indra/newview/llfloaterfixedenvironment.cpp115
-rw-r--r--indra/newview/llfloaterfixedenvironment.h27
-rw-r--r--indra/newview/llpaneleditwater.cpp3
5 files changed, 167 insertions, 22 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index 214ebb82b0..50f3f4f979 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -202,10 +202,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)
@@ -337,6 +337,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 +382,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);
@@ -1067,6 +1070,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;
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 95b24314cb..cb6cd11608 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -143,7 +143,7 @@ public:
void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
void updateShaderUniforms(LLGLSLShader *shader);
- void setSelectedEnvironment(EnvSelection_t env, F64Seconds transition = TRANSITION_DEFAULT);
+ void setSelectedEnvironment(EnvSelection_t env, F64Seconds transition = TRANSITION_DEFAULT, bool forced = false);
EnvSelection_t getSelectedEnvironment() const { return mSelectedEnvironment; }
bool hasEnvironment(EnvSelection_t env);
@@ -159,7 +159,7 @@ public:
LLSettingsSky::ptr_t getEnvironmentFixedSky(EnvSelection_t env) { return getEnvironmentFixed(env).first; };
LLSettingsWater::ptr_t getEnvironmentFixedWater(EnvSelection_t env) { return getEnvironmentFixed(env).second; };
- void updateEnvironment(F64Seconds transition = TRANSITION_DEFAULT);
+ void updateEnvironment(F64Seconds transition = TRANSITION_DEFAULT, bool forced = false);
void addSky(const LLSettingsSky::ptr_t &sky);
void addWater(const LLSettingsWater::ptr_t &sky);
@@ -187,6 +187,9 @@ public:
inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentEnvironment->getSky()->getClampedLightDirection(), 0.0f); }
inline LLVector4 getRotatedLight() const { return mRotatedLight; }
+ static LLSettingsWater::ptr_t createWaterFromLegacyPreset(const std::string filename);
+ static LLSettingsSky::ptr_t createSkyFromLegacyPreset(const std::string filename);
+
//-------------------------------------------
connection_t setSkyListChange(const change_signal_t::slot_type& cb);
connection_t setWaterListChange(const change_signal_t::slot_type& cb);
@@ -356,7 +359,7 @@ private:
void onTransitionDone(const LLSettingsBlender::ptr_t, bool isSky);
//=========================================================================
void legacyLoadAllPresets();
- LLSD legacyLoadPreset(const std::string& path);
+ static LLSD legacyLoadPreset(const std::string& path);
static std::string getSysDir(const std::string &subdir);
static std::string getUserDir(const std::string &subdir);
diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp
index d5162ef622..6c883b2534 100644
--- a/indra/newview/llfloaterfixedenvironment.cpp
+++ b/indra/newview/llfloaterfixedenvironment.cpp
@@ -36,6 +36,7 @@
#include "llnotificationsutil.h"
#include "llsliderctrl.h"
#include "lltabcontainer.h"
+#include "llfilepicker.h"
// newview
#include "llpaneleditwater.h"
@@ -44,6 +45,9 @@
#include "llsettingswater.h"
#include "llenvironment.h"
+#include "llagent.h"
+
+#include "llsettingsvo.h"
namespace
{
@@ -70,22 +74,41 @@ BOOL LLFloaterFixedEnvironment::postBuild()
mTxtName->setCommitOnFocusLost(TRUE);
mTxtName->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNameChanged(mTxtName->getValue().asString()); });
+ getChild<LLButton>(BUTTON_NAME_LOAD)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonLoad(); });
+ getChild<LLButton>(BUTTON_NAME_IMPORT)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonImport(); });
+ getChild<LLButton>(BUTTON_NAME_COMMIT)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonApply(); });
+ getChild<LLButton>(BUTTON_NAME_CANCEL)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonCancel(); });
+
return TRUE;
}
void LLFloaterFixedEnvironment::onFocusReceived()
{
updateEditEnvironment();
- LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST);
}
void LLFloaterFixedEnvironment::onFocusLost()
{
+ // *TODO*: If the window receiving focus is from a select color or select image control...
+ // We have technically not changed out of what we are doing so don't change back to displaying
+ // the local environment. (unfortunately the focus manager has
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
void LLFloaterFixedEnvironment::refresh()
{
+ if (!mSettings)
+ {
+ // disable everything.
+ return;
+ }
+
+ bool enableApplyAndLoad = canUseInventory();
+
+ getChild<LLButton>(BUTTON_NAME_LOAD)->setEnabled(enableApplyAndLoad);
+ getChild<LLButton>(BUTTON_NAME_COMMIT)->setEnabled(enableApplyAndLoad);
+
mTxtName->setValue(mSettings->getName());
S32 count = mTab->getTabCount();
@@ -115,6 +138,33 @@ void LLFloaterFixedEnvironment::onNameChanged(const std::string &name)
mSettings->setName(name);
}
+void LLFloaterFixedEnvironment::onButtonLoad()
+{
+ doLoadFromInventory();
+}
+
+void LLFloaterFixedEnvironment::onButtonImport()
+{
+ doImportFromDisk();
+}
+
+void LLFloaterFixedEnvironment::onButtonApply()
+{
+ doApplyFixedSettings();
+}
+
+void LLFloaterFixedEnvironment::onButtonCancel()
+{
+ // *TODO*: If changed issue a warning?
+ this->closeFloater();
+}
+
+//-------------------------------------------------------------------------
+bool LLFloaterFixedEnvironment::canUseInventory() const
+{
+ return !gAgent.getRegionCapability("UpdateSettingsAgentInventory").empty();
+}
+
//=========================================================================
LLFloaterFixedEnvironmentWater::LLFloaterFixedEnvironmentWater(const LLSD &key):
LLFloaterFixedEnvironment(key)
@@ -131,22 +181,69 @@ BOOL LLFloaterFixedEnvironmentWater::postBuild()
panel->setWater(std::static_pointer_cast<LLSettingsWater>(mSettings));
mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(true));
- // Initialize the settings, take a snapshot of the current water.
- mSettings = LLEnvironment::instance().getEnvironmentFixedWater(LLEnvironment::ENV_CURRENT)->buildClone();
+ return TRUE;
+}
- mSettings->setName("Snapshot water (new)");
+void LLFloaterFixedEnvironmentWater::updateEditEnvironment(void)
+{
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT,
+ std::static_pointer_cast<LLSettingsWater>(mSettings));
+}
- mTxtName->setValue(mSettings->getName());
+void LLFloaterFixedEnvironmentWater::onOpen(const LLSD& key)
+{
+ if (!mSettings)
+ {
+ // Initialize the settings, take a snapshot of the current water.
+ mSettings = LLEnvironment::instance().getEnvironmentFixedWater(LLEnvironment::ENV_CURRENT)->buildClone();
+ mSettings->setName("Snapshot water (new)");
+ // TODO: Should we grab sky and keep it around for reference?
+ }
+
+ updateEditEnvironment();
syncronizeTabs();
refresh();
- return TRUE;
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT, LLEnvironment::TRANSITION_FAST);
}
-void LLFloaterFixedEnvironmentWater::updateEditEnvironment(void)
+void LLFloaterFixedEnvironmentWater::onClose(bool app_quitting)
{
- LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT,
- std::static_pointer_cast<LLSettingsWater>(mSettings));
+ mSettings.reset();
+ syncronizeTabs();
+}
+
+void LLFloaterFixedEnvironmentWater::doLoadFromInventory()
+{
+
+}
+
+void LLFloaterFixedEnvironmentWater::doImportFromDisk()
+{ // Load a a legacy Windlight XML from disk.
+
+ LLFilePicker& picker = LLFilePicker::instance();
+ if (picker.getOpenFile(LLFilePicker::FFLOAD_XML))
+ {
+ std::string filename = picker.getFirstFile();
+
+ LL_WARNS("LAPRAS") << "Selected file: " << filename << LL_ENDL;
+ LLSettingsWater::ptr_t legacywater = LLEnvironment::createWaterFromLegacyPreset(filename);
+
+ if (!legacywater)
+ { // *TODO* Put up error dialog here. Could not create water from filename
+ return;
+ }
+
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, legacywater);
+ this->setEditSettings(legacywater);
+ LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_FAST, true);
+ }
+}
+
+void LLFloaterFixedEnvironmentWater::doApplyFixedSettings()
+{
+ LLSettingsVOBase::createInventoryItem(mSettings);
+
}
//=========================================================================
diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h
index 0d2d21533e..9eb03e0b3a 100644
--- a/indra/newview/llfloaterfixedenvironment.h
+++ b/indra/newview/llfloaterfixedenvironment.h
@@ -49,7 +49,7 @@ public:
virtual void onFocusReceived() override;
virtual void onFocusLost() override;
- void setEditSettings(LLSettingsBase::ptr_t &settings) { mSettings = settings; syncronizeTabs(); }
+ void setEditSettings(const LLSettingsBase::ptr_t &settings) { mSettings = settings; syncronizeTabs(); refresh(); }
LLSettingsBase::ptr_t getEditSettings() const { return mSettings; }
protected:
@@ -63,9 +63,19 @@ protected:
LLSettingsBase::ptr_t mSettings;
+ virtual void doLoadFromInventory() = 0;
+ virtual void doImportFromDisk() = 0;
+ virtual void doApplyFixedSettings() = 0;
+
+ bool canUseInventory() const;
private:
- void onNameChanged(const std::string &name);
+ void onNameChanged(const std::string &name);
+
+ void onButtonLoad();
+ void onButtonImport();
+ void onButtonApply();
+ void onButtonCancel();
#if 0
@@ -146,10 +156,17 @@ class LLFloaterFixedEnvironmentWater : public LLFloaterFixedEnvironment
public:
LLFloaterFixedEnvironmentWater(const LLSD &key);
- BOOL postBuild() override;
+ BOOL postBuild() override;
+
+ virtual void onOpen(const LLSD& key) override;
+ virtual void onClose(bool app_quitting) override;
+
+protected:
+ virtual void updateEditEnvironment() override;
-protected:
- virtual void updateEditEnvironment() override;
+ virtual void doLoadFromInventory() override;
+ virtual void doImportFromDisk() override;
+ virtual void doApplyFixedSettings() override;
private:
};
diff --git a/indra/newview/llpaneleditwater.cpp b/indra/newview/llpaneleditwater.cpp
index 08ba198894..3cb1dcfda4 100644
--- a/indra/newview/llpaneleditwater.cpp
+++ b/indra/newview/llpaneleditwater.cpp
@@ -80,11 +80,12 @@ BOOL LLPanelSettingsWaterMainTab::postBuild()
mClrFogColor = getChild<LLColorSwatchCtrl>(FIELD_WATER_FOG_COLOR);
mTxtNormalMap = getChild<LLTextureCtrl>(FIELD_WATER_NORMAL_MAP);
-
mClrFogColor->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogColorChanged(); });
getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(); });
// getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogDensityChanged(getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); });
getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onFogUnderWaterChanged(); });
+
+ mTxtNormalMap->setDefaultImageAssetID(LLSettingsWater::DEFAULT_WATER_NORMAL_ID);
mTxtNormalMap->setCommitCallback([this](LLUICtrl *, const LLSD &) { onNormalMapChanged(); });
getChild<LLUICtrl>(FIELD_WATER_WAVE1_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLargeWaveChanged(); });