PageRenderTime 40ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llcharacter/llmultigesture.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 235 lines | 127 code | 65 blank | 43 comment | 0 complexity | 928aa954e7a024c91010429384af17df MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llmultigesture.h
  3. * @brief Gestures that are asset-based and can have multiple steps.
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLMULTIGESTURE_H
  27. #define LL_LLMULTIGESTURE_H
  28. #include <set>
  29. #include <string>
  30. #include <vector>
  31. #include "lluuid.h"
  32. #include "llframetimer.h"
  33. class LLDataPacker;
  34. class LLGestureStep;
  35. class LLMultiGesture
  36. {
  37. public:
  38. LLMultiGesture();
  39. virtual ~LLMultiGesture();
  40. // Maximum number of bytes this could hold once serialized.
  41. S32 getMaxSerialSize() const;
  42. BOOL serialize(LLDataPacker& dp) const;
  43. BOOL deserialize(LLDataPacker& dp);
  44. void dump();
  45. void reset();
  46. const std::string& getTrigger() const { return mTrigger; }
  47. protected:
  48. LLMultiGesture(const LLMultiGesture& gest);
  49. const LLMultiGesture& operator=(const LLMultiGesture& rhs);
  50. public:
  51. KEY mKey;
  52. MASK mMask;
  53. // This name can be empty if the inventory item is not around and
  54. // the gesture manager has not yet set the name
  55. std::string mName;
  56. // String, like "/foo" or "hello" that makes it play
  57. std::string mTrigger;
  58. // Replaces the trigger substring with this text
  59. std::string mReplaceText;
  60. std::vector<LLGestureStep*> mSteps;
  61. // Is the gesture currently playing?
  62. BOOL mPlaying;
  63. // "instruction pointer" for steps
  64. S32 mCurrentStep;
  65. // We're waiting for triggered animations to stop playing
  66. BOOL mWaitingAnimations;
  67. // We're waiting a fixed amount of time
  68. BOOL mWaitingTimer;
  69. // Waiting after the last step played for all animations to complete
  70. BOOL mWaitingAtEnd;
  71. // Timer for waiting
  72. LLFrameTimer mWaitTimer;
  73. void (*mDoneCallback)(LLMultiGesture* gesture, void* data);
  74. void* mCallbackData;
  75. // Animations that we requested to start
  76. std::set<LLUUID> mRequestedAnimIDs;
  77. // Once the animation starts playing (sim says to start playing)
  78. // the ID is moved from mRequestedAnimIDs to here.
  79. std::set<LLUUID> mPlayingAnimIDs;
  80. };
  81. // Order must match the library_list in floater_preview_gesture.xml!
  82. enum EStepType
  83. {
  84. STEP_ANIMATION = 0,
  85. STEP_SOUND = 1,
  86. STEP_CHAT = 2,
  87. STEP_WAIT = 3,
  88. STEP_EOF = 4
  89. };
  90. class LLGestureStep
  91. {
  92. public:
  93. LLGestureStep() {}
  94. virtual ~LLGestureStep() {}
  95. virtual EStepType getType() = 0;
  96. // Return a user-readable label for this step
  97. virtual std::vector<std::string> getLabel() const = 0;
  98. virtual S32 getMaxSerialSize() const = 0;
  99. virtual BOOL serialize(LLDataPacker& dp) const = 0;
  100. virtual BOOL deserialize(LLDataPacker& dp) = 0;
  101. virtual void dump() = 0;
  102. };
  103. // By default, animation steps start animations.
  104. // If the least significant bit is 1, it will stop animations.
  105. const U32 ANIM_FLAG_STOP = 0x01;
  106. class LLGestureStepAnimation : public LLGestureStep
  107. {
  108. public:
  109. LLGestureStepAnimation();
  110. virtual ~LLGestureStepAnimation();
  111. virtual EStepType getType() { return STEP_ANIMATION; }
  112. virtual std::vector<std::string> getLabel() const;
  113. virtual S32 getMaxSerialSize() const;
  114. virtual BOOL serialize(LLDataPacker& dp) const;
  115. virtual BOOL deserialize(LLDataPacker& dp);
  116. virtual void dump();
  117. public:
  118. std::string mAnimName;
  119. LLUUID mAnimAssetID;
  120. U32 mFlags;
  121. };
  122. class LLGestureStepSound : public LLGestureStep
  123. {
  124. public:
  125. LLGestureStepSound();
  126. virtual ~LLGestureStepSound();
  127. virtual EStepType getType() { return STEP_SOUND; }
  128. virtual std::vector<std::string> getLabel() const;
  129. virtual S32 getMaxSerialSize() const;
  130. virtual BOOL serialize(LLDataPacker& dp) const;
  131. virtual BOOL deserialize(LLDataPacker& dp);
  132. virtual void dump();
  133. public:
  134. std::string mSoundName;
  135. LLUUID mSoundAssetID;
  136. U32 mFlags;
  137. };
  138. class LLGestureStepChat : public LLGestureStep
  139. {
  140. public:
  141. LLGestureStepChat();
  142. virtual ~LLGestureStepChat();
  143. virtual EStepType getType() { return STEP_CHAT; }
  144. virtual std::vector<std::string> getLabel() const;
  145. virtual S32 getMaxSerialSize() const;
  146. virtual BOOL serialize(LLDataPacker& dp) const;
  147. virtual BOOL deserialize(LLDataPacker& dp);
  148. virtual void dump();
  149. public:
  150. std::string mChatText;
  151. U32 mFlags;
  152. };
  153. const U32 WAIT_FLAG_TIME = 0x01;
  154. const U32 WAIT_FLAG_ALL_ANIM = 0x02;
  155. class LLGestureStepWait : public LLGestureStep
  156. {
  157. public:
  158. LLGestureStepWait();
  159. virtual ~LLGestureStepWait();
  160. virtual EStepType getType() { return STEP_WAIT; }
  161. virtual std::vector<std::string> getLabel() const;
  162. virtual S32 getMaxSerialSize() const;
  163. virtual BOOL serialize(LLDataPacker& dp) const;
  164. virtual BOOL deserialize(LLDataPacker& dp);
  165. virtual void dump();
  166. public:
  167. F32 mWaitSeconds;
  168. U32 mFlags;
  169. };
  170. #endif