diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llcharacter/llgesture.h | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/linden/indra/llcharacter/llgesture.h b/linden/indra/llcharacter/llgesture.h new file mode 100644 index 0000000..5180be0 --- /dev/null +++ b/linden/indra/llcharacter/llgesture.h | |||
@@ -0,0 +1,115 @@ | |||
1 | /** | ||
2 | * @file llgesture.h | ||
3 | * @brief A gesture is a combination of a triggering chat phrase or | ||
4 | * key, a sound, an animation, and a chat string. | ||
5 | * | ||
6 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #ifndef LL_LLGESTURE_H | ||
30 | #define LL_LLGESTURE_H | ||
31 | |||
32 | #include "llanimationstates.h" | ||
33 | #include "lluuid.h" | ||
34 | #include "llstring.h" | ||
35 | #include "lldarray.h" | ||
36 | |||
37 | class LLGesture | ||
38 | { | ||
39 | public: | ||
40 | LLGesture(); | ||
41 | LLGesture(KEY key, MASK mask, const std::string &trigger, | ||
42 | const LLUUID &sound_item_id, const std::string &animation, | ||
43 | const std::string &output_string); | ||
44 | |||
45 | LLGesture(U8 **buffer, S32 max_size); // deserializes, advances buffer | ||
46 | LLGesture(const LLGesture &gesture); | ||
47 | const LLGesture &operator=(const LLGesture &rhs); | ||
48 | |||
49 | virtual ~LLGesture() {}; | ||
50 | |||
51 | // Accessors | ||
52 | KEY getKey() const { return mKey; } | ||
53 | MASK getMask() const { return mMask; } | ||
54 | const std::string& getTrigger() const { return mTrigger; } | ||
55 | const LLUUID& getSound() const { return mSoundItemID; } | ||
56 | const std::string& getAnimation() const { return mAnimation; } | ||
57 | const std::string& getOutputString() const { return mOutputString; } | ||
58 | |||
59 | // Triggers if a key/mask matches it | ||
60 | virtual BOOL trigger(KEY key, MASK mask); | ||
61 | |||
62 | // Triggers if case-insensitive substring matches (assumes string is lowercase) | ||
63 | virtual BOOL trigger(const LLString &string); | ||
64 | |||
65 | // non-endian-neutral serialization | ||
66 | U8 *serialize(U8 *buffer) const; | ||
67 | U8 *deserialize(U8 *buffer, S32 max_size); | ||
68 | static S32 getMaxSerialSize(); | ||
69 | |||
70 | protected: | ||
71 | KEY mKey; // usually a function key | ||
72 | MASK mMask; // usually MASK_NONE, or MASK_SHIFT | ||
73 | std::string mTrigger; // string, no whitespace allowed | ||
74 | std::string mTriggerLower; // lowercase version of mTrigger | ||
75 | LLUUID mSoundItemID; // ItemID of sound to play, LLUUID::null if none | ||
76 | std::string mAnimation; // canonical name of animation or face animation | ||
77 | std::string mOutputString; // string to say | ||
78 | |||
79 | static const S32 MAX_SERIAL_SIZE; | ||
80 | }; | ||
81 | |||
82 | class LLGestureList | ||
83 | { | ||
84 | public: | ||
85 | LLGestureList(); | ||
86 | virtual ~LLGestureList(); | ||
87 | |||
88 | // Triggers if a key/mask matches one in the list | ||
89 | BOOL trigger(KEY key, MASK mask); | ||
90 | |||
91 | // Triggers if substring matches and generates revised string. | ||
92 | BOOL triggerAndReviseString(const LLString &string, LLString* revised_string); | ||
93 | |||
94 | // Used for construction from UI | ||
95 | S32 count() const { return mList.count(); } | ||
96 | virtual LLGesture* get(S32 i) const { return mList.get(i); } | ||
97 | virtual void put(LLGesture* gesture) { mList.put( gesture ); } | ||
98 | void deleteAll(); | ||
99 | |||
100 | // non-endian-neutral serialization | ||
101 | U8 *serialize(U8 *buffer) const; | ||
102 | U8 *deserialize(U8 *buffer, S32 max_size); | ||
103 | S32 getMaxSerialSize(); | ||
104 | |||
105 | protected: | ||
106 | // overridden by child class to use local LLGesture implementation | ||
107 | virtual LLGesture *create_gesture(U8 **buffer, S32 max_size); | ||
108 | |||
109 | protected: | ||
110 | LLDynamicArray<LLGesture*> mList; | ||
111 | |||
112 | static const S32 SERIAL_HEADER_SIZE; | ||
113 | }; | ||
114 | |||
115 | #endif | ||