From 08381a276dbf0544692c44236b40f57ec111aefc Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Wed, 23 Jun 2010 15:30:48 +0300
Subject: [PATCH] EXT-7755 ADDITIONAL FIX Fixed issues with wrong title after
 an outfit from the Inventory is worn, "Wear..." menu items state is made
 consistent with "Wear" button.

* Empty string is replaced with "Changing outfits" while changing COF;
* Fixed title to show "No Outfit" after an outfit from the Inventory is worn;
* Fixed bug with visible indicator after an empty folder is DnD from the Inventory "Clothing"
* Updated context and Gear "Wear..." menu items to take into account "isCOFChangeInProgress" state in on_enable callbacks

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/625/

--HG--
branch : product-engine
---
 indra/newview/llappearancemgr.cpp                |  3 ++-
 indra/newview/llappearancemgr.h                  |  3 +++
 indra/newview/lloutfitslist.cpp                  |  5 +++++
 indra/newview/llpaneloutfitsinventory.cpp        | 16 +++++++++++++---
 indra/newview/llpaneloutfitsinventory.h          |  4 +++-
 indra/newview/llsidepanelappearance.cpp          | 10 ++++++++--
 .../skins/default/xui/en/menu_outfit_tab.xml     |  3 +++
 .../default/xui/en/sidepanel_appearance.xml      |  3 +++
 8 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 3947be49bb5..f088a620d69 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1697,9 +1697,10 @@ void LLAppearanceMgr::getUserDescendents(const LLUUID& category,
 
 void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append)
 {
-	gAgentWearables.notifyLoadingStarted();
 	if(!category) return;
 
+	gAgentWearables.notifyLoadingStarted();
+
 	llinfos << "wearInventoryCategory( " << category->getName()
 			 << " )" << llendl;
 
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index ab4ff1bcfc8..982aa02cd0c 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -360,6 +360,9 @@ class CallAfterCategoryFetchStage1: public LLInventoryFetchDescendentsObserver
 					<< llendl;
 			//dec_busy_count();
 			gInventory.removeObserver(this);
+
+			// lets notify observers that loading is finished.
+			gAgentWearables.notifyLoadingFinished();
 			delete this;
 			return;
 		}
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index 6542afc366f..b3d39f2a4a3 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -103,8 +103,13 @@ class OutfitContextMenu : public LLListContextMenu
 		{
 			return get_is_category_renameable(&gInventory, outfit_cat_id);
 		}
+		else if ("wear_replace" == param)
+		{
+			return !gAgentWearables.isCOFChangeInProgress();
+		}
 		else if ("wear_add" == param)
 		{
+			if (gAgentWearables.isCOFChangeInProgress()) return false;
 			return LLAppearanceMgr::getCanAddToCOF(outfit_cat_id);
 		}
 		else if ("take_off" == param)
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp
index d382c77430f..77c135c7165 100644
--- a/indra/newview/llpaneloutfitsinventory.cpp
+++ b/indra/newview/llpaneloutfitsinventory.cpp
@@ -72,11 +72,13 @@ static const std::string COF_TAB_NAME = "cof_tab";
 
 static LLRegisterPanelClassWrapper<LLPanelOutfitsInventory> t_inventory("panel_outfits_inventory");
 
+class LLPanelOutfitsInventory;
 class LLOutfitListGearMenu
 {
 public:
-	LLOutfitListGearMenu(LLOutfitsList* olist)
+	LLOutfitListGearMenu(LLOutfitsList* olist, LLPanelOutfitsInventory* parent_panel)
 	:	mOutfitList(olist),
+		mMyOutfitsPanel(parent_panel),
 		mMenu(NULL)
 	{
 		llassert_always(mOutfitList);
@@ -209,6 +211,11 @@ class LLOutfitListGearMenu
 		{
 			return LLAppearanceMgr::getCanRemoveFromCOF(selected_outfit_id);
 		}
+		else if ("wear" == param)
+		{
+			return mMyOutfitsPanel->isActionEnabled(param);
+		}
+
 
 		return true;
 	}
@@ -233,6 +240,7 @@ class LLOutfitListGearMenu
 
 	LLOutfitsList*	mOutfitList;
 	LLMenuGL*		mMenu;
+	LLPanelOutfitsInventory* mMyOutfitsPanel;
 };
 
 LLPanelOutfitsInventory::LLPanelOutfitsInventory() :
@@ -550,13 +558,13 @@ void LLPanelOutfitsInventory::initListCommandsHandlers()
 				   ,       _7 // EAcceptance* accept
 				   ));
 
