CustomViewItem.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace SceneEditWindow
  5. {
  6. [AddComponentMenu("SceneEditWindow/CustomViewItem")]
  7. [RequireComponent(typeof(UITexture))]
  8. public class CustomViewItem : MonoBehaviour
  9. {
  10. private void Awake()
  11. {
  12. this.iconTex = base.GetComponent<UITexture>();
  13. this.button = base.GetComponentInChildren<UIButton>();
  14. NDebug.AssertNull(this.button);
  15. EventDelegate.Add(this.button.onClick, new EventDelegate.Callback(this.OnClickButton));
  16. this.buttonTweenTarget = this.button.tweenTarget;
  17. }
  18. public bool UpdateIcon(Maid maid = null)
  19. {
  20. if (maid == null)
  21. {
  22. maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  23. if (maid == null)
  24. {
  25. return false;
  26. }
  27. }
  28. if (this.mpn == MPN.chikubi)
  29. {
  30. this.mpn = MPN.chikubicolor;
  31. }
  32. bool flag = false;
  33. int num = maid.GetProp(this.mpn).nFileNameRID;
  34. if (this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit && maid.GetProp(this.mpn).nTempFileNameRID != 0)
  35. {
  36. num = maid.GetProp(this.mpn).nTempFileNameRID;
  37. }
  38. foreach (SceneEdit.SubPropMpnData subPropMpnData in this.sceneEdit.subPropDatas)
  39. {
  40. if (this.mpn == subPropMpnData.mpn)
  41. {
  42. SubProp subProp = maid.GetSubProp(this.mpn, 0);
  43. if (subProp != null)
  44. {
  45. num = subProp.nFileNameRID;
  46. }
  47. }
  48. }
  49. bool flag2 = true;
  50. if (this.requestNewFace && !this.sceneEdit.isNewFace)
  51. {
  52. this.settingRid = 0;
  53. num = -1;
  54. flag2 = false;
  55. }
  56. if (num != this.settingRid)
  57. {
  58. flag = true;
  59. this.settingRid = num;
  60. SceneEdit.SMenuItem smenuItem = (!flag2) ? null : this.GetMenuItem(maid, this.mpn);
  61. if (smenuItem == null || (smenuItem.m_boDelOnly && this.defaultIconTexture != null) || (smenuItem.m_texIconRef == null && this.defaultIconTexture != null))
  62. {
  63. this.iconTex.mainTexture = this.defaultIconTexture;
  64. this.button.tweenTarget = null;
  65. this.iconTex.color = new Color(1f, 1f, 1f, 0.58f);
  66. TweenColor component = base.GetComponent<TweenColor>();
  67. if (component != null)
  68. {
  69. component.from = (component.to = this.iconTex.color);
  70. }
  71. }
  72. else if (smenuItem.m_texIconRef)
  73. {
  74. this.iconTex.mainTexture = smenuItem.m_texIconRef;
  75. this.button.tweenTarget = this.buttonTweenTarget;
  76. this.iconTex.color = Color.white;
  77. TweenColor component2 = base.GetComponent<TweenColor>();
  78. if (component2 != null)
  79. {
  80. component2.from = (component2.to = this.iconTex.color);
  81. }
  82. }
  83. }
  84. if (this.mpn == MPN.chikubicolor)
  85. {
  86. this.mpn = MPN.chikubi;
  87. }
  88. this.button.isEnabled = this.sceneEdit.isEnabledButton(this.mpn);
  89. if (!this.button.isEnabled)
  90. {
  91. this.iconTex.color = this.button.disabledColor;
  92. }
  93. else if (!flag)
  94. {
  95. SceneEdit.SMenuItem smenuItem2 = (!flag2) ? null : this.GetMenuItem(maid, this.mpn);
  96. if (smenuItem2 == null || (smenuItem2.m_boDelOnly && this.defaultIconTexture != null) || (smenuItem2.m_texIconRef == null && this.defaultIconTexture != null))
  97. {
  98. this.iconTex.color = new Color(1f, 1f, 1f, 0.58f);
  99. }
  100. else
  101. {
  102. this.iconTex.color = Color.white;
  103. }
  104. }
  105. return flag;
  106. }
  107. public SceneEdit.SMenuItem GetMenuItem(Maid maid, MPN mpn)
  108. {
  109. int num = maid.GetProp(mpn).nFileNameRID;
  110. if (this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit)
  111. {
  112. num = maid.GetProp(mpn).nTempFileNameRID;
  113. }
  114. foreach (SceneEdit.SubPropMpnData subPropMpnData in this.sceneEdit.subPropDatas)
  115. {
  116. if (mpn == subPropMpnData.mpn)
  117. {
  118. SubProp subProp = maid.GetSubProp(mpn, 0);
  119. if (subProp != null)
  120. {
  121. num = subProp.nFileNameRID;
  122. }
  123. }
  124. }
  125. List<SceneEdit.SCategory> categoryList = this.sceneEdit.CategoryList;
  126. SceneEditInfo.EMenuCategory category = this.GetCategory(mpn);
  127. bool flag = false;
  128. switch (mpn)
  129. {
  130. case MPN.skin:
  131. mpn = MPN.folder_skin;
  132. flag = true;
  133. break;
  134. default:
  135. if (mpn != MPN.chikubicolor)
  136. {
  137. if (mpn == MPN.eyewhite)
  138. {
  139. mpn = MPN.folder_eyewhite;
  140. }
  141. }
  142. else
  143. {
  144. mpn = MPN.chikubi;
  145. flag = true;
  146. }
  147. break;
  148. case MPN.underhair:
  149. mpn = MPN.folder_underhair;
  150. flag = true;
  151. break;
  152. case MPN.mayu:
  153. mpn = MPN.folder_mayu;
  154. flag = true;
  155. break;
  156. case MPN.eye:
  157. mpn = MPN.folder_eye;
  158. flag = true;
  159. break;
  160. }
  161. for (int j = 0; j < categoryList.Count; j++)
  162. {
  163. if (categoryList[j].m_eCategory == category)
  164. {
  165. for (int k = 0; k < categoryList[j].m_listPartsType.Count; k++)
  166. {
  167. if (categoryList[j].m_listPartsType[k].m_mpn == mpn)
  168. {
  169. for (int l = 0; l < categoryList[j].m_listPartsType[k].m_listMenu.Count; l++)
  170. {
  171. SceneEdit.SMenuItem smenuItem = categoryList[j].m_listPartsType[k].m_listMenu[l];
  172. if (smenuItem.m_nMenuFileRID == num)
  173. {
  174. return smenuItem;
  175. }
  176. if (flag)
  177. {
  178. foreach (SceneEdit.SMenuItem smenuItem2 in smenuItem.m_listColorSet)
  179. {
  180. if (smenuItem2.m_nMenuFileRID == num)
  181. {
  182. return smenuItem;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. return null;
  192. }
  193. public void OnClickButton()
  194. {
  195. this.sceneEdit.ClickEmulate(this.mpn, false);
  196. }
  197. private SceneEditInfo.EMenuCategory GetCategory(MPN mpn)
  198. {
  199. Dictionary<MPN, SceneEditInfo.CCateNameType> dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
  200. if (!dicPartsTypePair.ContainsKey(mpn))
  201. {
  202. return SceneEditInfo.EMenuCategory.プロフィ\u30FCル;
  203. }
  204. return dicPartsTypePair[mpn].m_eMenuCate;
  205. }
  206. [SerializeField]
  207. public MPN mpn;
  208. [SerializeField]
  209. public SceneEdit sceneEdit;
  210. [NonSerialized]
  211. public Texture2D defaultIconTexture;
  212. [NonSerialized]
  213. public bool requestNewFace;
  214. private UIButton button;
  215. private GameObject buttonTweenTarget;
  216. private UITexture iconTex;
  217. private int settingRid;
  218. }
  219. }