CustomViewItem.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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) || (this.requestFBFace && !this.sceneEdit.isFBFace))
  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. if ((this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit && this.requestNewFace) || (this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit && this.requestFBFace))
  106. {
  107. this.button.isEnabled = false;
  108. this.button.tweenTarget = this.buttonTweenTarget;
  109. }
  110. return flag;
  111. }
  112. public SceneEdit.SMenuItem GetMenuItem(Maid maid, MPN mpn)
  113. {
  114. int num = maid.GetProp(mpn).nFileNameRID;
  115. if (this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit)
  116. {
  117. num = maid.GetProp(mpn).nTempFileNameRID;
  118. }
  119. foreach (SceneEdit.SubPropMpnData subPropMpnData in this.sceneEdit.subPropDatas)
  120. {
  121. if (mpn == subPropMpnData.mpn)
  122. {
  123. SubProp subProp = maid.GetSubProp(mpn, 0);
  124. if (subProp != null)
  125. {
  126. num = subProp.nFileNameRID;
  127. }
  128. }
  129. }
  130. List<SceneEdit.SCategory> categoryList = this.sceneEdit.CategoryList;
  131. SceneEditInfo.EMenuCategory category = this.GetCategory(mpn);
  132. bool flag = false;
  133. switch (mpn)
  134. {
  135. case MPN.mayu:
  136. mpn = MPN.folder_mayu;
  137. flag = true;
  138. break;
  139. default:
  140. switch (mpn)
  141. {
  142. case MPN.matsuge_up:
  143. mpn = MPN.folder_matsuge_up;
  144. flag = true;
  145. break;
  146. case MPN.matsuge_low:
  147. mpn = MPN.folder_matsuge_low;
  148. flag = true;
  149. break;
  150. case MPN.futae:
  151. mpn = MPN.folder_futae;
  152. flag = true;
  153. break;
  154. default:
  155. switch (mpn)
  156. {
  157. case MPN.skin:
  158. mpn = MPN.folder_skin;
  159. flag = true;
  160. break;
  161. case MPN.underhair:
  162. mpn = MPN.folder_underhair;
  163. flag = true;
  164. break;
  165. }
  166. break;
  167. }
  168. break;
  169. case MPN.chikubicolor:
  170. mpn = MPN.chikubi;
  171. flag = true;
  172. break;
  173. case MPN.eye:
  174. mpn = MPN.folder_eye;
  175. flag = true;
  176. break;
  177. case MPN.eyewhite:
  178. mpn = MPN.folder_eyewhite;
  179. flag = true;
  180. break;
  181. }
  182. for (int j = 0; j < categoryList.Count; j++)
  183. {
  184. if (categoryList[j].m_eCategory == category)
  185. {
  186. for (int k = 0; k < categoryList[j].m_listPartsType.Count; k++)
  187. {
  188. if (categoryList[j].m_listPartsType[k].m_mpn == mpn)
  189. {
  190. for (int l = 0; l < categoryList[j].m_listPartsType[k].m_listMenu.Count; l++)
  191. {
  192. SceneEdit.SMenuItem smenuItem = categoryList[j].m_listPartsType[k].m_listMenu[l];
  193. if (smenuItem.m_nMenuFileRID == num)
  194. {
  195. return smenuItem;
  196. }
  197. if (flag)
  198. {
  199. foreach (SceneEdit.SMenuItem smenuItem2 in smenuItem.m_listColorSet)
  200. {
  201. if (smenuItem2.m_nMenuFileRID == num)
  202. {
  203. return smenuItem;
  204. }
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. return null;
  213. }
  214. public void OnClickButton()
  215. {
  216. this.sceneEdit.ClickEmulate(this.mpn, false);
  217. }
  218. private SceneEditInfo.EMenuCategory GetCategory(MPN mpn)
  219. {
  220. Dictionary<MPN, SceneEditInfo.CCateNameType> dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
  221. if (!dicPartsTypePair.ContainsKey(mpn))
  222. {
  223. return SceneEditInfo.EMenuCategory.プロフィ\u30FCル;
  224. }
  225. return dicPartsTypePair[mpn].m_eMenuCate;
  226. }
  227. [SerializeField]
  228. public MPN mpn;
  229. [SerializeField]
  230. public SceneEdit sceneEdit;
  231. [NonSerialized]
  232. public Texture2D defaultIconTexture;
  233. [NonSerialized]
  234. public bool requestNewFace;
  235. [NonSerialized]
  236. public bool requestFBFace;
  237. private UIButton button;
  238. private GameObject buttonTweenTarget;
  239. private UITexture iconTex;
  240. private int settingRid;
  241. }
  242. }