BloomPane.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. public class BloomPane : EffectPane<BloomEffectManager>
  5. {
  6. protected override BloomEffectManager EffectManager { get; set; }
  7. private readonly Slider intensitySlider;
  8. private readonly Slider blurSlider;
  9. private readonly Slider redSlider;
  10. private readonly Slider greenSlider;
  11. private readonly Slider blueSlider;
  12. private readonly Toggle hdrToggle;
  13. public BloomPane(EffectManager effectManager) : base(effectManager)
  14. {
  15. intensitySlider = new Slider(
  16. Translation.Get("effectBloom", "intensity"), 0f, 100f, EffectManager.BloomValue
  17. );
  18. intensitySlider.ControlEvent += (s, a) =>
  19. {
  20. if (updating) return;
  21. EffectManager.BloomValue = intensitySlider.Value;
  22. };
  23. blurSlider = new Slider(Translation.Get("effectBloom", "blur"), 0f, 15f, EffectManager.BlurIterations);
  24. blurSlider.ControlEvent += (s, a) =>
  25. {
  26. if (updating) return;
  27. EffectManager.BlurIterations = (int)blurSlider.Value;
  28. };
  29. redSlider = new Slider(
  30. Translation.Get("backgroundWindow", "red"), 1f, 0.5f, EffectManager.BloomThresholdColorRed
  31. );
  32. redSlider.ControlEvent += (s, a) =>
  33. {
  34. if (updating) return;
  35. EffectManager.BloomThresholdColorRed = redSlider.Value;
  36. };
  37. greenSlider = new Slider(
  38. Translation.Get("backgroundWindow", "green"), 1f, 0.5f, EffectManager.BloomThresholdColorGreen
  39. );
  40. greenSlider.ControlEvent += (s, a) =>
  41. {
  42. if (updating) return;
  43. EffectManager.BloomThresholdColorGreen = greenSlider.Value;
  44. };
  45. blueSlider = new Slider(
  46. Translation.Get("backgroundWindow", "blue"), 1f, 0.5f, EffectManager.BloomThresholdColorBlue
  47. );
  48. blueSlider.ControlEvent += (s, a) =>
  49. {
  50. if (updating) return;
  51. EffectManager.BloomThresholdColorBlue = blueSlider.Value;
  52. };
  53. hdrToggle = new Toggle(Translation.Get("effectBloom", "hdrToggle"), EffectManager.BloomHDR);
  54. hdrToggle.ControlEvent += (s, a) =>
  55. {
  56. if (updating) return;
  57. EffectManager.BloomHDR = hdrToggle.Value;
  58. };
  59. }
  60. protected override void TranslatePane()
  61. {
  62. intensitySlider.Label = Translation.Get("effectBloom", "intensity");
  63. blurSlider.Label = Translation.Get("effectBloom", "blur");
  64. redSlider.Label = Translation.Get("backgroundWindow", "red");
  65. greenSlider.Label = Translation.Get("backgroundWindow", "green");
  66. blueSlider.Label = Translation.Get("backgroundWindow", "blue");
  67. hdrToggle.Label = Translation.Get("effectBloom", "hdrToggle");
  68. }
  69. protected override void UpdateControls()
  70. {
  71. intensitySlider.Value = EffectManager.BloomValue;
  72. blurSlider.Value = EffectManager.BlurIterations;
  73. redSlider.Value = EffectManager.BloomThresholdColorRed;
  74. greenSlider.Value = EffectManager.BloomThresholdColorGreen;
  75. blueSlider.Value = EffectManager.BloomThresholdColorBlue;
  76. hdrToggle.Value = EffectManager.BloomHDR;
  77. }
  78. protected override void DrawPane()
  79. {
  80. GUILayoutOption sliderWidth = MpsGui.HalfSlider;
  81. GUILayout.BeginHorizontal();
  82. intensitySlider.Draw(sliderWidth);
  83. blurSlider.Draw(sliderWidth);
  84. GUILayout.EndHorizontal();
  85. GUILayout.BeginHorizontal();
  86. redSlider.Draw(sliderWidth);
  87. greenSlider.Draw(sliderWidth);
  88. GUILayout.EndHorizontal();
  89. GUILayout.BeginHorizontal();
  90. blueSlider.Draw(sliderWidth);
  91. GUILayout.FlexibleSpace();
  92. hdrToggle.Draw(GUILayout.ExpandWidth(false));
  93. GUILayout.EndHorizontal();
  94. }
  95. }
  96. }