diff options
-rw-r--r-- | indra/llinventory/llsettingsbase.cpp | 2 | ||||
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 7 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 46 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.h | 10 | ||||
-rw-r--r-- | indra/newview/llenvironment.cpp | 77 | ||||
-rw-r--r-- | indra/newview/llenvironment.h | 27 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.cpp | 392 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.h | 50 | ||||
-rw-r--r-- | indra/newview/llfloaterfixedenvironment.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llfloaterfixedenvironment.h | 2 | ||||
-rw-r--r-- | indra/newview/llpaneleditsky.h | 2 | ||||
-rw-r--r-- | indra/newview/llpaneleditwater.h | 2 | ||||
-rw-r--r-- | indra/newview/llpanelenvironment.cpp | 10 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_fixedenvironment.xml | 4 |
15 files changed, 464 insertions, 173 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index a6a7a9acf9..f870ec8904 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -535,7 +535,7 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range) //========================================================================= void LLSettingsBlender::update(F64 blendf) { - + setPosition(blendf); } F64 LLSettingsBlender::setPosition(F64 blendf) diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 6ab3032a3d..d00e340b4b 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -265,7 +265,7 @@ public: typedef boost::signals2::connection connection_t; LLSettingsBlender(const LLSettingsBase::ptr_t &target, - const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 span = 1.0) : + const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting) : mOnFinished(), mTarget(target), mInitial(initsetting), @@ -277,8 +277,9 @@ public: virtual ~LLSettingsBlender() {} - virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 span = 1.0) + virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 /*span*/ = 1.0) { + // note: the 'span' reset parameter is unused by the base class. mInitial = initsetting; mFinal = endsetting; mTarget->replaceSettings(mInitial->getSettings()); @@ -322,7 +323,7 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender public: LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target, const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds) : - LLSettingsBlender(target, initsetting, endsetting, seconds.value()), + LLSettingsBlender(target, initsetting, endsetting), mBlendSpan(seconds), mLastUpdate(0.0f), mTimeSpent(0.0f) diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 5a6280884d..aa3fd4e0e6 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -551,23 +551,15 @@ bool LLSettingsDay::removeTrackKeyframe(S32 trackno, F32 frame) void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe) { - mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water; - setDirtyFlag(true); + setSettingsAtKeyframe(water, keyframe, TRACK_WATER); } -const LLSettingsWaterPtr_t LLSettingsDay::getWaterAtKeyframe(F32 keyframe) +LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(F32 keyframe) const { - // todo: better way to identify keyframes? - CycleTrack_t::iterator iter = mDayTracks[TRACK_WATER].find(keyframe); - if (iter != mDayTracks[TRACK_WATER].end()) - { - return std::dynamic_pointer_cast<LLSettingsWater>(iter->second); - } - - return LLSettingsWaterPtr_t(NULL); + return std::dynamic_pointer_cast<LLSettingsWater>(getSettingsAtKeyframe(keyframe, TRACK_WATER)); } -void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track) +void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, F32 keyframe, S32 track) { if ((track < 1) || (track >= TRACK_MAX)) { @@ -575,44 +567,48 @@ void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe return; } - mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = sky; - setDirtyFlag(true); + setSettingsAtKeyframe(sky, keyframe, track); } -const LLSettingsSkyPtr_t LLSettingsDay::getSkyAtKeyframe(F32 keyframe, S32 track) +LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(F32 keyframe, S32 track) const { if ((track < 1) || (track >= TRACK_MAX)) { LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; - return LLSettingsSkyPtr_t(NULL); + return LLSettingsSky::ptr_t(); } - // todo: better way to identify keyframes? - CycleTrack_t::iterator iter = mDayTracks[track].find(keyframe); - if (iter != mDayTracks[track].end()) + return std::dynamic_pointer_cast<LLSettingsSky>(getSettingsAtKeyframe(keyframe, track)); +} + +void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track) +{ + if ((track < 0) || (track >= TRACK_MAX)) { - return std::dynamic_pointer_cast<LLSettingsSky>(iter->second); + LL_WARNS("DAYCYCLE") << "Attempt to set track (#" << track << ") out of range!" << LL_ENDL; + return; } - return LLSettingsSkyPtr_t(NULL); + mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; + setDirtyFlag(true); } -const LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 track) +LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 track) const { if ((track < 0) || (track >= TRACK_MAX)) { LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL; - return LLSettingsBase::ptr_t(NULL); + return LLSettingsBase::ptr_t(); } // todo: better way to identify keyframes? - CycleTrack_t::iterator iter = mDayTracks[track].find(keyframe); + CycleTrack_t::const_iterator iter = mDayTracks[track].find(keyframe); if (iter != mDayTracks[track].end()) { return iter->second; } - return LLSettingsSkyPtr_t(NULL); + return LLSettingsBase::ptr_t(); } LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F32 keyframe) diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 15a5b29f9f..9a89031aed 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -33,6 +33,8 @@ class LLSettingsWater; class LLSettingsSky; +// These are alias for LLSettingsWater::ptr_t and LLSettingsSky::ptr_t respectively. +// Here for definitions only. typedef std::shared_ptr<LLSettingsWater> LLSettingsWaterPtr_t; typedef std::shared_ptr<LLSettingsSky> LLSettingsSkyPtr_t; @@ -84,16 +86,16 @@ public: static LLSD defaults(); //--------------------------------------------------------------------- - KeyframeList_t getTrackKeyframes(S32 track); bool moveTrackKeyframe(S32 track, F32 old_frame, F32 new_frame); bool removeTrackKeyframe(S32 track, F32 frame); void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe); - const LLSettingsWaterPtr_t getWaterAtKeyframe(F32 keyframe); + LLSettingsWaterPtr_t getWaterAtKeyframe(F32 keyframe) const; void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track); - const LLSettingsSkyPtr_t getSkyAtKeyframe(F32 keyframe, S32 track); - const LLSettingsBase::ptr_t getSettingsAtKeyframe(F32 keyframe, S32 track); + LLSettingsSkyPtr_t getSkyAtKeyframe(F32 keyframe, S32 track) const; + void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track); + LLSettingsBase::ptr_t getSettingsAtKeyframe(F32 keyframe, S32 track) const; //--------------------------------------------------------------------- void startDayCycle(); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 76192d1fe9..cfea83c788 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -400,6 +400,18 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe { DayInstance::ptr_t environment = getEnvironmentInstance(env); + if (env == ENV_DEFAULT) + { + LL_WARNS("ENVIRONMENT") << "Attempt to set default environment. Not allowed." << LL_ENDL; + return; + } + + if (!settings) + { + clearEnvironment(env); + return; + } + if (settings->getSettingType() == "daycycle") { S64Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH); @@ -1624,3 +1636,68 @@ void LLEnvironment::DayTransition::animate() LLEnvironment::instance().mCurrentEnvironment = mNextInstance; }); } + +//========================================================================= +LLTrackBlenderLoopingManual::LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno) : + LLSettingsBlender(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t()), + mDay(day), + mTrackNo(trackno), + mPosition(0.0) +{ + LLSettingsDay::TrackBound_t initial = getBoundingEntries(mPosition); + + if (initial.first != mEndMarker) + { // No frames in track + mInitial = (*initial.first).second; + mFinal = (*initial.second).second; + + LLSD initSettings = mInitial->getSettings(); + mTarget->replaceSettings(initSettings); + } +} + +F64 LLTrackBlenderLoopingManual::setPosition(F64 position) +{ + mPosition = llclamp(position, 0.0, 1.0); + + LLSettingsDay::TrackBound_t bounds = getBoundingEntries(mPosition); + + if (bounds.first == mEndMarker) + { // No frames in track. + return 0.0; + } + + mInitial = (*bounds.first).second; + mFinal = (*bounds.second).second; + + F64 spanLength = getSpanLength(bounds); + + F64 spanPos = ((mPosition < (*bounds.first).first) ? (mPosition + 1.0) : mPosition) - (*bounds.first).first; + + F64 blendf = fmod(spanPos, spanLength) / spanLength; + return LLSettingsBlender::setPosition(blendf); +} + +void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, F64 position) +{ + mTrackNo = trackno; + + F64 useposition = (position < 0.0) ? mPosition : position; + + setPosition(useposition); +} + +LLSettingsDay::TrackBound_t LLTrackBlenderLoopingManual::getBoundingEntries(F64 position) +{ + LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo); + + mEndMarker = wtrack.end(); + + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, position); + return bounds; +} + +F64 LLTrackBlenderLoopingManual::getSpanLength(const LLSettingsDay::TrackBound_t &bounds) const +{ + return get_wrapping_distance((*bounds.first).first, (*bounds.second).first); +} diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index e21f46d5b0..9f9eb614a4 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -77,13 +77,14 @@ public: enum EnvSelection_t { - ENV_EDIT, + ENV_EDIT = 0, ENV_LOCAL, ENV_PARCEL, ENV_REGION, ENV_DEFAULT, ENV_END, - ENV_CURRENT = -1 + ENV_CURRENT = -1, + ENV_NONE = -2 }; typedef boost::signals2::connection connection_t; @@ -154,6 +155,7 @@ public: void setEnvironment(EnvSelection_t env, const LLSettingsBase::ptr_t &fixed); void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); } void setEnvironment(EnvSelection_t env, const LLSettingsWater::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(LLSettingsSky::ptr_t(), fixed)); } + void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixeds, const LLSettingsWater::ptr_t & fixedw) { setEnvironment(env, fixedEnvironment_t(fixeds, fixedw)); } void clearEnvironment(EnvSelection_t env); LLSettingsDay::ptr_t getEnvironmentDay(EnvSelection_t env); S64Seconds getEnvironmentDayLength(EnvSelection_t env); @@ -369,6 +371,27 @@ private: }; +class LLTrackBlenderLoopingManual : public LLSettingsBlender +{ +public: + LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno); + + F64 setPosition(F64 position) override; + void switchTrack(S32 trackno, F64 position = -1.0); + S32 getTrack() const { return mTrackNo; } + + typedef std::shared_ptr<LLTrackBlenderLoopingManual> ptr_t; +protected: + LLSettingsDay::TrackBound_t getBoundingEntries(F64 position); + F64 getSpanLength(const LLSettingsDay::TrackBound_t &bounds) const; + +private: + LLSettingsDay::ptr_t mDay; + S32 mTrackNo; + F64 mPosition; + + LLSettingsDay::CycleTrack_t::iterator mEndMarker; +}; #endif // LL_ENVIRONMENT_H diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 747a20bbbd..d87ea83fe7 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -38,9 +38,10 @@ #include "llnotificationsutil.h" #include "llspinctrl.h" #include "lltimectrl.h" +#include "lltabcontainer.h" #include "llsettingsvo.h" - +#include "llinventorymodel.h" // newview #include "llagent.h" #include "llflyoutcombobtn.h" //Todo: make a proper UI element/button/panel instead @@ -70,18 +71,37 @@ const std::string ACTION_APPLY_PARCEL("apply_parcel"); const std::string ACTION_APPLY_REGION("apply_region"); +//========================================================================= +// **RIDER** + +const std::string LLFloaterEditExtDayCycle::KEY_INVENTORY_ID("inventory_id"); +const std::string LLFloaterEditExtDayCycle::KEY_LIVE_ENVIRONMENT("live_environment"); +const std::string LLFloaterEditExtDayCycle::KEY_DAY_LENGTH("day_length"); + +// **RIDER** + LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key): LLFloater(key), mFlyoutControl(NULL), mCancelButton(NULL), mDayLength(0), - mDayOffset(0), mCurrentTrack(4), mTimeSlider(NULL), mFramesSlider(NULL), - mCurrentTimeLabel(NULL) + mCurrentTimeLabel(NULL), + // **RIDER** + mInventoryId(), + mInventoryItem(nullptr), + mSkyBlender(), + mWaterBlender(), + mScratchSky(), + mScratchWater() + // **RIDER** { mCommitCallbackRegistrar.add("DayCycle.Track", boost::bind(&LLFloaterEditExtDayCycle::onTrackSelectionCallback, this, _2)); + + mScratchSky = LLSettingsVOSky::buildDefaultSky(); + mScratchWater = LLSettingsVOWater::buildDefaultWater(); } LLFloaterEditExtDayCycle::~LLFloaterEditExtDayCycle() @@ -91,15 +111,6 @@ LLFloaterEditExtDayCycle::~LLFloaterEditExtDayCycle() delete mFlyoutControl; } -void LLFloaterEditExtDayCycle::openFloater(LLSettingsDay::ptr_t settings, S64Seconds daylength, S64Seconds dayoffset) -{ - mOriginalDay = settings; - mEditDay = settings->buildClone(); - mDayLength = daylength; - mDayOffset = dayoffset; - LLFloater::openFloater(); -} - // virtual BOOL LLFloaterEditExtDayCycle::postBuild() { @@ -133,26 +144,35 @@ BOOL LLFloaterEditExtDayCycle::postBuild() void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) { - if (mEditDay.get() == NULL) + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); + LLEnvironment::instance().updateEnvironment(); + + // **RIDER** + + mEditingEnv = LLEnvironment::ENV_NONE; + mEditDay.reset(); + if (key.has(KEY_INVENTORY_ID)) + { + loadInventoryItem(key[KEY_INVENTORY_ID].asUUID()); + } + else if (key.has(KEY_LIVE_ENVIRONMENT)) + { + LLEnvironment::EnvSelection_t env = static_cast<LLEnvironment::EnvSelection_t>(key[KEY_LIVE_ENVIRONMENT].asInteger()); + + loadLiveEnvironment(env); + } + else { - LL_WARNS() << "Uninitialized day settings, closing floater" << LL_ENDL; - closeFloater(); + loadLiveEnvironment(LLEnvironment::ENV_DEFAULT); } - // Save previous data - LLEnvironment::EnvSelection_t env = LLEnvironment::instance().getSelectedEnvironment(); - mSavedEnvironment = env; - if (mSavedEnvironment == LLEnvironment::ENV_EDIT) + mDayLength.value(0); + if (key.has(KEY_DAY_LENGTH)) { - // Flawed in case of multiple edits (if multiple edits are possible), also check onClose() - LL_WARNS() << "Opening up Day editor when already editing day!" << LL_ENDL; + mDayLength.value(key[KEY_DAY_LENGTH].asReal()); } - mSavedDay = LLEnvironment::instance().getEnvironmentDay(env); - mSavedDayLength = LLEnvironment::instance().getEnvironmentDayLength(env); - mSavedDayOffset = LLEnvironment::instance().getEnvironmentDayOffset(env); - // set environment for editing (display the one we are editing) - setEditingEnv(); + // **RIDER** LLLineEditor* name_field = getChild<LLLineEditor>("day_cycle_name"); name_field->setText(mEditDay->getName()); @@ -170,7 +190,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) LLUIString formatted_label = getString("time_label"); for (int i = 0; i < max_elm; i++) { - total = ((mDayLength / (max_elm - 1)) * i) + mDayOffset; + total = ((mDayLength / (max_elm - 1)) * i); hrs = total; minutes = total - hrs; @@ -178,8 +198,8 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value()))); getChild<LLTextBox>("p" + llformat("%d", i), true)->setTextArg("[DSC]", formatted_label.getString()); } - hrs = mDayOffset; - minutes = mDayOffset - hrs; + hrs = mDayLength; + minutes = mDayLength - hrs; formatted_label.setArg("[HH]", llformat("%d", hrs.value())); formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value()))); mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString()); @@ -200,7 +220,7 @@ void LLFloaterEditExtDayCycle::onClose(bool app_quitting) // or if we already restored environment if (!app_quitting && LLEnvironment::instance().getSelectedEnvironment() == LLEnvironment::ENV_EDIT) { - restoreSavedEnv(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } } @@ -208,11 +228,12 @@ void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility) { if (new_visibility) { - setEditingEnv(); + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mScratchSky, mScratchWater); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); } else { - restoreSavedEnv(); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); } } @@ -222,27 +243,26 @@ void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data) if (ctrl_action == ACTION_SAVE) { - 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); +// 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) { LLSettingsVOBase::createInventoryItem(mEditDay); - restoreSavedEnv(); } else { @@ -266,7 +286,6 @@ void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data) LL_WARNS("ENVIRONMENT") << "Attempting to apply " << env << LL_ENDL; } } - closeFloater(); } void LLFloaterEditExtDayCycle::onBtnCancel() @@ -287,41 +306,49 @@ void LLFloaterEditExtDayCycle::onAddTrack() if (mCurrentTrack == LLSettingsDay::TRACK_WATER) { - if (mSliderKeyMap.empty()) - { - // No existing points, use defaults - setting = LLSettingsVOWater::buildDefaultWater(); - } - else - { - // clone existing element, since we are intentionally dropping slider on time selection, copy from tab panels - 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) - { - setting = panel->getWater()->buildClone(); - } - } + // **RIDER** + // scratch water should always have the current water settings. + setting = mScratchWater->buildClone(); +// if (mSliderKeyMap.empty()) +// { +// // No existing points, use defaults +// setting = LLSettingsVOWater::buildDefaultWater(); +// } +// else +// { +// // clone existing element, since we are intentionally dropping slider on time selection, copy from tab panels +// 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) +// { +// setting = panel->getWater()->buildClone(); +// } +// } + // **RIDER** mEditDay->setWaterAtKeyframe(std::dynamic_pointer_cast<LLSettingsWater>(setting), frame); } else { - if (mSliderKeyMap.empty()) - { - // No existing points, use defaults - setting = LLSettingsVOSky::buildDefaultSky(); - } - else - { - // clone existing element, since we are intentionally dropping slider on time selection, copy from tab panels - LLView* tab_container = mSkyTabLayoutContainer->getChild<LLView>("sky_tabs"); //can't extract panels directly, since they are in 'tuple' - - LLPanelSettingsSky* panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("atmosphere_panel")); - if (panel) - { - setting = panel->getSky()->buildClone(); - } - } + // **RIDER** + // scratch sky should always have the current sky settings. + setting = mScratchSky->buildClone(); +// if (mSliderKeyMap.empty()) +// { +// // No existing points, use defaults +// setting = LLSettingsVOSky::buildDefaultSky(); +// } +// else +// { +// // clone existing element, since we are intentionally dropping slider on time selection, copy from tab panels +// LLView* tab_container = mSkyTabLayoutContainer->getChild<LLView>("sky_tabs"); //can't extract panels directly, since they are in 'tuple' +// +// LLPanelSettingsSky* panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("atmosphere_panel")); +// if (panel) +// { +// setting = panel->getSky()->buildClone(); +// } +// } + // **RIDER** mEditDay->setSkyAtKeyframe(std::dynamic_pointer_cast<LLSettingsSky>(setting), frame, mCurrentTrack); } @@ -488,23 +515,27 @@ void LLFloaterEditExtDayCycle::clearTabs() void LLFloaterEditExtDayCycle::updateTabs() { - std::string sldr = mFramesSlider->getCurSlider(); - if (sldr.empty()) - { - // keep old settings if there are any for duplicating later, just disable panels - setWaterTabsEnabled(FALSE); - setSkyTabsEnabled(FALSE); - } - else if (mCurrentTrack == LLSettingsDay::TRACK_WATER) - { - const LLSettingsWaterPtr_t p_water = sldr.empty() ? LLSettingsWaterPtr_t(NULL) : mEditDay->getWaterAtKeyframe(mFramesSlider->getCurSliderValue()); - updateWaterTabs(p_water); - } - else - { - const LLSettingsSkyPtr_t p_sky = sldr.empty() ? LLSettingsSkyPtr_t(NULL) : mEditDay->getSkyAtKeyframe(mFramesSlider->getCurSliderValue(), mCurrentTrack); - updateSkyTabs(p_sky); - } +// std::string sldr = mFramesSlider->getCurSlider(); +// if (sldr.empty()) +// { +// // keep old settings for duplicating if there are any +// setWaterTabsEnabled(FALSE); +// setSkyTabsEnabled(FALSE); +// } +// else if (mCurrentTrack == LLSettingsDay::TRACK_WATER) +// { +// const LLSettingsWaterPtr_t p_water = sldr.empty() ? LLSettingsWaterPtr_t(NULL) : mEditDay->getWaterAtKeyframe(mFramesSlider->getCurSliderValue()); +// updateWaterTabs(p_water); +// } +// else +// { +// const LLSettingsSkyPtr_t p_sky = sldr.empty() ? LLSettingsSkyPtr_t(NULL) : mEditDay->getSkyAtKeyframe(mFramesSlider->getCurSliderValue(), mCurrentTrack); +// updateSkyTabs(p_sky); +// } + + reblendSettings(); + syncronizeTabs(); + updateButtons(); updateTimeAndLabel(); } @@ -619,7 +650,7 @@ void LLFloaterEditExtDayCycle::updateTimeAndLabel() { LLUIString formatted_label = getString("time_label"); - S64Seconds total = (mDayLength * time) + mDayOffset; + S64Seconds total = (mDayLength * time); S32Hours hrs = total; S32Minutes minutes = total - hrs; @@ -671,26 +702,163 @@ void LLFloaterEditExtDayCycle::removeCurrentSliderFrame() updateTabs(); } -void LLFloaterEditExtDayCycle::setEditingEnv() +//------------------------------------------------------------------------- + +LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSignal(LLFloaterEditExtDayCycle::edit_commit_signal_t::slot_type cb) { - S64Seconds day_length = mDayLength.value() > 0 ? mDayLength : LLSettingsDay::DEFAULT_DAYLENGTH; - S64Seconds day_offset = mDayLength.value() > 0 ? mDayOffset : LLSettingsDay::DEFAULT_DAYOFFSET; - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditDay, day_length, day_offset); - LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); - LLEnvironment::instance().updateEnvironment(); + return mCommitSignal.connect(cb); } -void LLFloaterEditExtDayCycle::restoreSavedEnv() +// **RIDER** +void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId) { - //LLEnvironment::instance().setEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment, mSavedDay, mSavedDayLength, mSavedDayOffset); - LLEnvironment::instance().setSelectedEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment); - LLEnvironment::instance().updateEnvironment(); + if (inventoryId.isNull()) + { + mInventoryItem = nullptr; + mInventoryId.setNull(); + return; + } + + mInventoryId = inventoryId; + LL_INFOS("SETTINGS") << "Setting edit inventory item to " << mInventoryId << "." << LL_ENDL; + mInventoryItem = gInventory.getItem(mInventoryId); + + if (!mInventoryItem) + { + LL_WARNS("SETTINGS") << "Could not find inventory item with Id = " << mInventoryId << LL_ENDL; + mInventoryId.setNull(); + mInventoryItem = nullptr; + return; + } + + LLSettingsVOBase::getSettingsAsset(mInventoryItem->getAssetUUID(), + [this](LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status, LLExtStat) { onAssetLoaded(asset_id, settins, status); }); } -//------------------------------------------------------------------------- +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(); +} -LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSignal(LLFloaterEditExtDayCycle::edit_commit_signal_t::slot_type cb) +void LLFloaterEditExtDayCycle::loadLiveEnvironment(LLEnvironment::EnvSelection_t env) { - return mCommitSignal.connect(cb); + mEditingEnv = env; + for (S32 idx = static_cast<S32>(env); idx <= LLEnvironment::ENV_DEFAULT; ++idx) + { + LLSettingsDay::ptr_t day = LLEnvironment::instance().getEnvironmentDay(static_cast<LLEnvironment::EnvSelection_t>(idx)); + + if (day) + { + mOriginalDay = day; + mEditDay = day->buildClone(); + break; + } + } + + updateEditEnvironment(); + syncronizeTabs(); + refresh(); +} + +void LLFloaterEditExtDayCycle::updateEditEnvironment(void) +{ + S32 skytrack = (mCurrentTrack) ? mCurrentTrack : 1; + mSkyBlender = std::make_shared<LLTrackBlenderLoopingManual>(mScratchSky, mEditDay, skytrack); + mWaterBlender = std::make_shared<LLTrackBlenderLoopingManual>(mScratchWater, mEditDay, LLSettingsDay::TRACK_WATER); + + reblendSettings(); + + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mScratchSky, mScratchWater); } +void LLFloaterEditExtDayCycle::syncronizeTabs() +{ + // This should probably get moved into "updateTabs" + + F32 frame = mTimeSlider->getCurSliderValue(); + bool canedit(false); + + LLSettingsWater::ptr_t psettingWater; + LLTabContainer * tabs = mWaterTabLayoutContainer->getChild<LLTabContainer>("water_tabs"); + if (mCurrentTrack == LLSettingsDay::TRACK_WATER) + { + canedit = true; + psettingWater = std::static_pointer_cast<LLSettingsWater>(mEditDay->getSettingsAtKeyframe(frame, LLSettingsDay::TRACK_WATER)); + if (!psettingWater) + { + canedit = false; + psettingWater = mScratchWater; + } + } + else + { + psettingWater = mScratchWater; + } + + S32 count = tabs->getTabCount(); + for (S32 idx = 0; idx < count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(tabs->getPanelByIndex(idx)); + if (panel) + { + panel->setAllChildrenEnabled(canedit); + panel->setSettings(psettingWater); + panel->refresh(); + } + } + + LLSettingsSky::ptr_t psettingSky; + + canedit = false; + tabs = mSkyTabLayoutContainer->getChild<LLTabContainer>("sky_tabs"); + if (mCurrentTrack != LLSettingsDay::TRACK_WATER) + { + canedit = true; + psettingSky = std::static_pointer_cast<LLSettingsSky>(mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack)); + if (!psettingSky) + { + canedit = false; + psettingSky = mScratchSky; + } + } + else + { + psettingSky = mScratchSky; + } + + count = tabs->getTabCount(); + for (S32 idx = 0; idx < count; ++idx) + { + LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(tabs->getPanelByIndex(idx)); + if (panel) + { + panel->setAllChildrenEnabled(canedit); + panel->setSettings(psettingSky); + panel->refresh(); + } + } + + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, psettingSky, psettingWater); +} + +void LLFloaterEditExtDayCycle::reblendSettings() +{ + F64 position = mTimeSlider->getCurSliderValue(); + + if ((mSkyBlender->getTrack() != mCurrentTrack) && (mCurrentTrack != LLSettingsDay::TRACK_WATER)) + { + mSkyBlender->switchTrack(mCurrentTrack, position); + } + else + mSkyBlender->setPosition(position); + + mWaterBlender->setPosition(position); +} + +// **RIDER** + + diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index 0b48b51b5d..287d2fe2dc 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -31,6 +31,8 @@ #include "llsettingsdaycycle.h" #include <boost/signals2.hpp> +#include "llenvironment.h" + class LLCheckBoxCtrl; class LLComboBox; class LLFlyoutComboBtnCtrl; @@ -39,6 +41,8 @@ class LLMultiSliderCtrl; class LLTextBox; class LLTimeCtrl; +class LLInventoryItem; + typedef std::shared_ptr<LLSettingsBase> LLSettingsBasePtr_t; /** @@ -49,13 +53,19 @@ class LLFloaterEditExtDayCycle : public LLFloater LOG_CLASS(LLFloaterEditExtDayCycle); public: + // **RIDER** + static const std::string KEY_INVENTORY_ID; + static const std::string KEY_LIVE_ENVIRONMENT; + static const std::string KEY_DAY_LENGTH; + // **RIDER** + typedef boost::signals2::signal<void(LLSettingsDay::ptr_t)> edit_commit_signal_t; typedef boost::signals2::connection connection_t; LLFloaterEditExtDayCycle(const LLSD &key); ~LLFloaterEditExtDayCycle(); - void openFloater(LLSettingsDay::ptr_t settings, S64Seconds daylength = S64Seconds(0), S64Seconds dayoffset = S64Seconds(0)); + //void openFloater(LLSettingsDay::ptr_t settings, S64Seconds daylength = S64Seconds(0), S64Seconds dayoffset = S64Seconds(0)); BOOL postBuild(); void onOpen(const LLSD& key); @@ -92,31 +102,45 @@ private: void addSliderFrame(const F32 frame, LLSettingsBase::ptr_t &setting, bool update_ui = true); void removeCurrentSliderFrame(); - void setEditingEnv(); - void restoreSavedEnv(); + // **RIDER** + void loadInventoryItem(const LLUUID &inventoryId); + void onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); + void loadLiveEnvironment(LLEnvironment::EnvSelection_t env); + void updateEditEnvironment(); + void syncronizeTabs(); + void reblendSettings(); + // **RIDER** + // data for restoring previous displayed environment - LLSettingsDay::ptr_t mSavedDay; // the one currently on screen + S32 mSavedEnvironment; - S64Seconds mSavedDayLength; - S64Seconds mSavedDayOffset; LLSettingsDay::ptr_t mEditDay; // edited copy LLSettingsDay::ptr_t mOriginalDay; // the one we are editing S64Seconds mDayLength; - S64Seconds mDayOffset; U32 mCurrentTrack; std::string mLastFrameSlider; - LLButton* mCancelButton; + LLButton* mCancelButton; LLButton* mAddFrameButton; LLButton* mDeleteFrameButton; - LLMultiSliderCtrl* mTimeSlider; - LLMultiSliderCtrl* mFramesSlider; - LLView* mSkyTabLayoutContainer; - LLView* mWaterTabLayoutContainer; - LLTextBox* mCurrentTimeLabel; + LLMultiSliderCtrl* mTimeSlider; + LLMultiSliderCtrl* mFramesSlider; + LLView* mSkyTabLayoutContainer; + LLView* mWaterTabLayoutContainer; + LLTextBox* mCurrentTimeLabel; + + // **RIDER** + LLUUID mInventoryId; + LLInventoryItem * mInventoryItem; + LLEnvironment::EnvSelection_t mEditingEnv; + LLTrackBlenderLoopingManual::ptr_t mSkyBlender; + LLTrackBlenderLoopingManual::ptr_t mWaterBlender; + LLSettingsSky::ptr_t mScratchSky; + LLSettingsWater::ptr_t mScratchWater; + // **RIDER** LLFlyoutComboBtnCtrl * mFlyoutControl; diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index 84d80bc32f..d5fc34a04b 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -210,9 +210,9 @@ void LLFloaterFixedEnvironment::loadInventoryItem(const LLUUID &inventoryId) [this](LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status, LLExtStat) { onAssetLoaded(asset_id, settins, status); }); } -void LLFloaterFixedEnvironment::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settins, S32 status) +void LLFloaterFixedEnvironment::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) { - mSettings = settins; + mSettings = settings; updateEditEnvironment(); syncronizeTabs(); refresh(); diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h index 0590a80e57..ef47941555 100644 --- a/indra/newview/llfloaterfixedenvironment.h +++ b/indra/newview/llfloaterfixedenvironment.h @@ -141,7 +141,7 @@ private: class LLSettingsEditPanel : public LLPanel { public: - virtual void setSettings(LLSettingsBase::ptr_t &) = 0; + virtual void setSettings(const LLSettingsBase::ptr_t &) = 0; // virtual void refresh() override; diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index 497c98af1f..56ae9dc7bb 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -45,7 +45,7 @@ class LLPanelSettingsSky : public LLSettingsEditPanel public: LLPanelSettingsSky(); - virtual void setSettings(LLSettingsBase::ptr_t &settings) override { setSky(std::static_pointer_cast<LLSettingsSky>(settings)); } + virtual void setSettings(const LLSettingsBase::ptr_t &settings) override { setSky(std::static_pointer_cast<LLSettingsSky>(settings)); } LLSettingsSky::ptr_t getSky() const { return mSkySettings; } void setSky(const LLSettingsSky::ptr_t &sky) { mSkySettings = sky; refresh(); } diff --git a/indra/newview/llpaneleditwater.h b/indra/newview/llpaneleditwater.h index 72ffa05767..3b41a1bb24 100644 --- a/indra/newview/llpaneleditwater.h +++ b/indra/newview/llpaneleditwater.h @@ -45,7 +45,7 @@ class LLPanelSettingsWater : public LLSettingsEditPanel public: LLPanelSettingsWater(); - virtual void setSettings(LLSettingsBase::ptr_t &settings) override { setWater(std::static_pointer_cast<LLSettingsWater>(settings)); } + virtual void setSettings(const LLSettingsBase::ptr_t &settings) override { setWater(std::static_pointer_cast<LLSettingsWater>(settings)); } LLSettingsWater::ptr_t getWater() const { return mWaterSettings; } void setWater(const LLSettingsWater::ptr_t &water) { mWaterSettings = water; refresh(); } diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index 8e846fe6ef..ebe3da79f2 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -359,9 +359,13 @@ void LLPanelEnvironmentInfo::onBtnEdit() LLFloaterEditExtDayCycle *dayeditor = (LLFloaterEditExtDayCycle *)LLFloaterReg::getInstance("env_edit_extdaycycle"); if (dayeditor) - { - dayeditor->setEditCommitSignal(boost::bind(&LLPanelEnvironmentInfo::onEditiCommited, this, _1)); - dayeditor->openFloater(mEditingDayCycle, F32Hours(mDayLengthSlider->getValue().asReal()), F32Hours(mDayOffsetSlider->getValue().asReal())); + { //*TODO Determine if region or parcel. + LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_LIVE_ENVIRONMENT, "parcel") + (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mDayLengthSlider->getValueF32() * (60.0 * 60.0))); + + LLFloaterReg::showInstance("env_edit_extdaycycle", params, TAKE_FOCUS_YES); + +// dayeditor->openFloater(mEditingDayCycle, F32Hours(mDayLengthSlider->getValue().asReal()), F32Hours(mDayOffsetSlider->getValue().asReal())); } } diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index ad11bded6a..ba4e15e7db 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -437,7 +437,7 @@ name="atmosphere_panel" /> <panel border="true" - class="panel_settings_clouds" + class="panel_settings_cloud" filename="panel_settings_sky_clouds.xml" label="Clouds" layout="topleft" diff --git a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml index 38ce131dc2..f88618fb71 100644 --- a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml +++ b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml @@ -81,10 +81,6 @@ tab_width="120" tab_padding_right="3"> <!-- Tabs inserted here in code --> - <!-- --> - <!-- --> - - <!-- --> </tab_container> </layout_panel> <layout_panel name="button_panel" |