WindowPartsBoneCheckBox.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WindowPartsBoneCheckBox : MonoBehaviour
  5. {
  6. public void Awake()
  7. {
  8. foreach (WindowPartsBoneCheckBox.Data data in this.data)
  9. {
  10. this.data_dic_.Add(data.BoneType, data.CheckBox);
  11. data.CheckBox.name = data.BoneType.ToString();
  12. data.CheckBox.onClick.Add(delegate(WFCheckBox check_box)
  13. {
  14. this.OnClickCheck((IKManager.BoneType)Enum.Parse(typeof(IKManager.BoneType), check_box.name));
  15. });
  16. }
  17. if (this.CheckBoxMuneLPhysics != null)
  18. {
  19. this.CheckBoxMuneLPhysics.onClick.Add(new Action<WFCheckBox>(this.OnClickCheckBoxMunePhysics));
  20. }
  21. if (this.CheckBoxMuneRPhysics != null)
  22. {
  23. this.CheckBoxMuneRPhysics.onClick.Add(new Action<WFCheckBox>(this.OnClickCheckBoxMunePhysics));
  24. }
  25. if (this.BtnAllOFF != null)
  26. {
  27. EventDelegate.Add(this.BtnAllOFF.onClick, new EventDelegate.Callback(this.AllCheckBoxOFF));
  28. }
  29. }
  30. public void AllCheckBoxOFF()
  31. {
  32. if (!this.enabled || this.pose_edit_window_ == null)
  33. {
  34. return;
  35. }
  36. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  37. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  38. {
  39. maidStoreData["rotate_visible_" + keyValuePair.Key.ToString()] = false.ToString();
  40. keyValuePair.Value.check = false;
  41. foreach (Action<WFCheckBox> action in keyValuePair.Value.onClick)
  42. {
  43. action(keyValuePair.Value);
  44. }
  45. }
  46. }
  47. public void AllCheckBoxEnabled(bool enabled)
  48. {
  49. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  50. {
  51. keyValuePair.Value.enabled = enabled;
  52. }
  53. }
  54. public void OnClickCheckBoxMunePhysics(WFCheckBox check_box)
  55. {
  56. if (!this.enabled || this.pose_edit_window_ == null)
  57. {
  58. return;
  59. }
  60. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  61. if (check_box == this.CheckBoxMuneLPhysics)
  62. {
  63. this.mgr.select_maid.body0.jbMuneL.enabled = !check_box.check;
  64. maidStoreData["use_mune_key_l"] = check_box.check.ToString();
  65. }
  66. else
  67. {
  68. this.mgr.select_maid.body0.jbMuneR.enabled = !check_box.check;
  69. maidStoreData["use_mune_key_r"] = check_box.check.ToString();
  70. }
  71. this.OnMotionUpdate();
  72. }
  73. public void OnMaidAddEvent(Maid maid, bool is_deserialize_load)
  74. {
  75. if (this.pose_edit_window_ == null)
  76. {
  77. this.pose_edit_window_ = (this.mgr.GetWindow(PhotoWindowManager.WindowType.PoseEdit) as PoseEditWindow);
  78. }
  79. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(maid);
  80. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  81. {
  82. string key = "rotate_visible_" + keyValuePair.Key.ToString();
  83. if (!maidStoreData.ContainsKey(key))
  84. {
  85. maidStoreData[key] = false.ToString();
  86. }
  87. }
  88. }
  89. public void ChangeEnabeled(bool use)
  90. {
  91. if (!use || this.mgr.select_maid == null)
  92. {
  93. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  94. {
  95. keyValuePair.Value.check = false;
  96. }
  97. return;
  98. }
  99. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  100. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair2 in this.data_dic_)
  101. {
  102. keyValuePair2.Value.enabled = true;
  103. keyValuePair2.Value.check = bool.Parse(maidStoreData["rotate_visible_" + keyValuePair2.Key.ToString()]);
  104. }
  105. if (this.CheckBoxMuneLPhysics != null || this.CheckBoxMuneRPhysics != null)
  106. {
  107. maidStoreData["use_mune_key_l"] = (this.mgr.select_maid.body0.GetMuneYureL() == 0f).ToString();
  108. maidStoreData["use_mune_key_r"] = (this.mgr.select_maid.body0.GetMuneYureR() == 0f).ToString();
  109. this.OnMotionUpdate();
  110. }
  111. else
  112. {
  113. this.Apply();
  114. }
  115. }
  116. public void OnMotionUpdate()
  117. {
  118. if (this.pose_edit_window_ == null)
  119. {
  120. return;
  121. }
  122. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  123. if (this.data_dic_.ContainsKey(IKManager.BoneType.Bust_L))
  124. {
  125. if (!bool.Parse(maidStoreData["use_mune_key_l"]))
  126. {
  127. WFCheckBox wfcheckBox = this.data_dic_[IKManager.BoneType.Bust_L];
  128. bool flag = false;
  129. this.data_dic_[IKManager.BoneType.Bust_L].check = flag;
  130. wfcheckBox.enabled = flag;
  131. maidStoreData["rotate_visible_" + IKManager.BoneType.Bust_L.ToString()] = false.ToString();
  132. }
  133. else
  134. {
  135. this.data_dic_[IKManager.BoneType.Bust_L].enabled = true;
  136. }
  137. }
  138. if (this.data_dic_.ContainsKey(IKManager.BoneType.Bust_R))
  139. {
  140. if (!bool.Parse(maidStoreData["use_mune_key_r"]))
  141. {
  142. WFCheckBox wfcheckBox2 = this.data_dic_[IKManager.BoneType.Bust_R];
  143. bool flag2 = false;
  144. this.data_dic_[IKManager.BoneType.Bust_R].check = flag2;
  145. wfcheckBox2.enabled = flag2;
  146. maidStoreData["rotate_visible_" + IKManager.BoneType.Bust_R.ToString()] = false.ToString();
  147. }
  148. else
  149. {
  150. this.data_dic_[IKManager.BoneType.Bust_R].enabled = true;
  151. }
  152. }
  153. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  154. {
  155. keyValuePair.Value.check = bool.Parse(maidStoreData["rotate_visible_" + keyValuePair.Key.ToString()]);
  156. }
  157. if (this.CheckBoxMuneLPhysics != null || this.CheckBoxMuneRPhysics != null)
  158. {
  159. this.CheckBoxMuneLPhysics.check = bool.Parse(maidStoreData["use_mune_key_l"]);
  160. this.CheckBoxMuneRPhysics.check = bool.Parse(maidStoreData["use_mune_key_r"]);
  161. }
  162. this.Apply();
  163. }
  164. public void OnClickCheck(IKManager.BoneType bone_type)
  165. {
  166. WFCheckBox wfcheckBox = this.GetData(bone_type);
  167. if (this.mgr.select_maid == null || this.pose_edit_window_ == null)
  168. {
  169. return;
  170. }
  171. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  172. maidStoreData["rotate_visible_" + bone_type.ToString()] = wfcheckBox.check.ToString();
  173. this.pose_edit_window_.ik_mgr.SetRotateVisibleBone(bone_type, wfcheckBox.check);
  174. if (this.BoneSetType == IKManager.BoneSetType.Body || !wfcheckBox.check)
  175. {
  176. return;
  177. }
  178. WindowPartsFingerBlend windowPartsFingerBlend = this.pose_edit_window_.GetWindowPartsFingerBlend(this.BoneSetType);
  179. if (windowPartsFingerBlend != null && windowPartsFingerBlend.CheckBoxEnabled.check)
  180. {
  181. windowPartsFingerBlend.OnClickEnter();
  182. }
  183. }
  184. public void Apply()
  185. {
  186. if (this.mgr.select_maid == null)
  187. {
  188. return;
  189. }
  190. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  191. if (!bool.Parse(maidStoreData["use"]))
  192. {
  193. return;
  194. }
  195. if (this.BoneSetType == IKManager.BoneSetType.Body)
  196. {
  197. this.mgr.select_maid.body0.jbMuneL.enabled = !bool.Parse(maidStoreData["use_mune_key_l"]);
  198. this.mgr.select_maid.body0.jbMuneR.enabled = !bool.Parse(maidStoreData["use_mune_key_r"]);
  199. }
  200. if (this.pose_edit_window_.ik_mgr != null)
  201. {
  202. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  203. {
  204. bool visible = bool.Parse(maidStoreData["rotate_visible_" + keyValuePair.Key.ToString()]);
  205. this.pose_edit_window_.ik_mgr.SetRotateVisibleBone(keyValuePair.Key, visible);
  206. }
  207. }
  208. }
  209. public new bool enabled
  210. {
  211. get
  212. {
  213. using (Dictionary<IKManager.BoneType, WFCheckBox>.Enumerator enumerator = this.data_dic_.GetEnumerator())
  214. {
  215. if (enumerator.MoveNext())
  216. {
  217. KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair = enumerator.Current;
  218. return keyValuePair.Value.enabled;
  219. }
  220. }
  221. return false;
  222. }
  223. }
  224. public WFCheckBox GetData(IKManager.BoneType bone_type)
  225. {
  226. WFCheckBox result;
  227. this.data_dic_.TryGetValue(bone_type, out result);
  228. return result;
  229. }
  230. [HideInInspector]
  231. public PhotoWindowManager mgr;
  232. public WFCheckBox CheckBoxMuneLPhysics;
  233. public WFCheckBox CheckBoxMuneRPhysics;
  234. public UIButton BtnAllOFF;
  235. public IKManager.BoneSetType BoneSetType;
  236. public WindowPartsBoneCheckBox.Data[] data;
  237. private Dictionary<IKManager.BoneType, WFCheckBox> data_dic_ = new Dictionary<IKManager.BoneType, WFCheckBox>();
  238. private PoseEditWindow pose_edit_window_;
  239. [Serializable]
  240. public class Data
  241. {
  242. public IKManager.BoneType BoneType;
  243. public WFCheckBox CheckBox;
  244. }
  245. }