CustomViewItem.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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.chikubicolor:
  136. mpn = MPN.chikubi;
  137. flag = true;
  138. break;
  139. case MPN.eyewhite:
  140. mpn = MPN.folder_eyewhite;
  141. flag = true;
  142. break;
  143. default:
  144. switch (mpn)
  145. {
  146. case MPN.skin:
  147. mpn = MPN.folder_skin;
  148. flag = true;
  149. break;
  150. case MPN.underhair:
  151. mpn = MPN.folder_underhair;
  152. flag = true;
  153. break;
  154. case MPN.mayu:
  155. mpn = MPN.folder_mayu;
  156. flag = true;
  157. break;
  158. case MPN.eye:
  159. mpn = MPN.folder_eye;
  160. flag = true;
  161. break;
  162. }
  163. break;
  164. case MPN.matsuge_up:
  165. mpn = MPN.folder_matsuge_up;
  166. flag = true;
  167. break;
  168. case MPN.matsuge_low:
  169. mpn = MPN.folder_matsuge_low;
  170. flag = true;
  171. break;
  172. case MPN.futae:
  173. mpn = MPN.folder_futae;
  174. flag = true;
  175. break;
  176. }
  177. for (int j = 0; j < categoryList.Count; j++)
  178. {
  179. if (categoryList[j].m_eCategory == category)
  180. {
  181. for (int k = 0; k < categoryList[j].m_listPartsType.Count; k++)
  182. {
  183. if (categoryList[j].m_listPartsType[k].m_mpn == mpn)
  184. {
  185. for (int l = 0; l < categoryList[j].m_listPartsType[k].m_listMenu.Count; l++)
  186. {
  187. SceneEdit.SMenuItem smenuItem = categoryList[j].m_listPartsType[k].m_listMenu[l];
  188. if (smenuItem.m_nMenuFileRID == num)
  189. {
  190. return smenuItem;
  191. }
  192. if (flag)
  193. {
  194. foreach (SceneEdit.SMenuItem smenuItem2 in smenuItem.m_listColorSet)
  195. {
  196. if (smenuItem2.m_nMenuFileRID == num)
  197. {
  198. return smenuItem;
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. return null;
  208. }
  209. public void OnClickButton()
  210. {
  211. this.sceneEdit.ClickEmulate(this.mpn, false);
  212. }
  213. private SceneEditInfo.EMenuCategory GetCategory(MPN mpn)
  214. {
  215. Dictionary<MPN, SceneEditInfo.CCateNameType> dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
  216. if (!dicPartsTypePair.ContainsKey(mpn))
  217. {
  218. return SceneEditInfo.EMenuCategory.プロフィ\u30FCル;
  219. }
  220. return dicPartsTypePair[mpn].m_eMenuCate;
  221. }
  222. [SerializeField]
  223. public MPN mpn;
  224. [SerializeField]
  225. public SceneEdit sceneEdit;
  226. [NonSerialized]
  227. public Texture2D defaultIconTexture;
  228. [NonSerialized]
  229. public bool requestNewFace;
  230. [NonSerialized]
  231. public bool requestFBFace;
  232. private UIButton button;
  233. private GameObject buttonTweenTarget;
  234. private UITexture iconTex;
  235. private int settingRid;
  236. }
  237. }