summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authornat-goodspeed <nat@lindenlab.com>2024-07-09 11:37:21 -0400
committerGitHub <noreply@github.com>2024-07-09 11:37:21 -0400
commite2122fcb60ceef5273f4f51fa3c53228ddc56ff5 (patch)
tree42ae287114dbc042e75f189c1237be2d81d7f41d /indra/newview
parent0b337d5ffec731120adf85da45ceb1ddf5e74621 (diff)
parentf8398b2b2d25d8318ecafb755cf1c1b235803da2 (diff)
Merge pull request #1958 from secondlife/lua-appearance-listener-combine
Break out common `LLAppearanceMgr::wearOutfit(LLInventoryCategory*)` method
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llappearancelistener.cpp33
-rw-r--r--indra/newview/llappearancemgr.cpp63
-rw-r--r--indra/newview/llappearancemgr.h4
3 files changed, 34 insertions, 66 deletions
diff --git a/indra/newview/llappearancelistener.cpp b/indra/newview/llappearancelistener.cpp
index 75eaf29186..0dab352311 100644
--- a/indra/newview/llappearancelistener.cpp
+++ b/indra/newview/llappearancelistener.cpp
@@ -38,7 +38,7 @@ LLAppearanceListener::LLAppearanceListener()
"API to wear a specified outfit and wear/remove individual items")
{
add("wearOutfit",
- "Wear outfit by folder id: [folder_id] OR by folder name: [folder_name]\n"
+ "Wear outfit by folder id: [\"folder_id\"] OR by folder name: [\"folder_name\"]\n"
"When [\"append\"] is true, outfit will be added to COF\n"
"otherwise it will replace current oufit",
&LLAppearanceListener::wearOutfit);
@@ -91,36 +91,15 @@ void LLAppearanceListener::wearOutfit(LLSD const &data)
void LLAppearanceListener::wearItems(LLSD const &data)
{
- if (data["items_id"].isArray())
- {
- uuid_vec_t ids;
- for (const auto &id : llsd::inArray(data["items_id"]))
- {
- ids.push_back(id);
- }
- LLAppearanceMgr::instance().wearItemsOnAvatar(ids, true, data["replace"].asBoolean());
- }
- else
- {
- LLAppearanceMgr::instance().wearItemOnAvatar(data["items_id"].asUUID(), true, data["replace"].asBoolean());
- }
+ LLAppearanceMgr::instance().wearItemsOnAvatar(
+ LLSDParam<uuid_vec_t>(data["items_id"]),
+ true, data["replace"].asBoolean());
}
void LLAppearanceListener::detachItems(LLSD const &data)
{
- if (data["items_id"].isArray())
- {
- uuid_vec_t ids;
- for (const auto &id : llsd::inArray(data["items_id"]))
- {
- ids.push_back(id);
- }
- LLAppearanceMgr::instance().removeItemsFromAvatar(ids);
- }
- else
- {
- LLAppearanceMgr::instance().removeItemFromAvatar(data["items_id"].asUUID());
- }
+ LLAppearanceMgr::instance().removeItemsFromAvatar(
+ LLSDParam<uuid_vec_t>(data["items_id"]));
}
void LLAppearanceListener::getOutfitsList(LLSD const &data)
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 7a34006323..26c41b19ed 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2904,6 +2904,17 @@ void LLAppearanceMgr::wearInventoryCategoryOnAvatar( LLInventoryCategory* catego
LLAppearanceMgr::changeOutfit(TRUE, category->getUUID(), append);
}
+bool LLAppearanceMgr::wearOutfitByName(const std::string& name, bool append)
+{
+ std::string error_msg;
+ if(!wearOutfitByName(name, error_msg, append))
+ {
+ LL_WARNS() << error_msg << LL_ENDL;
+ return false;
+ }
+ return true;
+}
+
bool LLAppearanceMgr::wearOutfitByName(const std::string& name, std::string& error_msg, bool append)
{
LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL;
@@ -2937,63 +2948,37 @@ bool LLAppearanceMgr::wearOutfitByName(const std::string& name, std::string& err
}
}
- if(cat)
- {
- // don't allow wearing a system folder
- if (LLFolderType::lookupIsProtectedType(cat->getPreferredType()))
- {
- error_msg = stringize(LLTrans::getString("SystemFolderNotWorn"), std::quoted(name));
- return false;
- }
- bool can_wear = append ? getCanAddToCOF(cat->getUUID()) : getCanReplaceCOF(cat->getUUID());
- if (!can_wear)
- {
- std::string msg = append ? LLTrans::getString("OutfitNotAdded") : LLTrans::getString("OutfitNotReplaced");
- error_msg = stringize(msg, std::quoted(name), ", id: ", cat->getUUID());
- return false;
- }
- LLAppearanceMgr::wearInventoryCategory(cat, copy_items, append);
- }
- else
- {
- error_msg = stringize(LLTrans::getString("OutfitNotFound"), std::quoted(name));
- return false;
- }
- return true;
+ return wearOutfit(stringize(std::quoted(name)), cat, error_msg, copy_items, append);
}
bool LLAppearanceMgr::wearOutfit(const LLUUID &cat_id, std::string &error_msg, bool append)
{
LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id);
+ return wearOutfit(stringize(cat_id), cat, error_msg, false, append);
+}
+
+bool LLAppearanceMgr::wearOutfit(const std::string &desc, LLInventoryCategory* cat,
+ std::string &error_msg, bool copy_items, bool append)
+{
if (!cat)
{
- error_msg = stringize(LLTrans::getString("OutfitNotFound"), cat_id);
+ error_msg = stringize(LLTrans::getString("OutfitNotFound"), desc);
return false;
}
+ // don't allow wearing a system folder
if (LLFolderType::lookupIsProtectedType(cat->getPreferredType()))
{
- error_msg = stringize(LLTrans::getString("SystemFolderNotWorn"), cat_id);
+ error_msg = stringize(LLTrans::getString("SystemFolderNotWorn"), std::quoted(cat->getName()));
return false;
}
- bool can_wear = append ? LLAppearanceMgr::instance().getCanAddToCOF(cat_id) : LLAppearanceMgr::instance().getCanReplaceCOF(cat_id);
+ bool can_wear = append ? getCanAddToCOF(cat->getUUID()) : getCanReplaceCOF(cat->getUUID());
if (!can_wear)
{
std::string msg = append ? LLTrans::getString("OutfitNotAdded") : LLTrans::getString("OutfitNotReplaced");
- error_msg = stringize(msg, std::quoted(cat->getName()), " , id: ", cat_id);
- return false;
- }
- LLAppearanceMgr::instance().wearInventoryCategory(cat, false, append);
- return true;
-}
-
-bool LLAppearanceMgr::wearOutfitByName(const std::string& name, bool append)
-{
- std::string error_msg;
- if(!wearOutfitByName(name, error_msg, append))
- {
- LL_WARNS() << error_msg << LL_ENDL;
+ error_msg = stringize(msg, std::quoted(cat->getName()), " , id: ", cat->getUUID());
return false;
}
+ wearInventoryCategory(cat, copy_items, append);
return true;
}
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index b795494f94..11d209e6b5 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -263,6 +263,10 @@ private:
static void onOutfitRename(const LLSD& notification, const LLSD& response);
+ // used by both wearOutfit(LLUUID) and wearOutfitByName(std::string)
+ bool wearOutfit(const std::string &desc, LLInventoryCategory* cat,
+ std::string &error_msg, bool copy_items, bool append);
+
bool mAttachmentInvLinkEnabled;
bool mOutfitIsDirty;
bool mIsInUpdateAppearanceFromCOF; // to detect recursive calls.