From 3656d80cf873a8e2852b262d6b5ed88608fdc49b Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Fri, 29 Aug 2014 12:00:11 +0300
Subject: [PATCH] MAINT-4239 FIXED Buttons are added to Object contents floater

---
 indra/newview/llfloateropenobject.cpp         | 23 +++++++--
 indra/newview/llfloateropenobject.h           |  7 ++-
 indra/newview/llinventorybridge.cpp           | 10 ++--
 .../default/xui/en/floater_openobject.xml     | 47 +++++++++++++++----
 4 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp
index 9986bdbd7f1..ef746d308db 100755
--- a/indra/newview/llfloateropenobject.cpp
+++ b/indra/newview/llfloateropenobject.cpp
@@ -58,6 +58,8 @@ LLFloaterOpenObject::LLFloaterOpenObject(const LLSD& key)
 {
 	mCommitCallbackRegistrar.add("OpenObject.MoveToInventory",	boost::bind(&LLFloaterOpenObject::onClickMoveToInventory, this));
 	mCommitCallbackRegistrar.add("OpenObject.MoveAndWear",		boost::bind(&LLFloaterOpenObject::onClickMoveAndWear, this));
+	mCommitCallbackRegistrar.add("OpenObject.ReplaceOutfit",	boost::bind(&LLFloaterOpenObject::onClickReplace, this));
+	mCommitCallbackRegistrar.add("OpenObject.Cancel",			boost::bind(&LLFloaterOpenObject::onClickCancel, this));
 }
 
 LLFloaterOpenObject::~LLFloaterOpenObject()
@@ -115,6 +117,7 @@ void LLFloaterOpenObject::refresh()
 	getChild<LLUICtrl>("object_name")->setTextArg("[DESC]", name);
 	getChildView("copy_to_inventory_button")->setEnabled(enabled);
 	getChildView("copy_and_wear_button")->setEnabled(enabled);
+	getChildView("copy_and_replace_button")->setEnabled(enabled);
 
 }
 
@@ -135,7 +138,7 @@ void LLFloaterOpenObject::dirty()
 
 
 
-void LLFloaterOpenObject::moveToInventory(bool wear)
+void LLFloaterOpenObject::moveToInventory(bool wear, bool replace)
 {
 	if (mObjectSelection->getRootObjectCount() != 1)
 	{
@@ -163,7 +166,7 @@ void LLFloaterOpenObject::moveToInventory(bool wear)
 		parent_category_id = gInventory.getRootFolderID();
 	}
 
-	inventory_func_type func = boost::bind(LLFloaterOpenObject::callbackCreateInventoryCategory,_1,object_id,wear);
+	inventory_func_type func = boost::bind(LLFloaterOpenObject::callbackCreateInventoryCategory,_1,object_id,wear,replace);
 	LLUUID category_id = gInventory.createNewCategory(parent_category_id, 
 													  LLFolderType::FT_NONE, 
 													  name,
@@ -177,6 +180,7 @@ void LLFloaterOpenObject::moveToInventory(bool wear)
 		data->mCatID = category_id;
 		data->mWear = wear;
 		data->mFolderResponded = false;
+		data->mReplace = replace;
 
 		// Copy and/or move the items into the newly created folder.
 		// Ignore any "you're going to break this item" messages.
@@ -194,13 +198,14 @@ void LLFloaterOpenObject::moveToInventory(bool wear)
 }
 
 // static
-void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLUUID& category_id, LLUUID object_id, bool wear)
+void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLUUID& category_id, LLUUID object_id, bool wear, bool replace)
 {
 	LLCatAndWear* wear_data = new LLCatAndWear;
 
 	wear_data->mCatID = category_id;
 	wear_data->mWear = wear;
 	wear_data->mFolderResponded = true;
+	wear_data->mReplace = replace;
 	
 	// Copy and/or move the items into the newly created folder.
 	// Ignore any "you're going to break this item" messages.
@@ -241,7 +246,17 @@ void LLFloaterOpenObject::onClickMoveToInventory()
 
 void LLFloaterOpenObject::onClickMoveAndWear()
 {
-	moveToInventory(true);
+	moveToInventory(true, false);
 	closeFloater();
 }
 
+void LLFloaterOpenObject::onClickReplace()
+{
+	moveToInventory(true, true);
+	closeFloater();
+}
+
+void LLFloaterOpenObject::onClickCancel()
+{
+	closeFloater();
+}
diff --git a/indra/newview/llfloateropenobject.h b/indra/newview/llfloateropenobject.h
index 8e472804a43..2e761f99bfb 100755
--- a/indra/newview/llfloateropenobject.h
+++ b/indra/newview/llfloateropenobject.h
@@ -50,6 +50,7 @@ class LLFloaterOpenObject
 		LLUUID mCatID;
 		bool mWear;
 		bool mFolderResponded;
+		bool mReplace;
 	};
 
 protected:
@@ -59,11 +60,13 @@ class LLFloaterOpenObject
 	void draw();
 	virtual void onOpen(const LLSD& key);
 
