PoseEditWindow.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  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. bool key2 = keyValuePair2.Key;
  264. bool value2 = keyValuePair2.Value;
  265. maid.body0.MuneYureL((float)((!key2) ? 1 : 0));
  266. maid.body0.MuneYureR((float)((!value2) ? 1 : 0));
  267. maid.body0.jbMuneL.enabled = !key2;
  268. maid.body0.jbMuneR.enabled = !value2;
  269. }
  270. }
  271. public void OnMotionUpdate(Maid maid)
  272. {
  273. if (base.mgr.select_maid == null || base.mgr.select_maid != maid || maid.boMAN)
  274. {
  275. return;
  276. }
  277. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(maid);
  278. if (!bool.Parse(maidStoreData["use"]))
  279. {
  280. return;
  281. }
  282. bool flag = maid.body0.GetMuneYureL() == 0f;
  283. bool flag2 = maid.body0.GetMuneYureR() == 0f;
  284. maidStoreData["use_mune_key_l"] = flag.ToString();
  285. maidStoreData["use_mune_key_r"] = flag2.ToString();
  286. maid.body0.jbMuneL.enabled = !flag;
  287. maid.body0.jbMuneR.enabled = !flag2;
  288. for (int i = 0; i < this.RotateCheckBoxArray.Length; i++)
  289. {
  290. this.RotateCheckBoxArray[i].OnMotionUpdate();
  291. }
  292. if (this.ik_mgr_ != null)
  293. {
  294. IKManager.BoneSetType[] array = new IKManager.BoneSetType[0];
  295. if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Body)
  296. {
  297. array = new IKManager.BoneSetType[]
  298. {
  299. IKManager.BoneSetType.RightArmFinger,
  300. IKManager.BoneSetType.LeftArmFinger,
  301. IKManager.BoneSetType.RightLegFinger,
  302. IKManager.BoneSetType.LeftLegFinger
  303. };
  304. }
  305. else if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Hand)
  306. {
  307. array = new IKManager.BoneSetType[]
  308. {
  309. IKManager.BoneSetType.Body,
  310. IKManager.BoneSetType.RightLegFinger,
  311. IKManager.BoneSetType.LeftLegFinger
  312. };
  313. }
  314. else if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Leg)
  315. {
  316. array = new IKManager.BoneSetType[]
  317. {
  318. IKManager.BoneSetType.Body,
  319. IKManager.BoneSetType.RightArmFinger,
  320. IKManager.BoneSetType.LeftArmFinger
  321. };
  322. }
  323. foreach (IKManager.BoneSetType bone_set_type in array)
  324. {
  325. this.ik_mgr_.SetRotateVisibleBoneSet(bone_set_type, false);
  326. }
  327. }
  328. for (int k = 0; k < this.FingerBlendArray.Length; k++)
  329. {
  330. this.FingerBlendArray[k].OnMotionUpdate();
  331. }
  332. if (this.ik_mgr_ != null)
  333. {
  334. this.ik_mgr.HistoryClear();
  335. this.ik_mgr.HistoryNew();
  336. }
  337. }
  338. public void OnSelectControlSelectBtn()
  339. {
  340. if (this.ControlSelectBtnTab.GetSelectButtonObject() == null || base.mgr.select_maid == null || base.mgr.select_maid.boMAN || !UIWFSelectButton.current.isSelected)
  341. {
  342. return;
  343. }
  344. UILabel componentInChildren = this.ControlSelectBtnTab.GetSelectButtonObject().GetComponentInChildren<UILabel>();
  345. if (componentInChildren == null)
  346. {
  347. return;
  348. }
  349. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  350. string key = "select_control_type";
  351. if (componentInChildren.text == "胴体")
  352. {
  353. this.ctrl_type_ = PoseEditWindow.ControlType.Body;
  354. }
  355. else if (componentInChildren.text == "手")
  356. {
  357. this.ctrl_type_ = PoseEditWindow.ControlType.Hand;
  358. }
  359. else
  360. {
  361. this.ctrl_type_ = PoseEditWindow.ControlType.Leg;
  362. }
  363. maidStoreData[key] = this.ctrl_type_.ToString();
  364. this.SetControlPanel(this.ctrl_type_);
  365. IKManager.BoneSetType[] array = new IKManager.BoneSetType[0];
  366. bool flag = false;
  367. if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Body)
  368. {
  369. array = new IKManager.BoneSetType[]
  370. {
  371. IKManager.BoneSetType.RightArmFinger,
  372. IKManager.BoneSetType.LeftArmFinger,
  373. IKManager.BoneSetType.RightLegFinger,
  374. IKManager.BoneSetType.LeftLegFinger
  375. };
  376. flag = true;
  377. }
  378. else if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Hand)
  379. {
  380. array = new IKManager.BoneSetType[]
  381. {
  382. IKManager.BoneSetType.Body,
  383. IKManager.BoneSetType.RightLegFinger,
  384. IKManager.BoneSetType.LeftLegFinger
  385. };
  386. }
  387. else if (this.ik_mgr_ != null && this.ctrl_type_ == PoseEditWindow.ControlType.Leg)
  388. {
  389. array = new IKManager.BoneSetType[]
  390. {
  391. IKManager.BoneSetType.Body,
  392. IKManager.BoneSetType.RightArmFinger,
  393. IKManager.BoneSetType.LeftArmFinger
  394. };
  395. }
  396. foreach (KeyValuePair<string, WFCheckBox> keyValuePair in this.ikbox_visible_dic_)
  397. {
  398. keyValuePair.Value.check = bool.Parse(maidStoreData[keyValuePair.Value.name]);
  399. keyValuePair.Value.onClick[0](keyValuePair.Value);
  400. }
  401. foreach (IKManager.BoneSetType bone_set_type in array)
  402. {
  403. this.ik_mgr_.SetRotateVisibleBoneSet(bone_set_type, false);
  404. this.ik_mgr_.SetTransAxisVisibleBoneSet(bone_set_type, false);
  405. }
  406. if (!flag)
  407. {
  408. this.ik_mgr_.SetTransAxisVisibleRoot(false);
  409. }
  410. List<IKManager.BoneSetType> list = new List<IKManager.BoneSetType>(array);
  411. for (int j = 0; j < this.RotateCheckBoxArray.Length; j++)
  412. {
  413. if (0 > list.IndexOf(this.RotateCheckBoxArray[j].BoneSetType))
  414. {
  415. this.RotateCheckBoxArray[j].Apply();
  416. }
  417. }
  418. }
  419. public void OnClickUseCheck(WFCheckBox check_box)
  420. {
  421. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN)
  422. {
  423. return;
  424. }
  425. if (!check_box.check && GameMain.Instance.SysDlg.IsDecided)
  426. {
  427. GameMain.Instance.SysDlg.Show("セーブしていないデータは失われます。\nOFFにしますか?", SystemDialog.TYPE.YES_NO, delegate
  428. {
  429. check_box.check = false;
  430. this.OnClickUseCheckRun(false);
  431. GameMain.Instance.SysDlg.Close();
  432. }, null);
  433. check_box.check = true;
  434. return;
  435. }
  436. this.OnClickUseCheckRun(true);
  437. }
  438. public void OnClickUseCheckRun(bool check)
  439. {
  440. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  441. maidStoreData["use"] = check.ToString();
  442. if (!check)
  443. {
  444. maidStoreData["pose_binary"] = string.Empty;
  445. }
  446. this.ChangeEnabeled(check);
  447. this.ik_mgr.HistoryClear();
  448. this.ik_mgr.HistoryNew();
  449. MaidColliderCollect component = base.mgr.select_maid.GetComponent<MaidColliderCollect>();
  450. List<CapsuleCollider> collider = component.GetCollider(MaidColliderCollect.ColliderType.Grab);
  451. foreach (CapsuleCollider capsuleCollider in collider)
  452. {
  453. capsuleCollider.gameObject.SetActive(!check);
  454. }
  455. }
  456. public void OnIKBOXVixibleCheckBox(WFCheckBox check_box)
  457. {
  458. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN || this.ik_mgr_ == null)
  459. {
  460. return;
  461. }
  462. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  463. maidStoreData[check_box.name] = check_box.check.ToString();
  464. string text = check_box.name.Replace("ik_box_visible_", string.Empty);
  465. if (text == "Root")
  466. {
  467. this.ik_mgr_.SetTransAxisVisibleRoot(check_box.check);
  468. }
  469. else
  470. {
  471. IKManager.BoneSetType boneSetType = (IKManager.BoneSetType)Enum.Parse(typeof(IKManager.BoneSetType), text);
  472. this.ik_mgr_.SetTransAxisVisibleBoneSet(boneSetType, check_box.check);
  473. if (check_box.check && boneSetType != IKManager.BoneSetType.Body)
  474. {
  475. WindowPartsFingerBlend windowPartsFingerBlend = this.GetWindowPartsFingerBlend(boneSetType);
  476. if (windowPartsFingerBlend != null && windowPartsFingerBlend.CheckBoxEnabled.check)
  477. {
  478. windowPartsFingerBlend.OnClickEnter();
  479. }
  480. }
  481. }
  482. }
  483. public void ChangeEnabeled(bool use)
  484. {
  485. if (use && (base.mgr.select_maid == null || base.mgr.select_maid.boMAN))
  486. {
  487. use = false;
  488. }
  489. if (use)
  490. {
  491. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  492. this.BtnSave.isEnabled = true;
  493. MotionWindow motionWindow = base.mgr.GetWindow(PhotoWindowManager.WindowType.Motion) as MotionWindow;
  494. if (!motionWindow.CheckbtnStop.check)
  495. {
  496. motionWindow.CheckbtnStop.check = true;
  497. motionWindow.OnClickStopCheck(motionWindow.CheckbtnStop);
  498. }
  499. base.mgr.select_maid.IKTargetToBone("左手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, false, false);
  500. base.mgr.select_maid.IKTargetToBone("右手", null, "無し", Vector3.zero, IKCtrlData.IKAttachType.Point, false, false, false);
  501. this.ControlSelectBtnTab.ResetSelect();
  502. Dictionary<PoseEditWindow.ControlType, UIWFTabButton> dictionary = new Dictionary<PoseEditWindow.ControlType, UIWFTabButton>();
  503. foreach (UIWFTabButton uiwftabButton in this.ControlSelectBtnTab.button_list)
  504. {
  505. uiwftabButton.SetSelect(false);
  506. uiwftabButton.isEnabled = true;
  507. dictionary.Add((PoseEditWindow.ControlType)Enum.Parse(typeof(PoseEditWindow.ControlType), uiwftabButton.transform.parent.name), uiwftabButton);
  508. }
  509. for (int i = 0; i < this.RotateCheckBoxArray.Length; i++)
  510. {
  511. this.RotateCheckBoxArray[i].ChangeEnabeled(use);
  512. }
  513. for (int j = 0; j < this.FingerBlendArray.Length; j++)
  514. {
  515. this.FingerBlendArray[j].ChangeEnabeled(use);
  516. }
  517. this.ControlSelectBtnTab.Select(dictionary[this.ctrl_type_]);
  518. }
  519. else
  520. {
  521. this.ControlSelectBtnTab.ResetSelect();
  522. foreach (UIWFTabButton uiwftabButton2 in this.ControlSelectBtnTab.button_list)
  523. {
  524. uiwftabButton2.SetSelect(false);
  525. uiwftabButton2.isEnabled = false;
  526. }
  527. this.BtnSave.isEnabled = false;
  528. MotionWindow motionWindow2 = base.mgr.GetWindow(PhotoWindowManager.WindowType.Motion) as MotionWindow;
  529. motionWindow2.UpdateAnimationData(base.mgr.select_maid);
  530. this.SetControlPanel(PoseEditWindow.ControlType.Null);
  531. if (this.ik_mgr_ != null)
  532. {
  533. IEnumerator enumerator3 = Enum.GetValues(typeof(IKManager.BoneSetType)).GetEnumerator();
  534. try
  535. {
  536. while (enumerator3.MoveNext())
  537. {
  538. object obj = enumerator3.Current;
  539. IKManager.BoneSetType bone_set_type = (IKManager.BoneSetType)obj;
  540. this.ik_mgr_.SetRotateVisibleBoneSet(bone_set_type, false);
  541. this.ik_mgr_.SetTransAxisVisibleBoneSet(bone_set_type, false);
  542. }
  543. }
  544. finally
  545. {
  546. IDisposable disposable;
  547. if ((disposable = (enumerator3 as IDisposable)) != null)
  548. {
  549. disposable.Dispose();
  550. }
  551. }
  552. this.ik_mgr_.SetTransAxisVisibleRoot(false);
  553. }
  554. if (base.mgr.select_maid != null && base.mgr.select_maid.body0 != null && !base.mgr.select_maid.boMAN)
  555. {
  556. base.mgr.select_maid.body0.MuneYureL(1f);
  557. base.mgr.select_maid.body0.MuneYureR(1f);
  558. base.mgr.select_maid.body0.jbMuneL.enabled = true;
  559. base.mgr.select_maid.body0.jbMuneR.enabled = true;
  560. }
  561. if (this.ik_mgr != null)
  562. {
  563. this.ik_mgr.HistoryClear();
  564. }
  565. for (int k = 0; k < this.RotateCheckBoxArray.Length; k++)
  566. {
  567. this.RotateCheckBoxArray[k].ChangeEnabeled(use);
  568. }
  569. for (int l = 0; l < this.FingerBlendArray.Length; l++)
  570. {
  571. this.FingerBlendArray[l].ChangeEnabeled(use);
  572. }
  573. }
  574. this.Apply();
  575. }
  576. public void Apply()
  577. {
  578. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN)
  579. {
  580. return;
  581. }
  582. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  583. if (!bool.Parse(maidStoreData["use"]))
  584. {
  585. return;
  586. }
  587. for (int i = 0; i < this.FingerBlendArray.Length; i++)
  588. {
  589. this.FingerBlendArray[i].Apply();
  590. }
  591. }
  592. public void OnBtnSave()
  593. {
  594. if (this.ik_mgr_ == null || base.mgr.select_maid == null)
  595. {
  596. return;
  597. }
  598. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  599. this.PanelSave.OpenPoseSaveMode(this.ik_mgr_.cache_bone_data.GetAnmBinary(bool.Parse(maidStoreData["use_mune_key_l"]), bool.Parse(maidStoreData["use_mune_key_r"])));
  600. }
  601. public void OnBtnReversal()
  602. {
  603. this.ik_mgr.Flip();
  604. }
  605. public override void OnMaidRemoveEvent(Maid maid)
  606. {
  607. if (maid != null && maid.boMAN)
  608. {
  609. maid = null;
  610. }
  611. this.DeleteIKManager(maid);
  612. }
  613. public override void OnMaidChangeEvent(Maid maid)
  614. {
  615. base.OnMaidChangeEvent(maid);
  616. if (maid == null)
  617. {
  618. this.ik_mgr_ = null;
  619. }
  620. Dictionary<string, string> dictionary;
  621. if (this.ik_mgr_ != null)
  622. {
  623. dictionary = base.GetMaidStoreData(this.ik_mgr_.maid);
  624. byte[] frameBinary = this.ik_mgr_.cache_bone_data.GetFrameBinary(bool.Parse(dictionary["use_mune_key_l"]), bool.Parse(dictionary["use_mune_key_r"]));
  625. if (bool.Parse(dictionary["use"]))
  626. {
  627. dictionary["pose_binary"] = Convert.ToBase64String(frameBinary);
  628. }
  629. else
  630. {
  631. dictionary["pose_binary"] = string.Empty;
  632. }
  633. IEnumerator enumerator = Enum.GetValues(typeof(IKManager.BoneSetType)).GetEnumerator();
  634. try
  635. {
  636. while (enumerator.MoveNext())
  637. {
  638. object obj = enumerator.Current;
  639. IKManager.BoneSetType bone_set_type = (IKManager.BoneSetType)obj;
  640. this.ik_mgr_.SetRotateVisibleBoneSet(bone_set_type, false);
  641. this.ik_mgr_.SetTransAxisVisibleBoneSet(bone_set_type, false);
  642. }
  643. }
  644. finally
  645. {
  646. IDisposable disposable;
  647. if ((disposable = (enumerator as IDisposable)) != null)
  648. {
  649. disposable.Dispose();
  650. }
  651. }
  652. this.ik_mgr_.SetTransAxisVisibleRoot(false);
  653. }
  654. this.ik_mgr_ = PoseEditWindow.GetMaidIKManager(maid);
  655. dictionary = null;
  656. bool flag = maid != null && !maid.boMAN;
  657. if (flag)
  658. {
  659. dictionary = base.GetMaidStoreData(base.mgr.select_maid);
  660. this.CheckbtnUse.check = bool.Parse(dictionary["use"]);
  661. this.ctrl_type_ = (PoseEditWindow.ControlType)Enum.Parse(typeof(PoseEditWindow.ControlType), dictionary["select_control_type"]);
  662. }
  663. else
  664. {
  665. this.CheckbtnUse.check = false;
  666. this.ctrl_type_ = PoseEditWindow.ControlType.Null;
  667. }
  668. this.CheckbtnUse.enabled = flag;
  669. if (this.ik_mgr_ != null && this.CheckbtnUse.check && dictionary["pose_binary"] != string.Empty)
  670. {
  671. KeyValuePair<bool, bool> keyValuePair = this.ik_mgr_.cache_bone_data.SetFrameBinary(Convert.FromBase64String(dictionary["pose_binary"]));
  672. bool key = keyValuePair.Key;
  673. bool value = keyValuePair.Value;
  674. maid.body0.MuneYureL((float)((!key) ? 1 : 0));
  675. maid.body0.MuneYureR((float)((!value) ? 1 : 0));
  676. maid.body0.jbMuneL.enabled = !key;
  677. maid.body0.jbMuneR.enabled = !value;
  678. }
  679. this.ChangeEnabeled(this.CheckbtnUse.check);
  680. if (this.ik_mgr_ != null && this.CheckbtnUse.check)
  681. {
  682. this.Apply();
  683. this.ik_mgr.HistoryNew();
  684. }
  685. this.noCharaActive.ChangeMode(maid == null, true);
  686. }
  687. public override void OnDeserializeEvent()
  688. {
  689. List<string> maidStoreGuidList = base.mgr.GetMaidStoreGuidList();
  690. for (int i = 0; i < maidStoreGuidList.Count; i++)
  691. {
  692. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(maidStoreGuidList[i]);
  693. }
  694. }
  695. public override void OnSerializeEvent()
  696. {
  697. base.OnSerializeEvent();
  698. if (base.mgr.select_maid == null || base.mgr.select_maid.boMAN)
  699. {
  700. return;
  701. }
  702. Dictionary<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
  703. byte[] frameBinary = this.ik_mgr_.cache_bone_data.GetFrameBinary(bool.Parse(maidStoreData["use_mune_key_l"]), bool.Parse(maidStoreData["use_mune_key_r"]));
  704. maidStoreData = base.GetMaidStoreData(this.ik_mgr_.maid);
  705. if (bool.Parse(maidStoreData["use"]))
  706. {
  707. maidStoreData["pose_binary"] = Convert.ToBase64String(frameBinary);
  708. }
  709. else
  710. {
  711. maidStoreData["pose_binary"] = string.Empty;
  712. }
  713. }
  714. public WindowPartsFingerBlend GetWindowPartsFingerBlend(IKManager.BoneSetType bone_set_type)
  715. {
  716. Dictionary<IKManager.BoneSetType, WindowPartsFingerBlend.Type> dictionary = new Dictionary<IKManager.BoneSetType, WindowPartsFingerBlend.Type>();
  717. dictionary.Add(IKManager.BoneSetType.RightArmFinger, WindowPartsFingerBlend.Type.RightArm);
  718. dictionary.Add(IKManager.BoneSetType.LeftArmFinger, WindowPartsFingerBlend.Type.LeftArm);
  719. dictionary.Add(IKManager.BoneSetType.RightLegFinger, WindowPartsFingerBlend.Type.RightLeg);
  720. dictionary.Add(IKManager.BoneSetType.LeftLegFinger, WindowPartsFingerBlend.Type.LeftLeg);
  721. WindowPartsFingerBlend result = null;
  722. for (int i = 0; i < this.FingerBlendArray.Length; i++)
  723. {
  724. if (dictionary[bone_set_type] == this.FingerBlendArray[i].BlendType)
  725. {
  726. result = this.FingerBlendArray[i];
  727. break;
  728. }
  729. }
  730. return result;
  731. }
  732. private void DeleteIKManager(Maid maid)
  733. {
  734. GameObject x = GameObject.Find("PoseEditWorkParent");
  735. if (x == null)
  736. {
  737. x = new GameObject("PoseEditWorkParent");
  738. }
  739. if (maid == null)
  740. {
  741. return;
  742. }
  743. GameObject gameObject = GameObject.Find("PoseEditWorkParent/" + maid.status.guid);
  744. if (gameObject != null)
  745. {
  746. if (this.ik_mgr_ != null && this.ik_mgr_.maid == maid)
  747. {
  748. this.ik_mgr_ = null;
  749. }
  750. UnityEngine.Object.DestroyImmediate(gameObject);
  751. }
  752. }
  753. private void SetControlPanel(PoseEditWindow.ControlType type)
  754. {
  755. if (type == PoseEditWindow.ControlType.Null)
  756. {
  757. this.WindowSize = new Vector2(480f, 120f);
  758. GameObject[] array = new GameObject[]
  759. {
  760. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body),
  761. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand),
  762. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg)
  763. };
  764. foreach (GameObject gameObject in array)
  765. {
  766. gameObject.SetActive(false);
  767. }
  768. }
  769. else if (type == PoseEditWindow.ControlType.Body)
  770. {
  771. this.WindowSize = new Vector2(513f, 850f);
  772. GameObject[] array3 = new GameObject[]
  773. {
  774. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand),
  775. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg)
  776. };
  777. foreach (GameObject gameObject2 in array3)
  778. {
  779. gameObject2.SetActive(false);
  780. }
  781. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body).SetActive(true);
  782. }
  783. else if (type == PoseEditWindow.ControlType.Hand)
  784. {
  785. this.WindowSize = new Vector2(765f, 890f);
  786. GameObject[] array5 = new GameObject[]
  787. {
  788. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body),
  789. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg)
  790. };
  791. foreach (GameObject gameObject3 in array5)
  792. {
  793. gameObject3.SetActive(false);
  794. }
  795. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand).SetActive(true);
  796. }
  797. else if (type == PoseEditWindow.ControlType.Leg)
  798. {
  799. this.WindowSize = new Vector2(765f, 710f);
  800. GameObject[] array7 = new GameObject[]
  801. {
  802. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Body),
  803. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Hand)
  804. };
  805. foreach (GameObject gameObject4 in array7)
  806. {
  807. gameObject4.SetActive(false);
  808. }
  809. this.GetControlPanelParentObject(PoseEditWindow.ControlType.Leg).SetActive(true);
  810. }
  811. base.ResizeWindow();
  812. }
  813. private GameObject GetControlPanelParentObject(PoseEditWindow.ControlType type)
  814. {
  815. if (type == PoseEditWindow.ControlType.Body)
  816. {
  817. return UTY.GetChildObject(base.gameObject, "Parent/ContentParent/BodyPanel", false);
  818. }
  819. if (type == PoseEditWindow.ControlType.Hand)
  820. {
  821. return UTY.GetChildObject(base.gameObject, "Parent/ContentParent/HandPanel", false);
  822. }
  823. if (type == PoseEditWindow.ControlType.Leg)
  824. {
  825. return UTY.GetChildObject(base.gameObject, "Parent/ContentParent/LegPanel", false);
  826. }
  827. return null;
  828. }
  829. public IKManager ik_mgr
  830. {
  831. get
  832. {
  833. return this.ik_mgr_;
  834. }
  835. }
  836. public UIButton BtnSave;
  837. public PhotoModePoseSave PanelSave;
  838. public WFCheckBox CheckbtnUse;
  839. public UIWFTabPanel ControlSelectBtnTab;
  840. public UIButton BtnReversal;
  841. public WindowPartsBoneCheckBox[] RotateCheckBoxArray;
  842. public WindowPartsFingerBlend[] FingerBlendArray;
  843. private Dictionary<string, WFCheckBox> ikbox_visible_dic_ = new Dictionary<string, WFCheckBox>();
  844. private PhotoNoCharaActive noCharaActive;
  845. private PoseEditWindow.ControlType ctrl_type_;
  846. private IKManager ik_mgr_;
  847. private Dictionary<string, string> store_type_name_map_ = new Dictionary<string, string>();
  848. private enum ControlType
  849. {
  850. Null,
  851. Body,
  852. Hand,
  853. Leg
  854. }
  855. }