VignettePane.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal class VignettePane : EffectPane<VignetteEffectManager>
  5. {
  6. protected override VignetteEffectManager EffectManager { get; set; }
  7. private Slider intensitySlider;
  8. private Slider blurSlider;
  9. private Slider blurSpreadSlider;
  10. private Slider aberrationSlider;
  11. public VignettePane(EffectManager effectManager) : base(effectManager.Get<VignetteEffectManager>())
  12. {
  13. this.intensitySlider = new Slider(Translation.Get("effectVignette", "intensity"), -40f, 70f);
  14. this.intensitySlider.ControlEvent += (s, a) =>
  15. {
  16. if (this.updating) return;
  17. this.EffectManager.Intensity = this.intensitySlider.Value;
  18. };
  19. this.blurSlider = new Slider(Translation.Get("effectVignette", "blur"), 0f, 5f);
  20. this.blurSlider.ControlEvent += (s, a) =>
  21. {
  22. if (this.updating) return;
  23. this.EffectManager.Blur = this.blurSlider.Value;
  24. };
  25. this.blurSpreadSlider = new Slider(Translation.Get("effectVignette", "blurSpread"), 0f, 40f);
  26. this.blurSpreadSlider.ControlEvent += (s, a) =>
  27. {
  28. if (this.updating) return;
  29. this.EffectManager.BlurSpread = this.blurSpreadSlider.Value;
  30. };
  31. this.aberrationSlider = new Slider(Translation.Get("effectVignette", "aberration"), -30f, 30f);
  32. this.aberrationSlider.ControlEvent += (s, a) =>
  33. {
  34. if (this.updating) return;
  35. this.EffectManager.ChromaticAberration = this.aberrationSlider.Value;
  36. };
  37. }
  38. protected override void TranslatePane()
  39. {
  40. this.intensitySlider.Label = Translation.Get("effectVignette", "intensity");
  41. this.blurSlider.Label = Translation.Get("effectVignette", "blur");
  42. this.blurSpreadSlider.Label = Translation.Get("effectVignette", "blurSpread");
  43. this.aberrationSlider.Label = Translation.Get("effectVignette", "aberration");
  44. }
  45. protected override void UpdateControls()
  46. {
  47. this.intensitySlider.Value = this.EffectManager.Intensity;
  48. this.blurSlider.Value = this.EffectManager.Blur;
  49. this.blurSpreadSlider.Value = this.EffectManager.BlurSpread;
  50. this.aberrationSlider.Value = this.EffectManager.ChromaticAberration;
  51. }
  52. protected override void DrawPane()
  53. {
  54. GUILayoutOption sliderWidth = MiscGUI.HalfSlider;
  55. GUILayout.BeginHorizontal();
  56. this.intensitySlider.Draw(sliderWidth);
  57. this.blurSlider.Draw(sliderWidth);
  58. GUILayout.EndHorizontal();
  59. GUILayout.BeginHorizontal();
  60. this.blurSpreadSlider.Draw(sliderWidth);
  61. this.aberrationSlider.Draw(sliderWidth);
  62. GUILayout.EndHorizontal();
  63. }
  64. }
  65. }