-	void moveToInventory(bool wear);
+	void moveToInventory(bool wear, bool replace = false);
 
 	void onClickMoveToInventory();
 	void onClickMoveAndWear();
-	static void callbackCreateInventoryCategory(const LLUUID& category_id, LLUUID object_id, bool wear);
+	void onClickReplace();
+	void onClickCancel();
+	static void callbackCreateInventoryCategory(const LLUUID& category_id, LLUUID object_id, bool wear, bool replace = false);
 	static void callbackMoveInventory(S32 result, void* data);
 
 private:
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index d6f2803fc23..085986dc689 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -2787,8 +2787,8 @@ void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer)
 class LLInventoryCopyAndWearObserver : public LLInventoryObserver
 {
 public:
-	LLInventoryCopyAndWearObserver(const LLUUID& cat_id, int count, bool folder_added=false) :
-		mCatID(cat_id), mContentsCount(count), mFolderAdded(folder_added) {}
+	LLInventoryCopyAndWearObserver(const LLUUID& cat_id, int count, bool folder_added=false, bool replace=false) :
+		mCatID(cat_id), mContentsCount(count), mFolderAdded(folder_added), mReplace(replace){}
 	virtual ~LLInventoryCopyAndWearObserver() {}
 	virtual void changed(U32 mask);
 
@@ -2796,6 +2796,7 @@ class LLInventoryCopyAndWearObserver : public LLInventoryObserver
 	LLUUID mCatID;
 	int    mContentsCount;
 	bool   mFolderAdded;
+	bool   mReplace;
 };
 
 
@@ -2834,7 +2835,7 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask)
 				    mContentsCount)
 				{
 					gInventory.removeObserver(this);
-					LLAppearanceMgr::instance().wearInventoryCategory(category, FALSE, TRUE);
+					LLAppearanceMgr::instance().wearInventoryCategory(category, FALSE, !mReplace);
 					delete this;
 				}
 			}
@@ -3815,7 +3816,8 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response
 			LLInventoryObject::object_list_t inventory_objects;
 			object->getInventoryContents(inventory_objects);
 			int contents_count = inventory_objects.size()-1; //subtract one for containing folder
-			LLInventoryCopyAndWearObserver* inventoryObserver = new LLInventoryCopyAndWearObserver(cat_and_wear->mCatID, contents_count, cat_and_wear->mFolderResponded);
+			LLInventoryCopyAndWearObserver* inventoryObserver = new LLInventoryCopyAndWearObserver(cat_and_wear->mCatID, contents_count, cat_and_wear->mFolderResponded,
+																									cat_and_wear->mReplace);
 			
 			gInventory.addObserver(inventoryObserver);
 		}
diff --git a/indra/newview/skins/default/xui/en/floater_openobject.xml b/indra/newview/skins/default/xui/en/floater_openobject.xml
index bf6e0c4917a..a130439baa7 100755
--- a/indra/newview/skins/default/xui/en/floater_openobject.xml
+++ b/indra/newview/skins/default/xui/en/floater_openobject.xml
@@ -6,7 +6,7 @@
  height="350"
  layout="topleft"
  min_height="160"
- min_width="280"
+ min_width="285"
  name="objectcontents"
  help_topic="objectcontents"
  save_rect="true"
@@ -31,36 +31,63 @@
      background_visible="false"
      draw_border="false"
      follows="all"
-     height="276"
+     height="250"
      layout="topleft"
      left="10"
      name="object_contents"
      top_pad="0"
      width="284" />
+     
+ 	<button
+     follows="bottom|left"
+     height="23"
+     label="Copy and add to outfit"
+     label_selected="Copy and add to outfit"
+     layout="topleft"
+ 	 left="15"    
+     name="copy_and_wear_button"
+ 	 top_pad="5"	
+     width="135">
+        <button.commit_callback
+         function="OpenObject.MoveAndWear" />
+    </button>
+	<button
+     follows="bottom|left"
+     height="23"
+     label="Replace outfit"
+     label_selected="Replace outfit"
+     layout="topleft"
+     left_pad="5"
+     name="copy_and_replace_button"
+     width="120">
+        <button.commit_callback
+         function="OpenObject.ReplaceOutfit" />
+    </button>  
+ 
     <button
      follows="bottom|left"
      height="23"
-     label="Copy to inventory"
-     label_selected="Copy to inventory"
+     label="Only copy to inventory"
+     label_selected="Only copy to inventory"
      layout="topleft"
      left="15"
      name="copy_to_inventory_button"
      tab_group="1"
      top_pad="5"
-     width="120">
+     width="135">
         <button.commit_callback
          function="OpenObject.MoveToInventory" />
     </button>
     <button
      follows="bottom|left"
      height="23"
-     label="Copy and add to outfit"
-     label_selected="Copy and add to outfit"
+     label="Cancel"
+     label_selected="Cancel"
      layout="topleft"
      left_pad="5"
-     name="copy_and_wear_button"
-     width="135">
+     name="cancel_button"
+     width="120">
         <button.commit_callback
-         function="OpenObject.MoveAndWear" />
+         function="OpenObject.Cancel" />
     </button>
 </floater>
-- 
GitLab