PoseWindowPane.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. public class PoseWindowPane : BaseMainWindowPane
  5. {
  6. private readonly MeidoManager meidoManager;
  7. private readonly MaidPoseSelectorPane maidPosePane;
  8. private readonly SavePosePane savePosePane;
  9. private readonly MaidSwitcherPane maidSwitcherPane;
  10. private readonly MaidFaceLookPane maidFaceLookPane;
  11. private readonly MpnAttachPropPane mpnAttachPropPane;
  12. private readonly MaidDressingPane maidDressingPane;
  13. private readonly GravityControlPane gravityControlPane;
  14. private readonly CopyPosePane copyPosePane;
  15. private readonly HandPresetPane handPresetPane;
  16. private readonly SaveHandPane saveHandPane;
  17. private readonly MaidIKPane maidIKPane;
  18. private readonly Toggle freeLookToggle;
  19. private readonly Toggle savePoseToggle;
  20. private readonly Toggle saveHandToggle;
  21. private readonly Button flipButton;
  22. private bool savePoseMode;
  23. private bool saveHandMode;
  24. private string handPresetHeader;
  25. private string flipIKHeader;
  26. public PoseWindowPane(MeidoManager meidoManager, MaidSwitcherPane maidSwitcherPane)
  27. {
  28. this.meidoManager = meidoManager;
  29. this.maidSwitcherPane = maidSwitcherPane;
  30. maidPosePane = AddPane(new MaidPoseSelectorPane(meidoManager));
  31. savePosePane = AddPane(new SavePosePane(meidoManager));
  32. maidFaceLookPane = AddPane(new MaidFaceLookPane(meidoManager));
  33. maidFaceLookPane.Enabled = false;
  34. freeLookToggle = new Toggle(Translation.Get("freeLookPane", "freeLookToggle"), false);
  35. freeLookToggle.ControlEvent += (s, a) => SetMaidFreeLook();
  36. savePoseToggle = new Toggle(Translation.Get("posePane", "saveToggle"));
  37. savePoseToggle.ControlEvent += (s, a) => savePoseMode = !savePoseMode;
  38. mpnAttachPropPane = new MpnAttachPropPane(this.meidoManager);
  39. maidDressingPane = AddPane(new MaidDressingPane(this.meidoManager));
  40. maidIKPane = AddPane(new MaidIKPane(this.meidoManager));
  41. gravityControlPane = AddPane(new GravityControlPane(this.meidoManager));
  42. copyPosePane = AddPane(new CopyPosePane(this.meidoManager));
  43. saveHandToggle = new Toggle(Translation.Get("handPane", "saveToggle"));
  44. saveHandToggle.ControlEvent += (s, a) => saveHandMode = !saveHandMode;
  45. handPresetPane = AddPane(new HandPresetPane(meidoManager));
  46. saveHandPane = AddPane(new SaveHandPane(meidoManager));
  47. flipButton = new Button(Translation.Get("flipIK", "flipButton"));
  48. flipButton.ControlEvent += (s, a) => this.meidoManager.ActiveMeido.IKManager.Flip();
  49. handPresetHeader = Translation.Get("handPane", "header");
  50. flipIKHeader = Translation.Get("flipIK", "header");
  51. }
  52. protected override void ReloadTranslation()
  53. {
  54. freeLookToggle.Label = Translation.Get("freeLookPane", "freeLookToggle");
  55. savePoseToggle.Label = Translation.Get("posePane", "saveToggle");
  56. saveHandToggle.Label = Translation.Get("handPane", "saveToggle");
  57. flipButton.Label = Translation.Get("flipIK", "flipButton");
  58. handPresetHeader = Translation.Get("handPane", "header");
  59. flipIKHeader = Translation.Get("flipIK", "header");
  60. }
  61. public override void Draw()
  62. {
  63. tabsPane.Draw();
  64. maidSwitcherPane.Draw();
  65. maidPosePane.Draw();
  66. maidIKPane.Draw();
  67. MpsGui.WhiteLine();
  68. scrollPos = GUILayout.BeginScrollView(scrollPos);
  69. GUI.enabled = meidoManager.HasActiveMeido;
  70. GUILayout.BeginHorizontal();
  71. freeLookToggle.Draw();
  72. savePoseToggle.Draw();
  73. GUILayout.EndHorizontal();
  74. GUI.enabled = true;
  75. if (savePoseMode) savePosePane.Draw();
  76. else maidFaceLookPane.Draw();
  77. mpnAttachPropPane.Draw();
  78. maidDressingPane.Draw();
  79. GUI.enabled = meidoManager.HasActiveMeido;
  80. MpsGui.Header(handPresetHeader);
  81. MpsGui.WhiteLine();
  82. saveHandToggle.Draw();
  83. GUI.enabled = true;
  84. if (saveHandMode) saveHandPane.Draw();
  85. else handPresetPane.Draw();
  86. gravityControlPane.Draw();
  87. copyPosePane.Draw();
  88. GUILayout.BeginHorizontal();
  89. GUI.enabled = meidoManager.HasActiveMeido;
  90. GUILayout.Label(flipIKHeader, GUILayout.ExpandWidth(false));
  91. flipButton.Draw(GUILayout.ExpandWidth(false));
  92. GUI.enabled = true;
  93. GUILayout.EndHorizontal();
  94. GUILayout.EndScrollView();
  95. }
  96. private void SetMaidFreeLook()
  97. {
  98. if (updating) return;
  99. meidoManager.ActiveMeido.FreeLook = freeLookToggle.Value;
  100. }
  101. public override void UpdatePanes()
  102. {
  103. if (meidoManager.ActiveMeido == null) return;
  104. if (ActiveWindow)
  105. {
  106. updating = true;
  107. freeLookToggle.Value = meidoManager.ActiveMeido?.FreeLook ?? false;
  108. updating = false;
  109. base.UpdatePanes();
  110. }
  111. }
  112. }
  113. }