diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-06-29 16:09:08 -0400 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-06-29 16:09:08 -0400 |
commit | 125b789239b5adb5f810b3586a95f5d5f8a17c40 (patch) | |
tree | 9650173fc466d363a9092722d04456c15b078f8d /indra/newview/llinventoryfunctions.cpp | |
parent | 17d2a3b9fb24ea56eb5e70007a2502bbef436a65 (diff) | |
parent | 33065ed28835f17aed22bd0d5f742bc5bb76e1a4 (diff) |
merge
Diffstat (limited to 'indra/newview/llinventoryfunctions.cpp')
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 37088064c6..7463658003 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -245,6 +245,47 @@ BOOL get_is_item_worn(const LLUUID& id) 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) { if (!model) @@ -282,7 +323,9 @@ BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id) BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id) { - // This function doesn't check the folder's children. + // NOTE: This function doesn't check the folder's children. + // See LLFolderBridge::isItemRemovable for a function that does + // consider the children. if (!model) { @@ -296,17 +339,29 @@ BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id) if (!isAgentAvatarValid()) return FALSE; - LLInventoryCategory* category = model->getCategory(id); + const LLInventoryCategory* category = model->getCategory(id); if (!category) { return FALSE; } - if (LLFolderType::lookupIsProtectedType(category->getPreferredType())) + const LLFolderType::EType folder_type = category->getPreferredType(); + + if (LLFolderType::lookupIsProtectedType(folder_type)) { return FALSE; } + // Can't delete the outfit that is currently being worn. + if (folder_type == LLFolderType::FT_OUTFIT) + { + const LLViewerInventoryItem *base_outfit_link = LLAppearanceMgr::instance().getBaseOutfitLink(); + if (base_outfit_link && (category == base_outfit_link->getLinkedCategory())) + { + return FALSE; + } + } + return TRUE; } |