WindowPartsBoneCheckBox.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. this.mgr.select_maid.body0.MuneYureL((float)((!this.mgr.select_maid.body0.jbMuneL.enabled) ? 0 : 1));
  65. maidStoreData["use_mune_key_l"] = check_box.check.ToString();
  66. }
  67. else
  68. {
  69. this.mgr.select_maid.body0.jbMuneR.enabled = !check_box.check;
  70. this.mgr.select_maid.body0.MuneYureR((float)((!this.mgr.select_maid.body0.jbMuneR.enabled) ? 0 : 1));
  71. maidStoreData["use_mune_key_r"] = check_box.check.ToString();
  72. }
  73. this.OnMotionUpdate();
  74. }
  75. public void OnMaidAddEvent(Maid maid, bool is_deserialize_load)
  76. {
  77. if (this.pose_edit_window_ == null)
  78. {
  79. this.pose_edit_window_ = (this.mgr.GetWindow(PhotoWindowManager.WindowType.PoseEdit) as PoseEditWindow);
  80. }
  81. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(maid);
  82. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  83. {
  84. string key = "rotate_visible_" + keyValuePair.Key.ToString();
  85. if (!maidStoreData.ContainsKey(key))
  86. {
  87. maidStoreData[key] = false.ToString();
  88. }
  89. }
  90. }
  91. public void ChangeEnabeled(bool use)
  92. {
  93. if (!use || this.mgr.select_maid == null)
  94. {
  95. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  96. {
  97. keyValuePair.Value.check = false;
  98. }
  99. return;
  100. }
  101. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  102. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair2 in this.data_dic_)
  103. {
  104. keyValuePair2.Value.enabled = true;
  105. keyValuePair2.Value.check = bool.Parse(maidStoreData["rotate_visible_" + keyValuePair2.Key.ToString()]);
  106. }
  107. if (this.CheckBoxMuneLPhysics != null || this.CheckBoxMuneRPhysics != null)
  108. {
  109. maidStoreData["use_mune_key_l"] = (this.mgr.select_maid.body0.GetMuneYureL() == 0f).ToString();
  110. maidStoreData["use_mune_key_r"] = (this.mgr.select_maid.body0.GetMuneYureR() == 0f).ToString();
  111. this.OnMotionUpdate();
  112. }
  113. else
  114. {
  115. this.Apply();
  116. }
  117. }
  118. public void OnMotionUpdate()
  119. {
  120. if (this.pose_edit_window_ == null)
  121. {
  122. return;
  123. }
  124. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  125. if (this.data_dic_.ContainsKey(IKManager.BoneType.Bust_L))
  126. {
  127. if (!bool.Parse(maidStoreData["use_mune_key_l"]))
  128. {
  129. WFCheckBox wfcheckBox = this.data_dic_[IKManager.BoneType.Bust_L];
  130. bool flag = false;
  131. this.data_dic_[IKManager.BoneType.Bust_L].check = flag;
  132. wfcheckBox.enabled = flag;
  133. maidStoreData["rotate_visible_" + IKManager.BoneType.Bust_L.ToString()] = false.ToString();
  134. }
  135. else
  136. {
  137. this.data_dic_[IKManager.BoneType.Bust_L].enabled = true;
  138. }
  139. }
  140. if (this.data_dic_.ContainsKey(IKManager.BoneType.Bust_R))
  141. {
  142. if (!bool.Parse(maidStoreData["use_mune_key_r"]))
  143. {
  144. WFCheckBox wfcheckBox2 = this.data_dic_[IKManager.BoneType.Bust_R];
  145. bool flag2 = false;
  146. this.data_dic_[IKManager.BoneType.Bust_R].check = flag2;
  147. wfcheckBox2.enabled = flag2;
  148. maidStoreData["rotate_visible_" + IKManager.BoneType.Bust_R.ToString()] = false.ToString();
  149. }
  150. else
  151. {
  152. this.data_dic_[IKManager.BoneType.Bust_R].enabled = true;
  153. }
  154. }
  155. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  156. {
  157. keyValuePair.Value.check = bool.Parse(maidStoreData["rotate_visible_" + keyValuePair.Key.ToString()]);
  158. }
  159. if (this.CheckBoxMuneLPhysics != null || this.CheckBoxMuneRPhysics != null)
  160. {
  161. this.CheckBoxMuneLPhysics.check = bool.Parse(maidStoreData["use_mune_key_l"]);
  162. this.CheckBoxMuneRPhysics.check = bool.Parse(maidStoreData["use_mune_key_r"]);
  163. }
  164. this.Apply();
  165. }
  166. public void OnClickCheck(IKManager.BoneType bone_type)
  167. {
  168. WFCheckBox wfcheckBox = this.GetData(bone_type);
  169. if (this.mgr.select_maid == null || this.pose_edit_window_ == null)
  170. {
  171. return;
  172. }
  173. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  174. maidStoreData["rotate_visible_" + bone_type.ToString()] = wfcheckBox.check.ToString();
  175. this.pose_edit_window_.ik_mgr.SetRotateVisibleBone(bone_type, wfcheckBox.check);
  176. if (this.BoneSetType == IKManager.BoneSetType.Body || !wfcheckBox.check)
  177. {
  178. return;
  179. }
  180. WindowPartsFingerBlend windowPartsFingerBlend = this.pose_edit_window_.GetWindowPartsFingerBlend(this.BoneSetType);
  181. if (windowPartsFingerBlend != null && windowPartsFingerBlend.CheckBoxEnabled.check)
  182. {
  183. windowPartsFingerBlend.OnClickEnter();
  184. }
  185. }
  186. public void Apply()
  187. {
  188. if (this.mgr.select_maid == null)
  189. {
  190. return;
  191. }
  192. Dictionary<string, string> maidStoreData = this.pose_edit_window_.GetMaidStoreData(this.mgr.select_maid);
  193. if (!bool.Parse(maidStoreData["use"]))
  194. {
  195. return;
  196. }
  197. if (this.BoneSetType == IKManager.BoneSetType.Body)
  198. {
  199. this.mgr.select_maid.body0.jbMuneL.enabled = !bool.Parse(maidStoreData["use_mune_key_l"]);
  200. this.mgr.select_maid.body0.jbMuneR.enabled = !bool.Parse(maidStoreData["use_mune_key_r"]);
  201. }
  202. if (this.pose_edit_window_.ik_mgr != null)
  203. {
  204. foreach (KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair in this.data_dic_)
  205. {
  206. bool visible = bool.Parse(maidStoreData["rotate_visible_" + keyValuePair.Key.ToString()]);
  207. this.pose_edit_window_.ik_mgr.SetRotateVisibleBone(keyValuePair.Key, visible);
  208. }
  209. }
  210. }
  211. public new bool enabled
  212. {
  213. get
  214. {
  215. using (Dictionary<IKManager.BoneType, WFCheckBox>.Enumerator enumerator = this.data_dic_.GetEnumerator())
  216. {
  217. if (enumerator.MoveNext())
  218. {
  219. KeyValuePair<IKManager.BoneType, WFCheckBox> keyValuePair = enumerator.Current;
  220. return keyValuePair.Value.enabled;
  221. }
  222. }
  223. return false;
  224. }
  225. }
  226. public WFCheckBox GetData(IKManager.BoneType bone_type)
  227. {
  228. WFCheckBox result;
  229. this.data_dic_.TryGetValue(bone_type, out result);
  230. return result;
  231. }
  232. [HideInInspector]
  233. public PhotoWindowManager mgr;
  234. public WFCheckBox CheckBoxMuneLPhysics;
  235. public WFCheckBox CheckBoxMuneRPhysics;
  236. public UIButton BtnAllOFF;
  237. public IKManager.BoneSetType BoneSetType;
  238. public WindowPartsBoneCheckBox.Data[] data;
  239. private Dictionary<IKManager.BoneType, WFCheckBox> data_dic_ = new Dictionary<IKManager.BoneType, WFCheckBox>();
  240. private PoseEditWindow pose_edit_window_;
  241. [Serializable]
  242. public class Data
  243. {
  244. public IKManager.BoneType BoneType;
  245. public WFCheckBox CheckBox;
  246. }
  247. }