WindowPartsEffectVignetting.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. public class WindowPartsEffectVignetting : WindowPartsEffectBase
  6. {
  7. public override void Awake()
  8. {
  9. base.Awake();
  10. this.vignetting_ = GameMain.Instance.MainCamera.GetComponent<Vignetting>();
  11. this.backup_intensity_ = this.vignetting_.intensity;
  12. this.backup_blur_ = this.vignetting_.blur;
  13. this.backup_blurspread_ = this.vignetting_.blurSpread;
  14. this.SettingInput.onChangeValue.Add(new Action<WindowPartsInputSliderSet.SliderAndInputSet, float>(this.OnChangetValue));
  15. }
  16. public override void OnDestroy()
  17. {
  18. if (GameMain.Instance == null || GameMain.Instance.MainCamera == null || this.vignetting_ == null)
  19. {
  20. return;
  21. }
  22. this.ResetValue();
  23. base.effect_enabled = false;
  24. }
  25. public override void OnChangeEffectEnabled(bool enabled)
  26. {
  27. this.SettingInput.enabled = enabled;
  28. }
  29. public override void Init()
  30. {
  31. this.value_vector_ = new Vector3(this.backup_intensity_, this.backup_blur_, this.backup_blurspread_);
  32. PhotoSliderAndInput sliderAndInput = this.SettingInput.GetSliderAndInput("intensity");
  33. PhotoSliderAndInput sliderAndInput2 = this.SettingInput.GetSliderAndInput("blur");
  34. PhotoSliderAndInput sliderAndInput3 = this.SettingInput.GetSliderAndInput("blurspread");
  35. sliderAndInput.ResetNum = this.value_vector_.x;
  36. sliderAndInput2.ResetNum = this.value_vector_.y;
  37. sliderAndInput3.ResetNum = this.value_vector_.z;
  38. this.EnabledCheckBox.check = false;
  39. this.UpdateGui();
  40. }
  41. private void ResetValue()
  42. {
  43. this.vignetting_.intensity = this.backup_intensity_;
  44. this.vignetting_.blur = this.backup_blur_;
  45. this.vignetting_.blurSpread = this.backup_blurspread_;
  46. base.effect_enabled = false;
  47. }
  48. public void OnChangetValue(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
  49. {
  50. if (input_object.Name == "intensity")
  51. {
  52. this.value_vector_.x = val;
  53. }
  54. else if (input_object.Name == "blur")
  55. {
  56. this.value_vector_.y = val;
  57. }
  58. else if (input_object.Name == "blurspread")
  59. {
  60. this.value_vector_.z = val;
  61. }
  62. this.vignetting_.intensity = this.value_vector_.x;
  63. this.vignetting_.blur = this.value_vector_.y;
  64. this.vignetting_.blurSpread = this.value_vector_.z;
  65. }
  66. public void UpdateGui()
  67. {
  68. PhotoSliderAndInput sliderAndInput = this.SettingInput.GetSliderAndInput("intensity");
  69. PhotoSliderAndInput sliderAndInput2 = this.SettingInput.GetSliderAndInput("blur");
  70. PhotoSliderAndInput sliderAndInput3 = this.SettingInput.GetSliderAndInput("blurspread");
  71. sliderAndInput.value = this.value_vector_.x;
  72. sliderAndInput2.value = this.value_vector_.y;
  73. sliderAndInput3.value = this.value_vector_.z;
  74. this.EnabledCheckBox.check = base.effect_enabled;
  75. this.OnChangeEffectEnabled(this.EnabledCheckBox.check);
  76. }
  77. public override void OnSerializeEvent()
  78. {
  79. Dictionary<string, Dictionary<string, string>> woldStoreData = this.effect_window_.GetWoldStoreData();
  80. woldStoreData["Vignetting"] = new Dictionary<string, string>();
  81. Dictionary<string, string> dictionary = woldStoreData["Vignetting"];
  82. dictionary.Add("value_vector", this.value_vector_.ToString("G9"));
  83. dictionary.Add("enabled", base.effect_enabled.ToString());
  84. }
  85. public override void OnDeserializeEvent()
  86. {
  87. Dictionary<string, Dictionary<string, string>> woldStoreData = this.effect_window_.GetWoldStoreData();
  88. if (!woldStoreData.ContainsKey("Vignetting"))
  89. {
  90. this.ResetValue();
  91. this.value_vector_.x = this.vignetting_.intensity;
  92. this.value_vector_.y = this.vignetting_.blur;
  93. this.value_vector_.z = this.vignetting_.blurSpread;
  94. this.EnabledCheckBox.check = base.effect_enabled;
  95. }
  96. else
  97. {
  98. Dictionary<string, string> dictionary = woldStoreData["Vignetting"];
  99. this.value_vector_ = Parse.Vector3(dictionary["value_vector"]);
  100. if (dictionary.ContainsKey("enabled"))
  101. {
  102. this.EnabledCheckBox.check = bool.Parse(dictionary["enabled"]);
  103. }
  104. else
  105. {
  106. this.EnabledCheckBox.check = (woldStoreData.ContainsKey("選択エフェクト") && int.Parse(woldStoreData["選択エフェクト"]["id"]) == 100);
  107. }
  108. base.effect_enabled = this.EnabledCheckBox.check;
  109. this.vignetting_.intensity = this.value_vector_.x;
  110. this.vignetting_.blur = this.value_vector_.y;
  111. this.vignetting_.blurSpread = this.value_vector_.z;
  112. }
  113. this.OnChangeEffectEnabled(this.EnabledCheckBox.check);
  114. this.UpdateGui();
  115. }
  116. protected override MonoBehaviour effect_object
  117. {
  118. get
  119. {
  120. return this.vignetting_;
  121. }
  122. }
  123. public WindowPartsInputSliderSet SettingInput;
  124. private Vignetting vignetting_;
  125. private float backup_intensity_;
  126. private float backup_blur_;
  127. private float backup_blurspread_;
  128. private Vector3 value_vector_;
  129. }