summaryrefslogtreecommitdiff
path: root/indra/newview/llappearancemgr.cpp
diff options
context:
space:
mode:
authornat-goodspeed <nat@lindenlab.com>2024-07-09 10:17:11 -0400
committerGitHub <noreply@github.com>2024-07-09 10:17:11 -0400
commit0b337d5ffec731120adf85da45ceb1ddf5e74621 (patch)
treef9f875a4ce16ec8c5528aa90d729d0ba8ebf96e4 /indra/newview/llappearancemgr.cpp
parent66fb45ddc7dd1a994f6b8312687cb73dbb1281dd (diff)
parentece0f4eb566af937d724f60f934beb6dfcb4d493 (diff)
Merge pull request #1892 from secondlife/lua-appearance-listener
Lua appearance listener
Diffstat (limited to 'indra/newview/llappearancemgr.cpp')
-rw-r--r--indra/newview/llappearancemgr.cpp62
1 files changed, 57 insertions, 5 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 30f07a873b..7a34006323 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -31,6 +31,7 @@
#include "llagent.h"
#include "llagentcamera.h"
#include "llagentwearables.h"
+#include "llappearancelistener.h"
#include "llappearancemgr.h"
#include "llattachmentsmgr.h"
#include "llcommandhandler.h"
@@ -48,6 +49,7 @@
#include "lloutfitslist.h"
#include "llselectmgr.h"
#include "llsidepanelappearance.h"
+#include "lltransutil.h"
#include "llviewerobjectlist.h"
#include "llvoavatar.h"
#include "llvoavatarself.h"
@@ -71,6 +73,8 @@
#pragma warning (disable:4702)
#endif
+LLAppearanceListener sAppearanceListener;
+
namespace
{
const S32 BAKE_RETRY_MAX_COUNT = 5;
@@ -2900,8 +2904,7 @@ void LLAppearanceMgr::wearInventoryCategoryOnAvatar( LLInventoryCategory* catego
LLAppearanceMgr::changeOutfit(TRUE, category->getUUID(), append);
}
-// FIXME do we really want to search entire inventory for matching name?
-void LLAppearanceMgr::wearOutfitByName(const std::string& name)
+bool LLAppearanceMgr::wearOutfitByName(const std::string& name, std::string& error_msg, bool append)
{
LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL;
@@ -2936,13 +2939,62 @@ void LLAppearanceMgr::wearOutfitByName(const std::string& name)
if(cat)
{
- LLAppearanceMgr::wearInventoryCategory(cat, copy_items, false);
+ // 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
{
- LL_WARNS() << "Couldn't find outfit " <<name<< " in wearOutfitByName()"
- << LL_ENDL;
+ error_msg = stringize(LLTrans::getString("OutfitNotFound"), std::quoted(name));
+ return false;
+ }
+ return true;
+}
+
+bool LLAppearanceMgr::wearOutfit(const LLUUID &cat_id, std::string &error_msg, bool append)
+{
+ LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id);
+ if (!cat)
+ {
+ error_msg = stringize(LLTrans::getString("OutfitNotFound"), cat_id);
+ return false;
+ }
+ if (LLFolderType::lookupIsProtectedType(cat->getPreferredType()))
+ {
+ error_msg = stringize(LLTrans::getString("SystemFolderNotWorn"), cat_id);
+ return false;
}
+ bool can_wear = append ? LLAppearanceMgr::instance().getCanAddToCOF(cat_id) : LLAppearanceMgr::instance().getCanReplaceCOF(cat_id);
+ 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;
+ return false;
+ }
+ return true;
}
bool areMatchingWearables(const LLViewerInventoryItem *a, const LLViewerInventoryItem *b)