Gesture Optimization Pass 2
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
#include "lldatapacker.h"
|
||||
#include "llstl.h"
|
||||
|
||||
const S32 GESTURE_VERSION = 2;
|
||||
constexpr S32 GESTURE_VERSION = 2;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// LLMultiGesture
|
||||
@@ -48,10 +48,10 @@ LLMultiGesture::LLMultiGesture()
|
||||
mTrigger(),
|
||||
mReplaceText(),
|
||||
mSteps(),
|
||||
mPlaying(FALSE),
|
||||
mPlaying(false),
|
||||
mLocal(false),
|
||||
mCurrentStep(0),
|
||||
mDoneCallback(NULL)
|
||||
mDoneCallback(nullptr)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
@@ -63,13 +63,13 @@ LLMultiGesture::~LLMultiGesture()
|
||||
|
||||
void LLMultiGesture::reset()
|
||||
{
|
||||
mPlaying = FALSE;
|
||||
mPlaying = false;
|
||||
mLocal = false;
|
||||
mCurrentStep = 0;
|
||||
mWaitTimer.reset();
|
||||
mWaitingTimer = FALSE;
|
||||
mWaitingAnimations = FALSE;
|
||||
mWaitingAtEnd = FALSE;
|
||||
mWaitingTimer = false;
|
||||
mWaitingAnimations = false;
|
||||
mWaitingAtEnd = false;
|
||||
mRequestedAnimIDs.clear();
|
||||
mPlayingAnimIDs.clear();
|
||||
}
|
||||
@@ -88,10 +88,8 @@ S32 LLMultiGesture::getMaxSerialSize() const
|
||||
|
||||
max_size += 64; // step count S32
|
||||
|
||||
std::vector<LLGestureStep*>::const_iterator it;
|
||||
for (it = mSteps.begin(); it != mSteps.end(); ++it)
|
||||
for (const auto& step : mSteps)
|
||||
{
|
||||
LLGestureStep* step = *it;
|
||||
max_size += 64; // type S32
|
||||
max_size += step->getMaxSerialSize();
|
||||
}
|
||||
@@ -104,10 +102,8 @@ S32 LLMultiGesture::getMaxSerialSize() const
|
||||
|
||||
max_size += sizeof(S32); // step count
|
||||
|
||||
std::vector<LLGestureStep*>::const_iterator it;
|
||||
for (it = mSteps.begin(); it != mSteps.end(); ++it)
|
||||
for (const auto& step : mSteps)
|
||||
{
|
||||
LLGestureStep* step = *it;
|
||||
max_size += sizeof(S32); // type
|
||||
max_size += step->getMaxSerialSize();
|
||||
}
|
||||
@@ -116,7 +112,7 @@ S32 LLMultiGesture::getMaxSerialSize() const
|
||||
return max_size;
|
||||
}
|
||||
|
||||
BOOL LLMultiGesture::serialize(LLDataPacker& dp) const
|
||||
bool LLMultiGesture::serialize(LLDataPacker& dp) const
|
||||
{
|
||||
dp.packS32(GESTURE_VERSION, "version");
|
||||
dp.packU8(mKey, "key");
|
||||
@@ -126,22 +122,18 @@ BOOL LLMultiGesture::serialize(LLDataPacker& dp) const
|
||||
|
||||
S32 count = (S32)mSteps.size();
|
||||
dp.packS32(count, "step_count");
|
||||
S32 i;
|
||||
for (i = 0; i < count; ++i)
|
||||
for (const auto& step : mSteps)
|
||||
{
|
||||
LLGestureStep* step = mSteps[i];
|
||||
|
||||
dp.packS32(step->getType(), "step_type");
|
||||
BOOL ok = step->serialize(dp);
|
||||
if (!ok)
|
||||
if (!step->serialize(dp))
|
||||
{
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL LLMultiGesture::deserialize(LLDataPacker& dp)
|
||||
bool LLMultiGesture::deserialize(LLDataPacker& dp)
|
||||
{
|
||||
S32 version;
|
||||
dp.unpackS32(version, "version");
|
||||
@@ -150,15 +142,12 @@ BOOL LLMultiGesture::deserialize(LLDataPacker& dp)
|
||||
LL_WARNS() << "Bad LLMultiGesture version " << version
|
||||
<< " should be " << GESTURE_VERSION
|
||||
<< LL_ENDL;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
dp.unpackU8(mKey, "key");
|
||||
dp.unpackU32(mMask, "mask");
|
||||
|
||||
|
||||
dp.unpackString(mTrigger, "trigger");
|
||||
|
||||
dp.unpackString(mReplaceText, "replace");
|
||||
|
||||
S32 count;
|
||||
@@ -166,58 +155,31 @@ BOOL LLMultiGesture::deserialize(LLDataPacker& dp)
|
||||
if (count < 0)
|
||||
{
|
||||
LL_WARNS() << "Bad LLMultiGesture step count " << count << LL_ENDL;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
S32 i;
|
||||
for (i = 0; i < count; ++i)
|
||||
std::unique_ptr<LLGestureStep> step;
|
||||
for (S32 i = 0; i < count; ++i)
|
||||
{
|
||||
S32 type;
|
||||
dp.unpackS32(type, "step_type");
|
||||
|
||||
EStepType step_type = (EStepType)type;
|
||||
switch(step_type)
|
||||
switch((EStepType)type)
|
||||
{
|
||||
case STEP_ANIMATION:
|
||||
{
|
||||
std::unique_ptr<LLGestureStep> step(new LLGestureStepAnimation());
|
||||
BOOL ok = step->deserialize(dp);
|
||||
if (!ok) return FALSE;
|
||||
mSteps.push_back(step.release());
|
||||
break;
|
||||
}
|
||||
case STEP_SOUND:
|
||||
{
|
||||
std::unique_ptr<LLGestureStep> step(new LLGestureStepSound());
|
||||
BOOL ok = step->deserialize(dp);
|
||||
if (!ok) return FALSE;
|
||||
mSteps.push_back(step.release());
|
||||
break;
|
||||
}
|
||||
case STEP_CHAT:
|
||||
{
|
||||
std::unique_ptr<LLGestureStep> step(new LLGestureStepChat());
|
||||
BOOL ok = step->deserialize(dp);
|
||||
if (!ok) return FALSE;
|
||||
mSteps.push_back(step.release());
|
||||
break;
|
||||
}
|
||||
case STEP_WAIT:
|
||||
{
|
||||
std::unique_ptr<LLGestureStep> step(new LLGestureStepWait());
|
||||
BOOL ok = step->deserialize(dp);
|
||||
if (!ok) return FALSE;
|
||||
mSteps.push_back(step.release());
|
||||
break;
|
||||
}
|
||||
case STEP_ANIMATION: step.reset(new LLGestureStepAnimation); break;
|
||||
case STEP_SOUND: step.reset(new LLGestureStepSound); break;
|
||||
case STEP_CHAT: step.reset(new LLGestureStepChat); break;
|
||||
case STEP_WAIT: step.reset(new LLGestureStepWait); break;
|
||||
default:
|
||||
{
|
||||
LL_WARNS() << "Bad LLMultiGesture step type " << type << LL_ENDL;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!step->deserialize(dp)) return false;
|
||||
mSteps.push_back(step.release());
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void LLMultiGesture::dump()
|
||||
@@ -226,10 +188,8 @@ void LLMultiGesture::dump()
|
||||
<< " trigger " << mTrigger
|
||||
<< " replace " << mReplaceText
|
||||
<< LL_ENDL;
|
||||
U32 i;
|
||||
for (i = 0; i < mSteps.size(); ++i)
|
||||
for (const auto& step : mSteps)
|
||||
{
|
||||
LLGestureStep* step = mSteps[i];
|
||||
step->dump();
|
||||
}
|
||||
}
|
||||
@@ -264,21 +224,21 @@ S32 LLGestureStepAnimation::getMaxSerialSize() const
|
||||
return max_size;
|
||||
}
|
||||
|
||||
BOOL LLGestureStepAnimation::serialize(LLDataPacker& dp) const
|
||||
bool LLGestureStepAnimation::serialize(LLDataPacker& dp) const
|
||||
{
|
||||
dp.packString(mAnimName, "anim_name");
|
||||
dp.packUUID(mAnimAssetID, "asset_id");
|
||||
dp.packU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL LLGestureStepAnimation::deserialize(LLDataPacker& dp)
|
||||
bool LLGestureStepAnimation::deserialize(LLDataPacker& dp)
|
||||
{
|
||||
dp.unpackString(mAnimName, "anim_name");
|
||||
|
||||
// Apparently an earlier version of the gesture code added \r to the end
|
||||
// of the animation names. Get rid of it. JC
|
||||
if (!mAnimName.empty() && mAnimName[mAnimName.length() - 1] == '\r')
|
||||
if (!mAnimName.empty() && mAnimName.back() == '\r')
|
||||
{
|
||||
// chop the last character
|
||||
mAnimName.resize(mAnimName.length() - 1);
|
||||
@@ -286,29 +246,18 @@ BOOL LLGestureStepAnimation::deserialize(LLDataPacker& dp)
|
||||
|
||||
dp.unpackUUID(mAnimAssetID, "asset_id");
|
||||
dp.unpackU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
// *NOTE: result is translated in LLPreviewGesture::getLabel()
|
||||
std::vector<std::string> LLGestureStepAnimation::getLabel() const
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
|
||||
// std::string label;
|
||||
/* std::string label;
|
||||
if (mFlags & ANIM_FLAG_STOP)
|
||||
{
|
||||
strings.push_back( "AnimFlagStop");
|
||||
|
||||
// label = "Stop Animation: ";
|
||||
}
|
||||
label = "Stop Animation: ";
|
||||
else
|
||||
{
|
||||
strings.push_back( "AnimFlagStart");
|
||||
|
||||
// label = "Start Animation: ";
|
||||
}
|
||||
strings.push_back( mAnimName);
|
||||
// label += mAnimName;
|
||||
return strings;
|
||||
label = "Start Animation: ";
|
||||
label += mAnimName;*/
|
||||
return {mFlags & ANIM_FLAG_STOP ? "AnimFlagStop" : "AnimFlagStart", mAnimName};
|
||||
}
|
||||
|
||||
void LLGestureStepAnimation::dump()
|
||||
@@ -346,31 +295,28 @@ S32 LLGestureStepSound::getMaxSerialSize() const
|
||||
return max_size;
|
||||
}
|
||||
|
||||
BOOL LLGestureStepSound::serialize(LLDataPacker& dp) const
|
||||
bool LLGestureStepSound::serialize(LLDataPacker& dp) const
|
||||
{
|
||||
dp.packString(mSoundName, "sound_name");
|
||||
dp.packUUID(mSoundAssetID, "asset_id");
|
||||
dp.packU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL LLGestureStepSound::deserialize(LLDataPacker& dp)
|
||||
bool LLGestureStepSound::deserialize(LLDataPacker& dp)
|
||||
{
|
||||
dp.unpackString(mSoundName, "sound_name");
|
||||
|
||||
dp.unpackUUID(mSoundAssetID, "asset_id");
|
||||
dp.unpackU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
// *NOTE: result is translated in LLPreviewGesture::getLabel()
|
||||
std::vector<std::string> LLGestureStepSound::getLabel() const
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back( "Sound");
|
||||
strings.push_back( mSoundName);
|
||||
// std::string label("Sound: ");
|
||||
// label += mSoundName;
|
||||
return strings;
|
||||
return {"Sound", mSoundName};
|
||||
}
|
||||
|
||||
void LLGestureStepSound::dump()
|
||||
@@ -406,27 +352,23 @@ S32 LLGestureStepChat::getMaxSerialSize() const
|
||||
return max_size;
|
||||
}
|
||||
|
||||
BOOL LLGestureStepChat::serialize(LLDataPacker& dp) const
|
||||
bool LLGestureStepChat::serialize(LLDataPacker& dp) const
|
||||
{
|
||||
dp.packString(mChatText, "chat_text");
|
||||
dp.packU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL LLGestureStepChat::deserialize(LLDataPacker& dp)
|
||||
bool LLGestureStepChat::deserialize(LLDataPacker& dp)
|
||||
{
|
||||
dp.unpackString(mChatText, "chat_text");
|
||||
|
||||
dp.unpackU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
// *NOTE: result is translated in LLPreviewGesture::getLabel()
|
||||
std::vector<std::string> LLGestureStepChat::getLabel() const
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back("Chat");
|
||||
strings.push_back(mChatText);
|
||||
return strings;
|
||||
return {"Chat", mChatText};
|
||||
}
|
||||
|
||||
void LLGestureStepChat::dump()
|
||||
@@ -461,44 +403,26 @@ S32 LLGestureStepWait::getMaxSerialSize() const
|
||||
return max_size;
|
||||
}
|
||||
|
||||
BOOL LLGestureStepWait::serialize(LLDataPacker& dp) const
|
||||
bool LLGestureStepWait::serialize(LLDataPacker& dp) const
|
||||
{
|
||||
dp.packF32(mWaitSeconds, "wait_seconds");
|
||||
dp.packU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL LLGestureStepWait::deserialize(LLDataPacker& dp)
|
||||
bool LLGestureStepWait::deserialize(LLDataPacker& dp)
|
||||
{
|
||||
dp.unpackF32(mWaitSeconds, "wait_seconds");
|
||||
dp.unpackU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
// *NOTE: result is translated in LLPreviewGesture::getLabel()
|
||||
std::vector<std::string> LLGestureStepWait::getLabel() const
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back( "Wait" );
|
||||
|
||||
// std::string label("--- Wait: ");
|
||||
if (mFlags & WAIT_FLAG_TIME)
|
||||
{
|
||||
char buffer[64]; /* Flawfinder: ignore */
|
||||
snprintf(buffer, sizeof(buffer), "%.1f seconds", (double)mWaitSeconds); /* Flawfinder: ignore */
|
||||
strings.push_back(buffer);
|
||||
// label += buffer;
|
||||
}
|
||||
else if (mFlags & WAIT_FLAG_ALL_ANIM)
|
||||
{
|
||||
strings.push_back("until animations are done");
|
||||
// label += "until animations are done";
|
||||
}
|
||||
else
|
||||
{
|
||||
strings.push_back("");
|
||||
}
|
||||
|
||||
return strings;
|
||||
return {"Wait",
|
||||
mFlags & WAIT_FLAG_TIME ? llformat("%.1f seconds", mWaitSeconds)
|
||||
: mFlags & WAIT_FLAG_ALL_ANIM ? "until animations are done"
|
||||
: LLStringUtil::null};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#ifndef LL_LLMULTIGESTURE_H
|
||||
#define LL_LLMULTIGESTURE_H
|
||||
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -46,8 +46,8 @@ public:
|
||||
// Maximum number of bytes this could hold once serialized.
|
||||
S32 getMaxSerialSize() const;
|
||||
|
||||
BOOL serialize(LLDataPacker& dp) const;
|
||||
BOOL deserialize(LLDataPacker& dp);
|
||||
bool serialize(LLDataPacker& dp) const;
|
||||
bool deserialize(LLDataPacker& dp);
|
||||
|
||||
void dump();
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
std::vector<LLGestureStep*> mSteps;
|
||||
|
||||
// Is the gesture currently playing?
|
||||
BOOL mPlaying;
|
||||
bool mPlaying;
|
||||
|
||||
// Is the gesture to be played locally?
|
||||
bool mLocal;
|
||||
@@ -86,25 +86,25 @@ public:
|
||||
S32 mCurrentStep;
|
||||
|
||||
// We're waiting for triggered animations to stop playing
|
||||
BOOL mWaitingAnimations;
|
||||
bool mWaitingAnimations;
|
||||
|
||||
// We're waiting a fixed amount of time
|
||||
BOOL mWaitingTimer;
|
||||
bool mWaitingTimer;
|
||||
|
||||
// Waiting after the last step played for all animations to complete
|
||||
BOOL mWaitingAtEnd;
|
||||
bool mWaitingAtEnd;
|
||||
|
||||
// Timer for waiting
|
||||
LLFrameTimer mWaitTimer;
|
||||
|
||||
boost::function<void (LLMultiGesture*)> mDoneCallback;
|
||||
std::function<void (LLMultiGesture*)> mDoneCallback;
|
||||
|
||||
// Animations that we requested to start
|
||||
std::set<LLUUID> mRequestedAnimIDs;
|
||||
std::unordered_set<LLUUID> mRequestedAnimIDs;
|
||||
|
||||
// Once the animation starts playing (sim says to start playing)
|
||||
// the ID is moved from mRequestedAnimIDs to here.
|
||||
std::set<LLUUID> mPlayingAnimIDs;
|
||||
std::unordered_set<LLUUID> mPlayingAnimIDs;
|
||||
};
|
||||
|
||||
|
||||
@@ -127,14 +127,14 @@ public:
|
||||
LLGestureStep() {}
|
||||
virtual ~LLGestureStep() {}
|
||||
|
||||
virtual EStepType getType() = 0;
|
||||
virtual EStepType getType() const = 0;
|
||||
|
||||
// Return a user-readable label for this step
|
||||
virtual std::vector<std::string> getLabel() const = 0;
|
||||
|
||||
virtual S32 getMaxSerialSize() const = 0;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const = 0;
|
||||
virtual BOOL deserialize(LLDataPacker& dp) = 0;
|
||||
virtual bool serialize(LLDataPacker& dp) const = 0;
|
||||
virtual bool deserialize(LLDataPacker& dp) = 0;
|
||||
|
||||
virtual void dump() = 0;
|
||||
};
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
|
||||
// By default, animation steps start animations.
|
||||
// If the least significant bit is 1, it will stop animations.
|
||||
const U32 ANIM_FLAG_STOP = 0x01;
|
||||
constexpr U32 ANIM_FLAG_STOP = 0x01;
|
||||
|
||||
class LLGestureStepAnimation : public LLGestureStep
|
||||
{
|
||||
@@ -150,15 +150,15 @@ public:
|
||||
LLGestureStepAnimation();
|
||||
virtual ~LLGestureStepAnimation();
|
||||
|
||||
virtual EStepType getType() { return STEP_ANIMATION; }
|
||||
EStepType getType() const override { return STEP_ANIMATION; }
|
||||
|
||||
virtual std::vector<std::string> getLabel() const;
|
||||
std::vector<std::string> getLabel() const override;
|
||||
|
||||
virtual S32 getMaxSerialSize() const;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const;
|
||||
virtual BOOL deserialize(LLDataPacker& dp);
|
||||
S32 getMaxSerialSize() const override;
|
||||
bool serialize(LLDataPacker& dp) const override;
|
||||
bool deserialize(LLDataPacker& dp) override;
|
||||
|
||||
virtual void dump();
|
||||
void dump() override;
|
||||
|
||||
public:
|
||||
std::string mAnimName;
|
||||
@@ -173,15 +173,15 @@ public:
|
||||
LLGestureStepSound();
|
||||
virtual ~LLGestureStepSound();
|
||||
|
||||
virtual EStepType getType() { return STEP_SOUND; }
|
||||
EStepType getType() const override { return STEP_SOUND; }
|
||||
|
||||
virtual std::vector<std::string> getLabel() const;
|
||||
std::vector<std::string> getLabel() const override;
|
||||
|
||||
virtual S32 getMaxSerialSize() const;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const;
|
||||
virtual BOOL deserialize(LLDataPacker& dp);
|
||||
S32 getMaxSerialSize() const override;
|
||||
bool serialize(LLDataPacker& dp) const override;
|
||||
bool deserialize(LLDataPacker& dp) override;
|
||||
|
||||
virtual void dump();
|
||||
void dump() override;
|
||||
|
||||
public:
|
||||
std::string mSoundName;
|
||||
@@ -196,15 +196,15 @@ public:
|
||||
LLGestureStepChat();
|
||||
virtual ~LLGestureStepChat();
|
||||
|
||||
virtual EStepType getType() { return STEP_CHAT; }
|
||||
EStepType getType() const override { return STEP_CHAT; }
|
||||
|
||||
virtual std::vector<std::string> getLabel() const;
|
||||
std::vector<std::string> getLabel() const override;
|
||||
|
||||
virtual S32 getMaxSerialSize() const;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const;
|
||||
virtual BOOL deserialize(LLDataPacker& dp);
|
||||
S32 getMaxSerialSize() const override;
|
||||
bool serialize(LLDataPacker& dp) const override;
|
||||
bool deserialize(LLDataPacker& dp) override;
|
||||
|
||||
virtual void dump();
|
||||
void dump() override;
|
||||
|
||||
public:
|
||||
std::string mChatText;
|
||||
@@ -212,8 +212,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
const U32 WAIT_FLAG_TIME = 0x01;
|
||||
const U32 WAIT_FLAG_ALL_ANIM = 0x02;
|
||||
constexpr U32 WAIT_FLAG_TIME = 0x01;
|
||||
constexpr U32 WAIT_FLAG_ALL_ANIM = 0x02;
|
||||
|
||||
class LLGestureStepWait : public LLGestureStep
|
||||
{
|
||||
@@ -221,15 +221,15 @@ public:
|
||||
LLGestureStepWait();
|
||||
virtual ~LLGestureStepWait();
|
||||
|
||||
virtual EStepType getType() { return STEP_WAIT; }
|
||||
EStepType getType() const override { return STEP_WAIT; }
|
||||
|
||||
virtual std::vector<std::string> getLabel() const;
|
||||
std::vector<std::string> getLabel() const override;
|
||||
|
||||
virtual S32 getMaxSerialSize() const;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const;
|
||||
virtual BOOL deserialize(LLDataPacker& dp);
|
||||
S32 getMaxSerialSize() const override;
|
||||
bool serialize(LLDataPacker& dp) const override;
|
||||
bool deserialize(LLDataPacker& dp) override;
|
||||
|
||||
virtual void dump();
|
||||
void dump() override;
|
||||
|
||||
public:
|
||||
F32 mWaitSeconds;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,8 +27,9 @@
|
||||
#ifndef LL_LLGESTUREMGR_H
|
||||
#define LL_LLGESTUREMGR_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "llassetstorage.h" // LLAssetType
|
||||
@@ -53,10 +54,10 @@ class LLGestureMgr : public LLSingleton<LLGestureMgr>, public LLInventoryFetchIt
|
||||
{
|
||||
public:
|
||||
|
||||
typedef boost::function<void (LLMultiGesture* loaded_gesture)> gesture_loaded_callback_t;
|
||||
typedef std::function<void (LLMultiGesture* loaded_gesture)> gesture_loaded_callback_t;
|
||||
// Maps inventory item_id to gesture
|
||||
typedef std::map<LLUUID, LLMultiGesture*> item_map_t;
|
||||
typedef std::map<LLUUID, gesture_loaded_callback_t> callback_map_t;
|
||||
typedef std::unordered_map<LLUUID, LLMultiGesture*> item_map_t;
|
||||
typedef std::unordered_map<LLUUID, gesture_loaded_callback_t> callback_map_t;
|
||||
|
||||
LLGestureMgr();
|
||||
~LLGestureMgr();
|
||||
@@ -81,24 +82,24 @@ public:
|
||||
|
||||
// Load gesture into in-memory active form.
|
||||
// Can be called even if the inventory item isn't loaded yet.
|
||||
// inform_server TRUE will send message upstream to update database
|
||||
// inform_server true will send message upstream to update database
|
||||
// user_gesture_active table, which isn't necessary on login.
|
||||
// deactivate_similar will cause other gestures with the same trigger phrase
|
||||
// or keybinding to be deactivated.
|
||||
void activateGestureWithAsset(const LLUUID& item_id, const LLUUID& asset_id, BOOL inform_server, BOOL deactivate_similar);
|
||||
void activateGestureWithAsset(const LLUUID& item_id, const LLUUID& asset_id, bool inform_server, bool deactivate_similar);
|
||||
|
||||
// Takes gesture out of active list and deletes it.
|
||||
void deactivateGesture(const LLUUID& item_id);
|
||||
|
||||
// Deactivates all gestures that match either this trigger phrase,
|
||||
// or this hot key.
|
||||
void deactivateSimilarGestures(LLMultiGesture* gesture, const LLUUID& in_item_id);
|
||||
void deactivateSimilarGestures(const LLMultiGesture* gesture, const LLUUID& in_item_id);
|
||||
|
||||
BOOL isGestureActive(const LLUUID& item_id);
|
||||
bool isGestureActive(const LLUUID& item_id) const;
|
||||
|
||||
BOOL isGesturePlaying(const LLUUID& item_id);
|
||||
bool isGesturePlaying(const LLUUID& item_id) const;
|
||||
|
||||
BOOL isGesturePlaying(LLMultiGesture* gesture);
|
||||
bool isGesturePlaying(const LLMultiGesture* gesture) const;
|
||||
|
||||
const item_map_t& getActiveGestures() const { return mActive; }
|
||||
// Force a gesture to be played, for example, if it is being
|
||||
@@ -115,19 +116,19 @@ public:
|
||||
* Note:
|
||||
* Manager will call cb after gesture will be loaded and will remove cb automatically.
|
||||
*/
|
||||
void setGestureLoadedCallback(LLUUID inv_item_id, gesture_loaded_callback_t cb)
|
||||
void setGestureLoadedCallback(const LLUUID& inv_item_id, gesture_loaded_callback_t cb)
|
||||
{
|
||||
mCallbackMap[inv_item_id] = cb;
|
||||
}
|
||||
// Trigger the first gesture that matches this key.
|
||||
// Returns TRUE if it finds a gesture bound to that key.
|
||||
BOOL triggerGesture(KEY key, MASK mask);
|
||||
bool triggerGesture(KEY key, MASK mask);
|
||||
|
||||
// Trigger all gestures referenced as substrings in this string
|
||||
BOOL triggerAndReviseString(const std::string &str, std::string *revised_string = NULL);
|
||||
bool triggerAndReviseString(const std::string &str, std::string *revised_string = NULL);
|
||||
|
||||
// Does some gesture have this key bound?
|
||||
BOOL isKeyBound(KEY key, MASK mask);
|
||||
//bool isKeyBound(KEY key, MASK mask) const;
|
||||
|
||||
S32 getPlayingCount() const;
|
||||
|
||||
@@ -138,10 +139,10 @@ public:
|
||||
// Overriding so we can update active gesture names and notify observers
|
||||
void changed(U32 mask);
|
||||
|
||||
BOOL matchPrefix(const std::string& in_str, std::string* out_str);
|
||||
bool matchPrefix(const std::string& in_str, std::string* out_str) const;
|
||||
|
||||
// Copy item ids into the vector
|
||||
void getItemIDs(uuid_vec_t* ids);
|
||||
void getItemIDs(uuid_vec_t* ids) const;
|
||||
|
||||
protected:
|
||||
// Handle the processing of a single gesture
|
||||
@@ -172,7 +173,7 @@ protected:
|
||||
|
||||
private:
|
||||
// Active gestures.
|
||||
// NOTE: The gesture pointer CAN BE NULL. This means that
|
||||
// NOTE: The gesture pointer CAN BE a nullptr. This means that
|
||||
// there is a gesture with that item_id, but the asset data
|
||||
// is still on its way down from the server.
|
||||
item_map_t mActive;
|
||||
@@ -183,9 +184,9 @@ private:
|
||||
std::vector<LLGestureManagerObserver*> mObservers;
|
||||
callback_map_t mCallbackMap;
|
||||
std::vector<LLMultiGesture*> mPlaying;
|
||||
BOOL mValid;
|
||||
bool mValid;
|
||||
|
||||
std::set<LLUUID> mLoadingAssets;
|
||||
std::unordered_set<LLUUID> mLoadingAssets;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user