Skip to content
Snippets Groups Projects
Commit 63029655 authored by Vadim Savchuk's avatar Vadim Savchuk
Browse files

EXT-7747 FIXED Disable the "Add" item of wearable context menu when it's inappropriate.

The "Add" item of wearable context menu is now disabled if multiple clothes selected
or when you can't add more wearables of the given type (max number is worn).

Reviewed by Nyx at https://codereview.productengine.com/secondlife/r/595/

--HG--
branch : product-engine
parent 81e2aad3
No related branches found
No related tags found
No related merge requests found
...@@ -647,6 +647,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu ...@@ -647,6 +647,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
// *TODO: eliminate multiple traversals over the menu items // *TODO: eliminate multiple traversals over the menu items
setMenuItemVisible(menu, "wear_add", mask == MASK_CLOTHING && n_worn == 0); setMenuItemVisible(menu, "wear_add", mask == MASK_CLOTHING && n_worn == 0);
setMenuItemEnabled(menu, "wear_add", n_items == 1 && canAddWearable(ids.front()));
setMenuItemVisible(menu, "wear", n_worn == 0); setMenuItemVisible(menu, "wear", n_worn == 0);
setMenuItemVisible(menu, "edit", !standalone && mask & (MASK_CLOTHING|MASK_BODYPART)); setMenuItemVisible(menu, "edit", !standalone && mask & (MASK_CLOTHING|MASK_BODYPART));
setMenuItemEnabled(menu, "edit", n_editable == 1 && n_worn == 1 && n_items == 1); setMenuItemEnabled(menu, "edit", n_editable == 1 && n_worn == 1 && n_items == 1);
...@@ -740,4 +741,23 @@ void LLWearableItemsList::ContextMenu::createNewWearable(const LLUUID& item_id) ...@@ -740,4 +741,23 @@ void LLWearableItemsList::ContextMenu::createNewWearable(const LLUUID& item_id)
LLAgentWearables::createWearable(item->getWearableType(), true); LLAgentWearables::createWearable(item->getWearableType(), true);
} }
// Can we wear another wearable of the given item's wearable type?
// static
bool LLWearableItemsList::ContextMenu::canAddWearable(const LLUUID& item_id)
{
if (!gAgentWearables.areWearablesLoaded())
{
return false;
}
LLViewerInventoryItem* item = gInventory.getItem(item_id);
if (!item || item->getType() != LLAssetType::AT_CLOTHING)
{
return false;
}
U32 wearable_count = gAgentWearables.getWearableCount(item->getWearableType());
return wearable_count < LLAgentWearables::MAX_CLOTHING_PER_TYPE;
}
// EOF // EOF
...@@ -342,6 +342,7 @@ class LLWearableItemsList : public LLInventoryItemsList ...@@ -342,6 +342,7 @@ class LLWearableItemsList : public LLInventoryItemsList
static void setMenuItemEnabled(LLContextMenu* menu, const std::string& name, bool val); static void setMenuItemEnabled(LLContextMenu* menu, const std::string& name, bool val);
static void updateMask(U32& mask, LLAssetType::EType at); static void updateMask(U32& mask, LLAssetType::EType at);
static void createNewWearable(const LLUUID& item_id); static void createNewWearable(const LLUUID& item_id);
static bool canAddWearable(const LLUUID& item_id);
LLWearableItemsList* mParent; LLWearableItemsList* mParent;
}; };
......
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