summaryrefslogtreecommitdiff
path: root/indra/newview/llwearableitemslist.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-08-24 18:44:39 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-08-24 18:44:39 +0100
commit98cc2365034a93c69704daa69efb389799cc9627 (patch)
tree4c3ec75b78a26a736f18a2153af025040ae05a4b /indra/newview/llwearableitemslist.cpp
parent6ba23344c95157793af9e4154933ae8df61630e8 (diff)
Backed out changeset a62bf7c0af21
Backing out this merge that I pushed (prematurely) to the wrong place.
Diffstat (limited to 'indra/newview/llwearableitemslist.cpp')
-rw-r--r--indra/newview/llwearableitemslist.cpp150
1 files changed, 17 insertions, 133 deletions
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index a49dc1b59d..29d2745d6e 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -119,11 +119,7 @@ void LLPanelWearableOutfitItem::updateItem(const std::string& name,
{
std::string search_label = name;
- // Updating item's worn status depending on whether it is linked in COF or not.
- // We don't use get_is_item_worn() here because this update is triggered by
- // an inventory observer upon link in COF beind added or removed so actual
- // worn status of a linked item may still remain unchanged.
- if (mWornIndicationEnabled && LLAppearanceMgr::instance().isLinkInCOF(mInventoryItemUUID))
+ if (mWornIndicationEnabled && get_is_item_worn(mInventoryItemUUID))
{
search_label += LLTrans::getString("worn");
item_state = IS_WORN;
@@ -526,8 +522,6 @@ bool LLWearableItemTypeNameComparator::doCompare(const LLPanelInventoryListItemB
const LLWearableType::EType item_wearable_type2 = wearable_item2->getWearableType();
if (item_wearable_type1 != item_wearable_type2)
- // If items are of different LLWearableType::EType types they are compared
- // by LLWearableType::EType. types order determined in LLWearableType::EType.
{
// If items are of different LLWearableType::EType types they are compared
// by LLWearableType::EType. types order determined in LLWearableType::EType.
@@ -550,7 +544,6 @@ LLWearableItemTypeNameComparator::ETypeListOrder LLWearableItemTypeNameComparato
{
wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type);
-
if(const_it == mWearableOrder.end())
{
llwarns<<"Absent information about order rang of items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
@@ -564,54 +557,32 @@ bool LLWearableItemTypeNameComparator::sortAssetTypeByName(LLAssetType::EType it
{
wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type);
-
if(const_it == mWearableOrder.end())
{
llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
return true;
}
-
return const_it->second.mSortAssetTypeByName;
- }
-
+}
bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType item_type) const
{
wearable_type_order_map_t::const_iterator const_it = mWearableOrder.find(item_type);
-
if(const_it == mWearableOrder.end())
{
llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
return true;
-}
-
-
- return const_it->second.mSortWearableTypeByName;
-}
-
-/*virtual*/
-bool LLWearableItemCreationDateComparator::doCompare(const LLPanelInventoryListItemBase* item1, const LLPanelInventoryListItemBase* item2) const
-{
- time_t date1 = item1->getCreationDate();
- time_t date2 = item2->getCreationDate();
-
- if (date1 == date2)
- {
- return LLWearableItemNameComparator::doCompare(item1, item2);
}
- return date1 > date2;
+ return const_it->second.mSortWearableTypeByName;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-static LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
-static const LLWearableItemTypeNameComparator WEARABLE_TYPE_LAYER_COMPARATOR;
-static const LLWearableItemNameComparator WEARABLE_NAME_COMPARATOR;
-static const LLWearableItemCreationDateComparator WEARABLE_CREATION_DATE_COMPARATOR;
+static const LLWearableItemTypeNameComparator WEARABLE_TYPE_NAME_COMPARATOR;
static const LLDefaultChildRegistry::Register<LLWearableItemsList> r("wearable_items_list");
@@ -623,7 +594,7 @@ LLWearableItemsList::Params::Params()
LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p)
: LLInventoryItemsList(p)
{
- setSortOrder(E_SORT_BY_TYPE_LAYER, false);
+ setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
mIsStandalone = p.standalone;
if (mIsStandalone)
{
@@ -631,7 +602,6 @@ LLWearableItemsList::LLWearableItemsList(const LLWearableItemsList::Params& p)
setRightMouseDownCallback(boost::bind(&LLWearableItemsList::onRightClick, this, _2, _3));
}
mWornIndicationEnabled = p.worn_indication_enabled;
- setNoItemsCommentText(LLTrans::getString("LoadingData"));
}
// virtual
@@ -673,15 +643,10 @@ void LLWearableItemsList::updateList(const LLUUID& category_id)
LLInventoryModel::EXCLUDE_TRASH,
collector);
- if(item_array.empty() && gInventory.isCategoryComplete(category_id))
- {
- setNoItemsCommentText(LLTrans::getString("EmptyOutfitText"));
- }
-
refreshList(item_array);
}
-void LLWearableItemsList::updateChangedItems(const uuid_vec_t& changed_items_uuids)
+void LLWearableItemsList::updateChangedItems(const LLInventoryModel::changed_items_t& changed_items_uuids)
{
// nothing to update
if (changed_items_uuids.empty()) return;
@@ -703,7 +668,7 @@ void LLWearableItemsList::updateChangedItems(const uuid_vec_t& changed_items_uui
LLUUID linked_uuid = inv_item->getLinkedUUID();
- for (uuid_vec_t::const_iterator iter = changed_items_uuids.begin();
+ for (LLInventoryModel::changed_items_t::const_iterator iter = changed_items_uuids.begin();
iter != changed_items_uuids.end();
++iter)
{
@@ -729,38 +694,6 @@ void LLWearableItemsList::onRightClick(S32 x, S32 y)
ContextMenu::instance().show(this, selected_uuids, x, y);
}
-void LLWearableItemsList::setSortOrder(ESortOrder sort_order, bool sort_now)
-{
- switch (sort_order)
- {
- case E_SORT_BY_MOST_RECENT:
- setComparator(&WEARABLE_CREATION_DATE_COMPARATOR);
- break;
- case E_SORT_BY_NAME:
- setComparator(&WEARABLE_NAME_COMPARATOR);
- break;
- case E_SORT_BY_TYPE_LAYER:
- setComparator(&WEARABLE_TYPE_LAYER_COMPARATOR);
- break;
- case E_SORT_BY_TYPE_NAME:
- {
- WEARABLE_TYPE_NAME_COMPARATOR.setOrder(LLAssetType::AT_CLOTHING, LLWearableItemTypeNameComparator::ORDER_RANK_1, false, true);
- setComparator(&WEARABLE_TYPE_NAME_COMPARATOR);
- break;
- }
-
- // No "default:" to raise compiler warning
- // if we're not handling something
- }
-
- mSortOrder = sort_order;
-
- if (sort_now)
- {
- sort();
- }
-}
-
//////////////////////////////////////////////////////////////////////////
/// ContextMenu
//////////////////////////////////////////////////////////////////////////
@@ -831,8 +764,6 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
U32 n_links = 0; // number of links among the selected items
U32 n_editable = 0; // number of editable items among the selected ones
- bool can_be_worn = true;
-
for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
{
LLUUID id = *it;
@@ -868,22 +799,16 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
{
++n_already_worn;
}
-
- if (can_be_worn)
- {
- can_be_worn = get_can_item_be_worn(item->getLinkedUUID());
- }
} // for
bool standalone = mParent ? mParent->isStandalone() : false;
- bool wear_add_visible = mask & (MASK_CLOTHING|MASK_ATTACHMENT) && n_worn == 0 && can_be_worn && (n_already_worn != 0 || mask & MASK_ATTACHMENT);
// *TODO: eliminate multiple traversals over the menu items
- setMenuItemVisible(menu, "wear_wear", n_already_worn == 0 && n_worn == 0 && can_be_worn);
+ setMenuItemVisible(menu, "wear_wear", n_already_worn == 0 && n_worn == 0);
setMenuItemEnabled(menu, "wear_wear", n_already_worn == 0 && n_worn == 0);
- setMenuItemVisible(menu, "wear_add", wear_add_visible);
- setMenuItemEnabled(menu, "wear_add", canAddWearables(ids));
- setMenuItemVisible(menu, "wear_replace", n_worn == 0 && n_already_worn != 0 && can_be_worn);
+ setMenuItemVisible(menu, "wear_add", mask == MASK_CLOTHING && n_worn == 0 && n_already_worn != 0);
+ setMenuItemEnabled(menu, "wear_add", n_items == 1 && canAddWearable(ids.front()) && n_already_worn != 0);
+ setMenuItemVisible(menu, "wear_replace", n_worn == 0 && n_already_worn != 0);
//visible only when one item selected and this item is worn
setMenuItemVisible(menu, "edit", !standalone && mask & (MASK_CLOTHING|MASK_BODYPART) && n_worn == n_items && n_worn == 1);
setMenuItemEnabled(menu, "edit", n_editable == 1 && n_worn == 1 && n_items == 1);
@@ -991,61 +916,20 @@ void LLWearableItemsList::ContextMenu::createNewWearable(const LLUUID& item_id)
LLAgentWearables::createWearable(item->getWearableType(), true);
}
-// Returns true if all the given objects and clothes can be added.
+// Can we wear another wearable of the given item's wearable type?
// static
-bool LLWearableItemsList::ContextMenu::canAddWearables(const uuid_vec_t& item_ids)
+bool LLWearableItemsList::ContextMenu::canAddWearable(const LLUUID& item_id)
{
// TODO: investigate wearables may not be loaded at this point EXT-8231
- U32 n_objects = 0;
- boost::unordered_map<LLWearableType::EType, U32> clothes_by_type;
-
- // Count given clothes (by wearable type) and objects.
- for (uuid_vec_t::const_iterator it = item_ids.begin(); it != item_ids.end(); ++it)
- {
- LLViewerInventoryItem* item = gInventory.getItem(*it);
- if (!item)
- {
- return false;
- }
-
- if (item->getType() == LLAssetType::AT_OBJECT)
- {
- ++n_objects;
- }
- else if (item->getType() == LLAssetType::AT_CLOTHING)
- {
- ++clothes_by_type[item->getWearableType()];
- }
- else
- {
- llwarns << "Unexpected wearable type" << llendl;
- return false;
- }
- }
-
- // Check whether we can add all the objects.
- if (!isAgentAvatarValid() || !gAgentAvatarp->canAttachMoreObjects(n_objects))
+ LLViewerInventoryItem* item = gInventory.getItem(item_id);
+ if (!item || item->getType() != LLAssetType::AT_CLOTHING)
{
return false;
}
- // Check whether we can add all the clothes.
- boost::unordered_map<LLWearableType::EType, U32>::const_iterator m_it;
- for (m_it = clothes_by_type.begin(); m_it != clothes_by_type.end(); ++m_it)
- {
- LLWearableType::EType w_type = m_it->first;
- U32 n_clothes = m_it->second;
-
- U32 wearable_count = gAgentWearables.getWearableCount(w_type);
- if ((wearable_count + n_clothes) > LLAgentWearables::MAX_CLOTHING_PER_TYPE)
- {
- return false;
- }
-
- }
-
- return true;
+ U32 wearable_count = gAgentWearables.getWearableCount(item->getWearableType());
+ return wearable_count < LLAgentWearables::MAX_CLOTHING_PER_TYPE;
}
// EOF