diff --git a/indra/newview/ao.cpp b/indra/newview/ao.cpp index 92c9c813e7..930c33dfef 100644 --- a/indra/newview/ao.cpp +++ b/indra/newview/ao.cpp @@ -282,6 +282,10 @@ bool FloaterAO::postBuild() mPreviousButtonSmall->setCommitCallback(boost::bind(&FloaterAO::onClickPrevious, this)); mNextButtonSmall->setCommitCallback(boost::bind(&FloaterAO::onClickNext, this)); +// Double click on animation in AO + mAnimationList->setDoubleClickCallback(boost::bind(&FloaterAO::onDoubleClick, this)); +// + updateSmart(); AOEngine::instance().setReloadCallback(boost::bind(&FloaterAO::updateList, this)); @@ -780,6 +784,34 @@ void FloaterAO::onClickNext() AOEngine::instance().cycle(AOEngine::CycleNext); } +// Double click on animation in AO +void FloaterAO::onDoubleClick() +{ + LLScrollListItem* item = mAnimationList->getFirstSelected(); + if (!item) + { + return; + } + LLUUID* animUUID = (LLUUID*)item->getUserdata(); + if (!animUUID) + { + return; + } + + // activate AO set if necessary + if (AOEngine::instance().getCurrentSet() != mSelectedSet) + { + // sync small set selector with main set selector + mSetSelectorSmall->selectNthItem(mSetSelector->getCurrentIndex()); + + LL_DEBUGS("AOEngine") << "Set activated: " << mSetSelector->getSelectedItemLabel() << LL_ENDL; + AOEngine::instance().selectSet(mSelectedSet); + } + + AOEngine::instance().playAnimation(*animUUID); +} +// + void FloaterAO::onClickMore() { LLRect fullSize = gSavedPerAccountSettings.getRect("floater_rect_animation_overrider_full"); diff --git a/indra/newview/ao.h b/indra/newview/ao.h index 1ef283d9c0..cadde5088c 100644 --- a/indra/newview/ao.h +++ b/indra/newview/ao.h @@ -91,6 +91,10 @@ class FloaterAO void onClickMore(); void onClickLess(); +// Double click on animation in AO + void onDoubleClick(); +// + void onAnimationChanged(const LLUUID& animation); void reloading(bool reload); diff --git a/indra/newview/aoengine.cpp b/indra/newview/aoengine.cpp index 62141ef422..ef6550ba0e 100644 --- a/indra/newview/aoengine.cpp +++ b/indra/newview/aoengine.cpp @@ -960,6 +960,112 @@ void AOEngine::cycle(eCycleMode cycleMode) } } +// Double click on animation in AO +void AOEngine::playAnimation(const LLUUID& animation) +{ + if (!mEnabled) + { + return; + } + + if (!mCurrentSet) + { + LL_DEBUGS("AOEngine") << "cycle without set." << LL_ENDL; + return; + } + + // do not cycle if we're sitting and sit-override is off + if (mLastMotion == ANIM_AGENT_SIT && !mCurrentSet->getSitOverride()) + { + return; + } + // do not cycle if we're standing and mouselook stand override is disabled while being in mouselook + else if (mLastMotion == ANIM_AGENT_STAND && mCurrentSet->getMouselookStandDisable() && mInMouselook) + { + return; + } + + AOSet::AOState* state = mCurrentSet->getStateByRemapID(mLastMotion); + if (!state) + { + LL_DEBUGS("AOEngine") << "cycle without state." << LL_ENDL; + return; + } + + if (!state->mAnimations.size()) + { + LL_DEBUGS("AOEngine") << "cycle without animations in state." << LL_ENDL; + return; + } + + LLViewerInventoryItem* item = gInventory.getItem(animation); + AOSet::AOAnimation anim; + anim.mName = item->LLInventoryItem::getName(); + anim.mInventoryUUID = item->getUUID(); + anim.mOriginalUUID = item->getLinkedUUID(); + anim.mAssetUUID = LLUUID::null; + + // if we can find the original animation already right here, save its asset ID, otherwise this will + // be tried again in AOSet::getAnimationForState() and/or AOEngine::cycle() + if (item->getLinkedItem()) + { + anim.mAssetUUID = item->getAssetUUID(); + } + + LLUUID newAnimation = anim.mAssetUUID; + LLUUID oldAnimation = state->mCurrentAnimationID; + + // don't do anything if the animation didn't change + if (newAnimation == oldAnimation) + { + return; + } + + mAnimationChangedSignal(LLUUID::null); + + // Searches for the index of the animation + U32 idx = -1; + for (U32 i = 0; i < state->mAnimations.size(); i++) + { + LLUUID* id = &(state->mAnimations[i].mAssetUUID); + if (*id == newAnimation) + { + idx = i; + break; + } + } + if (idx < 0) + { + idx = 0; + } + + state->mCurrentAnimation = idx; + state->mCurrentAnimationID = newAnimation; + if (newAnimation.notNull()) + { + LL_DEBUGS("AOEngine") << "requesting animation start for motion " << gAnimLibrary.animationName(mLastMotion) << ": " << newAnimation << LL_ENDL; + gAgent.sendAnimationRequest(newAnimation, ANIM_REQUEST_START); + mAnimationChangedSignal(state->mAnimations[state->mCurrentAnimation].mInventoryUUID); + } + else + { + LL_DEBUGS("AOEngine") << "overrider came back with NULL animation for motion " << gAnimLibrary.animationName(mLastMotion) << "." << LL_ENDL; + } + + if (oldAnimation.notNull()) + { + LL_DEBUGS("AOEngine") << "Cycling state " << state->mName << " - stopping animation " << oldAnimation << LL_ENDL; + gAgent.sendAnimationRequest(oldAnimation, ANIM_REQUEST_STOP); + gAgentAvatarp->LLCharacter::stopMotion(oldAnimation); + } +} + +const AOSet* AOEngine::getCurrentSet() const +{ + return mCurrentSet; +} +// + void AOEngine::updateSortOrder(AOSet::AOState* state) { for (U32 index = 0; index < state->mAnimations.size(); ++index) diff --git a/indra/newview/aoengine.h b/indra/newview/aoengine.h index a381d00dd3..184cb6c25d 100644 --- a/indra/newview/aoengine.h +++ b/indra/newview/aoengine.h @@ -123,6 +123,11 @@ class AOEngine void cycleTimeout(const AOSet* set); void cycle(eCycleMode cycleMode); +// Double click on animation in AO + void playAnimation(const LLUUID& animation); + const AOSet* getCurrentSet() const; +// + void inMouselook(bool mouselook); void selectSet(AOSet* set); AOSet* selectSetByName(const std::string& name);