MaidFreeLookPane.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. internal class MaidFaceLookPane : BasePane
  6. {
  7. private MeidoManager meidoManager;
  8. private Slider lookXSlider;
  9. private Slider lookYSlider;
  10. public MaidFaceLookPane(MeidoManager meidoManager)
  11. {
  12. this.meidoManager = meidoManager;
  13. // this.meidoManager.AnimeChange += (s, a) => SetBounds();
  14. this.lookXSlider = new Slider(Translation.Get("freeLook", "x"), -0.6f, 0.6f);
  15. this.lookXSlider.ControlEvent += (s, a) => SetMaidLook();
  16. this.lookYSlider = new Slider(Translation.Get("freeLook", "y"), 0.5f, -0.55f);
  17. this.lookYSlider.ControlEvent += (s, a) => SetMaidLook();
  18. }
  19. protected override void ReloadTranslation()
  20. {
  21. this.lookXSlider.Label = Translation.Get("freeLook", "x");
  22. this.lookYSlider.Label = Translation.Get("freeLook", "y");
  23. }
  24. public void SetMaidLook()
  25. {
  26. if (updating) return;
  27. TBody body = this.meidoManager.ActiveMeido.Maid.body0;
  28. body.offsetLookTarget = new Vector3(lookYSlider.Value, 1f, lookXSlider.Value);
  29. }
  30. public void SetBounds()
  31. {
  32. float left = 0.5f;
  33. float right = -0.55f;
  34. if (this.meidoManager.ActiveMeido.IsStop)
  35. {
  36. left *= 0.6f;
  37. right *= 0.6f;
  38. }
  39. this.lookYSlider.SetBounds(left, right);
  40. }
  41. public override void UpdatePane()
  42. {
  43. TBody body = this.meidoManager.ActiveMeido.Maid.body0;
  44. this.updating = true;
  45. this.SetBounds();
  46. this.lookXSlider.Value = body.offsetLookTarget.z;
  47. this.lookYSlider.Value = body.offsetLookTarget.x;
  48. this.updating = false;
  49. }
  50. public override void Draw()
  51. {
  52. GUI.enabled = this.meidoManager.HasActiveMeido && this.meidoManager.ActiveMeido.IsFreeLook;
  53. GUILayout.BeginHorizontal();
  54. lookXSlider.Draw();
  55. lookYSlider.Draw();
  56. GUILayout.EndHorizontal();
  57. }
  58. }
  59. }