PageRenderTime 46ms CodeModel.GetById 23ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLGESTURE_H
  28. #define LL_LLGESTURE_H
  29. #include "llanimationstates.h"
  30. #include "lluuid.h"
  31. #include "llstring.h"
  32. #include "lldarray.h"
  33. class LLGesture
  34. {
  35. public:
  36. LLGesture();
  37. LLGesture(KEY key, MASK mask, const std::string &trigger,
  38. const LLUUID &sound_item_id, const std::string &animation,
  39. const std::string &output_string);
  40. LLGesture(U8 **buffer, S32 max_size); // deserializes, advances buffer
  41. LLGesture(const LLGesture &gesture);
  42. const LLGesture &operator=(const LLGesture &rhs);
  43. virtual ~LLGesture() {};
  44. // Accessors
  45. KEY getKey() const { return mKey; }
  46. MASK getMask() const { return mMask; }
  47. const std::string& getTrigger() const { return mTrigger; }
  48. const LLUUID& getSound() const { return mSoundItemID; }
  49. const std::string& getAnimation() const { return mAnimation; }
  50. const std::string& getOutputString() const { return mOutputString; }
  51. // Triggers if a key/mask matches it
  52. virtual BOOL trigger(KEY key, MASK mask);
  53. // Triggers if case-insensitive substring matches (assumes string is lowercase)
  54. virtual BOOL trigger(const std::string &string);
  55. // non-endian-neutral serialization
  56. U8 *serialize(U8 *buffer) const;
  57. U8 *deserialize(U8 *buffer, S32 max_size);
  58. static S32 getMaxSerialSize();
  59. protected:
  60. KEY mKey; // usually a function key
  61. MASK mMask; // usually MASK_NONE, or MASK_SHIFT
  62. std::string mTrigger; // string, no whitespace allowed
  63. std::string mTriggerLower; // lowercase version of mTrigger
  64. LLUUID mSoundItemID; // ItemID of sound to play, LLUUID::null if none
  65. std::string mAnimation; // canonical name of animation or face animation
  66. std::string mOutputString; // string to say
  67. static const S32 MAX_SERIAL_SIZE;
  68. };
  69. class LLGestureList
  70. {
  71. public:
  72. LLGestureList();
  73. virtual ~LLGestureList();
  74. // Triggers if a key/mask matches one in the list
  75. BOOL trigger(KEY key, MASK mask);
  76. // Triggers if substring matches and generates revised string.
  77. BOOL triggerAndReviseString(const std::string &string, std::string* revised_string);
  78. // Used for construction from UI
  79. S32 count() const { return mList.count(); }
  80. virtual LLGesture* get(S32 i) const { return mList.get(i); }
  81. virtual void put(LLGesture* gesture) { mList.put( gesture ); }
  82. void deleteAll();
  83. // non-endian-neutral serialization
  84. U8 *serialize(U8 *buffer) const;
  85. U8 *deserialize(U8 *buffer, S32 max_size);
  86. S32 getMaxSerialSize();
  87. protected:
  88. // overridden by child class to use local LLGesture implementation
  89. virtual LLGesture *create_gesture(U8 **buffer, S32 max_size);
  90. protected:
  91. LLDynamicArray<LLGesture*> mList;
  92. static const S32 SERIAL_HEADER_SIZE;
  93. };
  94. #endif