Anonymous avatar Anonymous committed 11d4a88

EXT-2677 : "Remove From Outfit" active even when I'm not wearing any items in the folder

Now checking contents of the folder for any actively worn items for determining this flag.

Comments (0)

Files changed (2)

indra/newview/llinventorybridge.cpp

 			mItems.push_back(std::string("Wear As Ensemble"));
 		}
 		mItems.push_back(std::string("Remove From Outfit"));
-
+		if (!areAnyContentsWorn(model))
+		{
+			disabled_items.push_back(std::string("Remove From Outfit"));
+		}
 		mItems.push_back(std::string("Outfit Separator"));
 	}
 	hide_context_entries(*mMenu, mItems, disabled_items);
 	return ((item_array.count() > 0) ? TRUE : FALSE );
 }
 
+class LLFindWorn : public LLInventoryCollectFunctor
+{
+public:
+	LLFindWorn() {}
+	virtual ~LLFindWorn() {}
+	virtual bool operator()(LLInventoryCategory* cat,
+							LLInventoryItem* item)
+	{
+		if (item && get_is_item_worn(item->getUUID()))
+		{
+			return TRUE;
+		}
+		return FALSE;
+	}
+};
+
+BOOL LLFolderBridge::areAnyContentsWorn(LLInventoryModel* model) const
+{
+	LLInventoryModel::cat_array_t cat_array;
+	LLInventoryModel::item_array_t item_array;
+	LLFindWorn is_worn;
+	model->collectDescendentsIf(mUUID,
+								cat_array,
+								item_array,
+								LLInventoryModel::EXCLUDE_TRASH,
+								is_worn);
+	return (item_array.size() > 0);
+}
+
 // Flags unused
 void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
 			for(i = 0; i  < obj_count; ++i)
 			{
 				LLViewerInventoryItem *obj_item = obj_item_array.get(i);
-				gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
-				gMessageSystem->nextBlockFast(_PREHASH_ObjectData );
-				gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
-				gMessageSystem->addUUIDFast(_PREHASH_ItemID, obj_item->getLinkedUUID() );
-
-				gMessageSystem->sendReliable( gAgent.getRegion()->getHost() );
-
-				// this object might have been selected, so let the selection manager know it's gone now
-				LLViewerObject *found_obj = gObjectList.findObject( obj_item->getLinkedUUID());
-				if (found_obj)
+				if (get_is_item_worn(obj_item->getUUID()))
 				{
-					LLSelectMgr::getInstance()->remove(found_obj);
+					gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
+					gMessageSystem->nextBlockFast(_PREHASH_ObjectData );
+					gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
+					gMessageSystem->addUUIDFast(_PREHASH_ItemID, obj_item->getLinkedUUID() );
+					
+					gMessageSystem->sendReliable( gAgent.getRegion()->getHost() );
+					
+					// this object might have been selected, so let the selection manager know it's gone now
+					LLViewerObject *found_obj = gObjectList.findObject( obj_item->getLinkedUUID());
+					if (found_obj)
+					{
+						LLSelectMgr::getInstance()->remove(found_obj);
+					}
 				}
 			}
 		}
 			for(i = 0; i  < gest_count; ++i)
 			{
 				LLViewerInventoryItem *gest_item = gest_item_array.get(i);
-				if ( LLGestureManager::instance().isGestureActive( gest_item->getLinkedUUID()) )
+				if (get_is_item_worn(gest_item->getUUID()))
 				{
 					LLGestureManager::instance().deactivateGesture( gest_item->getLinkedUUID() );
 					gInventory.updateItem( gest_item );

indra/newview/llinventorybridge.h

 	static void createNewEyes(void* user_data);
 
 	BOOL checkFolderForContentsOfType(LLInventoryModel* model, LLInventoryCollectFunctor& typeToCheck);
+	BOOL areAnyContentsWorn(LLInventoryModel* model) const;
 
 	void modifyOutfit(BOOL append);
 	void determineFolderType();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.