PoseEditWindow.cs 29 KB

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