MaidFaceLookPane.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. public 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. public void SetMaidLook()
  20. {
  21. if (updating) return;
  22. TBody body = this.meidoManager.ActiveMeido.Maid.body0;
  23. body.offsetLookTarget = new Vector3(lookYSlider.Value, 1f, lookXSlider.Value);
  24. }
  25. public void SetBounds()
  26. {
  27. float left = 0.5f;
  28. float right = -0.55f;
  29. if (this.meidoManager.ActiveMeido.IsStop)
  30. {
  31. left *= 0.6f;
  32. right *= 0.6f;
  33. }
  34. this.lookYSlider.SetBounds(left, right);
  35. }
  36. public override void Update()
  37. {
  38. TBody body = this.meidoManager.ActiveMeido.Maid.body0;
  39. this.updating = true;
  40. this.SetBounds();
  41. this.lookXSlider.Value = body.offsetLookTarget.z;
  42. this.lookYSlider.Value = body.offsetLookTarget.x;
  43. this.updating = false;
  44. }
  45. public override void Draw(params GUILayoutOption[] layoutOptions)
  46. {
  47. GUI.enabled = this.meidoManager.HasActiveMeido && this.meidoManager.ActiveMeido.IsFreeLook;
  48. GUILayout.BeginHorizontal();
  49. lookXSlider.Draw();
  50. lookYSlider.Draw();
  51. GUILayout.EndHorizontal();
  52. }
  53. }
  54. }