diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-06-21 08:04:56 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-06-21 08:04:56 +0000 |
commit | 9ec432034dc3c45d7ce763eb02dae4cc7f6b8da8 (patch) | |
tree | 4a505c1e0919af52800b3ffb3eaf135e7d6f9ce6 /indra/newview/llinventorybridge.cpp | |
parent | 351ebe9fcb76f3b99c2957004bb8493a904869ee (diff) |
merge -r 122421-124917 viewer-2.0.0-2 -> viewer-2.0.0-3
ignore-dead-branch
Diffstat (limited to 'indra/newview/llinventorybridge.cpp')
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 1202 |
1 files changed, 686 insertions, 516 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 5d09d8748f..540cefbc46 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -40,8 +40,10 @@ #include "message.h" #include "llagent.h" +#include "llagentwearables.h" #include "llcallingcard.h" #include "llcheckboxctrl.h" // for radio buttons +#include "llfloaterreg.h" #include "llradiogroup.h" #include "llspinctrl.h" #include "lltextbox.h" @@ -49,13 +51,13 @@ #include "llviewercontrol.h" #include "llfirstuse.h" -#include "llfloateravatarinfo.h" #include "llfloaterchat.h" #include "llfloatercustomize.h" #include "llfloaterproperties.h" #include "llfloaterworldmap.h" #include "llfocusmgr.h" #include "llfolderview.h" +#include "llfriendactions.h" #include "llgesturemgr.h" #include "lliconctrl.h" #include "llinventorymodel.h" @@ -82,10 +84,12 @@ #include "llwearablelist.h" #include "llviewermessage.h" #include "llviewerregion.h" +#include "llvoavatarself.h" #include "lltabcontainer.h" #include "lluictrlfactory.h" #include "llselectmgr.h" #include "llfloateropenobject.h" +#include "lltrans.h" using namespace LLOldEvents; @@ -106,12 +110,13 @@ void dec_busy_count() // Function declarations struct LLWearableHoldingPattern; +void wear_add_inventory_item_on_avatar(LLInventoryItem* item); void wear_inventory_category_on_avatar(LLInventoryCategory* category, BOOL append); -void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata); +void wear_inventory_category_on_avatar_step2( BOOL proceed, LLUUID category, BOOL append); void wear_inventory_category_on_avatar_loop(LLWearable* wearable, void*); void wear_inventory_category_on_avatar_step3(LLWearableHoldingPattern* holder, BOOL append); void remove_inventory_category_from_avatar(LLInventoryCategory* category); -void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata); +void remove_inventory_category_from_avatar_step2( BOOL proceed, LLUUID category_id); bool move_task_inventory_callback(const LLSD& notification, const LLSD& response, LLMoveInv*); bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& response); @@ -144,17 +149,13 @@ std::string ICON_NAME[ICON_NAME_COUNT] = "inv_item_undershirt.tga", "inv_item_underpants.tga", "inv_item_skirt.tga", + "inv_item_alpha.tga", + "inv_item_tattoo.tga", "inv_item_animation.tga", "inv_item_gesture.tga", }; -struct LLWearInfo -{ - LLUUID mCategoryID; - BOOL mAppend; -}; - BOOL gAddToOutfit = FALSE; // +=================================================+ @@ -192,7 +193,7 @@ time_t LLInvFVBridge::getCreationDate() const // Can be destoryed (or moved to trash) BOOL LLInvFVBridge::isItemRemovable() { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; if(model->isObjectDescendentOf(mUUID, gAgent.getInventoryRootID())) { @@ -210,14 +211,14 @@ BOOL LLInvFVBridge::isItemMovable() // *TODO: make sure this does the right thing void LLInvFVBridge::showProperties() { - LLShowProps::showProperties(mUUID); + LLFloaterProperties::show(mUUID); } void LLInvFVBridge::removeBatch(LLDynamicArray<LLFolderViewEventListener*>& batch) { // Deactivate gestures when moving them into Trash LLInvFVBridge* bridge; - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); LLViewerInventoryItem* item = NULL; LLViewerInventoryCategory* cat = NULL; LLInventoryModel::cat_array_t descendent_categories; @@ -265,7 +266,7 @@ void LLInvFVBridge::removeBatchNoCheck(LLDynamicArray<LLFolderViewEventListener* // we call LLInventoryModel::moveObject() to move everything // around. LLInvFVBridge* bridge; - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return; LLMessageSystem* msg = gMessageSystem; LLUUID trash_id = model->findCategoryUUIDForType(LLAssetType::AT_TRASH); @@ -369,7 +370,7 @@ void LLInvFVBridge::removeBatchNoCheck(LLDynamicArray<LLFolderViewEventListener* BOOL LLInvFVBridge::isClipboardPasteable() const { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; BOOL is_agent_inventory = model->isObjectDescendentOf(mUUID, gAgent.getInventoryRootID()); @@ -381,8 +382,8 @@ BOOL LLInvFVBridge::isClipboardPasteable() const } void hideContextEntries(LLMenuGL& menu, - const std::vector<std::string> &entries_to_show, - const std::vector<std::string> &disabled_entries) + const std::vector<std::string> &entries_to_show, + const std::vector<std::string> &disabled_entries) { const LLView::child_list_t *list = menu.getChildList(); @@ -426,10 +427,10 @@ void hideContextEntries(LLMenuGL& menu, } // 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) +void LLInvFVBridge::getClipboardEntries(bool show_asset_id, + std::vector<std::string> &items, + std::vector<std::string> &disabled_items, U32 flags) { - // *TODO: Translate items.push_back(std::string("Rename")); if (!isItemRenameable() || (flags & FIRST_SELECTED_ITEM) == 0) { @@ -471,18 +472,17 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, std::vector<std::str void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - // *TODO: Translate lldebugs << "LLInvFVBridge::buildContextMenu()" << llendl; std::vector<std::string> items; std::vector<std::string> disabled_items; if(isInTrash()) { - items.push_back(std::string("Purge Item")); + items.push_back(std::string("PurgeItem")); if (!isItemRemovable()) { - disabled_items.push_back(std::string("Purge Item")); + disabled_items.push_back(std::string("PurgeItem")); } - items.push_back(std::string("Restore Item")); + items.push_back(std::string("RestoreItem")); } else { @@ -526,7 +526,7 @@ BOOL LLInvFVBridge::startDrag(EDragAndDropType* type, LLUUID* id) const LLInventoryObject* LLInvFVBridge::getInventoryObject() const { LLInventoryObject* obj = NULL; - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(model) { obj = (LLInventoryObject*)model->getObject(mUUID); @@ -534,9 +534,15 @@ LLInventoryObject* LLInvFVBridge::getInventoryObject() const return obj; } +LLInventoryModel* LLInvFVBridge::getInventoryModel() const +{ + LLInventoryPanel* panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get()); + return panel ? panel->getModel() : NULL; +} + BOOL LLInvFVBridge::isInTrash() const { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; LLUUID trash_id = model->findCategoryUUIDForType(LLAssetType::AT_TRASH); return model->isObjectDescendentOf(mUUID, trash_id); @@ -544,7 +550,7 @@ BOOL LLInvFVBridge::isInTrash() const BOOL LLInvFVBridge::isAgentInventory() const { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; if(gAgent.getInventoryRootID() == mUUID) return TRUE; return model->isObjectDescendentOf(mUUID, gAgent.getInventoryRootID()); @@ -602,22 +608,21 @@ void LLInvFVBridge::changeCategoryParent(LLInventoryModel* model, } -const char* safe_inv_type_lookup(LLInventoryType::EType inv_type) +const std::string safe_inv_type_lookup(LLInventoryType::EType inv_type) { - const char* rv = LLInventoryType::lookup(inv_type); - if(!rv) + const std::string rv= LLInventoryType::lookup(inv_type); + if(rv.empty()) { - const char* INVALID_TYPE = "<invalid>"; - rv = INVALID_TYPE; + return std::string("<invalid>"); } return rv; } LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type, - LLInventoryType::EType inv_type, - LLInventoryPanel* inventory, - const LLUUID& uuid, - U32 flags) + LLInventoryType::EType inv_type, + LLInventoryPanel* inventory, + const LLUUID& uuid, + U32 flags) { LLInvFVBridge* new_listener = NULL; switch(asset_type) @@ -715,6 +720,10 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type, case LLAssetType::AT_ROOT_CATEGORY: new_listener = new LLFolderBridge(inventory, uuid); break; + + case LLAssetType::AT_FAVORITE: + new_listener = new LLFolderBridge(inventory, uuid); + break; default: llinfos << "Unhandled asset type (llassetstorage.h): " @@ -811,7 +820,7 @@ void LLItemBridge::restoreItem() LLViewerInventoryItem* item = (LLViewerInventoryItem*)getItem(); if(item) { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); LLUUID new_parent = model->findCategoryUUIDForType(item->getType()); // do not restamp on restore. LLInvFVBridge::changeItemParent(model, item, new_parent, FALSE); @@ -906,6 +915,11 @@ void LLItemBridge::buildDisplayName(LLInventoryItem* item, std::string& name) std::string LLItemBridge::getLabelSuffix() const { + // assume that this won't be called before string table is loaded + static const char* NO_COPY =LLTrans::getString("NO_COPY").c_str(); + static const char* NO_MOD = LLTrans::getString("NO_MOD").c_str(); + static const char* NO_XFER = LLTrans::getString("NO_XFER").c_str(); + std::string suffix; LLInventoryItem* item = getItem(); if(item) @@ -918,11 +932,8 @@ std::string LLItemBridge::getLabelSuffix() const BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID()); BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); - // *TODO: Translate + const char* EMPTY = ""; - const char* NO_COPY = " (no copy)"; - const char* NO_MOD = " (no modify)"; - const char* NO_XFER = " (no transfer)"; const char* scopy; if(copy) scopy = EMPTY; else scopy = NO_COPY; @@ -961,10 +972,12 @@ BOOL LLItemBridge::isItemRenameable() const BOOL LLItemBridge::renameItem(const std::string& new_name) { - if(!isItemRenameable()) return FALSE; - LLPreview::rename(mUUID, getPrefix() + new_name); - LLInventoryModel* model = mInventoryPanel->getModel(); - if(!model) return FALSE; + if(!isItemRenameable()) + return FALSE; + LLPreview::dirty(mUUID); + LLInventoryModel* model = getInventoryModel(); + if(!model) + return FALSE; LLViewerInventoryItem* item = getItem(); if(item && (item->getName() != new_name)) { @@ -989,7 +1002,7 @@ BOOL LLItemBridge::removeItem() } // move it to the trash LLPreview::hide(mUUID, TRUE); - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; LLUUID trash_id = model->findCategoryUUIDForType(LLAssetType::AT_TRASH); LLViewerInventoryItem* item = getItem(); @@ -1015,7 +1028,7 @@ BOOL LLItemBridge::isItemCopyable() const if (item) { // can't copy worn objects. DEV-15183 - LLVOAvatar *avatarp = gAgent.getAvatarObject(); + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); if( !avatarp ) { return FALSE; @@ -1044,7 +1057,7 @@ BOOL LLItemBridge::copyToClipboard() const LLViewerInventoryItem* LLItemBridge::getItem() const { LLViewerInventoryItem* item = NULL; - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(model) { item = (LLViewerInventoryItem*)model->getItem(mUUID); @@ -1091,7 +1104,7 @@ void LLFolderBridge::selectItem() // Can be destroyed (or moved to trash) BOOL LLFolderBridge::isItemRemovable() { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) { return FALSE; @@ -1102,7 +1115,7 @@ BOOL LLFolderBridge::isItemRemovable() return FALSE; } - LLVOAvatar* avatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); if( !avatar ) { return FALSE; @@ -1139,7 +1152,7 @@ BOOL LLFolderBridge::isItemRemovable() if( (item->getType() == LLAssetType::AT_CLOTHING) || (item->getType() == LLAssetType::AT_BODYPART) ) { - if( gAgent.isWearingItem( item->getUUID() ) ) + if( gAgentWearables.isWearingItem( item->getUUID() ) ) { return FALSE; } @@ -1159,7 +1172,7 @@ BOOL LLFolderBridge::isItemRemovable() BOOL LLFolderBridge::isUpToDate() const { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; LLViewerInventoryCategory* category = (LLViewerInventoryCategory*)model->getCategory(mUUID); if( !category ) @@ -1177,10 +1190,10 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, // the UI will get confused and pass in a NULL. if(!inv_cat) return FALSE; - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; - LLVOAvatar* avatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); if(!avatar) return FALSE; // cannot drag into library @@ -1233,7 +1246,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, if( (item->getType() == LLAssetType::AT_CLOTHING) || (item->getType() == LLAssetType::AT_BODYPART) ) { - if( gAgent.isWearingItem( item->getUUID() ) ) + if( gAgentWearables.isWearingItem( item->getUUID() ) ) { is_movable = FALSE; // It's generally movable, but not into the trash! break; @@ -1394,7 +1407,7 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id, else { LLNotification::Params params("MoveInventoryFromObject"); - params.functor(boost::bind(move_task_inventory_callback, _1, _2, move_inv)); + params.functor.function(boost::bind(move_task_inventory_callback, _1, _2, move_inv)); LLNotifications::instance().forceResponse(params, 0); } } @@ -1626,7 +1639,7 @@ void LLFolderBridge::performAction(LLFolderView* folder, LLInventoryModel* model } else if ("removefromoutfit" == action) { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return; LLViewerInventoryCategory* cat = getCategory(); if(!cat) return; @@ -1657,7 +1670,7 @@ void LLFolderBridge::performAction(LLFolderView* folder, LLInventoryModel* model void LLFolderBridge::openItem() { lldebugs << "LLFolderBridge::openItem()" << llendl; - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return; model->fetchDescendentsOf(mUUID); } @@ -1679,13 +1692,25 @@ void LLFolderBridge::restoreItem() cat = (LLViewerInventoryCategory*)getCategory(); if(cat) { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); LLUUID new_parent = model->findCategoryUUIDForType(cat->getType()); // do not restamp children on restore LLInvFVBridge::changeCategoryParent(model, cat, new_parent, FALSE); } } +LLAssetType::EType LLFolderBridge::getPreferredType() const +{ + LLAssetType::EType preferred_type = LLAssetType::AT_NONE; + LLViewerInventoryCategory* cat = getCategory(); + if(cat) + { + preferred_type = cat->getPreferredType(); + } + + return preferred_type; +} + // Icons for folders are based on the preferred type LLUIImagePtr LLFolderBridge::getIcon() const { @@ -1744,6 +1769,10 @@ LLUIImagePtr LLFolderBridge::getIcon() const case LLAssetType::AT_GESTURE: control = "inv_folder_gesture.tga"; break; + case LLAssetType::AT_FAVORITE: + //TODO - need icon + control = "inv_folder_plain_closed.tga"; + break; default: control = "inv_folder_plain_closed.tga"; break; @@ -1753,9 +1782,11 @@ LLUIImagePtr LLFolderBridge::getIcon() const BOOL LLFolderBridge::renameItem(const std::string& new_name) { - if(!isItemRenameable()) return FALSE; - LLInventoryModel* model = mInventoryPanel->getModel(); - if(!model) return FALSE; + if(!isItemRenameable()) + return FALSE; + LLInventoryModel* model = getInventoryModel(); + if(!model) + return FALSE; LLViewerInventoryCategory* cat = getCategory(); if(cat && (cat->getName() != new_name)) { @@ -1778,7 +1809,7 @@ BOOL LLFolderBridge::removeItem() } // move it to the trash LLPreview::hide(mUUID); - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; LLUUID trash_id; @@ -1822,7 +1853,7 @@ BOOL LLFolderBridge::isClipboardPasteable() const void LLFolderBridge::pasteFromClipboard() { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(model && isClipboardPasteable()) { LLInventoryItem* item = NULL; @@ -1857,9 +1888,7 @@ void LLFolderBridge::folderOptionsMenu() { std::vector<std::string> disabled_items; - // *TODO: Translate - - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return; const LLInventoryCategory* category = model->getCategory(mUUID); @@ -1919,10 +1948,9 @@ BOOL LLFolderBridge::checkFolderForContentsOfType(LLInventoryModel* model, LLInv // Flags unused void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - // *TODO: Translate lldebugs << "LLFolderBridge::buildContextMenu()" << llendl; // std::vector<std::string> disabled_items; - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return; LLUUID trash_id = model->findCategoryUUIDForType(LLAssetType::AT_TRASH); LLUUID lost_and_found_id = model->findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND); @@ -1952,31 +1980,6 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } else if(isAgentInventory()) // do not allow creating in library { - // only mature accounts can create undershirts/underwear - /*if (!gAgent.isTeen()) - { - sub_menu->append(new LLMenuItemCallGL("New Undershirt", - &createNewUndershirt, - NULL, - (void*)this)); - sub_menu->append(new LLMenuItemCallGL("New Underpants", - &createNewUnderpants, - NULL, - (void*)this)); - }*/ - -/* BOOL contains_calling_cards = FALSE; - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - - LLIsType is_callingcard(LLAssetType::AT_CALLINGCARD); - model->collectDescendentsIf(mUUID, - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - is_callingcard); - if(item_array.count() > 0) contains_calling_cards = TRUE; -*/ mItems.push_back(std::string("New Folder")); mItems.push_back(std::string("New Script")); mItems.push_back(std::string("New Note")); @@ -2037,7 +2040,7 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) BOOL LLFolderBridge::hasChildren() const { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; LLInventoryModel::EHasChildren has_children; has_children = gInventory.categoryHasChildren(mUUID); @@ -2079,7 +2082,7 @@ BOOL LLFolderBridge::dragOrDrop(MASK mask, BOOL drop, LLViewerInventoryCategory* LLFolderBridge::getCategory() const { LLViewerInventoryCategory* cat = NULL; - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(model) { cat = (LLViewerInventoryCategory*)model->getCategory(mUUID); @@ -2099,7 +2102,8 @@ void LLFolderBridge::createNewCategory(void* user_data) { LLFolderBridge* bridge = (LLFolderBridge*)user_data; if(!bridge) return; - LLInventoryPanel* panel = bridge->mInventoryPanel; + LLInventoryPanel* panel = dynamic_cast<LLInventoryPanel*>(bridge->mInventoryPanel.get()); + if (!panel) return; LLInventoryModel* model = panel->getModel(); if(!model) return; LLUUID id; @@ -2191,7 +2195,7 @@ void LLFolderBridge::createWearable(LLFolderBridge* bridge, EWearableType type) // static void LLFolderBridge::createWearable(LLUUID parent_id, EWearableType type) { - LLWearable* wearable = gWearableList.createNewWearable(type); + LLWearable* wearable = LLWearableList::instance().createNewWearable(type); LLAssetType::EType asset_type = wearable->getAssetType(); LLInventoryType::EType inv_type = LLInventoryType::IT_WEARABLE; create_inventory_item(gAgent.getID(), gAgent.getSessionID(), @@ -2203,7 +2207,7 @@ void LLFolderBridge::createWearable(LLUUID parent_id, EWearableType type) void LLFolderBridge::modifyOutfit(BOOL append) { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return; LLViewerInventoryCategory* cat = getCategory(); if(!cat) return; @@ -2254,7 +2258,7 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, BOOL drop) { - LLInventoryModel* model = mInventoryPanel->getModel(); + LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; // cannot drag into library @@ -2263,7 +2267,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, return FALSE; } - LLVOAvatar* avatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); if(!avatar) return FALSE; LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource(); @@ -2294,7 +2298,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, { case LLAssetType::AT_CLOTHING: case LLAssetType::AT_BODYPART: - is_movable = !gAgent.isWearingItem(inv_item->getUUID()); + is_movable = !gAgentWearables.isWearingItem(inv_item->getUUID()); break; case LLAssetType::AT_OBJECT: @@ -2320,18 +2324,33 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, if (LLInventoryView::getActiveInventory()) { LLInventoryPanel* active_panel = LLInventoryView::getActiveInventory()->getPanel(); - if (active_panel && (mInventoryPanel != active_panel)) + LLInventoryPanel* panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get()); + if (active_panel && (panel != active_panel)) { active_panel->unSelectAll(); } } - // restamp if the move is into the trash. - LLInvFVBridge::changeItemParent( - model, - (LLViewerInventoryItem*)inv_item, - mUUID, - move_is_into_trash); + LLUUID favorites_id = model->findCategoryUUIDForType(LLAssetType::AT_FAVORITE); + if (favorites_id == mUUID) // if target is the favorites folder we use copy + { + copy_inventory_item( + gAgent.getID(), + inv_item->getPermissions().getOwner(), + inv_item->getUUID(), + mUUID, + std::string(), + LLPointer<LLInventoryCallback>(NULL)); + } + else + { + // restamp if the move is into the trash. + LLInvFVBridge::changeItemParent( + model, + (LLViewerInventoryItem*)inv_item, + mUUID, + move_is_into_trash); + } } } else if(LLToolDragAndDrop::SOURCE_WORLD == source) @@ -2380,7 +2399,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, else { LLNotification::Params params("MoveInventoryFromObject"); - params.functor(boost::bind(move_task_inventory_callback, _1, _2, move_inv)); + params.functor.function(boost::bind(move_task_inventory_callback, _1, _2, move_inv)); LLNotifications::instance().forceResponse(params, 0); } } @@ -2433,49 +2452,18 @@ LLUIImagePtr LLScriptBridge::getIcon() const // | LLTextureBridge | // +=================================================+ -std::string LLTextureBridge::sPrefix("Texture: "); - - LLUIImagePtr LLTextureBridge::getIcon() const { return get_item_icon(LLAssetType::AT_TEXTURE, mInvType, 0, FALSE); } -void open_texture(const LLUUID& item_id, - const std::string& title, - BOOL show_keep_discard, - const LLUUID& source_id, - BOOL take_focus) -{ - // See if we can bring an exiting preview to the front - if( !LLPreview::show( item_id, take_focus ) ) - { - // There isn't one, so make a new preview - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("PreviewTextureRect"); - rect.translate( left - rect.mLeft, top - rect.mTop ); - - LLPreviewTexture* preview; - preview = new LLPreviewTexture("preview texture", - rect, - title, - item_id, - LLUUID::null, - show_keep_discard); - preview->setSourceID(source_id); - if(take_focus) preview->setFocus(TRUE); - - gFloaterView->adjustToFitScreen(preview, FALSE); - } -} - void LLTextureBridge::openItem() { LLViewerInventoryItem* item = getItem(); - if(item) + + if (item) { - open_texture(mUUID, getPrefix() + item->getName(), FALSE); + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); } } @@ -2483,9 +2471,6 @@ void LLTextureBridge::openItem() // | LLSoundBridge | // +=================================================+ -std::string LLSoundBridge::sPrefix("Sound: "); - - LLUIImagePtr LLSoundBridge::getIcon() const { return get_item_icon(LLAssetType::AT_SOUND, LLInventoryType::IT_SOUND, 0, FALSE); @@ -2493,6 +2478,13 @@ LLUIImagePtr LLSoundBridge::getIcon() const void LLSoundBridge::openItem() { + LLViewerInventoryItem* item = getItem(); + + if (item) + { + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); + } +/* // Changed this back to the way it USED to work: // only open the preview dialog through the contextual right-click menu // double-click just plays the sound @@ -2503,18 +2495,7 @@ void LLSoundBridge::openItem() openSoundPreview((void*)this); //send_uuid_sound_trigger(item->getAssetUUID(), 1.0); } - -// if(!LLPreview::show(mUUID)) -// { -// S32 left, top; -// gFloaterView->getNewFloaterPosition(&left, &top); -// LLRect rect = gSavedSettings.getRect("PreviewSoundRect"); -// rect.translate(left - rect.mLeft, top - rect.mTop); -// new LLPreviewSound("preview sound", -// rect, -// getPrefix() + getName(), -// mUUID)); -// } +*/ } void LLSoundBridge::previewItem() @@ -2529,20 +2510,7 @@ void LLSoundBridge::previewItem() void LLSoundBridge::openSoundPreview(void* which) { LLSoundBridge *me = (LLSoundBridge *)which; - if(!LLPreview::show(me->mUUID)) - { - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("PreviewSoundRect"); - rect.translate(left - rect.mLeft, top - rect.mTop); - LLPreviewSound* preview = new LLPreviewSound("preview sound", - rect, - me->getPrefix() + me->getName(), - me->mUUID); - preview->setFocus(TRUE); - // Keep entirely onscreen. - gFloaterView->adjustToFitScreen(preview, FALSE); - } + LLFloaterReg::showInstance("preview_sound", LLSD(me->mUUID), TAKE_FOCUS_YES); } void LLSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) @@ -2551,7 +2519,6 @@ void LLSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) std::vector<std::string> items; std::vector<std::string> disabled_items; - // *TODO: Translate if(isInTrash()) { items.push_back(std::string("Purge Item")); @@ -2580,8 +2547,6 @@ void LLSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) // | LLLandmarkBridge | // +=================================================+ -std::string LLLandmarkBridge::sPrefix("Landmark: "); - LLUIImagePtr LLLandmarkBridge::getIcon() const { return get_item_icon(LLAssetType::AT_LANDMARK, LLInventoryType::IT_LANDMARK, mVisited, FALSE); @@ -2592,7 +2557,6 @@ void LLLandmarkBridge::buildContextMenu(LLMenuGL& menu, U32 flags) std::vector<std::string> items; std::vector<std::string> disabled_items; - // *TODO: Translate lldebugs << "LLLandmarkBridge::buildContextMenu()" << llendl; if(isInTrash()) { @@ -2619,6 +2583,20 @@ void LLLandmarkBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } +// Convenience function for the two functions below. +void teleport_via_landmark(const LLUUID& asset_id) +{ + gAgent.teleportViaLandmark( asset_id ); + + // we now automatically track the landmark you're teleporting to + // because you'll probably arrive at a telehub instead + LLFloaterWorldMap* floater_world_map = LLFloaterWorldMap::getInstance(); + if( floater_world_map ) + { + floater_world_map->trackLandmark( asset_id ); + } +} + // virtual void LLLandmarkBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { @@ -2627,52 +2605,20 @@ void LLLandmarkBridge::performAction(LLFolderView* folder, LLInventoryModel* mod LLViewerInventoryItem* item = getItem(); if(item) { - gAgent.teleportViaLandmark(item->getAssetUUID()); - - // we now automatically track the landmark you're teleporting to - // because you'll probably arrive at a telehub instead - if( gFloaterWorldMap ) - { - gFloaterWorldMap->trackLandmark( item->getAssetUUID() ); - } + teleport_via_landmark(item->getAssetUUID()); } } - if ("about" == action) + else if ("about" == action) { LLViewerInventoryItem* item = getItem(); if(item) { - open_landmark(item, std::string(" ") + getPrefix() + item->getName(), FALSE); + LLFloaterReg::showInstance("preview_landmark", LLSD(item->getUUID()), TAKE_FOCUS_YES); } } - else LLItemBridge::performAction(folder, model, action); -} - -void open_landmark(LLViewerInventoryItem* inv_item, - const std::string& title, - BOOL show_keep_discard, - const LLUUID& source_id, - BOOL take_focus) -{ - // See if we can bring an exiting preview to the front - if( !LLPreview::show( inv_item->getUUID(), take_focus ) ) + else { - // There isn't one, so make a new preview - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("PreviewLandmarkRect"); - rect.translate( left - rect.mLeft, top - rect.mTop ); - - LLPreviewLandmark* preview = new LLPreviewLandmark(title, - rect, - title, - inv_item->getUUID(), - show_keep_discard, - inv_item); - preview->setSourceID(source_id); - if(take_focus) preview->setFocus(TRUE); - // keep onscreen - gFloaterView->adjustToFitScreen(preview, FALSE); + LLItemBridge::performAction(folder, model, action); } } @@ -2683,15 +2629,7 @@ static bool open_landmark_callback(const LLSD& notification, const LLSD& respons LLUUID asset_id = notification["payload"]["asset_id"].asUUID(); if (option == 0) { - // HACK: This is to demonstrate teleport on double click for landmarks - gAgent.teleportViaLandmark( asset_id ); - - // we now automatically track the landmark you're teleporting to - // because you'll probably arrive at a telehub instead - if( gFloaterWorldMap ) - { - gFloaterWorldMap->trackLandmark( asset_id ); - } + teleport_via_landmark(asset_id); } return false; @@ -2702,15 +2640,23 @@ static LLNotificationFunctorRegistration open_landmark_callback_reg("TeleportFro void LLLandmarkBridge::openItem() { LLViewerInventoryItem* item = getItem(); + + if (item) + { + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); + } +/* + LLViewerInventoryItem* item = getItem(); if( item ) { // Opening (double-clicking) a landmark immediately teleports, // but warns you the first time. - // open_landmark(item, std::string(" ") + getPrefix() + item->getName(), FALSE); + // open_landmark(item); LLSD payload; payload["asset_id"] = item->getAssetUUID(); LLNotifications::instance().add("TeleportFromLandmark", LLSD(), payload); } +*/ } @@ -2726,8 +2672,6 @@ void LLCallingCardObserver::changed(U32 mask) // | LLCallingCardBridge | // +=================================================+ -std::string LLCallingCardBridge::sPrefix("Calling Card: "); - LLCallingCardBridge::LLCallingCardBridge( LLInventoryPanel* inventory, const LLUUID& uuid ) : LLItemBridge(inventory, uuid) { @@ -2743,7 +2687,8 @@ LLCallingCardBridge::~LLCallingCardBridge() void LLCallingCardBridge::refreshFolderViewItem() { - LLFolderViewItem* itemp = mInventoryPanel->getRootFolder()->getItemByID(mUUID); + LLInventoryPanel* panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get()); + LLFolderViewItem* itemp = panel ? panel->getRootFolder()->getItemByID(mUUID) : NULL; if (itemp) { itemp->refresh(); @@ -2759,7 +2704,6 @@ void LLCallingCardBridge::performAction(LLFolderView* folder, LLInventoryModel* if (item && (item->getCreatorUUID() != gAgent.getID()) && (!item->getCreatorUUID().isNull())) { - gIMMgr->setFloaterOpen(TRUE); gIMMgr->addSession(item->getName(), IM_NOTHING_SPECIAL, item->getCreatorUUID()); } } @@ -2769,7 +2713,7 @@ void LLCallingCardBridge::performAction(LLFolderView* folder, LLInventoryModel* if (item && (item->getCreatorUUID() != gAgent.getID()) && (!item->getCreatorUUID().isNull())) { - handle_lure(item->getCreatorUUID()); + LLFriendActions::offerTeleport(item->getCreatorUUID()); } } else LLItemBridge::performAction(folder, model, action); @@ -2802,17 +2746,22 @@ std::string LLCallingCardBridge::getLabelSuffix() const void LLCallingCardBridge::openItem() { LLViewerInventoryItem* item = getItem(); + + if (item) + { + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); + } +/* + LLViewerInventoryItem* item = getItem(); if(item && !item->getCreatorUUID().isNull()) { - BOOL online; - online = LLAvatarTracker::instance().isBuddyOnline(item->getCreatorUUID()); - LLFloaterAvatarInfo::showFromFriend(item->getCreatorUUID(), online); + LLFriendActions::showProfile(item->getCreatorUUID()); } +*/ } void LLCallingCardBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - // *TODO: Translate lldebugs << "LLCallingCardBridge::buildContextMenu()" << llendl; std::vector<std::string> items; std::vector<std::string> disabled_items; @@ -2933,68 +2882,27 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop, // | LLNotecardBridge | // +=================================================+ -std::string LLNotecardBridge::sPrefix("Note: "); - - LLUIImagePtr LLNotecardBridge::getIcon() const { return get_item_icon(LLAssetType::AT_NOTECARD, LLInventoryType::IT_NOTECARD, 0, FALSE); } -void open_notecard(LLViewerInventoryItem* inv_item, - const std::string& title, - const LLUUID& object_id, - BOOL show_keep_discard, - const LLUUID& source_id, - BOOL take_focus) -{ - // See if we can bring an existing preview to the front - if(!LLPreview::show(inv_item->getUUID(), take_focus)) - { - // There isn't one, so make a new preview - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("NotecardEditorRect"); - rect.translate(left - rect.mLeft, top - rect.mTop); - LLPreviewNotecard* preview; - preview = new LLPreviewNotecard("preview notecard", rect, title, - inv_item->getUUID(), object_id, inv_item->getAssetUUID(), - show_keep_discard, inv_item); - preview->setSourceID(source_id); - if(take_focus) preview->setFocus(TRUE); - // Force to be entirely onscreen. - gFloaterView->adjustToFitScreen(preview, FALSE); - - //if (source_id.notNull()) - //{ - // // look for existing tabbed view for content from same source - // LLPreview* existing_preview = LLPreview::getPreviewForSource(source_id); - // if (existing_preview) - // { - // // found existing preview from this source - // // is it already hosted in a multi-preview window? - // LLMultiPreview* preview_hostp = (LLMultiPreview*)existing_preview->getHost(); - // if (!preview_hostp) - // { - // // create new multipreview if it doesn't exist - // LLMultiPreview* preview_hostp = new LLMultiPreview(existing_preview->getRect()); - // preview_hostp->addFloater(existing_preview); - // } - // // add this preview to existing host - // preview_hostp->addFloater(preview); - // } - //} - } -} - - void LLNotecardBridge::openItem() { LLViewerInventoryItem* item = getItem(); + if (item) { - open_notecard(item, getPrefix() + item->getName(), LLUUID::null, FALSE); + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); } + +/* + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLFloaterReg::showInstance("preview_notecard", LLSD(item->getUUID()), TAKE_FOCUS_YES); + } +*/ } @@ -3002,8 +2910,6 @@ void LLNotecardBridge::openItem() // | LLGestureBridge | // +=================================================+ -std::string LLGestureBridge::sPrefix("Gesture: "); - LLUIImagePtr LLGestureBridge::getIcon() const { return get_item_icon(LLAssetType::AT_GESTURE, LLInventoryType::IT_GESTURE, 0, FALSE); @@ -3066,22 +2972,19 @@ void LLGestureBridge::performAction(LLFolderView* folder, LLInventoryModel* mode void LLGestureBridge::openItem() { LLViewerInventoryItem* item = getItem(); - if (!item) return; - - // See if we can bring an existing preview to the front - if(!LLPreview::show(mUUID)) + + if (item) { - LLUUID item_id = mUUID; - std::string title = getPrefix() + item->getName(); - LLUUID object_id = LLUUID::null; - - // TODO: save the rectangle - LLPreviewGesture* preview = LLPreviewGesture::show(title, item_id, object_id); + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); + } +/* + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLPreviewGesture* preview = LLPreviewGesture::show(mUUID, LLUUID::null); preview->setFocus(TRUE); - - // Force to be entirely onscreen. - gFloaterView->adjustToFitScreen(preview, FALSE); } +*/ } BOOL LLGestureBridge::removeItem() @@ -3093,7 +2996,6 @@ BOOL LLGestureBridge::removeItem() void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - // *TODO: Translate lldebugs << "LLGestureBridge::buildContextMenu()" << llendl; std::vector<std::string> items; std::vector<std::string> disabled_items; @@ -3117,15 +3019,6 @@ void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) items.push_back(std::string("Gesture Separator")); items.push_back(std::string("Activate")); items.push_back(std::string("Deactivate")); - - /*menu.append(new LLMenuItemCallGL("Activate", - handleActivateGesture, - enableActivateGesture, - (void*)this)); - menu.append(new LLMenuItemCallGL("Deactivate", - handleDeactivateGesture, - enableDeactivateGesture, - (void*)this));*/ } hideContextEntries(menu, items, disabled_items); } @@ -3134,9 +3027,6 @@ void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) // | LLAnimationBridge | // +=================================================+ -std::string LLAnimationBridge::sPrefix("Animation: "); - - LLUIImagePtr LLAnimationBridge::getIcon() const { return get_item_icon(LLAssetType::AT_ANIMATION, LLInventoryType::IT_ANIMATION, 0, FALSE); @@ -3144,7 +3034,6 @@ LLUIImagePtr LLAnimationBridge::getIcon() const void LLAnimationBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - // *TODO: Translate std::vector<std::string> items; std::vector<std::string> disabled_items; @@ -3178,32 +3067,18 @@ void LLAnimationBridge::buildContextMenu(LLMenuGL& menu, U32 flags) // virtual void LLAnimationBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { - S32 activate = 0; - if ((action == "playworld") || (action == "playlocal")) { - - if ("playworld" == action) activate = 1; - if ("playlocal" == action) activate = 2; - - // See if we can bring an existing preview to the front - if( !LLPreview::show( mUUID ) ) + if (getItem()) { - // There isn't one, so make a new preview - LLViewerInventoryItem* item = getItem(); - if( item ) + LLPreviewAnim::e_activation_type activate = LLPreviewAnim::NONE; + if ("playworld" == action) activate = LLPreviewAnim::PLAY; + if ("playlocal" == action) activate = LLPreviewAnim::AUDITION; + + LLPreviewAnim* preview = LLFloaterReg::showTypedInstance<LLPreviewAnim>("preview_anim", LLSD(mUUID)); + if (preview) { - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("PreviewAnimRect"); - rect.translate( left - rect.mLeft, top - rect.mTop ); - LLPreviewAnim* preview = new LLPreviewAnim("preview anim", - rect, - getPrefix() + item->getName(), - mUUID, - activate); - // Force to be entirely onscreen. - gFloaterView->adjustToFitScreen(preview, FALSE); + preview->activate(activate); } } } @@ -3215,27 +3090,19 @@ void LLAnimationBridge::performAction(LLFolderView* folder, LLInventoryModel* mo void LLAnimationBridge::openItem() { - // See if we can bring an existing preview to the front - if( !LLPreview::show( mUUID ) ) + LLViewerInventoryItem* item = getItem(); + + if (item) { - // There isn't one, so make a new preview - LLViewerInventoryItem* item = getItem(); - if( item ) - { - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("PreviewAnimRect"); - rect.translate( left - rect.mLeft, top - rect.mTop ); - LLPreviewAnim* preview = new LLPreviewAnim("preview anim", - rect, - getPrefix() + item->getName(), - mUUID, - 0); - preview->setFocus(TRUE); - // Force to be entirely onscreen. - gFloaterView->adjustToFitScreen(preview, FALSE); - } + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); } +/* + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLFloaterReg::showInstance("preview_anim", LLSD(mUUID), TAKE_FOCUS_YES); + } +*/ } // +=================================================+ @@ -3243,14 +3110,11 @@ void LLAnimationBridge::openItem() // +=================================================+ // static -std::string LLObjectBridge::sPrefix("Object: "); - -// static LLUUID LLObjectBridge::sContextMenuItemID; BOOL LLObjectBridge::isItemRemovable() { - LLVOAvatar* avatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); if(!avatar) return FALSE; if(avatar->isWearingAttachment(mUUID)) return FALSE; return LLInvFVBridge::isItemRemovable(); @@ -3261,8 +3125,6 @@ LLUIImagePtr LLObjectBridge::getIcon() const return get_item_icon(LLAssetType::AT_OBJECT, mInvType, mAttachPt, mIsMultiObject ); } -void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment); - // virtual void LLObjectBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { @@ -3318,15 +3180,21 @@ void LLObjectBridge::performAction(LLFolderView* folder, LLInventoryModel* model void LLObjectBridge::openItem() { - /* Disabled -- this preview isn't useful. JC */ - // CP: actually, this code is required - made changes to match LLAnimationBridge::openItem() idiom - // The properties preview is useful, converting to show object properties. - DaveP - LLShowProps::showProperties(mUUID); + LLViewerInventoryItem* item = getItem(); + + if (item) + { + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); + } + + /* + LLFloaterProperties::show(mUUID); + */ } LLFontGL::StyleFlags LLObjectBridge::getLabelStyle() const { - LLVOAvatar* avatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); if( avatar && avatar->isWearingAttachment( mUUID ) ) { return LLFontGL::BOLD; @@ -3339,7 +3207,7 @@ LLFontGL::StyleFlags LLObjectBridge::getLabelStyle() const std::string LLObjectBridge::getLabelSuffix() const { - LLVOAvatar* avatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); if( avatar && avatar->isWearingAttachment( mUUID ) ) { std::string attachment_point_name = avatar->getAttachedPointName(mUUID); @@ -3413,7 +3281,6 @@ static LLNotificationFunctorRegistration confirm_replace_attachment_rez_reg("Rep void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - // *TODO: Translate std::vector<std::string> items; std::vector<std::string> disabled_items; if(isInTrash()) @@ -3437,7 +3304,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) LLInventoryItem* item = getItem(); if(item) { - LLVOAvatar *avatarp = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if( !avatarp ) { return; @@ -3460,35 +3327,36 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) LLMenuGL* attach_menu = menu.getChildMenuByName("Attach To", TRUE); LLMenuGL* attach_hud_menu = menu.getChildMenuByName("Attach To HUD", TRUE); LLVOAvatar *avatarp = gAgent.getAvatarObject(); - if (attach_menu && (attach_menu->getChildCount() == 0) && - attach_hud_menu && (attach_hud_menu->getChildCount() == 0) && - avatarp) + if (attach_menu + && (attach_menu->getChildCount() == 0) + && attach_hud_menu + && (attach_hud_menu->getChildCount() == 0) + && avatarp) { for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); iter != avatarp->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; - LLMenuItemCallGL *new_item; - if (attachment->getIsHUDAttachment()) + LLMenuItemCallGL::Params p; + std::string submenu_name = attachment->getName(); + if (LLTrans::getString(submenu_name) != "") { - attach_hud_menu->append(new_item = new LLMenuItemCallGL(attachment->getName(), - NULL, //&LLObjectBridge::attachToAvatar, - NULL, &attach_label, (void*)attachment)); + p.name = (" ")+LLTrans::getString(submenu_name)+" "; } else { - attach_menu->append(new_item = new LLMenuItemCallGL(attachment->getName(), - NULL, //&LLObjectBridge::attachToAvatar, - NULL, &attach_label, (void*)attachment)); - } - - LLSimpleListener* callback = mInventoryPanel->getListenerByName("Inventory.AttachObject"); - - if (callback) - { - new_item->addListener(callback, "on_click", LLSD(attachment->getName())); + p.name = submenu_name; } + LLSD cbparams; + cbparams["index"] = curiter->first; + cbparams["label"] = attachment->getName(); + p.on_click.function_name = "Inventory.AttachObject"; + p.on_click.parameter = LLSD(attachment->getName()); + p.on_enable.function_name = "Attachment.Label"; + p.on_enable.parameter = cbparams; + LLView* parent = attachment->getIsHUDAttachment() ? attach_hud_menu : attach_menu; + LLUICtrlFactory::create<LLMenuItemCallGL>(p, parent); } } } @@ -3499,10 +3367,12 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) BOOL LLObjectBridge::renameItem(const std::string& new_name) { - if(!isItemRenameable()) return FALSE; - LLPreview::rename(mUUID, getPrefix() + new_name); - LLInventoryModel* model = mInventoryPanel->getModel(); - if(!model) return FALSE; + if(!isItemRenameable()) + return FALSE; + LLPreview::dirty(mUUID); + LLInventoryModel* model = getInventoryModel(); + if(!model) + return FALSE; LLViewerInventoryItem* item = getItem(); if(item && (item->getName() != new_name)) { @@ -3513,7 +3383,7 @@ BOOL LLObjectBridge::renameItem(const std::string& new_name) model->updateItem(new_item); model->notifyObservers(); - LLVOAvatar* avatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); if( avatar ) { LLViewerObject* obj = avatar->getWornAttachment( item->getUUID() ); @@ -3535,8 +3405,6 @@ BOOL LLObjectBridge::renameItem(const std::string& new_name) // | LLLSLTextBridge | // +=================================================+ -std::string LLLSLTextBridge::sPrefix("Script: "); - LLUIImagePtr LLLSLTextBridge::getIcon() const { return get_item_icon(LLAssetType::AT_SCRIPT, LLInventoryType::IT_LSL, 0, FALSE); @@ -3544,27 +3412,19 @@ LLUIImagePtr LLLSLTextBridge::getIcon() const void LLLSLTextBridge::openItem() { - // See if we can bring an exiting preview to the front - if(!LLPreview::show(mUUID)) + LLViewerInventoryItem* item = getItem(); + + if (item) { - LLViewerInventoryItem* item = getItem(); - if (item) - { - // There isn't one, so make a new preview - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - LLRect rect = gSavedSettings.getRect("PreviewScriptRect"); - rect.translate(left - rect.mLeft, top - rect.mTop); - - LLPreviewLSL* preview = new LLPreviewLSL("preview lsl text", - rect, - getPrefix() + item->getName(), - mUUID); - preview->setFocus(TRUE); - // keep onscreen - gFloaterView->adjustToFitScreen(preview, FALSE); - } + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); } + /* + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLFloaterReg::showInstance("preview_script", LLSD(mUUID), TAKE_FOCUS_YES); + } + */ } // +=================================================+ @@ -3579,7 +3439,7 @@ void wear_inventory_item_on_avatar( LLInventoryItem* item ) lldebugs << "wear_inventory_item_on_avatar( " << item->getName() << " )" << llendl; - gWearableList.getAsset(item->getAssetUUID(), + LLWearableList::instance().getAsset(item->getAssetUUID(), item->getName(), item->getType(), LLWearableBridge::onWearOnAvatarArrived, @@ -3587,6 +3447,22 @@ void wear_inventory_item_on_avatar( LLInventoryItem* item ) } } +void wear_add_inventory_item_on_avatar( LLInventoryItem* item ) +{ + if(item) + { + lldebugs << "wear_add_inventory_item_on_avatar( " << item->getName() + << " )" << llendl; + + LLWearableList::instance().getAsset(item->getAssetUUID(), + item->getName(), + item->getType(), + LLWearableBridge::onWearAddOnAvatarArrived, + new LLUUID(item->getUUID())); + } +} + + struct LLFoundData { LLFoundData(const LLUUID& item_id, @@ -3900,30 +3776,18 @@ void wear_inventory_category_on_avatar( LLInventoryCategory* category, BOOL appe lldebugs << "wear_inventory_category_on_avatar( " << category->getName() << " )" << llendl; - LLWearInfo* userdata = new LLWearInfo; - userdata->mAppend = append; - userdata->mCategoryID = category->getUUID(); - if( gFloaterCustomize ) { - gFloaterCustomize->askToSaveIfDirty( - wear_inventory_category_on_avatar_step2, - userdata); + gFloaterCustomize->askToSaveIfDirty(boost::bind(wear_inventory_category_on_avatar_step2, _1, category->getUUID(), append)); } else { - wear_inventory_category_on_avatar_step2( - TRUE, - userdata ); + wear_inventory_category_on_avatar_step2(TRUE, category->getUUID(), append ); } } - -void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) +void wear_inventory_category_on_avatar_step2( BOOL proceed, LLUUID category, BOOL append ) { - LLWearInfo* wear_info = (LLWearInfo*)userdata; - if (!wear_info) return; - // Find all the wearables that are in the category's subtree. lldebugs << "wear_inventory_category_on_avatar_step2()" << llendl; if(proceed) @@ -3931,7 +3795,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t item_array; LLFindWearables is_wearable; - gInventory.collectDescendentsIf(wear_info->mCategoryID, + gInventory.collectDescendentsIf(category, cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH, @@ -3942,7 +3806,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) LLInventoryModel::cat_array_t obj_cat_array; LLInventoryModel::item_array_t obj_item_array; LLIsType is_object( LLAssetType::AT_OBJECT ); - gInventory.collectDescendentsIf(wear_info->mCategoryID, + gInventory.collectDescendentsIf(category, obj_cat_array, obj_item_array, LLInventoryModel::EXCLUDE_TRASH, @@ -3953,7 +3817,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) LLInventoryModel::cat_array_t gest_cat_array; LLInventoryModel::item_array_t gest_item_array; LLIsType is_gesture( LLAssetType::AT_GESTURE ); - gInventory.collectDescendentsIf(wear_info->mCategoryID, + gInventory.collectDescendentsIf(category, gest_cat_array, gest_item_array, LLInventoryModel::EXCLUDE_TRASH, @@ -3963,7 +3827,6 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) if( !wearable_count && !obj_count && !gest_count) { LLNotifications::instance().add("CouldNotPutOnOutfit"); - delete wear_info; return; } @@ -3982,7 +3845,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) // Update the inventory item labels to reflect the fact // they are active. - LLViewerInventoryCategory* catp = gInventory.getCategory(wear_info->mCategoryID); + LLViewerInventoryCategory* catp = gInventory.getCategory(category); if (catp) { gInventory.updateCategory(catp); @@ -4010,10 +3873,10 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) } for(i = 0; i < wearable_count; ++i) { - gAddToOutfit = wear_info->mAppend; + gAddToOutfit = append; found = found_container.get(i); - gWearableList.getAsset(found->mAssetID, + LLWearableList::instance().getAsset(found->mAssetID, found->mName, found->mAssetType, wear_inventory_category_on_avatar_loop, @@ -4023,10 +3886,10 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) //If not appending and the folder doesn't contain only gestures, take off all attachments. - if (!wear_info->mAppend + if (!append && !(wearable_count == 0 && obj_count == 0 && gest_count > 0) ) { - LLAgent::userRemoveAllAttachments(NULL); + LLAgentWearables::userRemoveAllAttachments(NULL); } if( obj_count > 0 ) @@ -4064,7 +3927,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) msg->nextBlockFast(_PREHASH_HeaderData); msg->addUUIDFast(_PREHASH_CompoundMsgID, compound_msg_id ); msg->addU8Fast(_PREHASH_TotalObjects, obj_count ); - msg->addBOOLFast(_PREHASH_FirstDetachAll, !wear_info->mAppend ); + msg->addBOOLFast(_PREHASH_FirstDetachAll, !append ); } LLInventoryItem* item = obj_item_array.get(i); @@ -4085,8 +3948,6 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) } } } - delete wear_info; - wear_info = NULL; } void wear_inventory_category_on_avatar_loop(LLWearable* wearable, void* data) @@ -4135,18 +3996,6 @@ void wear_inventory_category_on_avatar_step3(LLWearableHoldingPattern* holder, B item = (LLViewerInventoryItem*)gInventory.getItem(data->mItemID); if( item && (item->getAssetUUID() == wearable->getID()) ) { - //RN: after discussing with Brashears, I disabled this code - //Metadata should reside in the item, not the asset - //And this code does not handle failed asset uploads properly -// if(!wearable->isMatchedToInventoryItem(item )) -// { -// wearable = gWearableList.createWearableMatchedToInventoryItem( wearable, item ); -// // Now that we have an asset that matches the -// // item, update the item to point to the new -// // asset. -// item->setAssetUUID(wearable->getID()); -// item->updateAssetOnServer(); -// } items.put(item); wearables.put(wearable); } @@ -4157,7 +4006,7 @@ void wear_inventory_category_on_avatar_step3(LLWearableHoldingPattern* holder, B if(wearables.count() > 0) { - gAgent.setWearableOutfit(items, wearables, !append); + gAgentWearables.setWearableOutfit(items, wearables, !append); gInventory.notifyObservers(); } @@ -4173,36 +4022,29 @@ void remove_inventory_category_from_avatar( LLInventoryCategory* category ) << " )" << llendl; - LLUUID* uuid = new LLUUID(category->getUUID()); - if( gFloaterCustomize ) { gFloaterCustomize->askToSaveIfDirty( - remove_inventory_category_from_avatar_step2, - uuid); + boost::bind(remove_inventory_category_from_avatar_step2, _1, category->getUUID())); } else { - remove_inventory_category_from_avatar_step2( - TRUE, - uuid ); + remove_inventory_category_from_avatar_step2(TRUE, category->getUUID() ); } } -void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata) +void remove_inventory_category_from_avatar_step2( BOOL proceed, LLUUID category_id) { // Find all the wearables that are in the category's subtree. - LLUUID* category_id = (LLUUID *)userdata; - lldebugs << "remove_inventory_category_from_avatar_step2()" << llendl; if(proceed) { LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t item_array; LLFindWearables is_wearable; - gInventory.collectDescendentsIf(*category_id, + gInventory.collectDescendentsIf(category_id, cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH, @@ -4213,7 +4055,7 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata) LLInventoryModel::cat_array_t obj_cat_array; LLInventoryModel::item_array_t obj_item_array; LLIsType is_object( LLAssetType::AT_OBJECT ); - gInventory.collectDescendentsIf(*category_id, + gInventory.collectDescendentsIf(category_id, obj_cat_array, obj_item_array, LLInventoryModel::EXCLUDE_TRASH, @@ -4224,7 +4066,7 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata) LLInventoryModel::cat_array_t gest_cat_array; LLInventoryModel::item_array_t gest_item_array; LLIsType is_gesture( LLAssetType::AT_GESTURE ); - gInventory.collectDescendentsIf(*category_id, + gInventory.collectDescendentsIf(category_id, gest_cat_array, gest_item_array, LLInventoryModel::EXCLUDE_TRASH, @@ -4235,9 +4077,9 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata) { for(i = 0; i < wearable_count; ++i) { - if( gAgent.isWearingItem (item_array.get(i)->getUUID()) ) + if( gAgentWearables.isWearingItem (item_array.get(i)->getUUID()) ) { - gWearableList.getAsset(item_array.get(i)->getAssetUUID(), + LLWearableList::instance().getAsset(item_array.get(i)->getAssetUUID(), item_array.get(i)->getName(), item_array.get(i)->getType(), LLWearableBridge::onRemoveFromAvatarArrived, @@ -4286,28 +4128,26 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata) } } } - delete category_id; - category_id = NULL; } BOOL LLWearableBridge::renameItem(const std::string& new_name) { - if( gAgent.isWearingItem( mUUID ) ) + if( gAgentWearables.isWearingItem( mUUID ) ) { - gAgent.setWearableName( mUUID, new_name ); + gAgentWearables.setWearableName( mUUID, new_name ); } return LLItemBridge::renameItem(new_name); } BOOL LLWearableBridge::isItemRemovable() { - if(gAgent.isWearingItem(mUUID)) return FALSE; + if(gAgentWearables.isWearingItem(mUUID)) return FALSE; return LLInvFVBridge::isItemRemovable(); } LLFontGL::StyleFlags LLWearableBridge::getLabelStyle() const { - if( gAgent.isWearingItem( mUUID ) ) + if( gAgentWearables.isWearingItem( mUUID ) ) { // llinfos << "BOLD" << llendl; return LLFontGL::BOLD; @@ -4320,7 +4160,7 @@ LLFontGL::StyleFlags LLWearableBridge::getLabelStyle() const std::string LLWearableBridge::getLabelSuffix() const { - if( gAgent.isWearingItem( mUUID ) ) + if( gAgentWearables.isWearingItem( mUUID ) ) { return LLItemBridge::getLabelSuffix() + " (worn)"; } @@ -4342,6 +4182,10 @@ void LLWearableBridge::performAction(LLFolderView* folder, LLInventoryModel* mod { wearOnAvatar(); } + else if ("wear_add" == action) + { + wearAddOnAvatar(); + } else if ("edit" == action) { editOnAvatar(); @@ -4349,12 +4193,12 @@ void LLWearableBridge::performAction(LLFolderView* folder, LLInventoryModel* mod } else if ("take_off" == action) { - if(gAgent.isWearingItem(mUUID)) + if(gAgentWearables.isWearingItem(mUUID)) { LLViewerInventoryItem* item = getItem(); if (item) { - gWearableList.getAsset(item->getAssetUUID(), + LLWearableList::instance().getAsset(item->getAssetUUID(), item->getName(), item->getType(), LLWearableBridge::onRemoveFromAvatarArrived, @@ -4367,13 +4211,20 @@ void LLWearableBridge::performAction(LLFolderView* folder, LLInventoryModel* mod void LLWearableBridge::openItem() { + LLViewerInventoryItem* item = getItem(); + + if (item) + { + LLInvFVBridgeAction::doAction(item->getType(),mUUID,getInventoryModel()); + } + /* if( isInTrash() ) { LLNotifications::instance().add("CannotWearTrash"); } else if(isAgentInventory()) { - if( !gAgent.isWearingItem( mUUID ) ) + if( !gAgentWearables.isWearingItem( mUUID ) ) { wearOnAvatar(); } @@ -4401,11 +4252,11 @@ void LLWearableBridge::openItem() LLNotifications::instance().add("CannotWearInfoNotComplete"); } } + */ } void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - // *TODO: Translate lldebugs << "LLWearableBridge::buildContextMenu()" << llendl; std::vector<std::string> items; std::vector<std::string> disabled_items; @@ -4442,29 +4293,17 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 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) { disabled_items.push_back(std::string("Wearable Edit")); } - //menu.appendSeparator(); - //menu.append(new LLMenuItemCallGL("Wear", - // LLWearableBridge::onWearOnAvatar, - // LLWearableBridge::canWearOnAvatar, - // (void*)this)); - //menu.append(new LLMenuItemCallGL("Edit", - // LLWearableBridge::onEditOnAvatar, - // LLWearableBridge::canEditOnAvatar, - // (void*)this)); if( item && (item->getType() == LLAssetType::AT_CLOTHING) ) { items.push_back(std::string("Take Off")); - /*menu.append(new LLMenuItemCallGL("Take Off", - LLWearableBridge::onRemoveFromAvatar, - LLWearableBridge::canRemoveFromAvatar, - (void*)this));*/ } } hideContextEntries(menu, items, disabled_items); @@ -4481,7 +4320,7 @@ BOOL LLWearableBridge::canWearOnAvatar(void* user_data) LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem(); if(!item || !item->isComplete()) return FALSE; } - return (!gAgent.isWearingItem(self->mUUID)); + return (!gAgentWearables.isWearingItem(self->mUUID)); } // Called from menus @@ -4497,7 +4336,7 @@ void LLWearableBridge::wearOnAvatar() { // Don't wear anything until initial wearables are loaded, can // destroy clothing items. - if (!gAgent.areWearablesLoaded()) + if (!gAgentWearables.areWearablesLoaded()) { LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); return; @@ -4524,6 +4363,37 @@ void LLWearableBridge::wearOnAvatar() } } +void LLWearableBridge::wearAddOnAvatar() +{ + // Don't wear anything until initial wearables are loaded, can + // destroy clothing items. + if (!gAgentWearables.areWearablesLoaded()) + { + LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); + return; + } + + LLViewerInventoryItem* item = getItem(); + if(item) + { + if(!isAgentInventory()) + { + LLPointer<LLInventoryCallback> cb = new WearOnAvatarCallback(); + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + LLUUID::null, + std::string(), + cb); + } + else + { + wear_add_inventory_item_on_avatar(item); + } + } +} + // static void LLWearableBridge::onWearOnAvatarArrived( LLWearable* wearable, void* userdata ) { @@ -4536,22 +4406,33 @@ void LLWearableBridge::onWearOnAvatarArrived( LLWearable* wearable, void* userda { if(item->getAssetUUID() == wearable->getID()) { - //RN: after discussing with Brashears, I disabled this code - //Metadata should reside in the item, not the asset - //And this code does not handle failed asset uploads properly + gAgentWearables.setWearable(item, wearable); + gInventory.notifyObservers(); + //self->getFolderItem()->refreshFromRoot(); + } + else + { + llinfos << "By the time wearable asset arrived, its inv item already pointed to a different asset." << llendl; + } + } + } + delete item_id; +} -// if(!wearable->isMatchedToInventoryItem(item)) -// { -// LLWearable* new_wearable = gWearableList.createWearableMatchedToInventoryItem( wearable, item ); -// -// // Now that we have an asset that matches the -// // item, update the item to point to the new -// // asset. -// item->setAssetUUID(new_wearable->getID()); -// item->updateAssetOnServer(); -// wearable = new_wearable; -// } - gAgent.setWearable(item, wearable); +// static +void LLWearableBridge::onWearAddOnAvatarArrived( LLWearable* wearable, void* userdata ) +{ + LLUUID* item_id = (LLUUID*) userdata; + if(wearable) + { + LLViewerInventoryItem* item = NULL; + item = (LLViewerInventoryItem*)gInventory.getItem(*item_id); + if(item) + { + if(item->getAssetUUID() == wearable->getID()) + { + bool do_append = true; + gAgentWearables.setWearable(item, wearable, do_append); gInventory.notifyObservers(); //self->getFolderItem()->refreshFromRoot(); } @@ -4570,7 +4451,7 @@ BOOL LLWearableBridge::canEditOnAvatar(void* user_data) LLWearableBridge* self = (LLWearableBridge*)user_data; if(!self) return FALSE; - return (gAgent.isWearingItem(self->mUUID)); + return (gAgentWearables.isWearingItem(self->mUUID)); } // static @@ -4585,11 +4466,12 @@ void LLWearableBridge::onEditOnAvatar(void* user_data) void LLWearableBridge::editOnAvatar() { - LLWearable* wearable = gAgent.getWearableFromWearableItem(mUUID); + LLWearable* wearable = gAgentWearables.getWearableFromWearableItem(mUUID); if( wearable ) { // Set the tab to the right wearable. - LLFloaterCustomize::setCurrentWearableType( wearable->getType() ); + if (gFloaterCustomize) + gFloaterCustomize->setCurrentWearableType( wearable->getType() ); if( CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode() ) { @@ -4605,7 +4487,7 @@ BOOL LLWearableBridge::canRemoveFromAvatar(void* user_data) LLWearableBridge* self = (LLWearableBridge*)user_data; if( self && (LLAssetType::AT_BODYPART != self->mAssetType) ) { - return gAgent.isWearingItem( self->mUUID ); + return gAgentWearables.isWearingItem( self->mUUID ); } return FALSE; } @@ -4615,12 +4497,12 @@ void LLWearableBridge::onRemoveFromAvatar(void* user_data) { LLWearableBridge* self = (LLWearableBridge*)user_data; if(!self) return; - if(gAgent.isWearingItem(self->mUUID)) + if(gAgentWearables.isWearingItem(self->mUUID)) { LLViewerInventoryItem* item = self->getItem(); if (item) { - gWearableList.getAsset(item->getAssetUUID(), + LLWearableList::instance().getAsset(item->getAssetUUID(), item->getName(), item->getType(), onRemoveFromAvatarArrived, @@ -4636,16 +4518,304 @@ void LLWearableBridge::onRemoveFromAvatarArrived(LLWearable* wearable, LLUUID* item_id = (LLUUID*) userdata; if(wearable) { - if( gAgent.isWearingItem( *item_id ) ) + if( gAgentWearables.isWearingItem( *item_id ) ) { EWearableType type = wearable->getType(); if( !(type==WT_SHAPE || type==WT_SKIN || type==WT_HAIR || type==WT_EYES ) ) //&& //!((!gAgent.isTeen()) && ( type==WT_UNDERPANTS || type==WT_UNDERSHIRT )) ) { - gAgent.removeWearable( type ); + // MULTI_WEARABLE: FIXME HACK - always remove all + bool do_remove_all = false; + gAgentWearables.removeWearable( type, do_remove_all, 0 ); } } } delete item_id; } + + +LLInvFVBridgeAction* LLInvFVBridgeAction::createAction(LLAssetType::EType asset_type, + const LLUUID& uuid,LLInventoryModel* model) +{ + LLInvFVBridgeAction* action = NULL; + switch(asset_type) + { + case LLAssetType::AT_TEXTURE: + action = new LLTextureBridgeAction(uuid,model); + break; + + case LLAssetType::AT_SOUND: + action = new LLSoundBridgeAction(uuid,model); + break; + + case LLAssetType::AT_LANDMARK: + action = new LLLandmarkBridgeAction(uuid,model); + break; + + case LLAssetType::AT_CALLINGCARD: + action = new LLCallingCardBridgeAction(uuid,model); + break; + + case LLAssetType::AT_OBJECT: + action = new LLObjectBridgeAction(uuid,model); + break; + + case LLAssetType::AT_NOTECARD: + action = new LLNotecardBridgeAction(uuid,model); + break; + + case LLAssetType::AT_ANIMATION: + action = new LLAnimationBridgeAction(uuid,model); + break; + + case LLAssetType::AT_GESTURE: + action = new LLGestureBridgeAction(uuid,model); + break; + + case LLAssetType::AT_LSL_TEXT: + action = new LLLSLTextBridgeAction(uuid,model); + break; + + case LLAssetType::AT_CLOTHING: + case LLAssetType::AT_BODYPART: + action = new LLWearableBridgeAction(uuid,model); + + break; + + default: + break; + } + return action; +} + +//static +void LLInvFVBridgeAction::doAction(LLAssetType::EType asset_type, + const LLUUID& uuid,LLInventoryModel* model) +{ + LLInvFVBridgeAction* action = createAction(asset_type,uuid,model); + if(action) + { + action->doIt(); + delete action; + } +} + +//static +void LLInvFVBridgeAction::doAction(const LLUUID& uuid, LLInventoryModel* model) +{ + LLAssetType::EType asset_type = model->getItem(uuid)->getType(); + LLInvFVBridgeAction* action = createAction(asset_type,uuid,model); + if(action) + { + action->doIt(); + delete action; + } +} + +LLViewerInventoryItem* LLInvFVBridgeAction::getItem() const +{ + if(mModel) + return (LLViewerInventoryItem*)mModel->getItem(mUUID); + return NULL; +} + +//virtual +void LLTextureBridgeAction::doIt() +{ + if (getItem()) + { + LLFloaterReg::showInstance("preview_texture", LLSD(mUUID), TAKE_FOCUS_YES); + } + + LLInvFVBridgeAction::doIt(); +} + +//virtual +void LLSoundBridgeAction::doIt() +{ + LLViewerInventoryItem* item = getItem(); + if(item) + { + LLFloaterReg::showInstance("preview_sound", LLSD(mUUID), TAKE_FOCUS_YES); + } + + LLInvFVBridgeAction::doIt(); +} + + +//virtual +void LLLandmarkBridgeAction::doIt() +{ + LLViewerInventoryItem* item = getItem(); + if( item ) + { + // Opening (double-clicking) a landmark immediately teleports, + // but warns you the first time. + LLSD payload; + payload["asset_id"] = item->getAssetUUID(); + LLNotifications::instance().add("TeleportFromLandmark", LLSD(), payload); + } + + LLInvFVBridgeAction::doIt(); +} + + +//virtual +void LLCallingCardBridgeAction::doIt() +{ + LLViewerInventoryItem* item = getItem(); + if(item && item->getCreatorUUID().notNull()) + { + LLFriendActions::showProfile(item->getCreatorUUID()); + } + + LLInvFVBridgeAction::doIt(); +} + +//virtual +void +LLNotecardBridgeAction::doIt() +{ + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLFloaterReg::showInstance("preview_notecard", LLSD(item->getUUID()), TAKE_FOCUS_YES); + } + + LLInvFVBridgeAction::doIt(); +} + +//virtual +void LLGestureBridgeAction::doIt() +{ + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLPreviewGesture* preview = LLPreviewGesture::show(mUUID, LLUUID::null); + preview->setFocus(TRUE); + } + + LLInvFVBridgeAction::doIt(); +} + +//virtual +void LLAnimationBridgeAction::doIt() +{ + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLFloaterReg::showInstance("preview_anim", LLSD(mUUID), TAKE_FOCUS_YES); + } + + LLInvFVBridgeAction::doIt(); +} + + +//virtual +void LLObjectBridgeAction::doIt() +{ + LLFloaterProperties::show(mUUID); + + LLInvFVBridgeAction::doIt(); +} + + +//virtual +void LLLSLTextBridgeAction::doIt() +{ + LLViewerInventoryItem* item = getItem(); + if (item) + { + LLFloaterReg::showInstance("preview_script", LLSD(mUUID), TAKE_FOCUS_YES); + } + + LLInvFVBridgeAction::doIt(); +} + + +BOOL LLWearableBridgeAction::isInTrash() const +{ + if(!mModel) return FALSE; + LLUUID trash_id = mModel->findCategoryUUIDForType(LLAssetType::AT_TRASH); + return mModel->isObjectDescendentOf(mUUID, trash_id); +} + +BOOL LLWearableBridgeAction::isAgentInventory() const +{ + if(!mModel) return FALSE; + if(gAgent.getInventoryRootID() == mUUID) return TRUE; + return mModel->isObjectDescendentOf(mUUID, gAgent.getInventoryRootID()); +} + +void LLWearableBridgeAction::wearOnAvatar() +{ + // Don't wear anything until initial wearables are loaded, can + // destroy clothing items. + if (!gAgentWearables.areWearablesLoaded()) + { + LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); + return; + } + + LLViewerInventoryItem* item = getItem(); + if(item) + { + if(!isAgentInventory()) + { + LLPointer<LLInventoryCallback> cb = new WearOnAvatarCallback(); + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + LLUUID::null, + std::string(), + cb); + } + else + { + wear_inventory_item_on_avatar(item); + } + } +} + +//virtual +void LLWearableBridgeAction::doIt() +{ + if( isInTrash() ) + { + LLNotifications::instance().add("CannotWearTrash"); + } + else if(isAgentInventory()) + { + if( !gAgentWearables.isWearingItem( mUUID ) ) + { + wearOnAvatar(); + } + } + else + { + // must be in the inventory library. copy it to our inventory + // and put it on right away. + LLViewerInventoryItem* item = getItem(); + if(item && item->isComplete()) + { + LLPointer<LLInventoryCallback> cb = new WearOnAvatarCallback(); + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + LLUUID::null, + std::string(), + cb); + } + else if(item) + { + // *TODO: We should fetch the item details, and then do + // the operation above. + LLNotifications::instance().add("CannotWearInfoNotComplete"); + } + } + + LLInvFVBridgeAction::doIt(); +} |