summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llappearancelistener.cpp93
-rw-r--r--indra/newview/llappearancelistener.h5
-rw-r--r--indra/newview/llappearancemgr.cpp28
-rw-r--r--indra/newview/llappearancemgr.h1
-rw-r--r--indra/newview/llwearableitemslist.h3
-rw-r--r--indra/newview/scripts/lua/require/LLAppearance.lua28
-rw-r--r--indra/newview/scripts/lua/test_LLAppearance.lua (renamed from indra/newview/scripts/lua/test_outfits_list.lua)8
7 files changed, 95 insertions, 71 deletions
diff --git a/indra/newview/llappearancelistener.cpp b/indra/newview/llappearancelistener.cpp
index 2a3133433a..75eaf29186 100644
--- a/indra/newview/llappearancelistener.cpp
+++ b/indra/newview/llappearancelistener.cpp
@@ -38,28 +38,20 @@ LLAppearanceListener::LLAppearanceListener()
"API to wear a specified outfit and wear/remove individual items")
{
add("wearOutfit",
- "Wear outfit by folder id: [folder_id]"
+ "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,
- llsd::map("folder_id", LLSD(), "append", LLSD()));
+ &LLAppearanceListener::wearOutfit);
- add("wearOutfitByName",
- "Wear outfit by folder name: [folder_name]"
- "When [\"append\"] is true, outfit will be added to COF\n"
- "otherwise it will replace current oufit",
- &LLAppearanceListener::wearOutfitByName,
- llsd::map("folder_name", LLSD(), "append", LLSD()));
-
- add("wearItem",
- "Wear item by item id: [item_id]",
- &LLAppearanceListener::wearItem,
- llsd::map("item_id", LLSD(), "replace", LLSD()));
+ add("wearItems",
+ "Wear items by id: [items_id]",
+ &LLAppearanceListener::wearItems,
+ llsd::map("items_id", LLSD(), "replace", LLSD()));
- add("detachItem",
- "Detach item by item id: [item_id]",
- &LLAppearanceListener::detachItem,
- llsd::map("item_id", LLSD()));
+ add("detachItems",
+ "Detach items by id: [items_id]",
+ &LLAppearanceListener::detachItems,
+ llsd::map("items_id", LLSD()));
add("getOutfitsList",
"Return the table with Outfits info(id and name)",
@@ -74,46 +66,61 @@ LLAppearanceListener::LLAppearanceListener()
void LLAppearanceListener::wearOutfit(LLSD const &data)
{
Response response(LLSD(), data);
- LLViewerInventoryCategory* cat = gInventory.getCategory(data["folder_id"].asUUID());
- if (!cat)
+ if (!data.has("folder_id") && !data.has("folder_name"))
{
- response.error(stringize(LLTrans::getString("OutfitNotFound"), data["folder_id"].asUUID()));
- return;
+ return response.error("Either [folder_id] or [folder_name] is required");
}
- if (LLFolderType::lookupIsProtectedType(cat->getPreferredType()))
+
+ std::string error_msg;
+ bool result(false);
+ bool append = data.has("append") ? data["append"].asBoolean() : false;
+ if (data.has("folder_id"))
{
- response.error(stringize(LLTrans::getString("SystemFolderNotWorn"), data["folder_id"].asUUID()));
- return;
+ result = LLAppearanceMgr::instance().wearOutfit(data["folder_id"].asUUID(), error_msg, append);
}
- bool append = data["append"].asBoolean();
- bool can_wear = append ? LLAppearanceMgr::instance().getCanAddToCOF(cat->getUUID()) : LLAppearanceMgr::instance().getCanReplaceCOF(cat->getUUID());
- if (!can_wear)
+ else
{
- std::string msg = append ? LLTrans::getString("OutfitNotAdded") : LLTrans::getString("OutfitNotReplaced");
- response.error(stringize(msg, std::quoted(cat->getName()), " , id: ", cat->getUUID()));
- return;
+ result = LLAppearanceMgr::instance().wearOutfitByName(data["folder_name"].asString(), error_msg, append);
}
- LLAppearanceMgr::instance().wearInventoryCategory(cat, false, append);
-}
-void LLAppearanceListener::wearOutfitByName(LLSD const &data)
-{
- Response response(LLSD(), data);
- std::string error_msg;
- if (!LLAppearanceMgr::instance().wearOutfitByName(data["folder_name"].asString(), error_msg, data["append"].asBoolean()))
+ if (!result)
{
response.error(error_msg);
}
}
-void LLAppearanceListener::wearItem(LLSD const &data)
+void LLAppearanceListener::wearItems(LLSD const &data)
{
- LLAppearanceMgr::instance().wearItemOnAvatar(data["item_id"].asUUID(), true, data["replace"].asBoolean());
+ 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());
+ }
}
-void LLAppearanceListener::detachItem(LLSD const &data)
+void LLAppearanceListener::detachItems(LLSD const &data)
{
- LLAppearanceMgr::instance().removeItemFromAvatar(data["item_id"].asUUID());
+ 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());
+ }
}
void LLAppearanceListener::getOutfitsList(LLSD const &data)
@@ -139,7 +146,7 @@ void LLAppearanceListener::getOutfitItems(LLSD const &data)
LLViewerInventoryCategory *cat = gInventory.getCategory(outfit_id);
if (!cat || cat->getPreferredType() != LLFolderType::FT_OUTFIT)
{
- response.error(stringize(LLTrans::getString("OutfitNotFound"), outfit_id.asString()));
+ return response.error(stringize(LLTrans::getString("OutfitNotFound"), outfit_id.asString()));
}
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t item_array;
diff --git a/indra/newview/llappearancelistener.h b/indra/newview/llappearancelistener.h
index 00553c072f..04c5eac2eb 100644
--- a/indra/newview/llappearancelistener.h
+++ b/indra/newview/llappearancelistener.h
@@ -36,9 +36,8 @@ public:
private:
void wearOutfit(LLSD const &data);
- void wearOutfitByName(LLSD const &data);
- void wearItem(LLSD const &data);
- void detachItem(LLSD const &data);
+ void wearItems(LLSD const &data);
+ void detachItems(LLSD const &data);
void getOutfitsList(LLSD const &data);
void getOutfitItems(LLSD const &data);
};
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;
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index adc783be5a..b795494f94 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -59,6 +59,7 @@ public:
void wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append);
void wearInventoryCategoryOnAvatar(LLInventoryCategory* category, bool append);
void wearCategoryFinal(const LLUUID& cat_id, bool copy_items, bool append);
+ bool wearOutfit(const LLUUID &cat_id, std::string &error_msg, bool append = false);
bool wearOutfitByName(const std::string &name, std::string &error_msg, bool append = false);
bool wearOutfitByName(const std::string &name, bool append = false);
void changeOutfit(bool proceed, const LLUUID& category, bool append);
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index a24679961f..15033f5e9a 100644
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -506,9 +506,8 @@ protected:
LLWearableType::EType mMenuWearableType;
};
-class LLFindOutfitItems : public LLInventoryCollectFunctor
+struct LLFindOutfitItems : public LLInventoryCollectFunctor
{
- public:
LLFindOutfitItems() {}
virtual ~LLFindOutfitItems() {}
virtual bool operator()(LLInventoryCategory *cat, LLInventoryItem *item);
diff --git a/indra/newview/scripts/lua/require/LLAppearance.lua b/indra/newview/scripts/lua/require/LLAppearance.lua
index 165bb6d06f..f533d22daf 100644
--- a/indra/newview/scripts/lua/require/LLAppearance.lua
+++ b/indra/newview/scripts/lua/require/LLAppearance.lua
@@ -1,29 +1,23 @@
-leap = require 'leap'
+local leap = require 'leap'
local LLAppearance = {}
-function LLAppearance.addOutfit(folder)
- leap.request('LLAppearance', {op='wearOutfit', append = true, folder_id=folder})
+function LLAppearance.wearOutfit(folder, action)
+ action = action or 'add'
+ leap.request('LLAppearance', {op='wearOutfit', append = (action == 'add'), folder_id=folder})
end
-function LLAppearance.replaceOutfit(folder)
- leap.request('LLAppearance', {op='wearOutfit', append = false, folder_id=folder})
+function LLAppearance.wearOutfitByName(folder, action)
+ action = action or 'add'
+ leap.request('LLAppearance', {op='wearOutfit', append = (action == 'add'), folder_name=folder})
end
-function LLAppearance.addOutfitByName(folder)
- leap.request('LLAppearance', {op='wearOutfitByName', append = true, folder_name=folder})
+function LLAppearance.wearItems(items_id, replace)
+ leap.send('LLAppearance', {op='wearItems', replace = replace, items_id=items_id})
end
-function LLAppearance.replaceOutfitByName(folder)
- leap.request('LLAppearance', {op='wearOutfitByName', append = false, folder_name=folder})
-end
-
-function LLAppearance.wearItem(item_id, replace)
- leap.send('LLAppearance', {op='wearItem', replace = replace, item_id=item_id})
-end
-
-function LLAppearance.detachItem(item_id)
- leap.send('LLAppearance', {op='detachItem', item_id=item_id})
+function LLAppearance.detachItems(items_id)
+ leap.send('LLAppearance', {op='detachItems', items_id=items_id})
end
function LLAppearance.getOutfitsList()
diff --git a/indra/newview/scripts/lua/test_outfits_list.lua b/indra/newview/scripts/lua/test_LLAppearance.lua
index 1011029f34..5ddd9f15ff 100644
--- a/indra/newview/scripts/lua/test_outfits_list.lua
+++ b/indra/newview/scripts/lua/test_LLAppearance.lua
@@ -82,17 +82,17 @@ end
function flt:commit_replace_btn(event_data)
if SHOW_OUTFITS then
- LLAppearance.replaceOutfit(get_selected_id())
+ LLAppearance.wearOutfit(get_selected_id(), 'replace')
else
- LLAppearance.wearItem(get_selected_id(), false)
+ LLAppearance.wearItems(get_selected_id(), false)
end
end
function flt:commit_add_btn(event_data)
if SHOW_OUTFITS then
- LLAppearance.addOutfit(get_selected_id())
+ LLAppearance.wearOutfit(get_selected_id(), 'add')
else
- LLAppearance.detachItem(get_selected_id())
+ LLAppearance.detachItems(get_selected_id())
end
end