VignettePane.cs 2.8 KB

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