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"     
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         
00063         void update();
00064 
00065         
00066         
00067         
00068         void activateGesture(const LLUUID& item_id);
00069 
00070         
00071         void activateGestures(LLViewerInventoryItem::item_array_t& items);
00072 
00073         
00074         
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         
00079         
00080         
00081         
00082         
00083         
00084         void activateGestureWithAsset(const LLUUID& item_id, const LLUUID& asset_id, BOOL inform_server, BOOL deactivate_similar);
00085 
00086         
00087         void deactivateGesture(const LLUUID& item_id);
00088 
00089         
00090         
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         
00098         
00099         void playGesture(LLMultiGesture* gesture);
00100         void playGesture(const LLUUID& item_id);
00101 
00102         
00103         
00104         void stopGesture(LLMultiGesture* gesture);
00105         void stopGesture(const LLUUID& item_id);
00106 
00107         
00108         
00109         BOOL triggerGesture(KEY key, MASK mask);
00110 
00111         
00112         BOOL triggerAndReviseString(const std::string &str, std::string *revised_string = NULL);
00113 
00114         
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         
00126         void getItemIDs(std::vector<LLUUID>* ids);
00127 
00128 protected:
00129         
00130         void stepGesture(LLMultiGesture* gesture);
00131 
00132         
00133         void runStep(LLMultiGesture* gesture, LLGestureStep* step);
00134 
00135         
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         
00146         typedef std::map<LLUUID, LLMultiGesture*> item_map_t;
00147 
00148         
00149         
00150         
00151         
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