OtherEffectsPane.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. public class OtherEffectsPane : BasePane
  5. {
  6. private readonly EffectManager effectManager;
  7. private readonly SepiaToneEffectManger sepiaToneEffectManger;
  8. private readonly BlurEffectManager blurEffectManager;
  9. private readonly Toggle sepiaToggle;
  10. private readonly Slider blurSlider;
  11. public OtherEffectsPane(EffectManager effectManager)
  12. {
  13. this.effectManager = effectManager;
  14. sepiaToneEffectManger = this.effectManager.Get<SepiaToneEffectManger>();
  15. blurEffectManager = this.effectManager.Get<BlurEffectManager>();
  16. sepiaToggle = new Toggle(Translation.Get("otherEffectsPane", "sepiaToggle"));
  17. sepiaToggle.ControlEvent += (s, a) =>
  18. {
  19. if (updating) return;
  20. sepiaToneEffectManger.SetEffectActive(sepiaToggle.Value);
  21. };
  22. blurSlider = new Slider(Translation.Get("otherEffectsPane", "blurSlider"), 0f, 18f);
  23. blurSlider.ControlEvent += (s, a) =>
  24. {
  25. float value = blurSlider.Value;
  26. if (!blurEffectManager.Active && value > 0f) blurEffectManager.SetEffectActive(true);
  27. else if (blurEffectManager.Active && value == 0f) blurEffectManager.SetEffectActive(false);
  28. if (blurEffectManager.Active) blurEffectManager.BlurSize = blurSlider.Value;
  29. };
  30. }
  31. protected override void ReloadTranslation()
  32. {
  33. sepiaToggle.Label = Translation.Get("otherEffectsPane", "sepiaToggle");
  34. blurSlider.Label = Translation.Get("otherEffectsPane", "blurSlider");
  35. }
  36. public override void Draw()
  37. {
  38. GUILayout.BeginHorizontal();
  39. sepiaToggle.Draw();
  40. blurSlider.Draw();
  41. GUILayout.EndHorizontal();
  42. }
  43. public override void UpdatePane()
  44. {
  45. if (sepiaToneEffectManger.Ready)
  46. {
  47. updating = true;
  48. sepiaToggle.Value = sepiaToneEffectManger.Active;
  49. updating = false;
  50. }
  51. if (blurEffectManager.Ready) blurSlider.Value = blurEffectManager.BlurSize;
  52. }
  53. }
  54. }