Commits

Anonymous committed e592b64

Fixed EXT-7163(normal) - Create dummy inventory item panel (an item panel for unworn wearable types)
Added new wearable list item - LLPanelDummyClothingListItem for not worn wearable types, it displays grayed wearable type icon, grayed
title '<clothing type> not worn' and 'add' button.
Modified base class to be more flexible.
Moved init() to protected section.
Modified COF panel to use dummy item.

Reviewed by Mike Antipov - https://codereview.productengine.com/secondlife/r/335/

Comments (0)

Files changed (7)

indra/newview/llcofwearables.cpp

 		U32 size = clothing_by_type[type].size();
 		if (size) continue;
 
-		//*TODO create dummy item panel
-		
-		//*TODO add dummy item panel -> mClothing->addItem(dummy_item_panel, item->getUUID(), ADD_BOTTOM, false);
-
+		EWearableType w_type = static_cast<EWearableType>(type);
+		LLPanelInventoryListItemBase* item_panel = LLPanelDummyClothingListItem::create(w_type);
+		if(!item_panel) continue;
+		mClothing->addItem(item_panel, LLUUID::null, ADD_BOTTOM, false);
 		addWearableTypeSeparator(mClothing);
 	}
 }

indra/newview/llinventoryitemslist.cpp

 
 void LLPanelInventoryListItemBase::updateItem()
 {
-	if (mItemIcon.notNull())
-		mIcon->setImage(mItemIcon);
-
-	LLTextUtil::textboxSetHighlightedVal(
-		mTitle,
-		LLStyle::Params(),
-		mItem->getName(),
-		mHighlightedText);
+	setIconImage(mIconImage);
+	setTitle(mItem->getName(), mHighlightedText);
 }
 
 void LLPanelInventoryListItemBase::addWidgetToLeftSide(const std::string& name, bool show_widget/* = true*/)
 
 BOOL LLPanelInventoryListItemBase::postBuild()
 {
-	// Inheritors need to call base implementation
-	mIcon = getChild<LLIconCtrl>("item_icon");
-	mTitle = getChild<LLTextBox>("item_name");
+	setIconCtrl(getChild<LLIconCtrl>("item_icon"));
+	setTitleCtrl(getChild<LLTextBox>("item_name"));
+
+	mIconImage = get_item_icon(mItem->getType(), mItem->getInventoryType(), mItem->getFlags(), FALSE);
 
 	updateItem();
 
 LLPanelInventoryListItemBase::LLPanelInventoryListItemBase(LLViewerInventoryItem* item)
 : LLPanel()
 , mItem(item)
-, mIcon(NULL)
-, mTitle(NULL)
+, mIconCtrl(NULL)
+, mTitleCtrl(NULL)
 , mWidgetSpacing(WIDGET_SPACING)
 , mLeftWidgetsWidth(0)
 , mRightWidgetsWidth(0)
 {
-	mItemIcon = get_item_icon(mItem->getType(), mItem->getInventoryType(), mItem->getFlags(), FALSE);
 }
 
 void LLPanelInventoryListItemBase::init()
 	reshapeMiddleWidgets();
 }
 
