diff options
-rw-r--r-- | indra/newview/llpanelmaininventory.cpp | 50 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 90 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.h | 5 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml | 24 |
4 files changed, 167 insertions, 2 deletions
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 2a56a6011e..92b4c8383e 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -966,6 +966,27 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) preview_texture->openToSave(); } } + if (command_name == "regenerate_link") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) + { + return; + } + const LLUUID& item_id = current_item->getListener()->getUUID(); + LLViewerInventoryItem *item = gInventory.getItem(item_id); + item->regenerateLink(); + } + if (command_name == "find_original") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) + { + return; + } + current_item->getListener()->performAction(getActivePanel()->getRootFolder(), getActivePanel()->getModel(), "goto"); + } + if (command_name == "find_links") { LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); @@ -1017,18 +1038,45 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) } return FALSE; } + if (command_name == "find_original") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) return FALSE; + const LLUUID& item_id = current_item->getListener()->getUUID(); + const LLViewerInventoryItem *item = gInventory.getItem(item_id); + if (item && item->getIsLinkType() && !item->getIsBrokenLink()) + { + return TRUE; + } + return FALSE; + } + if (command_name == "find_links") { LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) return FALSE; const LLUUID& item_id = current_item->getListener()->getUUID(); - LLInventoryObject *obj = gInventory.getObject(item_id); + const LLInventoryObject *obj = gInventory.getObject(item_id); if (obj && !obj->getIsLinkType() && LLAssetType::lookupCanLink(obj->getType())) { return TRUE; } return FALSE; } + + if (command_name == "regenerate_link") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) return FALSE; + const LLUUID& item_id = current_item->getListener()->getUUID(); + const LLViewerInventoryItem *item = gInventory.getItem(item_id); + if (item && item->getIsBrokenLink()) + { + return TRUE; + } + return FALSE; + } + return TRUE; } diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 43bf9d1a6b..f20d87a687 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1437,3 +1437,93 @@ void LLViewerInventoryItem::onCallingCardNameLookup(const LLUUID& id, const std: gInventory.notifyObservers(); } +class LLRegenerateLinkCollector : public LLInventoryCollectFunctor +{ +public: + LLRegenerateLinkCollector(const LLViewerInventoryItem *target_item) : mTargetItem(target_item) {} + virtual ~LLRegenerateLinkCollector() {} + virtual bool operator()(LLInventoryCategory* cat, + LLInventoryItem* item) + { + if (item) + { + if ((item->getName() == mTargetItem->getName()) && + (item->getInventoryType() == mTargetItem->getInventoryType()) && + (!item->getIsLinkType())) + { + return true; + } + } + return false; + } +protected: + const LLViewerInventoryItem* mTargetItem; +}; + +LLUUID find_possible_item_for_regeneration(const LLViewerInventoryItem *target_item) +{ + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + /* + LLAssetIDMatches asset_id_matches(target_item->getAssetUUID()); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + asset_id_matches); + for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items.begin(); + item_iter != items.end(); + item_iter++) + { + const LLViewerInventoryItem *item = (*item_iter); + if (!item->getIsBrokenLink()) + { + return item->getAssetUUID(); + } + } + */ + + items.clear(); + cats.clear(); + + LLRegenerateLinkCollector candidate_matches(target_item); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + candidate_matches); + for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items.begin(); + item_iter != items.end(); + ++item_iter) + { + const LLViewerInventoryItem *item = (*item_iter); + if (true) return item->getUUID(); + } + return LLUUID::null; +} + +BOOL LLViewerInventoryItem::regenerateLink() +{ + const LLUUID target_item_id = find_possible_item_for_regeneration(this); + if (target_item_id.isNull()) + return FALSE; + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(getAssetUUID()); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + asset_id_matches); + for (LLViewerInventoryItem::item_array_t::iterator item_iter = items.begin(); + item_iter != items.end(); + item_iter++) + { + LLViewerInventoryItem *item = (*item_iter); + item->setAssetUUID(target_item_id); + item->updateServer(FALSE); + gInventory.addChangedMask(LLInventoryObserver::REBUILD, item->getUUID()); + } + gInventory.notifyObservers(); + return TRUE; +} diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index d27faffdd9..0156e7dab1 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -161,7 +161,10 @@ public: // callback void onCallingCardNameLookup(const LLUUID& id, const std::string& first_name, const std::string& last_name); - + + // If this is a broken link, try to fix it and any other identical link. + BOOL regenerateLink(); + public: BOOL mIsComplete; LLTransactionID mTransactionID; diff --git a/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml b/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml index 7a3e91d5a1..e5592c3c57 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml @@ -76,6 +76,8 @@ function="Inventory.GearDefault.Custom.Action" parameter="empty_lostnfound" /> </menu_item_call> + <menu_item_separator + layout="topleft" /> <menu_item_call label="Save Texture As" layout="topleft" @@ -88,6 +90,17 @@ parameter="save_texture" /> </menu_item_call> <menu_item_call + label="Find Original" + layout="topleft" + name="Find Original"> + <on_click + function="Inventory.GearDefault.Custom.Action" + parameter="find_original" /> + <on_enable + function="Inventory.GearDefault.Enable" + parameter="find_original" /> + </menu_item_call> + <menu_item_call label="Find All Links" layout="topleft" name="Find All Links"> @@ -98,4 +111,15 @@ function="Inventory.GearDefault.Enable" parameter="find_links" /> </menu_item_call> + <menu_item_call + label="Regenerate Link" + layout="topleft" + name="Regenerate Link"> + <on_click + function="Inventory.GearDefault.Custom.Action" + parameter="regenerate_link" /> + <on_enable + function="Inventory.GearDefault.Enable" + parameter="regenerate_link" /> + </menu_item_call> </menu> |