PageRenderTime 52ms CodeModel.GetById 20ms app.highlight 14ms RepoModel.GetById 16ms 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
  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
 27#ifndef LL_LLMULTIGESTURE_H
 28#define LL_LLMULTIGESTURE_H
 29
 30#include <set>
 31#include <string>
 32#include <vector>
 33
 34#include "lluuid.h"
 35#include "llframetimer.h"
 36
 37class LLDataPacker;
 38class LLGestureStep;
 39
 40class LLMultiGesture
 41{
 42public:
 43	LLMultiGesture();
 44	virtual ~LLMultiGesture();
 45
 46	// Maximum number of bytes this could hold once serialized.
 47	S32 getMaxSerialSize() const;
 48
 49	BOOL serialize(LLDataPacker& dp) const;
 50	BOOL deserialize(LLDataPacker& dp);
 51
 52	void dump();
 53
 54	void reset();
 55
 56	const std::string& getTrigger() const { return mTrigger; }
 57protected:
 58	LLMultiGesture(const LLMultiGesture& gest);
 59	const LLMultiGesture& operator=(const LLMultiGesture& rhs);
 60
 61public:
 62	KEY mKey;
 63	MASK mMask;
 64
 65	// This name can be empty if the inventory item is not around and
 66    // the gesture manager has not yet set the name
 67	std::string mName;
 68
 69	// String, like "/foo" or "hello" that makes it play
 70	std::string mTrigger;
 71
 72	// Replaces the trigger substring with this text
 73	std::string mReplaceText;
 74
 75	std::vector<LLGestureStep*> mSteps;
 76
 77	// Is the gesture currently playing?
 78	BOOL mPlaying;
 79
 80	// "instruction pointer" for steps
 81	S32 mCurrentStep;
 82
 83	// We're waiting for triggered animations to stop playing
 84	BOOL mWaitingAnimations;
 85
 86	// We're waiting a fixed amount of time
 87	BOOL mWaitingTimer;
 88
 89	// Waiting after the last step played for all animations to complete
 90	BOOL mWaitingAtEnd;
 91
 92	// Timer for waiting
 93	LLFrameTimer mWaitTimer;
 94
 95	void (*mDoneCallback)(LLMultiGesture* gesture, void* data);
 96	void* mCallbackData;
 97
 98	// Animations that we requested to start
 99	std::set<LLUUID> mRequestedAnimIDs;
100
101	// Once the animation starts playing (sim says to start playing)
102	// the ID is moved from mRequestedAnimIDs to here.
103	std::set<LLUUID> mPlayingAnimIDs;
104};
105
106
107// Order must match the library_list in floater_preview_gesture.xml!
108
109enum EStepType
110{
111	STEP_ANIMATION = 0,
112	STEP_SOUND = 1,
113	STEP_CHAT = 2,
114	STEP_WAIT = 3,
115
116	STEP_EOF = 4
117};
118
119
120class LLGestureStep
121{
122public:
123	LLGestureStep() {}
124	virtual ~LLGestureStep() {}
125
126	virtual EStepType getType() = 0;
127
128	// Return a user-readable label for this step
129	virtual std::vector<std::string> getLabel() const = 0;
130
131	virtual S32 getMaxSerialSize() const = 0;
132	virtual BOOL serialize(LLDataPacker& dp) const = 0;
133	virtual BOOL deserialize(LLDataPacker& dp) = 0;
134
135	virtual void dump() = 0;
136};
137
138
139// By default, animation steps start animations.
140// If the least significant bit is 1, it will stop animations.
141const U32 ANIM_FLAG_STOP = 0x01;
142
143class LLGestureStepAnimation : public LLGestureStep
144{
145public:
146	LLGestureStepAnimation();
147	virtual ~LLGestureStepAnimation();
148
149	virtual EStepType getType() { return STEP_ANIMATION; }
150
151	virtual std::vector<std::string> getLabel() const;
152
153	virtual S32 getMaxSerialSize() const;
154	virtual BOOL serialize(LLDataPacker& dp) const;
155	virtual BOOL deserialize(LLDataPacker& dp);
156
157	virtual void dump();
158
159public:
160	std::string mAnimName;
161	LLUUID mAnimAssetID;
162	U32 mFlags;
163};
164
165
166class LLGestureStepSound : public LLGestureStep
167{
168public:
169	LLGestureStepSound();
170	virtual ~LLGestureStepSound();
171
172	virtual EStepType getType() { return STEP_SOUND; }
173
174	virtual std::vector<std::string> getLabel() const;
175
176	virtual S32 getMaxSerialSize() const;
177	virtual BOOL serialize(LLDataPacker& dp) const;
178	virtual BOOL deserialize(LLDataPacker& dp);
179
180	virtual void dump();
181
182public:
183	std::string mSoundName;
184	LLUUID mSoundAssetID;
185	U32 mFlags;
186};
187
188
189class LLGestureStepChat : public LLGestureStep
190{
191public:
192	LLGestureStepChat();
193	virtual ~LLGestureStepChat();
194
195	virtual EStepType getType() { return STEP_CHAT; }
196
197	virtual std::vector<std::string> getLabel() const;
198
199	virtual S32 getMaxSerialSize() const;
200	virtual BOOL serialize(LLDataPacker& dp) const;
201	virtual BOOL deserialize(LLDataPacker& dp);
202
203	virtual void dump();
204
205public:
206	std::string mChatText;
207	U32 mFlags;
208};
209
210
211const U32 WAIT_FLAG_TIME		= 0x01;
212const U32 WAIT_FLAG_ALL_ANIM	= 0x02;
213
214class LLGestureStepWait : public LLGestureStep
215{
216public:
217	LLGestureStepWait();
218	virtual ~LLGestureStepWait();
219
220	virtual EStepType getType() { return STEP_WAIT; }
221
222	virtual std::vector<std::string> getLabel() const;
223
224	virtual S32 getMaxSerialSize() const;
225	virtual BOOL serialize(LLDataPacker& dp) const;
226	virtual BOOL deserialize(LLDataPacker& dp);
227
228	virtual void dump();
229
230public:
231	F32 mWaitSeconds;
232	U32 mFlags;
233};
234
235#endif