summaryrefslogtreecommitdiff
path: root/indra/newview/llagentwearables.cpp
diff options
context:
space:
mode:
authorEric M. Tulla (BigPapi) <tulla@lindenlab.com>2009-11-17 17:58:17 -0500
committerEric M. Tulla (BigPapi) <tulla@lindenlab.com>2009-11-17 17:58:17 -0500
commit32178873564f86f0ab9ee06d485486fc9d609012 (patch)
tree4beae7908cbdd5e6af5241682110ac958b7c56ae /indra/newview/llagentwearables.cpp
parent064fb26092ac9f73f9d0301f1e214e27e8418839 (diff)
parent2365dbcd459b37942ddacbcb7010232113a126c1 (diff)
Merge of viewer2 into avp
--HG-- branch : avatar-pipeline
Diffstat (limited to 'indra/newview/llagentwearables.cpp')
-rw-r--r--indra/newview/llagentwearables.cpp146
1 files changed, 146 insertions, 0 deletions
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index a171f75b17..6b2033fc6f 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -86,6 +86,26 @@ protected:
void processContents();
};
+class LLLibraryOutfitsFetch : public LLInventoryFetchDescendentsObserver
+{
+public:
+ enum ELibraryOutfitFetchStep {
+ LOFS_FOLDER = 0,
+ LOFS_OUTFITS,
+ LOFS_CONTENTS
+ };
+ LLLibraryOutfitsFetch() : mCurrFetchStep(LOFS_FOLDER), mOutfitsPopulated(false) {}
+ ~LLLibraryOutfitsFetch() {}
+ virtual void done();
+protected:
+ void folderDone(void);
+ void outfitsDone(void);
+ void contentsDone(void);
+ enum ELibraryOutfitFetchStep mCurrFetchStep;
+ std::vector< std::pair< LLUUID, std::string > > mOutfits;
+ bool mOutfitsPopulated;
+};
+
LLAgentWearables gAgentWearables;
BOOL LLAgentWearables::mInitialWearablesUpdateReceived = FALSE;
@@ -905,6 +925,8 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
// will call done for us when everything is here.
gInventory.addObserver(outfit);
}
+
+ gAgentWearables.populateMyOutfitsFolder();
}
}
@@ -2004,6 +2026,130 @@ void LLAgentWearables::updateServer()
gAgent.sendAgentSetAppearance();
}
+void LLAgentWearables::populateMyOutfitsFolder(void)
+{
+ LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch();
+
+ // What we do here is get the complete information on the items in
+ // the inventory, and set up an observer that will wait for that to
+ // happen.
+ LLInventoryFetchDescendentsObserver::folder_ref_t folders;
+ const LLUUID my_outfits_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS);
+
+ folders.push_back(my_outfits_id);
+ outfits->fetchDescendents(folders);
+ if(outfits->isEverythingComplete())
+ {
+ // everything is already here - call done.
+ outfits->done();
+ }
+ else
+ {
+ // it's all on it's way - add an observer, and the inventory
+ // will call done for us when everything is here.
+ gInventory.addObserver(outfits);
+ }
+}
+
+void LLLibraryOutfitsFetch::done()
+{
+ switch (mCurrFetchStep){
+ case LOFS_FOLDER:
+ mCurrFetchStep = LOFS_OUTFITS;
+ folderDone();
+ break;
+ case LOFS_OUTFITS:
+ mCurrFetchStep = LOFS_CONTENTS;
+ outfitsDone();
+ break;
+ case LOFS_CONTENTS:
+ // No longer need this observer hanging around.
+ gInventory.removeObserver(this);
+ contentsDone();
+ break;
+ default:
+ gInventory.removeObserver(this);
+ delete this;
+ return;
+ }
+ if (mOutfitsPopulated)
+ {
+ delete this;
+ }
+}
+
+void LLLibraryOutfitsFetch::folderDone(void)
+{
+ // Early out if we already have items in My Outfits.
+ LLInventoryModel::cat_array_t cat_array;
+ LLInventoryModel::item_array_t wearable_array;
+ gInventory.collectDescendents(mCompleteFolders.front(), cat_array, wearable_array,
+ LLInventoryModel::EXCLUDE_TRASH);
+ if (cat_array.count() > 0 || wearable_array.count() > 0)
+ {
+ mOutfitsPopulated = true;
+ gInventory.removeObserver(this);
+ return;
+ }
+
+ // Get the UUID of the library's clothing folder
+ const LLUUID library_clothing_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING, false, true);
+
+ mCompleteFolders.clear();
+
+ // What we do here is get the complete information on the items in
+ // the inventory, and set up an observer that will wait for that to
+ // happen.
+ LLInventoryFetchDescendentsObserver::folder_ref_t folders;
+ folders.push_back(library_clothing_id);
+ fetchDescendents(folders);
+ if(isEverythingComplete())
+ {
+ // everything is already here - call done.
+ outfitsDone();
+ }
+}
+
+void LLLibraryOutfitsFetch::outfitsDone(void)
+{
+ LLInventoryModel::cat_array_t cat_array;
+ LLInventoryModel::item_array_t wearable_array;
+ gInventory.collectDescendents(mCompleteFolders.front(), cat_array, wearable_array,
+ LLInventoryModel::EXCLUDE_TRASH);
+
+ LLInventoryFetchDescendentsObserver::folder_ref_t folders;
+ for(S32 i = 0; i < cat_array.count(); ++i)
+ {
+ if (cat_array.get(i)->getName() != "More Outfits" && cat_array.get(i)->getName() != "Ruth"){
+ folders.push_back(cat_array.get(i)->getUUID());
+ mOutfits.push_back( std::make_pair(cat_array.get(i)->getUUID(), cat_array.get(i)->getName() ));
+ }
+ }
+ mCompleteFolders.clear();
+ fetchDescendents(folders);
+ if(isEverythingComplete())
+ {
+ // everything is already here - call done.
+ contentsDone();
+ }
+}
+
+void LLLibraryOutfitsFetch::contentsDone(void)
+{
+ for(S32 i = 0; i < (S32)mOutfits.size(); ++i)
+ {
+ // First, make a folder in the My Outfits directory.
+ const LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS);
+ LLUUID folder_id = gInventory.createNewCategory(parent_id,
+ LLFolderType::FT_OUTFIT,
+ mOutfits[i].second);
+
+ LLAppearanceManager::getInstance()->shallowCopyCategory(mOutfits[i].first, folder_id, NULL);
+ gInventory.notifyObservers();
+ }
+ mOutfitsPopulated = true;
+}
+
//--------------------------------------------------------------------
// InitialWearablesFetch
//