MaidFreeLookPane.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal class MaidFaceLookPane : BasePane
  5. {
  6. private MeidoManager meidoManager;
  7. private Slider lookXSlider;
  8. private Slider lookYSlider;
  9. private Toggle headToCamToggle;
  10. private Toggle eyeToCamToggle;
  11. public MaidFaceLookPane(MeidoManager meidoManager)
  12. {
  13. this.meidoManager = meidoManager;
  14. this.lookXSlider = new Slider(Translation.Get("freeLookPane", "xSlider"), -0.6f, 0.6f);
  15. this.lookXSlider.ControlEvent += (s, a) => SetMaidLook();
  16. this.lookYSlider = new Slider(Translation.Get("freeLookPane", "ySlider"), 0.5f, -0.55f);
  17. this.lookYSlider.ControlEvent += (s, a) => SetMaidLook();
  18. this.headToCamToggle = new Toggle(Translation.Get("freeLookPane", "headToCamToggle"));
  19. this.headToCamToggle.ControlEvent += (s, a) => SetHeadToCam(headToCamToggle.Value, eye: false);
  20. this.eyeToCamToggle = new Toggle(Translation.Get("freeLookPane", "eyeToCamToggle"));
  21. this.eyeToCamToggle.ControlEvent += (s, a) => SetHeadToCam(eyeToCamToggle.Value, eye: true);
  22. }
  23. protected override void ReloadTranslation()
  24. {
  25. this.lookXSlider.Label = Translation.Get("freeLookPane", "xSlider");
  26. this.lookYSlider.Label = Translation.Get("freeLookPane", "ySlider");
  27. this.headToCamToggle.Label = Translation.Get("freeLookPane", "headToCamToggle");
  28. this.eyeToCamToggle.Label = Translation.Get("freeLookPane", "eyeToCamToggle");
  29. }
  30. public void SetHeadToCam(bool value, bool eye = false)
  31. {
  32. if (updating) return;
  33. Meido meido = this.meidoManager.ActiveMeido;
  34. if (eye) meido.EyeToCam = value;
  35. else meido.HeadToCam = value;
  36. }
  37. public void SetMaidLook()
  38. {
  39. if (updating) return;
  40. TBody body = this.meidoManager.ActiveMeido.Body;
  41. body.offsetLookTarget = new Vector3(lookYSlider.Value, 1f, lookXSlider.Value);
  42. }
  43. public void SetBounds()
  44. {
  45. float left = 0.5f;
  46. float right = -0.55f;
  47. if (this.meidoManager.ActiveMeido.Stop)
  48. {
  49. left *= 0.6f;
  50. right *= 0.6f;
  51. }
  52. this.lookYSlider.SetBounds(left, right);
  53. }
  54. public override void UpdatePane()
  55. {
  56. Meido meido = this.meidoManager.ActiveMeido;
  57. this.updating = true;
  58. this.SetBounds();
  59. this.lookXSlider.Value = meido.Body.offsetLookTarget.z;
  60. this.lookYSlider.Value = meido.Body.offsetLookTarget.x;
  61. this.eyeToCamToggle.Value = meido.EyeToCam;
  62. this.headToCamToggle.Value = meido.HeadToCam;
  63. this.updating = false;
  64. }
  65. public override void Draw()
  66. {
  67. GUI.enabled = this.meidoManager.HasActiveMeido && this.meidoManager.ActiveMeido.FreeLook;
  68. GUILayout.BeginHorizontal();
  69. this.lookXSlider.Draw();
  70. this.lookYSlider.Draw();
  71. GUILayout.EndHorizontal();
  72. GUI.enabled = this.meidoManager.HasActiveMeido;
  73. GUILayout.BeginHorizontal();
  74. this.eyeToCamToggle.Draw();
  75. this.headToCamToggle.Draw();
  76. GUILayout.EndHorizontal();
  77. GUI.enabled = true;
  78. }
  79. }
  80. }