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.cpp392
1 files changed, 280 insertions, 112 deletions
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**
+
+