From e13a1ccdaa015bc392a65f82a23303ee8c71deac Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 4 Sep 2019 17:39:26 +0300 Subject: SL-11217 Show confirmation when replacing skin,shape,eyes or hairbase with item which doesn't match the type. --- indra/newview/llfloaterlinkreplace.cpp | 85 ++++++++++++++++------ indra/newview/llfloaterlinkreplace.h | 1 + .../newview/skins/default/xui/en/notifications.xml | 14 ++++ 3 files changed, 76 insertions(+), 24 deletions(-) diff --git a/indra/newview/llfloaterlinkreplace.cpp b/indra/newview/llfloaterlinkreplace.cpp index 10cce3bd22..595d584799 100644 --- a/indra/newview/llfloaterlinkreplace.cpp +++ b/indra/newview/llfloaterlinkreplace.cpp @@ -32,6 +32,8 @@ #include "llagent.h" #include "llappearancemgr.h" #include "lllineeditor.h" +#include "llnotificationsutil.h" +#include "llnotifications.h" #include "lltextbox.h" #include "llviewercontrol.h" @@ -142,37 +144,72 @@ void LLFloaterLinkReplace::onStartClicked() LL_WARNS() << "Cannot replace. Source and target are identical." << LL_ENDL; return; } + + const LLUUID& source_item_id = gInventory.getLinkedItemID(mSourceUUID); + LLViewerInventoryItem *source_item = gInventory.getItem(source_item_id); + const LLUUID& target_item_id = gInventory.getLinkedItemID(mTargetUUID); + LLViewerInventoryItem *target_item = gInventory.getItem(target_item_id); - LLInventoryModel::cat_array_t cat_array; - LLLinkedItemIDMatches is_linked_item_match(mSourceUUID); - gInventory.collectDescendentsIf(gInventory.getRootFolderID(), - cat_array, - mRemainingInventoryItems, - LLInventoryModel::INCLUDE_TRASH, - is_linked_item_match); - LL_INFOS() << "Found " << mRemainingInventoryItems.size() << " inventory links that need to be replaced." << LL_ENDL; - if (mRemainingInventoryItems.size() > 0) + LLNotification::Params params("ConfirmReplaceLink"); + params.functor.function(boost::bind(&LLFloaterLinkReplace::onStartClickedResponse, this, _1, _2)); + if (source_item && source_item->isWearableType() && source_item->getWearableType() <= LLWearableType::WT_EYES) { - LLViewerInventoryItem* target_item = gInventory.getItem(mTargetUUID); - if (target_item) + if(target_item && target_item->isWearableType() && source_item->getWearableType() == target_item->getWearableType()) { - mRemainingItems = (U32)mRemainingInventoryItems.size(); - - LLStringUtil::format_map_t args; - args["NUM"] = llformat("%d", mRemainingItems); - mStatusText->setText(getString("ItemsRemaining", args)); - - mStartBtn->setEnabled(FALSE); - mRefreshBtn->setEnabled(FALSE); - - mEventTimer.start(); - tick(); + LLNotifications::instance().forceResponse(params, 0); } else { - mStatusText->setText(getString("TargetNotFound")); - LL_WARNS() << "Link replace target not found." << LL_ENDL; + LLSD args; + args["TYPE"] = LLWearableType::getTypeName(source_item->getWearableType()); + params.substitutions(args); + LLNotifications::instance().add(params); + } + } + else + { + LLNotifications::instance().forceResponse(params, 0); + } +} + +void LLFloaterLinkReplace::onStartClickedResponse(const LLSD& notification, const LLSD& response) +{ + + if (LLNotificationsUtil::getSelectedOption(notification, response) == 0) + { + + LLInventoryModel::cat_array_t cat_array; + LLLinkedItemIDMatches is_linked_item_match(mSourceUUID); + gInventory.collectDescendentsIf(gInventory.getRootFolderID(), + cat_array, + mRemainingInventoryItems, + LLInventoryModel::INCLUDE_TRASH, + is_linked_item_match); + LL_INFOS() << "Found " << mRemainingInventoryItems.size() << " inventory links that need to be replaced." << LL_ENDL; + + if (mRemainingInventoryItems.size() > 0) + { + LLViewerInventoryItem* target_item = gInventory.getItem(mTargetUUID); + if (target_item) + { + mRemainingItems = (U32)mRemainingInventoryItems.size(); + + LLStringUtil::format_map_t args; + args["NUM"] = llformat("%d", mRemainingItems); + mStatusText->setText(getString("ItemsRemaining", args)); + + mStartBtn->setEnabled(FALSE); + mRefreshBtn->setEnabled(FALSE); + + mEventTimer.start(); + tick(); + } + else + { + mStatusText->setText(getString("TargetNotFound")); + LL_WARNS() << "Link replace target not found." << LL_ENDL; + } } } } diff --git a/indra/newview/llfloaterlinkreplace.h b/indra/newview/llfloaterlinkreplace.h index dd5c301206..060773f93e 100644 --- a/indra/newview/llfloaterlinkreplace.h +++ b/indra/newview/llfloaterlinkreplace.h @@ -94,6 +94,7 @@ public: private: void checkEnableStart(); void onStartClicked(); + void onStartClickedResponse(const LLSD& notification, const LLSD& response); void decreaseOpenItemCount(); void updateFoundLinks(); void processBatch(LLInventoryModel::item_array_t items); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index fd9a3f12e8..874fbe19fd 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -6166,6 +6166,20 @@ Are you sure you want to permanently delete the contents of your Lost And Found? yestext="Yes"/> + +You're about to replace '[TYPE]' body part link with the item which doesn't match the type. +Are you sure you want to proceed? + confirm + + +