llmultigesture.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. * @file llmultigesture.h
  3. * @brief Gestures that are asset-based and can have multiple steps.
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewergpl$
  6. *
  7. * Copyright (c) 2004-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLMULTIGESTURE_H
  33. #define LL_LLMULTIGESTURE_H
  34. #include <set>
  35. #include <string>
  36. #include <vector>
  37. #include "llframetimer.h"
  38. #include "llpreprocessor.h"
  39. #include "lluuid.h"
  40. class LLDataPacker;
  41. class LLGestureStep;
  42. class LLMultiGesture
  43. {
  44. protected:
  45. LOG_CLASS(LLMultiGesture);
  46. public:
  47. LLMultiGesture();
  48. virtual ~LLMultiGesture();
  49. // Maximum number of bytes this could hold once serialized.
  50. S32 getMaxSerialSize() const;
  51. bool serialize(LLDataPacker& dp) const;
  52. bool deserialize(LLDataPacker& dp);
  53. void dump();
  54. void reset();
  55. LL_INLINE const std::string& getTrigger() const { return mTrigger; }
  56. protected:
  57. LLMultiGesture(const LLMultiGesture& gest);
  58. const LLMultiGesture& operator=(const LLMultiGesture& rhs);
  59. public:
  60. // name is stored at asset level
  61. // desc is stored at asset level
  62. KEY mKey;
  63. MASK mMask;
  64. // String, like "/foo" or "hello" that makes it play
  65. std::string mTrigger;
  66. // Replaces the trigger substring with this text
  67. std::string mReplaceText;
  68. std::vector<LLGestureStep*> mSteps;
  69. // Is the gesture currently playing?
  70. bool mPlaying;
  71. // We're waiting for triggered animations to stop playing
  72. bool mWaitingAnimations;
  73. // We're waiting a fixed amount of time
  74. bool mWaitingTimer;
  75. // Waiting after the last step played for all animations to complete
  76. bool mWaitingAtEnd;
  77. // "instruction pointer" for steps
  78. S32 mCurrentStep;
  79. // Timer for waiting
  80. LLFrameTimer mWaitTimer;
  81. void (*mDoneCallback)(LLMultiGesture* gesture, void* data);
  82. void* mCallbackData;
  83. // Animations that we requested to start
  84. uuid_list_t mRequestedAnimIDs;
  85. // Once the animation starts playing (sim says to start playing) the ID is
  86. // moved from mRequestedAnimIDs to here.
  87. uuid_list_t mPlayingAnimIDs;
  88. };
  89. // Order must match the library_list in floater_preview_gesture.xml !
  90. enum EStepType
  91. {
  92. STEP_ANIMATION = 0,
  93. STEP_SOUND = 1,
  94. STEP_CHAT = 2,
  95. STEP_WAIT = 3,
  96. STEP_EOF = 4
  97. };
  98. class LLGestureStep
  99. {
  100. protected:
  101. LOG_CLASS(LLGestureStep);
  102. public:
  103. LLGestureStep() = default;
  104. virtual ~LLGestureStep() = default;
  105. virtual EStepType getType() = 0;
  106. // Return a user-readable label for this step
  107. virtual std::string getLabel() const = 0;
  108. virtual S32 getMaxSerialSize() const = 0;
  109. virtual bool serialize(LLDataPacker& dp) const = 0;
  110. virtual bool deserialize(LLDataPacker& dp) = 0;
  111. virtual void dump() = 0;
  112. };
  113. // By default, animation steps start animations.
  114. // If the least significant bit is 1, it will stop animations.
  115. constexpr U32 ANIM_FLAG_STOP = 0x01;
  116. class LLGestureStepAnimation final : public LLGestureStep
  117. {
  118. protected:
  119. LOG_CLASS(LLGestureStepAnimation);
  120. public:
  121. LLGestureStepAnimation();
  122. LL_INLINE EStepType getType() override { return STEP_ANIMATION; }
  123. std::string getLabel() const override;
  124. S32 getMaxSerialSize() const override;
  125. bool serialize(LLDataPacker& dp) const override;
  126. bool deserialize(LLDataPacker& dp) override;
  127. void dump() override;
  128. public:
  129. std::string mAnimName;
  130. LLUUID mAnimAssetID;
  131. U32 mFlags;
  132. };
  133. class LLGestureStepSound final : public LLGestureStep
  134. {
  135. protected:
  136. LOG_CLASS(LLGestureStepSound);
  137. public:
  138. LLGestureStepSound();
  139. LL_INLINE EStepType getType() override { return STEP_SOUND; }
  140. std::string getLabel() const override;
  141. S32 getMaxSerialSize() const override;
  142. bool serialize(LLDataPacker& dp) const override;
  143. bool deserialize(LLDataPacker& dp) override;
  144. void dump() override;
  145. public:
  146. std::string mSoundName;
  147. LLUUID mSoundAssetID;
  148. U32 mFlags;
  149. };
  150. class LLGestureStepChat final : public LLGestureStep
  151. {
  152. protected:
  153. LOG_CLASS(LLGestureStepChat);
  154. public:
  155. LLGestureStepChat();
  156. LL_INLINE EStepType getType() override { return STEP_CHAT; }
  157. std::string getLabel() const override;
  158. S32 getMaxSerialSize() const override;
  159. bool serialize(LLDataPacker& dp) const override;
  160. bool deserialize(LLDataPacker& dp) override;
  161. void dump() override;
  162. public:
  163. std::string mChatText;
  164. U32 mFlags;
  165. };
  166. constexpr U32 WAIT_FLAG_TIME = 0x01;
  167. constexpr U32 WAIT_FLAG_ALL_ANIM = 0x02;
  168. class LLGestureStepWait final : public LLGestureStep
  169. {
  170. protected:
  171. LOG_CLASS(LLGestureStepWait);
  172. public:
  173. LLGestureStepWait();
  174. EStepType getType() override { return STEP_WAIT; }
  175. std::string getLabel() const override;
  176. S32 getMaxSerialSize() const override;
  177. bool serialize(LLDataPacker& dp) const override;
  178. bool deserialize(LLDataPacker& dp) override;
  179. void dump() override;
  180. public:
  181. F32 mWaitSeconds;
  182. U32 mFlags;
  183. };
  184. #endif