AttachPointSubWindow.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class AttachPointSubWindow : BasePhotoSubWindow
  5. {
  6. public void Awake()
  7. {
  8. if (this.popupMaidList.onChangePopUpListValue.Count != 0)
  9. {
  10. return;
  11. }
  12. this.checkboxTransReset.check = true;
  13. if (this.popupMaidList.popup_value_list == null || this.popupMaidList.popup_value_list.Count == 0)
  14. {
  15. this.popupMaidList.popup_value_list = this.CreatePopupList();
  16. }
  17. Action<WFCheckBox> item = delegate(WFCheckBox checkbox)
  18. {
  19. foreach (AttachPointSubWindow.AttachPointCheckBoxs clickCheckBoxData in this.checkBoxs)
  20. {
  21. if (clickCheckBoxData.checkBox == checkbox)
  22. {
  23. this.OnClickAttachCheckBox(clickCheckBoxData);
  24. return;
  25. }
  26. }
  27. };
  28. foreach (AttachPointSubWindow.AttachPointCheckBoxs attachPointCheckBoxs in this.checkBoxs)
  29. {
  30. attachPointCheckBoxs.checkBox.check = false;
  31. attachPointCheckBoxs.checkBox.onClick.Add(item);
  32. }
  33. this.popupMaidList.onChangePopUpListValue.Add(new Action<KeyValuePair<string, UnityEngine.Object>>(this.OnSelectPopupList));
  34. }
  35. public override void Initizalize(BasePhotoWindow parentWindow)
  36. {
  37. this.Awake();
  38. base.Initizalize(parentWindow);
  39. this.popupMaidList.SetPopupValue(this.popupMaidList.popup_value_list[0].Key);
  40. }
  41. public void OnSelectPopupList(KeyValuePair<string, UnityEngine.Object> selectedItem)
  42. {
  43. if (this.selectItem == null || this.selectItem.obj == null || selectedItem.Value == null || this.selectItem.type == PhotoTransTargetObject.Type.BG)
  44. {
  45. this.stateText = "設定不可";
  46. if (this.selectItem != null && this.selectItem.obj != null)
  47. {
  48. this.selectItem.attachi_point = PhotoTransTargetObject.AttachPoint.Null;
  49. string stateText = this.selectItem.Attach(this.selectItem.attachi_point, !this.checkboxTransReset.check, null);
  50. if (this.selectItem.type != PhotoTransTargetObject.Type.BG)
  51. {
  52. this.stateText = stateText;
  53. }
  54. if (this.onStateTextChangeEvent != null)
  55. {
  56. this.onStateTextChangeEvent(this.stateText);
  57. }
  58. }
  59. foreach (AttachPointSubWindow.AttachPointCheckBoxs attachPointCheckBoxs in this.checkBoxs)
  60. {
  61. WFCheckBox checkBox = attachPointCheckBoxs.checkBox;
  62. bool flag = false;
  63. attachPointCheckBoxs.checkBox.enabled = flag;
  64. checkBox.check = flag;
  65. }
  66. return;
  67. }
  68. if (this.selectItem.attachi_point == PhotoTransTargetObject.AttachPoint.Null)
  69. {
  70. this.stateText = "設定なし";
  71. if (this.onStateTextChangeEvent != null)
  72. {
  73. this.onStateTextChangeEvent(this.stateText);
  74. }
  75. }
  76. foreach (AttachPointSubWindow.AttachPointCheckBoxs clickCheckBoxData in this.checkBoxs)
  77. {
  78. clickCheckBoxData.checkBox.enabled = true;
  79. clickCheckBoxData.checkBox.check = (clickCheckBoxData.attachType == this.selectItem.attachi_point);
  80. if (clickCheckBoxData.checkBox.check)
  81. {
  82. this.OnClickAttachCheckBox(clickCheckBoxData);
  83. }
  84. }
  85. }
  86. public void OnSelectItem(PhotoTransTargetObject select)
  87. {
  88. this.selectItem = select;
  89. if (select.attachi_point == PhotoTransTargetObject.AttachPoint.Null)
  90. {
  91. this.popupMaidList.SetPopupValue(this.popupMaidList.popup_value_list[0].Key);
  92. }
  93. else
  94. {
  95. string text = string.Empty;
  96. List<KeyValuePair<string, UnityEngine.Object>> popup_value_list = this.popupMaidList.popup_value_list;
  97. for (int i = 0; i < popup_value_list.Count; i++)
  98. {
  99. if (popup_value_list[i].Value != null && (popup_value_list[i].Value as Maid).status.guid == select.attach_maid_guid)
  100. {
  101. text = popup_value_list[i].Key;
  102. break;
  103. }
  104. }
  105. if (!string.IsNullOrEmpty(text))
  106. {
  107. this.popupMaidList.SetPopupValue(text);
  108. }
  109. else
  110. {
  111. this.popupMaidList.SetPopupValue(this.popupMaidList.popup_value_list[0].Key);
  112. }
  113. }
  114. }
  115. public void OnClickAttachCheckBox(AttachPointSubWindow.AttachPointCheckBoxs clickCheckBoxData)
  116. {
  117. if (this.selectItem == null || this.popupMaidList.popup_select_value.Value == null)
  118. {
  119. return;
  120. }
  121. foreach (AttachPointSubWindow.AttachPointCheckBoxs attachPointCheckBoxs in this.checkBoxs)
  122. {
  123. if (attachPointCheckBoxs.checkBox != clickCheckBoxData.checkBox)
  124. {
  125. attachPointCheckBoxs.checkBox.check = false;
  126. }
  127. }
  128. if (!clickCheckBoxData.checkBox.check)
  129. {
  130. this.selectItem.attachi_point = PhotoTransTargetObject.AttachPoint.Null;
  131. this.stateText = this.selectItem.Attach(this.selectItem.attachi_point, !this.checkboxTransReset.check, null);
  132. if (this.onStateTextChangeEvent != null)
  133. {
  134. this.onStateTextChangeEvent(this.stateText);
  135. }
  136. return;
  137. }
  138. this.selectItem.attachi_point = clickCheckBoxData.attachType;
  139. this.stateText = this.selectItem.Attach(this.selectItem.attachi_point, !this.checkboxTransReset.check, this.popupMaidList.popup_select_value.Value as Maid);
  140. if (this.onStateTextChangeEvent != null)
  141. {
  142. this.onStateTextChangeEvent(this.stateText);
  143. }
  144. }
  145. public void OnMaidAddEvent(Maid maid, bool is_deserialize_load)
  146. {
  147. if (maid == null || maid.boMAN)
  148. {
  149. return;
  150. }
  151. if (this.maidList == null)
  152. {
  153. PlacementWindow placementWindow = (this.parent_window_.mgr as PhotoWindowManager).GetWindow(PhotoWindowManager.WindowType.Placement) as PlacementWindow;
  154. this.maidList = placementWindow.maid_list;
  155. }
  156. this.activeMaidList.Add(maid);
  157. bool flag = this.popupMaidList.popup_select_value.Value == null;
  158. this.popupMaidList.popup_value_list = this.CreatePopupList();
  159. if (flag)
  160. {
  161. this.popupMaidList.SetPopupValue(this.popupMaidList.popup_value_list[0].Key);
  162. }
  163. }
  164. public void OnMaidRemoveEventPrev(Maid maid)
  165. {
  166. if (maid == null || maid.boMAN)
  167. {
  168. return;
  169. }
  170. Maid y = (!(this.popupMaidList.popup_select_value.Value == null)) ? (this.popupMaidList.popup_select_value.Value as Maid) : null;
  171. List<KeyValuePair<string, UnityEngine.Object>> popup_value_list = this.popupMaidList.popup_value_list;
  172. int num = -1;
  173. int num2 = 0;
  174. while (num2 < popup_value_list.Count && num == -1)
  175. {
  176. if (popup_value_list[num2].Value == y)
  177. {
  178. num = num2;
  179. }
  180. num2++;
  181. }
  182. this.activeMaidList.Remove(maid);
  183. List<KeyValuePair<string, UnityEngine.Object>> list = this.CreatePopupList();
  184. for (int i = 0; i < list.Count; i++)
  185. {
  186. Maid x = (!(list[i].Value == null)) ? (list[i].Value as Maid) : null;
  187. if (x == maid)
  188. {
  189. list.RemoveAt(i);
  190. break;
  191. }
  192. }
  193. this.popupMaidList.popup_value_list = list;
  194. if (0 <= num && num < list.Count)
  195. {
  196. this.popupMaidList.SetPopupValue(list[num].Key);
  197. }
  198. else
  199. {
  200. this.popupMaidList.SetPopupValue(list[0].Key);
  201. }
  202. }
  203. public void Serialize(ref Dictionary<string, string> serializeData)
  204. {
  205. serializeData.Add("trans_reset", this.checkboxTransReset.check.ToString());
  206. }
  207. public void Deserialize(Dictionary<string, string> deserializeData)
  208. {
  209. if (deserializeData.ContainsKey("trans_reset"))
  210. {
  211. bool check = bool.Parse(deserializeData["trans_reset"]);
  212. this.checkboxTransReset.check = check;
  213. }
  214. }
  215. private List<KeyValuePair<string, UnityEngine.Object>> CreatePopupList()
  216. {
  217. List<KeyValuePair<string, UnityEngine.Object>> list = new List<KeyValuePair<string, UnityEngine.Object>>();
  218. list.Add(new KeyValuePair<string, UnityEngine.Object>("アタッチポイントの指定なし", null));
  219. if (this.maidList == null || this.activeMaidList.Count <= 0)
  220. {
  221. return list;
  222. }
  223. list.Clear();
  224. HashSet<string> hashSet = new HashSet<string>();
  225. for (int i = 0; i < this.maidList.Count; i++)
  226. {
  227. if (this.activeMaidList.Contains(this.maidList[i]))
  228. {
  229. string text = this.maidList[i].status.lastName + " " + this.maidList[i].status.firstName;
  230. string text2 = text;
  231. if (hashSet.Contains(text2))
  232. {
  233. int num = 2;
  234. do
  235. {
  236. text2 = string.Concat(new object[]
  237. {
  238. text,
  239. "(",
  240. num,
  241. ")"
  242. });
  243. num++;
  244. }
  245. while (hashSet.Contains(text2));
  246. }
  247. hashSet.Add(text2);
  248. list.Add(new KeyValuePair<string, UnityEngine.Object>(text2, this.maidList[i]));
  249. }
  250. }
  251. return list;
  252. }
  253. public string stateText { get; private set; }
  254. public int activeMaidListCount
  255. {
  256. get
  257. {
  258. return this.activeMaidList.Count;
  259. }
  260. }
  261. public new PhotoWindowManager mgr
  262. {
  263. get
  264. {
  265. return base.mgr as PhotoWindowManager;
  266. }
  267. }
  268. [SerializeField]
  269. public WFCheckBox checkboxTransReset;
  270. [SerializeField]
  271. public WindowPartsPopUpList popupMaidList;
  272. [SerializeField]
  273. public AttachPointSubWindow.AttachPointCheckBoxs[] checkBoxs;
  274. [NonSerialized]
  275. public Action<string> onStateTextChangeEvent;
  276. [NonSerialized]
  277. public HashSet<Maid> activeMaidList = new HashSet<Maid>();
  278. private PhotoTransTargetObject selectItem;
  279. private List<Maid> maidList;
  280. [Serializable]
  281. public struct AttachPointCheckBoxs
  282. {
  283. [SerializeField]
  284. public PhotoTransTargetObject.AttachPoint attachType;
  285. [SerializeField]
  286. public WFCheckBox checkBox;
  287. }
  288. }