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/llviewerinventory.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/llviewerinventory.cpp')
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 199 |
1 files changed, 191 insertions, 8 deletions
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index f47d0777b0..45d24ee7e8 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -44,12 +44,14 @@ #include "llimview.h" #include "llgesturemgr.h" +#include "llinventorybridge.h" #include "llinventoryview.h" #include "llviewerregion.h" #include "llviewerobjectlist.h" #include "llpreviewgesture.h" #include "llviewerwindow.h" +#include "lltrans.h" ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs @@ -307,8 +309,8 @@ bool LLViewerInventoryItem::exportFileLocal(LLFILE* fp) const fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str()); mPermissions.exportFile(fp); fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType)); - const char* inv_type_str = LLInventoryType::lookup(mInventoryType); - if(inv_type_str) fprintf(fp, "\t\tinv_type\t%s\n", inv_type_str); + const std::string inv_type_str = LLInventoryType::lookup(mInventoryType); + if(!inv_type_str.empty()) fprintf(fp, "\t\tinv_type\t%s\n", inv_type_str.c_str()); fprintf(fp, "\t\tname\t%s|\n", mName.c_str()); fprintf(fp, "\t\tcreation_date\t%d\n", (S32) mCreationDate); fprintf(fp,"\t}\n"); @@ -684,12 +686,9 @@ void CreateGestureCallback::fire(const LLUUID& inv_item) gInventory.updateItem(item); gInventory.notifyObservers(); - if(!LLPreview::show(inv_item,FALSE)) - { - LLPreviewGesture* preview = LLPreviewGesture::show(std::string("Gesture: ") + item->getName(), inv_item, LLUUID::null); - // Force to be entirely onscreen. - gFloaterView->adjustToFitScreen(preview, FALSE); - } + LLPreviewGesture* preview = LLPreviewGesture::show(inv_item, LLUUID::null); + // Force to be entirely onscreen. + gFloaterView->adjustToFitScreen(preview, FALSE); } LLInventoryCallbackManager gInventoryCallbacks; @@ -800,3 +799,187 @@ void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecar viewer_region->getCapAPI().post(request); } + +void create_new_item(const std::string& name, + const LLUUID& parent_id, + LLAssetType::EType asset_type, + LLInventoryType::EType inv_type, + U32 next_owner_perm) +{ + std::string desc; + LLAssetType::generateDescriptionFor(asset_type, desc); + next_owner_perm = (next_owner_perm) ? next_owner_perm : PERM_MOVE | PERM_TRANSFER; + + + if (inv_type == LLInventoryType::IT_GESTURE) + { + LLPointer<LLInventoryCallback> cb = new CreateGestureCallback(); + create_inventory_item(gAgent.getID(), gAgent.getSessionID(), + parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, + NOT_WEARABLE, next_owner_perm, cb); + } + else + { + LLPointer<LLInventoryCallback> cb = NULL; + create_inventory_item(gAgent.getID(), gAgent.getSessionID(), + parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, + NOT_WEARABLE, next_owner_perm, cb); + } + +} + +const std::string NEW_LSL_NAME = "New Script"; // *TODO:Translate? (probably not) +const std::string NEW_NOTECARD_NAME = "New Note"; // *TODO:Translate? (probably not) +const std::string NEW_GESTURE_NAME = "New Gesture"; // *TODO:Translate? (probably not) + +void menu_create_inventory_item(LLFolderView* folder, LLFolderBridge *bridge, const LLSD& userdata) +{ + std::string type = userdata.asString(); + + if ("category" == type) + { + LLUUID category; + if (bridge) + { + category = gInventory.createNewCategory(bridge->getUUID(), LLAssetType::AT_NONE, LLStringUtil::null); + } + else + { + category = gInventory.createNewCategory(gAgent.getInventoryRootID(), LLAssetType::AT_NONE, LLStringUtil::null); + } + gInventory.notifyObservers(); + folder->setSelectionByID(category, TRUE); + } + else if ("lsl" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_LSL_TEXT); + create_new_item(NEW_LSL_NAME, + parent_id, + LLAssetType::AT_LSL_TEXT, + LLInventoryType::IT_LSL, + PERM_MOVE | PERM_TRANSFER); + } + else if ("notecard" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_NOTECARD); + create_new_item(NEW_NOTECARD_NAME, + parent_id, + LLAssetType::AT_NOTECARD, + LLInventoryType::IT_NOTECARD, + PERM_ALL); + } + else if ("gesture" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_GESTURE); + create_new_item(NEW_GESTURE_NAME, + parent_id, + LLAssetType::AT_GESTURE, + LLInventoryType::IT_GESTURE, + PERM_ALL); + } + else if ("shirt" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_SHIRT); + } + else if ("pants" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_PANTS); + } + else if ("shoes" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_SHOES); + } + else if ("socks" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_SOCKS); + } + else if ("jacket" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_JACKET); + } + else if ("skirt" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_SKIRT); + } + else if ("gloves" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_GLOVES); + } + else if ("undershirt" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_UNDERSHIRT); + } + else if ("underpants" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); + LLFolderBridge::createWearable(parent_id, WT_UNDERPANTS); + } + else if ("shape" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART); + LLFolderBridge::createWearable(parent_id, WT_SHAPE); + } + else if ("skin" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART); + LLFolderBridge::createWearable(parent_id, WT_SKIN); + } + else if ("hair" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART); + LLFolderBridge::createWearable(parent_id, WT_HAIR); + } + else if ("eyes" == type) + { + LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART); + LLFolderBridge::createWearable(parent_id, WT_EYES); + } + + folder->setNeedsAutoRename(TRUE); +} + +LLAssetType::EType LLViewerInventoryItem::getType() const +{ + if (mType == LLAssetType::AT_LINK) + { + LLInventoryItem *linked_item = gInventory.getItem(mAssetUUID); + if (linked_item) + { + return linked_item->getType(); + } + } + return LLInventoryItem::getType(); +} + +const LLUUID& LLViewerInventoryItem::getAssetUUID() const +{ + if (mType == LLAssetType::AT_LINK) + { + LLInventoryItem *linked_item = gInventory.getItem(mAssetUUID); + if (linked_item) + { + return linked_item->getAssetUUID(); + } + } + + return LLInventoryItem::getAssetUUID(); +} + +const std::string& LLViewerInventoryItem::getName() const +{ + if (mType == LLAssetType::AT_LINK) + { + return LLInventoryItem::getName(); //+" link"; + } + + return LLInventoryItem::getName(); +} + |