PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcharacter/llgesture.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 114 lines | 59 code | 20 blank | 35 comment | 0 complexity | 2902a1fcd70a2d84aed9fecfc890710c MD5 | raw file
  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 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#ifndef LL_LLGESTURE_H
 29#define LL_LLGESTURE_H
 30
 31#include "llanimationstates.h"
 32#include "lluuid.h"
 33#include "llstring.h"
 34#include "lldarray.h"
 35
 36class LLGesture
 37{
 38public:
 39	LLGesture();
 40	LLGesture(KEY key, MASK mask, const std::string &trigger, 
 41		const LLUUID &sound_item_id, const std::string &animation, 
 42		const std::string &output_string);
 43
 44	LLGesture(U8 **buffer, S32 max_size); // deserializes, advances buffer
 45	LLGesture(const LLGesture &gesture);
 46	const LLGesture &operator=(const LLGesture &rhs);
 47
 48	virtual ~LLGesture() {};
 49
 50	// Accessors
 51	KEY					getKey() const			{ return mKey; }
 52	MASK				getMask() const			{ return mMask; }
 53	const std::string&	getTrigger() const		{ return mTrigger; }
 54	const LLUUID&		getSound() const		{ return mSoundItemID; }
 55	const std::string&	getAnimation() const	{ return mAnimation; }
 56	const std::string&	getOutputString() const	{ return mOutputString; }
 57
 58	// Triggers if a key/mask matches it
 59	virtual BOOL trigger(KEY key, MASK mask);
 60
 61	// Triggers if case-insensitive substring matches (assumes string is lowercase)
 62	virtual BOOL trigger(const std::string &string);
 63
 64	// non-endian-neutral serialization
 65	U8 *serialize(U8 *buffer) const;
 66	U8 *deserialize(U8 *buffer, S32 max_size);
 67	static S32 getMaxSerialSize();
 68
 69protected:
 70	KEY					mKey;			// usually a function key
 71	MASK				mMask;			// usually MASK_NONE, or MASK_SHIFT
 72	std::string		mTrigger;		// string, no whitespace allowed
 73	std::string		mTriggerLower;	// lowercase version of mTrigger
 74	LLUUID				mSoundItemID;	// ItemID of sound to play, LLUUID::null if none
 75	std::string			mAnimation;		// canonical name of animation or face animation
 76	std::string		mOutputString;	// string to say
 77
 78	static const S32	MAX_SERIAL_SIZE;
 79};
 80
 81class LLGestureList
 82{
 83public:
 84	LLGestureList();
 85	virtual ~LLGestureList();
 86
 87	// Triggers if a key/mask matches one in the list
 88	BOOL trigger(KEY key, MASK mask);
 89
 90	// Triggers if substring matches and generates revised string.
 91	BOOL triggerAndReviseString(const std::string &string, std::string* revised_string);
 92
 93	// Used for construction from UI
 94	S32 count() const						{ return mList.count(); }
 95	virtual LLGesture* get(S32 i) const		{ return mList.get(i); }
 96	virtual void put(LLGesture* gesture)	{ mList.put( gesture ); }
 97	void deleteAll();
 98
 99	// non-endian-neutral serialization
100	U8 *serialize(U8 *buffer) const;
101	U8 *deserialize(U8 *buffer, S32 max_size);
102	S32 getMaxSerialSize();
103
104protected:
105	// overridden by child class to use local LLGesture implementation
106	virtual LLGesture *create_gesture(U8 **buffer, S32 max_size);
107
108protected:
109	LLDynamicArray<LLGesture*>	mList;
110
111	static const S32	SERIAL_HEADER_SIZE;
112};
113
114#endif