Skip to content
Snippets Groups Projects
Commit 8d18056e authored by Monroe Linden's avatar Monroe Linden
Browse files

Fix for EXT-8025 ('+' button on My Appearance > Edit Outfit panel does nothing)

Button now gets disabled in the early-exit case in LLPanelOutfitEdit::onInventorySelectionChange().

onInventorySelectionChange() also uses the new predicate get_can_item_be_worn(), which both checks whether the item is already being worn and whether it's of a type that could be worn.

Reviewed by Nyx at http://codereview.lindenlab.com/2451030 .
parent af488c97
No related branches found
No related tags found
No related merge requests found
...@@ -245,6 +245,47 @@ BOOL get_is_item_worn(const LLUUID& id) ...@@ -245,6 +245,47 @@ BOOL get_is_item_worn(const LLUUID& id)
return FALSE; return FALSE;
} }
BOOL get_can_item_be_worn(const LLUUID& id)
{
const LLViewerInventoryItem* item = gInventory.getItem(id);
if (!item)
return FALSE;
switch(item->getType())
{
case LLAssetType::AT_OBJECT:
{
if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(item->getLinkedUUID()))
{
// Already being worn
return FALSE;
}
else
{
// Not being worn yet.
return TRUE;
}
break;
}
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_CLOTHING:
if(gAgentWearables.isWearingItem(item->getLinkedUUID()))
{
// Already being worn
return FALSE;
}
else
{
// Not being worn yet.
return TRUE;
}
break;
default:
break;
}
return FALSE;
}
BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id) BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id)
{ {
if (!model) if (!model)
......
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
// Is this item or its baseitem is worn, attached, etc... // Is this item or its baseitem is worn, attached, etc...
BOOL get_is_item_worn(const LLUUID& id); BOOL get_is_item_worn(const LLUUID& id);
// Could this item be worn (correct type + not already being worn)
BOOL get_can_item_be_worn(const LLUUID& id);
BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id); BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id);
BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id); BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id);
......
...@@ -661,10 +661,13 @@ void LLPanelOutfitEdit::onInventorySelectionChange() ...@@ -661,10 +661,13 @@ void LLPanelOutfitEdit::onInventorySelectionChange()
getSelectedItemsUUID(selected_items); getSelectedItemsUUID(selected_items);
if (selected_items.empty()) if (selected_items.empty())
{ {
mPlusBtn->setEnabled(false);
return; return;
} }
uuid_vec_t::iterator worn_item = std::find_if(selected_items.begin(), selected_items.end(), boost::bind(&get_is_item_worn, _1));
bool can_add = ( worn_item == selected_items.end() ); // If any of the selected items are not wearable (due to already being worn OR being of the wrong type), disable the add button.
uuid_vec_t::iterator unwearable_item = std::find_if(selected_items.begin(), selected_items.end(), !boost::bind(& get_can_item_be_worn, _1));
bool can_add = ( unwearable_item == selected_items.end() );
mPlusBtn->setEnabled(can_add); mPlusBtn->setEnabled(can_add);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment