PoseEditWindow.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class PoseEditWindow : BaseMaidPhotoWindow
  6. {
  7. public static IKManager GetMaidIKManager(Maid maid)
  8. {
  9. GameObject gameObject = GameObject.Find("PoseEditWorkParent");
  10. if (gameObject == null)
  11. {
  12. gameObject = new GameObject("PoseEditWorkParent");
  13. }
  14. if (maid == null || maid.boMAN)
  15. {
  16. return null;
  17. }
  18. GameObject gameObject2 = GameObject.Find("PoseEditWorkParent/" + maid.status.guid);
  19. if (gameObject2 != null && gameObject2.GetComponent<IKManager>() != null)
  20. {
  21. return gameObject2.GetComponent<IKManager>();
  22. }
  23. if (gameObject2 == null)
  24. {
  25. gameObject2 = new GameObject(maid.status.guid);
  26. gameObject2.transform.SetParent(gameObject.transform, false);
  27. }
  28. IKManager ikmanager = gameObject2.AddComponent<IKManager>();
  29. ikmanager.SetMaid(maid);
  30. IEnumerator enumerator = Enum.GetValues(typeof(IKManager.BoneSetType)).GetEnumerator();
  31. try
  32. {
  33. while (enumerator.MoveNext())
  34. {
  35. object obj = enumerator.Current;
  36. IKManager.BoneSetType bone_set_type = (IKManager.BoneSetType)obj;
  37. ikmanager.SetRotateVisibleBoneSet(bone_set_type, false);
  38. ikmanager.SetTransAxisVisibleBoneSet(bone_set_type, false);
  39. }
  40. }
  41. finally
  42. {
  43. IDisposable disposable;
  44. if ((disposable = (enumerator as IDisposable)) != null)
  45. {
  46. disposable.Dispose();
  47. }
  48. }
  49. ikmanager.SetTransAxisVisibleRoot(false);
  50. return ikmanager;
  51. }
  52. public override void Awake()
  53. {
  54. base.Awake();
  55. this.noCharaActive = base.GetComponentInChildren<PhotoNoCharaActive>();
  56. EventDelegate.Add(this.BtnSave.onClick, new EventDelegate.Callback(this.OnBtnSave));
  57. if (this.BtnReversal != null)
  58. {
  59. EventDelegate.Add(this.BtnReversal.onClick, new EventDelegate.Callback(this.OnBtnReversal));
  60. }
  61. this.ControlSelectBtnTab.UpdateChildren();
  62. foreach (UIWFTabButton uiwftabButton in this.ControlSelectBtnTab.button_list)
  63. {
  64. EventDelegate.Add(uiwftabButton.onSelect, new EventDelegate.Callback(this.OnSelectControlSelectBtn));
  65. }
  66. for (int i = 0; i < this.FingerBlendArray.Length; i++)
  67. {
  68. this.FingerBlendArray[i].mgr = base.mgr;
  69. this.FingerBlendArray[i].OnClickFingerBlendEnabledEvent = delegate(WindowPartsFingerBlend.Type blend_type, bool blend_enabled)
  70. {
  71. IKManager.BoneSetType boneSetType = IKManager.BoneSetType.Body;
  72. WFCheckBox wfcheckBox = null;
  73. if (blend_type == WindowPartsFingerBlend.Type.RightArm)
  74. {
  75. wfcheckBox = this.ikbox_visible_dic_["ik_box_visible_RightArmFinger"];
  76. boneSetType = IKManager.BoneSetType.RightArmFinger;
  77. }
  78. else if (blend_type == WindowPartsFingerBlend.Type.LeftArm)
  79. {
  80. wfcheckBox = this.ikbox_visible_dic_["ik_box_visible_LeftArmFinger"];
  81. boneSetType = IKManager.BoneSetType.LeftArmFinger;
  82. }
  83. else if (blend_type == WindowPartsFingerBlend.Type.RightLeg)
  84. {
  85. wfcheckBox = this.ikbox_visible_dic_["ik_box_visible_RightLegFinger"];
  86. boneSetType = IKManager.BoneSetType.RightLegFinger;
  87. }
  88. else if (blend_type == WindowPartsFingerBlend.Type.LeftLeg)
  89. {
  90. wfcheckBox = this.ikbox_visible_dic_["ik_box_visible_LeftLegFinger"];
  91. boneSetType = IKManager.BoneSetType.LeftLegFinger;
  92. }
  93. if (!blend_enabled)
  94. {
  95. wfcheckBox.enabled = true;
  96. for (int l = 0; l < this.RotateCheckBoxArray.Length; l++)
  97. {
  98. if (this.RotateCheckBoxArray[l].BoneSetType == boneSetType)
  99. {
  100. this.RotateCheckBoxArray[l].AllCheckBoxEnabled(true);
  101. }
  102. }
  103. return;
  104. }
  105. WFCheckBox wfcheckBox2 = wfcheckBox;
  106. bool flag = false;
  107. wfcheckBox.enabled = flag;
  108. wfcheckBox2.check = flag;
  109. foreach (Action<WFCheckBox> action in wfcheckBox.onClick)
  110. {
  111. action(wfcheckBox);
  112. }
  113. for (int m = 0; m < this.RotateCheckBoxArray.Length; m++)
  114. {
  115. if (this.RotateCheckBoxArray[m].BoneSetType == boneSetType)
  116. {
  117. this.RotateCheckBoxArray[m].AllCheckBoxOFF();
  118. this.RotateCheckBoxArray[m].AllCheckBoxEnabled(false);
  119. }
  120. }
  121. };
  122. }
  123. for (int j = 0; j < this.RotateCheckBoxArray.Length; j++)
  124. {
  125. this.RotateCheckBoxArray[j].mgr = base.mgr;
  126. }
  127. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body).SetActive(true);
  128. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand).SetActive(true);
  129. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg).SetActive(true);
  130. List<KeyValuePair<PoseEditWindow.ControlType, KeyValuePair<string, string>>> list = new List<KeyValuePair<PoseEditWindow.ControlType, KeyValuePair<string, string>>>();
  131. list.Add(new KeyValuePair<PoseEditWindow.ControlType, KeyValuePair<string, string>>(PoseEditWindow.ControlType.Body, new KeyValuePair<string, string>("ik_box_visible_Root", "CheckCenterVisible")));
  132. list.Add(new KeyValuePair<PoseEditWindow.ControlType, KeyValuePair<string, string>>(PoseEditWindow.ControlType.Body, new KeyValuePair<string, string>("ik_box_visible_Body", "CheckLimbVisible")));
  133. list.Add(new KeyValuePair<PoseEditWindow.ControlType, KeyValuePair<string, string>>(PoseEditWindow.ControlType.Hand, new KeyValuePair<string, string>("ik_box_visible_RightArmFinger", "RightSet/Parent/CheckIKVisible")));
  134. list.Add(new KeyValuePair<PoseEditWindow.ControlType, KeyValuePair<string, string>>(PoseEditWindow.ControlType.Hand, new KeyValuePair<string, string>("ik_box_visible_LeftArmFinger", "LeftSet/Parent/CheckIKVisible")));
  135. list.Add(new KeyValuePair<PoseEditWindow.ControlType, KeyValuePair<string, string>>(PoseEditWindow.ControlType.Leg, new KeyValuePair<string, string>("ik_box_visible_RightLegFinger", "RightSet/Parent/CheckIKVisible")));
  136. list.Add(new KeyValuePair<PoseEditWindow.ControlType, KeyValuePair<string, string>>(PoseEditWindow.ControlType.Leg, new KeyValuePair<string, string>("ik_box_visible_LeftLegFinger", "LeftSet/Parent/CheckIKVisible")));
  137. for (int k = 0; k < list.Count; k++)
  138. {
  139. WFCheckBox component = UTY.GetChildObject(this.GetControlPanelParentObject(list[k].Key), list[k].Value.Value, false).GetComponent<WFCheckBox>();
  140. component.name = list[k].Value.Key;
  141. component.onClick.Add(new Action<WFCheckBox>(this.OnIKBOXVixibleCheckBox));
  142. this.ikbox_visible_dic_.Add(component.name, component);
  143. }
  144. }
  145. public override void Start()
  146. {
  147. base.Start();
  148. this.UpdateChildren();
  149. this.CheckbtnUse.onClick.Add(new Action<WFCheckBox>(this.OnClickUseCheck));
  150. this.noCharaActive.ChangeMode(true, true);
  151. }
  152. public new void Update()
  153. {
  154. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN || !this.CheckbtnUse.check)
  155. {
  156. return;
  157. }
  158. bool flag = false;
  159. bool flag2 = false;
  160. if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Z))
  161. {
  162. flag = true;
  163. }
  164. if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Y))
  165. {
  166. flag2 = true;
  167. }
  168. if (flag || flag2)
  169. {
  170. bool flag3 = true;
  171. string draw_text = string.Empty;
  172. for (int i = 0; i < this.FingerBlendArray.Length; i++)
  173. {
  174. if (this.FingerBlendArray[i].CheckBoxEnabled.enabled && this.FingerBlendArray[i].CheckBoxEnabled.check)
  175. {
  176. if (flag)
  177. {
  178. draw_text = "指先ブレンド中はUndoできません";
  179. }
  180. else
  181. {
  182. draw_text = "指先ブレンド中はRedoできません";
  183. }
  184. flag3 = false;
  185. break;
  186. }
  187. }
  188. if (GizmoRender.control_lock || IKDragPoint.IsDrag)
  189. {
  190. if (flag)
  191. {
  192. draw_text = "操作中はUndoできません";
  193. }
  194. else
  195. {
  196. draw_text = "操作中はRedoできません";
  197. }
  198. flag3 = false;
  199. }
  200. MouseExposition @object = MouseExposition.GetObject();
  201. if (flag3)
  202. {
  203. bool flag4 = (!flag) ? this.ik_mgr.HistoryRedo() : this.ik_mgr.HistoryUndo();
  204. if (flag4)
  205. {
  206. @object.SetText((!flag) ? "Redo" : "Undo", 0.5f);
  207. }
  208. }
  209. else
  210. {
  211. @object.SetText(draw_text, 3f);
  212. }
  213. }
  214. }
  215. public override void OnMaidAddEvent(Maid maid, bool is_deserialize_load)
  216. {
  217. base.OnMaidAddEvent(maid, is_deserialize_load);
  218. if (maid.boMAN)
  219. {
  220. return;
  221. }
  222. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(maid);
  223. if (!maidStoreData.ContainsKey("use"))
  224. {
  225. maidStoreData["use"] = false.ToString();
  226. }
  227. if (!maidStoreData.ContainsKey("select_control_type"))
  228. {
  229. maidStoreData["select_control_type"] = PoseEditWindow.ControlType.Body.ToString();
  230. }
  231. if (!maidStoreData.ContainsKey("pose_binary"))
  232. {
  233. maidStoreData["pose_binary"] = string.Empty;
  234. }
  235. if (!maidStoreData.ContainsKey("use_mune_key_l"))
  236. {
  237. Dictionary<string, string> dictionary = maidStoreData;
  238. string key = "use_mune_key_l";
  239. string value = false.ToString();
  240. maidStoreData["use_mune_key_r"] = value;
  241. dictionary[key] = value;
  242. }
  243. foreach (KeyValuePair<string, WFCheckBox> keyValuePair in this.ikbox_visible_dic_)
  244. {
  245. if (!maidStoreData.ContainsKey(keyValuePair.Value.name))
  246. {
  247. maidStoreData[keyValuePair.Value.name] = false.ToString();
  248. }
  249. }
  250. maidStoreData["ik_box_visible_Body"] = true.ToString();
  251. for (int i = 0; i < this.FingerBlendArray.Length; i++)
  252. {
  253. this.FingerBlendArray[i].OnMaidAddEvent(maid, is_deserialize_load);
  254. }
  255. for (int j = 0; j < this.RotateCheckBoxArray.Length; j++)
  256. {
  257. this.RotateCheckBoxArray[j].OnMaidAddEvent(maid, is_deserialize_load);
  258. }
  259. if (is_deserialize_load && !string.IsNullOrEmpty(maidStoreData["pose_binary"]))
  260. {
  261. IKManager maidIKManager = PoseEditWindow.GetMaidIKManager(maid);
  262. KeyValuePair<bool, bool> keyValuePair2 = maidIKManager.cache_bone_data.SetFrameBinary(Convert.FromBase64String(maidStoreData["pose_binary"]));
  263. maid.body0.jbMuneL.enabled = !keyValuePair2.Key;
  264. maid.body0.jbMuneR.enabled = !keyValuePair2.Value;
  265. }
  266. }
  267. public void OnMotionUpdate(Maid maid)
  268. {
  269. if (base.mgr.select_maid == null || base.mgr.select_maid != maid || maid.boMAN)
  270. {
  271. return;
  272. }
  273. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(maid);
  274. if (!bool.Parse(maidStoreData["use"]))
  275. {
  276. return;
  277. }
  278. maidStoreData["use_mune_key_l"] = (maid.body0.GetMuneYureL() == 0f).ToString();
  279. maidStoreData["use_mune_key_r"] = (maid.body0.GetMuneYureR() == 0f).ToString();
  280. maid.body0.jbMuneL.enabled = (maid.body0.GetMuneYureL() != 0f);
  281. maid.body0.jbMuneR.enabled = (maid.body0.GetMuneYureR() != 0f);
  282. for (int i = 0; i < this.RotateCheckBoxArray.Length; i++)
  283. {
  284. this.RotateCheckBoxArray[i].OnMotionUpdate();
  285. }
  286. if (this.ik_mgr_ != null)
  287. {
  288. IKManager.BoneSetType[] array = new IKManager.BoneSetType[0];
  289. if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Body)
  290. {
  291. array = new IKManager.BoneSetType[]
  292. {
  293. IKManager.BoneSetType.RightArmFinger,
  294. IKManager.BoneSetType.LeftArmFinger,
  295. IKManager.BoneSetType.RightLegFinger,
  296. IKManager.BoneSetType.LeftLegFinger
  297. };
  298. }
  299. else if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Hand)
  300. {
  301. array = new IKManager.BoneSetType[]
  302. {
  303. IKManager.BoneSetType.Body,
  304. IKManager.BoneSetType.RightLegFinger,
  305. IKManager.BoneSetType.LeftLegFinger
  306. };
  307. }
  308. else if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Leg)
  309. {
  310. array = new IKManager.BoneSetType[]
  311. {
  312. IKManager.BoneSetType.Body,
  313. IKManager.BoneSetType.RightArmFinger,
  314. IKManager.BoneSetType.LeftArmFinger
  315. };
  316. }
  317. foreach (IKManager.BoneSetType bone_set_type in array)
  318. {
  319. this.ik_mgr_.SetRotateVisibleBoneSet(bone_set_type, false);
  320. }
  321. }
  322. for (int k = 0; k < this.FingerBlendArray.Length; k++)
  323. {
  324. this.FingerBlendArray[k].OnMotionUpdate();
  325. }
  326. if (this.ik_mgr_ != null)
  327. {
  328. this.ik_mgr.HistoryClear();
  329. this.ik_mgr.HistoryNew();
  330. }
  331. }
  332. public void OnSelectControlSelectBtn()
  333. {
  334. if (this.ControlSelectBtnTab.GetSelectButtonObject() == null || base.mgr.select_maid == null || base.mgr.select_maid.boMAN || !UIWFSelectButton.current.isSelected)
  335. {
  336. return;
  337. }
  338. UILabel componentInChildren = this.ControlSelectBtnTab.GetSelectButtonObject().GetComponentInChildren<UILabel>();
  339. if (componentInChildren == null)
  340. {
  341. return;
  342. }
  343. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  344. string key = "select_control_type";
  345. if (componentInChildren.text == "胴体")
  346. {
  347. this.ctrl_type_ = PoseEditWindow.ControlType.Body;
  348. }
  349. else if (componentInChildren.text == "手")
  350. {
  351. this.ctrl_type_ = PoseEditWindow.ControlType.Hand;
  352. }
  353. else
  354. {
  355. this.ctrl_type_ = PoseEditWindow.ControlType.Leg;
  356. }
  357. maidStoreData[key] = this.ctrl_type_.ToString();
  358. this.SetControlPanel(this.ctrl_type_);
  359. IKManager.BoneSetType[] array = new IKManager.BoneSetType[0];
  360. bool flag = false;
  361. if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Body)
  362. {
  363. array = new IKManager.BoneSetType[]
  364. {
  365. IKManager.BoneSetType.RightArmFinger,
  366. IKManager.BoneSetType.LeftArmFinger,
  367. IKManager.BoneSetType.RightLegFinger,
  368. IKManager.BoneSetType.LeftLegFinger
  369. };
  370. flag = true;
  371. }
  372. else if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Hand)
  373. {
  374. array = new IKManager.BoneSetType[]
  375. {
  376. IKManager.BoneSetType.Body,
  377. IKManager.BoneSetType.RightLegFinger,
  378. IKManager.BoneSetType.LeftLegFinger
  379. };
  380. }
  381. else if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Leg)
  382. {
  383. array = new IKManager.BoneSetType[]
  384. {
  385. IKManager.BoneSetType.Body,
  386. IKManager.BoneSetType.RightArmFinger,
  387. IKManager.BoneSetType.LeftArmFinger
  388. };
  389. }
  390. foreach (KeyValuePair<string, WFCheckBox> keyValuePair in this.ikbox_visible_dic_)
  391. {
  392. keyValuePair.Value.check = bool.Parse(maidStoreData[keyValuePair.Value.name]);
  393. keyValuePair.Value.onClick[0](keyValuePair.Value);
  394. }
  395. foreach (IKManager.BoneSetType bone_set_type in array)
  396. {
  397. this.ik_mgr_.SetRotateVisibleBoneSet(bone_set_type, false);
  398. this.ik_mgr_.SetTransAxisVisibleBoneSet(bone_set_type, false);
  399. }
  400. if (!flag)
  401. {
  402. this.ik_mgr_.SetTransAxisVisibleRoot(false);
  403. }
  404. List<IKManager.BoneSetType> list = new List<IKManager.BoneSetType>(array);
  405. for (int j = 0; j < this.RotateCheckBoxArray.Length; j++)
  406. {
  407. if (0 > list.IndexOf(this.RotateCheckBoxArray[j].BoneSetType))
  408. {
  409. this.RotateCheckBoxArray[j].Apply();
  410. }
  411. }
  412. }
  413. public void OnClickUseCheck(WFCheckBox check_box)
  414. {
  415. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN)
  416. {
  417. return;
  418. }
  419. if (!check_box.check && GameMain.Instance.SysDlg.IsDecided)
  420. {
  421. GameMain.Instance.SysDlg.Show("セーブしていないデータは失われます。\nOFFにしますか?", SystemDialog.TYPE.YES_NO, delegate
  422. {
  423. check_box.check = false;
  424. this.OnClickUseCheckRun(false);
  425. GameMain.Instance.SysDlg.Close();
  426. }, null);
  427. check_box.check = true;
  428. return;
  429. }
  430. this.OnClickUseCheckRun(true);
  431. }
  432. public void OnClickUseCheckRun(bool check)
  433. {
  434. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  435. maidStoreData["use"] = check.ToString();
  436. if (!check)
  437. {
  438. maidStoreData["pose_binary"] = string.Empty;
  439. }
  440. this.ChangeEnabeled(check);
  441. this.ik_mgr.HistoryClear();
  442. this.ik_mgr.HistoryNew();
  443. MaidColliderCollect component = base.mgr.select_maid.GetComponent<MaidColliderCollect>();
  444. List<CapsuleCollider> collider = component.GetCollider(MaidColliderCollect.ColliderType.Grab);
  445. foreach (CapsuleCollider capsuleCollider in collider)
  446. {
  447. capsuleCollider.gameObject.SetActive(!check);
  448. }
  449. }
  450. public void OnIKBOXVixibleCheckBox(WFCheckBox check_box)
  451. {
  452. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN || this.ik_mgr_ == null)
  453. {
  454. return;
  455. }
  456. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  457. maidStoreData[check_box.name] = check_box.check.ToString();
  458. string text = check_box.name.Replace("ik_box_visible_", string.Empty);
  459. if (text == "Root")
  460. {
  461. this.ik_mgr_.SetTransAxisVisibleRoot(check_box.check);
  462. }
  463. else
  464. {
  465. IKManager.BoneSetType boneSetType = (IKManager.BoneSetType)Enum.Parse(typeof(IKManager.BoneSetType), text);
  466. this.ik_mgr_.SetTransAxisVisibleBoneSet(boneSetType, check_box.check);
  467. if (check_box.check && boneSetType != IKManager.BoneSetType.Body)
  468. {
  469. WindowPartsFingerBlend windowPartsFingerBlend = this.GetWindowPartsFingerBlend(boneSetType);
  470. if (windowPartsFingerBlend != null && windowPartsFingerBlend.CheckBoxEnabled.check)
  471. {
  472. windowPartsFingerBlend.OnClickEnter();
  473. }
  474. }
  475. }
  476. }
  477. public void ChangeEnabeled(bool use)
  478. {
  479. if (use && (base.mgr.select_maid == null || base.mgr.select_maid.boMAN))
  480. {
  481. use = false;
  482. }
  483. if (use)
  484. {
  485. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  486. this.BtnSave.isEnabled = true;
  487. MotionWindow motionWindow = base.mgr.GetWindow(PhotoWindowManager.WindowType.Motion) as MotionWindow;
  488. if (!motionWindow.CheckbtnStop.check)
  489. {
  490. motionWindow.CheckbtnStop.check = true;
  491. motionWindow.OnClickStopCheck(motionWindow.CheckbtnStop);
  492. }
  493. base.mgr.select_maid.IKTargetToBone("左手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, 0f, false, false);
  494. base.mgr.select_maid.IKTargetToBone("右手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, 0f, false, false);
  495. this.ControlSelectBtnTab.ResetSelect();
  496. Dictionary<PoseEditWindow.ControlType, UIWFTabButton> dictionary = new Dictionary<PoseEditWindow.ControlType, UIWFTabButton>();
  497. foreach (UIWFTabButton uiwftabButton in this.ControlSelectBtnTab.button_list)
  498. {
  499. uiwftabButton.SetSelect(false);
  500. uiwftabButton.isEnabled = true;
  501. dictionary.Add((PoseEditWindow.ControlType)Enum.Parse(typeof(PoseEditWindow.ControlType), uiwftabButton.transform.parent.name), uiwftabButton);
  502. }
  503. base.mgr.select_maid.body0.jbMuneL.enabled = (base.mgr.select_maid.body0.GetMuneYureL() != 0f);
  504. base.mgr.select_maid.body0.jbMuneR.enabled = (base.mgr.select_maid.body0.GetMuneYureR() != 0f);
  505. for (int i = 0; i < this.RotateCheckBoxArray.Length; i++)
  506. {
  507. this.RotateCheckBoxArray[i].ChangeEnabeled(use);
  508. }
  509. for (int j = 0; j < this.FingerBlendArray.Length; j++)
  510. {
  511. this.FingerBlendArray[j].ChangeEnabeled(use);
  512. }
  513. this.ControlSelectBtnTab.Select(dictionary[this.ctrl_type_]);
  514. }
  515. else
  516. {
  517. this.ControlSelectBtnTab.ResetSelect();
  518. foreach (UIWFTabButton uiwftabButton2 in this.ControlSelectBtnTab.button_list)
  519. {
  520. uiwftabButton2.SetSelect(false);
  521. uiwftabButton2.isEnabled = false;
  522. }
  523. this.BtnSave.isEnabled = false;
  524. MotionWindow motionWindow2 = base.mgr.GetWindow(PhotoWindowManager.WindowType.Motion) as MotionWindow;
  525. motionWindow2.UpdateAnimationData(base.mgr.select_maid);
  526. this.SetControlPanel(PoseEditWindow.ControlType.Null);
  527. if (this.ik_mgr_ != null)
  528. {
  529. IEnumerator enumerator3 = Enum.GetValues(typeof(IKManager.BoneSetType)).GetEnumerator();
  530. try
  531. {
  532. while (enumerator3.MoveNext())
  533. {
  534. object obj = enumerator3.Current;
  535. IKManager.BoneSetType bone_set_type = (IKManager.BoneSetType)obj;
  536. this.ik_mgr_.SetRotateVisibleBoneSet(bone_set_type, false);
  537. this.ik_mgr_.SetTransAxisVisibleBoneSet(bone_set_type, false);
  538. }
  539. }
  540. finally
  541. {
  542. IDisposable disposable;
  543. if ((disposable = (enumerator3 as IDisposable)) != null)
  544. {
  545. disposable.Dispose();
  546. }
  547. }
  548. this.ik_mgr_.SetTransAxisVisibleRoot(false);
  549. }
  550. if (base.mgr.select_maid != null && base.mgr.select_maid.body0 != null && !base.mgr.select_maid.boMAN)
  551. {
  552. base.mgr.select_maid.body0.jbMuneL.enabled = (base.mgr.select_maid.body0.GetMuneYureL() != 0f);
  553. base.mgr.select_maid.body0.jbMuneR.enabled = (base.mgr.select_maid.body0.GetMuneYureR() != 0f);
  554. }
  555. if (this.ik_mgr != null)
  556. {
  557. this.ik_mgr.HistoryClear();
  558. }
  559. for (int k = 0; k < this.RotateCheckBoxArray.Length; k++)
  560. {
  561. this.RotateCheckBoxArray[k].ChangeEnabeled(use);
  562. }
  563. for (int l = 0; l < this.FingerBlendArray.Length; l++)
  564. {
  565. this.FingerBlendArray[l].ChangeEnabeled(use);
  566. }
  567. }
  568. this.Apply();
  569. }
  570. public void Apply()
  571. {
  572. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN)
  573. {
  574. return;
  575. }
  576. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  577. if (!bool.Parse(maidStoreData["use"]))
  578. {
  579. return;
  580. }
  581. for (int i = 0; i < this.FingerBlendArray.Length; i++)
  582. {
  583. this.FingerBlendArray[i].Apply();
  584. }
  585. }
  586. public void OnBtnSave()
  587. {
  588. if (this.ik_mgr_ == null || base.mgr.select_maid == null)
  589. {
  590. return;
  591. }
  592. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  593. this.PanelSave.OpenPoseSaveMode(this.ik_mgr_.cache_bone_data.GetAnmBinary(bool.Parse(maidStoreData["use_mune_key_l"]), bool.Parse(maidStoreData["use_mune_key_r"])));
  594. }
  595. public void OnBtnReversal()
  596. {
  597. this.ik_mgr.Flip();
  598. }
  599. public override void OnMaidRemoveEvent(Maid maid)
  600. {
  601. if (maid != null && maid.boMAN)
  602. {
  603. maid = null;
  604. }
  605. this.DeleteIKManager(maid);
  606. }
  607. public override void OnMaidChangeEvent(Maid maid)
  608. {
  609. base.OnMaidChangeEvent(maid);
  610. if (maid == null)
  611. {
  612. this.ik_mgr_ = null;
  613. }
  614. Dictionary<string, string> dictionary;
  615. if (this.ik_mgr_ != null)
  616. {
  617. dictionary = base.GetMaidStoreData(this.ik_mgr_.maid);
  618. byte[] frameBinary = this.ik_mgr_.cache_bone_data.GetFrameBinary(bool.Parse(dictionary["use_mune_key_l"]), bool.Parse(dictionary["use_mune_key_r"]));
  619. if (bool.Parse(dictionary["use"]))
  620. {
  621. dictionary["pose_binary"] = Convert.ToBase64String(frameBinary);
  622. }
  623. else
  624. {
  625. dictionary["pose_binary"] = string.Empty;
  626. }
  627. IEnumerator enumerator = Enum.GetValues(typeof(IKManager.BoneSetType)).GetEnumerator();
  628. try
  629. {
  630. while (enumerator.MoveNext())
  631. {
  632. object obj = enumerator.Current;
  633. IKManager.BoneSetType bone_set_type = (IKManager.BoneSetType)obj;
  634. this.ik_mgr_.SetRotateVisibleBoneSet(bone_set_type, false);
  635. this.ik_mgr_.SetTransAxisVisibleBoneSet(bone_set_type, false);
  636. }
  637. }
  638. finally
  639. {
  640. IDisposable disposable;
  641. if ((disposable = (enumerator as IDisposable)) != null)
  642. {
  643. disposable.Dispose();
  644. }
  645. }
  646. this.ik_mgr_.SetTransAxisVisibleRoot(false);
  647. }
  648. this.ik_mgr_ = PoseEditWindow.GetMaidIKManager(maid);
  649. dictionary = null;
  650. bool flag = maid != null && !maid.boMAN;
  651. if (flag)
  652. {
  653. dictionary = base.GetMaidStoreData(base.mgr.select_maid);
  654. this.CheckbtnUse.check = bool.Parse(dictionary["use"]);
  655. this.ctrl_type_ = (PoseEditWindow.ControlType)Enum.Parse(typeof(PoseEditWindow.ControlType), dictionary["select_control_type"]);
  656. }
  657. else
  658. {
  659. this.CheckbtnUse.check = false;
  660. this.ctrl_type_ = PoseEditWindow.ControlType.Null;
  661. }
  662. this.CheckbtnUse.enabled = flag;
  663. this.ChangeEnabeled(this.CheckbtnUse.check);
  664. if (this.ik_mgr_ != null && this.CheckbtnUse.check)
  665. {
  666. if (dictionary["pose_binary"] != string.Empty)
  667. {
  668. KeyValuePair<bool, bool> keyValuePair = this.ik_mgr_.cache_bone_data.SetFrameBinary(Convert.FromBase64String(dictionary["pose_binary"]));
  669. maid.body0.MuneYureL((float)((!keyValuePair.Key) ? 1 : 0));
  670. maid.body0.MuneYureR((float)((!keyValuePair.Value) ? 1 : 0));
  671. }
  672. this.Apply();
  673. this.ik_mgr.HistoryNew();
  674. }
  675. this.noCharaActive.ChangeMode(maid == null, true);
  676. }
  677. public override void OnDeserializeEvent()
  678. {
  679. List<string> maidStoreGuidList = base.mgr.GetMaidStoreGuidList();
  680. for (int i = 0; i < maidStoreGuidList.Count; i++)
  681. {
  682. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(maidStoreGuidList[i]);
  683. }
  684. }
  685. public override void OnSerializeEvent()
  686. {
  687. base.OnSerializeEvent();
  688. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN)
  689. {
  690. return;
  691. }
  692. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  693. byte[] frameBinary = this.ik_mgr_.cache_bone_data.GetFrameBinary(bool.Parse(maidStoreData["use_mune_key_l"]), bool.Parse(maidStoreData["use_mune_key_r"]));
  694. maidStoreData = base.GetMaidStoreData(this.ik_mgr_.maid);
  695. if (bool.Parse(maidStoreData["use"]))
  696. {
  697. maidStoreData["pose_binary"] = Convert.ToBase64String(frameBinary);
  698. }
  699. else
  700. {
  701. maidStoreData["pose_binary"] = string.Empty;
  702. }
  703. }
  704. public WindowPartsFingerBlend GetWindowPartsFingerBlend(IKManager.BoneSetType bone_set_type)
  705. {
  706. Dictionary<IKManager.BoneSetType, WindowPartsFingerBlend.Type> dictionary = new Dictionary<IKManager.BoneSetType, WindowPartsFingerBlend.Type>();
  707. dictionary.Add(IKManager.BoneSetType.RightArmFinger, WindowPartsFingerBlend.Type.RightArm);
  708. dictionary.Add(IKManager.BoneSetType.LeftArmFinger, WindowPartsFingerBlend.Type.LeftArm);
  709. dictionary.Add(IKManager.BoneSetType.RightLegFinger, WindowPartsFingerBlend.Type.RightLeg);
  710. dictionary.Add(IKManager.BoneSetType.LeftLegFinger, WindowPartsFingerBlend.Type.LeftLeg);
  711. WindowPartsFingerBlend result = null;
  712. for (int i = 0; i < this.FingerBlendArray.Length; i++)
  713. {
  714. if (dictionary[bone_set_type] == this.FingerBlendArray[i].BlendType)
  715. {
  716. result = this.FingerBlendArray[i];
  717. break;
  718. }
  719. }
  720. return result;
  721. }
  722. private void DeleteIKManager(Maid maid)
  723. {
  724. GameObject x = GameObject.Find("PoseEditWorkParent");
  725. if (x == null)
  726. {
  727. x = new GameObject("PoseEditWorkParent");
  728. }
  729. if (maid == null)
  730. {
  731. return;
  732. }
  733. GameObject gameObject = GameObject.Find("PoseEditWorkParent/" + maid.status.guid);
  734. if (gameObject != null)
  735. {
  736. if (this.ik_mgr_ != null && this.ik_mgr_.maid == maid)
  737. {
  738. this.ik_mgr_ = null;
  739. }
  740. UnityEngine.Object.DestroyImmediate(gameObject);
  741. }
  742. }
  743. private void SetControlPanel(PoseEditWindow.ControlType type)
  744. {
  745. if (type == PoseEditWindow.ControlType.Null)
  746. {
  747. this.WindowSize = new Vector2(480f, 120f);
  748. GameObject[] array = new GameObject[]
  749. {
  750. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body),
  751. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand),
  752. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg)
  753. };
  754. foreach (GameObject gameObject in array)
  755. {
  756. gameObject.SetActive(false);
  757. }
  758. }
  759. else if (type == PoseEditWindow.ControlType.Body)
  760. {
  761. this.WindowSize = new Vector2(513f, 850f);
  762. GameObject[] array3 = new GameObject[]
  763. {
  764. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand),
  765. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg)
  766. };
  767. foreach (GameObject gameObject2 in array3)
  768. {
  769. gameObject2.SetActive(false);
  770. }
  771. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body).SetActive(true);
  772. }
  773. else if (type == PoseEditWindow.ControlType.Hand)
  774. {
  775. this.WindowSize = new Vector2(765f, 890f);
  776. GameObject[] array5 = new GameObject[]
  777. {
  778. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body),
  779. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg)
  780. };
  781. foreach (GameObject gameObject3 in array5)
  782. {
  783. gameObject3.SetActive(false);
  784. }
  785. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand).SetActive(true);
  786. }
  787. else if (type == PoseEditWindow.ControlType.Leg)
  788. {
  789. this.WindowSize = new Vector2(765f, 710f);
  790. GameObject[] array7 = new GameObject[]
  791. {
  792. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body),
  793. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand)
  794. };
  795. foreach (GameObject gameObject4 in array7)
  796. {
  797. gameObject4.SetActive(false);
  798. }
  799. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg).SetActive(true);
  800. }
  801. base.ResizeWindow();
  802. }
  803. private GameObject GetControlPanelParentObject(PoseEditWindow.ControlType type)
  804. {
  805. if (type == PoseEditWindow.ControlType.Body)
  806. {
  807. return UTY.GetChildObject(base.gameObject, "Parent/ContentParent/BodyPanel", false);
  808. }
  809. if (type == PoseEditWindow.ControlType.Hand)
  810. {
  811. return UTY.GetChildObject(base.gameObject, "Parent/ContentParent/HandPanel", false);
  812. }
  813. if (type == PoseEditWindow.ControlType.Leg)
  814. {
  815. return UTY.GetChildObject(base.gameObject, "Parent/ContentParent/LegPanel", false);
  816. }
  817. return null;
  818. }
  819. public IKManager ik_mgr
  820. {
  821. get
  822. {
  823. return this.ik_mgr_;
  824. }
  825. }
  826. public UIButton BtnSave;
  827. public PhotoModePoseSave PanelSave;
  828. public WFCheckBox CheckbtnUse;
  829. public UIWFTabPanel ControlSelectBtnTab;
  830. public UIButton BtnReversal;
  831. public WindowPartsBoneCheckBox[] RotateCheckBoxArray;
  832. public WindowPartsFingerBlend[] FingerBlendArray;
  833. private Dictionary<string, WFCheckBox> ikbox_visible_dic_ = new Dictionary<string, WFCheckBox>();
  834. private PhotoNoCharaActive noCharaActive;
  835. private PoseEditWindow.ControlType ctrl_type_;
  836. private IKManager ik_mgr_;
  837. private Dictionary<string, string> store_type_name_map_ = new Dictionary<string, string>();
  838. private enum ControlType
  839. {
  840. Null,
  841. Body,
  842. Hand,
  843. Leg
  844. }
  845. }