+void LLPanelInventoryListItemBase::setIconImage(const LLUIImagePtr& image)
+{
+	if(image)
+	{
+		mIconImage = image; 
+		mIconCtrl->setImage(mIconImage);
+	}
+}
+
+void LLPanelInventoryListItemBase::setTitle(const std::string& title, const std::string& highlit_text)
+{
+	LLTextUtil::textboxSetHighlightedVal(
+		mTitleCtrl,
+		LLStyle::Params(),
+		title,
+		highlit_text);
+}
+
 void LLPanelInventoryListItemBase::reshapeLeftWidgets()
 {
 	S32 widget_left = 0;
 
 void LLPanelInventoryListItemBase::reshapeMiddleWidgets()
 {
-	LLRect icon_rect(mIcon->getRect());
+	LLRect icon_rect(mIconCtrl->getRect());
 	icon_rect.setLeftTopAndSize(mLeftWidgetsWidth + getWidgetSpacing(), icon_rect.mTop, 
 		icon_rect.getWidth(), icon_rect.getHeight());
-	mIcon->setShape(icon_rect);
+	mIconCtrl->setShape(icon_rect);
 
 	S32 name_left = icon_rect.mRight + getWidgetSpacing();
 	S32 name_right = getLocalRect().getWidth() - mRightWidgetsWidth - getWidgetSpacing();
-	LLRect name_rect(mTitle->getRect());
+	LLRect name_rect(mTitleCtrl->getRect());
 	name_rect.set(name_left, name_rect.mTop, name_right, name_rect.mBottom);
-	mTitle->setShape(name_rect);
+	mTitleCtrl->setShape(name_rect);
 }
 
 ////////////////////////////////////////////////////////////////////////////////

indra/newview/llinventoryitemslist.h

 	 */
 	virtual void init();
 
+	/** setter for mIconCtrl */
+	void setIconCtrl(LLIconCtrl* icon) { mIconCtrl = icon; }
+	/** setter for MTitleCtrl */
+	void setTitleCtrl(LLTextBox* tb) { mTitleCtrl = tb; }
+
 	void setLeftWidgetsWidth(S32 width) { mLeftWidgetsWidth = width; }
 	void setRightWidgetsWidth(S32 width) { mRightWidgetsWidth = width; }
 
 	 */
 	virtual void reshapeWidgets();
 
+	/** set wearable type icon image */
+	void setIconImage(const LLUIImagePtr& image);
+
+	/** Set item title - inventory item name usually */
+	void setTitle(const std::string& title, const std::string& highlit_text);
+
 private:
 
 	/** reshape left side widgets
 
 	LLViewerInventoryItem* mItem;
 
-	LLIconCtrl*		mIcon;
-	LLTextBox*		mTitle;
+	LLIconCtrl*		mIconCtrl;
+	LLTextBox*		mTitleCtrl;
 
-	LLUIImagePtr	mItemIcon;
+	LLUIImagePtr	mIconImage;
 	std::string		mHighlightedText;
 
 	widget_array_t	mLeftSideWidgets;

indra/newview/llwearableitemslist.cpp

 
 #include "llwearableitemslist.h"
 
+#include "lliconctrl.h"
+
 #include "llinventoryfunctions.h"
 #include "llinventorymodel.h"
+#include "lltransutil.h"
 
 class LLFindOutfitItems : public LLInventoryCollectFunctor
 {
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 
+LLPanelDummyClothingListItem* LLPanelDummyClothingListItem::create(EWearableType w_type)
+{
+	LLPanelDummyClothingListItem* list_item = new LLPanelDummyClothingListItem(w_type);
+	list_item->init();
+	return list_item;
+}
+
+void LLPanelDummyClothingListItem::updateItem()
+{
+	std::string title = wearableTypeToString(mWearableType);
+	setTitle(title, LLStringUtil::null);
+}
+
+BOOL LLPanelDummyClothingListItem::postBuild()
+{
+	LLIconCtrl* icon = getChild<LLIconCtrl>("item_icon");
+	setIconCtrl(icon);
+	setTitleCtrl(getChild<LLTextBox>("item_name"));
+
+	addWidgetToRightSide("btn_add");
+
+	setIconImage(get_item_icon(LLAssetType::AT_CLOTHING, LLInventoryType::IT_NONE, mWearableType, FALSE));
+	updateItem();
+
+	// Make it look loke clothing item - reserve space for 'delete' button
+	setLeftWidgetsWidth(icon->getRect().mLeft);
+
+	setWidgetsVisible(false);
+	reshapeWidgets();
+
+	return TRUE;
+}
+
+LLPanelDummyClothingListItem::LLPanelDummyClothingListItem(EWearableType w_type)
+ : LLPanelWearableListItem(NULL)
+ , mWearableType(w_type)
+{
+}
+
+void LLPanelDummyClothingListItem::init()
+{
+	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_dummy_clothing_list_item.xml");
+}
+
+typedef std::map<EWearableType, std::string> clothing_to_string_map_t;
+
+clothing_to_string_map_t init_clothing_string_map()
+{
+	clothing_to_string_map_t w_map;
+	w_map.insert(std::make_pair(WT_SHIRT, "shirt_not_worn"));
+	w_map.insert(std::make_pair(WT_PANTS, "pants_not_worn"));
+	w_map.insert(std::make_pair(WT_SHOES, "shoes_not_worn"));
+	w_map.insert(std::make_pair(WT_SOCKS, "socks_not_worn"));
+	w_map.insert(std::make_pair(WT_JACKET, "jacket_not_worn"));
+	w_map.insert(std::make_pair(WT_GLOVES, "gloves_not_worn"));
+	w_map.insert(std::make_pair(WT_UNDERSHIRT, "undershirt_not_worn"));
+	w_map.insert(std::make_pair(WT_UNDERPANTS, "underpants_not_worn"));
+	w_map.insert(std::make_pair(WT_SKIRT, "skirt_not_worn"));
+	w_map.insert(std::make_pair(WT_ALPHA, "alpha_not_worn"));
+	w_map.insert(std::make_pair(WT_TATTOO, "tattoo_not_worn"));
+	return w_map;
+}
+
+std::string LLPanelDummyClothingListItem::wearableTypeToString(EWearableType w_type)
+{
+	static const clothing_to_string_map_t w_map = init_clothing_string_map();
+	static const std::string invalid_str = LLTrans::getString("invalid_not_worn");
+	
+	std::string type_str = invalid_str;
+	clothing_to_string_map_t::const_iterator it = w_map.find(w_type);
+	if(w_map.end() != it)
+	{
+		type_str = LLTrans::getString(it->second);
+	}
+	return type_str;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+
 static const LLDefaultChildRegistry::Register<LLWearableItemsList> r("wearable_items_list");
 
 LLWearableItemsList::Params::Params()

indra/newview/llwearableitemslist.h

 
 	virtual ~LLPanelClothingListItem();
 
-	/*virtual*/ void init();
 	/*virtual*/ BOOL postBuild();
 
 	/**
 protected:
 
 	LLPanelClothingListItem(LLViewerInventoryItem* item);
+	
+	/*virtual*/ void init();
 };
 
 class LLPanelBodyPartsListItem : public LLPanelWearableListItem
 
 	virtual ~LLPanelBodyPartsListItem();
 
