llmultigesture.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLMULTIGESTURE_H
00033 #define LL_LLMULTIGESTURE_H
00034 
00035 #include <set>
00036 #include <string>
00037 #include <vector>
00038 
00039 #include "lluuid.h"
00040 #include "llframetimer.h"
00041 
00042 class LLDataPacker;
00043 class LLGestureStep;
00044 
00045 class LLMultiGesture
00046 {
00047 public:
00048         LLMultiGesture();
00049         virtual ~LLMultiGesture();
00050 
00051         // Maximum number of bytes this could hold once serialized.
00052         S32 getMaxSerialSize() const;
00053 
00054         BOOL serialize(LLDataPacker& dp) const;
00055         BOOL deserialize(LLDataPacker& dp);
00056 
00057         void dump();
00058 
00059         void reset();
00060 
00061         const std::string& getTrigger() const { return mTrigger; }
00062 protected:
00063         LLMultiGesture(const LLMultiGesture& gest);
00064         const LLMultiGesture& operator=(const LLMultiGesture& rhs);
00065 
00066 public:
00067         // name is stored at asset level
00068         // desc is stored at asset level
00069         KEY mKey;
00070         MASK mMask;
00071 
00072         // String, like "/foo" or "hello" that makes it play
00073         std::string mTrigger;
00074 
00075         // Replaces the trigger substring with this text
00076         std::string mReplaceText;
00077 
00078         std::vector<LLGestureStep*> mSteps;
00079 
00080         // Is the gesture currently playing?
00081         BOOL mPlaying;
00082 
00083         // "instruction pointer" for steps
00084         S32 mCurrentStep;
00085 
00086         // We're waiting for triggered animations to stop playing
00087         BOOL mWaitingAnimations;
00088 
00089         // We're waiting a fixed amount of time
00090         BOOL mWaitingTimer;
00091 
00092         // Waiting after the last step played for all animations to complete
00093         BOOL mWaitingAtEnd;
00094 
00095         // Timer for waiting
00096         LLFrameTimer mWaitTimer;
00097 
00098         void (*mDoneCallback)(LLMultiGesture* gesture, void* data);
00099         void* mCallbackData;
00100 
00101         // Animations that we requested to start
00102         std::set<LLUUID> mRequestedAnimIDs;
00103 
00104         // Once the animation starts playing (sim says to start playing)
00105         // the ID is moved from mRequestedAnimIDs to here.
00106         std::set<LLUUID> mPlayingAnimIDs;
00107 };
00108 
00109 
00110 enum EStepType
00111 {
00112         STEP_ANIMATION = 0,
00113         STEP_SOUND = 1,
00114         STEP_CHAT = 2,
00115         STEP_WAIT = 3,
00116 
00117         STEP_EOF = 4
00118 };
00119 
00120 
00121 class LLGestureStep
00122 {
00123 public:
00124         LLGestureStep() {}
00125         virtual ~LLGestureStep() {}
00126 
00127         virtual EStepType getType() = 0;
00128 
00129         // Return a user-readable label for this step
00130         virtual std::string getLabel() const = 0;
00131 
00132         virtual S32 getMaxSerialSize() const = 0;
00133         virtual BOOL serialize(LLDataPacker& dp) const = 0;
00134         virtual BOOL deserialize(LLDataPacker& dp) = 0;
00135 
00136         virtual void dump() = 0;
00137 };
00138 
00139 
00140 // By default, animation steps start animations.
00141 // If the least significant bit is 1, it will stop animations.
00142 const U32 ANIM_FLAG_STOP = 0x01;
00143 
00144 class LLGestureStepAnimation : public LLGestureStep
00145 {
00146 public:
00147         LLGestureStepAnimation();
00148         virtual ~LLGestureStepAnimation();
00149 
00150         virtual EStepType getType() { return STEP_ANIMATION; }
00151 
00152         virtual std::string getLabel() const;
00153 
00154         virtual S32 getMaxSerialSize() const;
00155         virtual BOOL serialize(LLDataPacker& dp) const;
00156         virtual BOOL deserialize(LLDataPacker& dp);
00157 
00158         virtual void dump();
00159 
00160 public:
00161         std::string mAnimName;
00162         LLUUID mAnimAssetID;
00163         U32 mFlags;
00164 };
00165 
00166 
00167 class LLGestureStepSound : public LLGestureStep
00168 {
00169 public:
00170         LLGestureStepSound();
00171         virtual ~LLGestureStepSound();
00172 
00173         virtual EStepType getType() { return STEP_SOUND; }
00174 
00175         virtual std::string getLabel() const;
00176 
00177         virtual S32 getMaxSerialSize() const;
00178         virtual BOOL serialize(LLDataPacker& dp) const;
00179         virtual BOOL deserialize(LLDataPacker& dp);
00180 
00181         virtual void dump();
00182 
00183 public:
00184         std::string mSoundName;
00185         LLUUID mSoundAssetID;
00186         U32 mFlags;
00187 };
00188 
00189 
00190 class LLGestureStepChat : public LLGestureStep
00191 {
00192 public:
00193         LLGestureStepChat();
00194         virtual ~LLGestureStepChat();
00195 
00196         virtual EStepType getType() { return STEP_CHAT; }
00197 
00198         virtual std::string getLabel() const;
00199 
00200         virtual S32 getMaxSerialSize() const;
00201         virtual BOOL serialize(LLDataPacker& dp) const;
00202         virtual BOOL deserialize(LLDataPacker& dp);
00203 
00204         virtual void dump();
00205 
00206 public:
00207         std::string mChatText;
00208         U32 mFlags;
00209 };
00210 
00211 
00212 const U32 WAIT_FLAG_TIME                = 0x01;
00213 const U32 WAIT_FLAG_ALL_ANIM    = 0x02;
00214 
00215 class LLGestureStepWait : public LLGestureStep
00216 {
00217 public:
00218         LLGestureStepWait();
00219         virtual ~LLGestureStepWait();
00220 
00221         virtual EStepType getType() { return STEP_WAIT; }
00222 
00223         virtual std::string getLabel() const;
00224 
00225         virtual S32 getMaxSerialSize() const;
00226         virtual BOOL serialize(LLDataPacker& dp) const;
00227         virtual BOOL deserialize(LLDataPacker& dp);
00228 
00229         virtual void dump();
00230 
00231 public:
00232         F32 mWaitSeconds;
00233         U32 mFlags;
00234 };
00235 
00236 #endif

Generated on Thu Jul 1 06:08:54 2010 for Second Life Viewer by  doxygen 1.4.7