DepthOfFieldPane.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 Slider focalLengthSlider;
  8. private Slider focalSizeSlider;
  9. private Slider apertureSlider;
  10. private Slider blurSlider;
  11. private Toggle thicknessToggle;
  12. public DepthOfFieldPane(EffectManager effectManager) : base(effectManager.Get<DepthOfFieldEffectManager>())
  13. {
  14. this.focalLengthSlider = new Slider(Translation.Get("effectDof", "focalLength"), 0f, 10f);
  15. this.focalSizeSlider = new Slider(Translation.Get("effectDof", "focalArea"), 0f, 2f);
  16. this.apertureSlider = new Slider(Translation.Get("effectDof", "aperture"), 0f, 60f);
  17. this.blurSlider = new Slider(Translation.Get("effectDof", "blur"), 0f, 10f);
  18. this.thicknessToggle = new Toggle(Translation.Get("effectDof", "thicknessToggle"));
  19. this.focalLengthSlider.ControlEvent += (s, a) =>
  20. {
  21. this.EffectManager.FocalLength = this.focalLengthSlider.Value;
  22. };
  23. this.focalSizeSlider.ControlEvent += (s, a) =>
  24. {
  25. this.EffectManager.FocalSize = this.focalSizeSlider.Value;
  26. };
  27. this.apertureSlider.ControlEvent += (s, a) =>
  28. {
  29. this.EffectManager.Aperture = this.apertureSlider.Value;
  30. };
  31. this.blurSlider.ControlEvent += (s, a) =>
  32. {
  33. this.EffectManager.MaxBlurSize = this.blurSlider.Value;
  34. };
  35. this.thicknessToggle.ControlEvent += (s, a) =>
  36. {
  37. this.EffectManager.VisualizeFocus = this.thicknessToggle.Value;
  38. };
  39. }
  40. protected override void TranslatePane()
  41. {
  42. this.focalLengthSlider.Label = Translation.Get("effectDof", "focalLength");
  43. this.focalSizeSlider.Label = Translation.Get("effectDof", "focalArea");
  44. this.apertureSlider.Label = Translation.Get("effectDof", "aperture");
  45. this.blurSlider.Label = Translation.Get("effectDof", "blur");
  46. this.thicknessToggle.Label = Translation.Get("effectDof", "thicknessToggle");
  47. }
  48. protected override void UpdateControls()
  49. {
  50. this.focalLengthSlider.Value = this.EffectManager.FocalLength;
  51. this.focalSizeSlider.Value = this.EffectManager.FocalSize;
  52. this.apertureSlider.Value = this.EffectManager.Aperture;
  53. this.blurSlider.Value = this.EffectManager.MaxBlurSize;
  54. this.thicknessToggle.Value = this.EffectManager.VisualizeFocus;
  55. }
  56. protected override void DrawPane()
  57. {
  58. this.focalLengthSlider.Draw();
  59. GUILayoutOption sliderWidth = MiscGUI.HalfSlider;
  60. GUILayout.BeginHorizontal();
  61. this.focalSizeSlider.Draw(sliderWidth);
  62. this.apertureSlider.Draw(sliderWidth);
  63. GUILayout.EndHorizontal();
  64. GUILayout.BeginHorizontal();
  65. this.blurSlider.Draw(sliderWidth);
  66. GUILayout.FlexibleSpace();
  67. this.thicknessToggle.Draw();
  68. GUILayout.EndHorizontal();
  69. GUI.enabled = true;
  70. }
  71. }
  72. }