-	/*virtual*/ void init();
 	/*virtual*/ BOOL postBuild();
 
 	/**
 
 protected:
 	LLPanelBodyPartsListItem(LLViewerInventoryItem* item);
+
+	/*virtual*/ void init();
+};
+
+/**
+ * @class LLPanelDummyClothingListItem
+ *
+ * A dummy item panel - displays grayed clothing icon, grayed title '<clothing> not worn' and 'add' button
+ */
+class LLPanelDummyClothingListItem : public LLPanelWearableListItem
+{
+public:
+	static LLPanelDummyClothingListItem* create(EWearableType w_type);
+
+	/*virtual*/ void updateItem();
+	/*virtual*/ BOOL postBuild();
+
+protected:
+	LLPanelDummyClothingListItem(EWearableType w_type);
+
+	/*virtual*/ void init();
+
+	static std::string wearableTypeToString(EWearableType w_type);
+
+private:
+	EWearableType mWearableType;
 };
 
 /**

indra/newview/skins/default/xui/en/panel_dummy_clothing_list_item.xml

+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel
+ follows="top|right|left"
+ height="20"
+ layout="topleft"
+ left="0"
+ name="dummy_clothing_item"
+ top="0"
+ width="380">
+    <icon
+     follows="top|right|left"
+     height="20"
+     image_name="ListItem_Over"
+     layout="topleft"
+     left="0"
+     name="hovered_icon"
+     top="0"
+     visible="false"
+     width="380" />
+    <icon
+     height="20"
+     follows="top|right|left"
+     image_name="ListItem_Select"
+     layout="topleft"
+     left="0"
+     name="selected_icon"
+     top="0"
+     visible="false"
+     width="380" />
+    <icon
+     height="16"
+     color="0.75 0.75 0.75 1"
+     follows="top|left"
+     image_name="Inv_Object"
+     layout="topleft"
+     left="20"
+     name="item_icon"
+     top="2"
+     width="16" />
+    <text
+     follows="left|right"
+     height="16"
+     layout="topleft"
+     left_pad="5"
+     allow_html="false"
+     use_ellipses="true"
+     name="item_name"
+     text_color="LtGray_50"
+     top="4"
+     value="..."
+     width="359" />
+    <button 
+     name="btn_add"
+     layout="topleft"
+     follows="top|right"
+     label="+"
+     top="0"
+     left="0"
+     height="20"
+     width="20"
+     tab_stop="false" />
+</panel>

indra/newview/skins/default/xui/en/strings.xml

 	<string name="alpha">Alpha</string>
 	<string name="tattoo">Tattoo</string>
 	<string name="invalid">invalid</string>
+  
+  <!-- Not Worn Wearable Types -->
+	<string name="shirt_not_worn">Shirt not worn</string>
+	<string name="pants_not_worn">Pants not worn</string>
+	<string name="shoes_not_worn">Shoes not worn</string>
+	<string name="socks_not_worn">Socks not worn</string>
+	<string name="jacket_not_worn">Jacket not worn</string>
+	<string name="gloves_not_worn">Gloves not worn</string>
+	<string name="undershirt_not_worn">Undershirt not worn</string>
+	<string name="underpants_not_worn">Underpants not worn</string>
+	<string name="skirt_not_worn">Skirt not worn</string>
+	<string name="alpha_not_worn">Alpha not worn</string>
+	<string name="tattoo_not_worn">Tattoo not worn</string>
+	<string name="invalid_not_worn">invalid</string>
 
   <!-- Wearable List-->
   <string name="NewWearable">New [WEARABLE_ITEM]</string>