summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorybridge.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventorybridge.cpp')
-rw-r--r--indra/newview/llinventorybridge.cpp226
1 files changed, 159 insertions, 67 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 4c28d5e2df..e361082f7b 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -506,12 +506,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())
@@ -566,6 +613,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())
{
@@ -714,20 +767,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();
@@ -737,24 +790,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();
}
@@ -910,6 +966,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 |
// +=================================================+
@@ -1405,13 +1471,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);
@@ -2243,11 +2310,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);
@@ -2278,14 +2340,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);
}
}
@@ -2306,14 +2370,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())
@@ -2342,13 +2408,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))
{
@@ -2382,19 +2450,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;
@@ -2408,13 +2463,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");
}
@@ -2455,6 +2509,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);
@@ -2482,14 +2538,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.
@@ -2518,7 +2573,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.
@@ -3144,6 +3199,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;
@@ -3168,6 +3239,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);
}
@@ -3770,8 +3845,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);
@@ -4095,13 +4175,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();
@@ -4527,19 +4612,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)
@@ -4569,6 +4658,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;
@@ -4738,7 +4829,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.