summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2018-05-23 19:01:52 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2018-05-23 19:01:52 +0300
commitc75eeab8391859e0819de0afbf9acc2293864f1e (patch)
tree6a28c2e613aafb29996ceb42e9c0df192ccaf341 /indra/newview
parentfbaa01d9a0c63386f13f0e43437c69f700950fd6 (diff)
MAINT-8344 Day Cycle Editor (playing)
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloatereditextdaycycle.cpp132
-rw-r--r--indra/newview/llfloatereditextdaycycle.h13
-rw-r--r--indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml120
3 files changed, 173 insertions, 92 deletions
diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp
index e578b5db9a..277f2fab52 100644
--- a/indra/newview/llfloatereditextdaycycle.cpp
+++ b/indra/newview/llfloatereditextdaycycle.cpp
@@ -30,6 +30,7 @@
// libs
#include "llbutton.h"
+#include "llcallbacklist.h"
#include "llcheckboxctrl.h"
#include "llcombobox.h"
#include "llloadingindicator.h"
@@ -74,6 +75,8 @@ const std::string ACTION_APPLY_LOCAL("apply_local");
const std::string ACTION_APPLY_PARCEL("apply_parcel");
const std::string ACTION_APPLY_REGION("apply_region");
+const F32 DAY_CYCLE_PLAY_TIME_SECONDS = 60;
+
//=========================================================================
// **RIDER**
@@ -103,7 +106,9 @@ LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key):
mScratchWater()
// **RIDER**
{
- mCommitCallbackRegistrar.add("DayCycle.Track", boost::bind(&LLFloaterEditExtDayCycle::onTrackSelectionCallback, this, _2));
+
+ mCommitCallbackRegistrar.add("DayCycle.Track", [this](LLUICtrl *ctrl, const LLSD &data) { onTrackSelectionCallback(data); });
+ mCommitCallbackRegistrar.add("DayCycle.PlayActions", [this](LLUICtrl *ctrl, const LLSD &data) { onPlayActionCallback(data); });
mScratchSky = LLSettingsVOSky::buildDefaultSky();
mScratchWater = LLSettingsVOWater::buildDefaultWater();
@@ -226,6 +231,7 @@ void LLFloaterEditExtDayCycle::onClose(bool app_quitting)
{
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
+ stopPlay();
}
void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility)
@@ -238,6 +244,7 @@ void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility)
else
{
LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
+ stopPlay();
}
}
@@ -378,6 +385,34 @@ void LLFloaterEditExtDayCycle::onTrackSelectionCallback(const LLSD& user_data)
selectTrack(track_index);
}
+void LLFloaterEditExtDayCycle::onPlayActionCallback(const LLSD& user_data)
+{
+ std::string action = user_data.asString();
+ F32 frame = mTimeSlider->getCurSliderValue();
+ if (action == "play")
+ {
+ startPlay();
+ }
+ else if (action == "pause")
+ {
+ stopPlay();
+ }
+ else if (mSliderKeyMap.size() != 0)
+ {
+ F32 new_frame = 0;
+ if (action == "forward")
+ {
+ new_frame = mEditDay->getUpperBoundFrame(mCurrentTrack, frame);
+ }
+ else if (action == "back")
+ {
+ new_frame = mEditDay->getLowerBoundFrame(mCurrentTrack, frame - (mTimeSlider->getIncrement() / 2));
+ }
+ selectFrame(new_frame);
+ stopPlay();
+ }
+}
+
void LLFloaterEditExtDayCycle::onFrameSliderCallback()
{
if (mSliderKeyMap.size() == 0)
@@ -453,25 +488,7 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback()
void LLFloaterEditExtDayCycle::onTimeSliderMoved()
{
- mFramesSlider->resetCurSlider();
-
- keymap_t::iterator iter = mSliderKeyMap.begin();
- keymap_t::iterator end_iter = mSliderKeyMap.end();
- F32 frame = mTimeSlider->getCurSliderValue();
- while (iter != end_iter)
- {
- if (iter->second.mFrame == frame)
- {
- mFramesSlider->setCurSlider(iter->first);
- break;
- }
- iter++;
- }
-
- // block or update tabs according to new selection
- updateTabs();
-
- // blending:
+ selectFrame(mTimeSlider->getCurSliderValue());
}
void LLFloaterEditExtDayCycle::selectTrack(U32 track_index)
@@ -496,6 +513,28 @@ void LLFloaterEditExtDayCycle::selectTrack(U32 track_index)
updateSlider();
}
+void LLFloaterEditExtDayCycle::selectFrame(F32 frame)
+{
+ mFramesSlider->resetCurSlider();
+
+ mTimeSlider->setCurSliderValue(frame);
+
+ keymap_t::iterator iter = mSliderKeyMap.begin();
+ keymap_t::iterator end_iter = mSliderKeyMap.end();
+ while (iter != end_iter)
+ {
+ if (iter->second.mFrame == frame)
+ {
+ mFramesSlider->setCurSlider(iter->first);
+ break;
+ }
+ iter++;
+ }
+
+ // block or update tabs according to new selection
+ updateTabs();
+}
+
void LLFloaterEditExtDayCycle::clearTabs()
{
// Note: If this doesn't look good, init panels with default settings. It might be better looking
@@ -612,8 +651,9 @@ 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);
+ bool can_add = settings.get() == NULL;
+ mAddFrameButton->setEnabled(can_add);
+ mDeleteFrameButton->setEnabled(!can_add);
}
void LLFloaterEditExtDayCycle::updateSlider()
@@ -738,7 +778,6 @@ void LLFloaterEditExtDayCycle::loadInventoryItem(const LLUUID &inventoryId)
void LLFloaterEditExtDayCycle::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status)
{
mEditDay = std::dynamic_pointer_cast<LLSettingsDay>(settings);
- mOriginalDay = mEditDay->buildClone();
updateEditEnvironment();
syncronizeTabs();
refresh();
@@ -753,7 +792,6 @@ void LLFloaterEditExtDayCycle::loadLiveEnvironment(LLEnvironment::EnvSelection_t
if (day)
{
- mOriginalDay = day;
mEditDay = day->buildClone();
break;
}
@@ -811,9 +849,9 @@ void LLFloaterEditExtDayCycle::syncronizeTabs()
LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(tabs->getPanelByIndex(idx));
if (panel)
{
- panel->setAllChildrenEnabled(canedit);
panel->setSettings(psettingWater);
- panel->refresh();
+ panel->setEnabled(canedit);
+ panel->setAllChildrenEnabled(canedit);
}
}
@@ -842,9 +880,9 @@ void LLFloaterEditExtDayCycle::syncronizeTabs()
LLSettingsEditPanel *panel = static_cast<LLSettingsEditPanel *>(tabs->getPanelByIndex(idx));
if (panel)
{
- panel->setAllChildrenEnabled(canedit);
panel->setSettings(psettingSky);
- panel->refresh();
+ panel->setEnabled(canedit);
+ panel->setAllChildrenEnabled(canedit);
}
}
@@ -974,4 +1012,42 @@ bool LLFloaterEditExtDayCycle::canApplyParcel() const
// **RIDER**
+void LLFloaterEditExtDayCycle::startPlay()
+{
+ mPlayTimer.reset();
+ mPlayTimer.start();
+ gIdleCallbacks.addFunction(onIdlePlay, this);
+ mPlayStartFrame = mTimeSlider->getCurSliderValue();
+
+ getChild<LLView>("play_layout", true)->setVisible(FALSE);
+ getChild<LLView>("pause_layout", true)->setVisible(TRUE);
+}
+
+void LLFloaterEditExtDayCycle::stopPlay()
+{
+ gIdleCallbacks.deleteFunction(onIdlePlay, this);
+ mPlayTimer.stop();
+
+ getChild<LLView>("play_layout", true)->setVisible(TRUE);
+ getChild<LLView>("pause_layout", true)->setVisible(FALSE);
+}
+
+//static
+void LLFloaterEditExtDayCycle::onIdlePlay(void* user_data)
+{
+ LLFloaterEditExtDayCycle* self = (LLFloaterEditExtDayCycle*)user_data;
+
+ F32 prcnt_played = self->mPlayTimer.getElapsedTimeF32() / DAY_CYCLE_PLAY_TIME_SECONDS;
+ F32 new_frame = fmod(self->mPlayStartFrame + prcnt_played, 1.f);
+
+ self->mTimeSlider->setCurSliderValue(new_frame); // will do the rounding
+ self->selectFrame(self->mTimeSlider->getCurSliderValue());
+
+ if (self->mPlayTimer.getElapsedTimeF32() > DAY_CYCLE_PLAY_TIME_SECONDS)
+ {
+ // Nothing to do anymore.
+ self->stopPlay();
+ }
+}
+
diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h
index 6ef3563e8f..c68e189cae 100644
--- a/indra/newview/llfloatereditextdaycycle.h
+++ b/indra/newview/llfloatereditextdaycycle.h
@@ -87,12 +87,14 @@ private:
void onRemoveTrack();
void onCommitName(class LLLineEditor* caller, void* user_data);
void onTrackSelectionCallback(const LLSD& user_data);
+ void onPlayActionCallback(const LLSD& user_data);
// time slider moved
void onTimeSliderMoved();
// a frame moved or frame selection changed
void onFrameSliderCallback();
void selectTrack(U32 track_index);
+ void selectFrame(F32 frame);
void clearTabs();
void updateTabs();
void updateWaterTabs(const LLSettingsWaterPtr_t &p_water);
@@ -126,11 +128,13 @@ private:
void reblendSettings();
// **RIDER**
-
- // data for restoring previous displayed environment
+
+ // play functions
+ void startPlay();
+ void stopPlay();
+ static void onIdlePlay(void* user_data);
LLSettingsDay::ptr_t mEditDay; // edited copy
- LLSettingsDay::ptr_t mOriginalDay; // the one we are editing
S64Seconds mDayLength;
U32 mCurrentTrack;
std::string mLastFrameSlider;
@@ -158,6 +162,9 @@ private:
LLFlyoutComboBtnCtrl * mFlyoutControl;
+ LLFrameTimer mPlayTimer;
+ F32 mPlayStartFrame; // an env frame
+
edit_commit_signal_t mCommitSignal;
// For map of sliders to parameters
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 c4de2cdaee..1b07d1aa27 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
@@ -47,7 +47,7 @@
follows="top|left"
layout="topleft"
left_pad="10"
- max_chars="100"
+ max_length_bytes="100"
name="day_cycle_name"
top="5"
width="200"
@@ -74,8 +74,6 @@
<panel name="timeline_layers"
border="false"
follows="left|top"
- auto_resize="false"
- user_resize="true"
height="150"
width="110"
top_pad="0"
@@ -150,8 +148,6 @@
<panel name="timeline"
border="true"
follows="left|top"
- auto_resize="false"
- user_resize="true"
height="150"
min_height="0"
width="595"
@@ -205,7 +201,6 @@
value="100%[DSC]"
width="80" />
<multi_slider
- can_edit_text="true"
decimal_digits="0"
draw_track="false"
follows="bottom"
@@ -220,11 +215,9 @@
show_text="false"
top_pad="0"
use_triangle="true"
- width="525"
- min_width="525"/>
+ width="525" />
<multi_slider
- can_edit_text="true"
decimal_digits="0"
follows="bottom"
height="10"
@@ -237,8 +230,7 @@
name="WLDayCycleFrames"
show_text="false"
top_pad="15"
- width="525"
- min_width="525" />
+ width="525" />
<text
follows="left|bottom"
@@ -246,7 +238,6 @@
layout="topleft"
left_pad="0"
name="current_time"
- select_on_focus="true"
value="[PRCNT]%[DSC]"
top_delta="-5"
width="70" />
@@ -272,25 +263,29 @@
min_width="25"
width="25">
<button
- name="skip_back_btn"
- follows="top"
- image_overlay="SkipBackward_Off"
- image_disabled="PushButton_Disabled"
- image_disabled_selected="PushButton_Disabled"
- image_selected="PushButton_Selected"
- image_unselected="PushButton_Off"
- hover_glow_amount="0.15"
- auto_resize="false"
- width="25"
- height="25"
- layout="topleft"
- tool_tip="Step back"
- top="0"
- left="0"/>
+ name="skip_back_btn"
+ follows="top"
+ image_overlay="SkipBackward_Off"
+ image_disabled="PushButton_Disabled"
+ image_disabled_selected="PushButton_Disabled"
+ image_selected="PushButton_Selected"
+ image_unselected="PushButton_Off"
+ hover_glow_amount="0.15"
+ auto_resize="false"
+ width="25"
+ height="25"
+ layout="topleft"
+ tool_tip="Step back"
+ top="0"
+ left="0">
+ <button.commit_callback
+ function="DayCycle.PlayActions"
+ parameter="back" />
+ </button>
</layout_panel>
<layout_panel
- name="play"
+ name="play_layout"
mouse_opaque="false"
auto_resize="false"
layout="topleft"
@@ -312,11 +307,15 @@
height="25"
width="25"
left="0"
- top="0" />
+ top="0">
+ <button.commit_callback
+ function="DayCycle.PlayActions"
+ parameter="play" />
+ </button>
</layout_panel>
<layout_panel
- name="pause"
+ name="pause_layout"
mouse_opaque="false"
auto_resize="false"
layout="topleft"
@@ -339,32 +338,40 @@
height="25"
width="25"
left="0"
- top="0"/>
+ top="0">
+ <button.commit_callback
+ function="DayCycle.PlayActions"
+ parameter="pause" />
+ </button>
</layout_panel>
<layout_panel
- name="skip_forward"
- mouse_opaque="false"
- auto_resize="false"
- layout="topleft"
- top="0"
- height="25"
- min_width="25"
- width="25">
+ name="skip_forward"
+ mouse_opaque="false"
+ auto_resize="false"
+ layout="topleft"
+ top="0"
+ height="25"
+ min_width="25"
+ width="25">
<button
- name="skip_forward_btn"
- follows="top"
- image_overlay="SkipForward_Off"
- image_disabled="PushButton_Disabled"
- image_disabled_selected="PushButton_Disabled"
- image_selected="PushButton_Selected"
- image_unselected="PushButton_Off"
- hover_glow_amount="0.15"
- width="25"
- height="25"
- layout="topleft"
- tool_tip="Step forward"
- top="0" />
+ name="skip_forward_btn"
+ follows="top"
+ image_overlay="SkipForward_Off"
+ image_disabled="PushButton_Disabled"
+ image_disabled_selected="PushButton_Disabled"
+ image_selected="PushButton_Selected"
+ image_unselected="PushButton_Off"
+ hover_glow_amount="0.15"
+ width="25"
+ height="25"
+ layout="topleft"
+ tool_tip="Step forward"
+ top="0">
+ <button.commit_callback
+ function="DayCycle.PlayActions"
+ parameter="forward" />
+ </button>
</layout_panel>
</layout_stack>
@@ -505,15 +512,6 @@
name="cancel_btn"
width="100" />
- <!--<button
- follows="top|left"
- height="23"
- label="Upload"
- layout="topleft"
- left_pad="10"
- name="upload_btn"
- width="100" />-->
-
</layout_panel>
</layout_stack>