diff options
author | Dave Parks <davep@lindenlab.com> | 2009-11-24 23:21:57 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2009-11-24 23:21:57 -0600 |
commit | e264f00c833805e1f813bc1d0b2cfd7a1bf7b272 (patch) | |
tree | 1a64a520502d2ed2c7dadc2316e543ae9e9a91d2 /indra/newview/llappearancemgr.cpp | |
parent | c9e153c182dae9472a2b87cddfec8c47b30b06b9 (diff) | |
parent | 5b5354c933aa7b1ceeb307853c24fba28d4e31bf (diff) |
Merge
Diffstat (limited to 'indra/newview/llappearancemgr.cpp')
-rw-r--r-- | indra/newview/llappearancemgr.cpp | 492 |
1 files changed, 139 insertions, 353 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index d14de1c301..1050deaa27 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -32,18 +32,20 @@ #include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llagentwearables.h" #include "llappearancemgr.h" -#include "llinventorymodel.h" -#include "llnotifications.h" +#include "llfloatercustomize.h" #include "llgesturemgr.h" #include "llinventorybridge.h" -#include "llwearablelist.h" -#include "llagentwearables.h" -#include "llagent.h" +#include "llinventoryobserver.h" +#include "llnotifications.h" +#include "llsidepanelappearance.h" +#include "llsidetray.h" #include "llvoavatar.h" #include "llvoavatarself.h" #include "llviewerregion.h" -#include "llfloatercustomize.h" +#include "llwearablelist.h" class LLWearInventoryCategoryCallback : public LLInventoryCallback { @@ -72,7 +74,7 @@ protected: // If the inventory callback manager goes away, we're shutting down, no longer want the callback. if( LLInventoryCallbackManager::is_instantiated() ) { - LLAppearanceManager::wearInventoryCategoryOnAvatar(gInventory.getCategory(mCatID), mAppend); + LLAppearanceManager::instance().wearInventoryCategoryOnAvatar(gInventory.getCategory(mCatID), mAppend); } else { @@ -94,7 +96,8 @@ public: mAppend(append) {} ~LLOutfitObserver() {} - virtual void done(); //public + virtual void done(); + void doWearCategory(); protected: LLUUID mCatID; @@ -104,6 +107,12 @@ protected: void LLOutfitObserver::done() { + gInventory.removeObserver(this); + doOnIdle(boost::bind(&LLOutfitObserver::doWearCategory,this)); +} + +void LLOutfitObserver::doWearCategory() +{ // We now have an outfit ready to be copied to agent inventory. Do // it, and wear that outfit normally. if(mCopyItems) @@ -171,8 +180,9 @@ void LLOutfitObserver::done() else { // Wear the inventory category. - LLAppearanceManager::wearInventoryCategoryOnAvatar(gInventory.getCategory(mCatID), mAppend); + LLAppearanceManager::instance().wearInventoryCategoryOnAvatar(gInventory.getCategory(mCatID), mAppend); } + delete this; } class LLOutfitFetch : public LLInventoryFetchDescendentsObserver @@ -220,7 +230,6 @@ void LLOutfitFetch::done() // loop. //dec_busy_count(); gInventory.removeObserver(this); - delete this; // increment busy count and either tell the inventory to check & // call done, or add this object to the inventory for observation. @@ -239,6 +248,7 @@ void LLOutfitFetch::done() // will call done for us when everything is here. gInventory.addObserver(outfit_observer); } + delete this; } class LLUpdateAppearanceOnDestroy: public LLInventoryCallback @@ -251,7 +261,7 @@ public: virtual ~LLUpdateAppearanceOnDestroy() { - LLAppearanceManager::updateAppearanceFromCOF(); + LLAppearanceManager::instance().updateAppearanceFromCOF(); } /* virtual */ void fire(const LLUUID& inv_item) @@ -296,7 +306,7 @@ struct LLWearableHoldingPattern bool append; }; -/* static */ void removeDuplicateItems(LLInventoryModel::item_array_t& items) +static void removeDuplicateItems(LLInventoryModel::item_array_t& items) { LLInventoryModel::item_array_t new_items; std::set<LLUUID> items_seen; @@ -323,175 +333,73 @@ struct LLWearableHoldingPattern items = new_items; } -void removeDuplicateItems(LLInventoryModel::item_array_t& dst, const LLInventoryModel::item_array_t& src) +static void onWearableAssetFetch(LLWearable* wearable, void* data) { - LLInventoryModel::item_array_t new_dst; - std::set<LLUUID> mark_inventory; - - S32 inventory_dups = 0; + LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data; + bool append = holder->append; - for (LLInventoryModel::item_array_t::const_iterator src_pos = src.begin(); - src_pos != src.end(); - ++src_pos) - { - LLUUID src_item_id = (*src_pos)->getLinkedUUID(); - mark_inventory.insert(src_item_id); - } - - for (LLInventoryModel::item_array_t::const_iterator dst_pos = dst.begin(); - dst_pos != dst.end(); - ++dst_pos) + if(wearable) { - LLUUID dst_item_id = (*dst_pos)->getLinkedUUID(); - - if (mark_inventory.find(dst_item_id) == mark_inventory.end()) - { - // Item is not already present in COF. - new_dst.put(*dst_pos); - mark_inventory.insert(dst_item_id); - } - else + for (LLWearableHoldingPattern::found_list_t::iterator iter = holder->mFoundList.begin(); + iter != holder->mFoundList.end(); ++iter) { - inventory_dups++; + LLFoundData* data = *iter; + if(wearable->getAssetID() == data->mAssetID) + { + data->mWearable = wearable; + break; + } } } - llinfos << "removeDups, original " << dst.count() << " final " << new_dst.count() - << " inventory dups " << inventory_dups << llendl; - - dst = new_dst; + holder->mResolved += 1; + if(holder->mResolved >= (S32)holder->mFoundList.size()) + { + LLAppearanceManager::instance().updateAgentWearables(holder, append); + } } -/* static */ LLUUID LLAppearanceManager::getCOF() { return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); } -// Update appearance from outfit folder. -/* static */ -void LLAppearanceManager::changeOutfit(bool proceed, const LLUUID& category, bool append) -{ - if (!proceed) - return; -#if 1 - updateCOF(category,append); -#else - if (append) - { - updateCOFFromCategory(category, append); // append is true - add non-duplicates to COF. - } - else +const LLViewerInventoryItem* LLAppearanceManager::getCurrentOutfitLink() +{ + const LLUUID& current_outfit_cat = getCOF(); + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + // Can't search on FT_OUTFIT since links to categories return FT_CATEGORY for type since they don't + // return preferred type. + LLIsType is_category( LLAssetType::AT_CATEGORY ); + gInventory.collectDescendentsIf(current_outfit_cat, + cat_array, + item_array, + false, + is_category, + false); + for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin(); + iter != item_array.end(); + iter++) { - LLViewerInventoryCategory* catp = gInventory.getCategory(category); - if (catp->getPreferredType() == LLFolderType::FT_NONE || - LLFolderType::lookupIsEnsembleType(catp->getPreferredType())) - { - updateCOFFromCategory(category, append); // append is false - rebuild COF. - } - else if (catp->getPreferredType() == LLFolderType::FT_OUTFIT) + const LLViewerInventoryItem *item = (*iter); + const LLViewerInventoryCategory *cat = item->getLinkedCategory(); + if (cat && cat->getPreferredType() == LLFolderType::FT_OUTFIT) { - rebuildCOFFromOutfit(category); + return item; } } -#endif + return NULL; } -// Append to current COF contents by recursively traversing a folder. -/* static */ -void LLAppearanceManager::updateCOFFromCategory(const LLUUID& category, bool append) +// Update appearance from outfit folder. +void LLAppearanceManager::changeOutfit(bool proceed, const LLUUID& category, bool append) { - // BAP consolidate into one "get all 3 types of descendents" function, use both places. - LLInventoryModel::item_array_t wear_items; - LLInventoryModel::item_array_t obj_items; - LLInventoryModel::item_array_t gest_items; - bool follow_folder_links = false; - getUserDescendents(category, wear_items, obj_items, gest_items, follow_folder_links); - - // Find all the wearables that are in the category's subtree. - lldebugs << "appendCOFFromCategory()" << llendl; - if( !wear_items.count() && !obj_items.count() && !gest_items.count()) - { - LLNotifications::instance().add("CouldNotPutOnOutfit"); + if (!proceed) return; - } - - const LLUUID current_outfit_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); - // Processes that take time should show the busy cursor - //inc_busy_count(); - - LLInventoryModel::cat_array_t cof_cats; - LLInventoryModel::item_array_t cof_items; - gInventory.collectDescendents(current_outfit_id, cof_cats, cof_items, - LLInventoryModel::EXCLUDE_TRASH); - // Remove duplicates - if (append) - { - removeDuplicateItems(wear_items, cof_items); - removeDuplicateItems(obj_items, cof_items); - removeDuplicateItems(gest_items, cof_items); - } - - S32 total_links = gest_items.count() + wear_items.count() + obj_items.count(); - - if (!append && total_links > 0) - { - purgeCOFBeforeRebuild(category); - } - - LLPointer<LLUpdateAppearanceOnDestroy> link_waiter = new LLUpdateAppearanceOnDestroy; - - // Link all gestures in this folder - if (gest_items.count() > 0) - { - llinfos << "Linking " << gest_items.count() << " gestures" << llendl; - for (S32 i = 0; i < gest_items.count(); ++i) - { - const LLInventoryItem* gest_item = gest_items.get(i).get(); - link_inventory_item(gAgent.getID(), gest_item->getLinkedUUID(), current_outfit_id, - gest_item->getName(), - LLAssetType::AT_LINK, link_waiter); - } - } - - // Link all wearables - if(wear_items.count() > 0) - { - llinfos << "Linking " << wear_items.count() << " wearables" << llendl; - for(S32 i = 0; i < wear_items.count(); ++i) - { - // Populate the current outfit folder with links to the newly added wearables - const LLInventoryItem* wear_item = wear_items.get(i).get(); - link_inventory_item(gAgent.getID(), - wear_item->getLinkedUUID(), // If this item is a link, then we'll use the linked item's UUID. - current_outfit_id, - wear_item->getName(), - LLAssetType::AT_LINK, - link_waiter); - } - } - - // Link all attachments. - if( obj_items.count() > 0 ) - { - llinfos << "Linking " << obj_items.count() << " attachments" << llendl; - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if( avatar ) - { - for(S32 i = 0; i < obj_items.count(); ++i) - { - const LLInventoryItem* obj_item = obj_items.get(i).get(); - link_inventory_item(gAgent.getID(), - obj_item->getLinkedUUID(), // If this item is a link, then we'll use the linked item's UUID. - current_outfit_id, - obj_item->getName(), - LLAssetType::AT_LINK, link_waiter); - } - } - } + LLAppearanceManager::instance().updateCOF(category,append); } -/* static */ void LLAppearanceManager::shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id, LLPointer<LLInventoryCallback> cb) { @@ -535,7 +443,8 @@ void LLAppearanceManager::shallowCopyCategory(const LLUUID& src_id, const LLUUID } } } -/* static */ void LLAppearanceManager::purgeCategory(const LLUUID& category, bool keep_outfit_links) + +void LLAppearanceManager::purgeCategory(const LLUUID& category, bool keep_outfit_links) { LLInventoryModel::cat_array_t cats; LLInventoryModel::item_array_t items; @@ -552,7 +461,7 @@ void LLAppearanceManager::shallowCopyCategory(const LLUUID& src_id, const LLUUID // Keep the last N wearables of each type. For viewer 2.0, N is 1 for // both body parts and clothing items. -/* static */ void LLAppearanceManager::filterWearableItems( +void LLAppearanceManager::filterWearableItems( LLInventoryModel::item_array_t& items, S32 max_per_type) { // Divvy items into arrays by wearable type. @@ -583,9 +492,9 @@ void LLAppearanceManager::shallowCopyCategory(const LLUUID& src_id, const LLUUID } // Create links to all listed items. -/* static */ void LLAppearanceManager::linkAll(const LLUUID& category, - LLInventoryModel::item_array_t& items, - LLPointer<LLInventoryCallback> cb) +void LLAppearanceManager::linkAll(const LLUUID& category, + LLInventoryModel::item_array_t& items, + LLPointer<LLInventoryCallback> cb) { for (S32 i=0; i<items.count(); i++) { @@ -599,7 +508,7 @@ void LLAppearanceManager::shallowCopyCategory(const LLUUID& src_id, const LLUUID } } -/* static */ void LLAppearanceManager::updateCOF(const LLUUID& category, bool append) +void LLAppearanceManager::updateCOF(const LLUUID& category, bool append) { const LLUUID cof = getCOF(); @@ -651,150 +560,30 @@ void LLAppearanceManager::shallowCopyCategory(const LLUUID& src_id, const LLUUID linkAll(cof, gest_items, link_waiter); // Add link to outfit if category is an outfit. - LLViewerInventoryCategory* catp = gInventory.getCategory(category); + const LLViewerInventoryCategory* catp = gInventory.getCategory(category); + LLSidepanelAppearance* panel_appearance = dynamic_cast<LLSidepanelAppearance *>(LLSideTray::getInstance()->getPanel("sidepanel_appearance")); + if (!append && catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) { link_inventory_item(gAgent.getID(), category, cof, catp->getName(), LLAssetType::AT_LINK_FOLDER, link_waiter); - } - -} - -/* static */ -bool LLAppearanceManager::isMandatoryWearableType(EWearableType type) -{ - return (type==WT_SHAPE) || (type==WT_SKIN) || (type== WT_HAIR) || (type==WT_EYES); -} - -// For mandatory body parts. -/* static */ -void LLAppearanceManager::checkMandatoryWearableTypes(const LLUUID& category, std::set<EWearableType>& types_found) -{ - LLInventoryModel::cat_array_t new_cats; - LLInventoryModel::item_array_t new_items; - gInventory.collectDescendents(category, new_cats, new_items, - LLInventoryModel::EXCLUDE_TRASH); - std::set<EWearableType> wt_types_found; - for (S32 i = 0; i < new_items.count(); ++i) - { - LLViewerInventoryItem *itemp = new_items.get(i); - if (itemp->isWearableType()) - { - EWearableType type = itemp->getWearableType(); - if (isMandatoryWearableType(type)) - { - types_found.insert(type); - } - } - } -} -// Remove everything from the COF that we safely can before replacing -// with contents of new category. This means preserving any mandatory -// body parts that aren't present in the new category, and getting rid -// of everything else. -/* static */ -void LLAppearanceManager::purgeCOFBeforeRebuild(const LLUUID& category) -{ - // See which mandatory body types are present in the new category. - std::set<EWearableType> wt_types_found; - checkMandatoryWearableTypes(category,wt_types_found); - - LLInventoryModel::cat_array_t cof_cats; - LLInventoryModel::item_array_t cof_items; - gInventory.collectDescendents(getCOF(), cof_cats, cof_items, - LLInventoryModel::EXCLUDE_TRASH); - for (S32 i = 0; i < cof_items.count(); ++i) - { - LLViewerInventoryItem *itemp = cof_items.get(i); - if (itemp->isWearableType()) + // Update the current outfit name of the appearance sidepanel. + if (panel_appearance) { - EWearableType type = itemp->getWearableType(); - if (!isMandatoryWearableType(type) || (wt_types_found.find(type) != wt_types_found.end())) - { - // Not mandatory or supplied by the new category - OK to delete - gInventory.purgeObject(cof_items.get(i)->getUUID()); - } + panel_appearance->refreshCurrentOutfitName(catp->getName()); } - else - { - // Not a wearable - always purge - gInventory.purgeObject(cof_items.get(i)->getUUID()); - } - } - gInventory.notifyObservers(); -} - -// Replace COF contents from a given outfit folder. -/* static */ -void LLAppearanceManager::rebuildCOFFromOutfit(const LLUUID& category) -{ - lldebugs << "rebuildCOFFromOutfit()" << llendl; - - dumpCat(category,"start, source outfit"); - dumpCat(getCOF(),"start, COF"); - - // Find all the wearables that are in the category's subtree. - LLInventoryModel::item_array_t items; - getCOFValidDescendents(category, items); - - if( items.count() == 0) - { - LLNotifications::instance().add("CouldNotPutOnOutfit"); - return; - } - - // Processes that take time should show the busy cursor - //inc_busy_count(); - - //dumpCat(current_outfit_id,"COF before remove:"); - - //dumpCat(current_outfit_id,"COF after remove:"); - - purgeCOFBeforeRebuild(category); - - LLPointer<LLInventoryCallback> link_waiter = new LLUpdateAppearanceOnDestroy; - LLUUID current_outfit_id = getCOF(); - LLAppearanceManager::shallowCopyCategory(category, current_outfit_id, link_waiter); - - //dumpCat(current_outfit_id,"COF after shallow copy:"); - - // Create a link to the outfit that we wore. - LLViewerInventoryCategory* catp = gInventory.getCategory(category); - if (catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) - { - link_inventory_item(gAgent.getID(), category, current_outfit_id, catp->getName(), - LLAssetType::AT_LINK_FOLDER, link_waiter); } -} - -/* static */ -void LLAppearanceManager::onWearableAssetFetch(LLWearable* wearable, void* data) -{ - LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data; - bool append = holder->append; - - if(wearable) + else { - for (LLWearableHoldingPattern::found_list_t::iterator iter = holder->mFoundList.begin(); - iter != holder->mFoundList.end(); ++iter) + // Update the current outfit name of the appearance sidepanel. + if (panel_appearance) { - LLFoundData* data = *iter; - if(wearable->getAssetID() == data->mAssetID) - { - data->mWearable = wearable; - break; - } + panel_appearance->refreshCurrentOutfitName(); } } - holder->mResolved += 1; - if(holder->mResolved >= (S32)holder->mFoundList.size()) - { - LLAppearanceManager::updateAgentWearables(holder, append); - } } -/* static */ void LLAppearanceManager::updateAgentWearables(LLWearableHoldingPattern* holder, bool append) { lldebugs << "updateAgentWearables()" << llendl; @@ -827,7 +616,6 @@ void LLAppearanceManager::updateAgentWearables(LLWearableHoldingPattern* holder, if(wearables.count() > 0) { gAgentWearables.setWearableOutfit(items, wearables, !append); - gInventory.notifyObservers(); } delete holder; @@ -835,7 +623,6 @@ void LLAppearanceManager::updateAgentWearables(LLWearableHoldingPattern* holder, // dec_busy_count(); } -/* static */ void LLAppearanceManager::updateAppearanceFromCOF() { dumpCat(getCOF(),"COF, start"); @@ -903,7 +690,7 @@ void LLAppearanceManager::updateAppearanceFromCOF() LLWearableList::instance().getAsset(found->mAssetID, found->mName, found->mAssetType, - LLAppearanceManager::onWearableAssetFetch, + onWearableAssetFetch, (void*)holder); } } @@ -916,22 +703,6 @@ void LLAppearanceManager::updateAppearanceFromCOF() } } -/* static */ -void LLAppearanceManager::getCOFValidDescendents(const LLUUID& category, - LLInventoryModel::item_array_t& items) -{ - LLInventoryModel::cat_array_t cats; - LLFindCOFValidItems is_cof_valid; - bool follow_folder_links = false; - gInventory.collectDescendentsIf(category, - cats, - items, - LLInventoryModel::EXCLUDE_TRASH, - is_cof_valid, - follow_folder_links); -} - -/* static */ void LLAppearanceManager::getDescendentsOfAssetType(const LLUUID& category, LLInventoryModel::item_array_t& items, LLAssetType::EType type, @@ -947,7 +718,6 @@ void LLAppearanceManager::getDescendentsOfAssetType(const LLUUID& category, follow_folder_links); } -/* static */ void LLAppearanceManager::getUserDescendents(const LLUUID& category, LLInventoryModel::item_array_t& wear_items, LLInventoryModel::item_array_t& obj_items, @@ -1011,7 +781,6 @@ void LLAppearanceManager::wearInventoryCategory(LLInventoryCategory* category, b } // *NOTE: hack to get from avatar inventory to avatar -/* static */ void LLAppearanceManager::wearInventoryCategoryOnAvatar( LLInventoryCategory* category, bool append ) { // Avoid unintentionally overwriting old wearables. We have to do @@ -1023,7 +792,9 @@ void LLAppearanceManager::wearInventoryCategoryOnAvatar( LLInventoryCategory* ca if( gFloaterCustomize ) { - gFloaterCustomize->askToSaveIfDirty(boost::bind(LLAppearanceManager::changeOutfit, _1, category->getUUID(), append)); + gFloaterCustomize->askToSaveIfDirty(boost::bind(&LLAppearanceManager::changeOutfit, + &LLAppearanceManager::instance(), + _1, category->getUUID(), append)); } else { @@ -1031,7 +802,6 @@ void LLAppearanceManager::wearInventoryCategoryOnAvatar( LLInventoryCategory* ca } } -/* static */ void LLAppearanceManager::wearOutfitByName(const std::string& name) { llinfos << "Wearing category " << name << llendl; @@ -1084,16 +854,24 @@ bool areMatchingWearables(const LLViewerInventoryItem *a, const LLViewerInventor return (a->isWearableType() && b->isWearableType() && (a->getWearableType() == b->getWearableType())); } -/* static */ -void LLAppearanceManager::wearItem( LLInventoryItem* item, bool do_update ) + +void LLAppearanceManager::addCOFItemLink(const LLUUID &item_id, bool do_update ) { - LLViewerInventoryItem *vitem = dynamic_cast<LLViewerInventoryItem*>(item); + const LLInventoryItem *item = gInventory.getItem(item_id); + addCOFItemLink(item); +} + +void LLAppearanceManager::addCOFItemLink(const LLInventoryItem *item, bool do_update ) +{ + const LLViewerInventoryItem *vitem = dynamic_cast<const LLViewerInventoryItem*>(item); if (!vitem) { llwarns << "not an llviewerinventoryitem, failed" << llendl; return; } - + + gInventory.addChangedMask(LLInventoryObserver::LABEL, vitem->getLinkedUUID()); + LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t item_array; gInventory.collectDescendents(LLAppearanceManager::getCOF(), @@ -1105,7 +883,7 @@ void LLAppearanceManager::wearItem( LLInventoryItem* item, bool do_update ) { // Are these links to the same object? const LLViewerInventoryItem* inv_item = item_array.get(i).get(); - if (inv_item->getLinkedUUID() == item->getLinkedUUID()) + if (inv_item->getLinkedUUID() == vitem->getLinkedUUID()) { linked_already = true; } @@ -1116,13 +894,13 @@ void LLAppearanceManager::wearItem( LLInventoryItem* item, bool do_update ) { gAgentWearables.removeWearable(inv_item->getWearableType(),true,0); gInventory.purgeObject(inv_item->getUUID()); - gInventory.notifyObservers(); } } if (linked_already) { if (do_update) LLAppearanceManager::updateAppearanceFromCOF(); + return; } else { @@ -1134,10 +912,10 @@ void LLAppearanceManager::wearItem( LLInventoryItem* item, bool do_update ) LLAssetType::AT_LINK, cb); } + return; } -/* static */ -void LLAppearanceManager::wearEnsemble( LLInventoryCategory* cat, bool do_update ) +void LLAppearanceManager::addEnsembleLink( LLInventoryCategory* cat, bool do_update ) { #if SUPPORT_ENSEMBLES // BAP add check for already in COF. @@ -1151,9 +929,10 @@ void LLAppearanceManager::wearEnsemble( LLInventoryCategory* cat, bool do_update #endif } -/* static */ -void LLAppearanceManager::removeItemLinks(const LLUUID& item_id, bool do_update) +void LLAppearanceManager::removeCOFItemLinks(const LLUUID& item_id, bool do_update) { + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t item_array; gInventory.collectDescendents(LLAppearanceManager::getCOF(), @@ -1165,7 +944,8 @@ void LLAppearanceManager::removeItemLinks(const LLUUID& item_id, bool do_update) const LLInventoryItem* item = item_array.get(i).get(); if (item->getLinkedUUID() == item_id) { - gInventory.purgeObject(item_array.get(i)->getUUID()); + const LLUUID& item_id = item_array.get(i)->getUUID(); + gInventory.purgeObject(item_id); } } if (do_update) @@ -1176,7 +956,6 @@ void LLAppearanceManager::removeItemLinks(const LLUUID& item_id, bool do_update) //#define DUMP_CAT_VERBOSE -/* static */ void LLAppearanceManager::dumpCat(const LLUUID& cat_id, const std::string& msg) { LLInventoryModel::cat_array_t cats; @@ -1198,7 +977,6 @@ void LLAppearanceManager::dumpCat(const LLUUID& cat_id, const std::string& msg) llinfos << msg << " count " << items.count() << llendl; } -/* static */ void LLAppearanceManager::dumpItemArray(const LLInventoryModel::item_array_t& items, const std::string& msg) { @@ -1211,15 +989,19 @@ void LLAppearanceManager::dumpItemArray(const LLInventoryModel::item_array_t& it llinfos << llendl; } +LLAppearanceManager::LLAppearanceManager(): + mAttachmentInvLinkEnabled(false) +{ +} -std::set<LLUUID> LLAppearanceManager::sRegisteredAttachments; -bool LLAppearanceManager::sAttachmentInvLinkEnabled(false); +LLAppearanceManager::~LLAppearanceManager() +{ +} -/* static */ void LLAppearanceManager::setAttachmentInvLinkEnable(bool val) { llinfos << "setAttachmentInvLinkEnable => " << (int) val << llendl; - sAttachmentInvLinkEnabled = val; + mAttachmentInvLinkEnabled = val; } void dumpAttachmentSet(const std::set<LLUUID>& atts, const std::string& msg) @@ -1239,22 +1021,16 @@ void dumpAttachmentSet(const std::set<LLUUID>& atts, const std::string& msg) llinfos << llendl; } -/* static */ void LLAppearanceManager::registerAttachment(const LLUUID& item_id) { - sRegisteredAttachments.insert(item_id); - //dumpAttachmentSet(sRegisteredAttachments,"after register:"); + mRegisteredAttachments.insert(item_id); + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + //dumpAttachmentSet(mRegisteredAttachments,"after register:"); - if (sAttachmentInvLinkEnabled) + if (mAttachmentInvLinkEnabled) { - LLViewerInventoryItem *item = gInventory.getItem(item_id); - if (item) - { - //LLAppearanceManager::dumpCat(LLAppearanceManager::getCOF(),"Adding attachment link:"); - LLAppearanceManager::wearItem(item,false); // Add COF link for item. - gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); - gInventory.notifyObservers(); - } + //LLAppearanceManager::dumpCat(LLAppearanceManager::getCOF(),"Adding attachment link:"); + LLAppearanceManager::addCOFItemLink(item_id, false); // Add COF link for item. } else { @@ -1262,22 +1038,32 @@ void LLAppearanceManager::registerAttachment(const LLUUID& item_id) } } -/* static */ void LLAppearanceManager::unregisterAttachment(const LLUUID& item_id) { - sRegisteredAttachments.erase(item_id); - //dumpAttachmentSet(sRegisteredAttachments,"after unregister:"); + mRegisteredAttachments.erase(item_id); + gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + + //dumpAttachmentSet(mRegisteredAttachments,"after unregister:"); - if (sAttachmentInvLinkEnabled) + if (mAttachmentInvLinkEnabled) { //LLAppearanceManager::dumpCat(LLAppearanceManager::getCOF(),"Removing attachment link:"); - LLAppearanceManager::removeItemLinks(item_id, false); - // BAP - needs to change for label to track link. - gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); - gInventory.notifyObservers(); + LLAppearanceManager::removeCOFItemLinks(item_id, false); } else { //llinfos << "no link changes, inv link not enabled" << llendl; } } + +void LLAppearanceManager::linkRegisteredAttachments() +{ + for (std::set<LLUUID>::iterator it = mRegisteredAttachments.begin(); + it != mRegisteredAttachments.end(); + ++it) + { + LLUUID item_id = *it; + addCOFItemLink(item_id, false); + } + mRegisteredAttachments.clear(); +} |