/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. #ifndef LL_LLAPPEARANCEMGR_H
  27. #define LL_LLAPPEARANCEMGR_H
  28. #include "llsingleton.h"
  29. #include "llagentwearables.h"
  30. #include "llcallbacklist.h"
  31. #include "llinventorymodel.h"
  32. #include "llinventoryobserver.h"
  33. #include "llviewerinventory.h"
  34. class LLWearable;
  35. class LLWearableHoldingPattern;
  36. class LLInventoryCallback;
  37. class LLOutfitUnLockTimer;
  38. class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr>
  39. {
  40. LOG_CLASS(LLAppearanceMgr);
  41. friend class LLSingleton<LLAppearanceMgr>;
  42. friend class LLOutfitUnLockTimer;
  43. public:
  44. typedef std::vector<LLInventoryModel::item_array_t> wearables_by_type_t;
  45. void updateAppearanceFromCOF(bool update_base_outfit_ordering = false);
  46. bool needToSaveCOF();
  47. void updateCOF(const LLUUID& category, bool append = false);
  48. void wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append);
  49. void wearInventoryCategoryOnAvatar(LLInventoryCategory* category, bool append);
  50. void wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append);
  51. void wearOutfitByName(const std::string& name);
  52. void changeOutfit(bool proceed, const LLUUID& category, bool append);
  53. void replaceCurrentOutfit(const LLUUID& new_outfit);
  54. void renameOutfit(const LLUUID& outfit_id);
  55. void takeOffOutfit(const LLUUID& cat_id);
  56. void addCategoryToCurrentOutfit(const LLUUID& cat_id);
  57. S32 findExcessOrDuplicateItems(const LLUUID& cat_id,
  58. LLAssetType::EType type,
  59. S32 max_items,
  60. LLInventoryModel::item_array_t& items_to_kill);
  61. void enforceItemRestrictions();
  62. // Copy all items and the src category itself.
  63. void shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id,
  64. LLPointer<LLInventoryCallback> cb);
  65. // Return whether this folder contains minimal contents suitable for making a full outfit.
  66. BOOL getCanMakeFolderIntoOutfit(const LLUUID& folder_id);
  67. // Determine whether a given outfit can be removed.
  68. bool getCanRemoveOutfit(const LLUUID& outfit_cat_id);
  69. // Determine whether we're wearing any of the outfit contents (excluding body parts).
  70. static bool getCanRemoveFromCOF(const LLUUID& outfit_cat_id);
  71. // Determine whether we can add anything (but body parts) from the outfit contents to COF.
  72. static bool getCanAddToCOF(const LLUUID& outfit_cat_id);
  73. // Determine whether we can replace current outfit with the given one.
  74. bool getCanReplaceCOF(const LLUUID& outfit_cat_id);
  75. // Copy all items in a category.
  76. void shallowCopyCategoryContents(const LLUUID& src_id, const LLUUID& dst_id,
  77. LLPointer<LLInventoryCallback> cb);
  78. // Find the Current Outfit folder.
  79. const LLUUID getCOF() const;
  80. // Finds the folder link to the currently worn outfit
  81. const LLViewerInventoryItem *getBaseOutfitLink();
  82. bool getBaseOutfitName(std::string &name);
  83. // find the UUID of the currently worn outfit (Base Outfit)
  84. const LLUUID getBaseOutfitUUID();
  85. // Wear/attach an item (from a user's inventory) on the agent
  86. bool wearItemOnAvatar(const LLUUID& item_to_wear, bool do_update = true, bool replace = false, LLPointer<LLInventoryCallback> cb = NULL);
  87. // Update the displayed outfit name in UI.
  88. void updatePanelOutfitName(const std::string& name);
  89. void createBaseOutfitLink(const LLUUID& category, LLPointer<LLInventoryCallback> link_waiter);
  90. void updateAgentWearables(LLWearableHoldingPattern* holder, bool append);
  91. // For debugging - could be moved elsewhere.
  92. void dumpCat(const LLUUID& cat_id, const std::string& msg);
  93. void dumpItemArray(const LLInventoryModel::item_array_t& items, const std::string& msg);
  94. // Attachment link management
  95. void unregisterAttachment(const LLUUID& item_id);
  96. void registerAttachment(const LLUUID& item_id);
  97. void setAttachmentInvLinkEnable(bool val);
  98. // utility function for bulk linking.
  99. void linkAll(const LLUUID& category,
  100. LLInventoryModel::item_array_t& items,
  101. LLPointer<LLInventoryCallback> cb);
  102. // Add COF link to individual item.
  103. void addCOFItemLink(const LLUUID& item_id, bool do_update = true, LLPointer<LLInventoryCallback> cb = NULL);
  104. void addCOFItemLink(const LLInventoryItem *item, bool do_update = true, LLPointer<LLInventoryCallback> cb = NULL);
  105. // Remove COF entries
  106. void removeCOFItemLinks(const LLUUID& item_id, bool do_update = true);
  107. void removeCOFLinksOfType(LLWearableType::EType type, bool do_update = true);
  108. // Add COF link to ensemble folder.
  109. void addEnsembleLink(LLInventoryCategory* item, bool do_update = true);
  110. //has the current outfit changed since it was loaded?
  111. bool isOutfitDirty() { return mOutfitIsDirty; }
  112. // set false if you just loaded the outfit, true otherwise
  113. void setOutfitDirty(bool isDirty) { mOutfitIsDirty = isDirty; }
  114. // manually compare ouftit folder link to COF to see if outfit has changed.
  115. // should only be necessary to do on initial login.
  116. void updateIsDirty();
  117. // Called when self avatar is first fully visible.
  118. void onFirstFullyVisible();
  119. // Create initial outfits from library.
  120. void autopopulateOutfits();
  121. // Copy initial gestures from library.
  122. void copyLibraryGestures();
  123. void wearBaseOutfit();
  124. // Overrides the base outfit with the content from COF
  125. // @return false if there is no base outfit
  126. bool updateBaseOutfit();
  127. //Remove clothing or detach an object from the agent (a bodypart cannot be removed)
  128. void removeItemFromAvatar(const LLUUID& item_id);
  129. LLUUID makeNewOutfitLinks(const std::string& new_folder_name,bool show_panel = true);
  130. bool moveWearable(LLViewerInventoryItem* item, bool closer_to_body);
  131. static void sortItemsByActualDescription(LLInventoryModel::item_array_t& items);
  132. //Divvy items into arrays by wearable type
  133. static void divvyWearablesByType(const LLInventoryModel::item_array_t& items, wearables_by_type_t& items_by_type);
  134. //Check ordering information on wearables stored in links' descriptions and update if it is invalid
  135. // COF is processed if cat_id is not specified
  136. void updateClothingOrderingInfo(LLUUID cat_id = LLUUID::null, bool update_base_outfit_ordering = false);
  137. bool isOutfitLocked() { return mOutfitLocked; }
  138. bool isInUpdateAppearanceFromCOF() { return mIsInUpdateAppearanceFromCOF; }
  139. protected:
  140. LLAppearanceMgr();
  141. ~LLAppearanceMgr();
  142. private:
  143. void filterWearableItems(LLInventoryModel::item_array_t& items, S32 max_per_type);
  144. void getDescendentsOfAssetType(const LLUUID& category,
  145. LLInventoryModel::item_array_t& items,
  146. LLAssetType::EType type,
  147. bool follow_folder_links);
  148. void getUserDescendents(const LLUUID& category,
  149. LLInventoryModel::item_array_t& wear_items,
  150. LLInventoryModel::item_array_t& obj_items,
  151. LLInventoryModel::item_array_t& gest_items,
  152. bool follow_folder_links);
  153. void purgeCategory(const LLUUID& category, bool keep_outfit_links);
  154. void purgeBaseOutfitLink(const LLUUID& category);
  155. static void onOutfitRename(const LLSD& notification, const LLSD& response);
  156. void setOutfitLocked(bool locked);
  157. bool mAttachmentInvLinkEnabled;
  158. bool mOutfitIsDirty;
  159. bool mIsInUpdateAppearanceFromCOF; // to detect recursive calls.
  160. /**
  161. * Lock for blocking operations on outfit until server reply or timeout exceed
  162. * to avoid unsynchronized outfit state or performing duplicate operations.
  163. */
  164. bool mOutfitLocked;
  165. std::auto_ptr<LLOutfitUnLockTimer> mUnlockOutfitTimer;
  166. //////////////////////////////////////////////////////////////////////////////////
  167. // Item-specific convenience functions
  168. public:
  169. // Is this in the COF?
  170. BOOL getIsInCOF(const LLUUID& obj_id) const;
  171. // Is this in the COF and can the user delete it from the COF?
  172. BOOL getIsProtectedCOFItem(const LLUUID& obj_id) const;
  173. /**
  174. * Checks if COF contains link to specified object.
  175. */
  176. static bool isLinkInCOF(const LLUUID& obj_id);
  177. };
  178. class LLUpdateAppearanceOnDestroy: public LLInventoryCallback
  179. {
  180. public:
  181. LLUpdateAppearanceOnDestroy(bool update_base_outfit_ordering = false);
  182. virtual ~LLUpdateAppearanceOnDestroy();
  183. /* virtual */ void fire(const LLUUID& inv_item);
  184. private:
  185. U32 mFireCount;
  186. bool mUpdateBaseOrder;
  187. };
  188. #define SUPPORT_ENSEMBLES 0
  189. LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id,const std::string& name);
  190. // Invoke a given callable after category contents are fully fetched.
  191. void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb);
  192. // Wear all items in a uuid vector.
  193. void wear_multiple(const uuid_vec_t& ids, bool replace);
  194. #endif