FogPane.cs 4.8 KB

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