diff options
Diffstat (limited to 'indra/newview/llfloaterland.cpp')
-rw-r--r-- | indra/newview/llfloaterland.cpp | 165 |
1 files changed, 164 insertions, 1 deletions
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 88b3fb7b96..25cbf2f576 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -78,9 +78,11 @@ #include "lltrans.h" #include "llpanelexperiencelisteditor.h" #include "llpanelexperiencepicker.h" +#include "llpanelenvironment.h" #include "llexperiencecache.h" #include "llgroupactions.h" +#include "llenvironment.h" const F64 COVENANT_REFRESH_TIME_SEC = 60.0f; @@ -138,6 +140,33 @@ protected: LLPanelExperienceListEditor* mBlocked; }; + +class LLPanelLandEnvironment + : public LLPanelEnvironmentInfo +{ +public: + LLPanelLandEnvironment(LLSafeHandle<LLParcelSelection>& parcelp); + + virtual bool isRegion() const override { return false; } + + virtual BOOL postBuild() override; + virtual void refresh() override; + + virtual LLParcel * getParcel() override; + + virtual bool canEdit() override; + virtual S32 getParcelId() override; + +protected: + virtual void refreshFromSource() override; + + bool isSameRegion(); + + LLSafeHandle<LLParcelSelection> & mParcel; + S32 mLastParcelId; +}; + + // inserts maturity info(icon and text) into target textbox // names_floater - pointer to floater which contains strings with maturity icons filenames // str_to_parse is string in format "txt1[MATURITY]txt2" where maturity icon and text will be inserted instead of [MATURITY] @@ -226,7 +255,7 @@ LLPanelLandCovenant* LLFloaterLand::getCurrentPanelLandCovenant() // static void LLFloaterLand::refreshAll() { - LLFloaterLand* land_instance = LLFloaterReg::getTypedInstance<LLFloaterLand>("about_land"); + LLFloaterLand* land_instance = LLFloaterReg::findTypedInstance<LLFloaterLand>("about_land"); if(land_instance) { land_instance->refresh(); @@ -277,6 +306,7 @@ LLFloaterLand::LLFloaterLand(const LLSD& seed) mFactoryMap["land_media_panel"] = LLCallbackMap(createPanelLandMedia, this); mFactoryMap["land_access_panel"] = LLCallbackMap(createPanelLandAccess, this); mFactoryMap["land_experiences_panel"] = LLCallbackMap(createPanelLandExperiences, this); + mFactoryMap["land_environment_panel"] = LLCallbackMap(createPanelLandEnvironment, this); sObserver = new LLParcelSelectionObserver(); LLViewerParcelMgr::getInstance()->addObserver( sObserver ); @@ -318,6 +348,7 @@ void LLFloaterLand::refresh() mPanelAccess->refresh(); mPanelCovenant->refresh(); mPanelExperiences->refresh(); + mPanelEnvironment->refresh(); } @@ -386,6 +417,14 @@ void* LLFloaterLand::createPanelLandExperiences(void* data) return self->mPanelExperiences; } +//static +void* LLFloaterLand::createPanelLandEnvironment(void* data) +{ + LLFloaterLand* self = (LLFloaterLand*)data; + self->mPanelEnvironment = new LLPanelLandEnvironment(self->mParcel); + return self->mPanelEnvironment; +} + //--------------------------------------------------------------------------- // LLPanelLandGeneral @@ -3211,3 +3250,127 @@ void LLPanelLandExperiences::refresh() refreshPanel(mAllowed, EXPERIENCE_KEY_TYPE_ALLOWED); refreshPanel(mBlocked, EXPERIENCE_KEY_TYPE_BLOCKED); } + +//========================================================================= + +LLPanelLandEnvironment::LLPanelLandEnvironment(LLParcelSelectionHandle& parcel) : + LLPanelEnvironmentInfo(), + mParcel(parcel), + mLastParcelId(INVALID_PARCEL_ID) +{ +} + +BOOL LLPanelLandEnvironment::postBuild() +{ + if (!LLPanelEnvironmentInfo::postBuild()) + return FALSE; + + getChild<LLUICtrl>(RDO_USEDEFAULT)->setLabelArg("[USEDEFAULT]", getString(STR_LABEL_USEREGION)); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setVisible(FALSE); + getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(FALSE); + return TRUE; +} + +void LLPanelLandEnvironment::refresh() +{ + if (gDisconnected) + return; + + if (!isSameRegion()) + { + setCrossRegion(true); + mCurrentEnvironment.reset(); + mLastParcelId = INVALID_PARCEL_ID; + setControlsEnabled(false); + return; + } + + if (mLastParcelId != getParcelId()) + { + mCurrentEnvironment.reset(); + } + + if (!mCurrentEnvironment) + { + refreshFromSource(); + return; + } + + LLPanelEnvironmentInfo::refresh(); +} + +void LLPanelLandEnvironment::refreshFromSource() +{ + LLParcel *parcel = getParcel(); + + if (!LLEnvironment::instance().isExtendedEnvironmentEnabled()) + { + setNoEnvironmentSupport(true); + setControlsEnabled(false); + return; + } + setNoEnvironmentSupport(false); + + if (!parcel) + { + setNoSelection(true); + setControlsEnabled(false); + return; + } + + setNoSelection(false); + if (isSameRegion()) + { + setCrossRegion(false); + + LLHandle<LLPanel> that_h = getHandle(); + + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + LLEnvironment::instance().requestParcel(parcel->getLocalID(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) + { + LLPanelLandEnvironment *that = (LLPanelLandEnvironment*)that_h.get(); + if (!that) return; + that->mLastParcelId = parcel_id; + that->onEnvironmentReceived(parcel_id, envifo); + }); + } + else + { + setCrossRegion(true); + mCurrentEnvironment.reset(); + mLastParcelId = INVALID_PARCEL_ID; + } + setControlsEnabled(false); +} + + +bool LLPanelLandEnvironment::isSameRegion() +{ + LLViewerRegion* regionp = LLViewerParcelMgr::instance().getSelectionRegion(); + + return (!regionp || (regionp->getRegionID() == gAgent.getRegion()->getRegionID())); +} + +LLParcel *LLPanelLandEnvironment::getParcel() +{ + return mParcel->getParcel(); +} + + +bool LLPanelLandEnvironment::canEdit() +{ + LLParcel *parcel = getParcel(); + if (!parcel) + return false; + return LLEnvironment::instance().canAgentUpdateParcelEnvironment(parcel); +} + +S32 LLPanelLandEnvironment::getParcelId() +{ + LLParcel *parcel = getParcel(); + if (!parcel) + return INVALID_PARCEL_ID; + + return parcel->getLocalID(); +} |