summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatereditextdaycycle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatereditextdaycycle.cpp')
-rw-r--r--indra/newview/llfloatereditextdaycycle.cpp90
1 files changed, 44 insertions, 46 deletions
diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp
index 68c134a9ba..626f06ce7e 100644
--- a/indra/newview/llfloatereditextdaycycle.cpp
+++ b/indra/newview/llfloatereditextdaycycle.cpp
@@ -132,7 +132,6 @@ namespace {
//=========================================================================
const std::string LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT("edit_context");
const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length");
-const std::string LLFloaterEditExtDayCycle::KEY_CANMOD("canmod");
const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_INVENTORY("inventory");
const std::string LLFloaterEditExtDayCycle::VALUE_CONTEXT_PARCEL("parcel");
@@ -184,7 +183,6 @@ LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key) :
mLoadTrack(nullptr),
mClearTrack(nullptr)
{
-
mCommitCallbackRegistrar.add(EVNT_DAYTRACK, { [this](LLUICtrl *ctrl, const LLSD &data) { onTrackSelectionCallback(data); }});
mCommitCallbackRegistrar.add(EVNT_PLAY, { [this](LLUICtrl *ctrl, const LLSD &data) { onPlayActionCallback(data); }});
@@ -205,8 +203,8 @@ LLFloaterEditExtDayCycle::~LLFloaterEditExtDayCycle()
// virtual
bool LLFloaterEditExtDayCycle::postBuild()
{
- getChild<LLLineEditor>(TXT_DAY_NAME)->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onCommitName, this, _1, _2), NULL);
-
+ mNameEditor = getChild<LLLineEditor>(TXT_DAY_NAME, true);
+ mCancelButton = getChild<LLButton>(BTN_CANCEL, true);
mAddFrameButton = getChild<LLButton>(BTN_ADDFRAME, true);
mDeleteFrameButton = getChild<LLButton>(BTN_DELFRAME, true);
mTimeSlider = getChild<LLMultiSliderCtrl>(SLDR_TIME);
@@ -221,24 +219,24 @@ bool LLFloaterEditExtDayCycle::postBuild()
mClearTrack = getChild<LLButton>(BTN_CLEARTRACK, true);
mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BTN_SAVE, BTN_FLYOUT, XML_FLYOUTMENU_FILE, false);
- mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); });
+ mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD&) { onButtonApply(ctrl); });
- getChild<LLButton>(BTN_CANCEL, true)->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onClickCloseBtn(); });
- mTimeSlider->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onTimeSliderCallback(); });
- mAddFrameButton->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onAddFrame(); });
- mDeleteFrameButton->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onRemoveFrame(); });
- mImportButton->setCommitCallback([this](LLUICtrl *, const LLSD &){ onButtonImport(); });
- mLoadFrame->setCommitCallback([this](LLUICtrl *, const LLSD &){ onButtonLoadFrame(); });
+ mNameEditor->setKeystrokeCallback([this](LLLineEditor*, void*) { onNameKeystroke(); }, NULL);
+ mCancelButton->setCommitCallback([this](LLUICtrl*, const LLSD&) { onClickCloseBtn(); });
+ mTimeSlider->setCommitCallback([this](LLUICtrl*, const LLSD&) { onTimeSliderCallback(); });
+ mAddFrameButton->setCommitCallback([this](LLUICtrl*, const LLSD&) { onAddFrame(); });
+ mDeleteFrameButton->setCommitCallback([this](LLUICtrl*, const LLSD&) { onRemoveFrame(); });
+ mImportButton->setCommitCallback([this](LLUICtrl*, const LLSD&) { onButtonImport(); });
+ mLoadFrame->setCommitCallback([this](LLUICtrl*, const LLSD&) { onButtonLoadFrame(); });
- mCloneTrack->setCommitCallback([this](LLUICtrl *, const LLSD&){ onCloneTrack(); });
- mLoadTrack->setCommitCallback([this](LLUICtrl *, const LLSD&){ onLoadTrack();});
- mClearTrack->setCommitCallback([this](LLUICtrl *, const LLSD&){ onClearTrack(); });
+ mCloneTrack->setCommitCallback([this](LLUICtrl*, const LLSD&) { onCloneTrack(); });
+ mLoadTrack->setCommitCallback([this](LLUICtrl*, const LLSD&) { onLoadTrack();});
+ mClearTrack->setCommitCallback([this](LLUICtrl*, const LLSD&) { onClearTrack(); });
-
- mFramesSlider->setCommitCallback([this](LLUICtrl *, const LLSD &data) { onFrameSliderCallback(data); });
- mFramesSlider->setDoubleClickCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderDoubleClick(x, y, mask); });
- mFramesSlider->setMouseDownCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderMouseDown(x, y, mask); });
- mFramesSlider->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask){ onFrameSliderMouseUp(x, y, mask); });
+ mFramesSlider->setCommitCallback([this](LLUICtrl*, const LLSD &data) { onFrameSliderCallback(data); });
+ mFramesSlider->setDoubleClickCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { onFrameSliderDoubleClick(x, y, mask); });
+ mFramesSlider->setMouseDownCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { onFrameSliderMouseDown(x, y, mask); });
+ mFramesSlider->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { onFrameSliderMouseUp(x, y, mask); });
mTimeSlider->addSlider(0);
@@ -287,11 +285,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
mEditContext = CONTEXT_REGION;
}
- if (key.has(KEY_CANMOD))
- {
- mCanMod = key[KEY_CANMOD].asBoolean();
- }
-
if (mEditContext == CONTEXT_UNKNOWN)
{
LL_WARNS("ENVDAYEDIT") << "Unknown editing context!" << LL_ENDL;
@@ -299,6 +292,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
if (key.has(KEY_INVENTORY_ID))
{
+ // mCanMod is initialized inside this call
loadInventoryItem(key[KEY_INVENTORY_ID].asUUID());
}
else
@@ -313,7 +307,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
mDayLength.value(0);
if (key.has(KEY_DAY_LENGTH))
{
- mDayLength.value(key[KEY_DAY_LENGTH].asReal());
+ mDayLength.value(key[KEY_DAY_LENGTH].asInteger());
}
// Time&Percentage labels
@@ -352,7 +346,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
// Adjust Time&Percentage labels' location according to length
LLRect label_rect = getChild<LLTextBox>("p0", true)->getRect();
- F32 slider_width = mFramesSlider->getRect().getWidth();
+ F32 slider_width = (F32)mFramesSlider->getRect().getWidth();
for (int i = 1; i < max_elm; i++)
{
LLTextBox *pcnt_label = getChild<LLTextBox>("p" + llformat("%d", i), true);
@@ -431,12 +425,10 @@ void LLFloaterEditExtDayCycle::refresh()
{
if (mEditDay)
{
- LLLineEditor* name_field = getChild<LLLineEditor>(TXT_DAY_NAME);
- name_field->setText(mEditDay->getName());
- name_field->setEnabled(mCanMod);
+ mNameEditor->setText(mEditDay->getName());
+ mNameEditor->setEnabled(mCanMod && mCanSave && mInventoryId.notNull());
}
-
bool is_inventory_avail = canUseInventory();
bool show_commit = ((mEditContext == CONTEXT_PARCEL) || (mEditContext == CONTEXT_REGION));
@@ -461,7 +453,7 @@ void LLFloaterEditExtDayCycle::refresh()
mFlyoutControl->setMenuItemVisible(ACTION_APPLY_REGION, show_apply);
mFlyoutControl->setMenuItemEnabled(ACTION_COMMIT, show_commit && !mCommitSignal.empty());
- mFlyoutControl->setMenuItemEnabled(ACTION_SAVE, is_inventory_avail && mCanMod && !mInventoryId.isNull() && mCanSave);
+ mFlyoutControl->setMenuItemEnabled(ACTION_SAVE, is_inventory_avail && mCanMod && mCanSave && mInventoryId.notNull());
mFlyoutControl->setMenuItemEnabled(ACTION_SAVEAS, is_inventory_avail && mCanCopy && mCanSave);
mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_LOCAL, true);
mFlyoutControl->setMenuItemEnabled(ACTION_APPLY_PARCEL, canApplyParcel() && show_apply);
@@ -522,14 +514,20 @@ void LLFloaterEditExtDayCycle::setEditDefaultDayCycle()
std::string LLFloaterEditExtDayCycle::getEditName() const
{
if (mEditDay)
+ {
return mEditDay->getName();
+ }
+
return "new";
}
void LLFloaterEditExtDayCycle::setEditName(const std::string &name)
{
if (mEditDay)
+ {
mEditDay->setName(name);
+ }
+
getChild<LLLineEditor>(TXT_DAY_NAME)->setText(name);
}
@@ -551,13 +549,13 @@ bool LLFloaterEditExtDayCycle::handleKeyUp(KEY key, MASK mask, bool called_from_
keymap_t::iterator it = mSliderKeyMap.find(curslider);
if (it != mSliderKeyMap.end())
{
- if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos))
+ if (mEditDay->moveTrackKeyframe(mCurrentTrack, it->second.mFrame, sliderpos))
{
- (*it).second.mFrame = sliderpos;
+ it->second.mFrame = sliderpos;
}
else
{
- mFramesSlider->setCurSliderValue((*it).second.mFrame);
+ mFramesSlider->setCurSliderValue(it->second.mFrame);
}
}
else
@@ -569,7 +567,7 @@ bool LLFloaterEditExtDayCycle::handleKeyUp(KEY key, MASK mask, bool called_from_
return LLFloater::handleKeyUp(key, mask, called_from_parent);
}
-void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data)
+void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl)
{
std::string ctrl_action = ctrl->getName();
@@ -705,7 +703,7 @@ void LLFloaterEditExtDayCycle::onAddFrame()
LL_WARNS("ENVDAYEDIT") << "Attempt to add new frame while waiting for day(asset) to load." << LL_ENDL;
return;
}
- if ((mEditDay->getSettingsNearKeyframe(frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second)
+ if ((mEditDay->getSettingsNearKeyframe((LLSettingsBase::TrackPosition)frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second)
{
LL_WARNS("ENVDAYEDIT") << "Attempt to add new frame too close to existing frame." << LL_ENDL;
return;
@@ -722,17 +720,17 @@ void LLFloaterEditExtDayCycle::onAddFrame()
// scratch water should always have the current water settings.
LLSettingsWater::ptr_t water(mScratchWater->buildClone());
setting = water;
- mEditDay->setWaterAtKeyframe( std::static_pointer_cast<LLSettingsWater>(setting), frame);
+ mEditDay->setWaterAtKeyframe( std::static_pointer_cast<LLSettingsWater>(setting), (LLSettingsBase::TrackPosition)frame);
}
else
{
// scratch sky should always have the current sky settings.
LLSettingsSky::ptr_t sky(mScratchSky->buildClone());
setting = sky;
- mEditDay->setSkyAtKeyframe(sky, frame, mCurrentTrack);
+ mEditDay->setSkyAtKeyframe(sky, (LLSettingsBase::TrackPosition)frame, mCurrentTrack);
}
setDirtyFlag();
- addSliderFrame(frame, setting);
+ addSliderFrame((F32)frame, setting);
updateTabs();
}
@@ -832,7 +830,7 @@ void LLFloaterEditExtDayCycle::onClearTrack()
refresh();
}
-void LLFloaterEditExtDayCycle::onCommitName(class LLLineEditor* caller, void* user_data)
+void LLFloaterEditExtDayCycle::onNameKeystroke()
{
if (!mEditDay)
{
@@ -840,7 +838,7 @@ void LLFloaterEditExtDayCycle::onCommitName(class LLLineEditor* caller, void* us
return;
}
- mEditDay->setName(caller->getText());
+ mEditDay->setName(mNameEditor->getText());
}
void LLFloaterEditExtDayCycle::onTrackSelectionCallback(const LLSD& user_data)
@@ -1316,7 +1314,7 @@ void LLFloaterEditExtDayCycle::removeCurrentSliderFrame()
{
LL_DEBUGS("ENVDAYEDIT") << "Removing frame from " << iter->second.mFrame << LL_ENDL;
LLSettingsBase::Seconds seconds(iter->second.mFrame);
- mEditDay->removeTrackKeyframe(mCurrentTrack, seconds);
+ mEditDay->removeTrackKeyframe(mCurrentTrack, (LLSettingsBase::TrackPosition)seconds);
mSliderKeyMap.erase(iter);
}
@@ -1474,17 +1472,17 @@ void LLFloaterEditExtDayCycle::reblendSettings()
{
if ((mSkyBlender->getTrack() != mCurrentTrack) && (mCurrentTrack != LLSettingsDay::TRACK_WATER))
{
- mSkyBlender->switchTrack(mCurrentTrack, position);
+ mSkyBlender->switchTrack(mCurrentTrack, (LLSettingsBase::TrackPosition)position);
}
else
{
- mSkyBlender->setPosition(position);
+ mSkyBlender->setPosition((LLSettingsBase::TrackPosition)position);
}
}
if (mWaterBlender)
{
- mWaterBlender->setPosition(position);
+ mWaterBlender->setPosition((LLSettingsBase::TrackPosition)position);
}
}
@@ -1517,7 +1515,7 @@ bool LLFloaterEditExtDayCycle::isAddingFrameAllowed()
if (!mFramesSlider->getCurSlider().empty() || !mEditDay) return false;
LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue());
- if ((mEditDay->getSettingsNearKeyframe(frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second)
+ if ((mEditDay->getSettingsNearKeyframe((LLSettingsBase::TrackPosition)frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second)
{
return false;
}