From b8e0c16ab1eb3cdd1d11e869bd3fd6196de51d4b Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 21 Jun 2024 17:42:45 +0300 Subject: Add Appearance listener --- indra/newview/llappearancemgr.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'indra/newview/llappearancemgr.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 30f07a873b..19b81f5a79 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" @@ -71,6 +72,8 @@ #pragma warning (disable:4702) #endif +LLAppearanceListener sAppearanceListener; + namespace { const S32 BAKE_RETRY_MAX_COUNT = 5; @@ -2900,8 +2903,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, bool append, std::string& error_msg) { LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL; @@ -2936,13 +2938,29 @@ void LLAppearanceMgr::wearOutfitByName(const std::string& name) if(cat) { - LLAppearanceMgr::wearInventoryCategory(cat, copy_items, false); + bool is_system_folder = LLFolderType::lookupIsProtectedType(cat->getPreferredType()); + if (is_system_folder) + { + error_msg = stringize("Can't wear system folder ", std::quoted(name)); + return false; + } + bool can_wear = append ? getCanAddToCOF(cat->getUUID()) : getCanReplaceCOF(cat->getUUID()); + if (!can_wear) + { + std::string msg = append ? "Can't add to COF outfit " : "Can't replace COF with outfit "; + error_msg = stringize(msg, std::quoted(name), " , id: ", cat->getUUID()); + LL_WARNS() << error_msg << LL_ENDL; + return false; + } + LLAppearanceMgr::wearInventoryCategory(cat, copy_items, append); } else { - LL_WARNS() << "Couldn't find outfit " < Date: Mon, 1 Jul 2024 13:02:49 +0300 Subject: Move error strings to strings.xml; pass wearable type and is_worn flag for outfit items --- indra/newview/llappearancemgr.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/newview/llappearancemgr.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 19b81f5a79..3d13f8afc8 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -49,6 +49,7 @@ #include "lloutfitslist.h" #include "llselectmgr.h" #include "llsidepanelappearance.h" +#include "lltransutil.h" #include "llviewerobjectlist.h" #include "llvoavatar.h" #include "llvoavatarself.h" @@ -2941,14 +2942,14 @@ bool LLAppearanceMgr::wearOutfitByName(const std::string& name, bool append, std bool is_system_folder = LLFolderType::lookupIsProtectedType(cat->getPreferredType()); if (is_system_folder) { - error_msg = stringize("Can't wear system folder ", std::quoted(name)); + 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 ? "Can't add to COF outfit " : "Can't replace COF with outfit "; - error_msg = stringize(msg, std::quoted(name), " , id: ", cat->getUUID()); + std::string msg = append ? LLTrans::getString("OutfitNotAdded") : LLTrans::getString("OutfitNotReplaced"); + error_msg = stringize(msg, std::quoted(name), ", id: ", cat->getUUID()); LL_WARNS() << error_msg << LL_ENDL; return false; } @@ -2956,7 +2957,7 @@ bool LLAppearanceMgr::wearOutfitByName(const std::string& name, bool append, std } else { - error_msg = stringize("Couldn't find outfit ", std::quoted(name)); + error_msg = stringize(LLTrans::getString("OutfitNotFound"), std::quoted(name)); LL_WARNS() << error_msg << LL_ENDL; return false; } -- cgit v1.2.3 From 3961bac0ef705775883a4b37f2b6a84e41b82c05 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Mon, 1 Jul 2024 14:47:52 +0300 Subject: build fix --- indra/newview/llappearancemgr.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'indra/newview/llappearancemgr.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 3d13f8afc8..e4a545a55b 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -2904,7 +2904,7 @@ void LLAppearanceMgr::wearInventoryCategoryOnAvatar( LLInventoryCategory* catego LLAppearanceMgr::changeOutfit(TRUE, category->getUUID(), append); } -bool LLAppearanceMgr::wearOutfitByName(const std::string& name, bool append, std::string& error_msg) +bool LLAppearanceMgr::wearOutfitByName(const std::string& name, std::string& error_msg, bool append) { LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL; @@ -2950,7 +2950,6 @@ bool LLAppearanceMgr::wearOutfitByName(const std::string& name, bool append, std { std::string msg = append ? LLTrans::getString("OutfitNotAdded") : LLTrans::getString("OutfitNotReplaced"); error_msg = stringize(msg, std::quoted(name), ", id: ", cat->getUUID()); - LL_WARNS() << error_msg << LL_ENDL; return false; } LLAppearanceMgr::wearInventoryCategory(cat, copy_items, append); @@ -2958,6 +2957,16 @@ bool LLAppearanceMgr::wearOutfitByName(const std::string& name, bool append, std else { error_msg = stringize(LLTrans::getString("OutfitNotFound"), std::quoted(name)); + return false; + } + 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; } -- cgit v1.2.3 From ece0f4eb566af937d724f60f934beb6dfcb4d493 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 5 Jul 2024 16:03:51 +0300 Subject: clean up and rename demo script --- indra/newview/llappearancemgr.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'indra/newview/llappearancemgr.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index e4a545a55b..7a34006323 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -2939,8 +2939,8 @@ bool LLAppearanceMgr::wearOutfitByName(const std::string& name, std::string& err if(cat) { - bool is_system_folder = LLFolderType::lookupIsProtectedType(cat->getPreferredType()); - if (is_system_folder) + // don't allow wearing a system folder + if (LLFolderType::lookupIsProtectedType(cat->getPreferredType())) { error_msg = stringize(LLTrans::getString("SystemFolderNotWorn"), std::quoted(name)); return false; @@ -2962,6 +2962,30 @@ bool LLAppearanceMgr::wearOutfitByName(const std::string& name, std::string& err 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; -- cgit v1.2.3