diff options
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 151 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.h | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 10 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/strings.xml | 2 |
4 files changed, 161 insertions, 4 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 64bc486767..349ba6183b 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -107,6 +107,7 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response bool confirm_attachment_rez(const LLSD& notification, const LLSD& response); void teleport_via_landmark(const LLUUID& asset_id); static BOOL can_move_to_outfit(LLInventoryItem* inv_item, BOOL move_is_into_current_outfit); +static bool can_move_to_my_outfits(LLInventoryModel* model, LLInventoryCategory* inv_cat, U32 wear_limit); static BOOL can_move_to_landmarks(LLInventoryItem* inv_item); static bool check_category(LLInventoryModel* model, const LLUUID& cat_id, @@ -2506,9 +2507,28 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, is_movable = FALSE; // tooltip? } + + U32 max_items_to_wear = gSavedSettings.getU32("WearFolderLimit"); if (is_movable && move_is_into_outfit) { - if((mUUID == my_outifts_id) || (getCategory() && getCategory()->getPreferredType() == LLFolderType::FT_NONE)) + if (mUUID == my_outifts_id) + { + if (source != LLToolDragAndDrop::SOURCE_AGENT || move_is_from_marketplacelistings) + { + tooltip_msg = LLTrans::getString("TooltipOutfitNotInInventory"); + is_movable = false; + } + else if (can_move_to_my_outfits(model, inv_cat, max_items_to_wear)) + { + is_movable = true; + } + else + { + tooltip_msg = LLTrans::getString("TooltipCantCreateOutfit"); + is_movable = false; + } + } + else if(getCategory() && getCategory()->getPreferredType() == LLFolderType::FT_NONE) { is_movable = ((inv_cat->getPreferredType() == LLFolderType::FT_NONE) || (inv_cat->getPreferredType() == LLFolderType::FT_OUTFIT)); } @@ -2553,7 +2573,6 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, } } } - U32 max_items_to_wear = gSavedSettings.getU32("WearFolderLimit"); if (is_movable && move_is_into_current_outfit && descendent_items.size() > max_items_to_wear) @@ -2708,8 +2727,14 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, } } + if (mUUID == my_outifts_id) + { + // Category can contains objects, + // create a new folder and populate it with links to original objects + dropToMyOutfits(inv_cat); + } // if target is current outfit folder we use link - if (move_is_into_current_outfit && + else if (move_is_into_current_outfit && (inv_cat->getPreferredType() == LLFolderType::FT_NONE || inv_cat->getPreferredType() == LLFolderType::FT_OUTFIT)) { @@ -3719,12 +3744,40 @@ void LLFolderBridge::perform_pasteFromClipboard() return; } } - if (move_is_into_current_outfit || move_is_into_outfit) + if (move_is_into_outfit) + { + if (!move_is_into_my_outfits && item && can_move_to_outfit(item, move_is_into_current_outfit)) + { + dropToOutfit(item, move_is_into_current_outfit); + } + else if (move_is_into_my_outfits && LLAssetType::AT_CATEGORY == obj->getType()) + { + LLInventoryCategory* cat = model->getCategory(item_id); + U32 max_items_to_wear = gSavedSettings.getU32("WearFolderLimit"); + if (cat && can_move_to_my_outfits(model, cat, max_items_to_wear)) + { + dropToMyOutfits(cat); + } + else + { + LLNotificationsUtil::add("MyOutfitsPasteFailed"); + } + } + else + { + LLNotificationsUtil::add("MyOutfitsPasteFailed"); + } + } + else if (move_is_into_current_outfit) { if (item && can_move_to_outfit(item, move_is_into_current_outfit)) { dropToOutfit(item, move_is_into_current_outfit); } + else + { + LLNotificationsUtil::add("MyOutfitsPasteFailed"); + } } else if (move_is_into_favorites) { @@ -4670,6 +4723,46 @@ static BOOL can_move_to_outfit(LLInventoryItem* inv_item, BOOL move_is_into_curr return TRUE; } +// Returns true if folder's content can be moved to Current Outfit or any outfit folder. +static bool can_move_to_my_outfits(LLInventoryModel* model, LLInventoryCategory* inv_cat, U32 wear_limit) +{ + LLInventoryModel::cat_array_t *cats; + LLInventoryModel::item_array_t *items; + model->getDirectDescendentsOf(inv_cat->getUUID(), cats, items); + + if (items->size() > wear_limit) + { + return false; + } + + if (items->size() == 0) + { + // Nothing to move(create) + return false; + } + + if (cats->size() > 0) + { + // We do not allow subfolders in outfits of "My Outfits" yet + return false; + } + + LLInventoryModel::item_array_t::iterator iter = items->begin(); + LLInventoryModel::item_array_t::iterator end = items->end(); + + while (iter != end) + { + LLViewerInventoryItem *item = *iter; + if (!can_move_to_outfit(item, false)) + { + return false; + } + iter++; + } + + return true; +} + // Returns TRUE if item is a landmark or a link to a landmark // and can be moved to Favorites or Landmarks folder. static BOOL can_move_to_landmarks(LLInventoryItem* inv_item) @@ -4738,6 +4831,56 @@ void LLFolderBridge::dropToOutfit(LLInventoryItem* inv_item, BOOL move_is_into_c } } +void LLFolderBridge::dropToMyOutfits(LLInventoryCategory* inv_cat) +{ + // make a folder in the My Outfits directory. + const LLUUID dest_id = getInventoryModel()->findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + + // Note: creation will take time, so passing folder id to callback is slightly unreliable, + // but so is collecting and passing descendants' ids + inventory_func_type func = boost::bind(&LLFolderBridge::outfitFolderCreatedCallback, this, inv_cat->getUUID(), _1); + gInventory.createNewCategory(dest_id, + LLFolderType::FT_OUTFIT, + inv_cat->getName(), + func); +} + +void LLFolderBridge::outfitFolderCreatedCallback(LLUUID cat_source_id, LLUUID cat_dest_id) +{ + LLInventoryModel::cat_array_t* categories; + LLInventoryModel::item_array_t* items; + getInventoryModel()->getDirectDescendentsOf(cat_source_id, categories, items); + + LLInventoryObject::const_object_list_t link_array; + + + LLInventoryModel::item_array_t::iterator iter = items->begin(); + LLInventoryModel::item_array_t::iterator end = items->end(); + while (iter!=end) + { + const LLViewerInventoryItem* item = (*iter); + // By this point everything is supposed to be filtered, + // but there was a delay to create folder so something could have changed + LLInventoryType::EType inv_type = item->getInventoryType(); + if ((inv_type == LLInventoryType::IT_WEARABLE) || + (inv_type == LLInventoryType::IT_GESTURE) || + (inv_type == LLInventoryType::IT_ATTACHMENT) || + (inv_type == LLInventoryType::IT_OBJECT) || + (inv_type == LLInventoryType::IT_SNAPSHOT) || + (inv_type == LLInventoryType::IT_TEXTURE)) + { + link_array.push_back(LLConstPointer<LLInventoryObject>(item)); + } + iter++; + } + + if (!link_array.empty()) + { + LLPointer<LLInventoryCallback> cb = NULL; + link_inventory_array(cat_dest_id, link_array, cb); + } +} + // Callback for drop item if DAMA required... void LLFolderBridge::callback_dropItemIntoFolder(const LLSD& notification, const LLSD& response, LLInventoryItem* inv_item) { diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index f4df566fa6..0823cf8b52 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -359,6 +359,7 @@ protected: void dropToFavorites(LLInventoryItem* inv_item); void dropToOutfit(LLInventoryItem* inv_item, BOOL move_is_into_current_outfit); + void dropToMyOutfits(LLInventoryCategory* inv_cat); //-------------------------------------------------------------------- // Messy hacks for handling folder options @@ -368,6 +369,7 @@ public: static void staticFolderOptionsMenu(); protected: + void outfitFolderCreatedCallback(LLUUID cat_source_id, LLUUID cat_dest_id); void callback_pasteFromClipboard(const LLSD& notification, const LLSD& response); void perform_pasteFromClipboard(); void gatherMessage(std::string& message, S32 depth, LLError::ELevel log_level); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 6e710f053c..465652cfde 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -326,6 +326,16 @@ Initialization with the Marketplace failed because of a system or network error. name="okbutton" yestext="OK"/> </notification> + + <notification + icon="OutboxStatus_Error" + name="MyOutfitsPasteFailed" + type="alertmodal"> + One or more items can't be used inside "My outfits" + <usetemplate + name="okbutton" + yestext="OK"/> + </notification> <notification icon="OutboxStatus_Error" diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 8fa339a946..71ab490547 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -263,6 +263,8 @@ Please try logging in again in a minute.</string> <string name="TooltipOutboxDragActive">You can't move a listed listing</string> <string name="TooltipOutboxCannotMoveRoot">You can't move the marketplace listings root folder</string> <string name="TooltipOutboxMixedStock">All items in a stock folder must have the same type and permission</string> + <string name="TooltipOutfitNotInInventory">You can only put items or outfits from your personal inventory into "My outfits"</string> + <string name="TooltipCantCreateOutfit">One or more items can't be used inside "My outfits"</string> <string name="TooltipDragOntoOwnChild">You can't move a folder into its child</string> <string name="TooltipDragOntoSelf">You can't move a folder into itself</string> |