CostumePartsEnabledCtrl.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. public class CostumePartsEnabledCtrl : MonoBehaviour
  6. {
  7. public void Init(GameObject goCostumePartsEnabledPanel)
  8. {
  9. if (this.m_sceneEdit != null)
  10. {
  11. return;
  12. }
  13. this.m_sceneEdit = GameObject.Find("__SceneEdit__").GetComponent<SceneEdit>();
  14. foreach (MPN key in this.m_sceneEdit.enabledMpns)
  15. {
  16. this.testForced.Add(key, true);
  17. }
  18. this.m_notSettingIcon = (Resources.Load("SceneEdit/RandomPreset/Texture/_I_del") as Texture2D);
  19. this.CreateRandomItem(goCostumePartsEnabledPanel);
  20. this.LoadMaidPropData();
  21. }
  22. public void CreateRandomItem(GameObject goRandomPresetPanel)
  23. {
  24. Dictionary<MPN, SceneEditInfo.CCateNameType> dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
  25. this.m_dicItemBtn = new Dictionary<string, RandomPresetButton>();
  26. bool flag = false;
  27. foreach (KeyValuePair<MPN, SceneEditInfo.CCateNameType> keyValuePair in dicPartsTypePair)
  28. {
  29. RandomPresetContent.MPNMapping mpnmapping;
  30. if (RandomPresetContent.m_dicMPNMapping.TryGetValue(keyValuePair.Key, out mpnmapping))
  31. {
  32. string text;
  33. if (RandomPresetContent.m_dicCategoryMapping.TryGetValue(keyValuePair.Value.m_eMenuCate, out text))
  34. {
  35. GameObject childObject = UTY.GetChildObject(goRandomPresetPanel, "Contents/Buttons/" + mpnmapping.m_buttonName, true);
  36. if (!(childObject == null))
  37. {
  38. childObject.SetActive(false);
  39. NDebug.Assert(childObject != null, string.Concat(new string[]
  40. {
  41. "ランダムプリセットのボタン[",
  42. mpnmapping.m_buttonTitle,
  43. "]のオブジェクト、[",
  44. mpnmapping.m_buttonName,
  45. "]が見つかりませんでした"
  46. }));
  47. if (keyValuePair.Value.m_eType == SceneEditInfo.CCateNameType.EType.Item)
  48. {
  49. if (this.m_sceneEdit.enabledMpns.Contains(keyValuePair.Key))
  50. {
  51. if (keyValuePair.Key != MPN.acckamisub)
  52. {
  53. childObject.SetActive(true);
  54. UTY.GetChildObject(childObject, "Title", false).GetComponent<UILabel>().text = mpnmapping.m_buttonTitle;
  55. if (keyValuePair.Key == MPN.hairt)
  56. {
  57. UILabel component = UTY.GetChildObject(childObject, "Title", false).GetComponent<UILabel>();
  58. component.text += " &\nリボン";
  59. }
  60. UIButton component2 = childObject.GetComponent<UIButton>();
  61. if (!flag)
  62. {
  63. this.activeColor = new Color(component2.defaultColor.r, component2.defaultColor.g, component2.defaultColor.b, 1f);
  64. this.inActiveColor = component2.defaultColor;
  65. flag = true;
  66. }
  67. SceneEditInfo.CCateNameType.EType eType = keyValuePair.Value.m_eType;
  68. ItemTypeRandomPresetButton itemTypeRandomPresetButton = new ItemTypeRandomPresetButton();
  69. itemTypeRandomPresetButton.m_menuCategory = keyValuePair.Value.m_eMenuCate;
  70. itemTypeRandomPresetButton.m_eButtonType = eType;
  71. itemTypeRandomPresetButton.m_name = mpnmapping.m_buttonName;
  72. itemTypeRandomPresetButton.m_mpn = keyValuePair.Key;
  73. itemTypeRandomPresetButton.m_btnButton = component2;
  74. itemTypeRandomPresetButton.m_bBtnActive = false;
  75. itemTypeRandomPresetButton.m_executionOrder = mpnmapping.m_executionOrder;
  76. itemTypeRandomPresetButton.m_txtItem = UTY.GetChildObject(childObject, "Item", false).GetComponent<UITexture>();
  77. this.m_dicItemBtn.Add(itemTypeRandomPresetButton.m_name, itemTypeRandomPresetButton);
  78. }
  79. }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. UITable component3 = UTY.GetChildObject(goRandomPresetPanel, "Contents/Buttons", false).GetComponent<UITable>();
  86. Utility.ResetNGUI(component3);
  87. component3.repositionNow = true;
  88. }
  89. public void LoadMaidPropData()
  90. {
  91. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  92. Action<SceneEditInfo.EMenuCategory, MPN, UITexture> action = delegate(SceneEditInfo.EMenuCategory category, MPN mpn, UITexture tex)
  93. {
  94. int num = maid.GetProp(mpn).nTempFileNameRID;
  95. foreach (SceneEdit.SubPropMpnData subPropMpnData in this.m_sceneEdit.subPropDatas)
  96. {
  97. if (mpn == subPropMpnData.mpn)
  98. {
  99. if (subPropMpnData.manager.sloatItems != null && subPropMpnData.manager.sloatItems[0].menuItem != null)
  100. {
  101. num = subPropMpnData.manager.sloatItems[0].menuItem.m_nMenuFileRID;
  102. }
  103. break;
  104. }
  105. }
  106. Texture2D mainTexture;
  107. if (num == 0)
  108. {
  109. mainTexture = this.m_notSettingIcon;
  110. }
  111. else
  112. {
  113. mainTexture = this.GetTextureByRid(category, mpn, num);
  114. }
  115. tex.mainTexture = mainTexture;
  116. };
  117. Facility tempSelectFacility = GameMain.Instance.FacilityMgr.tempSelectFacility;
  118. NDebug.Assert(tempSelectFacility != null, "現在選択中の施設がnullです");
  119. foreach (KeyValuePair<string, RandomPresetButton> keyValuePair in this.m_dicItemBtn)
  120. {
  121. RandomPresetButton value = keyValuePair.Value;
  122. action(value.m_menuCategory, value.m_mpn, value.m_txtItem);
  123. bool costumeForced = tempSelectFacility.GetCostumeForced(value.m_mpn);
  124. this.SetButtonActive(value, costumeForced);
  125. if (value.m_mpn == MPN.hairt)
  126. {
  127. UITexture component = UTY.GetChildObject(value.m_btnButton.gameObject, "Item2", false).GetComponent<UITexture>();
  128. action(SceneEditInfo.EMenuCategory.アクセサリ, MPN.acckamisub, component);
  129. }
  130. }
  131. }
  132. public void OnButtonClick(string clickBtnName)
  133. {
  134. RandomPresetButton randomPresetButton = this.m_dicItemBtn[clickBtnName];
  135. this.SetButtonActive(randomPresetButton, !randomPresetButton.m_bBtnActive);
  136. }
  137. public void OnAllButtonClick(bool active)
  138. {
  139. foreach (KeyValuePair<string, RandomPresetButton> keyValuePair in this.m_dicItemBtn)
  140. {
  141. this.SetButtonActive(keyValuePair.Value, active);
  142. }
  143. }
  144. public void SetButtonActive(RandomPresetButton itemData, bool active)
  145. {
  146. Facility tempSelectFacility = GameMain.Instance.FacilityMgr.tempSelectFacility;
  147. tempSelectFacility.SetCostumeForced(itemData.m_mpn, active);
  148. if (itemData.m_mpn == MPN.hairt)
  149. {
  150. this.testForced[MPN.acckamisub] = active;
  151. }
  152. tempSelectFacility.SetCostumeForced(MPN.acckamisub, active);
  153. itemData.m_bBtnActive = active;
  154. if (itemData.m_bBtnActive)
  155. {
  156. itemData.m_btnButton.defaultColor = this.activeColor;
  157. }
  158. else
  159. {
  160. itemData.m_btnButton.defaultColor = this.inActiveColor;
  161. }
  162. }
  163. private Texture2D GetTextureByRid(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn, int rid)
  164. {
  165. List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
  166. foreach (SceneEdit.SCategory scategory in categoryList)
  167. {
  168. if (scategory.m_eCategory == eMenuCategory)
  169. {
  170. foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
  171. {
  172. if (spartsType.m_mpn == btnMpn)
  173. {
  174. foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
  175. {
  176. if (smenuItem.m_nMenuFileRID == rid)
  177. {
  178. if (smenuItem.m_boDelOnly)
  179. {
  180. return smenuItem.m_texIcon;
  181. }
  182. return smenuItem.m_texIcon;
  183. }
  184. }
  185. return this.m_notSettingIcon;
  186. }
  187. }
  188. }
  189. }
  190. return null;
  191. }
  192. private SceneEdit m_sceneEdit;
  193. private Dictionary<string, RandomPresetButton> m_dicItemBtn;
  194. private Color activeColor;
  195. private Color inActiveColor;
  196. private Texture2D m_notSettingIcon;
  197. private Dictionary<MPN, bool> testForced = new Dictionary<MPN, bool>();
  198. }