DepthOfFieldPane.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal class DepthOfFieldPane : EffectPane<DepthOfFieldEffectManager>
  5. {
  6. protected override DepthOfFieldEffectManager EffectManager { get; set; }
  7. private readonly Slider focalLengthSlider;
  8. private readonly Slider focalSizeSlider;
  9. private readonly Slider apertureSlider;
  10. private readonly Slider blurSlider;
  11. private readonly Toggle thicknessToggle;
  12. public DepthOfFieldPane(EffectManager effectManager) : base(effectManager.Get<DepthOfFieldEffectManager>())
  13. {
  14. focalLengthSlider = new Slider(Translation.Get("effectDof", "focalLength"), 0f, 10f);
  15. focalSizeSlider = new Slider(Translation.Get("effectDof", "focalArea"), 0f, 2f);
  16. apertureSlider = new Slider(Translation.Get("effectDof", "aperture"), 0f, 60f);
  17. blurSlider = new Slider(Translation.Get("effectDof", "blur"), 0f, 10f);
  18. thicknessToggle = new Toggle(Translation.Get("effectDof", "thicknessToggle"));
  19. focalLengthSlider.ControlEvent += (s, a) => EffectManager.FocalLength = focalLengthSlider.Value;
  20. focalSizeSlider.ControlEvent += (s, a) => EffectManager.FocalSize = focalSizeSlider.Value;
  21. apertureSlider.ControlEvent += (s, a) => EffectManager.Aperture = apertureSlider.Value;
  22. blurSlider.ControlEvent += (s, a) => EffectManager.MaxBlurSize = blurSlider.Value;
  23. thicknessToggle.ControlEvent += (s, a) => EffectManager.VisualizeFocus = thicknessToggle.Value;
  24. }
  25. protected override void TranslatePane()
  26. {
  27. focalLengthSlider.Label = Translation.Get("effectDof", "focalLength");
  28. focalSizeSlider.Label = Translation.Get("effectDof", "focalArea");
  29. apertureSlider.Label = Translation.Get("effectDof", "aperture");
  30. blurSlider.Label = Translation.Get("effectDof", "blur");
  31. thicknessToggle.Label = Translation.Get("effectDof", "thicknessToggle");
  32. }
  33. protected override void UpdateControls()
  34. {
  35. focalLengthSlider.Value = EffectManager.FocalLength;
  36. focalSizeSlider.Value = EffectManager.FocalSize;
  37. apertureSlider.Value = EffectManager.Aperture;
  38. blurSlider.Value = EffectManager.MaxBlurSize;
  39. thicknessToggle.Value = EffectManager.VisualizeFocus;
  40. }
  41. protected override void DrawPane()
  42. {
  43. focalLengthSlider.Draw();
  44. GUILayoutOption sliderWidth = MpsGui.HalfSlider;
  45. GUILayout.BeginHorizontal();
  46. focalSizeSlider.Draw(sliderWidth);
  47. apertureSlider.Draw(sliderWidth);
  48. GUILayout.EndHorizontal();
  49. GUILayout.BeginHorizontal();
  50. blurSlider.Draw(sliderWidth);
  51. GUILayout.FlexibleSpace();
  52. thicknessToggle.Draw();
  53. GUILayout.EndHorizontal();
  54. GUI.enabled = true;
  55. }
  56. }
  57. }