summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatereditextdaycycle.cpp
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2018-05-22 13:08:35 -0700
committerRider Linden <rider@lindenlab.com>2018-05-22 13:08:35 -0700
commit656967b326c59a3966261cd75e256e3a7a27cc0a (patch)
tree1c2c4c8f2adae7f17930843913a286fc1fd784b4 /indra/newview/llfloatereditextdaycycle.cpp
parent044b80e4e1a7b55f46e6f3b52c9cae6d9c6df3eb (diff)
parentb6ba9dd565b59e516571445e56f9dafe3bdf4061 (diff)
Merge PR
Diffstat (limited to 'indra/newview/llfloatereditextdaycycle.cpp')
-rw-r--r--indra/newview/llfloatereditextdaycycle.cpp255
1 files changed, 148 insertions, 107 deletions
diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp
index 1c9b42d03f..d87ea83fe7 100644
--- a/indra/newview/llfloatereditextdaycycle.cpp
+++ b/indra/newview/llfloatereditextdaycycle.cpp
@@ -44,13 +44,11 @@
#include "llinventorymodel.h"
// newview
#include "llagent.h"
-//#include "llflyoutcombobtnctrl.h" //Todo: get rid of this and LLSaveOutfitComboBtn, make a proper UI element/button/pannel instead
+#include "llflyoutcombobtn.h" //Todo: make a proper UI element/button/panel instead
#include "llregioninfomodel.h"
#include "llviewerregion.h"
#include "llpaneleditwater.h"
#include "llpaneleditsky.h"
-//#include "llsettingsvo.h"
-//#include "llinventorymodel.h"
#include "llenvironment.h"
#include "lltrans.h"
@@ -64,13 +62,14 @@ static const std::string track_tabs[] = {
};
// For flyout
-/*const std::string ACTION_SAVE("save_settings");
+const std::string XML_FLYOUTMENU_FILE("menu_save_settings.xml");
+// From menu_save_settings.xml, consider moving into flyout since it should be supported by flyout either way
+const std::string ACTION_SAVE("save_settings");
const std::string ACTION_SAVEAS("save_as_new_settings");
const std::string ACTION_APPLY_LOCAL("apply_local");
const std::string ACTION_APPLY_PARCEL("apply_parcel");
const std::string ACTION_APPLY_REGION("apply_region");
-const std::string XML_FLYOUTMENU_FILE("menu_save_settings.xml");*/
//=========================================================================
// **RIDER**
@@ -83,14 +82,12 @@ const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length");
LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key):
LLFloater(key),
- mSaveButton(NULL),
+ mFlyoutControl(NULL),
mCancelButton(NULL),
- mUploadButton(NULL),
mDayLength(0),
mCurrentTrack(4),
mTimeSlider(NULL),
mFramesSlider(NULL),
- //mFlyoutControl(NULL),
mCurrentTimeLabel(NULL),
// **RIDER**
mInventoryId(),
@@ -109,28 +106,17 @@ LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key):
LLFloaterEditExtDayCycle::~LLFloaterEditExtDayCycle()
{
- // Todo: consider remaking mFlyoutControl into class that initializes intself with floater,
- // completes at postbuild, e t c...
- // (make it into actual button?, In such case XML_FLYOUTMENU_FILE will be specified in xml)
- //delete mFlyoutControl;
+ // Todo: consider remaking mFlyoutControl into full view class that initializes intself with floater,
+ // complete with postbuild, e t c...
+ delete mFlyoutControl;
}
-// void LLFloaterEditExtDayCycle::openFloater(LLSettingsDay::ptr_t settings, S64Seconds daylength, S64Seconds dayoffset)
-// {
-// mEditDay = settings->buildClone();
-// mDayLength = daylength;
-// mDayOffset = dayoffset;
-// LLFloater::openFloater();
-// }
-
// virtual
BOOL LLFloaterEditExtDayCycle::postBuild()
{
getChild<LLLineEditor>("day_cycle_name")->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onCommitName, this, _1, _2), NULL);
- mSaveButton = getChild<LLButton>("save_btn", true);
mCancelButton = getChild<LLButton>("cancel_btn", true);
- mUploadButton = getChild<LLButton>("upload_btn", true);
mAddFrameButton = getChild<LLButton>("add_frame", true);
mDeleteFrameButton = getChild<LLButton>("delete_frame", true);
mTimeSlider = getChild<LLMultiSliderCtrl>("WLTimeSlider");
@@ -139,12 +125,10 @@ BOOL LLFloaterEditExtDayCycle::postBuild()
mWaterTabLayoutContainer = getChild<LLView>("frame_settings_water", true);
mCurrentTimeLabel = getChild<LLTextBox>("current_time", true);
- //mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE);
- //mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); });
+ mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE);
+ mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); });
- mUploadButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnSave, this));
mCancelButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnCancel, this));
- mUploadButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnUpload, this));
mTimeSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onTimeSliderMoved, this));
mFramesSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onFrameSliderCallback, this));
mAddFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddTrack, this));
@@ -203,7 +187,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
S32Hours hrs;
S32Minutes minutes;
S64Seconds total;
- //LLDate date;
LLUIString formatted_label = getString("time_label");
for (int i = 0; i < max_elm; i++)
{
@@ -211,19 +194,12 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
hrs = total;
minutes = total - hrs;
- //date = LLDate(((mDayLength / (max_elm - 1)) * i) + mDayOffset);
- //formatted_label.setArg("[TIME]", date.toHTTPDateString(std::string("%H:%M")));
- //formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value()));
-
formatted_label.setArg("[HH]", llformat("%d", hrs.value()));
formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value())));
getChild<LLTextBox>("p" + llformat("%d", i), true)->setTextArg("[DSC]", formatted_label.getString());
}
hrs = mDayLength;
minutes = mDayLength - hrs;
- //formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value()));
- //date = LLDate(mDayOffset);
- //formatted_label.setArg("[TIME]", date.toHTTPDateString(std::string("%H:%M")));
formatted_label.setArg("[HH]", llformat("%d", hrs.value()));
formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value())));
mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString());
@@ -240,12 +216,12 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
void LLFloaterEditExtDayCycle::onClose(bool app_quitting)
{
- if (!app_quitting) // there's no point to change environment if we're quitting
- {
- /* TODO: don't restore this environment. We may have gotten here from land or region. */
- LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
- LLEnvironment::instance().updateEnvironment();
- }
+ // there's no point to change environment if we're quitting
+ // or if we already restored environment
+ if (!app_quitting && LLEnvironment::instance().getSelectedEnvironment() == LLEnvironment::ENV_EDIT)
+ {
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
+ }
}
void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility)
@@ -257,60 +233,64 @@ void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility)
}
else
{
- /* TODO: don't restore this environment. We may have gotten here from land or region. */
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
-/*void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data)
+void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data)
{
std::string ctrl_action = ctrl->getName();
if (ctrl_action == ACTION_SAVE)
{
- mSavedDay = mEditDay;
- //doApplyUpdateInventory();
+// if (mSavedDay.get() != mOriginalDay.get())
+// {
+// restoreSavedEnv();
+// }
+// else
+// {
+// S64Seconds day_length = mDayLength.value() > 0 ? mDayLength : LLSettingsDay::DEFAULT_DAYLENGTH;
+// S64Seconds day_offset = mDayLength.value() > 0 ? mDayOffset : LLSettingsDay::DEFAULT_DAYOFFSET;
+// LLEnvironment::instance().setEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment, mEditDay, day_length, day_offset);
+// LLEnvironment::instance().setSelectedEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment);
+// LLEnvironment::instance().updateEnvironment();
+// }
+// mOriginalDay = mEditDay; // to kill the pointer
+//
+// if (!mCommitSignal.empty())
+// mCommitSignal(mEditDay);
}
else if (ctrl_action == ACTION_SAVEAS)
{
- //doApplyCreateNewInventory();
- LLSettingsVOBase::createInventoryItem(mEditDay, NULL);
- }
- else if ((ctrl_action == ACTION_APPLY_LOCAL) ||
- (ctrl_action == ACTION_APPLY_PARCEL) ||
- (ctrl_action == ACTION_APPLY_REGION))
- {
- //doApplyEnvironment(ctrl_action);
- // Shouldn't be supported?
+ LLSettingsVOBase::createInventoryItem(mEditDay);
}
else
{
- LL_WARNS("ENVIRONMENT") << "Unknown settings action '" << ctrl_action << "'" << LL_ENDL;
- }
+ LLEnvironment::EnvSelection_t env(LLEnvironment::ENV_DEFAULT);
+ bool updateSimulator(ctrl_action != ACTION_APPLY_LOCAL);
- if (!mCommitSignal.empty())
- mCommitSignal(mEditDay);
- closeFloater();
- }*/
-
-void LLFloaterEditExtDayCycle::onBtnSave()
-{
- //no longer needed?
- if (!mCommitSignal.empty())
- mCommitSignal(mEditDay);
+ if (ctrl_action == ACTION_APPLY_LOCAL)
+ env = LLEnvironment::ENV_LOCAL;
+ else if (ctrl_action == ACTION_APPLY_PARCEL)
+ env = LLEnvironment::ENV_PARCEL;
+ else if (ctrl_action == ACTION_APPLY_REGION)
+ env = LLEnvironment::ENV_REGION;
+ else
+ {
+ LL_WARNS("ENVIRONMENT") << "Unknown apply '" << ctrl_action << "'" << LL_ENDL;
+ }
- closeFloater();
+ LLEnvironment::instance().setEnvironment(env, mEditDay);
+ if (updateSimulator)
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempting to apply " << env << LL_ENDL;
+ }
+ }
}
void LLFloaterEditExtDayCycle::onBtnCancel()
{
- closeFloater();
-}
-
-void LLFloaterEditExtDayCycle::onBtnUpload()
-{
- LLSettingsVOBase::createInventoryItem(mEditDay);
- //closeFloater();
+ closeFloater(); // will restore env
}
void LLFloaterEditExtDayCycle::onAddTrack()
@@ -414,14 +394,44 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback()
}
F32 new_frame = mFramesSlider->getCurSliderValue();
- // todo: add safety checks, user shouldn't be capable of moving one frame over another or move missing frame
+ // todo: add safety 2.5% checks
keymap_t::iterator iter = mSliderKeyMap.find(cur_sldr);
if (iter != mSliderKeyMap.end() && mEditDay->getSettingsAtKeyframe(new_frame, mCurrentTrack).get() == NULL)
{
- LL_DEBUGS() << "Moving frame from " << iter->second.first << " to " << new_frame << LL_ENDL;
- if (mEditDay->moveTrackKeyframe(mCurrentTrack, iter->second.first, new_frame))
+ if (gKeyboard->currentMask(TRUE) == MASK_SHIFT)
{
- iter->second.first = new_frame;
+ LL_DEBUGS() << "Copying frame from " << iter->second.mFrame << " to " << new_frame << LL_ENDL;
+ LLSettingsBase::ptr_t new_settings;
+
+ // mEditDay still remembers old position, add copy at new position
+ if (mCurrentTrack == LLSettingsDay::TRACK_WATER)
+ {
+ LLSettingsWaterPtr_t water_ptr = std::dynamic_pointer_cast<LLSettingsWater>(iter->second.pSettings)->buildClone();
+ mEditDay->setWaterAtKeyframe(water_ptr, new_frame);
+ new_settings = water_ptr;
+ }
+ else
+ {
+ LLSettingsSkyPtr_t sky_ptr = std::dynamic_pointer_cast<LLSettingsSky>(iter->second.pSettings)->buildClone();
+ mEditDay->setSkyAtKeyframe(sky_ptr, new_frame, mCurrentTrack);
+ new_settings = sky_ptr;
+ }
+
+ // mSliderKeyMap still remembers old position, for simplicity, just move it to be identical to slider
+ F32 old_frame = iter->second.mFrame;
+ iter->second.mFrame = new_frame;
+ // slider already moved old frame, create new one in old place
+ addSliderFrame(old_frame, new_settings, false /*because we are going to reselect new one*/);
+ // reselect new frame
+ mFramesSlider->setCurSlider(iter->first);
+ }
+ else
+ {
+ LL_DEBUGS() << "Moving frame from " << iter->second.mFrame << " to " << new_frame << LL_ENDL;
+ if (mEditDay->moveTrackKeyframe(mCurrentTrack, iter->second.mFrame, new_frame))
+ {
+ iter->second.mFrame = new_frame;
+ }
}
}
@@ -450,7 +460,7 @@ void LLFloaterEditExtDayCycle::onTimeSliderMoved()
F32 frame = mTimeSlider->getCurSliderValue();
while (iter != end_iter)
{
- if (iter->second.first == frame)
+ if (iter->second.mFrame == frame)
{
mFramesSlider->setCurSlider(iter->first);
break;
@@ -458,14 +468,14 @@ void LLFloaterEditExtDayCycle::onTimeSliderMoved()
iter++;
}
- // Todo: safety checks
+ // block or update tabs according to new selection
updateTabs();
- //Todo: update something related to time/play/blending?
+
+ // blending:
}
void LLFloaterEditExtDayCycle::selectTrack(U32 track_index)
{
- // todo: safety checks
mCurrentTrack = track_index;
LLButton* button = getChild<LLButton>(track_tabs[track_index], true);
if (button->getToggleState())
@@ -488,7 +498,7 @@ void LLFloaterEditExtDayCycle::selectTrack(U32 track_index)
void LLFloaterEditExtDayCycle::clearTabs()
{
- // todo: instead init with defaults?
+ // Note: If this doesn't look good, init panels with default settings. It might be better looking
if (mCurrentTrack == LLSettingsDay::TRACK_WATER)
{
const LLSettingsWaterPtr_t p_water = LLSettingsWaterPtr_t(NULL);
@@ -505,12 +515,12 @@ void LLFloaterEditExtDayCycle::clearTabs()
void LLFloaterEditExtDayCycle::updateTabs()
{
-// // TODO: either prevent user from editing existing settings or clone them to not affect saved frames
// std::string sldr = mFramesSlider->getCurSlider();
// if (sldr.empty())
// {
-// // keep old settings for duplicating if there are any
-// // TODO: disable tabs to prevent editing without nulling settings
+// // keep old settings for duplicating if there are any
+// setWaterTabsEnabled(FALSE);
+// setSkyTabsEnabled(FALSE);
// }
// else if (mCurrentTrack == LLSettingsDay::TRACK_WATER)
// {
@@ -562,6 +572,42 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky)
}
}
+void LLFloaterEditExtDayCycle::setWaterTabsEnabled(BOOL enable)
+{
+ LLView* tab_container = mWaterTabLayoutContainer->getChild<LLView>("water_tabs"); //can't extract panels directly, since it is in 'tuple'
+ LLPanelSettingsWaterMainTab* panel = dynamic_cast<LLPanelSettingsWaterMainTab*>(tab_container->getChildView("water_panel"));
+ if (panel)
+ {
+ panel->setEnabled(enable);
+ panel->setAllChildrenEnabled(enable);
+ }
+}
+
+void LLFloaterEditExtDayCycle::setSkyTabsEnabled(BOOL enable)
+{
+ LLView* tab_container = mSkyTabLayoutContainer->getChild<LLView>("sky_tabs"); //can't extract panels directly, since they are in 'tuple'
+
+ LLPanelSettingsSky* panel;
+ panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("atmosphere_panel"));
+ if (panel)
+ {
+ panel->setEnabled(enable);
+ panel->setAllChildrenEnabled(enable);
+ }
+ panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("clouds_panel"));
+ if (panel)
+ {
+ panel->setEnabled(enable);
+ panel->setAllChildrenEnabled(enable);
+ }
+ panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("moon_panel"));
+ if (panel)
+ {
+ panel->setEnabled(enable);
+ panel->setAllChildrenEnabled(enable);
+ }
+}
+
void LLFloaterEditExtDayCycle::updateButtons()
{
F32 frame = mTimeSlider->getCurSliderValue();
@@ -575,29 +621,24 @@ void LLFloaterEditExtDayCycle::updateSlider()
mFramesSlider->clear();
mSliderKeyMap.clear();
- std::string new_slider;
- F32 frame = 0;
LLSettingsDay::CycleTrack_t track = mEditDay->getCycleTrack(mCurrentTrack);
for (auto &track_frame : track)
{
- // multi slider distinguishes elements by key/name in string format
- // store names to map to be able to recall dependencies
- frame = track_frame.first;
- new_slider = mFramesSlider->addSlider(frame);
- mSliderKeyMap[new_slider] = framedata_t(frame, track_frame.second);
+ addSliderFrame(track_frame.first, track_frame.second, false);
}
- mLastFrameSlider = new_slider;
-
if (mSliderKeyMap.size() > 0)
{
- mTimeSlider->setCurSliderValue(frame);
+ // update positions
+ mLastFrameSlider = mFramesSlider->getCurSlider();
+ mTimeSlider->setCurSliderValue(mFramesSlider->getCurSliderValue());
updateTabs();
}
else
{
// disable panels
clearTabs();
+ mLastFrameSlider.clear();
}
}
@@ -609,11 +650,6 @@ void LLFloaterEditExtDayCycle::updateTimeAndLabel()
{
LLUIString formatted_label = getString("time_label");
- //F32Hours hrs = (mDayLength * time) + mDayOffset;
- //LLDate date((mDayLength * time) + mDayOffset);
- //formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value()));
- //formatted_label.setArg("[TIME]", date.toHTTPDateString(std::string("%H:%M")));
-
S64Seconds total = (mDayLength * time);
S32Hours hrs = total;
S32Minutes minutes = total - hrs;
@@ -630,16 +666,19 @@ void LLFloaterEditExtDayCycle::updateTimeAndLabel()
// Update blender here:
}
-void LLFloaterEditExtDayCycle::addSliderFrame(const F32 frame, LLSettingsBase::ptr_t setting)
+void LLFloaterEditExtDayCycle::addSliderFrame(const F32 frame, LLSettingsBase::ptr_t &setting, bool update_ui)
{
// multi slider distinguishes elements by key/name in string format
// store names to map to be able to recall dependencies
std::string new_slider = mFramesSlider->addSlider(frame);
- mSliderKeyMap[new_slider] = framedata_t(frame, setting);
- mLastFrameSlider = new_slider;
+ mSliderKeyMap[new_slider] = FrameData(frame, setting);
- mTimeSlider->setCurSliderValue(frame);
- updateTabs();
+ if (update_ui)
+ {
+ mLastFrameSlider = new_slider;
+ mTimeSlider->setCurSliderValue(frame);
+ updateTabs();
+ }
}
void LLFloaterEditExtDayCycle::removeCurrentSliderFrame()
@@ -653,9 +692,9 @@ void LLFloaterEditExtDayCycle::removeCurrentSliderFrame()
keymap_t::iterator iter = mSliderKeyMap.find(sldr);
if (iter != mSliderKeyMap.end())
{
- LL_DEBUGS() << "Removing frame from " << iter->second.first << LL_ENDL;
+ LL_DEBUGS() << "Removing frame from " << iter->second.mFrame << LL_ENDL;
mSliderKeyMap.erase(iter);
- mEditDay->removeTrackKeyframe(mCurrentTrack, iter->second.first);
+ mEditDay->removeTrackKeyframe(mCurrentTrack, iter->second.mFrame);
}
mLastFrameSlider = mFramesSlider->getCurSlider();
@@ -699,6 +738,7 @@ void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId)
void LLFloaterEditExtDayCycle::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status)
{
mEditDay = std::dynamic_pointer_cast<LLSettingsDay>(settings);
+ mOriginalDay = mEditDay->buildClone();
updateEditEnvironment();
syncronizeTabs();
refresh();
@@ -713,6 +753,7 @@ void LLFloaterEditExtDayCycle::loadLiveEnvironment(LLEnvironment::EnvSelection_t
if (day)
{
+ mOriginalDay = day;
mEditDay = day->buildClone();
break;
}