llpaneleditwearable.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /**
  2. * @file llpaneleditwearable.h
  3. * @brief A LLPanel dedicated to the editing of wearables.
  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_LLPANELEDITWEARABLE_H
  33. #define LL_LLPANELEDITWEARABLE_H
  34. #include "hbfileselector.h"
  35. #include "llmodaldialog.h"
  36. #include "llpanel.h"
  37. #include "llviewerwearable.h"
  38. #include "llvoavatarself.h"
  39. class LLButton;
  40. class LLIconCtrl;
  41. class LLSpinCtrl;
  42. class LLTextBox;
  43. ////////////////////////////////////////////////////////////////////////////
  44. class LLWearableSaveAsDialog : public LLModalDialog
  45. {
  46. public:
  47. LLWearableSaveAsDialog(const std::string& desc,
  48. void (*commit_cb)(LLWearableSaveAsDialog*, void*),
  49. void* userdata);
  50. virtual void startModal();
  51. LL_INLINE const std::string& getItemName() { return mItemName; }
  52. private:
  53. static void onSave(void* userdata);
  54. static void onCancel(void* userdata);
  55. private:
  56. std::string mItemName;
  57. void (*mCommitCallback)(LLWearableSaveAsDialog*, void*);
  58. void* mCallbackUserData;
  59. };
  60. /////////////////////////////////////////////////////////////////////
  61. // LLPanelEditWearable
  62. enum ESubpart
  63. {
  64. SUBPART_SHAPE_HEAD = 1, // avoid 0
  65. SUBPART_SHAPE_EYES,
  66. SUBPART_SHAPE_EARS,
  67. SUBPART_SHAPE_NOSE,
  68. SUBPART_SHAPE_MOUTH,
  69. SUBPART_SHAPE_CHIN,
  70. SUBPART_SHAPE_TORSO,
  71. SUBPART_SHAPE_LEGS,
  72. SUBPART_SHAPE_WHOLE,
  73. SUBPART_SHAPE_DETAIL,
  74. SUBPART_SKIN_COLOR,
  75. SUBPART_SKIN_FACEDETAIL,
  76. SUBPART_SKIN_MAKEUP,
  77. SUBPART_SKIN_BODYDETAIL,
  78. SUBPART_HAIR_COLOR,
  79. SUBPART_HAIR_STYLE,
  80. SUBPART_HAIR_EYEBROWS,
  81. SUBPART_HAIR_FACIAL,
  82. SUBPART_EYES,
  83. SUBPART_SHIRT,
  84. SUBPART_PANTS,
  85. SUBPART_SHOES,
  86. SUBPART_SOCKS,
  87. SUBPART_JACKET,
  88. SUBPART_GLOVES,
  89. SUBPART_UNDERSHIRT,
  90. SUBPART_UNDERPANTS,
  91. SUBPART_SKIRT,
  92. SUBPART_ALPHA,
  93. SUBPART_TATTOO,
  94. SUBPART_UNIVERSAL,
  95. SUBPART_PHYSICS_BREASTS_UPDOWN,
  96. SUBPART_PHYSICS_BREASTS_INOUT,
  97. SUBPART_PHYSICS_BREASTS_LEFTRIGHT,
  98. SUBPART_PHYSICS_BELLY_UPDOWN,
  99. SUBPART_PHYSICS_BUTT_UPDOWN,
  100. SUBPART_PHYSICS_BUTT_LEFTRIGHT,
  101. SUBPART_PHYSICS_ADVANCED
  102. };
  103. struct LLSubpart
  104. {
  105. LLSubpart() : mSex(SEX_BOTH), mVisualHint(true) {}
  106. std::string mButtonName;
  107. std::string mEditGroup;
  108. U32 mTargetJointKey;
  109. LLVector3d mTargetOffset;
  110. LLVector3d mCameraOffset;
  111. ESex mSex;
  112. bool mVisualHint;
  113. };
  114. ////////////////////////////////////////////////////////////////////////////
  115. class LLPanelEditWearable : public LLPanel
  116. {
  117. protected:
  118. LOG_CLASS(LLPanelEditWearable);
  119. public:
  120. LLPanelEditWearable(LLWearableType::EType type);
  121. ~LLPanelEditWearable() override;
  122. bool postBuild() override;
  123. void draw() override;
  124. bool isDirty() const override;
  125. void setVisible(bool visible) override;
  126. void addSubpart(const std::string& name, ESubpart id, LLSubpart* part);
  127. void addTextureDropTarget(LLAvatarAppearanceDefines::ETextureIndex te,
  128. const std::string& name,
  129. const LLUUID& default_image_id,
  130. bool allow_no_texture = false);
  131. void addInvisibilityCheckbox(LLAvatarAppearanceDefines::ETextureIndex te,
  132. const std::string& name);
  133. void addColorSwatch(LLAvatarAppearanceDefines::ETextureIndex te,
  134. const std::string& name);
  135. LL_INLINE const std::string& getLabel() { return LLWearableType::getTypeLabel(mType); }
  136. LL_INLINE LLWearableType::EType getType() { return mType; }
  137. LL_INLINE LLSubpart* getCurrentSubpart() { return mSubpartList[mCurrentSubpart]; }
  138. ESubpart getDefaultSubpart();
  139. void setSubpart(ESubpart subpart);
  140. void switchToDefaultSubpart();
  141. void setWearable(LLViewerWearable* wearable, U32 perm_mask,
  142. bool is_complete);
  143. LL_INLINE LLViewerWearable* getWearable() { return mWearable; }
  144. LL_INLINE U32 getWearableIndex() { return mLayer; }
  145. void setUIPermissions(U32 perm_mask, bool is_complete);
  146. void hideTextureControls();
  147. bool textureIsInvisible(LLAvatarAppearanceDefines::ETextureIndex te);
  148. void initPreviousTextureList();
  149. void initPreviousTextureListEntry(LLAvatarAppearanceDefines::ETextureIndex te);
  150. private:
  151. void setMaxLayers();
  152. // Callbacks
  153. static void onCommitSexChange(LLUICtrl*, void* userdata);
  154. static void onBtnImport(void* userdata);
  155. static void importCallback(HBFileSelector::ELoadFilter type,
  156. std::string& filename, void* userdata);
  157. static void onBtnSubpart(void* userdata);
  158. static void onBtnTakeOff(void* userdata);
  159. static void onBtnSave(void* userdata);
  160. static void onBtnSaveAs(void* userdata);
  161. static void onSaveAsCommit(LLWearableSaveAsDialog* save_as_dialog,
  162. void* userdata);
  163. static void onBtnRevert(void* userdata);
  164. static void onBtnTakeOffDialog(S32 option, void* userdata);
  165. static void onBtnCreateNew(void* userdata);
  166. static void onTextureCommit(LLUICtrl* ctrl, void* userdata);
  167. static void onInvisibilityCommit(LLUICtrl* ctrl, void* userdata);
  168. static void onColorCommit(LLUICtrl* ctrl, void* userdata);
  169. static void onCommitLayer(LLUICtrl*, void* userdata);
  170. private:
  171. LLSpinCtrl* mSpinLayer;
  172. LLButton* mButtonImport;
  173. LLButton* mButtonCreateNew;
  174. LLButton* mButtonSave;
  175. LLButton* mButtonSaveAs;
  176. LLButton* mButtonRevert;
  177. LLButton* mButtonTakeOff;
  178. LLUICtrl* mSexRadio;
  179. LLIconCtrl* mWearableIcon;
  180. LLIconCtrl* mLockIcon;
  181. LLTextBox* mNotWornInstructions;
  182. LLTextBox* mNoModifyInstructions;
  183. LLTextBox* mTitle;
  184. LLTextBox* mTitleNoModify;
  185. LLTextBox* mTitleNotWorn;
  186. LLTextBox* mTitleLoading;
  187. LLTextBox* mPath;
  188. LLViewerWearable* mWearable;
  189. LLWearableType::EType mType;
  190. U32 mLayer;
  191. ESubpart mCurrentSubpart;
  192. bool mCanTakeOff;
  193. std::map<std::string, S32> mTextureList;
  194. std::map<std::string, S32> mInvisibilityList;
  195. std::map<std::string, S32> mColorList;
  196. std::map<ESubpart, LLSubpart*> mSubpartList;
  197. std::map<S32, LLUUID> mPreviousTextureList;
  198. };
  199. #endif