diff options
author | Rider Linden <rider@lindenlab.com> | 2018-08-15 13:35:53 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2018-08-15 13:35:53 -0700 |
commit | eadf0b910174274e7c83fe37e417f576a7350edb (patch) | |
tree | 1560b09670fba4b867026f0ac7d087dacb1946b2 /indra | |
parent | 30ef616af5cfbb552458e88acd9f803aa076a08b (diff) |
MAINT-8990, MAINT-9002: First pass rework on environment panels, region/parcel
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 8 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 18 | ||||
-rw-r--r-- | indra/newview/llenvironment.cpp | 55 | ||||
-rw-r--r-- | indra/newview/llenvironment.h | 9 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.cpp | 7 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.h | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterland.cpp | 133 | ||||
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 102 | ||||
-rw-r--r-- | indra/newview/llpanelenvironment.cpp | 506 | ||||
-rw-r--r-- | indra/newview/llpanelenvironment.h | 90 | ||||
-rw-r--r-- | indra/newview/llsettingspicker.cpp | 1404 | ||||
-rw-r--r-- | indra/newview/llsettingspicker.h | 368 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.cpp | 39 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.h | 6 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_about_land.xml | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_region_environment.xml | 184 |
16 files changed, 649 insertions, 2286 deletions
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index beaeac2d04..3356727ee6 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -87,7 +87,7 @@ public: inline bool hasSetting(const std::string ¶m) const { return mSettings.has(param); } inline bool isDirty() const { return mDirty; } inline bool isVeryDirty() const { return mReplaced; } - inline void setDirtyFlag(bool dirty) { mDirty = dirty; } + inline void setDirtyFlag(bool dirty) { mDirty = dirty; clearAssetId(); } size_t getHash() const; // Hash will not include Name, ID or a previously stored Hash @@ -116,10 +116,10 @@ public: virtual void replaceSettings(LLSD settings) { - mSettings = settings; mBlendedFactor = 0.0; setDirtyFlag(true); mReplaced = true; + mSettings = settings; } virtual LLSD getSettings() const; @@ -130,8 +130,8 @@ public: { mSettings[name] = value; mDirty = true; - if (mSettings.has(SETTING_ASSETID)) - mSettings.erase(SETTING_ASSETID); + if (name != SETTING_ASSETID) + clearAssetId(); } inline void setValue(const std::string &name, const LLSD &value) diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index ea57c8987f..20efb23607 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -120,7 +120,7 @@ const S32 LLSettingsDay::FRAME_MAX(56); const F32 LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR(0.02501f); -const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("283a26a3-b147-47b7-8057-cfff0302ec0e"); +const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb"); // Minimum value to prevent multislider in edit floaters from eating up frames that 'encroach' on one another's space static const F32 DEFAULT_MULTISLIDER_INCREMENT(0.005f); @@ -150,6 +150,9 @@ LLSD LLSettingsDay::getSettings() const if (mSettings.has(SETTING_ID)) settings[SETTING_ID] = mSettings[SETTING_ID]; + if (mSettings.has(SETTING_ASSETID)) + settings[SETTING_ASSETID] = mSettings[SETTING_ASSETID]; + settings[SETTING_TYPE] = getSettingsType(); std::map<std::string, LLSettingsBase::ptr_t> in_use; @@ -194,6 +197,14 @@ bool LLSettingsDay::initialize(bool validate_frames) LLSD tracks = mSettings[SETTING_TRACKS]; LLSD frames = mSettings[SETTING_FRAMES]; + // save for later... + LLUUID assetid; + if (mSettings.has(SETTING_ASSETID)) + { + assetid = mSettings[SETTING_ASSETID].asUUID(); + LL_WARNS("LAPRAS") << "initializing daycycle with asset id " << assetid << LL_ENDL; + } + std::map<std::string, LLSettingsBase::ptr_t> used; for (LLSD::map_const_iterator itFrame = frames.beginMap(); itFrame != frames.endMap(); ++itFrame) @@ -385,6 +396,11 @@ bool LLSettingsDay::initialize(bool validate_frames) mSettings.erase(SETTING_TRACKS); mSettings.erase(SETTING_FRAMES); + if (!assetid.isNull()) + { + mSettings[SETTING_ASSETID] = assetid; + } + mInitialized = true; return true; } diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index b2bd20d809..66063564c0 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -57,6 +57,8 @@ #include <boost/make_shared.hpp> #include "llatmosphere.h" +#include "llagent.h" +#include "roles_constants.h" //========================================================================= namespace @@ -374,23 +376,33 @@ void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settin } } -bool LLEnvironment::canAgentUpdateParcelEnvironment(bool useselected) const +bool LLEnvironment::canAgentUpdateParcelEnvironment() const { - if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + + return canAgentUpdateParcelEnvironment(parcel); +} + + +bool LLEnvironment::canAgentUpdateParcelEnvironment(LLParcel *parcel) const +{ + if (!parcel) return false; - LLParcel *parcel(LLViewerParcelMgr::instance().getAgentOrSelectedParcel()); + if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + return false; - if (parcel) - { - return parcel->allowTerraformBy(gAgent.getID()); - } + if (gAgent.isGodlike()) + return true; - return false; + return LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS); } bool LLEnvironment::canAgentUpdateRegionEnvironment() const { + if (gAgent.isGodlike()) + return true; + return gAgent.getRegion()->canManageEstate(); } @@ -595,6 +607,7 @@ void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLS } setEnvironment(env, settings); + updateEnvironment(); } void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env) @@ -1001,7 +1014,7 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI } //========================================================================= -void LLEnvironment::requestRegion() +void LLEnvironment::requestRegion(environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { /*TODO: When EEP is live on the entire grid, this can go away. */ @@ -1009,7 +1022,7 @@ void LLEnvironment::requestRegion() return; } - requestParcel(INVALID_PARCEL_ID); + requestParcel(INVALID_PARCEL_ID, cb); } void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) @@ -1051,12 +1064,16 @@ void LLEnvironment::resetRegion() resetParcel(INVALID_PARCEL_ID); } -void LLEnvironment::requestParcel(S32 parcel_id) +void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) { + if (!cb) + { + cb = [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }; + } + std::string coroname = LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment", - boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, - [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); })); + [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset) @@ -1065,10 +1082,6 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_ LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", [this, parcel_id, asset_id, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, environment_apply_fn()); }); -// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); - -// LLSettingsVOBase::getSettingsAsset(asset_id, -// [this, parcel_id, day_length, day_offset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onUpdateParcelAssetLoaded(asset_id, settings, status, parcel_id, day_length, day_offset); }); } void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) @@ -1117,7 +1130,6 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment", [this, parcel_id, pday, day_length, day_offset]() { coroUpdateEnvironment(parcel_id, NO_TRACK, pday, LLUUID::null, day_length, day_offset, environment_apply_fn()); }); -// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); } @@ -1127,7 +1139,6 @@ void LLEnvironment::resetParcel(S32 parcel_id) std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", [this, parcel_id]() { coroResetEnvironment(parcel_id, NO_TRACK, environment_apply_fn()); }); -// [this](S32 pid, EnvironmentInfo::ptr_t envinfo) { recordEnvironment(pid, envinfo); }); }); } void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) @@ -1419,6 +1430,12 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL pinfo->mDayHash = environment.has(KEY_DAYHASH) ? environment[KEY_DAYHASH].asInteger() : 0; } + if (environment.has(KEY_DAYASSET)) + { + pinfo->mAssetId = environment[KEY_DAYASSET].asUUID(); + LL_WARNS("LAPRAS") << "Environment asset ID is " << pinfo->mAssetId << LL_ENDL; + LL_WARNS("LAPRAS") << "(day cycle claims " << pinfo->mDayCycle->getAssetId() << ")" << LL_ENDL; + } return pinfo; } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index eba1b737c8..5acec97bd9 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -43,6 +43,7 @@ //------------------------------------------------------------------------- class LLViewerCamera; class LLGLSLShader; +class LLParcel; //------------------------------------------------------------------------- class LLEnvironment : public LLSingleton<LLEnvironment> @@ -81,6 +82,7 @@ public: LLSettingsDay::ptr_t mDayCycle; std::array<F32, 4> mAltitudes; bool mIsDefault; + LLUUID mAssetId; static ptr_t extract(LLSD); }; @@ -148,7 +150,8 @@ public: bool canEdit() const; bool isExtendedEnvironmentEnabled() const; bool isInventoryEnabled() const; - bool canAgentUpdateParcelEnvironment(bool useselected = true) const; + bool canAgentUpdateParcelEnvironment() const; + bool canAgentUpdateParcelEnvironment(LLParcel *parcel) const; bool canAgentUpdateRegionEnvironment() const; LLSettingsDay::ptr_t getCurrentDay() const { return mCurrentEnvironment->getDayCycle(); } @@ -228,13 +231,13 @@ public: void onLegacyRegionSettings(LLSD data); - void requestRegion(); + void requestRegion(environment_apply_fn cb = environment_apply_fn()); void updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset); void updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); void updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset); void updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset); void resetRegion(); - void requestParcel(S32 parcel_id); + void requestParcel(S32 parcel_id, environment_apply_fn cb = environment_apply_fn()); void updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset); void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset); void updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset); diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 85bcf086e5..bcae9d2476 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -111,7 +111,7 @@ namespace { //========================================================================= const std::string LLFloaterEditExtDayCycle::KEY_INVENTORY_ID("inventory_id"); -const std::string LLFloaterEditExtDayCycle::KEY_LIVE_ENVIRONMENT("live_environment"); +const std::string LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT("edit_context"); const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length"); //========================================================================= @@ -198,9 +198,9 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) { loadInventoryItem(key[KEY_INVENTORY_ID].asUUID()); } - else if (key.has(KEY_LIVE_ENVIRONMENT)) + else if (key.has(KEY_EDIT_CONTEXT)) { - env = static_cast<LLEnvironment::EnvSelection_t>(key[KEY_LIVE_ENVIRONMENT].asInteger()); + env = static_cast<LLEnvironment::EnvSelection_t>(key[KEY_EDIT_CONTEXT].asInteger()); loadLiveEnvironment(env); } @@ -1261,6 +1261,7 @@ void LLFloaterEditExtDayCycle::doOpenInventoryFloater(LLSettingsType::type_e typ } picker->setSettingsFilter(type); + picker->setSettingsAssetId(currasset); picker->openFloater(); picker->setFocus(TRUE); } diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index 83506ba85f..084280063c 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -56,7 +56,7 @@ class LLFloaterEditExtDayCycle : public LLFloater public: // **RIDER** static const std::string KEY_INVENTORY_ID; - static const std::string KEY_LIVE_ENVIRONMENT; + static const std::string KEY_EDIT_CONTEXT; static const std::string KEY_DAY_LENGTH; // **RIDER** diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 995b5aaffc..5fcd3df7a8 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -145,14 +145,19 @@ class LLPanelLandEnvironment : public LLPanelEnvironmentInfo { public: - LLPanelLandEnvironment(LLSafeHandle<LLParcelSelection>& parcelp); + LLPanelLandEnvironment(LLSafeHandle<LLParcelSelection>& parcelp); - virtual BOOL postBuild(); - virtual void refresh(); + virtual bool isRegion() const override { return false; } + virtual BOOL postBuild() override; + virtual void refresh() override; + + virtual LLParcel * getParcel() override; + + virtual bool canEdit(); protected: - virtual void doApply(); + virtual void doApply(); LLSafeHandle<LLParcelSelection>& mParcel; @@ -3257,88 +3262,80 @@ BOOL LLPanelLandEnvironment::postBuild() if (!LLPanelEnvironmentInfo::postBuild()) return FALSE; - mAllowOverRide->setVisible(FALSE); + getChild<LLUICtrl>(RDO_USEDEFAULT)->setLabelArg("[USEDEFAULT]", getString(STR_LABEL_USEREGION)); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setVisible(FALSE); return TRUE; } void LLPanelLandEnvironment::refresh() { - /*TODO: if legacy don't do any of this.*/ + if (gDisconnected) + return; - LLParcel* parcel = mParcel->getParcel(); + LLParcel *parcel = getParcel(); if (!parcel) { - mRegionSettingsRadioGroup->setEnabled(FALSE); - mDayLengthSlider->setEnabled(FALSE); - mDayOffsetSlider->setEnabled(FALSE); - mAllowOverRide->setEnabled(FALSE); - + LL_INFOS("ENVPANEL") << "No parcel selected." << LL_ENDL; + mCurrentEnvironment.reset(); + mCurrentParcelId = INVALID_PARCEL_ID; + setControlsEnabled(false); return; } - //BOOL owner_or_god = gAgent.isGodlike() || (parcel owner or group) - BOOL owner_or_god = true; - //BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); - - F64Hours daylength; - F64Hours dayoffset; - - LLEnvironment::EnvSelection_t env = LLEnvironment::ENV_PARCEL; - - if (!LLEnvironment::instance().hasEnvironment(env)) - env = LLEnvironment::ENV_REGION; - - daylength = LLEnvironment::instance().getEnvironmentDayLength(env); - dayoffset = LLEnvironment::instance().getEnvironmentDayOffset(env); - - LLSettingsDay::ptr_t pday = LLEnvironment::instance().getEnvironmentDay(env); - - mEditingDayCycle = pday->buildClone(); - - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditingDayCycle, daylength, dayoffset); + if ((!mCurrentEnvironment) || (mCurrentEnvironment->mParcelId != parcel->getLocalID())) + { + mCurrentParcelId = parcel->getLocalID(); + refreshFromSource(); + return; + } - if (dayoffset.value() > 12.0) - dayoffset = dayoffset - F32Hours(24.0f); + LLPanelEnvironmentInfo::refresh(); - mDayLengthSlider->setValue(daylength.value()); - mDayOffsetSlider->setValue(dayoffset.value()); +} - //mRegionSettingsRadioGroup->setSelectedIndex(parcel->getUsesDefaultDayCycle() ? 0 : 1); - mRegionSettingsRadioGroup->setSelectedIndex(1); +LLParcel *LLPanelLandEnvironment::getParcel() +{ + return mParcel->getParcel(); +} - setControlsEnabled(owner_or_god); +bool LLPanelLandEnvironment::canEdit() +{ + LLParcel *parcel = getParcel(); + if (!parcel) + return false; + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(parcel); } void LLPanelLandEnvironment::doApply() { - LLParcel* parcel = mParcel->getParcel(); - if (!parcel) - { - LL_WARNS("PARCEL") << "Could not get parcel." << LL_ENDL; - return; - } - S32 parcel_id = parcel->getLocalID(); - - if (mRegionSettingsRadioGroup->getSelectedIndex() == 0) - { - LLEnvironment::instance().resetParcel(parcel_id); - } - else - { - LLSettingsDay::Seconds daylength; - F32Hours dayoffset_h; - - daylength = F32Hours(mDayLengthSlider->getValueF32()); - dayoffset_h = F32Hours(mDayOffsetSlider->getValueF32()); - - if (dayoffset_h.value() < 0) - { - dayoffset_h = F32Hours(24.0f) + dayoffset_h; - } - - LLSettingsDay::Seconds dayoffset_s = dayoffset_h; - - LLEnvironment::instance().updateParcel(parcel_id, mEditingDayCycle, daylength.value(), dayoffset_s.value()); - } +// LLParcel* parcel = mParcel->getParcel(); +// if (!parcel) +// { +// LL_WARNS("PARCEL") << "Could not get parcel." << LL_ENDL; +// return; +// } +// S32 parcel_id = parcel->getLocalID(); +// +// if (mRegionSettingsRadioGroup->getSelectedIndex() == 0) +// { +// LLEnvironment::instance().resetParcel(parcel_id); +// } +// else +// { +// LLSettingsDay::Seconds daylength; +// F32Hours dayoffset_h; +// +// daylength = F32Hours(mDayLengthSlider->getValueF32()); +// dayoffset_h = F32Hours(mDayOffsetSlider->getValueF32()); +// +// if (dayoffset_h.value() < 0) +// { +// dayoffset_h = F32Hours(24.0f) + dayoffset_h; +// } +// +// LLSettingsDay::Seconds dayoffset_s = dayoffset_h; +// +// LLEnvironment::instance().updateParcel(parcel_id, mEditingDayCycle, daylength.value(), dayoffset_s.value()); +// } } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 5112ff11bf..eb42ede8a8 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -181,12 +181,16 @@ class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo public: LLPanelRegionEnvironment(); - void refresh(); + virtual void refresh() override; + + virtual bool isRegion() const override { return true; } + virtual LLParcel * getParcel() override { return nullptr; } + virtual bool canEdit() override { return LLEnvironment::instance().canAgentUpdateRegionEnvironment(); } bool refreshFromRegion(LLViewerRegion* region); void refreshFromEstate(); - virtual BOOL postBuild(); + virtual BOOL postBuild() override; protected: virtual void doApply(); @@ -194,8 +198,6 @@ protected: virtual void doEditCommited(LLSettingsDay::ptr_t &newday); BOOL sendUpdate(); -private: - LLViewerRegion * mLastRegion; }; @@ -246,6 +248,7 @@ BOOL LLFloaterRegionInfo::postBuild() mEnvironmentPanel = new LLPanelRegionEnvironment; mEnvironmentPanel->buildFromFile("panel_region_environment.xml"); +// mEnvironmentPanel->configureForRegion(); mTab->addTabPanel(mEnvironmentPanel); panel = new LLPanelRegionDebugInfo; @@ -3367,8 +3370,7 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id ) //========================================================================= LLPanelRegionEnvironment::LLPanelRegionEnvironment(): - LLPanelEnvironmentInfo(), - mLastRegion(NULL) + LLPanelEnvironmentInfo() { LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); estate_info.setCommitCallback(boost::bind(&LLPanelRegionEnvironment::refreshFromEstate, this)); @@ -3381,48 +3383,28 @@ BOOL LLPanelRegionEnvironment::postBuild() if (!LLPanelEnvironmentInfo::postBuild()) return FALSE; + getChild<LLUICtrl>(RDO_USEDEFAULT)->setLabelArg("[USEDEFAULT]", getString(STR_LABEL_USEDEFAULT)); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setVisible(TRUE); + return TRUE; } void LLPanelRegionEnvironment::refresh() { - refreshFromRegion(mLastRegion); + if (!mCurrentEnvironment) + { + refreshFromSource(); + return; + } + refreshFromEstate(); + LLPanelEnvironmentInfo::refresh(); } bool LLPanelRegionEnvironment::refreshFromRegion(LLViewerRegion* region) { - BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); - BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); - - F64Hours daylength; - F64Hours dayoffset; - - daylength = LLEnvironment::instance().getEnvironmentDayLength(LLEnvironment::ENV_REGION); - dayoffset = LLEnvironment::instance().getEnvironmentDayOffset(LLEnvironment::ENV_REGION); - - if (dayoffset.value() > 12.0) - dayoffset = dayoffset - F64Hours(24.0f); - - mDayLengthSlider->setValue(daylength.value()); - mDayOffsetSlider->setValue(dayoffset.value()); - - setControlsEnabled(owner_or_god_or_manager); - mLastRegion = region; - - LLSettingsDay::ptr_t pday = LLEnvironment::instance().getEnvironmentDay(LLEnvironment::ENV_REGION); - - if (pday) - { - mRegionSettingsRadioGroup->setSelectedIndex((pday->getAssetId() == LLSettingsDay::GetDefaultAssetId()) ? 0 : 1); - mEditingDayCycle = std::static_pointer_cast<LLSettingsDay>(pday->buildDerivedClone()); - } - else - { - mRegionSettingsRadioGroup->setSelectedIndex(1); - } - + refresh(); return true; } @@ -3430,38 +3412,38 @@ void LLPanelRegionEnvironment::refreshFromEstate() { const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); - getChild<LLUICtrl>("allow_override_chk")->setValue(estate_info.getAllowEnvironmentOverride()); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setValue(estate_info.getAllowEnvironmentOverride()); } void LLPanelRegionEnvironment::doApply() { - if (mRegionSettingsRadioGroup->getSelectedIndex() == 0) - { - LLEnvironment::instance().resetRegion(); - } - else - { - LLSettingsDay::Seconds daylength; - F32Hours dayoffset_h; - - daylength = F32Hours(mDayLengthSlider->getValueF32()); - dayoffset_h = F32Hours(mDayOffsetSlider->getValueF32()); - - if (dayoffset_h.value() < 0) - { - dayoffset_h = F32Hours(24.0f) + dayoffset_h; - } - - LLSettingsDay::Seconds dayoffset_s = dayoffset_h; - - LLEnvironment::instance().updateRegion(mEditingDayCycle, daylength.value(), dayoffset_s.value()); - } +// if (mRegionSettingsRadioGroup->getSelectedIndex() == 0) +// { +// LLEnvironment::instance().resetRegion(); +// } +// else +// { +// LLSettingsDay::Seconds daylength; +// F32Hours dayoffset_h; +// +// daylength = F32Hours(mDayLengthSlider->getValueF32()); +// dayoffset_h = F32Hours(mDayOffsetSlider->getValueF32()); +// +// if (dayoffset_h.value() < 0) +// { +// dayoffset_h = F32Hours(24.0f) + dayoffset_h; +// } +// +// LLSettingsDay::Seconds dayoffset_s = dayoffset_h; +// +// LLEnvironment::instance().updateRegion(mEditingDayCycle, daylength.value(), dayoffset_s.value()); +// } } void LLPanelRegionEnvironment::doEditCommited(LLSettingsDay::ptr_t &newday) { - mEditingDayCycle = newday; +// mEditingDayCycle = newday; } BOOL LLPanelRegionEnvironment::sendUpdate() diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index ebe3da79f2..a2788124e7 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -31,6 +31,7 @@ #include "lluictrlfactory.h" #include "llexperiencecache.h" #include "llagent.h" +#include "llparcel.h" #include "llviewerregion.h" #include "llpanelenvironment.h" @@ -40,31 +41,63 @@ #include "llfloater.h" #include "llfloaterreg.h" #include "llfloatereditextdaycycle.h" +#include "llsettingsvo.h" -//static LLPanelInjector<LLPanelEnvironmentInfo> register_environment_panel("environment_panel"); +#include "llappviewer.h" +//========================================================================= +namespace +{ + const std::string FLOATER_DAY_CYCLE_EDIT("env_edit_extdaycycle"); +} + +//========================================================================= +const std::string LLPanelEnvironmentInfo::RDG_ENVIRONMENT_SELECT("rdg_environment_select"); +const std::string LLPanelEnvironmentInfo::RDO_USEDEFAULT("rdo_use_xxx_setting"); +const std::string LLPanelEnvironmentInfo::RDO_USEINV("rdo_use_inv_setting"); +const std::string LLPanelEnvironmentInfo::RDO_USECUSTOM("rdo_use_custom_setting"); +const std::string LLPanelEnvironmentInfo::EDT_INVNAME("edt_inventory_name"); +const std::string LLPanelEnvironmentInfo::BTN_SELECTINV("btn_select_inventory"); +const std::string LLPanelEnvironmentInfo::BTN_EDIT("btn_edit"); +const std::string LLPanelEnvironmentInfo::SLD_DAYLENGTH("sld_day_length"); +const std::string LLPanelEnvironmentInfo::SLD_DAYOFFSET("sld_day_offset"); +const std::string LLPanelEnvironmentInfo::CHK_ALLOWOVERRIDE("chk_allow_override"); +const std::string LLPanelEnvironmentInfo::BTN_APPLY("btn_apply"); +const std::string LLPanelEnvironmentInfo::BTN_CANCEL("btn_cancel"); + +const std::string LLPanelEnvironmentInfo::STR_LABEL_USEDEFAULT("str_label_use_default"); +const std::string LLPanelEnvironmentInfo::STR_LABEL_USEREGION("str_label_use_region"); +const std::string LLPanelEnvironmentInfo::STR_LABEL_UNKNOWNINV("str_unknow_inventory"); + +const S32 LLPanelEnvironmentInfo::DIRTY_FLAG_DAYCYCLE(0x01 << 0); +const S32 LLPanelEnvironmentInfo::DIRTY_FLAG_DAYLENGTH(0x01 << 1); +const S32 LLPanelEnvironmentInfo::DIRTY_FLAG_DAYOFFSET(0x01 << 2); + +const S32 LLPanelEnvironmentInfo::DIRTY_FLAG_MASK( + LLPanelEnvironmentInfo::DIRTY_FLAG_DAYCYCLE | + LLPanelEnvironmentInfo::DIRTY_FLAG_DAYLENGTH | + LLPanelEnvironmentInfo::DIRTY_FLAG_DAYOFFSET ); + +//========================================================================= LLPanelEnvironmentInfo::LLPanelEnvironmentInfo(): - mEnableEditing(false), - mRegionSettingsRadioGroup(NULL), - mDayLengthSlider(NULL), - mDayOffsetSlider(NULL), - mAllowOverRide(NULL) + mCurrentEnvironment(), + mCurrentParcelId(INVALID_PARCEL_ID), + mDirtyFlag(0), + mSettingsFloater(), + mEditFloater() { } -// virtual BOOL LLPanelEnvironmentInfo::postBuild() { - mRegionSettingsRadioGroup = getChild<LLRadioGroup>("environment_select_radio_group"); - mRegionSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDefaultSelection, this)); - - mDayLengthSlider = getChild<LLSliderCtrl>("day_length_sld"); - mDayOffsetSlider = getChild<LLSliderCtrl>("day_offset_sld"); - mAllowOverRide = getChild<LLCheckBoxCtrl>("allow_override_chk"); + getChild<LLUICtrl>(RDG_ENVIRONMENT_SELECT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onSwitchDefaultSelection(); }); + getChild<LLUICtrl>(BTN_SELECTINV)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnSelect(); }); + getChild<LLUICtrl>(BTN_EDIT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnEdit(); }); + getChild<LLUICtrl>(BTN_APPLY)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnApply(); }); + getChild<LLUICtrl>(BTN_CANCEL)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnReset(); }); - childSetCommitCallback("edit_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnEdit, this), NULL); - childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); - childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); + getChild<LLUICtrl>(SLD_DAYLENGTH)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged(value.asReal()); }); + getChild<LLUICtrl>(SLD_DAYOFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayOffsetChanged(value.asReal()); }); return TRUE; } @@ -72,8 +105,7 @@ BOOL LLPanelEnvironmentInfo::postBuild() // virtual void LLPanelEnvironmentInfo::onOpen(const LLSD& key) { - LL_DEBUGS("Windlight") << "Panel opened, refreshing" << LL_ENDL; - refresh(); + refreshFromSource(); } // virtual @@ -87,53 +119,120 @@ void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) void LLPanelEnvironmentInfo::refresh() { -#if 0 if (gDisconnected) - { return; + + if (((mCurrentEnvironment->mParcelId != INVALID_PARCEL_ID) && (!mCurrentEnvironment->mDayCycle)) || + ((mCurrentEnvironment->mParcelId == INVALID_PARCEL_ID) && (mCurrentEnvironment->mDayCycle->getAssetId() == LLSettingsDay::GetDefaultAssetId() ))) + { + getChild<LLRadioGroup>(RDG_ENVIRONMENT_SELECT)->setSelectedIndex(0); + getChild<LLUICtrl>(EDT_INVNAME)->setValue(""); } + else if (!mCurrentEnvironment->mDayCycle->getAssetId().isNull()) + { + getChild<LLRadioGroup>(RDG_ENVIRONMENT_SELECT)->setSelectedIndex(1); + + LLUUID asset_id = mCurrentEnvironment->mDayCycle->getAssetId(); + + std::string inventoryname = getInventoryNameForAssetId(asset_id); + + if (inventoryname.empty()) + inventoryname = "(" + mCurrentEnvironment->mDayCycle->getName() + ")"; - populateWaterPresetsList(); - populateSkyPresetsList(); - populateDayCyclesList(); + getChild<LLUICtrl>(EDT_INVNAME)->setValue(inventoryname); + } + else + { // asset id is null so this is a custom environment + getChild<LLRadioGroup>(RDG_ENVIRONMENT_SELECT)->setSelectedIndex(2); + getChild<LLUICtrl>(EDT_INVNAME)->setValue(""); + } - // Init radio groups. - const LLEnvironmentSettings& settings = LLEnvManagerNew::instance().getRegionSettings(); - const LLSD& dc = settings.getWLDayCycle(); - LLSD::Real first_frame_time = dc.size() > 0 ? dc[0][0].asReal() : 0.0f; - const bool use_fixed_sky = dc.size() == 1 && first_frame_time < 0; - mRegionSettingsRadioGroup->setSelectedIndex(settings.getSkyMap().size() == 0 ? 0 : 1); - mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); + F32Hours daylength(mCurrentEnvironment->mDayLength); + F32Hours dayoffset(mCurrentEnvironment->mDayOffset); - setControlsEnabled(mEnableEditing); + if (dayoffset.value() > 8.0f) + dayoffset -= F32Hours(24.0); - setDirty(false); -#endif + getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setValue(daylength.value()); + getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setValue(dayoffset.value()); + + setControlsEnabled(canEdit()); } -void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) +void LLPanelEnvironmentInfo::refreshFromSource() { - mRegionSettingsRadioGroup->setEnabled(enabled); + LLEnvironment::instance().requestParcel(mCurrentParcelId, + [this](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) {handleEnvironmentReceived(parcel_id, envifo); }); +} - mDayLengthSlider->setEnabled(false); - mDayOffsetSlider->setEnabled(false); - mAllowOverRide->setEnabled(enabled); +std::string LLPanelEnvironmentInfo::getInventoryNameForAssetId(LLUUID asset_id) +{ + LLFloaterSettingsPicker *picker = getSettingsPicker(); + + if (!picker) + { + LL_WARNS("ENVPANEL") << "Couldn't instantiate picker." << LL_ENDL; + return std::string(); + } + + std::string name(picker->findItemName(asset_id, false, false)); + + if (name.empty()) + return getString(STR_LABEL_UNKNOWNINV); + return name; +} + +LLFloaterSettingsPicker *LLPanelEnvironmentInfo::getSettingsPicker() +{ + LLFloaterSettingsPicker *picker = static_cast<LLFloaterSettingsPicker *>(mSettingsFloater.get()); - getChildView("edit_btn")->setEnabled(false); + // Show the dialog + if (!picker) + { + picker = new LLFloaterSettingsPicker(this, + LLUUID::null, "SELECT SETTINGS"); + + mSettingsFloater = picker->getHandle(); + + picker->setCommitCallback([this](LLUICtrl *, const LLSD &data){ onPickerCommited(data.asUUID()); }); + } - getChildView("apply_btn")->setEnabled(enabled); - getChildView("cancel_btn")->setEnabled(enabled); + return picker; +} + +LLFloaterEditExtDayCycle * LLPanelEnvironmentInfo::getEditFloater() +{ + LLFloaterEditExtDayCycle *editor = static_cast<LLFloaterEditExtDayCycle *>(mEditFloater.get()); - if (enabled) + // Show the dialog + if (!editor) { - // Enable/disable some controls based on currently selected radio buttons. - bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - getChild<LLView>("edit_btn")->setEnabled(!use_defaults); + LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT, "parcel") + (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, static_cast<S32>(mCurrentEnvironment->mDayLength.value()))); - mDayLengthSlider->setEnabled(!use_defaults); - mDayOffsetSlider->setEnabled(!use_defaults); + editor = (LLFloaterEditExtDayCycle *)LLFloaterReg::getInstance(FLOATER_DAY_CYCLE_EDIT, params); + if (!editor) + return nullptr; } + + return editor; +} + +void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) +{ + getChild<LLUICtrl>(RDG_ENVIRONMENT_SELECT)->setEnabled(enabled); + getChild<LLUICtrl>(RDO_USEDEFAULT)->setEnabled(enabled); + getChild<LLUICtrl>(RDO_USEINV)->setEnabled(enabled); + getChild<LLUICtrl>(RDO_USECUSTOM)->setEnabled(enabled); + getChild<LLUICtrl>(EDT_INVNAME)->setEnabled(FALSE); + getChild<LLUICtrl>(BTN_SELECTINV)->setEnabled(enabled); + getChild<LLUICtrl>(BTN_EDIT)->setEnabled(enabled); + getChild<LLUICtrl>(SLD_DAYLENGTH)->setEnabled(enabled); + getChild<LLUICtrl>(SLD_DAYOFFSET)->setEnabled(enabled); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setEnabled(enabled && (mCurrentParcelId == INVALID_PARCEL_ID)); + getChild<LLUICtrl>(BTN_APPLY)->setEnabled(enabled && (mDirtyFlag != 0)); + getChild<LLUICtrl>(BTN_CANCEL)->setEnabled(enabled && (mDirtyFlag != 0)); } void LLPanelEnvironmentInfo::setApplyProgress(bool started) @@ -152,270 +251,119 @@ void LLPanelEnvironmentInfo::setApplyProgress(bool started) // } } -void LLPanelEnvironmentInfo::setDirty(bool dirty) +void LLPanelEnvironmentInfo::setDirtyFlag(S32 flag) { - getChildView("apply_btn")->setEnabled(dirty); - getChildView("cancel_btn")->setEnabled(dirty); + bool can_edit = canEdit(); + mDirtyFlag |= flag; + getChildView(BTN_APPLY)->setEnabled((mDirtyFlag != 0) && can_edit); + getChildView(BTN_CANCEL)->setEnabled((mDirtyFlag != 0) && can_edit); } -// void LLPanelEnvironmentInfo::sendRegionSunUpdate() -// { -// #if 0 -// LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); -// -// // If the region is being switched to fixed sky, -// // change the region's sun hour according to the (fixed) sun position. -// // This is needed for llGetSunDirection() LSL function to work properly (STORM-1330). -// const LLSD& sky_map = mNewRegionSettings.getSkyMap(); -// bool region_use_fixed_sky = sky_map.size() == 1; -// if (region_use_fixed_sky) -// { -// LLWLParamSet param_set; -// llassert(sky_map.isMap()); -// param_set.setAll(sky_map.beginMap()->second); -// F32 sun_angle = param_set.getSunAngle(); -// -// LL_DEBUGS("Windlight Sync") << "Old sun hour: " << region_info.mSunHour << LL_ENDL; -// // convert value range from 0..2pi to 6..30 -// region_info.mSunHour = fmodf((sun_angle / F_TWO_PI) * 24.f, 24.f) + 6.f; -// } +void LLPanelEnvironmentInfo::onSwitchDefaultSelection() +{ + setDirtyFlag(DIRTY_FLAG_DAYCYCLE); +// bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; +// +// getChild<LLView>("edit_btn")->setEnabled(!use_defaults); // -// region_info.setUseFixedSun(region_use_fixed_sky); -// region_info.mUseEstateSun = !region_use_fixed_sky; -// LL_DEBUGS("Windlight Sync") << "Sun hour: " << region_info.mSunHour << LL_ENDL; +// mDayLengthSlider->setEnabled(!use_defaults); +// mDayOffsetSlider->setEnabled(!use_defaults); // -// region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); -// #endif -// } - -// void LLPanelEnvironmentInfo::fixEstateSun() -// { -// // We don't support fixed sun estates anymore and need to fix -// // such estates for region day cycle to take effect. -// // *NOTE: Assuming that current estate settings have arrived already. -// LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); -// if (estate_info.getUseFixedSun()) -// { -// LL_INFOS() << "Switching estate to global sun" << LL_ENDL; -// estate_info.setUseFixedSun(false); -// estate_info.sendEstateInfo(); -// } -// } +// setDirty(true); +} -// void LLPanelEnvironmentInfo::populateWaterPresetsList() -// { -// #if 0 -// mWaterPresetCombo->removeall(); -// -// // If the region already has water params, add them to the list. -// const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); -// if (region_settings.getWaterParams().size() != 0) -// { -// const std::string& region_name = gAgent.getRegion()->getName(); -// mWaterPresetCombo->add(region_name, LLWLParamKey(region_name, LLEnvKey::SCOPE_REGION).toLLSD()); -// mWaterPresetCombo->addSeparator(); -// } -// -// std::list<std::string> user_presets, system_presets; -// LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); -// -// // Add local user presets first. -// for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) -// { -// mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); -// } -// -// if (user_presets.size() > 0) -// { -// mWaterPresetCombo->addSeparator(); -// } -// -// // Add local system presets. -// for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) -// { -// mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); -// } -// -// // There's no way to select current preset because its name is not stored on server. -// #endif -// } -// -// void LLPanelEnvironmentInfo::populateSkyPresetsList() -// { -// #if 0 -// mSkyPresetCombo->removeall(); -// -// LLWLParamManager::preset_name_list_t region_presets; -// LLWLParamManager::preset_name_list_t user_presets, sys_presets; -// LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); -// -// // Add region presets. -// std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); -// for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) -// { -// std::string preset_name = *it; -// std::string item_title = preset_name + " (" + region_name + ")"; -// mSkyPresetCombo->add(item_title, LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); -// } -// -// if (!region_presets.empty()) -// { -// mSkyPresetCombo->addSeparator(); -// } -// -// // Add user presets. -// for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) -// { -// mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); -// } -// -// if (!user_presets.empty()) -// { -// mSkyPresetCombo->addSeparator(); -// } -// -// // Add system presets. -// for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) -// { -// mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); -// } -// -// // Select current preset. -// LLSD sky_map = LLEnvManagerNew::instance().getRegionSettings().getSkyMap(); -// if (sky_map.size() == 1) // if the region is set to fixed sky -// { -// std::string preset_name = sky_map.beginMap()->first; -// mSkyPresetCombo->selectByValue(LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); -// } -// #endif -// } -// -// void LLPanelEnvironmentInfo::populateDayCyclesList() -// { -// #if 0 -// mDayCyclePresetCombo->removeall(); -// -// // If the region already has env. settings, add its day cycle to the list. -// const LLSD& cur_region_dc = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); -// if (cur_region_dc.size() != 0) -// { -// LLViewerRegion* region = gAgent.getRegion(); -// llassert(region != NULL); -// -// LLWLParamKey key(region->getName(), LLEnvKey::SCOPE_REGION); -// mDayCyclePresetCombo->add(region->getName(), key.toStringVal()); -// mDayCyclePresetCombo->addSeparator(); -// } -// -// // Add local user day cycles. -// LLDayCycleManager::preset_name_list_t user_days, sys_days; -// LLDayCycleManager::instance().getPresetNames(user_days, sys_days); -// for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) -// { -// mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); -// } -// -// if (user_days.size() > 0) -// { -// mDayCyclePresetCombo->addSeparator(); -// } -// -// // Add local system day cycles. -// for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) -// { -// mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); -// } -// -// // Current day cycle is already selected. -// #endif -// } -void LLPanelEnvironmentInfo::onSwitchDefaultSelection() +void LLPanelEnvironmentInfo::onSldDayLengthChanged(F32 value) { - bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - - getChild<LLView>("edit_btn")->setEnabled(!use_defaults); - - mDayLengthSlider->setEnabled(!use_defaults); - mDayOffsetSlider->setEnabled(!use_defaults); + F32Hours daylength(value); - setDirty(true); + mCurrentEnvironment->mDayLength = daylength; + setDirtyFlag(DIRTY_FLAG_DAYLENGTH); } +void LLPanelEnvironmentInfo::onSldDayOffsetChanged(F32 value) +{ + F32Hours dayoffset(value); + + if (dayoffset.value() < 0.0f) + dayoffset += F32Hours(24.0); + + mCurrentEnvironment->mDayLength = dayoffset; + setDirtyFlag(DIRTY_FLAG_DAYOFFSET); +} + void LLPanelEnvironmentInfo::onBtnApply() { - doApply(); +// doApply(); } -void LLPanelEnvironmentInfo::onBtnCancel() +void LLPanelEnvironmentInfo::onBtnReset() { - // Reload last saved region settings. - refresh(); + mCurrentEnvironment.reset(); + refreshFromSource(); } void LLPanelEnvironmentInfo::onBtnEdit() { - LLFloaterEditExtDayCycle *dayeditor = (LLFloaterEditExtDayCycle *)LLFloaterReg::getInstance("env_edit_extdaycycle"); + LLFloaterEditExtDayCycle *dayeditor = getEditFloater(); - if (dayeditor) - { //*TODO Determine if region or parcel. - LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_LIVE_ENVIRONMENT, "parcel") - (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mDayLengthSlider->getValueF32() * (60.0 * 60.0))); - - LLFloaterReg::showInstance("env_edit_extdaycycle", params, TAKE_FOCUS_YES); + dayeditor->openFloater(dayeditor->getKey()); +} -// dayeditor->openFloater(mEditingDayCycle, F32Hours(mDayLengthSlider->getValue().asReal()), F32Hours(mDayOffsetSlider->getValue().asReal())); +void LLPanelEnvironmentInfo::onBtnSelect() +{ + LLFloaterSettingsPicker *picker = getSettingsPicker(); + if (picker) + { + picker->setSettingsFilter(LLSettingsType::ST_NONE); + picker->setSettingsAssetId((mCurrentEnvironment->mDayCycle) ? mCurrentEnvironment->mDayCycle->getAssetId() : LLUUID::null); + picker->openFloater(); + picker->setFocus(TRUE); } } +void LLPanelEnvironmentInfo::onPickerCommited(LLUUID asset_id) +{ + LLSettingsVOBase::getSettingsAsset(asset_id, [this](LLUUID, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { + if (status) + return; + onPickerAssetDownloaded(settings); + }); +} + void LLPanelEnvironmentInfo::onEditiCommited(LLSettingsDay::ptr_t newday) { doEditCommited(newday); } -void LLPanelEnvironmentInfo::doEditCommited(LLSettingsDay::ptr_t &newday) +void LLPanelEnvironmentInfo::onPickerAssetDownloaded(LLSettingsBase::ptr_t settings) { - mEditingDayCycle = newday; - /*TODO pure virtual*/ + LLSettingsVODay::buildFromOtherSetting(settings, [this](LLSettingsDay::ptr_t pday) + { + if (pday) + { + mCurrentEnvironment->mDayCycle = pday; + setDirtyFlag(DIRTY_FLAG_DAYCYCLE); + } + refresh(); + }); } -// void LLPanelEnvironmentInfo::onRegionSettingschange() -// { -// LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL; -// refresh(); -// -// // Stop applying progress indicator (it may be running if it's us who initiated settings update). -// setApplyProgress(false); -// } -// -// void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) -// { -// // If applying new settings has failed, stop the indicator right away. -// // Otherwise it will be stopped when we receive the updated settings from server. -// if (ok) -// { -// // Set the region sun phase/flags according to the chosen new preferences. -// // -// // If we do this earlier we may get jerky transition from fixed sky to a day cycle (STORM-1481). -// // That is caused by the simulator re-sending the region info, which in turn makes us -// // re-request and display old region environment settings while the new ones haven't been applied yet. -// sendRegionSunUpdate(); -// -// // Switch estate to not using fixed sun for the region day cycle to work properly (STORM-1506). -// fixEstateSun(); -// } -// else -// { -// setApplyProgress(false); -// -// // We need to re-request environment setting here, -// // otherwise our subsequent attempts to change region settings will fail with the following error: -// // "Unable to update environment settings because the last update your viewer saw was not the same -// // as the last update sent from the simulator. Try sending your update again, and if this -// // does not work, try leaving and returning to the region." -// // LLEnvManagerNew::instance().requestRegionSettings(); -// } -// } - +void LLPanelEnvironmentInfo::handleEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) +{ + if (parcel_id != mCurrentParcelId) + { + LL_WARNS("ENVPANEL") << "Have environment for parcel " << parcel_id << " expecting " << mCurrentParcelId << ". Discarding." << LL_ENDL; + return; + } + mCurrentEnvironment = envifo; + setDirtyFlag(DIRTY_FLAG_DAYCYCLE); + refresh(); +} +void LLPanelEnvironmentInfo::doEditCommited(LLSettingsDay::ptr_t &newday) +{ +// mEditingDayCycle = newday; + /*TODO pure virtual*/ +} diff --git a/indra/newview/llpanelenvironment.h b/indra/newview/llpanelenvironment.h index 7cc7ddae6f..29c9c411ba 100644 --- a/indra/newview/llpanelenvironment.h +++ b/indra/newview/llpanelenvironment.h @@ -32,52 +32,96 @@ #include "llcheckboxctrl.h" #include "llsliderctrl.h" #include "llsettingsdaycycle.h" +#include "llenvironment.h" +#include "llparcel.h" +#include "llsettingspicker.h" +#include "llfloatereditextdaycycle.h" class LLViewerRegion; class LLPanelEnvironmentInfo : public LLPanel { public: - LLPanelEnvironmentInfo(); + LLPanelEnvironmentInfo(); // LLPanel - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onOpen(const LLSD& key); + virtual BOOL postBuild() override; + virtual void onOpen(const LLSD& key) override; // LLView - /*virtual*/ void onVisibilityChange(BOOL new_visibility); + virtual void onVisibilityChange(BOOL new_visibility) override; + virtual void refresh() override; - virtual void refresh(); + S32 getCurrentParcelId() const { return mCurrentParcelId; } + void setCurrentParcelId(S32 parcel_id) { mCurrentParcelId = parcel_id; } + + virtual bool isRegion() const = 0; + virtual LLParcel * getParcel() = 0; + virtual bool canEdit() = 0; protected: LOG_CLASS(LLPanelEnvironmentInfo); - void setControlsEnabled(bool enabled); - void setApplyProgress(bool started); - void setDirty(bool dirty); + static const std::string RDG_ENVIRONMENT_SELECT; + static const std::string RDO_USEDEFAULT; + static const std::string RDO_USEINV; + static const std::string RDO_USECUSTOM; + static const std::string EDT_INVNAME; + static const std::string BTN_SELECTINV; + static const std::string BTN_EDIT; + static const std::string SLD_DAYLENGTH; + static const std::string SLD_DAYOFFSET; + static const std::string CHK_ALLOWOVERRIDE; + static const std::string BTN_APPLY; + static const std::string BTN_CANCEL; + + static const std::string STR_LABEL_USEDEFAULT; + static const std::string STR_LABEL_USEREGION; + static const std::string STR_LABEL_UNKNOWNINV; + + static const S32 DIRTY_FLAG_DAYCYCLE; + static const S32 DIRTY_FLAG_DAYLENGTH; + static const S32 DIRTY_FLAG_DAYOFFSET; + + static const S32 DIRTY_FLAG_MASK; + + void setControlsEnabled(bool enabled); + void setApplyProgress(bool started); + void setDirtyFlag(S32 flag); + bool getIsDirty() const { return (mDirtyFlag != 0); } + bool getIsDirtyFlag(S32 flag) const { return ((mDirtyFlag & flag) != 0); } + + void onSwitchDefaultSelection(); + void onSldDayLengthChanged(F32 value); + void onSldDayOffsetChanged(F32 value); + void onBtnApply(); + void onBtnReset(); + void onBtnEdit(); + void onBtnSelect(); + + void onPickerCommited(LLUUID asset_id); + void onEditiCommited(LLSettingsDay::ptr_t newday); + void onPickerAssetDownloaded(LLSettingsBase::ptr_t settings); - void onSwitchDefaultSelection(); + void handleEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo); - void onBtnApply(); - void onBtnCancel(); - void onBtnEdit(); + virtual void doEditCommited(LLSettingsDay::ptr_t &newday); - void onEditiCommited(LLSettingsDay::ptr_t newday); + void refreshFromSource(); - virtual void doApply() = 0; - virtual void doEditCommited(LLSettingsDay::ptr_t &newday); + std::string getInventoryNameForAssetId(LLUUID asset_id); - /// New environment settings that are being applied to the region. - // LLEnvironmentSettings mNewRegionSettings; + LLFloaterSettingsPicker * getSettingsPicker(); + LLFloaterEditExtDayCycle * getEditFloater(); - bool mEnableEditing; + LLEnvironment::EnvironmentInfo::ptr_t mCurrentEnvironment; + S32 mCurrentParcelId; - LLRadioGroup* mRegionSettingsRadioGroup; - LLSliderCtrl* mDayLengthSlider; - LLSliderCtrl* mDayOffsetSlider; - LLCheckBoxCtrl* mAllowOverRide; - LLSettingsDay::ptr_t mEditingDayCycle; +private: + LLHandle<LLFloater> mSettingsFloater; + LLHandle<LLFloater> mEditFloater; + S32 mDirtyFlag; }; #endif // LL_LLPANELEXPERIENCES_H diff --git a/indra/newview/llsettingspicker.cpp b/indra/newview/llsettingspicker.cpp index b386243777..fedd3f387c 100644 --- a/indra/newview/llsettingspicker.cpp +++ b/indra/newview/llsettingspicker.cpp @@ -131,6 +131,9 @@ BOOL LLFloaterSettingsPicker::postBuild() void LLFloaterSettingsPicker::onClose(bool app_quitting) { + if (app_quitting) + return; + mCloseSignal(); if (mOwner) { @@ -218,6 +221,7 @@ void LLFloaterSettingsPicker::draw() LLFloater::draw(); } + //========================================================================= void LLFloaterSettingsPicker::onFilterEdit(const std::string& search_string) { @@ -270,7 +274,7 @@ void LLFloaterSettingsPicker::onSelectionChange(const LLFloaterSettingsPicker::i { mNoCopySettingsSelected = true; } - setSettingsID(itemp->getAssetUUID(), false); + setSettingsAssetId(itemp->getAssetUUID(), false); mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? if (user_action) @@ -299,7 +303,7 @@ void LLFloaterSettingsPicker::setActive(bool active) mActive = active; } -void LLFloaterSettingsPicker::setSettingsID(const LLUUID &settings_id, bool set_selection) +void LLFloaterSettingsPicker::setSettingsAssetId(const LLUUID &settings_id, bool set_selection) { if (mSettingAssetID != settings_id && mActive) { @@ -327,7 +331,7 @@ void LLFloaterSettingsPicker::setSettingsID(const LLUUID &settings_id, bool set_ } } -LLUUID LLFloaterSettingsPicker::findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library) +LLInventoryItem* LLFloaterSettingsPicker::findItem(const LLUUID& asset_id, bool copyable_only, bool ignore_library) { LLViewerInventoryCategory::cat_array_t cats; LLViewerInventoryItem::item_array_t items; @@ -350,1409 +354,23 @@ LLUUID LLFloaterSettingsPicker::findItemID(const LLUUID& asset_id, bool copyable { if(!ignore_library || !gInventory.isObjectDescendentOf(itemp->getUUID(),gInventory.getLibraryRootFolderID())) { - return itemp->getUUID(); + return itemp; } } } // otherwise just return first instance, unless copyable requested if (copyable_only) { - return LLUUID::null; + return nullptr; } else { if(!ignore_library || !gInventory.isObjectDescendentOf(items[0]->getUUID(),gInventory.getLibraryRootFolderID())) { - return items[0]->getUUID(); + return items[0]; } } } - return LLUUID::null; -} - - -#if 0 -#include "llrender.h" -#include "llagent.h" -#include "llviewertexturelist.h" -#include "llcheckboxctrl.h" -#include "llcombobox.h" -#include "llbutton.h" -#include "lldraghandle.h" -#include "llfocusmgr.h" -#include "llfolderviewmodel.h" -#include "llinventory.h" -#include "llinventoryfunctions.h" -#include "llinventorymodelbackgroundfetch.h" -#include "llinventoryobserver.h" -#include "llinventorypanel.h" -#include "lllineeditor.h" -#include "llui.h" -#include "llviewerinventory.h" -#include "llpermissions.h" -#include "llsaleinfo.h" -#include "llassetstorage.h" -#include "lltextbox.h" -#include "llresizehandle.h" -#include "llscrollcontainer.h" -#include "lltoolmgr.h" -#include "lltoolpipette.h" -#include "llwindow.h" - -#include "lltool.h" -#include "llviewerwindow.h" -#include "llviewerobject.h" -#include "llviewercontrol.h" -#include "llglheaders.h" -#include "lluictrlfactory.h" -#include "lltrans.h" - -#include "llradiogroup.h" -#include "llfloaterreg.h" -#include "lllocalbitmaps.h" -#include "llerror.h" - -static const S32 LOCAL_TRACKING_ID_COLUMN = 1; - -//static const char CURRENT_IMAGE_NAME[] = "Current Texture"; -//static const char WHITE_IMAGE_NAME[] = "Blank Texture"; -//static const char NO_IMAGE_NAME[] = "None"; - -LLFloaterTexturePicker::LLFloaterTexturePicker( - LLView* owner, - LLUUID image_asset_id, - LLUUID default_image_asset_id, - LLUUID blank_image_asset_id, - BOOL tentative, - BOOL allow_no_texture, - const std::string& label, - PermissionMask immediate_filter_perm_mask, - PermissionMask dnd_filter_perm_mask, - PermissionMask non_immediate_filter_perm_mask, - BOOL can_apply_immediately, - LLUIImagePtr fallback_image) -: LLFloater(LLSD()), - mOwner( owner ), - mImageAssetID( image_asset_id ), - mOriginalImageAssetID(image_asset_id), - mFallbackImage(fallback_image), - mDefaultImageAssetID(default_image_asset_id), - mBlankImageAssetID(blank_image_asset_id), - mTentative(tentative), - mAllowNoTexture(allow_no_texture), - mLabel(label), - mTentativeLabel(NULL), - mResolutionLabel(NULL), - mActive( TRUE ), - mFilterEdit(NULL), - mImmediateFilterPermMask(immediate_filter_perm_mask), - mDnDFilterPermMask(dnd_filter_perm_mask), - mNonImmediateFilterPermMask(non_immediate_filter_perm_mask), - mContextConeOpacity(0.f), - mSelectedItemPinned( FALSE ), - mCanApply(true), - mCanPreview(true), - mPreviewSettingChanged(false), - mOnFloaterCommitCallback(NULL), - mOnFloaterCloseCallback(NULL), - mSetImageAssetIDCallback(NULL), - mOnUpdateImageStatsCallback(NULL) -{ - buildFromFile("floater_texture_ctrl.xml"); - mCanApplyImmediately = can_apply_immediately; - setCanMinimize(FALSE); -} - -LLFloaterTexturePicker::~LLFloaterTexturePicker() -{ -} - -void LLFloaterTexturePicker::setCanApplyImmediately(BOOL b) -{ - mCanApplyImmediately = b; - if (!mCanApplyImmediately) - { - getChild<LLUICtrl>("apply_immediate_check")->setValue(FALSE); - } - updateFilterPermMask(); -} - -void LLFloaterTexturePicker::stopUsingPipette() -{ - if (LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()) - { - LLToolMgr::getInstance()->clearTransientTool(); - } -} - -void LLFloaterTexturePicker::updateImageStats() -{ - if (mTexturep.notNull()) - { - //RN: have we received header data for this image? - if (mTexturep->getFullWidth() > 0 && mTexturep->getFullHeight() > 0) - { - std::string formatted_dims = llformat("%d x %d", mTexturep->getFullWidth(),mTexturep->getFullHeight()); - mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims); - if (mOnUpdateImageStatsCallback) - { - mOnUpdateImageStatsCallback(mTexturep); - } - } - else - { - mResolutionLabel->setTextArg("[DIMENSIONS]", std::string("[? x ?]")); - } - } - else - { - mResolutionLabel->setTextArg("[DIMENSIONS]", std::string("")); - } -} - -// virtual -BOOL LLFloaterTexturePicker::handleDragAndDrop( - S32 x, S32 y, MASK mask, - BOOL drop, - EDragAndDropType cargo_type, void *cargo_data, - EAcceptance *accept, - std::string& tooltip_msg) -{ - BOOL handled = FALSE; - - bool is_mesh = cargo_type == DAD_MESH; - - if ((cargo_type == DAD_TEXTURE) || is_mesh) - { - LLInventoryItem *item = (LLInventoryItem *)cargo_data; - - BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID()); - BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID()); - BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, - gAgent.getID()); - - PermissionMask item_perm_mask = 0; - if (copy) item_perm_mask |= PERM_COPY; - if (mod) item_perm_mask |= PERM_MODIFY; - if (xfer) item_perm_mask |= PERM_TRANSFER; - - //PermissionMask filter_perm_mask = getFilterPermMask(); Commented out due to no-copy texture loss. - PermissionMask filter_perm_mask = mDnDFilterPermMask; - if ( (item_perm_mask & filter_perm_mask) == filter_perm_mask ) - { - if (drop) - { - setImageID( item->getAssetUUID() ); - commitIfImmediateSet(); - } - - *accept = ACCEPT_YES_SINGLE; - } - else - { - *accept = ACCEPT_NO; - } - } - else - { - *accept = ACCEPT_NO; - } - - handled = TRUE; - LL_DEBUGS("UserInput") << "dragAndDrop handled by LLFloaterTexturePicker " << getName() << LL_ENDL; - - return handled; -} - -BOOL LLFloaterTexturePicker::handleKeyHere(KEY key, MASK mask) -{ - LLFolderView* root_folder = mInventoryPanel->getRootFolder(); - - if (root_folder && mFilterEdit) - { - if (mFilterEdit->hasFocus() - && (key == KEY_RETURN || key == KEY_DOWN) - && mask == MASK_NONE) - { - if (!root_folder->getCurSelectedItem()) - { - LLFolderViewItem* itemp = mInventoryPanel->getItemByID(gInventory.getRootFolderID()); - if (itemp) - { - root_folder->setSelection(itemp, FALSE, FALSE); - } - } - root_folder->scrollToShowSelection(); - - // move focus to inventory proper - mInventoryPanel->setFocus(TRUE); - - // treat this as a user selection of the first filtered result - commitIfImmediateSet(); - - return TRUE; - } - - if (mInventoryPanel->hasFocus() && key == KEY_UP) - { - mFilterEdit->focusFirstItem(TRUE); - } - } - - return LLFloater::handleKeyHere(key, mask); -} - -void LLFloaterTexturePicker::onClose(bool app_quitting) -{ - if (mOwner && mOnFloaterCloseCallback) - { - mOnFloaterCloseCallback(); - } - stopUsingPipette(); -} - -// virtual -BOOL LLFloaterTexturePicker::postBuild() -{ - LLFloater::postBuild(); - - if (!mLabel.empty()) - { - std::string pick = getString("pick title"); - - setTitle(pick + mLabel); - } - mTentativeLabel = getChild<LLTextBox>("Multiple"); - - mResolutionLabel = getChild<LLTextBox>("unknown"); - - - childSetAction("Default",LLFloaterTexturePicker::onBtnSetToDefault,this); - childSetAction("None", LLFloaterTexturePicker::onBtnNone,this); - childSetAction("Blank", LLFloaterTexturePicker::onBtnBlank,this); - - - childSetCommitCallback("show_folders_check", onShowFolders, this); - getChildView("show_folders_check")->setVisible( FALSE); - - mFilterEdit = getChild<LLFilterEditor>("inventory search editor"); - mFilterEdit->setCommitCallback(boost::bind(&LLFloaterTexturePicker::onFilterEdit, this, _2)); - - mInventoryPanel = getChild<LLInventoryPanel>("inventory panel"); - - if(mInventoryPanel) - { - U32 filter_types = 0x0; - filter_types |= 0x1 << LLInventoryType::IT_TEXTURE; - filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT; - - mInventoryPanel->setFilterTypes(filter_types); - //mInventoryPanel->setFilterPermMask(getFilterPermMask()); //Commented out due to no-copy texture loss. - mInventoryPanel->setFilterPermMask(mImmediateFilterPermMask); - mInventoryPanel->setSelectCallback(boost::bind(&LLFloaterTexturePicker::onSelectionChange, this, _1, _2)); - mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - - // Disable auto selecting first filtered item because it takes away - // selection from the item set by LLTextureCtrl owning this floater. - mInventoryPanel->getRootFolder()->setAutoSelectOverride(TRUE); - - // Commented out to scroll to currently selected texture. See EXT-5403. - // // store this filter as the default one - // mInventoryPanel->getRootFolder()->getFilter().markDefault(); - - // Commented out to stop opening all folders with textures - // mInventoryPanel->openDefaultFolderForType(LLFolderType::FT_TEXTURE); - - // don't put keyboard focus on selected item, because the selection callback - // will assume that this was user input - if(!mImageAssetID.isNull()) - { - mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO); - } - } - - mModeSelector = getChild<LLRadioGroup>("mode_selection"); - mModeSelector->setCommitCallback(onModeSelect, this); - mModeSelector->setSelectedIndex(0, 0); - - childSetAction("l_add_btn", LLFloaterTexturePicker::onBtnAdd, this); - childSetAction("l_rem_btn", LLFloaterTexturePicker::onBtnRemove, this); - childSetAction("l_upl_btn", LLFloaterTexturePicker::onBtnUpload, this); - - mLocalScrollCtrl = getChild<LLScrollListCtrl>("l_name_list"); - mLocalScrollCtrl->setCommitCallback(onLocalScrollCommit, this); - LLLocalBitmapMgr::feedScrollList(mLocalScrollCtrl); - - mNoCopyTextureSelected = FALSE; - - getChild<LLUICtrl>("apply_immediate_check")->setValue(gSavedSettings.getBOOL("TextureLivePreview")); - childSetCommitCallback("apply_immediate_check", onApplyImmediateCheck, this); - - if (!mCanApplyImmediately) - { - getChildView("show_folders_check")->setEnabled(FALSE); - } - - getChild<LLUICtrl>("Pipette")->setCommitCallback( boost::bind(&LLFloaterTexturePicker::onBtnPipette, this)); - childSetAction("Cancel", LLFloaterTexturePicker::onBtnCancel,this); - childSetAction("Select", LLFloaterTexturePicker::onBtnSelect,this); - - // update permission filter once UI is fully initialized - updateFilterPermMask(); - mSavedFolderState.setApply(FALSE); - - LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterTexturePicker::onTextureSelect, this, _1)); - - return TRUE; -} - -// virtual -void LLFloaterTexturePicker::draw() -{ - if (mOwner) - { - // draw cone of context pointing back to texture swatch - LLRect owner_rect; - mOwner->localRectToOtherView(mOwner->getLocalRect(), &owner_rect, this); - LLRect local_rect = getLocalRect(); - if (gFocusMgr.childHasKeyboardFocus(this) && mOwner->isInVisibleChain() && mContextConeOpacity > 0.001f) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLEnable(GL_CULL_FACE); - gGL.begin(LLRender::QUADS); - { - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); - gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mTop); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); - - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mTop); - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); - gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); - gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom); - - - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); - gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); - gGL.vertex2i(local_rect.mRight, local_rect.mBottom); - gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); - gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom); - gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom); - } - gGL.end(); - } - } - - if (gFocusMgr.childHasMouseCapture(getDragHandle())) - { - mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME)); - } - else - { - mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME)); - } - - updateImageStats(); - - // if we're inactive, gray out "apply immediate" checkbox - getChildView("show_folders_check")->setEnabled(mActive && mCanApplyImmediately && !mNoCopyTextureSelected); - getChildView("Select")->setEnabled(mActive && mCanApply); - getChildView("Pipette")->setEnabled(mActive); - getChild<LLUICtrl>("Pipette")->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); - - //BOOL allow_copy = FALSE; - if( mOwner ) - { - mTexturep = NULL; - if(mImageAssetID.notNull()) - { - mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID); - mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); - } - - if (mTentativeLabel) - { - mTentativeLabel->setVisible( FALSE ); - } - - getChildView("Default")->setEnabled(mImageAssetID != mDefaultImageAssetID || mTentative); - getChildView("Blank")->setEnabled(mImageAssetID != mBlankImageAssetID || mTentative); - getChildView("None")->setEnabled(mAllowNoTexture && (!mImageAssetID.isNull() || mTentative)); - - LLFloater::draw(); - - if( isMinimized() ) - { - return; - } - - // Border - LLRect border = getChildView("preview_widget")->getRect(); - gl_rect_2d( border, LLColor4::black, FALSE ); - - - // Interior - LLRect interior = border; - interior.stretch( -1 ); - - // If the floater is focused, don't apply its alpha to the texture (STORM-677). - const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); - if( mTexturep ) - { - if( mTexturep->getComponents() == 4 ) - { - gl_rect_2d_checkerboard( interior, alpha ); - } - - gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha ); - - // Pump the priority - mTexturep->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) ); - } - else if (!mFallbackImage.isNull()) - { - mFallbackImage->draw(interior, UI_VERTEX_COLOR % alpha); - } - else - { - gl_rect_2d( interior, LLColor4::grey % alpha, TRUE ); - - // Draw X - gl_draw_x(interior, LLColor4::black ); - } - - // Draw Tentative Label over the image - if( mTentative && !mViewModel->isDirty() ) - { - mTentativeLabel->setVisible( TRUE ); - drawChild(mTentativeLabel); - } - - if (mSelectedItemPinned) return; - - LLFolderView* folder_view = mInventoryPanel->getRootFolder(); - if (!folder_view) return; - - LLFolderViewFilter& filter = static_cast<LLFolderViewModelInventory*>(folder_view->getFolderViewModel())->getFilter(); - - bool is_filter_active = folder_view->getViewModelItem()->getLastFilterGeneration() < filter.getCurrentGeneration() && - filter.isNotDefault(); - - // After inventory panel filter is applied we have to update - // constraint rect for the selected item because of folder view - // AutoSelectOverride set to TRUE. We force PinningSelectedItem - // flag to FALSE state and setting filter "dirty" to update - // scroll container to show selected item (see LLFolderView::doIdle()). - if (!is_filter_active && !mSelectedItemPinned) - { - folder_view->setPinningSelectedItem(mSelectedItemPinned); - folder_view->getViewModelItem()->dirtyFilter(); - mSelectedItemPinned = TRUE; - } - } -} - -PermissionMask LLFloaterTexturePicker::getFilterPermMask() -{ - bool apply_immediate = getChild<LLUICtrl>("apply_immediate_check")->getValue().asBoolean(); - return apply_immediate ? mImmediateFilterPermMask : mNonImmediateFilterPermMask; -} - -void LLFloaterTexturePicker::commitCancel() -{ - if (!mNoCopyTextureSelected && mOnFloaterCommitCallback && mCanApply) - { - mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, LLUUID::null); - } -} - -// static -void LLFloaterTexturePicker::onBtnSetToDefault(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - self->setCanApply(true, true); - if (self->mOwner) - { - self->setImageID( self->getDefaultImageAssetID() ); - } - self->commitIfImmediateSet(); -} - -// static -void LLFloaterTexturePicker::onBtnBlank(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - self->setCanApply(true, true); - self->setImageID( self->getBlankImageAssetID() ); - self->commitIfImmediateSet(); -} - - -// static -void LLFloaterTexturePicker::onBtnNone(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - self->setImageID( LLUUID::null ); - self->commitCancel(); -} - -/* -// static -void LLFloaterTexturePicker::onBtnRevert(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - self->setImageID( self->mOriginalImageAssetID ); - // TODO: Change this to tell the owner to cancel. It needs to be - // smart enough to restore multi-texture selections. - self->mOwner->onFloaterCommit(); - self->mViewModel->resetDirty(); -}*/ - -// static -void LLFloaterTexturePicker::onBtnCancel(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - self->setImageID( self->mOriginalImageAssetID ); - if (self->mOnFloaterCommitCallback) - { - self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, LLUUID::null); - } - self->mViewModel->resetDirty(); - self->closeFloater(); -} - -// static -void LLFloaterTexturePicker::onBtnSelect(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - LLUUID local_id = LLUUID::null; - if (self->mOwner) - { - if (self->mLocalScrollCtrl->getVisible() && !self->mLocalScrollCtrl->getAllSelected().empty()) - { - LLUUID temp_id = self->mLocalScrollCtrl->getFirstSelected()->getColumn(LOCAL_TRACKING_ID_COLUMN)->getValue().asUUID(); - local_id = LLLocalBitmapMgr::getWorldID(temp_id); - } - } - if (self->mOnFloaterCommitCallback) - { - self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_SELECT, local_id); - } - self->closeFloater(); -} - -void LLFloaterTexturePicker::onBtnPipette() -{ - BOOL pipette_active = getChild<LLUICtrl>("Pipette")->getValue().asBoolean(); - pipette_active = !pipette_active; - if (pipette_active) - { - LLToolMgr::getInstance()->setTransientTool(LLToolPipette::getInstance()); - } - else - { - LLToolMgr::getInstance()->clearTransientTool(); - } -} - -// static -void LLFloaterTexturePicker::onModeSelect(LLUICtrl* ctrl, void *userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - bool mode = (self->mModeSelector->getSelectedIndex() == 0); - - self->getChild<LLButton>("Default")->setVisible(mode); - self->getChild<LLButton>("Blank")->setVisible(mode); - self->getChild<LLButton>("None")->setVisible(mode); - self->getChild<LLButton>("Pipette")->setVisible(mode); - self->getChild<LLFilterEditor>("inventory search editor")->setVisible(mode); - self->getChild<LLInventoryPanel>("inventory panel")->setVisible(mode); - - /*self->getChild<LLCheckBox>("show_folders_check")->setVisible(mode); - no idea under which conditions the above is even shown, needs testing. */ - - self->getChild<LLButton>("l_add_btn")->setVisible(!mode); - self->getChild<LLButton>("l_rem_btn")->setVisible(!mode); - self->getChild<LLButton>("l_upl_btn")->setVisible(!mode); - self->getChild<LLScrollListCtrl>("l_name_list")->setVisible(!mode); -} - -// static -void LLFloaterTexturePicker::onBtnAdd(void* userdata) -{ - if (LLLocalBitmapMgr::addUnit() == true) - { - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - LLLocalBitmapMgr::feedScrollList(self->mLocalScrollCtrl); - } -} - -// static -void LLFloaterTexturePicker::onBtnRemove(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - std::vector<LLScrollListItem*> selected_items = self->mLocalScrollCtrl->getAllSelected(); - - if (!selected_items.empty()) - { - for(std::vector<LLScrollListItem*>::iterator iter = selected_items.begin(); - iter != selected_items.end(); iter++) - { - LLScrollListItem* list_item = *iter; - if (list_item) - { - LLUUID tracking_id = list_item->getColumn(LOCAL_TRACKING_ID_COLUMN)->getValue().asUUID(); - LLLocalBitmapMgr::delUnit(tracking_id); - } - } - - self->getChild<LLButton>("l_rem_btn")->setEnabled(false); - self->getChild<LLButton>("l_upl_btn")->setEnabled(false); - LLLocalBitmapMgr::feedScrollList(self->mLocalScrollCtrl); - } - -} - -// static -void LLFloaterTexturePicker::onBtnUpload(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - std::vector<LLScrollListItem*> selected_items = self->mLocalScrollCtrl->getAllSelected(); - - if (selected_items.empty()) - { - return; - } - - /* currently only allows uploading one by one, picks the first item from the selection list. (not the vector!) - in the future, it might be a good idea to check the vector size and if more than one units is selected - opt for multi-image upload. */ - - LLUUID tracking_id = (LLUUID)self->mLocalScrollCtrl->getSelectedItemLabel(LOCAL_TRACKING_ID_COLUMN); - std::string filename = LLLocalBitmapMgr::getFilename(tracking_id); - - if (!filename.empty()) - { - LLFloaterReg::showInstance("upload_image", LLSD(filename)); - } - -} - -//static -void LLFloaterTexturePicker::onLocalScrollCommit(LLUICtrl* ctrl, void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - std::vector<LLScrollListItem*> selected_items = self->mLocalScrollCtrl->getAllSelected(); - bool has_selection = !selected_items.empty(); - - self->getChild<LLButton>("l_rem_btn")->setEnabled(has_selection); - self->getChild<LLButton>("l_upl_btn")->setEnabled(has_selection && (selected_items.size() < 2)); - /* since multiple-localbitmap upload is not implemented, upl button gets disabled if more than one is selected. */ - - if (has_selection) - { - LLUUID tracking_id = (LLUUID)self->mLocalScrollCtrl->getSelectedItemLabel(LOCAL_TRACKING_ID_COLUMN); - LLUUID inworld_id = LLLocalBitmapMgr::getWorldID(tracking_id); - if (self->mSetImageAssetIDCallback) - { - self->mSetImageAssetIDCallback(inworld_id); - } - - if (self->childGetValue("apply_immediate_check").asBoolean()) - { - if (self->mOnFloaterCommitCallback) - { - self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, inworld_id); - } - } - } -} - -// static -void LLFloaterTexturePicker::onShowFolders(LLUICtrl* ctrl, void *user_data) -{ - LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; - LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; - - if (check_box->get()) - { - picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - } - else - { - picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NO_FOLDERS); - } -} - -// static -void LLFloaterTexturePicker::onApplyImmediateCheck(LLUICtrl* ctrl, void *user_data) -{ - LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; - - LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; - gSavedSettings.setBOOL("TextureLivePreview", check_box->get()); - - picker->updateFilterPermMask(); - picker->commitIfImmediateSet(); -} - -void LLFloaterTexturePicker::updateFilterPermMask() -{ - //mInventoryPanel->setFilterPermMask( getFilterPermMask() ); Commented out due to no-copy texture loss. -} - -void LLFloaterTexturePicker::setCanApply(bool can_preview, bool can_apply) -{ - getChildRef<LLUICtrl>("Select").setEnabled(can_apply); - getChildRef<LLUICtrl>("preview_disabled").setVisible(!can_preview); - getChildRef<LLUICtrl>("apply_immediate_check").setVisible(can_preview); - - mCanApply = can_apply; - mCanPreview = can_preview ? gSavedSettings.getBOOL("TextureLivePreview") : false; - mPreviewSettingChanged = true; -} - -void LLFloaterTexturePicker::setLocalTextureEnabled(BOOL enabled) -{ - mModeSelector->setIndexEnabled(1,enabled); -} - -void LLFloaterTexturePicker::onTextureSelect( const LLTextureEntry& te ) -{ - LLUUID inventory_item_id = findItemID(te.getID(), TRUE); - if (inventory_item_id.notNull()) - { - LLToolPipette::getInstance()->setResult(TRUE, ""); - setImageID(te.getID()); - - mNoCopyTextureSelected = FALSE; - LLInventoryItem* itemp = gInventory.getItem(inventory_item_id); - - if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) - { - // no copy texture - mNoCopyTextureSelected = TRUE; - } - - commitIfImmediateSet(); - } - else - { - LLToolPipette::getInstance()->setResult(FALSE, LLTrans::getString("InventoryNoTexture")); - } -} - -/////////////////////////////////////////////////////////////////////// -// LLTextureCtrl - -static LLDefaultChildRegistry::Register<LLTextureCtrl> r("texture_picker"); - -LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) -: LLUICtrl(p), - mDragCallback(NULL), - mDropCallback(NULL), - mOnCancelCallback(NULL), - mOnCloseCallback(NULL), - mOnSelectCallback(NULL), - mBorderColor( p.border_color() ), - mAllowNoTexture( FALSE ), - mImmediateFilterPermMask( PERM_NONE ), - mNonImmediateFilterPermMask( PERM_NONE ), - mCanApplyImmediately( FALSE ), - mNeedsRawImageData( FALSE ), - mValid( TRUE ), - mShowLoadingPlaceholder( TRUE ), - mImageAssetID(p.image_id), - mDefaultImageAssetID(p.default_image_id), - mDefaultImageName(p.default_image_name), - mFallbackImage(p.fallback_image) -{ - - // Default of defaults is white image for diff tex - // - LLUUID whiteImage( gSavedSettings.getString( "UIImgWhiteUUID" ) ); - setBlankImageAssetID( whiteImage ); - - setAllowNoTexture(p.allow_no_texture); - setCanApplyImmediately(p.can_apply_immediately); - mCommitOnSelection = !p.no_commit_on_selection; - - LLTextBox::Params params(p.caption_text); - params.name(p.label); - params.rect(LLRect( 0, BTN_HEIGHT_SMALL, getRect().getWidth(), 0 )); - params.initial_value(p.label()); - params.follows.flags(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_BOTTOM); - mCaption = LLUICtrlFactory::create<LLTextBox> (params); - addChild( mCaption ); - - S32 image_top = getRect().getHeight(); - S32 image_bottom = BTN_HEIGHT_SMALL; - S32 image_middle = (image_top + image_bottom) / 2; - S32 line_height = LLFontGL::getFontSansSerifSmall()->getLineHeight(); - - LLTextBox::Params tentative_label_p(p.multiselect_text); - tentative_label_p.name("Multiple"); - tentative_label_p.rect(LLRect (0, image_middle + line_height / 2, getRect().getWidth(), image_middle - line_height / 2 )); - tentative_label_p.follows.flags(FOLLOWS_ALL); - mTentativeLabel = LLUICtrlFactory::create<LLTextBox> (tentative_label_p); - - // It is no longer possible to associate a style with a textbox, so it has to be done in this fashion - LLStyle::Params style_params; - style_params.color = LLColor4::white; - - mTentativeLabel->setText(LLTrans::getString("multiple_textures"), style_params); - mTentativeLabel->setHAlign(LLFontGL::HCENTER); - addChild( mTentativeLabel ); - - LLRect border_rect = getLocalRect(); - border_rect.mBottom += BTN_HEIGHT_SMALL; - LLViewBorder::Params vbparams(p.border); - vbparams.name("border"); - vbparams.rect(border_rect); - mBorder = LLUICtrlFactory::create<LLViewBorder> (vbparams); - addChild(mBorder); - - mLoadingPlaceholderString = LLTrans::getString("texture_loading"); -} - -LLTextureCtrl::~LLTextureCtrl() -{ - closeDependentFloater(); -} - -void LLTextureCtrl::setShowLoadingPlaceholder(BOOL showLoadingPlaceholder) -{ - mShowLoadingPlaceholder = showLoadingPlaceholder; -} - -void LLTextureCtrl::setCaption(const std::string& caption) -{ - mCaption->setText( caption ); -} - -void LLTextureCtrl::setCanApplyImmediately(BOOL b) -{ - mCanApplyImmediately = b; - LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); - if( floaterp ) - { - floaterp->setCanApplyImmediately(b); - } -} - -void LLTextureCtrl::setCanApply(bool can_preview, bool can_apply) -{ - LLFloaterTexturePicker* floaterp = dynamic_cast<LLFloaterTexturePicker*>(mFloaterHandle.get()); - if( floaterp ) - { - floaterp->setCanApply(can_preview, can_apply); - } -} - -void LLTextureCtrl::setVisible( BOOL visible ) -{ - if( !visible ) - { - closeDependentFloater(); - } - LLUICtrl::setVisible( visible ); -} - -void LLTextureCtrl::setEnabled( BOOL enabled ) -{ - LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); - if( enabled ) - { - std::string tooltip; - if (floaterp) tooltip = floaterp->getString("choose_picture"); - setToolTip( tooltip ); - } - else - { - setToolTip( std::string() ); - // *TODO: would be better to keep floater open and show - // disabled state. - closeDependentFloater(); - } - - if( floaterp ) - { - floaterp->setActive(enabled); - } - - mCaption->setEnabled( enabled ); - - LLView::setEnabled( enabled ); -} - -void LLTextureCtrl::setValid(BOOL valid ) -{ - mValid = valid; - if (!valid) - { - LLFloaterTexturePicker* pickerp = (LLFloaterTexturePicker*)mFloaterHandle.get(); - if (pickerp) - { - pickerp->setActive(FALSE); - } - } -} - - -// virtual -void LLTextureCtrl::clear() -{ - setImageAssetID(LLUUID::null); -} - -void LLTextureCtrl::setLabel(const std::string& label) -{ - mLabel = label; - mCaption->setText(label); -} - -void LLTextureCtrl::showPicker(BOOL take_focus) -{ - // show hourglass cursor when loading inventory window - // because inventory construction is slooow - getWindow()->setCursor(UI_CURSOR_WAIT); - LLFloater* floaterp = mFloaterHandle.get(); - - // Show the dialog - if( floaterp ) - { - floaterp->openFloater(); - } - else - { - floaterp = new LLFloaterTexturePicker( - this, - getImageAssetID(), - getDefaultImageAssetID(), - getBlankImageAssetID(), - getTentative(), - getAllowNoTexture(), - mLabel, - mImmediateFilterPermMask, - mDnDFilterPermMask, - mNonImmediateFilterPermMask, - mCanApplyImmediately, - mFallbackImage); - mFloaterHandle = floaterp->getHandle(); - - LLFloaterTexturePicker* texture_floaterp = dynamic_cast<LLFloaterTexturePicker*>(floaterp); - if (texture_floaterp && mOnTextureSelectedCallback) - { - texture_floaterp->setTextureSelectedCallback(mOnTextureSelectedCallback); - } - if (texture_floaterp && mOnCloseCallback) - { - texture_floaterp->setOnFloaterCloseCallback(boost::bind(&LLTextureCtrl::onFloaterClose, this)); - } - if (texture_floaterp) - { - texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2)); - } - if (texture_floaterp) - { - texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1)); - } - - LLFloater* root_floater = gFloaterView->getParentFloater(this); - if (root_floater) - root_floater->addDependentFloater(floaterp); - floaterp->openFloater(); - } - - if (take_focus) - { - floaterp->setFocus(TRUE); - } -} - - -void LLTextureCtrl::closeDependentFloater() -{ - LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); - if( floaterp ) - { - floaterp->setOwner(NULL); - floaterp->closeFloater(); - } -} - -// Allow us to download textures quickly when floater is shown -class LLTextureFetchDescendentsObserver : public LLInventoryFetchDescendentsObserver -{ -public: - virtual void done() - { - // We need to find textures in all folders, so get the main - // background download going. - LLInventoryModelBackgroundFetch::instance().start(); - gInventory.removeObserver(this); - delete this; - } -}; - -BOOL LLTextureCtrl::handleHover(S32 x, S32 y, MASK mask) -{ - getWindow()->setCursor(mBorder->parentPointInView(x,y) ? UI_CURSOR_HAND : UI_CURSOR_ARROW); - return TRUE; -} - - -BOOL LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask) -{ - BOOL handled = LLUICtrl::handleMouseDown( x, y , mask ); - - if (!handled && mBorder->parentPointInView(x, y)) - { - showPicker(FALSE); - //grab textures first... - LLInventoryModelBackgroundFetch::instance().start(gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE)); - //...then start full inventory fetch. - LLInventoryModelBackgroundFetch::instance().start(); - handled = TRUE; - } - - return handled; -} - -void LLTextureCtrl::onFloaterClose() -{ - LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); - - if (floaterp) - { - if (mOnCloseCallback) - { - mOnCloseCallback(this,LLSD()); - } - floaterp->setOwner(NULL); - } - - mFloaterHandle.markDead(); -} - -void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLUUID id) -{ - LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); - - if( floaterp && getEnabled()) - { - if (op == TEXTURE_CANCEL) - mViewModel->resetDirty(); - // If the "no_commit_on_selection" parameter is set - // we get dirty only when user presses OK in the picker - // (i.e. op == TEXTURE_SELECT) or texture changes via DnD. - else if (mCommitOnSelection || op == TEXTURE_SELECT) - mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? - - if(floaterp->isDirty() || id.notNull()) // mModelView->setDirty does not work. - { - setTentative( FALSE ); - - if (id.notNull()) - { - mImageItemID = id; - mImageAssetID = id; - } - else - { - mImageItemID = floaterp->findItemID(floaterp->getAssetID(), FALSE); - LL_DEBUGS() << "mImageItemID: " << mImageItemID << LL_ENDL; - mImageAssetID = floaterp->getAssetID(); - LL_DEBUGS() << "mImageAssetID: " << mImageAssetID << LL_ENDL; - } - - if (op == TEXTURE_SELECT && mOnSelectCallback) - { - mOnSelectCallback( this, LLSD() ); - } - else if (op == TEXTURE_CANCEL && mOnCancelCallback) - { - mOnCancelCallback( this, LLSD() ); - } - else - { - // If the "no_commit_on_selection" parameter is set - // we commit only when user presses OK in the picker - // (i.e. op == TEXTURE_SELECT) or texture changes via DnD. - if (mCommitOnSelection || op == TEXTURE_SELECT) - onCommit(); - } - } - } -} - -void LLTextureCtrl::setOnTextureSelectedCallback(texture_selected_callback cb) -{ - mOnTextureSelectedCallback = cb; - LLFloaterTexturePicker* floaterp = dynamic_cast<LLFloaterTexturePicker*>(mFloaterHandle.get()); - if (floaterp) - { - floaterp->setTextureSelectedCallback(cb); - } + return nullptr; } - -void LLTextureCtrl::setImageAssetName(const std::string& name) -{ - LLPointer<LLUIImage> imagep = LLUI::getUIImage(name); - if(imagep) - { - LLViewerFetchedTexture* pTexture = dynamic_cast<LLViewerFetchedTexture*>(imagep->getImage().get()); - if(pTexture) - { - LLUUID id = pTexture->getID(); - setImageAssetID(id); - } - } -} - -void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id ) -{ - if( mImageAssetID != asset_id ) - { - mImageItemID.setNull(); - mImageAssetID = asset_id; - LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); - if( floaterp && getEnabled() ) - { - floaterp->setImageID( asset_id ); - floaterp->resetDirty(); - } - } -} - -BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, - BOOL drop, EDragAndDropType cargo_type, void *cargo_data, - EAcceptance *accept, - std::string& tooltip_msg) -{ - BOOL handled = FALSE; - - // this downcast may be invalid - but if the second test below - // returns true, then the cast was valid, and we can perform - // the third test without problems. - LLInventoryItem* item = (LLInventoryItem*)cargo_data; - bool is_mesh = cargo_type == DAD_MESH; - - if (getEnabled() && - ((cargo_type == DAD_TEXTURE) || is_mesh) && - allowDrop(item)) - { - if (drop) - { - if(doDrop(item)) - { - if (!mCommitOnSelection) - mViewModel->setDirty(); - - // This removes the 'Multiple' overlay, since - // there is now only one texture selected. - setTentative( FALSE ); - onCommit(); - } - } - - *accept = ACCEPT_YES_SINGLE; - } - else - { - *accept = ACCEPT_NO; - } - - handled = TRUE; - LL_DEBUGS("UserInput") << "dragAndDrop handled by LLTextureCtrl " << getName() << LL_ENDL; - - return handled; -} - -void LLTextureCtrl::draw() -{ - mBorder->setKeyboardFocusHighlight(hasFocus()); - - if (!mValid) - { - mTexturep = NULL; - } - else if (!mImageAssetID.isNull()) - { - LLPointer<LLViewerFetchedTexture> texture = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES,LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - - texture->setBoostLevel(LLGLTexture::BOOST_PREVIEW); - texture->forceToSaveRawImage(0) ; - - mTexturep = texture; - } - else//mImageAssetID == LLUUID::null - { - mTexturep = NULL; - } - - // Border - LLRect border( 0, getRect().getHeight(), getRect().getWidth(), BTN_HEIGHT_SMALL ); - gl_rect_2d( border, mBorderColor.get(), FALSE ); - - // Interior - LLRect interior = border; - interior.stretch( -1 ); - - // If we're in a focused floater, don't apply the floater's alpha to the texture (STORM-677). - const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); - if( mTexturep ) - { - if( mTexturep->getComponents() == 4 ) - { - gl_rect_2d_checkerboard( interior, alpha ); - } - - gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha); - mTexturep->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) ); - } - else if (!mFallbackImage.isNull()) - { - mFallbackImage->draw(interior, UI_VERTEX_COLOR % alpha); - } - else - { - gl_rect_2d( interior, LLColor4::grey % alpha, TRUE ); - - // Draw X - gl_draw_x( interior, LLColor4::black ); - } - - mTentativeLabel->setVisible( getTentative() ); - - // Show "Loading..." string on the top left corner while this texture is loading. - // Using the discard level, do not show the string if the texture is almost but not - // fully loaded. - if (mTexturep.notNull() && - (!mTexturep->isFullyLoaded()) && - (mShowLoadingPlaceholder == TRUE)) - { - U32 v_offset = 25; - LLFontGL* font = LLFontGL::getFontSansSerif(); - - // Don't show as loaded if the texture is almost fully loaded (i.e. discard1) unless god - if ((mTexturep->getDiscardLevel() > 1) || gAgent.isGodlike()) - { - font->renderUTF8( - mLoadingPlaceholderString, - 0, - llfloor(interior.mLeft+3), - llfloor(interior.mTop-v_offset), - LLColor4::white, - LLFontGL::LEFT, - LLFontGL::BASELINE, - LLFontGL::DROP_SHADOW); - } - - // Optionally show more detailed information. - if (gSavedSettings.getBOOL("DebugAvatarRezTime")) - { - LLFontGL* font = LLFontGL::getFontSansSerif(); - std::string tdesc; - // Show what % the texture has loaded (0 to 100%, 100 is highest), and what level of detail (5 to 0, 0 is best). - - v_offset += 12; - tdesc = llformat(" PK : %d%%", U32(mTexturep->getDownloadProgress()*100.0)); - font->renderUTF8(tdesc, 0, llfloor(interior.mLeft+3), llfloor(interior.mTop-v_offset), - LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW); - - v_offset += 12; - tdesc = llformat(" LVL: %d", mTexturep->getDiscardLevel()); - font->renderUTF8(tdesc, 0, llfloor(interior.mLeft+3), llfloor(interior.mTop-v_offset), - LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW); - - v_offset += 12; - tdesc = llformat(" ID : %s...", (mImageAssetID.asString().substr(0,7)).c_str()); - font->renderUTF8(tdesc, 0, llfloor(interior.mLeft+3), llfloor(interior.mTop-v_offset), - LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW); - } - } - - LLUICtrl::draw(); -} - -BOOL LLTextureCtrl::allowDrop(LLInventoryItem* item) -{ - BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID()); - BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID()); - BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, - gAgent.getID()); - - PermissionMask item_perm_mask = 0; - if (copy) item_perm_mask |= PERM_COPY; - if (mod) item_perm_mask |= PERM_MODIFY; - if (xfer) item_perm_mask |= PERM_TRANSFER; - -// PermissionMask filter_perm_mask = mCanApplyImmediately ? commented out due to no-copy texture loss. -// mImmediateFilterPermMask : mNonImmediateFilterPermMask; - PermissionMask filter_perm_mask = mImmediateFilterPermMask; - if ( (item_perm_mask & filter_perm_mask) == filter_perm_mask ) - { - if(mDragCallback) - { - return mDragCallback(this, item); - } - else - { - return TRUE; - } - } - else - { - return FALSE; - } -} - -BOOL LLTextureCtrl::doDrop(LLInventoryItem* item) -{ - // call the callback if it exists. - if(mDropCallback) - { - // if it returns TRUE, we return TRUE, and therefore the - // commit is called above. - return mDropCallback(this, item); - } - - // no callback installed, so just set the image ids and carry on. - setImageAssetID( item->getAssetUUID() ); - mImageItemID = item->getUUID(); - return TRUE; -} - -BOOL LLTextureCtrl::handleUnicodeCharHere(llwchar uni_char) -{ - if( ' ' == uni_char ) - { - showPicker(TRUE); - return TRUE; - } - return LLUICtrl::handleUnicodeCharHere(uni_char); -} - -void LLTextureCtrl::setValue( const LLSD& value ) -{ - setImageAssetID(value.asUUID()); -} - -LLSD LLTextureCtrl::getValue() const -{ - return LLSD(getImageAssetID()); -} - -#endif diff --git a/indra/newview/llsettingspicker.h b/indra/newview/llsettingspicker.h index 968bcaa692..c3ccbe22c3 100644 --- a/indra/newview/llsettingspicker.h +++ b/indra/newview/llsettingspicker.h @@ -32,6 +32,7 @@ #include "llfloater.h" #include "llpermissionsflags.h" #include "llfolderview.h" +#include "llinventory.h" #include <boost/signals2.hpp> @@ -52,14 +53,13 @@ public: virtual ~LLFloaterSettingsPicker() override; void setActive(bool active); - void setSettingsID(const LLUUID &settings_id, bool set_selection = true); virtual BOOL postBuild() override; virtual void onClose(bool app_quitting) override; virtual void draw() override; - void setSettingsAssetID(LLUUID setting_asset_id); - LLUUID getSettingsAssetID() const { return mSettingAssetID; } + void setSettingsAssetId(const LLUUID &settings_id, bool set_selection = true); + LLUUID getSettingsAssetId() const { return mSettingAssetID; } void setDefaultSettingsAssetID(LLUUID id) { mDefaultSettingsAssetID = id; } LLUUID getDefaultSettingsAssetID() const { return mDefaultSettingsAssetID; } @@ -71,6 +71,24 @@ public: virtual void setValue(const LLSD& value) override; virtual LLSD getValue() const override; + LLUUID findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library = false) + { + LLInventoryItem *pitem = findItem(asset_id, copyable_only, ignore_library); + if (pitem) + return pitem->getUUID(); + return LLUUID::null; + } + + std::string findItemName(const LLUUID& asset_id, bool copyable_only, bool ignore_library = false) + { + LLInventoryItem *pitem = findItem(asset_id, copyable_only, ignore_library); + if (pitem) + return pitem->getName(); + return std::string(); + } + + LLInventoryItem * findItem(const LLUUID& asset_id, bool copyable_only, bool ignore_library); + private: typedef std::deque<LLFolderViewItem *> itemlist_t; @@ -79,7 +97,6 @@ private: void onButtonCancel(); void onButtonSelect(); - LLUUID findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library = false); LLView* mOwner; std::string mLabel; @@ -105,347 +122,4 @@ private: boost::signals2::signal<void(const LLUUID& asset_id)> mChangeIDSignal; }; -#if 0 -#include "llcoord.h" -#include "llfiltereditor.h" -#include "llfolderview.h" -#include "lllocalbitmaps.h" -#include "llstring.h" -#include "lluictrl.h" -#include "llradiogroup.h" -#include "lltextbox.h" // for params -#include "llviewerinventory.h" -#include "llviewborder.h" // for params -#include "llviewerobject.h" -#include "llviewertexture.h" -#include "llwindow.h" - -class LLButton; -class LLFloaterTexturePicker; -class LLInventoryItem; -class LLViewerFetchedTexture; - -// used for setting drag & drop callbacks. -typedef boost::function<BOOL (LLUICtrl*, LLInventoryItem*)> drag_n_drop_callback; -typedef boost::function<void (LLInventoryItem*)> texture_selected_callback; - - -////////////////////////////////////////////////////////////////////////////////////////// -// LLTextureCtrl - - -class LLTextureCtrl -: public LLUICtrl -{ -public: - typedef enum e_texture_pick_op - { - TEXTURE_CHANGE, - TEXTURE_SELECT, - TEXTURE_CANCEL - } ETexturePickOp; - -public: - struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> - { - Optional<LLUUID> image_id; - Optional<LLUUID> default_image_id; - Optional<std::string> default_image_name; - Optional<bool> allow_no_texture; - Optional<bool> can_apply_immediately; - Optional<bool> no_commit_on_selection; // alternative mode: commit occurs and the widget gets dirty - // only on DnD or when OK is pressed in the picker - Optional<S32> label_width; - Optional<LLUIColor> border_color; - Optional<LLUIImage*> fallback_image; - - Optional<LLTextBox::Params> multiselect_text, - caption_text; - - Optional<LLViewBorder::Params> border; - - Params() - : image_id("image"), - default_image_id("default_image_id"), - default_image_name("default_image_name"), - allow_no_texture("allow_no_texture"), - can_apply_immediately("can_apply_immediately"), - no_commit_on_selection("no_commit_on_selection", false), - label_width("label_width", -1), - border_color("border_color"), - fallback_image("fallback_image"), - multiselect_text("multiselect_text"), - caption_text("caption_text"), - border("border") - {} - }; -protected: - LLTextureCtrl(const Params&); - friend class LLUICtrlFactory; -public: - virtual ~LLTextureCtrl(); - - // LLView interface - - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, - BOOL drop, EDragAndDropType cargo_type, void *cargo_data, - EAcceptance *accept, - std::string& tooltip_msg); - virtual BOOL handleHover(S32 x, S32 y, MASK mask); - virtual BOOL handleUnicodeCharHere(llwchar uni_char); - - virtual void draw(); - virtual void setVisible( BOOL visible ); - virtual void setEnabled( BOOL enabled ); - - void setValid(BOOL valid); - - // LLUICtrl interface - virtual void clear(); - - // Takes a UUID, wraps get/setImageAssetID - virtual void setValue(const LLSD& value); - virtual LLSD getValue() const; - - // LLTextureCtrl interface - void showPicker(BOOL take_focus); - bool isPickerShown() { return !mFloaterHandle.isDead(); } - void setLabel(const std::string& label); - void setLabelWidth(S32 label_width) {mLabelWidth =label_width;} - const std::string& getLabel() const { return mLabel; } - - void setAllowNoTexture( BOOL b ) { mAllowNoTexture = b; } - bool getAllowNoTexture() const { return mAllowNoTexture; } - - const LLUUID& getImageItemID() { return mImageItemID; } - - virtual void setImageAssetName(const std::string& name); - - void setImageAssetID(const LLUUID &image_asset_id); - const LLUUID& getImageAssetID() const { return mImageAssetID; } - - void setDefaultImageAssetID( const LLUUID& id ) { mDefaultImageAssetID = id; } - const LLUUID& getDefaultImageAssetID() const { return mDefaultImageAssetID; } - - const std::string& getDefaultImageName() const { return mDefaultImageName; } - - void setBlankImageAssetID( const LLUUID& id ) { mBlankImageAssetID = id; } - const LLUUID& getBlankImageAssetID() const { return mBlankImageAssetID; } - - void setCaption(const std::string& caption); - void setCanApplyImmediately(BOOL b); - - void setCanApply(bool can_preview, bool can_apply); - - void setImmediateFilterPermMask(PermissionMask mask) - { mImmediateFilterPermMask = mask; } - void setDnDFilterPermMask(PermissionMask mask) - { mDnDFilterPermMask = mask; } - void setNonImmediateFilterPermMask(PermissionMask mask) - { mNonImmediateFilterPermMask = mask; } - PermissionMask getImmediateFilterPermMask() { return mImmediateFilterPermMask; } - PermissionMask getNonImmediateFilterPermMask() { return mNonImmediateFilterPermMask; } - - void closeDependentFloater(); - - void onFloaterClose(); - void onFloaterCommit(ETexturePickOp op, LLUUID id); - - // This call is returned when a drag is detected. Your callback - // should return TRUE if the drag is acceptable. - void setDragCallback(drag_n_drop_callback cb) { mDragCallback = cb; } - - // This callback is called when the drop happens. Return TRUE if - // the drop happened - resulting in an on commit callback, but not - // necessariliy any other change. - void setDropCallback(drag_n_drop_callback cb) { mDropCallback = cb; } - - void setOnCancelCallback(commit_callback_t cb) { mOnCancelCallback = cb; } - void setOnCloseCallback(commit_callback_t cb) { mOnCloseCallback = cb; } - void setOnSelectCallback(commit_callback_t cb) { mOnSelectCallback = cb; } - - /* - * callback for changing texture selection in inventory list of texture floater - */ - void setOnTextureSelectedCallback(texture_selected_callback cb); - - void setShowLoadingPlaceholder(BOOL showLoadingPlaceholder); - - LLViewerFetchedTexture* getTexture() { return mTexturep; } - -private: - BOOL allowDrop(LLInventoryItem* item); - BOOL doDrop(LLInventoryItem* item); - -private: - drag_n_drop_callback mDragCallback; - drag_n_drop_callback mDropCallback; - commit_callback_t mOnCancelCallback; - commit_callback_t mOnSelectCallback; - commit_callback_t mOnCloseCallback; - texture_selected_callback mOnTextureSelectedCallback; - LLPointer<LLViewerFetchedTexture> mTexturep; - LLUIColor mBorderColor; - LLUUID mImageItemID; - LLUUID mImageAssetID; - LLUUID mDefaultImageAssetID; - LLUUID mBlankImageAssetID; - LLUIImagePtr mFallbackImage; - std::string mDefaultImageName; - LLHandle<LLFloater> mFloaterHandle; - LLTextBox* mTentativeLabel; - LLTextBox* mCaption; - std::string mLabel; - BOOL mAllowNoTexture; // If true, the user can select "none" as an option - PermissionMask mImmediateFilterPermMask; - PermissionMask mDnDFilterPermMask; - PermissionMask mNonImmediateFilterPermMask; - BOOL mCanApplyImmediately; - BOOL mCommitOnSelection; - BOOL mNeedsRawImageData; - LLViewBorder* mBorder; - BOOL mValid; - BOOL mShowLoadingPlaceholder; - std::string mLoadingPlaceholderString; - S32 mLabelWidth; -}; - -////////////////////////////////////////////////////////////////////////////////////////// -// LLFloaterTexturePicker -typedef boost::function<void(LLTextureCtrl::ETexturePickOp op, LLUUID id)> floater_commit_callback; -typedef boost::function<void()> floater_close_callback; -typedef boost::function<void(const LLUUID& asset_id)> set_image_asset_id_callback; -typedef boost::function<void(LLPointer<LLViewerTexture> texture)> set_on_update_image_stats_callback; - -class LLFloaterTexturePicker : public LLFloater -{ -public: - LLFloaterTexturePicker( - LLView* owner, - LLUUID image_asset_id, - LLUUID default_image_asset_id, - LLUUID blank_image_asset_id, - BOOL tentative, - BOOL allow_no_texture, - const std::string& label, - PermissionMask immediate_filter_perm_mask, - PermissionMask dnd_filter_perm_mask, - PermissionMask non_immediate_filter_perm_mask, - BOOL can_apply_immediately, - LLUIImagePtr fallback_image_name - ); - - virtual ~LLFloaterTexturePicker(); - - // LLView overrides - /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, - BOOL drop, EDragAndDropType cargo_type, void *cargo_data, - EAcceptance *accept, - std::string& tooltip_msg); - /*virtual*/ void draw(); - /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); - - // LLFloater overrides - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onClose(bool app_settings); - - // New functions - void setImageID(const LLUUID& image_asset_id, bool set_selection = true); - void updateImageStats(); - const LLUUID& getAssetID() { return mImageAssetID; } - const LLUUID& findItemID(const LLUUID& asset_id, BOOL copyable_only, BOOL ignore_library = FALSE); - void setCanApplyImmediately(BOOL b); - - void setActive(BOOL active); - - LLView* getOwner() const { return mOwner; } - void setOwner(LLView* owner) { mOwner = owner; } - void stopUsingPipette(); - PermissionMask getFilterPermMask(); - - void updateFilterPermMask(); - void commitIfImmediateSet(); - void commitCancel(); - - void onFilterEdit(const std::string& search_string); - - void setCanApply(bool can_preview, bool can_apply); - void setTextureSelectedCallback(const texture_selected_callback& cb) { mTextureSelectedCallback = cb; } - void setOnFloaterCloseCallback(const floater_close_callback& cb) { mOnFloaterCloseCallback = cb; } - void setOnFloaterCommitCallback(const floater_commit_callback& cb) { mOnFloaterCommitCallback = cb; } - void setSetImageAssetIDCallback(const set_image_asset_id_callback& cb) { mSetImageAssetIDCallback = cb; } - void setOnUpdateImageStatsCallback(const set_on_update_image_stats_callback& cb) { mOnUpdateImageStatsCallback = cb; } - const LLUUID& getDefaultImageAssetID() { return mDefaultImageAssetID; } - const LLUUID& getBlankImageAssetID() { return mBlankImageAssetID; } - - static void onBtnSetToDefault(void* userdata); - static void onBtnSelect(void* userdata); - static void onBtnCancel(void* userdata); - void onBtnPipette(); - //static void onBtnRevert( void* userdata ); - static void onBtnBlank(void* userdata); - static void onBtnNone(void* userdata); - static void onBtnClear(void* userdata); - void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action); - static void onShowFolders(LLUICtrl* ctrl, void* userdata); - static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); - void onTextureSelect(const LLTextureEntry& te); - - static void onModeSelect(LLUICtrl* ctrl, void *userdata); - static void onBtnAdd(void* userdata); - static void onBtnRemove(void* userdata); - static void onBtnUpload(void* userdata); - static void onLocalScrollCommit(LLUICtrl* ctrl, void* userdata); - - void setLocalTextureEnabled(BOOL enabled); - -protected: - LLPointer<LLViewerTexture> mTexturep; - LLView* mOwner; - - LLUUID mImageAssetID; // Currently selected texture - LLUIImagePtr mFallbackImage; // What to show if currently selected texture is null. - LLUUID mDefaultImageAssetID; - LLUUID mBlankImageAssetID; - BOOL mTentative; - BOOL mAllowNoTexture; - LLUUID mSpecialCurrentImageAssetID; // Used when the asset id has no corresponding texture in the user's inventory. - LLUUID mOriginalImageAssetID; - - std::string mLabel; - - LLTextBox* mTentativeLabel; - LLTextBox* mResolutionLabel; - - std::string mPendingName; - BOOL mActive; - - LLFilterEditor* mFilterEdit; - LLInventoryPanel* mInventoryPanel; - PermissionMask mImmediateFilterPermMask; - PermissionMask mDnDFilterPermMask; - PermissionMask mNonImmediateFilterPermMask; - BOOL mCanApplyImmediately; - BOOL mNoCopyTextureSelected; - F32 mContextConeOpacity; - LLSaveFolderState mSavedFolderState; - BOOL mSelectedItemPinned; - - LLRadioGroup* mModeSelector; - LLScrollListCtrl* mLocalScrollCtrl; - -private: - bool mCanApply; - bool mCanPreview; - bool mPreviewSettingChanged; - - texture_selected_callback mTextureSelectedCallback; - floater_close_callback mOnFloaterCloseCallback; - floater_commit_callback mOnFloaterCommitCallback; - set_image_asset_id_callback mSetImageAssetIDCallback; - set_on_update_image_stats_callback mOnUpdateImageStatsCallback; -}; - -#endif #endif // LL_LLTEXTURECTRL_H diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 80797ae21c..a9e801a2e1 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -273,6 +273,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(LLVFS *vfs, const LLUUID &asset_i } else { + LL_WARNS("LAPRAS") << "Setting asset ID to " << asset_id << LL_ENDL; settings->setAssetId(asset_id); } } @@ -1074,6 +1075,44 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings) } +void LLSettingsVODay::buildFromOtherSetting(LLSettingsBase::ptr_t settings, LLSettingsVODay::asset_built_fn cb) +{ + if (settings->getSettingsType() == "daycycle") + { + if (cb) + cb(std::static_pointer_cast<LLSettingsDay>(settings)); + } + else + { + LLSettingsVOBase::getSettingsAsset(LLSettingsDay::GetDefaultAssetId(), + [settings, cb](LLUUID, LLSettingsBase::ptr_t pday, S32, LLExtStat){ combineIntoDayCycle(std::static_pointer_cast<LLSettingsDay>(pday), settings, cb); }); + } +} + +void LLSettingsVODay::combineIntoDayCycle(LLSettingsDay::ptr_t pday, LLSettingsBase::ptr_t settings, asset_built_fn cb) +{ + if (settings->getSettingsType() == "sky") + { + pday->setName("sky: " + settings->getName()); + pday->clearCycleTrack(1); + pday->setSettingsAtKeyframe(settings, 0.0, 1); + } + else if (settings->getSettingsType() == "water") + { + pday->setName("water: " + settings->getName()); + pday->clearCycleTrack(0); + pday->setSettingsAtKeyframe(settings, 0.0, 0); + } + else + { + pday.reset(); + } + + if (cb) + cb(pday); +} + + LLSettingsDay::ptr_t LLSettingsVODay::buildClone() { LLSD settings = cloneSettings(); diff --git a/indra/newview/llsettingsvo.h b/indra/newview/llsettingsvo.h index 15b51d0988..789739e5af 100644 --- a/indra/newview/llsettingsvo.h +++ b/indra/newview/llsettingsvo.h @@ -146,6 +146,8 @@ private: class LLSettingsVODay : public LLSettingsDay { public: + typedef std::function<void(LLSettingsDay::ptr_t day)> asset_built_fn; + LLSettingsVODay(const LLSD &data); static ptr_t buildDay(LLSD settings); @@ -155,6 +157,7 @@ public: static ptr_t buildFromLegacyMessage(const LLUUID ®ionId, LLSD daycycle, LLSD skys, LLSD water); static ptr_t buildDefaultDayCycle(); static ptr_t buildFromEnvironmentMessage(LLSD settings); + static void buildFromOtherSetting(LLSettingsBase::ptr_t settings, asset_built_fn cb); virtual ptr_t buildClone() override; static LLSD convertToLegacy(const ptr_t &); @@ -166,6 +169,9 @@ public: protected: LLSettingsVODay(); + +private: + static void combineIntoDayCycle(LLSettingsDay::ptr_t, LLSettingsBase::ptr_t, asset_built_fn); }; diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml index 334de8e3db..37c4e3ff8d 100644 --- a/indra/newview/skins/default/xui/en/floater_about_land.xml +++ b/indra/newview/skins/default/xui/en/floater_about_land.xml @@ -2106,7 +2106,7 @@ Only large parcels can be listed in search. top="0" help_topic="land_experiences_tab" name="land_experiences_panel" - class="land_experiences_panel" + class="land_experiences_panel" filename="panel_region_experiences.xml"> </panel> <panel @@ -2118,7 +2118,7 @@ Only large parcels can be listed in search. top="0" help_topic="land_environment_tab" name="land_environment_panel" - class="land_environment_panel" + class="land_environment_panel" filename="panel_region_environment.xml"> </panel> </tab_container> 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 41f58eef01..c1cfe79ba4 100644 --- a/indra/newview/skins/default/xui/en/panel_region_environment.xml +++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml @@ -1,82 +1,109 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <panel - border="true" - follows="top|left" - height="300" - label="Environment" - layout="topleft" - help_topic="panel_region_environment_tab" - name="panel_env_info" - width="530"> + border="true" + follows="top|left" + height="300" + label="Environment" + layout="topleft" + help_topic="panel_region_environment_tab" + name="panel_env_info" + width="420"> + <string name="str_label_use_default">Use Default Settings</string> + <string name="str_label_use_region">Use Region Settings</string> + <string name="str_unknow_inventory">Unknown</string> + <layout_stack - left_offset="0" - top_offset="0" width="420" - height="250" + height="450" follows="left|right|top|bottom" orientation="vertical"> <layout_panel - auto_resize="false" - user_resize="true" - bg_alpha_color="red" - min_height="130" - background_visible="false"> + auto_resize="true" + user_resize="false"> <layout_stack - left_offset="5" - top_offset="5" - right_offset="-5" + left="5" + top="5" + right="-5" follows="left|right|top|bottom" orientation="horizontal"> <layout_panel + background_visible="true" border="true" bevel_style="in" - auto_resize="false" + auto_resize="true" user_resize="false" - width="160" - background_visible="true"> + width="260" + min_width="260"> <text follows="top|left" + font="SansSerif" halign="left" - text_color="white">Environment Source</text> + text_color="white">Current Environment</text> <radio_group - follows="top|left" - height="45" + height="90" layout="topleft" + top_pad="5" left_delta="10" - name="environment_select_radio_group" - bottom_delta="50" - max_width="200" - width="200"> + name="rdg_environment_select"> <radio_item - label="Use Region Settings" + label="[USEDEFAULT]" layout="topleft" - name="use_region_setting" + name="rdo_use_xxx_setting" height="20"/> <radio_item + label="Settings From Inventory" + layout="topleft" + valign="top" + name="rdo_use_inv_setting" + height="20"/> + <radio_item + top_pad="25" label="Custom Environment" layout="topleft" height="20" - name="use_custom_setting"/> + name="rdo_use_custom_setting"/> </radio_group> + <line_editor + follows="top|left" + enabled="false" + left_delta="20" + top_delta="50" + height="20" + layout="topleft" + name="edt_inventory_name" + width="200"> + Unknown + </line_editor> <button - follows="top|right" + name="btn_select_inventory" + follows="top|left" + image_overlay="Command_Inventory_Icon" + auto_resize="false" + layout="topleft" + height="20" + width="20" + left_delta="205" + top_delta="0"/> + <button + follows="top|left" + top_pad="25" + left_delta="-205" + layout="topleft" height="23" - label="Edit Custom" - right_offset="30" - bottom_offset="30" - width="100" - name="edit_btn"/> + label="Edit Environment" + width="120" + name="btn_edit"/> </layout_panel> <layout_panel border="true" bevel_style="in" - auto_resize="false" - user_resize="true" - height="11" - width="220" + auto_resize="true" + user_resize="false" background_visible="true"> - <text follows="top|left|right" + <text + font="SansSerif" + follows="top|left|right" halign="left" text_color="white">Day Settings</text> <text @@ -101,10 +128,10 @@ layout="topleft" left_delta="0" top_pad="6" - name="day_length_sld" + name="sld_day_length" min_val="4" max_val="178" - width="200" /> + width="180" /> <text type="string" length="1" @@ -127,53 +154,44 @@ layout="topleft" left_delta="0" top_pad="6" - name="day_offset_sld" + name="sld_day_offset" min_val="-12" max_val="12" - width="200" /> + width="180" /> </layout_panel> - <layout_panel name="flex" - auto_resize="true" - user_resize="true" - visible="false" - bg_alpha_color="blue" - height="100" - background_visible="true"> - </layout_panel> </layout_stack> </layout_panel> <layout_panel auto_resize="true" - user_resize="true" + user_resize="false" height="21" - min_height="0" - background_visible="false"> - <check_box - height="16" - label="Parcel Owners May Override" - layout="topleft" - left_offset="10" - top_offset="10" - name="allow_override_chk" - width="200" /> - <button - follows="top|left" - height="23" - label="Apply" - left_offset="160" - top_offset="60" - name="apply_btn" - width="100" /> - <button - follows="top|left" - height="23" - label="Cancel" - layout="topleft" - left_pad="10" - name="cancel_btn" - width="100" /> - + min_height="0"> + <check_box + height="20" + label="Parcel Owners May Override Environment" + layout="topleft" + left="10" + top="10" + name="chk_allow_override" + width="200" /> + <button + follows="top|left" + height="23" + label="Apply" + top_pad="10" + name="btn_apply" + width="100" /> + <button + follows="top|left" + height="23" + label="Reset" + layout="topleft" + left_pad="10" + top_delta="0" + name="btn_cancel" + width="100" /> + </layout_panel> </layout_stack> </panel> |