From 399bd5643cdec65b98b76556b16e3a00df6db1b2 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <none@none>
Date: Sat, 17 Dec 2011 13:27:20 -0500
Subject: [PATCH] STORM-653 As a user i would like to be able to see the
 available number of attachments and remaining free slots.

---
 doc/contributions.txt                              |  1 +
 indra/newview/llcofwearables.cpp                   | 14 ++++++++++++++
 indra/newview/llcofwearables.h                     |  2 ++
 .../skins/default/xui/en/panel_cof_wearables.xml   |  1 +
 indra/newview/skins/default/xui/en/strings.xml     |  1 +
 5 files changed, 19 insertions(+)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 274632a8040..24743777f79 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -595,6 +595,7 @@ Jonathan Yap
 	STORM-1719
 	STORM-1712
 	STORM-1728
+	STORM-653
 Kadah Coba
 	STORM-1060
 Jondan Lundquist
diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index 54598f90c83..e9c7a3fa039 100644
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -328,6 +328,19 @@ BOOL LLCOFWearables::postBuild()
 	return LLPanel::postBuild();
 }
 
+void LLCOFWearables::setAttachmentsTitle()
+{
+	if (mAttachmentsTab)
+	{
+		U32 free_slots = MAX_AGENT_ATTACHMENTS - mAttachments->size();
+
+		LLStringUtil::format_map_t args_attachments;
+		args_attachments["[COUNT]"] = llformat ("%d", free_slots);
+		std::string attachments_title = LLTrans::getString("Attachments remain", args_attachments);
+		mAttachmentsTab->setTitle(attachments_title);
+	}
+}
+
 void LLCOFWearables::onSelectionChange(LLFlatListView* selected_list)
 {
 	if (!selected_list) return;
@@ -490,6 +503,7 @@ void LLCOFWearables::populateAttachmentsAndBodypartsLists(const LLInventoryModel
 	{
 		mAttachments->sort();
 		mAttachments->notify(REARRANGE); //notifying the parent about the list's size change (cause items were added with rearrange=false)
+		setAttachmentsTitle();
 	}
 	else
 	{
diff --git a/indra/newview/llcofwearables.h b/indra/newview/llcofwearables.h
index 1f8d6d0c94e..9957d6a64e1 100644
--- a/indra/newview/llcofwearables.h
+++ b/indra/newview/llcofwearables.h
@@ -91,6 +91,8 @@ class LLCOFWearables : public LLPanel
 	 */
 	void selectClothing(LLWearableType::EType clothing_type);
 
+	void setAttachmentsTitle();
+
 protected:
 
 	void populateAttachmentsAndBodypartsLists(const LLInventoryModel::item_array_t& cof_items);
diff --git a/indra/newview/skins/default/xui/en/panel_cof_wearables.xml b/indra/newview/skins/default/xui/en/panel_cof_wearables.xml
index beea53437a8..aa8e3d07a6e 100644
--- a/indra/newview/skins/default/xui/en/panel_cof_wearables.xml
+++ b/indra/newview/skins/default/xui/en/panel_cof_wearables.xml
@@ -37,6 +37,7 @@
              top="0"
              width="311" />
         </accordion_tab>
+         <!-- The Attachments title is overwritten by the definition of "Attachments remain" in strings.xml -->
         <accordion_tab
          layout="topleft"
          name="tab_attachments"
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index c25d1f57d6e..30697278c3a 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -2133,6 +2133,7 @@ Returns a string with the requested data about the region
 	<string name="InvFolder All">All</string>
 
 	<string name="no_attachments">No attachments worn</string>
+    <string name="Attachments remain">Attachments ([COUNT] slots remain)</string>
 
 	<!-- inventory FVBridge -->
 	<!--  This is used in llpanelinventory.cpp when constructing a context menu for an item for Sale  -->
-- 
GitLab