FogPane.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. public class FogPane : EffectPane<FogEffectManager>
  5. {
  6. protected override FogEffectManager EffectManager { get; set; }
  7. private readonly Slider distanceSlider;
  8. private readonly Slider densitySlider;
  9. private readonly Slider heightScaleSlider;
  10. private readonly Slider heightSlider;
  11. private readonly Slider redSlider;
  12. private readonly Slider greenSlider;
  13. private readonly Slider blueSlider;
  14. public FogPane(EffectManager effectManager) : base(effectManager)
  15. {
  16. distanceSlider = new Slider(
  17. Translation.Get("effectFog", "distance"), 0f, 30f, EffectManager.Distance
  18. );
  19. densitySlider = new Slider(
  20. Translation.Get("effectFog", "density"), 0f, 10f, EffectManager.Density
  21. );
  22. heightScaleSlider = new Slider(
  23. Translation.Get("effectFog", "strength"), -5f, 20f, EffectManager.HeightScale
  24. );
  25. heightSlider = new Slider(
  26. Translation.Get("effectFog", "height"), -10f, 10f, EffectManager.Height
  27. );
  28. Color initialFogColour = EffectManager.FogColour;
  29. redSlider = new Slider(Translation.Get("backgroundWIndow", "red"), 0f, 1f, initialFogColour.r);
  30. greenSlider = new Slider(Translation.Get("backgroundWIndow", "green"), 0f, 1f, initialFogColour.g);
  31. blueSlider = new Slider(Translation.Get("backgroundWIndow", "blue"), 0f, 1f, initialFogColour.b);
  32. distanceSlider.ControlEvent += (s, a) =>
  33. {
  34. if (updating) return;
  35. EffectManager.Distance = distanceSlider.Value;
  36. };
  37. densitySlider.ControlEvent += (s, a) =>
  38. {
  39. if (updating) return;
  40. EffectManager.Density = densitySlider.Value;
  41. };
  42. heightScaleSlider.ControlEvent += (s, a) =>
  43. {
  44. if (updating) return;
  45. EffectManager.HeightScale = heightScaleSlider.Value;
  46. };
  47. heightSlider.ControlEvent += (s, a) =>
  48. {
  49. if (updating) return;
  50. EffectManager.Height = heightSlider.Value;
  51. };
  52. redSlider.ControlEvent += (s, a) =>
  53. {
  54. if (updating) return;
  55. EffectManager.FogColourRed = redSlider.Value;
  56. };
  57. greenSlider.ControlEvent += (s, a) =>
  58. {
  59. if (updating) return;
  60. EffectManager.FogColourGreen = greenSlider.Value;
  61. };
  62. blueSlider.ControlEvent += (s, a) =>
  63. {
  64. if (updating) return;
  65. EffectManager.FogColourBlue = blueSlider.Value;
  66. };
  67. }
  68. protected override void TranslatePane()
  69. {
  70. distanceSlider.Label = Translation.Get("effectFog", "distance");
  71. densitySlider.Label = Translation.Get("effectFog", "density");
  72. heightScaleSlider.Label = Translation.Get("effectFog", "strength");
  73. heightSlider.Label = Translation.Get("effectFog", "height");
  74. redSlider.Label = Translation.Get("backgroundWIndow", "red");
  75. greenSlider.Label = Translation.Get("backgroundWIndow", "green");
  76. blueSlider.Label = Translation.Get("backgroundWIndow", "blue");
  77. }
  78. protected override void UpdateControls()
  79. {
  80. distanceSlider.Value = EffectManager.Distance;
  81. densitySlider.Value = EffectManager.Density;
  82. heightScaleSlider.Value = EffectManager.HeightScale;
  83. heightSlider.Value = EffectManager.Height;
  84. redSlider.Value = EffectManager.FogColourRed;
  85. greenSlider.Value = EffectManager.FogColourGreen;
  86. blueSlider.Value = EffectManager.FogColourBlue;
  87. }
  88. protected override void DrawPane()
  89. {
  90. GUILayoutOption sliderWidth = MpsGui.HalfSlider;
  91. GUILayout.BeginHorizontal();
  92. distanceSlider.Draw(sliderWidth);
  93. densitySlider.Draw(sliderWidth);
  94. GUILayout.EndHorizontal();
  95. GUILayout.BeginHorizontal();
  96. heightScaleSlider.Draw(sliderWidth);
  97. heightSlider.Draw(sliderWidth);
  98. GUILayout.EndHorizontal();
  99. GUILayout.BeginHorizontal();
  100. redSlider.Draw(sliderWidth);
  101. greenSlider.Draw(sliderWidth);
  102. GUILayout.EndHorizontal();
  103. blueSlider.Draw(sliderWidth);
  104. }
  105. }
  106. }