diff options
author | Palmer Truelson <palmer@lindenlab.com> | 2009-12-14 11:44:48 -0600 |
---|---|---|
committer | Palmer Truelson <palmer@lindenlab.com> | 2009-12-14 11:44:48 -0600 |
commit | de38b58f37d6c7dadd4a5f15be519cb0bb230fc7 (patch) | |
tree | fdfe34a8be0e2086c1e9407931af85f5f8c2fc39 /indra/newview/llinventorybridge.cpp | |
parent | fadfa09e6d3bbff9ebae0aabeacf26a83aae4ad7 (diff) | |
parent | a9e409c7071ba74f01158aa7b876a1ad60161fc4 (diff) |
Merging in latest viewer 2
Diffstat (limited to 'indra/newview/llinventorybridge.cpp')
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 226 |
1 files changed, 159 insertions, 67 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 93cfbddc92..419910b5b6 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -508,12 +508,59 @@ void hide_context_entries(LLMenuGL& menu, } } +bool isWornLink(LLUUID link_id) +{ + LLViewerInventoryItem *link = gInventory.getItem(link_id); + if (!link) + return false; + LLViewerInventoryItem *item = link->getLinkedItem(); + if (!item) + return false; + + switch(item->getType()) + { + case LLAssetType::AT_OBJECT: + { + LLVOAvatarSelf* my_avatar = gAgent.getAvatarObject(); + if(my_avatar && my_avatar->isWearingAttachment(item->getUUID())) + return true; + } + break; + + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + if(gAgentWearables.isWearingItem(item->getUUID())) + return true; + break; + + case LLAssetType::AT_GESTURE: + if (LLGestureManager::instance().isGestureActive(item->getUUID())) + return true; + break; + default: + break; + } + return false; +} + // Helper for commonly-used entries void LLInvFVBridge::getClipboardEntries(bool show_asset_id, std::vector<std::string> &items, std::vector<std::string> &disabled_items, U32 flags) { const LLInventoryObject *obj = getInventoryObject(); + + bool is_sidepanel = isInOutfitsSidePanel(); + if (is_sidepanel) + { + // Sidepanel includes restricted menu. + if (obj && obj->getIsLinkType() && !isWornLink(mUUID)) + { + items.push_back(std::string("Remove Link")); + } + return; + } + if (obj) { if (obj->getIsLinkType()) @@ -568,6 +615,12 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, } items.push_back(std::string("Paste Separator")); + + if (obj && obj->getIsLinkType() && !isWornLink(mUUID)) + { + items.push_back(std::string("Remove Link")); + } + items.push_back(std::string("Delete")); if (!isItemRemovable()) { @@ -716,20 +769,20 @@ BOOL LLInvFVBridge::isItemPermissive() const // static void LLInvFVBridge::changeItemParent(LLInventoryModel* model, LLViewerInventoryItem* item, - const LLUUID& new_parent, + const LLUUID& new_parent_id, BOOL restamp) { - if(item->getParentUUID() != new_parent) + if(item->getParentUUID() != new_parent_id) { LLInventoryModel::update_list_t update; LLInventoryModel::LLCategoryUpdate old_folder(item->getParentUUID(),-1); update.push_back(old_folder); - LLInventoryModel::LLCategoryUpdate new_folder(new_parent, 1); + LLInventoryModel::LLCategoryUpdate new_folder(new_parent_id, 1); update.push_back(new_folder); gInventory.accountForUpdate(update); LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); - new_item->setParent(new_parent); + new_item->setParent(new_parent_id); new_item->updateParentOnServer(restamp); model->updateItem(new_item); model->notifyObservers(); @@ -739,24 +792,27 @@ void LLInvFVBridge::changeItemParent(LLInventoryModel* model, // static void LLInvFVBridge::changeCategoryParent(LLInventoryModel* model, LLViewerInventoryCategory* cat, - const LLUUID& new_parent, + const LLUUID& new_parent_id, BOOL restamp) { - if(cat->getParentUUID() != new_parent) + // Can't move a folder into a child of itself. + if (model->isObjectDescendentOf(new_parent_id, cat->getUUID())) { - LLInventoryModel::update_list_t update; - LLInventoryModel::LLCategoryUpdate old_folder(cat->getParentUUID(), -1); - update.push_back(old_folder); - LLInventoryModel::LLCategoryUpdate new_folder(new_parent, 1); - update.push_back(new_folder); - gInventory.accountForUpdate(update); - - LLPointer<LLViewerInventoryCategory> new_cat = new LLViewerInventoryCategory(cat); - new_cat->setParent(new_parent); - new_cat->updateParentOnServer(restamp); - model->updateCategory(new_cat); - model->notifyObservers(); + return; } + + LLInventoryModel::update_list_t update; + LLInventoryModel::LLCategoryUpdate old_folder(cat->getParentUUID(), -1); + update.push_back(old_folder); + LLInventoryModel::LLCategoryUpdate new_folder(new_parent_id, 1); + update.push_back(new_folder); + model->accountForUpdate(update); + + LLPointer<LLViewerInventoryCategory> new_cat = new LLViewerInventoryCategory(cat); + new_cat->setParent(new_parent_id); + new_cat->updateParentOnServer(restamp); + model->updateCategory(new_cat); + model->notifyObservers(); } @@ -920,6 +976,16 @@ void LLInvFVBridge::purgeItem(LLInventoryModel *model, const LLUUID &uuid) } } +bool LLInvFVBridge::isInOutfitsSidePanel() const +{ + LLInventoryPanel *my_panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get()); + LLPanelOutfitsInventory *outfit_panel = + dynamic_cast<LLPanelOutfitsInventory*>(LLSideTray::getInstance()->getPanel("panel_outfits_inventory")); + if (!outfit_panel) + return false; + return outfit_panel->isAccordionPanel(my_panel); +} + // +=================================================+ // | InventoryFVBridgeBuilder | // +=================================================+ @@ -1415,13 +1481,14 @@ BOOL LLFolderBridge::isItemRemovable() { return FALSE; } + // Allow protected types to be removed, but issue a warning. - /* - if(LLFolderType::lookupIsProtectedType(category->getPreferredType())) + // Restrict to god mode so users don't inadvertently mess up their inventory. + if(LLFolderType::lookupIsProtectedType(category->getPreferredType()) && + !gAgent.isGodlike()) { return FALSE; } - */ LLInventoryPanel* panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get()); LLFolderViewFolder* folderp = dynamic_cast<LLFolderViewFolder*>(panel ? panel->getRootFolder()->getItemByID(mUUID) : NULL); @@ -2256,11 +2323,6 @@ BOOL LLFolderBridge::removeItem() LLNotification::Params params("ConfirmDeleteProtectedCategory"); params.payload(payload).substitutions(args).functor.function(boost::bind(&LLFolderBridge::removeItemResponse, this, _1, _2)); - //params.functor.function(boost::bind(&LLFolderBridge::removeItemResponse, this, _1, _2)); - /* - LLNotification::Params params("ChangeLindenEstate"); - params.functor.function(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2)); - */ if (LLFolderType::lookupIsProtectedType(cat->getPreferredType())) { LLNotifications::instance().add(params); @@ -2291,14 +2353,16 @@ bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& re LLInventoryModel::item_array_t descendent_items; gInventory.collectDescendents( mUUID, descendent_categories, descendent_items, FALSE ); - S32 i; - for (i = 0; i < descendent_items.count(); i++) + for (LLInventoryModel::item_array_t::const_iterator iter = descendent_items.begin(); + iter != descendent_items.end(); + ++iter) { - LLInventoryItem* item = descendent_items[i]; + const LLViewerInventoryItem* item = (*iter); + const LLUUID& item_id = item->getUUID(); if (item->getType() == LLAssetType::AT_GESTURE - && LLGestureManager::instance().isGestureActive(item->getUUID())) + && LLGestureManager::instance().isGestureActive(item_id)) { - LLGestureManager::instance().deactivateGesture(item->getUUID()); + LLGestureManager::instance().deactivateGesture(item_id); } } @@ -2319,14 +2383,16 @@ void LLFolderBridge::pasteFromClipboard() LLInventoryModel* model = getInventoryModel(); if(model && isClipboardPasteable()) { - LLInventoryItem* item = NULL; + const LLUUID parent_id(mUUID); + LLDynamicArray<LLUUID> objects; LLInventoryClipboard::instance().retrieve(objects); - S32 count = objects.count(); - const LLUUID parent_id(mUUID); - for(S32 i = 0; i < count; i++) + for (LLDynamicArray<LLUUID>::const_iterator iter = objects.begin(); + iter != objects.end(); + ++iter) { - item = model->getItem(objects.get(i)); + const LLUUID& item_id = (*iter); + LLInventoryItem *item = model->getItem(item_id); if (item) { if(LLInventoryClipboard::instance().isCutMode()) @@ -2355,13 +2421,15 @@ void LLFolderBridge::pasteLinkFromClipboard() const LLInventoryModel* model = getInventoryModel(); if(model) { + const LLUUID parent_id(mUUID); + LLDynamicArray<LLUUID> objects; LLInventoryClipboard::instance().retrieve(objects); - S32 count = objects.count(); - LLUUID parent_id(mUUID); - for(S32 i = 0; i < count; i++) + for (LLDynamicArray<LLUUID>::const_iterator iter = objects.begin(); + iter != objects.end(); + ++iter) { - const LLUUID &object_id = objects.get(i); + const LLUUID &object_id = (*iter); #if SUPPORT_ENSEMBLES if (LLInventoryCategory *cat = model->getCategory(object_id)) { @@ -2395,19 +2463,6 @@ void LLFolderBridge::staticFolderOptionsMenu() sSelf->folderOptionsMenu(); } -bool isInOutfitsSidePanel(LLPanel *panel) -{ - LLInventoryPanel *my_panel = dynamic_cast<LLInventoryPanel*>(panel); - LLPanelOutfitsInventory *outfit_panel = - dynamic_cast<LLPanelOutfitsInventory*>(LLSideTray::getInstance()->getPanel("panel_outfits_inventory")); - if (!outfit_panel) - return false; - return outfit_panel->isAccordionPanel(my_panel); - - //LLInventoryPanel *outfit_inv_panel = outfit_panel ? outfit_panel->getActivePanel(): NULL; - //return (my_panel && (my_panel == outfit_inv_panel)); -} - void LLFolderBridge::folderOptionsMenu() { std::vector<std::string> disabled_items; @@ -2421,13 +2476,12 @@ void LLFolderBridge::folderOptionsMenu() // BAP change once we're no longer treating regular categories as ensembles. const bool is_ensemble = category && (type == LLFolderType::FT_NONE || LLFolderType::lookupIsEnsembleType(type)); - const bool is_sidepanel = isInOutfitsSidePanel(mInventoryPanel.get()); // calling card related functionality for folders. + const bool is_sidepanel = isInOutfitsSidePanel(); if (is_sidepanel) { - mItems.clear(); mItems.push_back("Rename"); mItems.push_back("Delete"); } @@ -2468,6 +2522,8 @@ void LLFolderBridge::folderOptionsMenu() mItems.push_back(std::string("Wear As Ensemble")); } mItems.push_back(std::string("Remove From Outfit")); + + mItems.push_back(std::string("Outfit Separator")); } hide_context_entries(*mMenu, mItems, disabled_items); @@ -2495,14 +2551,13 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) mDisabledItems.clear(); lldebugs << "LLFolderBridge::buildContextMenu()" << llendl; + // std::vector<std::string> disabled_items; LLInventoryModel* model = getInventoryModel(); if(!model) return; const LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); const LLUUID lost_and_found_id = model->findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); - mItems.clear(); //adding code to clear out member Items (which means Items should not have other data here at this point) - mDisabledItems.clear(); //adding code to clear out disabled members from previous if (lost_and_found_id == mUUID) { // This is the lost+found folder. @@ -2531,7 +2586,7 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) LLViewerInventoryCategory *cat = getCategory(); // BAP removed protected check to re-enable standard ops in untyped folders. // Not sure what the right thing is to do here. - if (!isCOFFolder() && cat /*&& + if (!isCOFFolder() && cat && cat->getPreferredType()!=LLFolderType::FT_OUTFIT /*&& LLAssetType::lookupIsProtectedCategoryType(cat->getPreferredType())*/) { // Do not allow to create 2-level subfolder in the Calling Card/Friends folder. EXT-694. @@ -3158,6 +3213,22 @@ void LLTextureBridge::openItem() } } +bool LLTextureBridge::canSaveTexture(void) +{ + const LLInventoryModel* model = getInventoryModel(); + if(!model) + { + return false; + } + + const LLViewerInventoryItem *item = model->getItem(mUUID); + if (item) + { + return item->checkPermissionsSet(PERM_ITEM_UNRESTRICTED); + } + return false; +} + void LLTextureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { lldebugs << "LLTextureBridge::buildContextMenu()" << llendl; @@ -3182,6 +3253,10 @@ void LLTextureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) items.push_back(std::string("Texture Separator")); items.push_back(std::string("Save As")); + if (!canSaveTexture()) + { + disabled_items.push_back(std::string("Save As")); + } } hide_context_entries(menu, items, disabled_items); } @@ -3785,8 +3860,13 @@ void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } else { - items.push_back(std::string("Open")); - items.push_back(std::string("Properties")); + bool is_sidepanel = isInOutfitsSidePanel(); + + if (!is_sidepanel) + { + items.push_back(std::string("Open")); + items.push_back(std::string("Properties")); + } getClipboardEntries(true, items, disabled_items, flags); @@ -4110,13 +4190,18 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } else { - items.push_back(std::string("Properties")); + bool is_sidepanel = isInOutfitsSidePanel(); + + if (!is_sidepanel) + { + items.push_back(std::string("Properties")); + } - LLInventoryItem *item = getItem(); getClipboardEntries(true, items, disabled_items, flags); LLObjectBridge::sContextMenuItemID = mUUID; + LLInventoryItem *item = getItem(); if(item) { LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); @@ -4542,19 +4627,23 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { can_open = FALSE; } - if (can_open) + + bool is_sidepanel = isInOutfitsSidePanel(); + + if (can_open && !is_sidepanel) { items.push_back(std::string("Open")); } - items.push_back(std::string("Properties")); + if (!is_sidepanel) + { + items.push_back(std::string("Properties")); + } getClipboardEntries(true, items, disabled_items, flags); items.push_back(std::string("Wearable Separator")); - items.push_back(std::string("Wearable Wear")); - items.push_back(std::string("Wearable Add")); items.push_back(std::string("Wearable Edit")); if ((flags & FIRST_SELECTED_ITEM) == 0) @@ -4584,6 +4673,8 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } else { + items.push_back(std::string("Wearable Wear")); + items.push_back(std::string("Wearable Add")); disabled_items.push_back(std::string("Take Off")); } break; @@ -4753,7 +4844,8 @@ void LLWearableBridge::onEditOnAvatar(void* user_data) void LLWearableBridge::editOnAvatar() { - const LLWearable* wearable = gAgentWearables.getWearableFromItemID(mUUID); + LLUUID linked_id = gInventory.getLinkedItemID(mUUID); + const LLWearable* wearable = gAgentWearables.getWearableFromItemID(linked_id); if( wearable ) { // Set the tab to the right wearable. |