MaidIKPane.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal class MaidIKPane : BasePane
  5. {
  6. private MeidoManager meidoManager;
  7. private Toggle ikToggle;
  8. private Toggle releaseIKToggle;
  9. private Toggle boneIKToggle;
  10. private enum IKToggle
  11. {
  12. IK, Release, Bone
  13. }
  14. public MaidIKPane(MeidoManager meidoManager)
  15. {
  16. this.meidoManager = meidoManager;
  17. this.ikToggle = new Toggle(Translation.Get("maidPoseWindow", "ikToggle"), true);
  18. this.ikToggle.ControlEvent += (s, a) => SetIK(IKToggle.IK, this.ikToggle.Value);
  19. this.releaseIKToggle = new Toggle(Translation.Get("maidPoseWindow", "releaseToggle"));
  20. this.releaseIKToggle.ControlEvent += (s, a) => SetIK(IKToggle.Release, this.releaseIKToggle.Value);
  21. this.boneIKToggle = new Toggle(Translation.Get("maidPoseWindow", "boneToggle"));
  22. this.boneIKToggle.ControlEvent += (s, a) => SetIK(IKToggle.Bone, this.boneIKToggle.Value);
  23. }
  24. protected override void ReloadTranslation()
  25. {
  26. this.ikToggle.Label = Translation.Get("maidPoseWindow", "ikToggle");
  27. this.releaseIKToggle.Label = Translation.Get("maidPoseWindow", "releaseToggle");
  28. this.boneIKToggle.Label = Translation.Get("maidPoseWindow", "boneToggle");
  29. }
  30. private void SetIK(IKToggle toggle, bool value)
  31. {
  32. if (updating) return;
  33. if (toggle == IKToggle.IK) this.meidoManager.ActiveMeido.IK = value;
  34. else if (toggle == IKToggle.Release) this.meidoManager.ActiveMeido.Stop = false;
  35. else if (toggle == IKToggle.Bone) this.meidoManager.ActiveMeido.Bone = value;
  36. }
  37. public override void UpdatePane()
  38. {
  39. this.updating = true;
  40. this.ikToggle.Value = this.meidoManager.ActiveMeido.IK;
  41. this.releaseIKToggle.Value = this.meidoManager.ActiveMeido.Stop;
  42. this.boneIKToggle.Value = this.meidoManager.ActiveMeido.Bone;
  43. this.updating = false;
  44. }
  45. public override void Draw()
  46. {
  47. bool active = this.meidoManager.HasActiveMeido;
  48. GUILayout.BeginHorizontal();
  49. GUI.enabled = active;
  50. this.ikToggle.Draw();
  51. GUI.enabled = active ? this.meidoManager.ActiveMeido.Stop : false;
  52. this.releaseIKToggle.Draw();
  53. GUI.enabled = active ? this.ikToggle.Value : false;
  54. this.boneIKToggle.Draw();
  55. GUILayout.EndHorizontal();
  56. GUI.enabled = true;
  57. }
  58. }
  59. }