From c8c125b774b926c7d487b11833ac0c83d6936bc2 Mon Sep 17 00:00:00 2001
From: Vadim Savchuk <vsavchuk@productengine.com>
Date: Tue, 17 Aug 2010 22:40:28 +0300
Subject: [PATCH] EXT-8564 FIXED Ability to take off wearables via "Wearing"
 Tab of My Outfits.

Added Take Off / Detach options to the Wearing tab context menu.

Reviewed by Sergey Litovchuk at https://codereview.productengine.com/secondlife/r/864/

--HG--
branch : product-engine
---
 indra/newview/llpanelwearing.cpp              | 51 ++++++++++++++++++-
 .../skins/default/xui/en/menu_wearing_tab.xml | 18 +++++++
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp
index b8852890add..fd7ca39c72a 100644
--- a/indra/newview/llpanelwearing.cpp
+++ b/indra/newview/llpanelwearing.cpp
@@ -87,9 +87,58 @@ class LLWearingContextMenu : public LLListContextMenu
 	{
 		LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
 
+		functor_t take_off = boost::bind(&LLAppearanceMgr::removeItemFromAvatar, LLAppearanceMgr::getInstance(), _1);
+
 		registrar.add("Wearing.Edit", boost::bind(&edit_outfit));
+		registrar.add("Wearing.TakeOff", boost::bind(handleMultiple, take_off, mUUIDs));
+		registrar.add("Wearing.Detach", boost::bind(handleMultiple, take_off, mUUIDs));
+
+		LLContextMenu* menu = createFromFile("menu_wearing_tab.xml");
+
+		updateMenuItemsVisibility(menu);
 
-		return createFromFile("menu_wearing_tab.xml");
+		return menu;
+	}
+
+	void updateMenuItemsVisibility(LLContextMenu* menu)
+	{
+		bool bp_selected			= false;	// true if body parts selected
+		bool clothes_selected		= false;
+		bool attachments_selected	= false;
+
+		// See what types of wearables are selected.
+		for (uuid_vec_t::const_iterator it = mUUIDs.begin(); it != mUUIDs.end(); ++it)
+		{
+			LLViewerInventoryItem* item = gInventory.getItem(*it);
+
+			if (!item)
+			{
+				llwarns << "Invalid item" << llendl;
+				continue;
+			}
+
+			LLAssetType::EType type = item->getType();
+			if (type == LLAssetType::AT_CLOTHING)
+			{
+				clothes_selected = true;
+			}
+			else if (type == LLAssetType::AT_BODYPART)
+			{
+				bp_selected = true;
+			}
+			else if (type == LLAssetType::AT_OBJECT)
+			{
+				attachments_selected = true;
+			}
+		}
+
+		// Enable/disable some menu items depending on the selection.
+		bool allow_detach = !bp_selected && !clothes_selected && attachments_selected;
+		bool allow_take_off = !bp_selected && clothes_selected && !attachments_selected;
+
+		menu->setItemVisible("take_off",	allow_take_off);
+		menu->setItemVisible("detach",		allow_detach);
+		menu->setItemVisible("edit_outfit_separator", allow_take_off || allow_detach);
 	}
 };
 
diff --git a/indra/newview/skins/default/xui/en/menu_wearing_tab.xml b/indra/newview/skins/default/xui/en/menu_wearing_tab.xml
index 85505f99727..2d54e696013 100644
--- a/indra/newview/skins/default/xui/en/menu_wearing_tab.xml
+++ b/indra/newview/skins/default/xui/en/menu_wearing_tab.xml
@@ -2,6 +2,24 @@
 <context_menu
  layout="topleft"
  name="Wearing">
+    <menu_item_call
+     label="Take Off"
+     layout="topleft"
+     name="take_off">
+        <on_click
+         function="Wearing.TakeOff" />
+    </menu_item_call>
+    <menu_item_call
+     label="Detach"
+     layout="topleft"
+     name="detach">
+        <on_click
+         function="Wearing.Detach"
+         parameter="detach"/>
+    </menu_item_call>
+    <menu_item_separator
+     layout="topleft"
+     name="edit_outfit_separator" />
     <menu_item_call
      label="Edit Outfit"
      layout="topleft"
-- 
GitLab