llviewerwearable.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /**
  2. * @file llviewerwearable.h
  3. * @brief LLViewerWearable class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, 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_VIEWER_WEARABLE_H
  33. #define LL_VIEWER_WEARABLE_H
  34. #include "llavatarappearance.h"
  35. #include "llavatarappearancedefines.h"
  36. #include "llextendedstatus.h"
  37. #include "llwearable.h"
  38. #include "lluuid.h"
  39. class LLViewerWearable : public LLWearable
  40. {
  41. friend class LLWearableList;
  42. protected:
  43. LOG_CLASS(LLViewerWearable);
  44. //--------------------------------------------------------------------
  45. // Constructors and destructors
  46. //--------------------------------------------------------------------
  47. private:
  48. // Private constructor used by LLWearableList
  49. LLViewerWearable(const LLTransactionID& transactionID);
  50. LLViewerWearable(const LLAssetID& assetID);
  51. public:
  52. ~LLViewerWearable() override = default;
  53. LL_INLINE LLViewerWearable* asViewerWearable() override
  54. {
  55. return this;
  56. }
  57. LL_INLINE const LLViewerWearable* asViewerWearable() const override
  58. {
  59. return this;
  60. }
  61. //--------------------------------------------------------------------
  62. // Accessors
  63. //--------------------------------------------------------------------
  64. LL_INLINE const LLUUID& getItemID() const { return mItemID; }
  65. LL_INLINE const LLAssetID& getAssetID() const { return mAssetID; }
  66. LL_INLINE const LLTransactionID& getTransactionID() const
  67. {
  68. return mTransactionID;
  69. }
  70. void setItemID(const LLUUID& item_id);
  71. bool isDirty() const;
  72. bool isOldVersion() const;
  73. void writeToAvatar(LLAvatarAppearance* avatarp) override;
  74. LL_INLINE void removeFromAvatar(bool upload_bake)
  75. {
  76. LLViewerWearable::removeFromAvatar(mType, upload_bake);
  77. }
  78. static void removeFromAvatar(LLWearableType::EType type, bool upload_bake);
  79. EImportResult importStream(std::istream& input_stream,
  80. LLAvatarAppearance* avatarp) override;
  81. void setParamsToDefaults();
  82. void setTexturesToDefaults();
  83. // true when doing preview renders, some updates will be suppressed.
  84. LL_INLINE void setVolatile(bool is_volatile) { mVolatile = is_volatile; }
  85. LL_INLINE bool getVolatile() { return mVolatile; }
  86. LLUUID getDefaultTextureImageID(LLAvatarAppearanceDefines::ETextureIndex index) override;
  87. void saveNewAsset() const;
  88. static void onSaveNewAssetComplete(const LLUUID& asset_uuid,
  89. void* user_data, S32 status,
  90. LLExtStat ext_status);
  91. void copyDataFrom(const LLViewerWearable* src);
  92. friend std::ostream& operator<<(std::ostream &s,
  93. const LLViewerWearable &w);
  94. void revertValues() override;
  95. void saveValues() override;
  96. LL_INLINE void revertValuesWithoutUpdate() { LLWearable::revertValues(); }
  97. // Something happened that requires the wearable's label to be updated
  98. // (e.g. worn/unworn).
  99. void setUpdated() const override;
  100. // The wearable was worn. make sure the name of the wearable object matches
  101. // the LLViewerInventoryItem, not the wearable asset itself.
  102. void refreshName();
  103. // Update the baked texture hash.
  104. void addToBakedTextureHash(LLMD5& hash) const override;
  105. protected:
  106. LLAssetID mAssetID;
  107. LLTransactionID mTransactionID;
  108. // ID of the inventory item in the agent's inventory:
  109. LLUUID mItemID;
  110. // true when rendering preview images. Can suppress some updates.
  111. bool mVolatile;
  112. // Cache used by getDefaultTextureImageID() for speed
  113. static std::map<LLAvatarAppearanceDefines::ETextureIndex, LLUUID> sCachedTextures;
  114. };
  115. class LLWearableSaveData
  116. {
  117. public:
  118. LLWearableSaveData(LLWearableType::EType type);
  119. ~LLWearableSaveData();
  120. LL_INLINE static void resetSavedWearableCount() { sSavedWearableCount = 0; }
  121. LL_INLINE static bool pendingSavedWearables() { return sSavedWearableCount != 0; }
  122. public:
  123. LLWearableType::EType mType;
  124. bool mResetCOFTimer;
  125. static bool sResetCOFTimer;
  126. private:
  127. static U32 sSavedWearableCount;
  128. };
  129. #endif // LL_VIEWER_WEARABLE_H