PageRenderTime 27ms CodeModel.GetById 2ms app.highlight 20ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llappearancemgr.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 260 lines | 125 code | 66 blank | 69 comment | 0 complexity | 1a6d5d7f0aefc7f0709170bacdfbb0bc MD5 | raw file
  1/** 
  2 * @file llappearancemgr.h
  3 * @brief Manager for initiating appearance changes on the viewer
  4 *
  5 * $LicenseInfo:firstyear=2004&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLAPPEARANCEMGR_H
 28#define LL_LLAPPEARANCEMGR_H
 29
 30#include "llsingleton.h"
 31
 32#include "llagentwearables.h"
 33#include "llcallbacklist.h"
 34#include "llinventorymodel.h"
 35#include "llinventoryobserver.h"
 36#include "llviewerinventory.h"
 37
 38class LLWearable;
 39class LLWearableHoldingPattern;
 40class LLInventoryCallback;
 41class LLOutfitUnLockTimer;
 42
 43class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr>
 44{
 45	LOG_CLASS(LLAppearanceMgr);
 46
 47	friend class LLSingleton<LLAppearanceMgr>;
 48	friend class LLOutfitUnLockTimer;
 49	
 50public:
 51	typedef std::vector<LLInventoryModel::item_array_t> wearables_by_type_t;
 52
 53	void updateAppearanceFromCOF(bool update_base_outfit_ordering = false);
 54	bool needToSaveCOF();
 55	void updateCOF(const LLUUID& category, bool append = false);
 56	void wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append);
 57	void wearInventoryCategoryOnAvatar(LLInventoryCategory* category, bool append);
 58	void wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append);
 59	void wearOutfitByName(const std::string& name);
 60	void changeOutfit(bool proceed, const LLUUID& category, bool append);
 61	void replaceCurrentOutfit(const LLUUID& new_outfit);
 62	void renameOutfit(const LLUUID& outfit_id);
 63	void takeOffOutfit(const LLUUID& cat_id);
 64	void addCategoryToCurrentOutfit(const LLUUID& cat_id);
 65	S32 findExcessOrDuplicateItems(const LLUUID& cat_id,
 66								   LLAssetType::EType type,
 67								   S32 max_items,
 68								   LLInventoryModel::item_array_t& items_to_kill);
 69	void enforceItemRestrictions();
 70
 71	// Copy all items and the src category itself.
 72	void shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id,
 73							 LLPointer<LLInventoryCallback> cb);
 74
 75	// Return whether this folder contains minimal contents suitable for making a full outfit.
 76	BOOL getCanMakeFolderIntoOutfit(const LLUUID& folder_id);
 77
 78	// Determine whether a given outfit can be removed.
 79	bool getCanRemoveOutfit(const LLUUID& outfit_cat_id);
 80
 81	// Determine whether we're wearing any of the outfit contents (excluding body parts).
 82	static bool getCanRemoveFromCOF(const LLUUID& outfit_cat_id);
 83
 84	// Determine whether we can add anything (but body parts) from the outfit contents to COF.
 85	static bool getCanAddToCOF(const LLUUID& outfit_cat_id);
 86
 87	// Determine whether we can replace current outfit with the given one.
 88	bool getCanReplaceCOF(const LLUUID& outfit_cat_id);
 89
 90	// Copy all items in a category.
 91	void shallowCopyCategoryContents(const LLUUID& src_id, const LLUUID& dst_id,
 92									 LLPointer<LLInventoryCallback> cb);
 93
 94	// Find the Current Outfit folder.
 95	const LLUUID getCOF() const;
 96
 97	// Finds the folder link to the currently worn outfit
 98	const LLViewerInventoryItem *getBaseOutfitLink();
 99	bool getBaseOutfitName(std::string &name);
100
101	// find the UUID of the currently worn outfit (Base Outfit)
102	const LLUUID getBaseOutfitUUID();
103
104	// Wear/attach an item (from a user's inventory) on the agent
105	bool wearItemOnAvatar(const LLUUID& item_to_wear, bool do_update = true, bool replace = false, LLPointer<LLInventoryCallback> cb = NULL);
106
107	// Update the displayed outfit name in UI.
108	void updatePanelOutfitName(const std::string& name);
109
110	void createBaseOutfitLink(const LLUUID& category, LLPointer<LLInventoryCallback> link_waiter);
111
112	void updateAgentWearables(LLWearableHoldingPattern* holder, bool append);
113
114	// For debugging - could be moved elsewhere.
115	void dumpCat(const LLUUID& cat_id, const std::string& msg);
116	void dumpItemArray(const LLInventoryModel::item_array_t& items, const std::string& msg);
117
118	// Attachment link management
119	void unregisterAttachment(const LLUUID& item_id);
120	void registerAttachment(const LLUUID& item_id);
121	void setAttachmentInvLinkEnable(bool val);
122
123	// utility function for bulk linking.
124	void linkAll(const LLUUID& category,
125				 LLInventoryModel::item_array_t& items,
126				 LLPointer<LLInventoryCallback> cb);
127
128	// Add COF link to individual item.
129	void addCOFItemLink(const LLUUID& item_id, bool do_update = true, LLPointer<LLInventoryCallback> cb = NULL);
130	void addCOFItemLink(const LLInventoryItem *item, bool do_update = true, LLPointer<LLInventoryCallback> cb = NULL);
131
132	// Remove COF entries
133	void removeCOFItemLinks(const LLUUID& item_id, bool do_update = true);
134	void removeCOFLinksOfType(LLWearableType::EType type, bool do_update = true);
135
136	// Add COF link to ensemble folder.
137	void addEnsembleLink(LLInventoryCategory* item, bool do_update = true);
138
139	//has the current outfit changed since it was loaded?
140	bool isOutfitDirty() { return mOutfitIsDirty; }
141
142	// set false if you just loaded the outfit, true otherwise
143	void setOutfitDirty(bool isDirty) { mOutfitIsDirty = isDirty; }
144	
145	// manually compare ouftit folder link to COF to see if outfit has changed.
146	// should only be necessary to do on initial login.
147	void updateIsDirty();
148
149	// Called when self avatar is first fully visible.
150	void onFirstFullyVisible();
151
152	// Create initial outfits from library.
153	void autopopulateOutfits();
154
155	// Copy initial gestures from library.
156	void copyLibraryGestures();
157	
158	void wearBaseOutfit();
159
160	// Overrides the base outfit with the content from COF
161	// @return false if there is no base outfit
162	bool updateBaseOutfit();
163
164	//Remove clothing or detach an object from the agent (a bodypart cannot be removed)
165	void removeItemFromAvatar(const LLUUID& item_id);
166
167
168	LLUUID makeNewOutfitLinks(const std::string& new_folder_name,bool show_panel = true);
169
170	bool moveWearable(LLViewerInventoryItem* item, bool closer_to_body);
171
172	static void sortItemsByActualDescription(LLInventoryModel::item_array_t& items);
173
174	//Divvy items into arrays by wearable type
175	static void divvyWearablesByType(const LLInventoryModel::item_array_t& items, wearables_by_type_t& items_by_type);
176
177	//Check ordering information on wearables stored in links' descriptions and update if it is invalid
178	// COF is processed if cat_id is not specified
179	void updateClothingOrderingInfo(LLUUID cat_id = LLUUID::null, bool update_base_outfit_ordering = false);
180
181	bool isOutfitLocked() { return mOutfitLocked; }
182
183	bool isInUpdateAppearanceFromCOF() { return mIsInUpdateAppearanceFromCOF; }
184
185protected:
186	LLAppearanceMgr();
187	~LLAppearanceMgr();
188
189private:
190
191	void filterWearableItems(LLInventoryModel::item_array_t& items, S32 max_per_type);
192	
193	void getDescendentsOfAssetType(const LLUUID& category, 
194										  LLInventoryModel::item_array_t& items,
195										  LLAssetType::EType type,
196										  bool follow_folder_links);
197
198	void getUserDescendents(const LLUUID& category, 
199								   LLInventoryModel::item_array_t& wear_items,
200								   LLInventoryModel::item_array_t& obj_items,
201								   LLInventoryModel::item_array_t& gest_items,
202								   bool follow_folder_links);
203
204	void purgeCategory(const LLUUID& category, bool keep_outfit_links);
205	void purgeBaseOutfitLink(const LLUUID& category);
206
207	static void onOutfitRename(const LLSD& notification, const LLSD& response);
208
209	void setOutfitLocked(bool locked);
210
211	bool mAttachmentInvLinkEnabled;
212	bool mOutfitIsDirty;
213	bool mIsInUpdateAppearanceFromCOF; // to detect recursive calls.
214
215	/**
216	 * Lock for blocking operations on outfit until server reply or timeout exceed
217	 * to avoid unsynchronized outfit state or performing duplicate operations.
218	 */
219	bool mOutfitLocked;
220
221	std::auto_ptr<LLOutfitUnLockTimer> mUnlockOutfitTimer;
222
223	//////////////////////////////////////////////////////////////////////////////////
224	// Item-specific convenience functions 
225public:
226	// Is this in the COF?
227	BOOL getIsInCOF(const LLUUID& obj_id) const;
228	// Is this in the COF and can the user delete it from the COF?
229	BOOL getIsProtectedCOFItem(const LLUUID& obj_id) const;
230
231	/**
232	 * Checks if COF contains link to specified object.
233	 */
234	static bool isLinkInCOF(const LLUUID& obj_id);
235};
236
237class LLUpdateAppearanceOnDestroy: public LLInventoryCallback
238{
239public:
240	LLUpdateAppearanceOnDestroy(bool update_base_outfit_ordering = false);
241	virtual ~LLUpdateAppearanceOnDestroy();
242	/* virtual */ void fire(const LLUUID& inv_item);
243
244private:
245	U32 mFireCount;
246	bool mUpdateBaseOrder;
247};
248
249
250#define SUPPORT_ENSEMBLES 0
251
252LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id,const std::string& name);
253
254// Invoke a given callable after category contents are fully fetched.
255void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb);
256
257// Wear all items in a uuid vector.
258void wear_multiple(const uuid_vec_t& ids, bool replace);
259
260#endif