diff options
author | Rider Linden <rider@lindenlab.com> | 2018-04-30 16:37:08 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2018-04-30 16:37:08 -0700 |
commit | 438609699b838924becee89fa9d8ec83552f3236 (patch) | |
tree | ba2ebdd1e2ce3680bd2c4c1fb1ebb6fecc926de0 /indra/newview/llfloaterfixedenvironment.cpp | |
parent | cf0e4f79f52b4fb24769aa6e355ec8c95c6d2afc (diff) |
New water settings dialog.
Diffstat (limited to 'indra/newview/llfloaterfixedenvironment.cpp')
-rw-r--r-- | indra/newview/llfloaterfixedenvironment.cpp | 115 |
1 files changed, 106 insertions, 9 deletions
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); + } //========================================================================= |