// Sub-classes should override this function if they allow editing void LLPreview::onCommit() { const LLViewerInventoryItem *item = getItem(); if(item) { if (!item->isComplete()) { // We are attempting to save an item that was never loaded llwarns << "LLPreview::onCommit() called with mIsComplete == FALSE" << " Type: " << item->getType() << " ID: " << item->getUUID() << llendl; return; } LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); new_item->setDescription(childGetText("desc")); if(mObjectUUID.notNull()) { // must be in an object LLViewerObject* object = gObjectList.findObject(mObjectUUID); if(object) { object->updateInventory( new_item, TASK_INVENTORY_ITEM_KEY, false); } } else if(item->getPermissions().getOwner() == gAgent.getID()) { new_item->updateServer(FALSE); gInventory.updateItem(new_item); gInventory.notifyObservers(); // If the item is an attachment that is currently being worn, // update the object itself. if( item->getType() == LLAssetType::AT_OBJECT ) { LLVOAvatar* avatar = gAgent.getAvatarObject(); if( avatar ) { LLViewerObject* obj = avatar->getWornAttachment( item->getUUID() ); if( obj ) { LLSelectMgr::getInstance()->deselectAll(); LLSelectMgr::getInstance()->addAsIndividual( obj, SELECT_ALL_TES, FALSE ); LLSelectMgr::getInstance()->selectionSetObjectDescription( childGetText("desc") ); LLSelectMgr::getInstance()->deselectAll(); } } } } } }
// Checked: 2010-03-21 (RLVa-1.1.3a) | Modified: RLVa-1.2.0a void RlvForceWear::forceFolder(const LLViewerInventoryCategory* pFolder, EWearAction eAction, EWearFlags eFlags) { // [See LLWearableBridge::wearOnAvatar(): don't wear anything until initial wearables are loaded, can destroy clothing items] if (!gAgent.areWearablesLoaded()) { LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); return; } LLVOAvatar* pAvatar = gAgent.getAvatarObject(); if (!pAvatar) return; // Grab a list of all the items we'll be wearing/attaching LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; RlvWearableItemCollector f(pFolder, eAction, eFlags); gInventory.collectDescendentsIf(pFolder->getUUID(), folders, items, FALSE, f, TRUE); EWearAction eCurAction = eAction; for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++) { LLViewerInventoryItem* pRlvItem = items.get(idxItem); LLViewerInventoryItem* pItem = (LLAssetType::AT_LINK == pRlvItem->getActualType()) ? pRlvItem->getLinkedItem() : pRlvItem; // If it's wearable it should be worn on detach // if ( (ACTION_DETACH == eAction) && (isWearableItem(pItem)) && (!isWearingItem(pItem)) ) // continue; // Each folder can specify its own EWearAction override if (isWearAction(eAction)) eCurAction = f.getWearAction(pRlvItem->getParentUUID()); // NOTES: * if there are composite items then RlvWearableItemCollector made sure they can be worn (or taken off depending) // * some scripts issue @remattach=force,attach:worn-items=force so we need to attach items even if they're currently worn switch (pItem->getType()) { case LLAssetType::AT_BODYPART: RLV_ASSERT(isWearAction(eAction)); // RlvWearableItemCollector shouldn't be supplying us with body parts on detach case LLAssetType::AT_CLOTHING: if (isWearAction(eAction)) { ERlvWearMask eWearMask = gRlvWearableLocks.canWear(pRlvItem); if ( ((ACTION_WEAR_REPLACE == eCurAction) && (eWearMask & RLV_WEAR_REPLACE)) || ((ACTION_WEAR_ADD == eCurAction) && (eWearMask & RLV_WEAR_ADD)) ) { // The check for whether we're replacing a currently worn composite item happens in onWearableArrived() if (!isAddWearable(pItem)) addWearable(pRlvItem, eCurAction); } } else { const LLWearable* pWearable = gAgent.getWearableFromWearableItem(pItem->getUUID()); if ( (pWearable) && (isForceRemovable(pWearable, false)) ) remWearable(pWearable); } break; case LLAssetType::AT_OBJECT: if (isWearAction(eAction)) { ERlvWearMask eWearMask = gRlvAttachmentLocks.canAttach(pRlvItem); if ( ((ACTION_WEAR_REPLACE == eCurAction) && (eWearMask & RLV_WEAR_REPLACE)) || ((ACTION_WEAR_ADD == eCurAction) && (eWearMask & RLV_WEAR_ADD)) ) { if (!isAddAttachment(pRlvItem)) { #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS // We still need to check whether we're about to replace a currently worn composite item // (which we're not if we're just reattaching an attachment we're already wearing) LLViewerInventoryCategory* pCompositeFolder = NULL; if ( (pAttachPt->getObject()) && (RlvSettings::getEnableComposites()) && (pAttachPt->getItemID() != pItem->getUUID()) && (gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pCompositeFolder)) ) { // If we can't take off the composite folder this item would replace then don't allow it to get attached if (gRlvHandler.canTakeOffComposite(pCompositeFolder)) { forceFolder(pCompositeFolder, ACTION_DETACH, FLAG_DEFAULT); addAttachment(pRlvItem); } } else #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS { addAttachment(pRlvItem, eCurAction); } } } } else { const LLViewerObject* pAttachObj = pAvatar->getWornAttachment(pItem->getUUID()); if ( (pAttachObj) && (isForceDetachable(pAttachObj, false)) ) remAttachment(pAttachObj); } break; #ifdef RLV_EXTENSION_FORCEWEAR_GESTURES case LLAssetType::AT_GESTURE: if (isWearAction(eAction)) { if (std::find_if(m_addGestures.begin(), m_addGestures.end(), RlvPredIsEqualOrLinkedItem(pRlvItem)) == m_addGestures.end()) m_addGestures.push_back(pRlvItem); } else { if (std::find_if(m_remGestures.begin(), m_remGestures.end(), RlvPredIsEqualOrLinkedItem(pRlvItem)) == m_remGestures.end()) m_remGestures.push_back(pRlvItem); } break; #endif // RLV_EXTENSION_FORCEWEAR_GESTURES default: break; } } }