llagentwearables.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /**
  2. * @file llagentwearables.h
  3. * @brief LLAgentWearables class header file
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewergpl$
  6. *
  7. * Copyright (c) 2010, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLAGENTWEARABLES_H
  33. #define LL_LLAGENTWEARABLES_H
  34. #include <vector>
  35. #include "llinitdestroyclass.h"
  36. #include "llinventory.h"
  37. #include "llmemory.h"
  38. #include "llstring.h"
  39. #include "lluuid.h"
  40. #include "llwearabledata.h"
  41. #include "llinventorymodel.h"
  42. #include "llviewerinventory.h"
  43. // LL apparently removed silently these restrictions (underwears "always on"
  44. // for teens) from their own viewer, so... Set to 1 to reenable if ever needed
  45. // again. HB
  46. #define LL_TEEN_WERABLE_RESTRICTIONS 0
  47. class LLInitialWearablesFetch;
  48. class LLViewerObject;
  49. class LLViewerWearable;
  50. class LLVOAvatarSelf;
  51. struct HBNewOutfitData;
  52. class LLAgentWearables final : public LLInitClass<LLAgentWearables>,
  53. public LLWearableData
  54. {
  55. friend class LLInitialWearablesFetch;
  56. friend class LLAddWearableToInventoryCallback;
  57. friend class LLCreateStandardWearablesDoneCallback;
  58. friend class LLSendAgentWearablesUpdateCallback;
  59. protected:
  60. LOG_CLASS(LLAgentWearables);
  61. public:
  62. //--------------------------------------------------------------------
  63. // Constructors / destructors / Initializers
  64. //--------------------------------------------------------------------
  65. LLAgentWearables();
  66. // LLInitClass interface
  67. static void initClass() {}
  68. void setAvatarObject(LLVOAvatarSelf* avatar);
  69. void createStandardWearables(bool female);
  70. protected:
  71. void createStandardWearablesDone(S32 type, U32 index);
  72. void createStandardWearablesAllDone();
  73. //--------------------------------------------------------------------
  74. // Queries
  75. //--------------------------------------------------------------------
  76. public:
  77. bool isWearingItem(const LLUUID& item_id) const;
  78. bool isWearableModifiable(LLWearableType::EType type, U32 index) const;
  79. bool isWearableModifiable(const LLUUID& item_id) const;
  80. bool isWearableCopyable(LLWearableType::EType type, U32 index) const;
  81. bool areWearablesLoaded() const;
  82. LL_INLINE bool isSettingOutfit() const { return mIsSettingOutfit; }
  83. void updateWearablesLoaded();
  84. bool canMoveWearable(const LLUUID& item_id, bool closer_to_body) const;
  85. // Note: False for shape, skin, eyes, and hair, unless you have MORE than 1.
  86. bool canWearableBeRemoved(const LLViewerWearable* wearable) const;
  87. void animateAllWearableParams(F32 delta, bool upload_bake);
  88. //--------------------------------------------------------------------
  89. // Accessors
  90. //--------------------------------------------------------------------
  91. public:
  92. const LLUUID& getWearableItemID(LLWearableType::EType t, U32 idx) const;
  93. const LLUUID& getWearableAssetID(LLWearableType::EType t, U32 idx) const;
  94. const LLViewerWearable* getWearableFromItemID(const LLUUID& item_id) const;
  95. LLViewerWearable* getWearableFromItemID(const LLUUID& item_id);
  96. LLViewerWearable* getWearableFromAssetID(const LLUUID& asset_id);
  97. LLViewerWearable* getViewerWearable(LLWearableType::EType type, U32 idx);
  98. const LLViewerWearable* getViewerWearable(LLWearableType::EType type,
  99. U32 idx) const;
  100. LLViewerInventoryItem* getWearableInventoryItem(LLWearableType::EType type,
  101. U32 idx);
  102. static bool selfHasWearable(LLWearableType::EType type);
  103. //--------------------------------------------------------------------
  104. // Setters
  105. //--------------------------------------------------------------------
  106. private:
  107. void wearableUpdated(LLWearable* wearable, bool removed) override;
  108. public:
  109. void setWearableItem(LLInventoryItem* new_item, LLViewerWearable* wearable,
  110. bool do_append = false);
  111. void setWearableOutfit(const LLInventoryItem::item_array_t& items,
  112. const std::vector<LLViewerWearable*>& wearables,
  113. bool remove);
  114. void setWearableName(const LLUUID& item_id, const std::string& new_name);
  115. // *TODO: Move this into llappearance/LLWearableData ?
  116. LLLocalTextureObject* addLocalTextureObject(LLWearableType::EType type,
  117. LLAvatarAppearanceDefines::ETextureIndex texture_type,
  118. U32 index);
  119. protected:
  120. void setWearableFinal(LLInventoryItem* new_item,
  121. LLViewerWearable* new_wearable,
  122. bool do_append = false);
  123. void addWearableToAgentInventory(LLPointer<LLInventoryCallback> cb,
  124. LLViewerWearable* wearable,
  125. const LLUUID& category_id = LLUUID::null,
  126. bool notify = true);
  127. void addWearabletoAgentInventoryDone(LLWearableType::EType type, U32 index,
  128. const LLUUID& item_id,
  129. LLViewerWearable* wearable);
  130. void recoverMissingWearable(LLWearableType::EType type, U32 index);
  131. void recoverMissingWearableDone();
  132. //--------------------------------------------------------------------
  133. // Removing wearables
  134. //--------------------------------------------------------------------
  135. public:
  136. void removeWearable(LLWearableType::EType type, bool do_remove_all,
  137. U32 index);
  138. private:
  139. void removeWearableFinal(LLWearableType::EType type, bool do_remove_all,
  140. U32 index);
  141. protected:
  142. static bool onRemoveWearableDialog(const LLSD& notification,
  143. const LLSD& response);
  144. //--------------------------------------------------------------------
  145. // Server Communication
  146. //--------------------------------------------------------------------
  147. public:
  148. // Processes the initial wearables update message
  149. static void processAgentInitialWearablesUpdate(LLMessageSystem* mesgsys,
  150. void** user_data);
  151. protected:
  152. void invalidateBakedTextureHash(LLMD5& hash) const override;
  153. void sendAgentWearablesUpdate();
  154. void sendAgentWearablesRequest();
  155. void queryWearableCache();
  156. void updateServer();
  157. static void onInitialWearableAssetArrived(LLViewerWearable* wearable,
  158. void* userdata);
  159. //--------------------------------------------------------------------
  160. // Outfits
  161. //--------------------------------------------------------------------
  162. public:
  163. S32 getWearableTypeAndIndex(LLViewerWearable* wearable,
  164. LLWearableType::EType& type);
  165. void makeNewOutfit(const std::string& new_folder_name,
  166. const uuid_vec_t& wearables_to_include,
  167. const uuid_vec_t& attachments_to_include,
  168. bool rename_clothing);
  169. private:
  170. void makeNewOutfitCopy(const LLUUID& cat_id, HBNewOutfitData* datap);
  171. void makeNewOutfitDone(LLWearableType::EType type, U32 index);
  172. //--------------------------------------------------------------------
  173. // Save Wearables
  174. //--------------------------------------------------------------------
  175. public:
  176. void saveWearableAs(LLWearableType::EType type, U32 index,
  177. const std::string& new_name,
  178. bool save_in_lost_and_found = false);
  179. void saveWearable(LLWearableType::EType type, U32 index,
  180. bool send_update = true,
  181. const std::string& new_name = LLStringUtil::null);
  182. void saveAllWearables();
  183. void revertWearable(LLWearableType::EType type, U32 index);
  184. //--------------------------------------------------------------------
  185. // Static UI hooks
  186. //--------------------------------------------------------------------
  187. public:
  188. static void userRemoveWearable(LLWearableType::EType type, U32 index);
  189. static void userRemoveWearablesOfType(LLWearableType::EType type);
  190. static void userRemoveAllClothes();
  191. static void userRemoveAllClothesStep2(bool proceed, void*);
  192. typedef std::vector<LLViewerObject*> llvo_vec_t;
  193. static void userRemoveMultipleAttachments(llvo_vec_t& llvo_array);
  194. static void userRemoveAllAttachments(bool only_temp_attach = false);
  195. static void userAttachMultipleAttachments(LLInventoryModel::item_array_t& items);
  196. // These methods are for overriding the old initial wearables update
  197. // message logic in SL, for when that message will stop being sent...
  198. // They are only used by the LLAppearanceMgr::checkOutfit() function.
  199. LL_INLINE bool initialWearablesUpdateReceived() { return mInitialWearablesUpdateReceived; }
  200. void setInitialWearablesUpdateReceived();
  201. LL_INLINE void setWearablesLoaded() { mWearablesLoaded = true; }
  202. private:
  203. // All wearables of a certain type (EG all shirts)
  204. typedef std::vector<LLWearable*> wearableentry_vec_t;
  205. // Wearable "categories" arranged by wearable type:
  206. typedef std::map<LLWearableType::EType,
  207. wearableentry_vec_t> wearableentry_map_t;
  208. wearableentry_map_t mWearableDatas;
  209. bool mInitialWearablesUpdateReceived;
  210. bool mWearablesLoaded;
  211. bool mIsSettingOutfit;
  212. };
  213. extern LLAgentWearables gAgentWearables;
  214. extern bool gWearablesListDirty;
  215. #endif // LL_AGENTWEARABLES_H