123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- /**
- * @file llgesturemgr.h
- * @brief Manager for playing gestures on the viewer
- *
- * $LicenseInfo:firstyear=2004&license=viewergpl$
- *
- * Copyright (c) 2004-2009, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #ifndef LL_LLGESTUREMGR_H
- #define LL_LLGESTUREMGR_H
- #include "llassetstorage.h" // LLAssetType
- #include "hbfastmap.h"
- #include "llviewerinventory.h"
- class LLMultiGesture;
- class LLGestureStep;
- class LLUUID;
- class LLGestureManagerObserver
- {
- public:
- virtual ~LLGestureManagerObserver() {}
- virtual void changed() = 0;
- };
- class LLGestureManager
- {
- protected:
- LOG_CLASS(LLGestureManager);
- public:
- LLGestureManager();
- ~LLGestureManager();
- // Loads and activates gestures on login
- void load(const LLSD& gestures);
- // Call once per frame to manage gestures
- void update();
- // Loads a gesture out of inventory into the in-memory active form. Note
- // that the inventory item must exist, so we can look up the asset id.
- void activateGesture(const LLUUID& item_id);
- // Activate a list of gestures
- void activateGestures(LLViewerInventoryItem::item_array_t& items);
- // If you change a gesture, you need to build a new multigesture
- // and call this method.
- void replaceGesture(const LLUUID& item_id,
- LLMultiGesture* new_gesturep,
- const LLUUID& asset_id);
- void replaceGesture(const LLUUID& item_id, const LLUUID& asset_id);
- // Load gesture into in-memory active form. Can be called even if the
- // inventory item isn't loaded yet. inform_server true will send message
- // upstream to update database user_gesture_active table, which isn't
- // necessary on login. deactivate_similar will cause other gestures with
- // the same trigger phrase or keybinding to be deactivated.
- void activateGestureWithAsset(const LLUUID& item_id,
- const LLUUID& asset_id, bool inform_server,
- bool deactivate_similar);
- // Takes gesture out of active list and deletes it.
- void deactivateGesture(const LLUUID& item_id);
- // Deactivates all gestures that match either this trigger phrase or this
- // hot key.
- void deactivateSimilarGestures(LLMultiGesture* gesture,
- const LLUUID& in_item_id);
- bool isGestureActive(const LLUUID& item_id);
- bool isGesturePlaying(const LLUUID& item_id);
- // Forces a gesture to be played, for example, if it is being previewed.
- void playGesture(LLMultiGesture* gesturep);
- void playGesture(const LLUUID& item_id);
- // Stops all requested or playing anims for this gesture. Also removes from
- // playing list.
- void stopGesture(LLMultiGesture* gesturep);
- void stopGesture(const LLUUID& item_id);
- // Trigger the first gesture that matches this key.
- // Returns true if it finds a gesture bound to that key.
- bool triggerGesture(KEY key, MASK mask);
- // Triggers all gestures referenced as substrings in this string
- bool triggerAndReviseString(const std::string& str,
- std::string* revised_string = NULL);
- S32 getPlayingCount() const;
- void addObserver(LLGestureManagerObserver* observer);
- void removeObserver(LLGestureManagerObserver* observer);
- void notifyObservers();
- bool matchPrefix(const std::string& in_str, std::string* out_str);
- // Copy item ids into the vector
- void getItemIDs(uuid_vec_t* ids);
- static void notifyLoadFailed(const LLUUID& item_id, S32 status);
- protected:
- // Handle the processing of a single gesture
- void stepGesture(LLMultiGesture* gesturep);
- // Do a single step in a gesture
- void runStep(LLMultiGesture* gesturep, LLGestureStep* step);
- // Used by loadGesture
- static void onLoadComplete(const LLUUID& asset_uuid,
- LLAssetType::EType type, void* user_data,
- S32 status, LLExtStat);
- public:
- std::vector<LLMultiGesture*> mPlaying;
- // Maps inventory item_id to gesture
- typedef fast_hmap<LLUUID, LLMultiGesture*> item_map_t;
- // Active gestures. NOTE: The gesture pointer CAN BE NULL. This means that
- // there is a gesture with that item_id, but the asset data is still on its
- // way down from the server.
- item_map_t mActive;
- std::vector<LLGestureManagerObserver*> mObservers;
- std::string mDeactivateSimilarNames;
- S32 mLoadingCount;
- bool mValid;
- };
- extern LLGestureManager gGestureManager;
- #endif
|