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.cpp1280
1 files changed, 544 insertions, 736 deletions
diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp
index c57add32fe..d87ea83fe7 100644
--- a/indra/newview/llfloatereditextdaycycle.cpp
+++ b/indra/newview/llfloatereditextdaycycle.cpp
@@ -38,11 +38,13 @@
#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
#include "llregioninfomodel.h"
#include "llviewerregion.h"
#include "llpaneleditwater.h"
@@ -59,47 +61,78 @@ static const std::string track_tabs[] = {
"sky4_track",
};
+// For flyout
+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");
+
+
+//=========================================================================
+// **RIDER**
-LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key):
+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),
- mSaveButton(NULL),
+ mFlyoutControl(NULL),
mCancelButton(NULL),
mDayLength(0),
- mDayOffset(0),
mCurrentTrack(4),
mTimeSlider(NULL),
mFramesSlider(NULL),
- mCurrentTimeLabel(NULL)
-// , mTimeCtrl(NULL)
-// , mMakeDefaultCheckBox(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()
+{
+ // Todo: consider remaking mFlyoutControl into full view class that initializes intself with floater,
+ // complete with postbuild, e t c...
+ delete mFlyoutControl;
}
// virtual
BOOL LLFloaterEditExtDayCycle::postBuild()
{
- getChild<LLButton>("add_frame")->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddTrack, this));
- getChild<LLButton>("delete_frame")->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onRemoveTrack, this));
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");
mFramesSlider = getChild<LLMultiSliderCtrl>("WLDayCycleFrames");
mSkyTabLayoutContainer = getChild<LLView>("frame_settings_sky", true);
mWaterTabLayoutContainer = getChild<LLView>("frame_settings_water", true);
mCurrentTimeLabel = getChild<LLTextBox>("current_time", true);
- //initCallbacks();
+ mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE);
+ mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); });
- mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnSave, this));
mCancelButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnCancel, this));
- mUploadButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onUpload, this));
mTimeSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onTimeSliderMoved, this));
mFramesSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onFrameSliderCallback, this));
+ mAddFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddTrack, this));
+ mDeleteFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onRemoveTrack, this));
mTimeSlider->addSlider(0);
@@ -114,18 +147,32 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT);
LLEnvironment::instance().updateEnvironment();
+ // **RIDER**
+ mEditingEnv = LLEnvironment::ENV_NONE;
+ mEditDay.reset();
+ if (key.has(KEY_INVENTORY_ID))
{
- // TODO/TEMP
- LLEnvironment::EnvSelection_t env = LLEnvironment::ENV_REGION; // should not be used
- LLSettingsDay::ptr_t pday = LLEnvironment::instance().getEnvironmentDay(env);
- mEditDay = pday->buildClone(); // pday should be passed as parameter
-
- S64Seconds daylength = LLEnvironment::instance().getEnvironmentDayLength(env);
- S64Seconds dayoffset = LLEnvironment::instance().getEnvironmentDayOffset(env);
- mDayLength = daylength; // should be passed as parameter
- mDayOffset = dayoffset; // should be passed as parameter
+ 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
+ {
+ loadLiveEnvironment(LLEnvironment::ENV_DEFAULT);
+ }
+
+ mDayLength.value(0);
+ if (key.has(KEY_DAY_LENGTH))
+ {
+ mDayLength.value(key[KEY_DAY_LENGTH].asReal());
+ }
+
+ // **RIDER**
LLLineEditor* name_field = getChild<LLLineEditor>("day_cycle_name");
name_field->setText(mEditDay->getName());
@@ -137,17 +184,24 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
const S32 max_elm = 5;
if (mDayLength.value() != 0)
{
- F32Hours hrs;
+ S32Hours hrs;
+ S32Minutes minutes;
+ S64Seconds total;
LLUIString formatted_label = getString("time_label");
for (int i = 0; i < max_elm; i++)
{
- // Todo: if possible, find a better way, both to get string and child names
- hrs = ((mDayLength / (max_elm - 1)) * i) + mDayOffset;
- formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value()));
+ total = ((mDayLength / (max_elm - 1)) * i);
+ hrs = total;
+ minutes = total - hrs;
+
+ 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 = mDayOffset;
- formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value()));
+ 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());
}
else
@@ -158,139 +212,159 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
}
mCurrentTimeLabel->setTextArg("[DSC]", std::string());
}
-
- //todo: add time slider setting
-
- /*list_name_id_t getSkyList() const;
- list_name_id_t getWaterList() const;
-
- getChild<LLButton>("sky4_track", true)->setToggleState(true);*/
}
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();
- }
-}
-
-
-void LLFloaterEditExtDayCycle::onUpload()
-{
- LLSettingsVOBase::createInventoryItem( mEditDay );
-
-#if 0
- LLSettingsVOBase::storeAsAsset(mEditDay);
-
- LLTransactionID tid;
- tid.generate();
- LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-
- const std::string filename = asset_id_to_filename(mAssetID, LL_PATH_CACHE);
- if (!exportFile(filename))
- {
- std::string buffer = llformat("Unable to save '%s' to wearable file.", mName.c_str());
- LL_WARNS() << buffer << LL_ENDL;
-
- LLSD args;
- args["NAME"] = mName;
- LLNotificationsUtil::add("CannotSaveWearableOutOfSpace", args);
- return;
- }
-
- if (gSavedSettings.getBOOL("LogWearableAssetSave"))
- {
- const std::string log_filename = asset_id_to_filename(mAssetID, LL_PATH_LOGS);
- exportFile(log_filename);
- }
-
- // save it out to database
- if (gAssetStorage)
+ // 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)
{
- /*
- std::string url = gAgent.getRegion()->getCapability("NewAgentInventory");
- if (!url.empty())
- {
- LL_INFOS() << "Update Agent Inventory via capability" << LL_ENDL;
- LLSD body;
- body["folder_id"] = gInventory.findCategoryUUIDForType(LLFolderType::assetToFolderType(getAssetType()));
- body["asset_type"] = LLAssetType::lookup(getAssetType());
- body["inventory_type"] = LLInventoryType::lookup(LLInventoryType::IT_WEARABLE);
- body["name"] = getName();
- body["description"] = getDescription();
- LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, filename));
- }
- else
- {
- }
- */
- LLWearableSaveData* data = new LLWearableSaveData;
- data->mType = mType;
- gAssetStorage->storeAssetData(filename, mTransactionID, getAssetType(),
- &LLViewerWearable::onSaveNewAssetComplete,
- (void*)data);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
-#endif
}
void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility)
{
if (new_visibility)
{
- LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditDay, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mScratchSky, mScratchWater);
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT);
}
else
{
- /* TODO: don't restore this environment. We may have gotten here from land or region. */
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
-void LLFloaterEditExtDayCycle::onBtnSave()
+void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data)
{
- if (!mCommitSignal.empty())
- mCommitSignal(mEditDay);
- closeFloater();
+ std::string ctrl_action = ctrl->getName();
+
+ 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);
+ }
+ else if (ctrl_action == ACTION_SAVEAS)
+ {
+ LLSettingsVOBase::createInventoryItem(mEditDay);
+ }
+ else
+ {
+ LLEnvironment::EnvSelection_t env(LLEnvironment::ENV_DEFAULT);
+ bool updateSimulator(ctrl_action != ACTION_APPLY_LOCAL);
+
+ 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;
+ }
+
+ LLEnvironment::instance().setEnvironment(env, mEditDay);
+ if (updateSimulator)
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempting to apply " << env << LL_ENDL;
+ }
+ }
}
void LLFloaterEditExtDayCycle::onBtnCancel()
{
- closeFloater();
+ closeFloater(); // will restore env
}
void LLFloaterEditExtDayCycle::onAddTrack()
{
+ // todo: 2.5% safety zone
+ std::string sldr_key = mFramesSlider->getCurSlider();
F32 frame = mTimeSlider->getCurSliderValue();
LLSettingsBase::ptr_t setting;
- // todo: expand to generate from panels instead of using defaults
- if (mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack).get() != NULL) //temp check? todo: disable button in such cases
+ if (mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack).get() != NULL)
{
return;
}
- if (mCurrentTrack == 0)
+
+ if (mCurrentTrack == LLSettingsDay::TRACK_WATER)
{
- setting = LLSettingsVOWater::buildDefaultWater();
+ // **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
{
- setting = LLSettingsVOSky::buildDefaultSky();
+ // **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);
}
+
addSliderFrame(frame, setting);
updateTabs();
}
void LLFloaterEditExtDayCycle::onRemoveTrack()
{
- F32 frame = mTimeSlider->getCurSliderValue();
- mEditDay->removeTrackKeyframe(mCurrentTrack, frame);
+ std::string sldr_key = mFramesSlider->getCurSlider();
+ if (!sldr_key.empty())
+ {
+ return;
+ }
removeCurrentSliderFrame();
- //mFramesSlider->deleteCurSlider();
+ updateButtons();
}
void LLFloaterEditExtDayCycle::onCommitName(class LLLineEditor* caller, void* user_data)
@@ -306,31 +380,63 @@ void LLFloaterEditExtDayCycle::onTrackSelectionCallback(const LLSD& user_data)
void LLFloaterEditExtDayCycle::onFrameSliderCallback()
{
- if (mFramesSlider->getValue().size() == 0)
+ if (mSliderKeyMap.size() == 0)
{
mLastFrameSlider.clear();
return;
}
// make sure we have a slider
const std::string& cur_sldr = mFramesSlider->getCurSlider();
- if (cur_sldr == "")
+ if (cur_sldr.empty())
{
mLastFrameSlider.clear();
return;
}
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() && /*temp? until disabling mechanics*/ mEditDay->getSettingsAtKeyframe(new_frame, mCurrentTrack).get() == NULL)
+ 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)
+ {
+ 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
{
- iter->second.first = new_frame;
+ 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;
+ }
}
}
+ mTimeSlider->setCurSliderValue(new_frame);
+
if (mLastFrameSlider != cur_sldr)
{
// technically should not be possible for both frame and slider to change
@@ -338,34 +444,38 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback()
mLastFrameSlider = cur_sldr;
updateTabs();
}
- // updateTrack();
- // reset last known position
+ else
+ {
+ updateButtons();
+ updateTimeAndLabel();
+ }
}
void LLFloaterEditExtDayCycle::onTimeSliderMoved()
{
- // Todo: safety checks
- // Update label
- F32 time = mTimeSlider->getCurSliderValue();
- mCurrentTimeLabel->setTextArg("[PRCNT]", llformat("%.0f", time * 100));
- if (mDayLength.value() != 0)
- {
- F32Hours hrs = (mDayLength * time) + mDayOffset;
- LLUIString formatted_label = getString("time_label");
- formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value()));
- mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString());
- }
- else
+ mFramesSlider->resetCurSlider();
+
+ keymap_t::iterator iter = mSliderKeyMap.begin();
+ keymap_t::iterator end_iter = mSliderKeyMap.end();
+ F32 frame = mTimeSlider->getCurSliderValue();
+ while (iter != end_iter)
{
- mCurrentTimeLabel->setTextArg("[DSC]", std::string());
+ if (iter->second.mFrame == frame)
+ {
+ mFramesSlider->setCurSlider(iter->first);
+ break;
+ }
+ iter++;
}
- //Todo: update something related to time/play?
+ // block or update tabs according to new selection
+ updateTabs();
+
+ // 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())
@@ -373,60 +483,82 @@ void LLFloaterEditExtDayCycle::selectTrack(U32 track_index)
return;
}
- for (int i = 0; i < 5; i++) // yse max value
+ for (int i = 0; i < LLSettingsDay::TRACK_MAX; i++) // use max value
{
getChild<LLButton>(track_tabs[i], true)->setToggleState(false);
}
button->setToggleState(true);
- bool show_water = mCurrentTrack == 0;
+ bool show_water = mCurrentTrack == LLSettingsDay::TRACK_WATER;
mSkyTabLayoutContainer->setVisible(!show_water);
mWaterTabLayoutContainer->setVisible(show_water);
updateSlider();
}
-void LLFloaterEditExtDayCycle::updateTabs()
+void LLFloaterEditExtDayCycle::clearTabs()
{
- if (mCurrentTrack == 0)
+ // Note: If this doesn't look good, init panels with default settings. It might be better looking
+ if (mCurrentTrack == LLSettingsDay::TRACK_WATER)
{
- updateWaterTabs();
+ const LLSettingsWaterPtr_t p_water = LLSettingsWaterPtr_t(NULL);
+ updateWaterTabs(p_water);
}
else
{
- updateSkyTabs();
+ const LLSettingsSkyPtr_t p_sky = LLSettingsSkyPtr_t(NULL);
+ updateSkyTabs(p_sky);
}
+ updateButtons();
+ updateTimeAndLabel();
}
-void LLFloaterEditExtDayCycle::updateWaterTabs()
+void LLFloaterEditExtDayCycle::updateTabs()
{
- // todo: substitute with mSliderKeyMap?
- const LLSettingsWaterPtr_t p_water = mEditDay->getWaterAtKeyframe(mFramesSlider->getCurSliderValue());
+// 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();
+}
- // Compiler warnings from getChild about LLPanelSettingsWaterMainTab not being complete/missing params constructor...
- // Todo: fix class to work with getChild()?
- LLView* tab_container = mWaterTabLayoutContainer->getChild<LLView>("water_tabs"); //can't extract panels directly, since they are in 'tuple'
+void LLFloaterEditExtDayCycle::updateWaterTabs(const LLSettingsWaterPtr_t &p_water)
+{
+ 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->setWater(p_water); // todo: Null disables
+ panel->setWater(p_water);
}
}
-void LLFloaterEditExtDayCycle::updateSkyTabs()
+void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky)
{
- // todo: substitute with mSliderKeyMap?
- const LLSettingsSkyPtr_t p_sky = mEditDay->getSkyAtKeyframe(mFramesSlider->getCurSliderValue(), mCurrentTrack);
-
LLView* tab_container = mSkyTabLayoutContainer->getChild<LLView>("sky_tabs"); //can't extract panels directly, since they are in 'tuple'
- // Compiler warnings from getChild about tabs...
- // Todo: fix class
LLPanelSettingsSky* panel;
panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("atmosphere_panel"));
if (panel)
{
- panel->setSky(p_sky); // todo: Null disables
+ panel->setSky(p_sky);
}
panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("clouds_panel"));
if (panel)
@@ -440,51 +572,136 @@ void LLFloaterEditExtDayCycle::updateSkyTabs()
}
}
+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();
+ LLSettingsBase::ptr_t settings = mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack);
+ mAddFrameButton->setEnabled(settings.get() == NULL ? TRUE : FALSE);
+ mDeleteFrameButton->setEnabled(mSliderKeyMap.size() > 0 ? TRUE : FALSE);
+}
+
void LLFloaterEditExtDayCycle::updateSlider()
{
mFramesSlider->clear();
mSliderKeyMap.clear();
LLSettingsDay::CycleTrack_t track = mEditDay->getCycleTrack(mCurrentTrack);
- for (auto &frame : track)
+ for (auto &track_frame : track)
+ {
+ addSliderFrame(track_frame.first, track_frame.second, false);
+ }
+
+ if (mSliderKeyMap.size() > 0)
+ {
+ // update positions
+ mLastFrameSlider = mFramesSlider->getCurSlider();
+ mTimeSlider->setCurSliderValue(mFramesSlider->getCurSliderValue());
+ updateTabs();
+ }
+ else
{
- addSliderFrame(frame.first, frame.second);
+ // disable panels
+ clearTabs();
+ mLastFrameSlider.clear();
}
}
-void LLFloaterEditExtDayCycle::addSliderFrame(const F32 frame, LLSettingsBase::ptr_t setting)
+void LLFloaterEditExtDayCycle::updateTimeAndLabel()
+{
+ F32 time = mTimeSlider->getCurSliderValue();
+ mCurrentTimeLabel->setTextArg("[PRCNT]", llformat("%.0f", time * 100));
+ if (mDayLength.value() != 0)
+ {
+ LLUIString formatted_label = getString("time_label");
+
+ S64Seconds total = (mDayLength * time);
+ S32Hours hrs = total;
+ S32Minutes minutes = total - hrs;
+
+ formatted_label.setArg("[HH]", llformat("%d", hrs.value()));
+ formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value())));
+ mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString());
+ }
+ else
+ {
+ mCurrentTimeLabel->setTextArg("[DSC]", std::string());
+ }
+
+ // Update blender here:
+}
+
+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 recal dependencies
+ // 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);
- updateTabs();
+ if (update_ui)
+ {
+ mLastFrameSlider = new_slider;
+ mTimeSlider->setCurSliderValue(frame);
+ updateTabs();
+ }
}
void LLFloaterEditExtDayCycle::removeCurrentSliderFrame()
{
std::string sldr = mFramesSlider->getCurSlider();
+ if (sldr.empty())
+ {
+ return;
+ }
mFramesSlider->deleteCurSlider();
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.mFrame);
}
+ mLastFrameSlider = mFramesSlider->getCurSlider();
+ mTimeSlider->setCurSliderValue(mFramesSlider->getCurSliderValue());
updateTabs();
}
-/*void LLFloaterEditExtDayCycle::updateTrack()
-{
- LLMultiSliderCtrl* slider = getChild<LLMultiSliderCtrl>("WLDayCycleKeys");
- //mEditDay->getTrackKeyframes
-
- // todo make tracks named to allow movement
-}*/
-
//-------------------------------------------------------------------------
LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSignal(LLFloaterEditExtDayCycle::edit_commit_signal_t::slot_type cb)
@@ -492,565 +709,156 @@ LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSi
return mCommitSignal.connect(cb);
}
-//
-// virtual
-// void LLFloaterEditExtDayCycle::draw()
-// {
-// syncTimeSlider();
-// LLFloater::draw();
-// }
-//
-// void LLFloaterEditExtDayCycle::initCallbacks(void)
-// {
-// #if 0
-// mDayCycleNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onDayCycleNameEdited, this), NULL);
-// mDayCyclesCombo->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onDayCycleSelected, this));
-// mDayCyclesCombo->setTextEntryCallback(boost::bind(&LLFloaterEditExtDayCycle::onDayCycleNameEdited, this));
-// mTimeSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onTimeSliderMoved, this));
-// mKeysSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onKeyTimeMoved, this));
-// mTimeCtrl->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onKeyTimeChanged, this));
-// mSkyPresetsCombo->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onKeyPresetChanged, this));
-//
-// getChild<LLButton>("WLAddKey")->setClickedCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddKey, this));
-// getChild<LLButton>("WLDeleteKey")->setClickedCallback(boost::bind(&LLFloaterEditExtDayCycle::onDeleteKey, this));
-//
-// mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnSave, this));
-// mSaveButton->setRightMouseDownCallback(boost::bind(&LLFloaterEditExtDayCycle::dumpTrack, this));
-// getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnCancel, this));
-//
-// // Connect to env manager events.
-// LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance();
-// env_mgr.setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditExtDayCycle::onRegionSettingsChange, this));
-// gAgent.addRegionChangedCallback(boost::bind(&LLFloaterEditExtDayCycle::onRegionChange, this));
-// env_mgr.setRegionSettingsAppliedCallback(boost::bind(&LLFloaterEditExtDayCycle::onRegionSettingsApplied, this, _1));
-// // Connect to day cycle manager events.
-// LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEditExtDayCycle::onDayCycleListChange, this));
-//
-// // Connect to sky preset list changes.
-// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditExtDayCycle::onSkyPresetListChange, this));
-//
-//
-// // Connect to region info updates.
-// LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditExtDayCycle::onRegionInfoUpdate, this));
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::syncTimeSlider()
-// {
-// #if 0
-// // set time
-// mTimeSlider->setCurSliderValue((F32)LLWLParamManager::getInstance()->mAnimator.getDayTime() * sHoursPerDay);
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::loadTrack()
-// {
-// // clear the slider
-// mKeysSlider->clear();
-// mSliderToKey.clear();
-//
-// // add sliders
-//
-// LL_DEBUGS() << "Adding " << LLWLParamManager::getInstance()->mDay.mTimeMap.size() << " keys to slider" << LL_ENDL;
-//
-// LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay;
-// for (std::map<F32, LLWLParamKey>::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it)
-// {
-// addSliderKey(it->first * sHoursPerDay, it->second);
-// }
-//
-// // set drop-down menu to match preset of currently-selected keyframe (one is automatically selected initially)
-// const std::string& cur_sldr = mKeysSlider->getCurSlider();
-// if (strlen(cur_sldr.c_str()) > 0) // only do this if there is a curSldr, otherwise we put an invalid entry into the map
-// {
-// mSkyPresetsCombo->selectByValue(mSliderToKey[cur_sldr].keyframe.toStringVal());
-// }
-//
-// syncTimeSlider();
-// }
-//
-// void LLFloaterEditExtDayCycle::applyTrack()
-// {
-// #if 0
-// LL_DEBUGS() << "Applying track (" << mSliderToKey.size() << ")" << LL_ENDL;
-//
-// // if no keys, do nothing
-// if (mSliderToKey.size() == 0)
-// {
-// LL_DEBUGS() << "No keys, not syncing" << LL_ENDL;
-// return;
-// }
-//
-// llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size());
-//
-// // create a new animation track
-// LLWLParamManager::getInstance()->mDay.clearKeyframes();
-//
-// // add the keys one by one
-// for (std::map<std::string, SliderKey>::iterator it = mSliderToKey.begin();
-// it != mSliderToKey.end(); ++it)
-// {
-// LLWLParamManager::getInstance()->mDay.addKeyframe(it->second.time / sHoursPerDay,
-// it->second.keyframe);
-// }
-//
-// // set the param manager's track to the new one
-// LLWLParamManager::getInstance()->resetAnimator(
-// mTimeSlider->getCurSliderValue() / sHoursPerDay, false);
-//
-// LLWLParamManager::getInstance()->mAnimator.update(
-// LLWLParamManager::getInstance()->mCurParams);
-// #endif
-// }
-
-// void LLFloaterEditExtDayCycle::refreshDayCyclesList()
-// {
-// #if 0
-// llassert(isNewDay() == false);
-//
-// mDayCyclesCombo->removeall();
-//
-// #if 0 // Disable editing existing day cycle until the workflow is clear enough.
-// const LLSD& region_day = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle();
-// if (region_day.size() > 0)
-// {
-// LLWLParamKey key(getRegionName(), LLEnvKey::SCOPE_REGION);
-// mDayCyclesCombo->add(key.name, key.toLLSD());
-// mDayCyclesCombo->addSeparator();
-// }
-// #endif
-//
-// LLDayCycleManager::preset_name_list_t user_days, sys_days;
-// LLDayCycleManager::instance().getPresetNames(user_days, sys_days);
-//
-// // Add user days.
-// for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it)
-// {
-// mDayCyclesCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD());
-// }
-//
-// if (user_days.size() > 0)
-// {
-// mDayCyclesCombo->addSeparator();
-// }
-//
-// // Add system days.
-// for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it)
-// {
-// mDayCyclesCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD());
-// }
-//
-// mDayCyclesCombo->setLabel(getString("combo_label"));
-// #endif
-// }
-//
-//
-//
-// void LLFloaterEditExtDayCycle::onKeyTimeChanged()
-// {
-// #if 0
-// // if no keys, skipped
-// if (mSliderToKey.size() == 0)
-// {
-// return;
-// }
-//
-// F32 time24 = mTimeCtrl->getTime24();
-//
-// const std::string& cur_sldr = mKeysSlider->getCurSlider();
-// mKeysSlider->setCurSliderValue(time24, TRUE);
-// F32 time = mKeysSlider->getCurSliderValue() / sHoursPerDay;
-//
-// // now set the key's time in the sliderToKey map
-// LL_DEBUGS() << "Setting key time: " << time << LL_ENDL;
-// mSliderToKey[cur_sldr].time = time;
-//
-// applyTrack();
-// #endif
-// }
-//
-//
-// void LLFloaterEditExtDayCycle::onAddKey()
-// {
-// #if 0
-// llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size());
-//
-// S32 max_sliders;
-// LLEnvKey::EScope scope = LLEnvKey::SCOPE_LOCAL; // *TODO: editing region day cycle
-// switch (scope)
-// {
-// case LLEnvKey::SCOPE_LOCAL:
-// max_sliders = 20; // *HACK this should be LLWLPacketScrubber::MAX_LOCAL_KEY_FRAMES;
-// break;
-// case LLEnvKey::SCOPE_REGION:
-// max_sliders = 12; // *HACK this should be LLWLPacketScrubber::MAX_REGION_KEY_FRAMES;
-// break;
-// default:
-// max_sliders = (S32) mKeysSlider->getMaxValue();
-// break;
-// }
-//
-// #if 0
-// if ((S32)mSliderToKey.size() >= max_sliders)
-// {
-// LLSD args;
-// args["SCOPE"] = LLEnvManagerNew::getScopeString(scope);
-// args["MAX"] = max_sliders;
-// LLNotificationsUtil::add("DayCycleTooManyKeyframes", args, LLSD(), LLNotificationFunctorRegistry::instance().DONOTHING);
-// return;
-// }
-// #endif
-//
-// // add the slider key
-// std::string key_val = mSkyPresetsCombo->getSelectedValue().asString();
-// LLWLParamKey sky_params(key_val);
-// llassert(!sky_params.name.empty());
-//
-// F32 time = mTimeSlider->getCurSliderValue();
-// addSliderKey(time, sky_params);
-//
-// // apply the change to current day cycles
-// applyTrack();
-// #endif
-// }
-//
+// **RIDER**
+void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId)
+{
+ 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();
+}
+
+void LLFloaterEditExtDayCycle::loadLiveEnvironment(LLEnvironment::EnvSelection_t env)
+{
+ 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**
+
-// #if 0
-// LLWLParamKey LLFloaterEditExtDayCycle::getSelectedDayCycle()
-// {
-// LLWLParamKey dc_key;
-//
-// if (mDayCycleNameEditor->getVisible())
-// {
-// dc_key.name = mDayCycleNameEditor->getText();
-// dc_key.scope = LLEnvKey::SCOPE_LOCAL;
-// }
-// else
-// {
-// LLSD combo_val = mDayCyclesCombo->getValue();
-//
-// if (!combo_val.isArray()) // manually typed text
-// {
-// dc_key.name = combo_val.asString();
-// dc_key.scope = LLEnvKey::SCOPE_LOCAL;
-// }
-// else
-// {
-// dc_key.fromLLSD(combo_val);
-// }
-// }
-//
-// return dc_key;
-// }
-// #endif
-//
-// bool LLFloaterEditExtDayCycle::isNewDay() const
-// {
-// return mKey.asString() == "new";
-// }
-//
-// void LLFloaterEditExtDayCycle::dumpTrack()
-// {
-// #if 0
-// LL_DEBUGS("Windlight") << "Dumping day cycle" << LL_ENDL;
-//
-// LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay;
-// for (std::map<F32, LLWLParamKey>::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it)
-// {
-// F32 time = it->first * 24.0f;
-// S32 h = (S32) time;
-// S32 m = (S32) ((time - h) * 60.0f);
-// LL_DEBUGS("Windlight") << llformat("(%.3f) %02d:%02d", time, h, m) << " => " << it->second.name << LL_ENDL;
-// }
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::enableEditing(bool enable)
-// {
-// mSkyPresetsCombo->setEnabled(enable);
-// mTimeCtrl->setEnabled(enable);
-// getChild<LLPanel>("day_cycle_slider_panel")->setCtrlsEnabled(enable);
-// mSaveButton->setEnabled(enable);
-// mMakeDefaultCheckBox->setEnabled(enable);
-// }
-//
-// void LLFloaterEditExtDayCycle::reset()
-// {
-// #if 0
-// // clear the slider
-// mKeysSlider->clear();
-// mSliderToKey.clear();
-//
-// refreshSkyPresetsList();
-//
-// if (isNewDay())
-// {
-// mDayCycleNameEditor->setValue(LLSD());
-// F32 time = 0.5f * sHoursPerDay;
-// mSaveButton->setEnabled(FALSE); // will be enabled as soon as users enters a name
-// mTimeSlider->setCurSliderValue(time);
-//
-// addSliderKey(time, LLWLParamKey("Default", LLEnvKey::SCOPE_LOCAL));
-// onKeyTimeMoved(); // update the time control and sky sky combo
-//
-// applyTrack();
-// }
-// else
-// {
-// refreshDayCyclesList();
-//
-// // Disable controls until a day cycle to edit is selected.
-// enableEditing(false);
-// }
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::saveRegionDayCycle()
-// {
-// #if 0
-// LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance();
-// LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; // the day cycle being edited
-//
-// // Get current day cycle and the sky preset it references.
-// LLSD day_cycle = cur_dayp.asLLSD();
-// LLSD sky_map;
-// cur_dayp.getSkyMap(sky_map);
-//
-// // Apply it to the region.
-// LLEnvironmentSettings new_region_settings;
-// new_region_settings.saveParams(day_cycle, sky_map, env_mgr.getRegionSettings().getWaterParams(), 0.0f);
-//
-// #if 1
-// LLEnvManagerNew::instance().setRegionSettings(new_region_settings);
-// #else // Temporary disabled ability to upload new region settings from the Day Cycle Editor.
-// if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings))
-// {
-// LL_WARNS() << "Error applying region environment settings" << LL_ENDL;
-// return;
-// }
-//
-// setApplyProgress(true);
-// #endif
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::setApplyProgress(bool started)
-// {
-// LLLoadingIndicator* indicator = getChild<LLLoadingIndicator>("progress_indicator");
-//
-// indicator->setVisible(started);
-//
-// if (started)
-// {
-// indicator->start();
-// }
-// else
-// {
-// indicator->stop();
-// }
-// }
-//
-// bool LLFloaterEditExtDayCycle::getApplyProgress() const
-// {
-// return getChild<LLLoadingIndicator>("progress_indicator")->getVisible();
-// }
-//
-// void LLFloaterEditExtDayCycle::onDeleteKey()
-// {
-// #if 0
-// if (mSliderToKey.size() == 0)
-// {
-// return;
-// }
-// else if (mSliderToKey.size() == 1)
-// {
-// LLNotifications::instance().add("EnvCannotDeleteLastDayCycleKey", LLSD(), LLSD());
-// return;
-// }
-//
-// // delete from map
-// const std::string& sldr_name = mKeysSlider->getCurSlider();
-// std::map<std::string, SliderKey>::iterator mIt = mSliderToKey.find(sldr_name);
-// mSliderToKey.erase(mIt);
-//
-// mKeysSlider->deleteCurSlider();
-//
-// if (mSliderToKey.size() == 0)
-// {
-// return;
-// }
-//
-// const std::string& name = mKeysSlider->getCurSlider();
-// mSkyPresetsCombo->selectByValue(mSliderToKey[name].keyframe.toStringVal());
-// F32 time24 = mSliderToKey[name].time;
-//
-// mTimeCtrl->setTime24(time24);
-//
-// applyTrack();
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::onRegionSettingsChange()
-// {
-// #if 0
-// LL_DEBUGS("Windlight") << "Region settings changed" << LL_ENDL;
-//
-// if (getApplyProgress()) // our region settings have being applied
-// {
-// setApplyProgress(false);
-//
-// // Change preference if requested.
-// if (mMakeDefaultCheckBox->getValue())
-// {
-// LL_DEBUGS("Windlight") << "Changed environment preference to region settings" << LL_ENDL;
-// LLEnvManagerNew::instance().setUseRegionSettings(true);
-// }
-//
-// closeFloater();
-// }
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::onRegionChange()
-// {
-// #if 0
-// LL_DEBUGS("Windlight") << "Region changed" << LL_ENDL;
-//
-// // If we're editing the region day cycle
-// if (getSelectedDayCycle().scope == LLEnvKey::SCOPE_REGION)
-// {
-// reset(); // undoes all unsaved changes
-// }
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::onRegionSettingsApplied(bool success)
-// {
-// LL_DEBUGS("Windlight") << "Region settings applied: " << success << LL_ENDL;
-//
-// if (!success)
-// {
-// // stop progress indicator
-// setApplyProgress(false);
-// }
-// }
-//
-// void LLFloaterEditExtDayCycle::onRegionInfoUpdate()
-// {
-// #if 0
-// LL_DEBUGS("Windlight") << "Region info updated" << LL_ENDL;
-// bool can_edit = true;
-//
-// // If we've selected the region day cycle for editing.
-// if (getSelectedDayCycle().scope == LLEnvKey::SCOPE_REGION)
-// {
-// // check whether we have the access
-// can_edit = LLEnvManagerNew::canEditRegionSettings();
-// }
-//
-// enableEditing(can_edit);
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::onDayCycleNameEdited()
-// {
-// #if 0
-// // Disable saving a day cycle having empty name.
-// LLWLParamKey key = getSelectedDayCycle();
-// mSaveButton->setEnabled(!key.name.empty());
-// #endif
-// }
-//
-// void LLFloaterEditExtDayCycle::onDayCycleSelected()
-// {
-// #if 0
-//
-// LLSD day_data;
-// LLWLParamKey dc_key = getSelectedDayCycle();
-// bool can_edit = true;
-//
-// if (dc_key.scope == LLEnvKey::SCOPE_LOCAL)
-// {
-// if (!LLDayCycleManager::instance().getPreset(dc_key.name, day_data))
-// {
-// LL_WARNS() << "No day cycle named " << dc_key.name << LL_ENDL;
-// return;
-// }
-// }
-// else
-// {
-// day_data = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle();
-// if (day_data.size() == 0)
-// {
-// LL_WARNS() << "Empty region day cycle" << LL_ENDL;
-// llassert(day_data.size() > 0);
-// return;
-// }
-//
-// can_edit = LLEnvManagerNew::canEditRegionSettings();
-// }
-//
-// // We may need to add or remove region skies from the list.
-// refreshSkyPresetsList();
-//
-// F32 slider_time = mTimeSlider->getCurSliderValue() / sHoursPerDay;
-// LLWLParamManager::instance().applyDayCycleParams(day_data, dc_key.scope, slider_time);
-// loadTrack();
-// #endif
-// enableEditing(false);
-// }
-//
-// bool LLFloaterEditExtDayCycle::onSaveAnswer(const LLSD& notification, const LLSD& response)
-// {
-// S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-//
-// // If they choose save, do it. Otherwise, don't do anything
-// if (option == 0)
-// {
-// onSaveConfirmed();
-// }
-//
-// return false;
-// }
-//
-// void LLFloaterEditExtDayCycle::onSaveConfirmed()
-// {
-// #if 0
-// std::string name = getSelectedDayCycle().name;
-//
-// // Save preset.
-// LLSD data = LLWLParamManager::instance().mDay.asLLSD();
-// LL_DEBUGS("Windlight") << "Saving day cycle " << name << ": " << data << LL_ENDL;
-// LLDayCycleManager::instance().savePreset(name, data);
-//
-// // Change preference if requested.
-// if (mMakeDefaultCheckBox->getValue())
-// {
-// LL_DEBUGS("Windlight") << name << " is now the new preferred day cycle" << LL_ENDL;
-// LLEnvManagerNew::instance().setUseDayCycle(name);
-// }
-// #endif
-// closeFloater();
-// }
-//
-// void LLFloaterEditExtDayCycle::onDayCycleListChange()
-// {
-// if (!isNewDay())
-// {
-// refreshDayCyclesList();
-// }
-// }
-//
-// void LLFloaterEditExtDayCycle::onSkyPresetListChange()
-// {
-// refreshSkyPresetsList();
-//
-// // Refresh sliders from the currently visible day cycle.
-// loadTrack();
-// }
-//
-// static
-// std::string LLFloaterEditExtDayCycle::getRegionName()
-// {
-// return gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown");
-// }