PoseWindowPane.cs 5.3 KB

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