-	mGearMenu = new LLOutfitListGearMenu(mMyOutfitsPanel);
+	mGearMenu = new LLOutfitListGearMenu(mMyOutfitsPanel, this);
 }
 
 void LLPanelOutfitsInventory::updateListCommands()
 {
 	bool trash_enabled = isActionEnabled("delete");
-	bool wear_enabled =  !gAgentWearables.isCOFChangeInProgress() && isActionEnabled("wear");
+	bool wear_enabled =  isActionEnabled("wear");
 	bool wear_visible = !isCOFPanelActive();
 	bool make_outfit_enabled = isActionEnabled("save_outfit");
 
@@ -710,6 +718,8 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata)
 	
 	if (command_name == "wear")
 	{
+		if (gAgentWearables.isCOFChangeInProgress()) return FALSE;
+
 		if (isCOFPanelActive())
 		{
 			return FALSE;
diff --git a/indra/newview/llpaneloutfitsinventory.h b/indra/newview/llpaneloutfitsinventory.h
index eabfda7f8c2..287fcbf4bb0 100644
--- a/indra/newview/llpaneloutfitsinventory.h
+++ b/indra/newview/llpaneloutfitsinventory.h
@@ -112,6 +112,9 @@ class LLPanelOutfitsInventory : public LLPanel
 
 	//////////////////////////////////////////////////////////////////////////////////
 	// List Commands                                                                //
+public:
+	BOOL isActionEnabled(const LLSD& command_name);
+
 protected:
 	void initListCommandsHandlers();
 	void updateListCommands();
@@ -119,7 +122,6 @@ class LLPanelOutfitsInventory : public LLPanel
 	void showGearMenu();
 	void onTrashButtonClick();
 	void onClipboardAction(const LLSD& userdata);
-	BOOL isActionEnabled(const LLSD& command_name);
 	void onCustomAction(const LLSD& command_name);
 	bool handleDragAndDropToTrash(BOOL drop, EDragAndDropType cargo_type, EAcceptance* accept);
 	bool hasItemsSelected();
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index 0d1be911254..ea5796d7660 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -390,8 +390,8 @@ void LLSidepanelAppearance::refreshCurrentOutfitName(const std::string& name)
 				return;
 		}
 
-		std::string look_name = gAgentWearables.isCOFChangeInProgress() ? "" : getString("No Outfit");
-		mCurrentLookName->setText(look_name);
+		std::string string_name = gAgentWearables.isCOFChangeInProgress() ? "Changing outfits" : "No Outfit";
+		mCurrentLookName->setText(getString(string_name));
 		mOpenOutfitBtn->setEnabled(FALSE);
 	}
 	else
@@ -475,6 +475,12 @@ void LLSidepanelAppearance::setWearablesLoading(bool val)
 {
 	childSetVisible("wearables_loading_indicator", val);
 	childSetVisible("edit_outfit_btn", !val);
+
+	if (!val)
+	{
+		// refresh outfit name when COF is already changed.
+		refreshCurrentOutfitName();
+	}
 }
 
 void LLSidepanelAppearance::showDefaultSubpart()
diff --git a/indra/newview/skins/default/xui/en/menu_outfit_tab.xml b/indra/newview/skins/default/xui/en/menu_outfit_tab.xml
index 9c3151fe07f..8c8bb29baf1 100644
--- a/indra/newview/skins/default/xui/en/menu_outfit_tab.xml
+++ b/indra/newview/skins/default/xui/en/menu_outfit_tab.xml
@@ -8,6 +8,9 @@
      name="wear_replace">
         <on_click
          function="Outfit.WearReplace" />
+        <on_enable
+         function="Outfit.OnEnable"
+         parameter="wear_replace" />
         <on_visible
          function="Outfit.OnVisible"
          parameter="wear_replace" />
diff --git a/indra/newview/skins/default/xui/en/sidepanel_appearance.xml b/indra/newview/skins/default/xui/en/sidepanel_appearance.xml
index e189d11d352..9a07d3a48a8 100644
--- a/indra/newview/skins/default/xui/en/sidepanel_appearance.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_appearance.xml
@@ -21,6 +21,9 @@ width="333">
    <string
    name="Now Wearing"
    value="Now wearing..." />
+   <string
+   name="Changing outfits"
+   value="Changing outfits" />
    <panel
    background_opaque="true"
    background_visible="true"
-- 
GitLab