From 68158f0340729d9f7e5a4b3e64bfc154a105ab6c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 16 Aug 2018 09:43:54 -0700 Subject: Pass call backs into parcel and region change methods. --- indra/newview/llenvironment.cpp | 44 ++++++++++++------------- indra/newview/llenvironment.h | 20 +++++------ indra/newview/llfloaterland.cpp | 36 -------------------- indra/newview/llfloaterregioninfo.cpp | 9 ++--- indra/newview/llpanelenvironment.cpp | 62 +++++++++++++++++++++++++++-------- indra/newview/llpanelenvironment.h | 9 +++-- 6 files changed, 91 insertions(+), 89 deletions(-) (limited to 'indra') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 66063564c0..98fe593aeb 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1025,7 +1025,7 @@ void LLEnvironment::requestRegion(environment_apply_fn cb) requestParcel(INVALID_PARCEL_ID, cb); } -void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { @@ -1033,10 +1033,10 @@ void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_lengt return; } - updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, cb); } -void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb) { if (!isExtendedEnvironmentEnabled()) { @@ -1045,23 +1045,23 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, S32 day_length, S32 day return; } - updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, asset_id, day_length, day_offset, cb); } -void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, environment_apply_fn cb) { - updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, psky, day_length, day_offset, cb); } -void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +void LLEnvironment::updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, environment_apply_fn cb) { - updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset); + updateParcel(INVALID_PARCEL_ID, pwater, day_length, day_offset, cb); } -void LLEnvironment::resetRegion() +void LLEnvironment::resetRegion(environment_apply_fn cb) { - resetParcel(INVALID_PARCEL_ID); + resetParcel(INVALID_PARCEL_ID, cb); } void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) @@ -1076,12 +1076,12 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb) [this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); }); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb) { std::string coroname = 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, parcel_id, asset_id, day_length, day_offset, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + LLSettingsDay::ptr_t(), asset_id, day_length, day_offset, cb); }); } void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset) @@ -1112,33 +1112,33 @@ void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::p updateParcel(parcel_id, pday, day_length, day_offset); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, environment_apply_fn cb) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, psky); - updateParcel(parcel_id, pday, day_length, day_offset); + updateParcel(parcel_id, pday, day_length, day_offset, cb); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, environment_apply_fn cb) { LLSettingsDay::ptr_t pday = createDayCycleFromEnvironment((parcel_id == INVALID_PARCEL_ID) ? ENV_REGION : ENV_PARCEL, pwater); - updateParcel(parcel_id, pday, day_length, day_offset); + updateParcel(parcel_id, pday, day_length, day_offset, cb); } -void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset) +void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb) { std::string coroname = 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, parcel_id, pday, day_length, day_offset, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, + pday, LLUUID::null, day_length, day_offset, cb); }); } -void LLEnvironment::resetParcel(S32 parcel_id) +void LLEnvironment::resetParcel(S32 parcel_id, environment_apply_fn cb) { std::string coroname = LLCoros::instance().launch("LLEnvironment::coroResetEnvironment", - [this, parcel_id]() { coroResetEnvironment(parcel_id, NO_TRACK, environment_apply_fn()); }); + [this, parcel_id, cb]() { coroResetEnvironment(parcel_id, NO_TRACK, cb); }); } void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply) diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 5acec97bd9..eadbb3e941 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -232,17 +232,17 @@ public: void onLegacyRegionSettings(LLSD data); 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 updateRegion(const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); + void updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); + void updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); + void updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); + void resetRegion(environment_apply_fn cb = environment_apply_fn()); 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); - void updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset); - void resetParcel(S32 parcel_id); + void updateParcel(S32 parcel_id, const LLUUID &asset_id, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); + void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); + void updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); + void updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, environment_apply_fn cb = environment_apply_fn()); + void resetParcel(S32 parcel_id, environment_apply_fn cb = environment_apply_fn()); void selectAgentEnvironment(); diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 5fcd3df7a8..57d34c5c5a 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -157,9 +157,6 @@ public: virtual bool canEdit(); protected: - virtual void doApply(); - - LLSafeHandle& mParcel; }; @@ -3306,36 +3303,3 @@ bool LLPanelLandEnvironment::canEdit() 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()); -// } -} diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index eb42ede8a8..cbb99f1854 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -187,13 +187,13 @@ public: virtual LLParcel * getParcel() override { return nullptr; } virtual bool canEdit() override { return LLEnvironment::instance().canAgentUpdateRegionEnvironment(); } - bool refreshFromRegion(LLViewerRegion* region); - void refreshFromEstate(); + bool refreshFromRegion(LLViewerRegion* region); + void refreshFromEstate(); - virtual BOOL postBuild() override; + virtual BOOL postBuild() override; protected: - virtual void doApply(); + virtual void doApply() override; virtual void doEditCommited(LLSettingsDay::ptr_t &newday); BOOL sendUpdate(); @@ -3418,6 +3418,7 @@ void LLPanelRegionEnvironment::refreshFromEstate() void LLPanelRegionEnvironment::doApply() { + LLPanelEnvironmentInfo::doApply(); // if (mRegionSettingsRadioGroup->getSelectedIndex() == 0) // { // LLEnvironment::instance().resetRegion(); diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index a2788124e7..d323e5f43b 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -221,6 +221,8 @@ LLFloaterEditExtDayCycle * LLPanelEnvironmentInfo::getEditFloater() void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) { + S32 rdo_selection = getChild(RDG_ENVIRONMENT_SELECT)->getSelectedIndex(); + getChild(RDG_ENVIRONMENT_SELECT)->setEnabled(enabled); getChild(RDO_USEDEFAULT)->setEnabled(enabled); getChild(RDO_USEINV)->setEnabled(enabled); @@ -228,8 +230,8 @@ void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) getChild(EDT_INVNAME)->setEnabled(FALSE); getChild(BTN_SELECTINV)->setEnabled(enabled); getChild(BTN_EDIT)->setEnabled(enabled); - getChild(SLD_DAYLENGTH)->setEnabled(enabled); - getChild(SLD_DAYOFFSET)->setEnabled(enabled); + getChild(SLD_DAYLENGTH)->setEnabled(enabled && (rdo_selection != 0)); + getChild(SLD_DAYOFFSET)->setEnabled(enabled && (rdo_selection != 0)); getChild(CHK_ALLOWOVERRIDE)->setEnabled(enabled && (mCurrentParcelId == INVALID_PARCEL_ID)); getChild(BTN_APPLY)->setEnabled(enabled && (mDirtyFlag != 0)); getChild(BTN_CANCEL)->setEnabled(enabled && (mDirtyFlag != 0)); @@ -259,19 +261,23 @@ void LLPanelEnvironmentInfo::setDirtyFlag(S32 flag) getChildView(BTN_CANCEL)->setEnabled((mDirtyFlag != 0) && can_edit); } +void LLPanelEnvironmentInfo::clearDirtyFlag(S32 flag) +{ + bool can_edit = canEdit(); + mDirtyFlag &= ~flag; + getChildView(BTN_APPLY)->setEnabled((mDirtyFlag != 0) && can_edit); + getChildView(BTN_CANCEL)->setEnabled((mDirtyFlag != 0) && can_edit); +} + void LLPanelEnvironmentInfo::onSwitchDefaultSelection() { + bool can_edit = canEdit(); setDirtyFlag(DIRTY_FLAG_DAYCYCLE); -// bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; -// -// getChild("edit_btn")->setEnabled(!use_defaults); -// -// mDayLengthSlider->setEnabled(!use_defaults); -// mDayOffsetSlider->setEnabled(!use_defaults); -// -// setDirty(true); -} + S32 rdo_selection = getChild(RDG_ENVIRONMENT_SELECT)->getSelectedIndex(); + getChild(SLD_DAYLENGTH)->setEnabled(can_edit && (rdo_selection != 0)); + getChild(SLD_DAYOFFSET)->setEnabled(can_edit && (rdo_selection != 0)); +} void LLPanelEnvironmentInfo::onSldDayLengthChanged(F32 value) { @@ -281,7 +287,6 @@ void LLPanelEnvironmentInfo::onSldDayLengthChanged(F32 value) setDirtyFlag(DIRTY_FLAG_DAYLENGTH); } - void LLPanelEnvironmentInfo::onSldDayOffsetChanged(F32 value) { F32Hours dayoffset(value); @@ -295,7 +300,7 @@ void LLPanelEnvironmentInfo::onSldDayOffsetChanged(F32 value) void LLPanelEnvironmentInfo::onBtnApply() { -// doApply(); + doApply(); } void LLPanelEnvironmentInfo::onBtnReset() @@ -323,6 +328,35 @@ void LLPanelEnvironmentInfo::onBtnSelect() } } + +void LLPanelEnvironmentInfo::doApply() +{ + if (getIsDirtyFlag(DIRTY_FLAG_MASK)) + { + S32 rdo_selection = getChild(RDG_ENVIRONMENT_SELECT)->getSelectedIndex(); + + if (rdo_selection == 0) + { + LLEnvironment::instance().resetParcel(mCurrentParcelId, + [this](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) {handleEnvironmentReceived(parcel_id, envifo); }); + } + else if (rdo_selection == 1) + { + LLEnvironment::instance().updateParcel(mCurrentParcelId, + mCurrentEnvironment->mDayCycle->getAssetId(), mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), + [this](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) {handleEnvironmentReceived(parcel_id, envifo); }); + } + else + { + LLEnvironment::instance().updateParcel(mCurrentParcelId, + mCurrentEnvironment->mDayCycle, mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), + [this](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) {handleEnvironmentReceived(parcel_id, envifo); }); + } + + } + setControlsEnabled(false); +} + void LLPanelEnvironmentInfo::onPickerCommited(LLUUID asset_id) { LLSettingsVOBase::getSettingsAsset(asset_id, [this](LLUUID, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { @@ -358,7 +392,7 @@ void LLPanelEnvironmentInfo::handleEnvironmentReceived(S32 parcel_id, LLEnvironm return; } mCurrentEnvironment = envifo; - setDirtyFlag(DIRTY_FLAG_DAYCYCLE); + clearDirtyFlag(DIRTY_FLAG_MASK); refresh(); } diff --git a/indra/newview/llpanelenvironment.h b/indra/newview/llpanelenvironment.h index 29c9c411ba..66224f8ba7 100644 --- a/indra/newview/llpanelenvironment.h +++ b/indra/newview/llpanelenvironment.h @@ -89,8 +89,10 @@ protected: 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 clearDirtyFlag(S32 flag); + bool getIsDirty() const { return (mDirtyFlag != 0); } + bool getIsDirtyFlag(S32 flag) const { return ((mDirtyFlag & flag) != 0); } + S32 getDirtyFlag() const { return mDirtyFlag; } void onSwitchDefaultSelection(); void onSldDayLengthChanged(F32 value); @@ -100,10 +102,11 @@ protected: void onBtnEdit(); void onBtnSelect(); + virtual void doApply(); + void onPickerCommited(LLUUID asset_id); void onEditiCommited(LLSettingsDay::ptr_t newday); void onPickerAssetDownloaded(LLSettingsBase::ptr_t settings); - void handleEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo); virtual void doEditCommited(LLSettingsDay::ptr_t &newday); -- cgit v1.2.3