llgesturemgr.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLGESTUREMGR_H
00033 #define LL_LLGESTUREMGR_H
00034 
00035 #include <map>
00036 #include <string>
00037 #include <vector>
00038 
00039 #include "llassetstorage.h"     // LLAssetType
00040 #include "llviewerinventory.h"
00041 
00042 class LLMultiGesture;
00043 class LLGestureStep;
00044 class LLUUID;
00045 class LLVFS;
00046 
00047 class LLGestureManagerObserver
00048 {
00049 public:
00050         virtual ~LLGestureManagerObserver() { };
00051         virtual void changed() = 0;
00052 };
00053 
00054 class LLGestureManager
00055 {
00056 public:
00057         LLGestureManager();
00058         ~LLGestureManager();
00059 
00060         void init();
00061 
00062         // Call once per frame to manage gestures
00063         void update();
00064 
00065         // Loads a gesture out of inventory into the in-memory active form
00066         // Note that the inventory item must exist, so we can look up the 
00067         // asset id.
00068         void activateGesture(const LLUUID& item_id);
00069 
00070         // Activate a list of gestures
00071         void activateGestures(LLViewerInventoryItem::item_array_t& items);
00072 
00073         // If you change a gesture, you need to build a new multigesture
00074         // and call this method.
00075         void replaceGesture(const LLUUID& item_id, LLMultiGesture* new_gesture, const LLUUID& asset_id);
00076         void replaceGesture(const LLUUID& item_id, const LLUUID& asset_id);
00077 
00078         // Load gesture into in-memory active form.
00079         // Can be called even if the inventory item isn't loaded yet.
00080         // inform_server TRUE will send message upstream to update database
00081         // user_gesture_active table, which isn't necessary on login.
00082         // deactivate_similar will cause other gestures with the same trigger phrase
00083         // or keybinding to be deactivated.
00084         void activateGestureWithAsset(const LLUUID& item_id, const LLUUID& asset_id, BOOL inform_server, BOOL deactivate_similar);
00085 
00086         // Takes gesture out of active list and deletes it.
00087         void deactivateGesture(const LLUUID& item_id);
00088 
00089         // Deactivates all gestures that match either this trigger phrase,
00090         // or this hot key.
00091         void deactivateSimilarGestures(LLMultiGesture* gesture, const LLUUID& in_item_id);
00092 
00093         BOOL isGestureActive(const LLUUID& item_id);
00094 
00095         BOOL isGesturePlaying(const LLUUID& item_id);
00096 
00097         // Force a gesture to be played, for example, if it is being
00098         // previewed.
00099         void playGesture(LLMultiGesture* gesture);
00100         void playGesture(const LLUUID& item_id);
00101 
00102         // Stop all requested or playing anims for this gesture
00103         // Also remove from playing list
00104         void stopGesture(LLMultiGesture* gesture);
00105         void stopGesture(const LLUUID& item_id);
00106 
00107         // Trigger the first gesture that matches this key.
00108         // Returns TRUE if it finds a gesture bound to that key.
00109         BOOL triggerGesture(KEY key, MASK mask);
00110 
00111         // Trigger all gestures referenced as substrings in this string
00112         BOOL triggerAndReviseString(const std::string &str, std::string *revised_string = NULL);
00113 
00114         // Does some gesture have this key bound?
00115         BOOL isKeyBound(KEY key, MASK mask);
00116 
00117         S32 getPlayingCount() const;
00118 
00119         void addObserver(LLGestureManagerObserver* observer);
00120         void removeObserver(LLGestureManagerObserver* observer);
00121         void notifyObservers();
00122 
00123         BOOL matchPrefix(const std::string& in_str, std::string* out_str);
00124 
00125         // Copy item ids into the vector
00126         void getItemIDs(std::vector<LLUUID>* ids);
00127 
00128 protected:
00129         // Handle the processing of a single gesture
00130         void stepGesture(LLMultiGesture* gesture);
00131 
00132         // Do a single step in a gesture
00133         void runStep(LLMultiGesture* gesture, LLGestureStep* step);
00134 
00135         // Used by loadGesture
00136         static void onLoadComplete(LLVFS *vfs,
00137                                                    const LLUUID& asset_uuid,
00138                                                    LLAssetType::EType type,
00139                                                    void* user_data, S32 status, LLExtStat ext_status);
00140 
00141 public:
00142         BOOL mValid;
00143         std::vector<LLMultiGesture*> mPlaying;
00144 
00145         // Maps inventory item_id to gesture
00146         typedef std::map<LLUUID, LLMultiGesture*> item_map_t;
00147 
00148         // Active gestures.
00149         // NOTE: The gesture pointer CAN BE NULL.  This means that
00150         // there is a gesture with that item_id, but the asset data
00151         // is still on its way down from the server.
00152         item_map_t mActive;
00153 
00154         S32 mLoadingCount;
00155         std::string mDeactivateSimilarNames;
00156 
00157         std::vector<LLGestureManagerObserver*> mObservers;
00158 };
00159 
00160 extern LLGestureManager gGestureManager;
00161 
00162 #endif

Generated on Thu Jul 1 06:08:39 2010 for Second Life Viewer by  doxygen 1.4.7