CustomViewItem.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 result = 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. if (num != this.settingRid)
  50. {
  51. result = true;
  52. this.settingRid = num;
  53. SceneEdit.SMenuItem menuItem = this.GetMenuItem(maid, this.mpn);
  54. if (menuItem == null || (menuItem.m_boDelOnly && this.defaultIconTexture != null) || (menuItem.m_texIcon == null && this.defaultIconTexture != null))
  55. {
  56. this.iconTex.mainTexture = this.defaultIconTexture;
  57. this.button.tweenTarget = null;
  58. this.iconTex.color = new Color(1f, 1f, 1f, 0.58f);
  59. TweenColor component = base.GetComponent<TweenColor>();
  60. if (component != null)
  61. {
  62. component.from = (component.to = this.iconTex.color);
  63. }
  64. }
  65. else if (menuItem.m_texIcon)
  66. {
  67. this.iconTex.mainTexture = menuItem.m_texIcon;
  68. this.button.tweenTarget = this.buttonTweenTarget;
  69. this.iconTex.color = Color.white;
  70. TweenColor component2 = base.GetComponent<TweenColor>();
  71. if (component2 != null)
  72. {
  73. component2.from = (component2.to = this.iconTex.color);
  74. }
  75. }
  76. }
  77. if (this.mpn == MPN.chikubicolor)
  78. {
  79. this.mpn = MPN.chikubi;
  80. }
  81. this.button.isEnabled = this.sceneEdit.isEnabledButton(this.mpn);
  82. if (!this.button.isEnabled)
  83. {
  84. this.iconTex.color = this.button.disabledColor;
  85. }
  86. return result;
  87. }
  88. public SceneEdit.SMenuItem GetMenuItem(Maid maid, MPN mpn)
  89. {
  90. int num = maid.GetProp(mpn).nFileNameRID;
  91. if (this.sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit)
  92. {
  93. num = maid.GetProp(mpn).nTempFileNameRID;
  94. }
  95. foreach (SceneEdit.SubPropMpnData subPropMpnData in this.sceneEdit.subPropDatas)
  96. {
  97. if (mpn == subPropMpnData.mpn)
  98. {
  99. SubProp subProp = maid.GetSubProp(mpn, 0);
  100. if (subProp != null)
  101. {
  102. num = subProp.nFileNameRID;
  103. }
  104. }
  105. }
  106. List<SceneEdit.SCategory> categoryList = this.sceneEdit.CategoryList;
  107. SceneEditInfo.EMenuCategory category = this.GetCategory(mpn);
  108. bool flag = false;
  109. switch (mpn)
  110. {
  111. case MPN.skin:
  112. mpn = MPN.folder_skin;
  113. flag = true;
  114. break;
  115. default:
  116. if (mpn == MPN.chikubicolor)
  117. {
  118. mpn = MPN.chikubi;
  119. flag = true;
  120. }
  121. break;
  122. case MPN.underhair:
  123. mpn = MPN.folder_underhair;
  124. flag = true;
  125. break;
  126. case MPN.mayu:
  127. mpn = MPN.folder_mayu;
  128. flag = true;
  129. break;
  130. case MPN.eye:
  131. mpn = MPN.folder_eye;
  132. flag = true;
  133. break;
  134. }
  135. for (int j = 0; j < categoryList.Count; j++)
  136. {
  137. if (categoryList[j].m_eCategory == category)
  138. {
  139. for (int k = 0; k < categoryList[j].m_listPartsType.Count; k++)
  140. {
  141. if (categoryList[j].m_listPartsType[k].m_mpn == mpn)
  142. {
  143. for (int l = 0; l < categoryList[j].m_listPartsType[k].m_listMenu.Count; l++)
  144. {
  145. SceneEdit.SMenuItem smenuItem = categoryList[j].m_listPartsType[k].m_listMenu[l];
  146. if (smenuItem.m_nMenuFileRID == num)
  147. {
  148. return smenuItem;
  149. }
  150. if (flag)
  151. {
  152. foreach (SceneEdit.SMenuItem smenuItem2 in smenuItem.m_listColorSet)
  153. {
  154. if (smenuItem2.m_nMenuFileRID == num)
  155. {
  156. return smenuItem;
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. return null;
  166. }
  167. public void OnClickButton()
  168. {
  169. this.sceneEdit.ClickEmulate(this.mpn, false);
  170. }
  171. private SceneEditInfo.EMenuCategory GetCategory(MPN mpn)
  172. {
  173. Dictionary<MPN, SceneEditInfo.CCateNameType> dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
  174. if (!dicPartsTypePair.ContainsKey(mpn))
  175. {
  176. return SceneEditInfo.EMenuCategory.プロフィ\u30FCル;
  177. }
  178. return dicPartsTypePair[mpn].m_eMenuCate;
  179. }
  180. [SerializeField]
  181. public MPN mpn;
  182. [SerializeField]
  183. public SceneEdit sceneEdit;
  184. [NonSerialized]
  185. public Texture2D defaultIconTexture;
  186. private UIButton button;
  187. private GameObject buttonTweenTarget;
  188. private UITexture iconTex;
  189. private int settingRid;
  190. }
  191. }