From 8227a0b270f6e7cc521adeb7b97ad2d5fb646973 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 21 Dec 2018 15:30:57 -0800 Subject: SL-10279: Rework the environment pannel. Still in progress. --- indra/newview/llpanelenvironment.cpp | 337 +++++++++++++++++++++++------------ 1 file changed, 227 insertions(+), 110 deletions(-) (limited to 'indra/newview/llpanelenvironment.cpp') diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index e3be46f1af..6465c25716 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -54,16 +54,20 @@ namespace { const std::string FLOATER_DAY_CYCLE_EDIT("env_edit_extdaycycle"); + + inline bool ends_with(std::string const & value, std::string const & ending) + { + if (ending.size() > value.size()) + return false; + return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); + } + } //========================================================================= -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::BTN_USEDEFAULT("btn_usedefault"); const std::string LLPanelEnvironmentInfo::SLD_DAYLENGTH("sld_day_length"); const std::string LLPanelEnvironmentInfo::SLD_DAYOFFSET("sld_day_offset"); const std::string LLPanelEnvironmentInfo::SLD_ALTITUDES("sld_altitudes"); @@ -111,9 +115,9 @@ const std::string alt_labels[] = { "alt2", "alt3", "ground", + "water", }; - static LLDefaultChildRegistry::Register r("settings_drop_target"); //========================================================================= @@ -140,16 +144,19 @@ LLPanelEnvironmentInfo::~LLPanelEnvironmentInfo() BOOL LLPanelEnvironmentInfo::postBuild() { - getChild(RDG_ENVIRONMENT_SELECT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onSwitchDefaultSelection(); }); + getChild(BTN_USEDEFAULT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnDefault(); }); getChild(BTN_SELECTINV)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnSelect(); }); getChild(BTN_EDIT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnEdit(); }); getChild(BTN_APPLY)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnApply(); }); getChild(BTN_CANCEL)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnReset(); }); getChild(SLD_DAYLENGTH)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged(value.asReal()); }); + getChild(SLD_DAYLENGTH)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); getChild(SLD_DAYOFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayOffsetChanged(value.asReal()); }); + getChild(SLD_DAYOFFSET)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); getChild(SLD_ALTITUDES)->setCommitCallback([this](LLUICtrl *cntrl, const LLSD &value) { onAltSliderCallback(cntrl, value); }); + getChild(SLD_ALTITUDES)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onAltSliderMouseUp(); }); mChangeMonitor = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32 version) { onEnvironmentChanged(env, version); }); @@ -211,31 +218,31 @@ void LLPanelEnvironmentInfo::refresh() return; } - S32 rdo_selection = 0; - if ((!mCurrentEnvironment->mDayCycle) || - ((mCurrentEnvironment->mParcelId == INVALID_PARCEL_ID) && (mCurrentEnvironment->mDayCycle->getAssetId() == LLSettingsDay::GetDefaultAssetId() ))) - { - getChild(EDT_INVNAME)->setValue(""); - } - else if (!mCurrentEnvironment->mDayCycle->getAssetId().isNull()) - { - rdo_selection = 1; - - LLUUID asset_id = mCurrentEnvironment->mDayCycle->getAssetId(); - - std::string inventoryname = getInventoryNameForAssetId(asset_id); - - if (inventoryname.empty()) - inventoryname = "(" + mCurrentEnvironment->mDayCycle->getName() + ")"; - - getChild(EDT_INVNAME)->setValue(inventoryname); - } - else - { // asset id is null so this is a custom environment - rdo_selection = 2; - getChild(EDT_INVNAME)->setValue(""); - } - getChild(RDG_ENVIRONMENT_SELECT)->setSelectedIndex(rdo_selection); +// S32 rdo_selection = 0; +// if ((!mCurrentEnvironment->mDayCycle) || +// ((mCurrentEnvironment->mParcelId == INVALID_PARCEL_ID) && (mCurrentEnvironment->mDayCycle->getAssetId() == LLSettingsDay::GetDefaultAssetId() ))) +// { +// getChild(EDT_INVNAME)->setValue(""); +// } +// else if (!mCurrentEnvironment->mDayCycle->getAssetId().isNull()) +// { +// rdo_selection = 1; +// +// LLUUID asset_id = mCurrentEnvironment->mDayCycle->getAssetId(); +// +// std::string inventoryname = getInventoryNameForAssetId(asset_id); +// +// if (inventoryname.empty()) +// inventoryname = "(" + mCurrentEnvironment->mDayCycle->getName() + ")"; +// +// getChild(EDT_INVNAME)->setValue(inventoryname); +// } +// else +// { // asset id is null so this is a custom environment +// rdo_selection = 2; +// getChild(EDT_INVNAME)->setValue(""); +// } +// getChild(RDG_ENVIRONMENT_SELECT)->setSelectedIndex(rdo_selection); F32Hours daylength(mCurrentEnvironment->mDayLength); F32Hours dayoffset(mCurrentEnvironment->mDayOffset); @@ -245,8 +252,8 @@ void LLPanelEnvironmentInfo::refresh() getChild(SLD_DAYLENGTH)->setValue(daylength.value()); getChild(SLD_DAYOFFSET)->setValue(dayoffset.value()); - getChild(SLD_DAYLENGTH)->setEnabled(canEdit() && (rdo_selection != 0) && !mCurrentEnvironment->mIsLegacy); - getChild(SLD_DAYOFFSET)->setEnabled(canEdit() && (rdo_selection != 0) && !mCurrentEnvironment->mIsLegacy); +// getChild(SLD_DAYLENGTH)->setEnabled(canEdit() && (rdo_selection != 0) && !mCurrentEnvironment->mIsLegacy); +// getChild(SLD_DAYOFFSET)->setEnabled(canEdit() && (rdo_selection != 0) && !mCurrentEnvironment->mIsLegacy); udpateApparentTimeOfDay(); @@ -271,6 +278,9 @@ void LLPanelEnvironmentInfo::refresh() readjustAltLabels(); } + updateAltLabel(alt_labels[3], 1, 0); // ground + updateAltLabel(alt_labels[4], 0, 0); // water + } std::string LLPanelEnvironmentInfo::getInventoryNameForAssetId(LLUUID asset_id) @@ -282,6 +292,27 @@ std::string LLPanelEnvironmentInfo::getInventoryNameForAssetId(LLUUID asset_id) return name; } + +std::string LLPanelEnvironmentInfo::getNameForTrackIndex(S32 index) +{ + std::string invname; + + LL_WARNS("LAPRAS") << "mDayCycleName='" << mCurrentEnvironment->mDayCycleName << "'" << LL_ENDL; + if (mCurrentEnvironment->mDayCycleName.empty()) + { + invname = mCurrentEnvironment->mNameList[index]; + } + else if (!mCurrentEnvironment->mDayCycle->isTrackEmpty(index)) + { + invname = mCurrentEnvironment->mDayCycleName; + } + + if (invname.empty()) + invname = getString("str_empty"); + + return invname; +} + LLFloaterSettingsPicker * LLPanelEnvironmentInfo::getSettingsPicker(bool create) { LLFloaterSettingsPicker *picker = static_cast(mSettingsFloater.get()); @@ -391,20 +422,13 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) getChild(PNL_BUTTONS)->setVisible(true); getChild(PNL_DISABLED)->setVisible(false); - getChild(PNL_ENVIRONMENT_ALTITUDES)->setVisible(isRegion() && LLEnvironment::instance().isExtendedEnvironmentEnabled()); - - S32 rdo_selection = getChild(RDG_ENVIRONMENT_SELECT)->getSelectedIndex(); + getChild(PNL_ENVIRONMENT_ALTITUDES)->setVisible(LLEnvironment::instance().isExtendedEnvironmentEnabled()); - bool can_enable = enabled && mCurrentEnvironment && mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION; - getChild(RDG_ENVIRONMENT_SELECT)->setEnabled(can_enable); - getChild(RDO_USEDEFAULT)->setEnabled(can_enable && !is_legacy); - getChild(RDO_USEINV)->setEnabled(false); // these two are selected automatically based on - getChild(RDO_USECUSTOM)->setEnabled(false); - getChild(EDT_INVNAME)->setEnabled(FALSE); + bool can_enable = enabled && mCurrentEnvironment && (mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION); getChild(BTN_SELECTINV)->setEnabled(can_enable && !is_legacy); getChild(BTN_EDIT)->setEnabled(can_enable); - getChild(SLD_DAYLENGTH)->setEnabled(can_enable && (rdo_selection != 0) && !is_legacy); - getChild(SLD_DAYOFFSET)->setEnabled(can_enable && (rdo_selection != 0) && !is_legacy); + getChild(SLD_DAYLENGTH)->setEnabled(can_enable && !is_legacy); + getChild(SLD_DAYOFFSET)->setEnabled(can_enable && !is_legacy); getChild(SLD_ALTITUDES)->setEnabled(can_enable && isRegion() && !is_legacy); getChild(ICN_GROUND)->setColor((can_enable && isRegion() && !is_legacy) ? LLColor4::white : LLColor4::grey % 0.8f); getChild(PNL_ENVIRONMENT_ALTITUDES)->setEnabled(can_enable && isRegion() && !is_legacy); @@ -460,7 +484,10 @@ void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_name, U32 sky // get related text box LLTextBox* text = getChild(alt_name); - if (text) + LLLineEditor *field = getChild("edt_invname_" + alt_name); + LLSettingsDropTarget *dt = getChild("sdt_" + alt_name); + + if (text && (sky_index > 1)) { // move related text box LLRect rect = text->getRect(); @@ -468,7 +495,6 @@ void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_name, U32 sky rect.mBottom = sld_bottom + (sld_offset / 2 + 1) + pos - (height / 2); rect.mTop = rect.mBottom + height; text->setRect(rect); - // update text std::ostringstream convert; convert << alt_value; @@ -477,7 +503,26 @@ void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_name, U32 sky convert.clear(); convert << sky_index; text->setTextArg("[INDEX]", convert.str()); + + if (field) + { + LLRect rect_name = field->getRect(); + S32 name_height = rect_name.getHeight(); + S32 center = rect.mBottom + (height / 2); + rect_name.mBottom = center - (name_height / 2); + rect_name.mTop = rect_name.mBottom + name_height; + + field->setRect(rect_name); + if (dt) + dt->setRect(rect_name); + } } + + if (field) + { + field->setText(getNameForTrackIndex(sky_index)); + } + } void LLPanelEnvironmentInfo::readjustAltLabels() @@ -492,10 +537,22 @@ void LLPanelEnvironmentInfo::readjustAltLabels() ground_text_rect.mTop = ground_text_rect.mBottom + height; text->setRect(ground_text_rect); +// LLMultiSliderCtrl *sld = getChild(SLD_ALTITUDES); +// for (U32 idx = 0; idx < ALTITUDE_SLIDER_COUNT; ++idx) +// { +// LLRect rect_sld = sld->getSliderThumbRect(alt_sliders[idx]); +// LLTextBox* text_cmp = getChild(alt_labels[i]); +// +// LLRect rect_text = text_cmp->getRect(); +// +// LL_WARNS("LAPRAS") << "slider[" << alt_sliders[idx] << "] -> " << rect_sld << " value=" << sld->getSliderValue(alt_sliders[idx]) LL_ENDL; +// } + + +#if 0 // Re-adjust all labels // Very simple "adjust after the fact" method // Note: labels are unordered, labels are 1 above sliders due to 'ground' - for (U32 i = 0; i < ALTITUDE_SLIDER_COUNT; i++) { LLTextBox* text_cmp = getChild(alt_labels[i]); @@ -531,17 +588,20 @@ void LLPanelEnvironmentInfo::readjustAltLabels() } } } +#endif } +#if 0 void LLPanelEnvironmentInfo::onSwitchDefaultSelection() { - bool can_edit = canEdit(); +// bool can_edit = canEdit(); setDirtyFlag(DIRTY_FLAG_DAYCYCLE); - 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)); +// 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)); } +#endif void LLPanelEnvironmentInfo::onSldDayLengthChanged(F32 value) { @@ -566,6 +626,22 @@ void LLPanelEnvironmentInfo::onSldDayOffsetChanged(F32 value) udpateApparentTimeOfDay(); } +void LLPanelEnvironmentInfo::onDayLenOffsetMouseUp() +{ + if (getDirtyFlag() & (DIRTY_FLAG_DAYLENGTH | DIRTY_FLAG_DAYOFFSET)) + { + clearDirtyFlag(DIRTY_FLAG_DAYOFFSET); + clearDirtyFlag(DIRTY_FLAG_DAYLENGTH); + + LLHandle that_h = getHandle(); + + LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), + mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), LLEnvironment::altitudes_vect_t(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + + } +} + void LLPanelEnvironmentInfo::onAltSliderCallback(LLUICtrl *cntrl, const LLSD &data) { LLMultiSliderCtrl *sld = (LLMultiSliderCtrl *)cntrl; @@ -593,6 +669,7 @@ void LLPanelEnvironmentInfo::onAltSliderCallback(LLUICtrl *cntrl, const LLSD &da iter2++; } iter->second.mAltitudeIndex = new_index; + updateAltLabel(alt_labels[iter->second.mLabelIndex], iter->second.mAltitudeIndex + 1, iter->second.mAltitude); iter++; } @@ -601,6 +678,27 @@ void LLPanelEnvironmentInfo::onAltSliderCallback(LLUICtrl *cntrl, const LLSD &da setDirtyFlag(DIRTY_FLAG_ALTITUDES); } +void LLPanelEnvironmentInfo::onAltSliderMouseUp() +{ + if (isRegion() && (getDirtyFlag() & DIRTY_FLAG_ALTITUDES)) + { + clearDirtyFlag(DIRTY_FLAG_ALTITUDES); + + LLHandle that_h = getHandle(); + LLEnvironment::altitudes_vect_t alts; + + for (auto alt : mAltitudes) + { + alts.push_back(alt.second.mAltitude); + } + + LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), + -1, -1, alts, + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + + } +} + void LLPanelEnvironmentInfo::onBtnApply() { doApply(); @@ -612,6 +710,14 @@ void LLPanelEnvironmentInfo::onBtnReset() refreshFromSource(); } +void LLPanelEnvironmentInfo::onBtnDefault() +{ + LLHandle that_h = getHandle(); + + LLEnvironment::instance().resetParcel(getParcelId(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); +} + void LLPanelEnvironmentInfo::onBtnEdit() { static const S32 FOURHOURS(4 * 60 * 60); @@ -624,7 +730,13 @@ void LLPanelEnvironmentInfo::onBtnEdit() dayeditor->openFloater(params); if (mCurrentEnvironment && mCurrentEnvironment->mDayCycle) + { dayeditor->setEditDayCycle(mCurrentEnvironment->mDayCycle); + if (!ends_with(mCurrentEnvironment->mDayCycle->getName(), "(customized)")) + { + dayeditor->setEditName(mCurrentEnvironment->mDayCycle->getName() + "(customized)"); + } + } else dayeditor->setEditDefaultDayCycle(); } @@ -649,57 +761,57 @@ void LLPanelEnvironmentInfo::onBtnSelect() void LLPanelEnvironmentInfo::doApply() { - S32 parcel_id = getParcelId(); - - if (getIsDirtyFlag(DIRTY_FLAG_MASK)) - { - LLHandle that_h = getHandle(); - LLEnvironment::altitudes_vect_t alts; - - S32 rdo_selection = getChild(RDG_ENVIRONMENT_SELECT)->getSelectedIndex(); - - if (isRegion() && getIsDirtyFlag(DIRTY_FLAG_ALTITUDES)) - { - altitudes_data_t::iterator it; - for (auto alt : mAltitudes) - { - alts.push_back(alt.second.mAltitude); - } - } +// S32 parcel_id = getParcelId(); - if (rdo_selection == 0) - { - LLEnvironment::instance().resetParcel(parcel_id, - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); - } - else if (rdo_selection == 1) - { - if (!mCurrentEnvironment) - { - // Attempting to save mid update? - LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " update state: " << mCurEnvVersion << LL_ENDL; - return; - } - LLEnvironment::instance().updateParcel(parcel_id, - mCurrentEnvironment->mDayCycle->getAssetId(), std::string(), mCurrentEnvironment->mDayLength.value(), - mCurrentEnvironment->mDayOffset.value(), alts, - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); - } - else - { - if (!mCurrentEnvironment) - { - // Attempting to save mid update? - LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " update state: " << mCurEnvVersion << LL_ENDL; - return; - } - LLEnvironment::instance().updateParcel(parcel_id, - mCurrentEnvironment->mDayCycle, mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), alts, - [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); - } - - setControlsEnabled(false); - } +// if (getIsDirtyFlag(DIRTY_FLAG_MASK)) +// { +// LLHandle that_h = getHandle(); +// LLEnvironment::altitudes_vect_t alts; +// +// // S32 rdo_selection = getChild(RDG_ENVIRONMENT_SELECT)->getSelectedIndex(); +// +// if (isRegion() && getIsDirtyFlag(DIRTY_FLAG_ALTITUDES)) +// { +// altitudes_data_t::iterator it; +// for (auto alt : mAltitudes) +// { +// alts.push_back(alt.second.mAltitude); +// } +// } + +// if (rdo_selection == 0) +// { +// LLEnvironment::instance().resetParcel(parcel_id, +// [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); +// } +// else if (rdo_selection == 1) +// { +// if (!mCurrentEnvironment) +// { +// // Attempting to save mid update? +// LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " update state: " << mCurEnvVersion << LL_ENDL; +// return; +// } +// LLEnvironment::instance().updateParcel(parcel_id, +// mCurrentEnvironment->mDayCycle->getAssetId(), std::string(), mCurrentEnvironment->mDayLength.value(), +// mCurrentEnvironment->mDayOffset.value(), alts, +// [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); +// } +// else +// { +// if (!mCurrentEnvironment) +// { +// // Attempting to save mid update? +// LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " update state: " << mCurEnvVersion << LL_ENDL; +// return; +// } +// LLEnvironment::instance().updateParcel(parcel_id, +// mCurrentEnvironment->mDayCycle, mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), alts, +// [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); +// } + +// setControlsEnabled(false); +// } } @@ -751,16 +863,19 @@ void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id) LLInventoryItem *itemp = gInventory.getItem(item_id); if (itemp) { - LLSettingsVOBase::getSettingsAsset(itemp->getAssetUUID(), [this](LLUUID, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { - if (status) - return; - onPickerAssetDownloaded(settings); - }); + LLHandle that_h = getHandle(); + + LLEnvironment::instance().updateParcel(getParcelId(), itemp->getAssetUUID(), + itemp->getName(), + -1, -1, LLEnvironment::altitudes_vect_t(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } } void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) { + LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); + LLEnvironment::instance().updateEnvironment(); if (!newday) { LL_WARNS("ENVPANEL") << "Editor committed an empty day. Do nothing." << LL_ENDL; @@ -777,9 +892,11 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) if (newhash != oldhash) { - mCurrentEnvironment->mDayCycle = newday; - setDirtyFlag(DIRTY_FLAG_DAYCYCLE); - refresh(); + LLHandle that_h = getHandle(); + + LLEnvironment::instance().updateParcel(getParcelId(), newday, + -1, -1, LLEnvironment::altitudes_vect_t(), + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } } -- cgit v1.2.3 From 5fe626afabd2857980e8011ceb6081f9e9f108c7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 2 Jan 2019 15:13:47 -0800 Subject: SL-10279: Most functionality now present. Still needs some cleanup on the bump code. --- indra/newview/llpanelenvironment.cpp | 109 ++++++----------------------------- 1 file changed, 17 insertions(+), 92 deletions(-) (limited to 'indra/newview/llpanelenvironment.cpp') diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index 6465c25716..79e3d61014 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -73,8 +73,6 @@ const std::string LLPanelEnvironmentInfo::SLD_DAYOFFSET("sld_day_offset"); const std::string LLPanelEnvironmentInfo::SLD_ALTITUDES("sld_altitudes"); const std::string LLPanelEnvironmentInfo::ICN_GROUND("icon_ground"); 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::LBL_TIMEOFDAY("lbl_apparent_time"); const std::string LLPanelEnvironmentInfo::PNL_SETTINGS("pnl_environment_config"); const std::string LLPanelEnvironmentInfo::PNL_ENVIRONMENT_ALTITUDES("pnl_environment_altitudes"); @@ -90,6 +88,7 @@ const std::string LLPanelEnvironmentInfo::STR_ALTITUDE_DESCRIPTION("str_altitude const std::string LLPanelEnvironmentInfo::STR_NO_PARCEL("str_no_parcel"); const std::string LLPanelEnvironmentInfo::STR_CROSS_REGION("str_cross_region"); const std::string LLPanelEnvironmentInfo::STR_LEGACY("str_legacy"); +const std::string LLPanelEnvironmentInfo::STR_DISALLOWED("str_disallowed"); const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_DAYCYCLE(0x01 << 0); const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_DAYLENGTH(0x01 << 1); @@ -130,7 +129,8 @@ LLPanelEnvironmentInfo::LLPanelEnvironmentInfo(): mNoEnvironment(false), mCurEnvVersion(INVALID_PARCEL_ENVIRONMENT_VERSION), mSettingsFloater(), - mEditFloater() + mEditFloater(), + mAllowOverride(false) { } @@ -147,8 +147,6 @@ BOOL LLPanelEnvironmentInfo::postBuild() getChild(BTN_USEDEFAULT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnDefault(); }); getChild(BTN_SELECTINV)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnSelect(); }); getChild(BTN_EDIT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnEdit(); }); - getChild(BTN_APPLY)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnApply(); }); - getChild(BTN_CANCEL)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnReset(); }); getChild(SLD_DAYLENGTH)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged(value.asReal()); }); getChild(SLD_DAYLENGTH)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); @@ -283,6 +281,13 @@ void LLPanelEnvironmentInfo::refresh() } +void LLPanelEnvironmentInfo::refreshFromEstate() +{ + const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + mAllowOverride = estate_info.getAllowEnvironmentOverride(); +} + std::string LLPanelEnvironmentInfo::getInventoryNameForAssetId(LLUUID asset_id) { std::string name(LLFloaterSettingsPicker::findItemName(asset_id, false, false)); @@ -406,6 +411,11 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) is_unavailable = true; getChild(TXT_DISABLED)->setText(getString(STR_CROSS_REGION)); } + else if (!isRegion() && !mAllowOverride) + { + is_unavailable = true; + getChild(TXT_DISABLED)->setText(getString(STR_DISALLOWED)); + } if (is_unavailable) { @@ -426,6 +436,7 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) bool can_enable = enabled && mCurrentEnvironment && (mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION); getChild(BTN_SELECTINV)->setEnabled(can_enable && !is_legacy); + getChild(BTN_USEDEFAULT)->setEnabled(can_enable && !is_legacy); getChild(BTN_EDIT)->setEnabled(can_enable); getChild(SLD_DAYLENGTH)->setEnabled(can_enable && !is_legacy); getChild(SLD_DAYOFFSET)->setEnabled(can_enable && !is_legacy); @@ -433,8 +444,6 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) getChild(ICN_GROUND)->setColor((can_enable && isRegion() && !is_legacy) ? LLColor4::white : LLColor4::grey % 0.8f); getChild(PNL_ENVIRONMENT_ALTITUDES)->setEnabled(can_enable && isRegion() && !is_legacy); getChild(CHK_ALLOWOVERRIDE)->setEnabled(can_enable && isRegion() && !is_legacy); - getChild(BTN_APPLY)->setEnabled(can_enable && (mDirtyFlag != 0)); - getChild(BTN_CANCEL)->setEnabled(enabled && (mDirtyFlag != 0)); getChild(SDT_DROP_TARGET)->setDndEnabled(enabled && !is_legacy); @@ -459,18 +468,12 @@ void LLPanelEnvironmentInfo::setApplyProgress(bool started) void LLPanelEnvironmentInfo::setDirtyFlag(U32 flag) { - bool can_edit = canEdit(); mDirtyFlag |= flag; - getChildView(BTN_APPLY)->setEnabled((mDirtyFlag != 0) && mCurrentEnvironment && mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION && can_edit); - getChildView(BTN_CANCEL)->setEnabled((mDirtyFlag != 0) && mCurrentEnvironment && can_edit); } void LLPanelEnvironmentInfo::clearDirtyFlag(U32 flag) { - bool can_edit = canEdit(); mDirtyFlag &= ~flag; - getChildView(BTN_APPLY)->setEnabled((mDirtyFlag != 0) && mCurrentEnvironment && mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION && can_edit); - getChildView(BTN_CANCEL)->setEnabled((mDirtyFlag != 0) && mCurrentEnvironment && can_edit); } void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_name, U32 sky_index, F32 alt_value) @@ -591,18 +594,6 @@ void LLPanelEnvironmentInfo::readjustAltLabels() #endif } -#if 0 -void LLPanelEnvironmentInfo::onSwitchDefaultSelection() -{ -// bool can_edit = canEdit(); - setDirtyFlag(DIRTY_FLAG_DAYCYCLE); - -// 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)); -} -#endif - void LLPanelEnvironmentInfo::onSldDayLengthChanged(F32 value) { F32Hours daylength(value); @@ -699,17 +690,6 @@ void LLPanelEnvironmentInfo::onAltSliderMouseUp() } } -void LLPanelEnvironmentInfo::onBtnApply() -{ - doApply(); -} - -void LLPanelEnvironmentInfo::onBtnReset() -{ - mCurrentEnvironment.reset(); - refreshFromSource(); -} - void LLPanelEnvironmentInfo::onBtnDefault() { LLHandle that_h = getHandle(); @@ -759,62 +739,6 @@ void LLPanelEnvironmentInfo::onBtnSelect() } -void LLPanelEnvironmentInfo::doApply() -{ -// S32 parcel_id = getParcelId(); - -// if (getIsDirtyFlag(DIRTY_FLAG_MASK)) -// { -// LLHandle that_h = getHandle(); -// LLEnvironment::altitudes_vect_t alts; -// -// // S32 rdo_selection = getChild(RDG_ENVIRONMENT_SELECT)->getSelectedIndex(); -// -// if (isRegion() && getIsDirtyFlag(DIRTY_FLAG_ALTITUDES)) -// { -// altitudes_data_t::iterator it; -// for (auto alt : mAltitudes) -// { -// alts.push_back(alt.second.mAltitude); -// } -// } - -// if (rdo_selection == 0) -// { -// LLEnvironment::instance().resetParcel(parcel_id, -// [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); -// } -// else if (rdo_selection == 1) -// { -// if (!mCurrentEnvironment) -// { -// // Attempting to save mid update? -// LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " update state: " << mCurEnvVersion << LL_ENDL; -// return; -// } -// LLEnvironment::instance().updateParcel(parcel_id, -// mCurrentEnvironment->mDayCycle->getAssetId(), std::string(), mCurrentEnvironment->mDayLength.value(), -// mCurrentEnvironment->mDayOffset.value(), alts, -// [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); -// } -// else -// { -// if (!mCurrentEnvironment) -// { -// // Attempting to save mid update? -// LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " update state: " << mCurEnvVersion << LL_ENDL; -// return; -// } -// LLEnvironment::instance().updateParcel(parcel_id, -// mCurrentEnvironment->mDayCycle, mCurrentEnvironment->mDayLength.value(), mCurrentEnvironment->mDayOffset.value(), alts, -// [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); -// } - -// setControlsEnabled(false); -// } -} - - void LLPanelEnvironmentInfo::udpateApparentTimeOfDay() { static const F32 SECONDSINDAY(24.0 * 60.0 * 60.0); @@ -990,6 +914,7 @@ void LLPanelEnvironmentInfo::onEnvironmentReceived(S32 parcel_id, LLEnvironment: LL_WARNS("ENVPANEL") << " Environment version was not provided for " << parcel_id << ", old env version: " << mCurEnvVersion << LL_ENDL; } + refreshFromEstate(); refresh(); // todo: we have envifo and parcel env version, should we just setEnvironment() and parcel's property to prevent dupplicate requests? -- cgit v1.2.3 From d607d81dba25dfe7dd1ecdf123af656ca939924f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 2 Jan 2019 17:10:15 -0800 Subject: SL-10279: Temp fix for stale estate info when editing parcel environment. --- indra/newview/llpanelenvironment.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpanelenvironment.cpp') diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index 79e3d61014..b4007cfdf0 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -130,7 +130,7 @@ LLPanelEnvironmentInfo::LLPanelEnvironmentInfo(): mCurEnvVersion(INVALID_PARCEL_ENVIRONMENT_VERSION), mSettingsFloater(), mEditFloater(), - mAllowOverride(false) + mAllowOverride(true) { } @@ -283,9 +283,21 @@ void LLPanelEnvironmentInfo::refresh() void LLPanelEnvironmentInfo::refreshFromEstate() { + /*TODO: Bug!! estate_info seems stale if regain floater has not been opened.*/ const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); - mAllowOverride = estate_info.getAllowEnvironmentOverride(); + if (isRegion()) + { // this should always work... but estate_info gives back false when it shouldn't for parcels + bool oldAO = mAllowOverride; + mAllowOverride = estate_info.getAllowEnvironmentOverride(); + if (oldAO != mAllowOverride) + refresh(); + } + else + { + // Get rid of this when I solve the above. + mAllowOverride = true; + } } std::string LLPanelEnvironmentInfo::getInventoryNameForAssetId(LLUUID asset_id) -- cgit v1.2.3