summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelenvironment.cpp
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-01-03 08:47:03 -0800
committerGraham Linden <graham@lindenlab.com>2019-01-03 08:47:03 -0800
commitcccb3a541c655c15c7578bb50dd762b68ccbfcac (patch)
tree724f8a16f9edbaaf461ca034a0ba413384d7c7e0 /indra/newview/llpanelenvironment.cpp
parent744e22e3645e205fa3f37ff3532bca607057887f (diff)
parentd607d81dba25dfe7dd1ecdf123af656ca939924f (diff)
Merge
Diffstat (limited to 'indra/newview/llpanelenvironment.cpp')
-rw-r--r--indra/newview/llpanelenvironment.cpp334
1 files changed, 194 insertions, 140 deletions
diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp
index e3be46f1af..b4007cfdf0 100644
--- a/indra/newview/llpanelenvironment.cpp
+++ b/indra/newview/llpanelenvironment.cpp
@@ -54,23 +54,25 @@
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");
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");
@@ -86,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);
@@ -111,9 +114,9 @@ const std::string alt_labels[] = {
"alt2",
"alt3",
"ground",
+ "water",
};
-
static LLDefaultChildRegistry::Register<LLSettingsDropTarget> r("settings_drop_target");
//=========================================================================
@@ -126,7 +129,8 @@ LLPanelEnvironmentInfo::LLPanelEnvironmentInfo():
mNoEnvironment(false),
mCurEnvVersion(INVALID_PARCEL_ENVIRONMENT_VERSION),
mSettingsFloater(),
- mEditFloater()
+ mEditFloater(),
+ mAllowOverride(true)
{
}
@@ -140,16 +144,17 @@ LLPanelEnvironmentInfo::~LLPanelEnvironmentInfo()
BOOL LLPanelEnvironmentInfo::postBuild()
{
- getChild<LLUICtrl>(RDG_ENVIRONMENT_SELECT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onSwitchDefaultSelection(); });
+ getChild<LLUICtrl>(BTN_USEDEFAULT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnDefault(); });
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(); });
getChild<LLUICtrl>(SLD_DAYLENGTH)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged(value.asReal()); });
+ getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
getChild<LLUICtrl>(SLD_DAYOFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayOffsetChanged(value.asReal()); });
+ getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
getChild<LLMultiSliderCtrl>(SLD_ALTITUDES)->setCommitCallback([this](LLUICtrl *cntrl, const LLSD &value) { onAltSliderCallback(cntrl, value); });
+ getChild<LLMultiSliderCtrl>(SLD_ALTITUDES)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onAltSliderMouseUp(); });
mChangeMonitor = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32 version) { onEnvironmentChanged(env, version); });
@@ -211,31 +216,31 @@ void LLPanelEnvironmentInfo::refresh()
return;
}
- S32 rdo_selection = 0;
- if ((!mCurrentEnvironment->mDayCycle) ||
- ((mCurrentEnvironment->mParcelId == INVALID_PARCEL_ID) && (mCurrentEnvironment->mDayCycle->getAssetId() == LLSettingsDay::GetDefaultAssetId() )))
- {
- getChild<LLUICtrl>(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<LLUICtrl>(EDT_INVNAME)->setValue(inventoryname);
- }
- else
- { // asset id is null so this is a custom environment
- rdo_selection = 2;
- getChild<LLUICtrl>(EDT_INVNAME)->setValue("");
- }
- getChild<LLRadioGroup>(RDG_ENVIRONMENT_SELECT)->setSelectedIndex(rdo_selection);
+// S32 rdo_selection = 0;
+// if ((!mCurrentEnvironment->mDayCycle) ||
+// ((mCurrentEnvironment->mParcelId == INVALID_PARCEL_ID) && (mCurrentEnvironment->mDayCycle->getAssetId() == LLSettingsDay::GetDefaultAssetId() )))
+// {
+// getChild<LLUICtrl>(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<LLUICtrl>(EDT_INVNAME)->setValue(inventoryname);
+// }
+// else
+// { // asset id is null so this is a custom environment
+// rdo_selection = 2;
+// getChild<LLUICtrl>(EDT_INVNAME)->setValue("");
+// }
+// getChild<LLRadioGroup>(RDG_ENVIRONMENT_SELECT)->setSelectedIndex(rdo_selection);
F32Hours daylength(mCurrentEnvironment->mDayLength);
F32Hours dayoffset(mCurrentEnvironment->mDayOffset);
@@ -245,8 +250,8 @@ void LLPanelEnvironmentInfo::refresh()
getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setValue(daylength.value());
getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setValue(dayoffset.value());
- getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setEnabled(canEdit() && (rdo_selection != 0) && !mCurrentEnvironment->mIsLegacy);
- getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setEnabled(canEdit() && (rdo_selection != 0) && !mCurrentEnvironment->mIsLegacy);
+// getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setEnabled(canEdit() && (rdo_selection != 0) && !mCurrentEnvironment->mIsLegacy);
+// getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setEnabled(canEdit() && (rdo_selection != 0) && !mCurrentEnvironment->mIsLegacy);
udpateApparentTimeOfDay();
@@ -271,6 +276,28 @@ void LLPanelEnvironmentInfo::refresh()
readjustAltLabels();
}
+ updateAltLabel(alt_labels[3], 1, 0); // ground
+ updateAltLabel(alt_labels[4], 0, 0); // water
+
+}
+
+void LLPanelEnvironmentInfo::refreshFromEstate()
+{
+ /*TODO: Bug!! estate_info seems stale if regain floater has not been opened.*/
+ const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance();
+
+ 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)
@@ -282,6 +309,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<LLFloaterSettingsPicker *>(mSettingsFloater.get());
@@ -375,6 +423,11 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled)
is_unavailable = true;
getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_CROSS_REGION));
}
+ else if (!isRegion() && !mAllowOverride)
+ {
+ is_unavailable = true;
+ getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_DISALLOWED));
+ }
if (is_unavailable)
{
@@ -391,26 +444,18 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled)
getChild<LLUICtrl>(PNL_BUTTONS)->setVisible(true);
getChild<LLUICtrl>(PNL_DISABLED)->setVisible(false);
- getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(isRegion() && LLEnvironment::instance().isExtendedEnvironmentEnabled());
-
- S32 rdo_selection = getChild<LLRadioGroup>(RDG_ENVIRONMENT_SELECT)->getSelectedIndex();
+ getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(LLEnvironment::instance().isExtendedEnvironmentEnabled());
- bool can_enable = enabled && mCurrentEnvironment && mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION;
- getChild<LLUICtrl>(RDG_ENVIRONMENT_SELECT)->setEnabled(can_enable);
- getChild<LLUICtrl>(RDO_USEDEFAULT)->setEnabled(can_enable && !is_legacy);
- getChild<LLUICtrl>(RDO_USEINV)->setEnabled(false); // these two are selected automatically based on
- getChild<LLUICtrl>(RDO_USECUSTOM)->setEnabled(false);
- getChild<LLUICtrl>(EDT_INVNAME)->setEnabled(FALSE);
+ bool can_enable = enabled && mCurrentEnvironment && (mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION);
getChild<LLUICtrl>(BTN_SELECTINV)->setEnabled(can_enable && !is_legacy);
+ getChild<LLUICtrl>(BTN_USEDEFAULT)->setEnabled(can_enable && !is_legacy);
getChild<LLUICtrl>(BTN_EDIT)->setEnabled(can_enable);
- getChild<LLUICtrl>(SLD_DAYLENGTH)->setEnabled(can_enable && (rdo_selection != 0) && !is_legacy);
- getChild<LLUICtrl>(SLD_DAYOFFSET)->setEnabled(can_enable && (rdo_selection != 0) && !is_legacy);
+ getChild<LLUICtrl>(SLD_DAYLENGTH)->setEnabled(can_enable && !is_legacy);
+ getChild<LLUICtrl>(SLD_DAYOFFSET)->setEnabled(can_enable && !is_legacy);
getChild<LLUICtrl>(SLD_ALTITUDES)->setEnabled(can_enable && isRegion() && !is_legacy);
getChild<LLUICtrl>(ICN_GROUND)->setColor((can_enable && isRegion() && !is_legacy) ? LLColor4::white : LLColor4::grey % 0.8f);
getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setEnabled(can_enable && isRegion() && !is_legacy);
getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setEnabled(can_enable && isRegion() && !is_legacy);
- getChild<LLUICtrl>(BTN_APPLY)->setEnabled(can_enable && (mDirtyFlag != 0));
- getChild<LLUICtrl>(BTN_CANCEL)->setEnabled(enabled && (mDirtyFlag != 0));
getChild<LLSettingsDropTarget>(SDT_DROP_TARGET)->setDndEnabled(enabled && !is_legacy);
@@ -435,18 +480,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)
@@ -460,7 +499,10 @@ void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_name, U32 sky
// get related text box
LLTextBox* text = getChild<LLTextBox>(alt_name);
- if (text)
+ LLLineEditor *field = getChild<LLLineEditor>("edt_invname_" + alt_name);
+ LLSettingsDropTarget *dt = getChild<LLSettingsDropTarget>("sdt_" + alt_name);
+
+ if (text && (sky_index > 1))
{
// move related text box
LLRect rect = text->getRect();
@@ -468,7 +510,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 +518,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 +552,22 @@ void LLPanelEnvironmentInfo::readjustAltLabels()
ground_text_rect.mTop = ground_text_rect.mBottom + height;
text->setRect(ground_text_rect);
+// LLMultiSliderCtrl *sld = getChild<LLMultiSliderCtrl>(SLD_ALTITUDES);
+// for (U32 idx = 0; idx < ALTITUDE_SLIDER_COUNT; ++idx)
+// {
+// LLRect rect_sld = sld->getSliderThumbRect(alt_sliders[idx]);
+// LLTextBox* text_cmp = getChild<LLTextBox>(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<LLTextBox>(alt_labels[i]);
@@ -531,16 +603,7 @@ void LLPanelEnvironmentInfo::readjustAltLabels()
}
}
}
-}
-
-void LLPanelEnvironmentInfo::onSwitchDefaultSelection()
-{
- bool can_edit = canEdit();
- setDirtyFlag(DIRTY_FLAG_DAYCYCLE);
-
- S32 rdo_selection = getChild<LLRadioGroup>(RDG_ENVIRONMENT_SELECT)->getSelectedIndex();
- getChild<LLUICtrl>(SLD_DAYLENGTH)->setEnabled(can_edit && (rdo_selection != 0));
- getChild<LLUICtrl>(SLD_DAYOFFSET)->setEnabled(can_edit && (rdo_selection != 0));
+#endif
}
void LLPanelEnvironmentInfo::onSldDayLengthChanged(F32 value)
@@ -566,6 +629,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<LLPanel> 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 +672,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,15 +681,33 @@ void LLPanelEnvironmentInfo::onAltSliderCallback(LLUICtrl *cntrl, const LLSD &da
setDirtyFlag(DIRTY_FLAG_ALTITUDES);
}
-void LLPanelEnvironmentInfo::onBtnApply()
+void LLPanelEnvironmentInfo::onAltSliderMouseUp()
{
- doApply();
+ if (isRegion() && (getDirtyFlag() & DIRTY_FLAG_ALTITUDES))
+ {
+ clearDirtyFlag(DIRTY_FLAG_ALTITUDES);
+
+ LLHandle<LLPanel> 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::onBtnReset()
+void LLPanelEnvironmentInfo::onBtnDefault()
{
- mCurrentEnvironment.reset();
- refreshFromSource();
+ LLHandle<LLPanel> 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()
@@ -624,7 +722,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();
}
@@ -647,62 +751,6 @@ void LLPanelEnvironmentInfo::onBtnSelect()
}
-void LLPanelEnvironmentInfo::doApply()
-{
- S32 parcel_id = getParcelId();
-
- if (getIsDirtyFlag(DIRTY_FLAG_MASK))
- {
- LLHandle<LLPanel> that_h = getHandle();
- LLEnvironment::altitudes_vect_t alts;
-
- S32 rdo_selection = getChild<LLRadioGroup>(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);
@@ -751,16 +799,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<LLPanel> 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 +828,11 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday)
if (newhash != oldhash)
{
- mCurrentEnvironment->mDayCycle = newday;
- setDirtyFlag(DIRTY_FLAG_DAYCYCLE);
- refresh();
+ LLHandle<LLPanel> 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); });
}
}
@@ -873,6 +926,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?