Added a reload button to upload animation preview. Patch by Dawa Gurbux, thank you! FIRE-4662

master
ziree 2012-01-15 00:58:37 +01:00
parent dfc8a8e5a2
commit bcb6a412e0
3 changed files with 78 additions and 36 deletions

View File

@ -188,9 +188,6 @@ void LLFloaterAnimPreview::setAnimCallbacks()
//-----------------------------------------------------------------------------
BOOL LLFloaterAnimPreview::postBuild()
{
LLKeyframeMotion* motionp = NULL;
LLBVHLoader* loaderp = NULL;
if (!LLFloaterNameDesc::postBuild())
{
return FALSE;
@ -198,30 +195,43 @@ BOOL LLFloaterAnimPreview::postBuild()
getChild<LLUICtrl>("name_form")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitName, this));
childSetAction("reload_btn", onBtnReload, this);
childSetAction("ok_btn", onBtnOK, this);
setDefaultBtn();
if (sUseDummy)
{
LLRect rect = getRect();
translate(0, PREVIEW_TEXTURE_HEIGHT-30);
reshape(rect.getWidth(), rect.getHeight() + PREVIEW_TEXTURE_HEIGHT-30);
if (sUseDummy)
{
LLRect rect = getRect();
translate(0, PREVIEW_TEXTURE_HEIGHT-30);
reshape(rect.getWidth(), rect.getHeight() + PREVIEW_TEXTURE_HEIGHT-30);
mPreviewRect.set(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT, getRect().getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD);
mPreviewImageRect.set(0.f, 1.f, 1.f, 0.f);
}
mPreviewRect.set(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT, getRect().getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD);
mPreviewImageRect.set(0.f, 1.f, 1.f, 0.f);
}
mPlayButton = getChild<LLButton>( "play_btn");
mPlayButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnPlay, this));
mPlayButton->setVisible(true);
mPauseButton = getChild<LLButton>( "pause_btn");
mPauseButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnPause, this));
mPauseButton->setVisible(false);
mStopButton = getChild<LLButton>( "stop_btn");
mStopButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnStop, this));
loadBVH();
return TRUE;
}
//-----------------------------------------------------------------------------
// loadBVH()
//-----------------------------------------------------------------------------
BOOL LLFloaterAnimPreview::loadBVH()
{
LLKeyframeMotion* motionp = NULL;
LLBVHLoader* loaderp = NULL;
mPlayButton->setVisible(true);
mPauseButton->setVisible(false);
getChildView("bad_animation_text")->setVisible(FALSE);
std::string exten = gDirUtilp->getExtension(mFilename);
@ -371,20 +381,28 @@ BOOL LLFloaterAnimPreview::postBuild()
return TRUE;
}
//-----------------------------------------------------------------------------
// unloadMotion()
//-----------------------------------------------------------------------------
void LLFloaterAnimPreview::unloadMotion()
{
if (mMotionID.notNull() && mAnimPreview && !sUseDummy)
{
resetMotion();
mAnimPreview->getPreviewAvatar()->removeMotion(mMotionID);
LLKeyframeDataCache::removeKeyframeData(mMotionID);
}
mMotionID.setNull();
mAnimPreview = NULL;
}
//-----------------------------------------------------------------------------
// LLFloaterAnimPreview()
//-----------------------------------------------------------------------------
LLFloaterAnimPreview::~LLFloaterAnimPreview()
{
if (mMotionID.notNull() && mAnimPreview && !sUseDummy)
{
resetMotion();
mAnimPreview->getPreviewAvatar()->removeMotion(mMotionID);
LLKeyframeDataCache::removeKeyframeData(mMotionID);
}
mMotionID.setNull();
mAnimPreview = NULL;
unloadMotion();
setEnabled(FALSE);
}
@ -1031,6 +1049,18 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata)
floaterp->closeFloater(false);
}
//-----------------------------------------------------------------------------
// onBtnReload()
//-----------------------------------------------------------------------------
void LLFloaterAnimPreview::onBtnReload(void* userdata)
{
LLFloaterAnimPreview* floaterp = (LLFloaterAnimPreview*)userdata;
if (!floaterp->getEnabled()) return;
floaterp->unloadMotion();
floaterp->loadBVH();
}
//-----------------------------------------------------------------------------
// LLPreviewAnimation
//-----------------------------------------------------------------------------

View File

@ -102,10 +102,13 @@ public:
bool validateEaseIn(const LLSD& data);
bool validateEaseOut(const LLSD& data);
static void onBtnOK(void*);
static void onBtnReload(void*);
static void onSaveComplete(const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status);
static bool sUseDummy;
private:
void setAnimCallbacks() ;
BOOL loadBVH();
void unloadMotion();
protected:
void draw();

View File

@ -2,7 +2,7 @@
<floater
legacy_header_height="18"
can_minimize="false"
height="360"
height="387"
left="30"
layout="topleft"
name="Animation Preview"
@ -550,15 +550,24 @@ Maximum animation length is [MAX_LENGTH] seconds.
Unable to read animation file.
We recommend BVH files exported from Poser 4.
</text>
<button
bottom="-5"
follows="bottom|left"
height="23"
label="Upload (L$[AMOUNT])"
layout="topleft"
left="10"
name="ok_btn"
width="128" />
<button
bottom="-32"
follows="bottom|left"
height="23"
label="Reload file"
layout="topleft"
left="10"
name="reload_btn"
width="128" />
<button
bottom="-5"
follows="bottom|left"
height="23"
label="Upload (L$[AMOUNT])"
layout="topleft"
left="10"
name="ok_btn"
width="128" />
<button
bottom="-5"
follows="bottom|left"