BloomPane.cs 4.2 KB

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