diff options
Diffstat (limited to 'indra/newview/llgesturemgr.cpp')
| -rw-r--r-- | indra/newview/llgesturemgr.cpp | 130 | 
1 files changed, 81 insertions, 49 deletions
| diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 82293b4aa0..0996d09e25 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -67,19 +67,18 @@ static const LLUUID& get_linked_uuid(const LLUUID& item_id);  // Lightweight constructor.  // init() does the heavy lifting. -LLGestureManager::LLGestureManager() +LLGestureMgr::LLGestureMgr()  :	mValid(FALSE),  	mPlaying(),  	mActive(),  	mLoadingCount(0)  { -	mRetryIfMissing = true;  	gInventory.addObserver(this);  }  // We own the data for gestures, so clean them up. -LLGestureManager::~LLGestureManager() +LLGestureMgr::~LLGestureMgr()  {  	item_map_t::iterator it;  	for (it = mActive.begin(); it != mActive.end(); ++it) @@ -93,15 +92,50 @@ LLGestureManager::~LLGestureManager()  } -void LLGestureManager::init() +void LLGestureMgr::init()  {  	// TODO  } +void LLGestureMgr::changed(U32 mask)  +{  +	LLInventoryFetchItemsObserver::changed(mask); + +	if (mask & LLInventoryObserver::GESTURE) +	{ +		// If there was a gesture label changed, update all the names in the  +		// active gestures and then notify observers +		if (mask & LLInventoryObserver::LABEL) +		{ +			for(item_map_t::iterator it = mActive.begin(); it != mActive.end(); ++it) +			{ +				if(it->second) +				{ +					LLViewerInventoryItem* item = gInventory.getItem(it->first); +					if(item) +					{ +						it->second->mName = item->getName(); +					} +				} +			} +			notifyObservers(); +		} +		// If there was a gesture added or removed notify observers +		// STRUCTURE denotes that the inventory item has been moved +		// In the case of deleting gesture, it is moved to the trash +		else if(mask & LLInventoryObserver::ADD || +				mask & LLInventoryObserver::REMOVE || +				mask & LLInventoryObserver::STRUCTURE) +		{ +			notifyObservers(); +		} +	} +} +  // Use this version when you have the item_id but not the asset_id,  // and you KNOW the inventory is loaded. -void LLGestureManager::activateGesture(const LLUUID& item_id) +void LLGestureMgr::activateGesture(const LLUUID& item_id)  {  	LLViewerInventoryItem* item = gInventory.getItem(item_id);  	if (!item) return; @@ -117,7 +151,7 @@ void LLGestureManager::activateGesture(const LLUUID& item_id)  } -void LLGestureManager::activateGestures(LLViewerInventoryItem::item_array_t& items) +void LLGestureMgr::activateGestures(LLViewerInventoryItem::item_array_t& items)  {  	// Load up the assets  	S32 count = 0; @@ -213,7 +247,7 @@ struct LLLoadInfo  /**   * It will load a gesture from remote storage   */ -void LLGestureManager::activateGestureWithAsset(const LLUUID& item_id, +void LLGestureMgr::activateGestureWithAsset(const LLUUID& item_id,  												const LLUUID& asset_id,  												BOOL inform_server,  												BOOL deactivate_similar) @@ -222,7 +256,7 @@ void LLGestureManager::activateGestureWithAsset(const LLUUID& item_id,  	if( !gAssetStorage )  	{ -		llwarns << "LLGestureManager::activateGestureWithAsset without valid gAssetStorage" << llendl; +		llwarns << "LLGestureMgr::activateGestureWithAsset without valid gAssetStorage" << llendl;  		return;  	}  	// If gesture is already active, nothing to do. @@ -264,7 +298,7 @@ void LLGestureManager::activateGestureWithAsset(const LLUUID& item_id,  } -void LLGestureManager::deactivateGesture(const LLUUID& item_id) +void LLGestureMgr::deactivateGesture(const LLUUID& item_id)  {  	const LLUUID& base_item_id = get_linked_uuid(item_id);  	item_map_t::iterator it = mActive.find(base_item_id); @@ -303,16 +337,16 @@ void LLGestureManager::deactivateGesture(const LLUUID& item_id)  	gAgent.sendReliableMessage(); -	LLAppearanceManager::instance().removeCOFItemLinks(base_item_id, false); +	LLAppearanceMgr::instance().removeCOFItemLinks(base_item_id, false);  	notifyObservers();  } -void LLGestureManager::deactivateSimilarGestures(LLMultiGesture* in, const LLUUID& in_item_id) +void LLGestureMgr::deactivateSimilarGestures(LLMultiGesture* in, const LLUUID& in_item_id)  {  	const LLUUID& base_in_item_id = get_linked_uuid(in_item_id); -	std::vector<LLUUID> gest_item_ids; +	uuid_vec_t gest_item_ids;  	// Deactivate all gestures that match  	item_map_t::iterator it; @@ -351,7 +385,7 @@ void LLGestureManager::deactivateSimilarGestures(LLMultiGesture* in, const LLUUI  	// Inform database of the change  	LLMessageSystem* msg = gMessageSystem;  	BOOL start_message = TRUE; -	std::vector<LLUUID>::const_iterator vit = gest_item_ids.begin(); +	uuid_vec_t::const_iterator vit = gest_item_ids.begin();  	while (vit != gest_item_ids.end())  	{  		if (start_message) @@ -396,7 +430,7 @@ void LLGestureManager::deactivateSimilarGestures(LLMultiGesture* in, const LLUUI  } -BOOL LLGestureManager::isGestureActive(const LLUUID& item_id) +BOOL LLGestureMgr::isGestureActive(const LLUUID& item_id)  {  	const LLUUID& base_item_id = get_linked_uuid(item_id);  	item_map_t::iterator it = mActive.find(base_item_id); @@ -404,7 +438,7 @@ BOOL LLGestureManager::isGestureActive(const LLUUID& item_id)  } -BOOL LLGestureManager::isGesturePlaying(const LLUUID& item_id) +BOOL LLGestureMgr::isGesturePlaying(const LLUUID& item_id)  {  	const LLUUID& base_item_id = get_linked_uuid(item_id); @@ -417,7 +451,7 @@ BOOL LLGestureManager::isGesturePlaying(const LLUUID& item_id)  	return gesture->mPlaying;  } -BOOL LLGestureManager::isGesturePlaying(LLMultiGesture* gesture) +BOOL LLGestureMgr::isGesturePlaying(LLMultiGesture* gesture)  {  	if(!gesture)  	{ @@ -427,7 +461,7 @@ BOOL LLGestureManager::isGesturePlaying(LLMultiGesture* gesture)  	return gesture->mPlaying;  } -void LLGestureManager::replaceGesture(const LLUUID& item_id, LLMultiGesture* new_gesture, const LLUUID& asset_id) +void LLGestureMgr::replaceGesture(const LLUUID& item_id, LLMultiGesture* new_gesture, const LLUUID& asset_id)  {  	const LLUUID& base_item_id = get_linked_uuid(item_id); @@ -469,11 +503,11 @@ void LLGestureManager::replaceGesture(const LLUUID& item_id, LLMultiGesture* new  	notifyObservers();  } -void LLGestureManager::replaceGesture(const LLUUID& item_id, const LLUUID& new_asset_id) +void LLGestureMgr::replaceGesture(const LLUUID& item_id, const LLUUID& new_asset_id)  {  	const LLUUID& base_item_id = get_linked_uuid(item_id); -	item_map_t::iterator it = LLGestureManager::instance().mActive.find(base_item_id); +	item_map_t::iterator it = LLGestureMgr::instance().mActive.find(base_item_id);  	if (it == mActive.end())  	{  		llwarns << "replaceGesture for inactive gesture " << base_item_id << llendl; @@ -482,10 +516,10 @@ void LLGestureManager::replaceGesture(const LLUUID& item_id, const LLUUID& new_a  	// mActive owns this gesture pointer, so clean up memory.  	LLMultiGesture* gesture = (*it).second; -	LLGestureManager::instance().replaceGesture(base_item_id, gesture, new_asset_id); +	LLGestureMgr::instance().replaceGesture(base_item_id, gesture, new_asset_id);  } -void LLGestureManager::playGesture(LLMultiGesture* gesture) +void LLGestureMgr::playGesture(LLMultiGesture* gesture)  {  	if (!gesture) return; @@ -504,7 +538,7 @@ void LLGestureManager::playGesture(LLMultiGesture* gesture)  // Convenience function that looks up the item_id for you. -void LLGestureManager::playGesture(const LLUUID& item_id) +void LLGestureMgr::playGesture(const LLUUID& item_id)  {  	const LLUUID& base_item_id = get_linked_uuid(item_id); @@ -521,7 +555,7 @@ void LLGestureManager::playGesture(const LLUUID& item_id)  // Iterates through space delimited tokens in string, triggering any gestures found.  // Generates a revised string that has the found tokens replaced by their replacement strings  // and (as a minor side effect) has multiple spaces in a row replaced by single spaces. -BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::string* revised_string) +BOOL LLGestureMgr::triggerAndReviseString(const std::string &utf8str, std::string* revised_string)  {  	std::string tokenized = utf8str; @@ -614,7 +648,7 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s  } -BOOL LLGestureManager::triggerGesture(KEY key, MASK mask) +BOOL LLGestureMgr::triggerGesture(KEY key, MASK mask)  {  	std::vector <LLMultiGesture *> matching;  	item_map_t::iterator it; @@ -648,7 +682,7 @@ BOOL LLGestureManager::triggerGesture(KEY key, MASK mask)  } -S32 LLGestureManager::getPlayingCount() const +S32 LLGestureMgr::getPlayingCount() const  {  	return mPlaying.size();  } @@ -662,7 +696,7 @@ struct IsGesturePlaying : public std::unary_function<LLMultiGesture*, bool>  	}  }; -void LLGestureManager::update() +void LLGestureMgr::update()  {  	S32 i;  	for (i = 0; i < (S32)mPlaying.size(); ++i) @@ -705,14 +739,13 @@ void LLGestureManager::update()  // Run all steps until you're either done or hit a wait. -void LLGestureManager::stepGesture(LLMultiGesture* gesture) +void LLGestureMgr::stepGesture(LLMultiGesture* gesture)  {  	if (!gesture)  	{  		return;  	} -	LLVOAvatar* avatar = gAgent.getAvatarObject(); -	if (!avatar) return; +	if (!isAgentAvatarValid()) return;  	// Of the ones that started playing, have any stopped? @@ -723,8 +756,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture)  	{  		// look in signaled animations (simulator's view of what is  		// currently playing. -		LLVOAvatar::AnimIterator play_it = avatar->mSignaledAnimations.find(*gest_it); -		if (play_it != avatar->mSignaledAnimations.end()) +		LLVOAvatar::AnimIterator play_it = gAgentAvatarp->mSignaledAnimations.find(*gest_it); +		if (play_it != gAgentAvatarp->mSignaledAnimations.end())  		{  			++gest_it;  		} @@ -742,8 +775,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture)  		 gest_it != gesture->mRequestedAnimIDs.end();  		 )  	{ -	 LLVOAvatar::AnimIterator play_it = avatar->mSignaledAnimations.find(*gest_it); -		if (play_it != avatar->mSignaledAnimations.end()) +	 LLVOAvatar::AnimIterator play_it = gAgentAvatarp->mSignaledAnimations.find(*gest_it); +		if (play_it != gAgentAvatarp->mSignaledAnimations.end())  		{  			// Hooray, this animation has started playing!  			// Copy into playing. @@ -853,7 +886,7 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture)  } -void LLGestureManager::runStep(LLMultiGesture* gesture, LLGestureStep* step) +void LLGestureMgr::runStep(LLMultiGesture* gesture, LLGestureStep* step)  {  	switch(step->getType())  	{ @@ -940,7 +973,7 @@ void LLGestureManager::runStep(LLMultiGesture* gesture, LLGestureStep* step)  // static -void LLGestureManager::onLoadComplete(LLVFS *vfs, +void LLGestureMgr::onLoadComplete(LLVFS *vfs,  									   const LLUUID& asset_uuid,  									   LLAssetType::EType type,  									   void* user_data, S32 status, LLExtStat ext_status) @@ -953,7 +986,7 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs,  	delete info;  	info = NULL; -	LLGestureManager& self = LLGestureManager::instance(); +	LLGestureMgr& self = LLGestureMgr::instance();  	self.mLoadingCount--;  	if (0 == status) @@ -997,9 +1030,8 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs,  			else  			{  				// Watch this item and set gesture name when item exists in inventory -				item_ref_t ids; -				ids.push_back(item_id); -				self.fetchItems(ids); +				self.setFetchID(item_id); +				self.startFetch();  			}  			self.mActive[item_id] = gesture; @@ -1059,12 +1091,12 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs,  		llwarns << "Problem loading gesture: " << status << llendl; -		LLGestureManager::instance().mActive.erase(item_id);			 +		LLGestureMgr::instance().mActive.erase(item_id);			  	}  } -void LLGestureManager::stopGesture(LLMultiGesture* gesture) +void LLGestureMgr::stopGesture(LLMultiGesture* gesture)  {  	if (!gesture) return; @@ -1104,7 +1136,7 @@ void LLGestureManager::stopGesture(LLMultiGesture* gesture)  } -void LLGestureManager::stopGesture(const LLUUID& item_id) +void LLGestureMgr::stopGesture(const LLUUID& item_id)  {  	const LLUUID& base_item_id = get_linked_uuid(item_id); @@ -1118,12 +1150,12 @@ void LLGestureManager::stopGesture(const LLUUID& item_id)  } -void LLGestureManager::addObserver(LLGestureManagerObserver* observer) +void LLGestureMgr::addObserver(LLGestureManagerObserver* observer)  {  	mObservers.push_back(observer);  } -void LLGestureManager::removeObserver(LLGestureManagerObserver* observer) +void LLGestureMgr::removeObserver(LLGestureManagerObserver* observer)  {  	std::vector<LLGestureManagerObserver*>::iterator it;  	it = std::find(mObservers.begin(), mObservers.end(), observer); @@ -1136,9 +1168,9 @@ void LLGestureManager::removeObserver(LLGestureManagerObserver* observer)  // Call this method when it's time to update everyone on a new state.  // Copy the list because an observer could respond by removing itself  // from the list. -void LLGestureManager::notifyObservers() +void LLGestureMgr::notifyObservers()  { -	lldebugs << "LLGestureManager::notifyObservers" << llendl; +	lldebugs << "LLGestureMgr::notifyObservers" << llendl;  	std::vector<LLGestureManagerObserver*> observers = mObservers; @@ -1150,7 +1182,7 @@ void LLGestureManager::notifyObservers()  	}  } -BOOL LLGestureManager::matchPrefix(const std::string& in_str, std::string* out_str) +BOOL LLGestureMgr::matchPrefix(const std::string& in_str, std::string* out_str)  {  	S32 in_len = in_str.length(); @@ -1181,7 +1213,7 @@ BOOL LLGestureManager::matchPrefix(const std::string& in_str, std::string* out_s  } -void LLGestureManager::getItemIDs(std::vector<LLUUID>* ids) +void LLGestureMgr::getItemIDs(uuid_vec_t* ids)  {  	item_map_t::const_iterator it;  	for (it = mActive.begin(); it != mActive.end(); ++it) @@ -1190,7 +1222,7 @@ void LLGestureManager::getItemIDs(std::vector<LLUUID>* ids)  	}  } -void LLGestureManager::done() +void LLGestureMgr::done()  {  	bool notify = false;  	for(item_map_t::iterator it = mActive.begin(); it != mActive.end(); ++it) | 
