llagentwearables.h
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:11k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llagentwearables.h
  3.  * @brief LLAgentWearables class header file
  4.  *
  5.  * $LicenseInfo:firstyear=2000&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2000-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 "llmemory.h"
  35. #include "lluuid.h"
  36. #include "llinventory.h"
  37. #include "llinventorymodel.h"
  38. #include "llviewerinventory.h"
  39. #include "llvoavatardefines.h"
  40. class LLInventoryItem;
  41. class LLVOAvatarSelf;
  42. class LLWearable;
  43. class LLInitialWearablesFetch;
  44. class LLViewerObject;
  45. class LLTexLayerTemplate;
  46. class LLAgentWearables
  47. {
  48. //--------------------------------------------------------------------
  49. // Constructors / destructors / Initializers
  50. //--------------------------------------------------------------------
  51. public:
  52. friend class LLInitialWearablesFetch;
  53. LLAgentWearables();
  54. virtual ~LLAgentWearables();
  55. void  setAvatarObject(LLVOAvatarSelf *avatar);
  56. void createStandardWearables(BOOL female); 
  57. void cleanup();
  58. void dump();
  59. protected:
  60. // MULTI-WEARABLE: assuming one per type.  Type is called index - rename.
  61. void createStandardWearablesDone(S32 type, U32 index/* = 0*/);
  62. void createStandardWearablesAllDone();
  63. //--------------------------------------------------------------------
  64. // Queries
  65. //--------------------------------------------------------------------
  66. public:
  67. BOOL isWearingItem(const LLUUID& item_id) const;
  68. BOOL isWearableModifiable(EWearableType type, U32 index /*= 0*/) const;
  69. BOOL isWearableCopyable(EWearableType type, U32 index /*= 0*/) const;
  70. BOOL areWearablesLoaded() const;
  71. void updateWearablesLoaded();
  72. void checkWearablesLoaded() const;
  73. // Note: False for shape, skin, eyes, and hair, unless you have MORE than 1.
  74. bool canWearableBeRemoved(const LLWearable* wearable) const;
  75. void animateAllWearableParams(F32 delta, BOOL upload_bake);
  76. //--------------------------------------------------------------------
  77. // Accessors
  78. //--------------------------------------------------------------------
  79. public:
  80. const LLUUID getWearableItemID(EWearableType type, U32 index /*= 0*/) const;
  81. const LLUUID getWearableAssetID(EWearableType type, U32 index /*= 0*/) const;
  82. const LLWearable* getWearableFromItemID(const LLUUID& item_id) const;
  83. const LLWearable* getWearableFromAssetID(const LLUUID& asset_id) const;
  84. LLInventoryItem* getWearableInventoryItem(EWearableType type, U32 index /*= 0*/);
  85. // MULTI-WEARABLE: assuming one per type.
  86. static BOOL selfHasWearable(EWearableType type);
  87. LLWearable* getWearable(const EWearableType type, U32 index /*= 0*/); 
  88. const LLWearable*  getWearable(const EWearableType type, U32 index /*= 0*/) const;
  89. LLWearable* getTopWearable(const EWearableType type);
  90. U32 getWearableCount(const EWearableType type) const;
  91. U32 getWearableCount(const U32 tex_index) const;
  92. //--------------------------------------------------------------------
  93. // Setters
  94. //--------------------------------------------------------------------
  95. private:
  96. // Low-level data structure setter - public access is via setWearableItem, etc.
  97. void  setWearable(const EWearableType type, U32 index, LLWearable *wearable);
  98. U32  pushWearable(const EWearableType type, LLWearable *wearable);
  99. void wearableUpdated(LLWearable *wearable);
  100. void  popWearable(LLWearable *wearable);
  101. void popWearable(const EWearableType type, U32 index);
  102. public:
  103. void setWearableItem(LLInventoryItem* new_item, LLWearable* wearable, bool do_append = false);
  104. void setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove);
  105. void setWearableName(const LLUUID& item_id, const std::string& new_name);
  106. void addLocalTextureObject(const EWearableType wearable_type, const LLVOAvatarDefines::ETextureIndex texture_type, U32 wearable_index);
  107. U32 getWearableIndex(LLWearable *wearable);
  108. protected:
  109. void setWearableFinal(LLInventoryItem* new_item, LLWearable* new_wearable, bool do_append = false);
  110. static bool onSetWearableDialog(const LLSD& notification, const LLSD& response, LLWearable* wearable);
  111. void addWearableToAgentInventory(LLPointer<LLInventoryCallback> cb,
  112. LLWearable* wearable, 
  113. const LLUUID& category_id = LLUUID::null,
  114. BOOL notify = TRUE);
  115. void  addWearabletoAgentInventoryDone(const S32 type,
  116. const U32 index,
  117. const LLUUID& item_id,
  118. LLWearable* wearable);
  119. void recoverMissingWearable(const EWearableType type, U32 index /*= 0*/);
  120. void recoverMissingWearableDone();
  121. //--------------------------------------------------------------------
  122. // Removing wearables
  123. //--------------------------------------------------------------------
  124. public:
  125. void removeWearable(const EWearableType type, bool do_remove_all /*= false*/, U32 index /*= 0*/);
  126. private:
  127. void removeWearableFinal(const EWearableType type, bool do_remove_all /*= false*/, U32 index /*= 0*/);
  128. protected:
  129. static bool onRemoveWearableDialog(const LLSD& notification, const LLSD& response);
  130. static void userRemoveAllClothesStep2(BOOL proceed); // userdata is NULL
  131. //--------------------------------------------------------------------
  132. // Server Communication
  133. //--------------------------------------------------------------------
  134. public:
  135. // Processes the initial wearables update message (if necessary, since the outfit folder makes it redundant)
  136. static void processAgentInitialWearablesUpdate(LLMessageSystem* mesgsys, void** user_data);
  137. protected:
  138. void sendAgentWearablesUpdate();
  139. void sendAgentWearablesRequest();
  140. void queryWearableCache();
  141. void  updateServer();
  142. static void onInitialWearableAssetArrived(LLWearable* wearable, void* userdata);
  143. //--------------------------------------------------------------------
  144. // Outfits
  145. //--------------------------------------------------------------------
  146. public:
  147. void  getAllWearablesArray(LLDynamicArray<S32>& wearables);
  148. // Note: wearables_to_include should be a list of EWearableType types
  149. // attachments_to_include should be a list of attachment points
  150. void makeNewOutfit(const std::string& new_folder_name,
  151.   const LLDynamicArray<S32>& wearables_to_include,
  152.   const LLDynamicArray<S32>& attachments_to_include,
  153.   BOOL rename_clothing);
  154. LLUUID makeNewOutfitLinks(const std::string& new_folder_name);
  155. // Should only be called if we *know* we've never done so before, since users may
  156. // not want the Library outfits to stay in their quick outfit selector and can delete them.
  157. void populateMyOutfitsFolder(void);
  158. private:
  159. void makeNewOutfitDone(S32 type, U32 index); 
  160. //--------------------------------------------------------------------
  161. // Save Wearables
  162. //--------------------------------------------------------------------
  163. public:
  164.     // MULTI-WEARABLE: assumes one per type.
  165. void saveWearableAs(const EWearableType type, const U32 index, const std::string& new_name, BOOL save_in_lost_and_found);
  166. void saveWearable(const EWearableType type, const U32 index, BOOL send_update = TRUE);
  167. void saveAllWearables();
  168. void revertWearable(const EWearableType type, const U32 index);
  169. //--------------------------------------------------------------------
  170. // Static UI hooks
  171. //--------------------------------------------------------------------
  172. public:
  173. // MULTI-WEARABLE: assuming one wearable per type.  Need upstream changes.
  174. static void userRemoveWearable(EWearableType& type);
  175. static void userRemoveAllClothes();
  176. typedef std::vector<LLViewerObject*> llvo_vec_t;
  177. static void  userUpdateAttachments(LLInventoryModel::item_array_t& obj_item_array);
  178. static void userRemoveMultipleAttachments(llvo_vec_t& llvo_array);
  179. static void userRemoveAllAttachments();
  180. static void userAttachMultipleAttachments(LLInventoryModel::item_array_t& obj_item_array);
  181. BOOL itemUpdatePending(const LLUUID& item_id) const;
  182. U32 itemUpdatePendingCount() const;
  183. //--------------------------------------------------------------------
  184. // Member variables
  185. //--------------------------------------------------------------------
  186. private:
  187. typedef std::vector<LLWearable*> wearableentry_vec_t; // all wearables of a certain type (EG all shirts)
  188. typedef std::map<EWearableType, wearableentry_vec_t> wearableentry_map_t; // wearable "categories" arranged by wearable type
  189. wearableentry_map_t mWearableDatas;
  190. static BOOL mInitialWearablesUpdateReceived;
  191. BOOL mWearablesLoaded;
  192. std::set<LLUUID> mItemsAwaitingWearableUpdate;
  193. LLPointer<LLVOAvatarSelf> mAvatarObject; // NULL until avatar object sent down from simulator
  194. //--------------------------------------------------------------------------------
  195. // Support classes
  196. //--------------------------------------------------------------------------------
  197. private:
  198. class createStandardWearablesAllDoneCallback : public LLRefCount
  199. {
  200. protected:
  201. ~createStandardWearablesAllDoneCallback();
  202. };
  203. class sendAgentWearablesUpdateCallback : public LLRefCount
  204. {
  205. protected:
  206. ~sendAgentWearablesUpdateCallback();
  207. };
  208. class addWearableToAgentInventoryCallback : public LLInventoryCallback
  209. {
  210. public:
  211. enum EType
  212. {
  213. CALL_NONE = 0,
  214. CALL_UPDATE = 1,
  215. CALL_RECOVERDONE = 2,
  216. CALL_CREATESTANDARDDONE = 4,
  217. CALL_MAKENEWOUTFITDONE = 8,
  218. CALL_WEARITEM = 16
  219. };
  220. // MULTI-WEARABLE: index is an EWearableType - more confusing usage.
  221. // MULTI-WEARABLE: need to have type and index args both?
  222. addWearableToAgentInventoryCallback(LLPointer<LLRefCount> cb,
  223. S32 type,
  224. U32 index,
  225. LLWearable* wearable,
  226. U32 todo = CALL_NONE);
  227. virtual void fire(const LLUUID& inv_item);
  228. private:
  229. S32 mType;
  230. U32 mIndex;
  231. LLWearable* mWearable;
  232. U32 mTodo;
  233. LLPointer<LLRefCount> mCB;
  234. };
  235. static const U32 MAX_WEARABLES_PER_TYPE = 1; 
  236. }; // LLAgentWearables
  237. extern LLAgentWearables gAgentWearables;
  238. //--------------------------------------------------------------------
  239. // Types
  240. //--------------------------------------------------------------------
  241. #endif // LL_AGENTWEARABLES_H