summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2013-01-16 11:34:42 -0500
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2013-01-16 11:34:42 -0500
commit6a8947679cdb3a3d6ce9d4d175a2bdfed4b7eee3 (patch)
tree79d985e8e1182052fea3d917de4d2031eca4d720 /indra
parentf48011e4d04f744a93a18267bf7b78ec0b717b7c (diff)
SH-3645 WIP - preserve item order after wearable save as
Diffstat (limited to 'indra')
-rwxr-xr-xindra/newview/llagentwearables.cpp12
-rwxr-xr-xindra/newview/llagentwearables.h6
-rwxr-xr-xindra/newview/llappearancemgr.cpp26
-rwxr-xr-xindra/newview/llappearancemgr.h4
-rw-r--r--indra/newview/llinventorylistitem.cpp2
-rwxr-xr-xindra/newview/llpaneleditwearable.cpp55
6 files changed, 64 insertions, 41 deletions
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index e79fda2459..70f4de8db2 100755
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -210,12 +210,13 @@ LLAgentWearables::sendAgentWearablesUpdateCallback::~sendAgentWearablesUpdateCal
* @param todo Bitmask of actions to take on completion.
*/
LLAgentWearables::addWearableToAgentInventoryCallback::addWearableToAgentInventoryCallback(
- LLPointer<LLRefCount> cb, LLWearableType::EType type, U32 index, LLViewerWearable* wearable, U32 todo) :
+ LLPointer<LLRefCount> cb, LLWearableType::EType type, U32 index, LLViewerWearable* wearable, U32 todo, const std::string description) :
mType(type),
mIndex(index),
mWearable(wearable),
mTodo(todo),
- mCB(cb)
+ mCB(cb),
+ mDescription(description)
{
llinfos << "constructor" << llendl;
}
@@ -255,7 +256,7 @@ void LLAgentWearables::addWearableToAgentInventoryCallback::fire(const LLUUID& i
}
if (mTodo & CALL_WEARITEM)
{
- LLAppearanceMgr::instance().addCOFItemLink(inv_item, true);
+ LLAppearanceMgr::instance().addCOFItemLink(inv_item, true, NULL, mDescription);
}
}
@@ -455,6 +456,7 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32
void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
const U32 index,
const std::string& new_name,
+ const std::string& description,
BOOL save_in_lost_and_found)
{
if (!isWearableCopyable(type, index))
@@ -486,7 +488,9 @@ void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
type,
index,
new_wearable,
- addWearableToAgentInventoryCallback::CALL_WEARITEM);
+ addWearableToAgentInventoryCallback::CALL_WEARITEM,
+ description
+ );
LLUUID category_id;
if (save_in_lost_and_found)
{
diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h
index a60fbc969b..5be4648636 100755
--- a/indra/newview/llagentwearables.h
+++ b/indra/newview/llagentwearables.h
@@ -183,7 +183,7 @@ private:
// Save Wearables
//--------------------------------------------------------------------
public:
- void saveWearableAs(const LLWearableType::EType type, const U32 index, const std::string& new_name, BOOL save_in_lost_and_found);
+ void saveWearableAs(const LLWearableType::EType type, const U32 index, const std::string& new_name, const std::string& description, BOOL save_in_lost_and_found);
void saveWearable(const LLWearableType::EType type, const U32 index, BOOL send_update = TRUE,
const std::string new_name = "");
void saveAllWearables();
@@ -270,7 +270,8 @@ private:
LLWearableType::EType type,
U32 index,
LLViewerWearable* wearable,
- U32 todo = CALL_NONE);
+ U32 todo = CALL_NONE,
+ const std::string description = "");
virtual void fire(const LLUUID& inv_item);
private:
LLWearableType::EType mType;
@@ -278,6 +279,7 @@ private:
LLViewerWearable* mWearable;
U32 mTodo;
LLPointer<LLRefCount> mCB;
+ std::string mDescription;
};
}; // LLAgentWearables
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index d1ed82cc98..2b1e78c899 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1902,7 +1902,7 @@ static void remove_non_link_items(LLInventoryModel::item_array_t &items)
}
//a predicate for sorting inventory items by actual descriptions
-bool sort_by_description(const LLInventoryItem* item1, const LLInventoryItem* item2)
+bool sort_by_actual_description(const LLInventoryItem* item1, const LLInventoryItem* item2)
{
if (!item1 || !item2)
{
@@ -2345,10 +2345,11 @@ bool areMatchingWearables(const LLViewerInventoryItem *a, const LLViewerInventor
class LLDeferredCOFLinkObserver: public LLInventoryObserver
{
public:
- LLDeferredCOFLinkObserver(const LLUUID& item_id, bool do_update, LLPointer<LLInventoryCallback> cb = NULL):
+ LLDeferredCOFLinkObserver(const LLUUID& item_id, bool do_update, LLPointer<LLInventoryCallback> cb = NULL, std::string description = ""):
mItemID(item_id),
mDoUpdate(do_update),
- mCallback(cb)
+ mCallback(cb),
+ mDescription(description)
{
}
@@ -2370,23 +2371,24 @@ public:
private:
const LLUUID mItemID;
bool mDoUpdate;
+ std::string mDescription;
LLPointer<LLInventoryCallback> mCallback;
};
// BAP - note that this runs asynchronously if the item is not already loaded from inventory.
// Dangerous if caller assumes link will exist after calling the function.
-void LLAppearanceMgr::addCOFItemLink(const LLUUID &item_id, bool do_update, LLPointer<LLInventoryCallback> cb)
+void LLAppearanceMgr::addCOFItemLink(const LLUUID &item_id, bool do_update, LLPointer<LLInventoryCallback> cb, const std::string description)
{
const LLInventoryItem *item = gInventory.getItem(item_id);
if (!item)
{
- LLDeferredCOFLinkObserver *observer = new LLDeferredCOFLinkObserver(item_id, do_update, cb);
+ LLDeferredCOFLinkObserver *observer = new LLDeferredCOFLinkObserver(item_id, do_update, cb, description);
gInventory.addObserver(observer);
}
else
{
- addCOFItemLink(item, do_update, cb);
+ addCOFItemLink(item, do_update, cb, description);
}
}
@@ -2409,8 +2411,9 @@ void modified_cof_cb(const LLUUID& inv_item)
}
}
-void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update, LLPointer<LLInventoryCallback> cb)
+void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update, LLPointer<LLInventoryCallback> cb, const std::string description)
{
+ std::string link_description = description;
const LLViewerInventoryItem *vitem = dynamic_cast<const LLViewerInventoryItem*>(item);
if (!vitem)
{
@@ -2474,12 +2477,15 @@ void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update
{
cb = new LLBoostFuncInventoryCallback(modified_cof_cb);
}
- const std::string description = vitem->getIsLinkType() ? vitem->getDescription() : "";
+ if (vitem->getIsLinkType())
+ {
+ link_description = vitem->getActualDescription();
+ }
link_inventory_item( gAgent.getID(),
vitem->getLinkedUUID(),
getCOF(),
vitem->getName(),
- description,
+ link_description,
LLAssetType::AT_LINK,
cb);
}
@@ -3240,7 +3246,7 @@ void LLAppearanceMgr::sortItemsByActualDescription(LLInventoryModel::item_array_
{
if (items.size() < 2) return;
- std::sort(items.begin(), items.end(), sort_by_description);
+ std::sort(items.begin(), items.end(), sort_by_actual_description);
}
//#define DUMP_CAT_VERBOSE
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index 01a2d41458..bb4c9ee5a2 100755
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -129,8 +129,8 @@ public:
LLPointer<LLInventoryCallback> cb);
// Add COF link to individual item.
- void addCOFItemLink(const LLUUID& item_id, bool do_update = true, LLPointer<LLInventoryCallback> cb = NULL);
- void addCOFItemLink(const LLInventoryItem *item, bool do_update = true, LLPointer<LLInventoryCallback> cb = NULL);
+ void addCOFItemLink(const LLUUID& item_id, bool do_update = true, LLPointer<LLInventoryCallback> cb = NULL, const std::string description = "");
+ void addCOFItemLink(const LLInventoryItem *item, bool do_update = true, LLPointer<LLInventoryCallback> cb = NULL, const std::string description = "");
// Find COF entries referencing the given item.
LLInventoryModel::item_array_t findCOFItemLinks(const LLUUID& item_id);
diff --git a/indra/newview/llinventorylistitem.cpp b/indra/newview/llinventorylistitem.cpp
index 26041767fd..0601796436 100644
--- a/indra/newview/llinventorylistitem.cpp
+++ b/indra/newview/llinventorylistitem.cpp
@@ -231,7 +231,7 @@ const std::string& LLPanelInventoryListItemBase::getDescription() const
{
return LLStringUtil::null;
}
- return inv_item->getDescription();
+ return inv_item->getActualDescription();
}
time_t LLPanelInventoryListItemBase::getCreationDate() const
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index cca3b90329..fe4b55bb5a 100755
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -1056,36 +1056,47 @@ void LLPanelEditWearable::saveChanges(bool force_save_as)
U32 index = gAgentWearables.getWearableIndex(mWearablePtr);
std::string new_name = mNameEditor->getText();
+
+ // Find an existing link to this wearable's inventory item, if any, and its description field.
+ LLInventoryItem *link_item = NULL;
+ std::string description;
+ LLInventoryModel::item_array_t links =
+ LLAppearanceMgr::instance().findCOFItemLinks(mWearablePtr->getItemID());
+ if (links.size()>0)
+ {
+ link_item = links.get(0).get();
+ if (link_item && link_item->getIsLinkType())
+ {
+ description = link_item->getActualDescription();
+ }
+ }
+
if (force_save_as)
{
- // the name of the wearable has changed, re-save wearable with new name
- LLAppearanceMgr::instance().removeCOFItemLinks(mWearablePtr->getItemID());
- gAgentWearables.saveWearableAs(mWearablePtr->getType(), index, new_name, FALSE);
- mNameEditor->setText(mWearableItem->getName());
+ // the name of the wearable has changed, re-save wearable with new name
+ LLAppearanceMgr::instance().removeCOFItemLinks(mWearablePtr->getItemID());
+ gAgentWearables.saveWearableAs(mWearablePtr->getType(), index, new_name, description, FALSE);
+ mNameEditor->setText(mWearableItem->getName());
}
else
{
- LLInventoryModel::item_array_t links =
- LLAppearanceMgr::instance().findCOFItemLinks(mWearablePtr->getItemID());
- if (links.size()>0)
+ // Make another copy of this link, with the same
+ // description. This is needed to bump the COF
+ // version so texture baking service knows appearance has changed.
+ if (link_item)
{
- // Make another copy of this link, with the same description.
- LLInventoryItem *item = links.get(0).get();
- if (item)
- {
- const std::string description = item->getIsLinkType() ? item->getActualDescription() : "";
- link_inventory_item( gAgent.getID(),
- item->getLinkedUUID(),
- LLAppearanceMgr::instance().getCOF(),
- item->getName(),
- description,
- LLAssetType::AT_LINK,
- NULL);
- gInventory.purgeObject(item->getUUID());
- }
+ // Create new link
+ link_inventory_item( gAgent.getID(),
+ link_item->getLinkedUUID(),
+ LLAppearanceMgr::instance().getCOF(),
+ link_item->getName(),
+ description,
+ LLAssetType::AT_LINK,
+ NULL);
+ // Remove old link
+ gInventory.purgeObject(link_item->getUUID());
}
gAgentWearables.saveWearable(mWearablePtr->getType(), index, TRUE, new_name);
-
}
}