MaidFreeLookPane.cs 2.1 KB

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