using System;
using System.Collections.Generic;
using UnityEngine;
using wf;

public class WindowPartsEffectVignetting : WindowPartsEffectBase
{
	public override void Awake()
	{
		base.Awake();
		this.vignetting_ = GameMain.Instance.MainCamera.GetComponent<Vignetting>();
		this.backup_intensity_ = this.vignetting_.intensity;
		this.backup_blur_ = this.vignetting_.blur;
		this.backup_blurspread_ = this.vignetting_.blurSpread;
		this.SettingInput.onChangeValue.Add(new Action<WindowPartsInputSliderSet.SliderAndInputSet, float>(this.OnChangetValue));
	}

	public override void OnDestroy()
	{
		if (GameMain.Instance == null || GameMain.Instance.MainCamera == null || this.vignetting_ == null)
		{
			return;
		}
		this.ResetValue();
		base.effect_enabled = false;
	}

	public override void OnChangeEffectEnabled(bool enabled)
	{
		this.SettingInput.enabled = enabled;
	}

	public override void Init()
	{
		this.value_vector_ = new Vector3(this.backup_intensity_, this.backup_blur_, this.backup_blurspread_);
		PhotoSliderAndInput sliderAndInput = this.SettingInput.GetSliderAndInput("intensity");
		PhotoSliderAndInput sliderAndInput2 = this.SettingInput.GetSliderAndInput("blur");
		PhotoSliderAndInput sliderAndInput3 = this.SettingInput.GetSliderAndInput("blurspread");
		sliderAndInput.ResetNum = this.value_vector_.x;
		sliderAndInput2.ResetNum = this.value_vector_.y;
		sliderAndInput3.ResetNum = this.value_vector_.z;
		this.EnabledCheckBox.check = false;
		this.UpdateGui();
	}

	private void ResetValue()
	{
		this.vignetting_.intensity = this.backup_intensity_;
		this.vignetting_.blur = this.backup_blur_;
		this.vignetting_.blurSpread = this.backup_blurspread_;
		base.effect_enabled = false;
	}

	public void OnChangetValue(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
	{
		if (input_object.Name == "intensity")
		{
			this.value_vector_.x = val;
		}
		else if (input_object.Name == "blur")
		{
			this.value_vector_.y = val;
		}
		else if (input_object.Name == "blurspread")
		{
			this.value_vector_.z = val;
		}
		this.vignetting_.intensity = this.value_vector_.x;
		this.vignetting_.blur = this.value_vector_.y;
		this.vignetting_.blurSpread = this.value_vector_.z;
	}

	public void UpdateGui()
	{
		PhotoSliderAndInput sliderAndInput = this.SettingInput.GetSliderAndInput("intensity");
		PhotoSliderAndInput sliderAndInput2 = this.SettingInput.GetSliderAndInput("blur");
		PhotoSliderAndInput sliderAndInput3 = this.SettingInput.GetSliderAndInput("blurspread");
		sliderAndInput.value = this.value_vector_.x;
		sliderAndInput2.value = this.value_vector_.y;
		sliderAndInput3.value = this.value_vector_.z;
		this.EnabledCheckBox.check = base.effect_enabled;
		this.OnChangeEffectEnabled(this.EnabledCheckBox.check);
	}

	public override void OnSerializeEvent()
	{
		Dictionary<string, Dictionary<string, string>> woldStoreData = this.effect_window_.GetWoldStoreData();
		woldStoreData["Vignetting"] = new Dictionary<string, string>();
		Dictionary<string, string> dictionary = woldStoreData["Vignetting"];
		dictionary.Add("value_vector", this.value_vector_.ToString("G9"));
		dictionary.Add("enabled", base.effect_enabled.ToString());
	}

	public override void OnDeserializeEvent()
	{
		Dictionary<string, Dictionary<string, string>> woldStoreData = this.effect_window_.GetWoldStoreData();
		if (!woldStoreData.ContainsKey("Vignetting"))
		{
			this.ResetValue();
			this.value_vector_.x = this.vignetting_.intensity;
			this.value_vector_.y = this.vignetting_.blur;
			this.value_vector_.z = this.vignetting_.blurSpread;
			this.EnabledCheckBox.check = base.effect_enabled;
		}
		else
		{
			Dictionary<string, string> dictionary = woldStoreData["Vignetting"];
			this.value_vector_ = Parse.Vector3(dictionary["value_vector"]);
			if (dictionary.ContainsKey("enabled"))
			{
				this.EnabledCheckBox.check = bool.Parse(dictionary["enabled"]);
			}
			else
			{
				this.EnabledCheckBox.check = (woldStoreData.ContainsKey("選択エフェクト") && int.Parse(woldStoreData["選択エフェクト"]["id"]) == 100);
			}
			base.effect_enabled = this.EnabledCheckBox.check;
			this.vignetting_.intensity = this.value_vector_.x;
			this.vignetting_.blur = this.value_vector_.y;
			this.vignetting_.blurSpread = this.value_vector_.z;
		}
		this.OnChangeEffectEnabled(this.EnabledCheckBox.check);
		this.UpdateGui();
	}

	protected override MonoBehaviour effect_object
	{
		get
		{
			return this.vignetting_;
		}
	}

	public WindowPartsInputSliderSet SettingInput;

	private Vignetting vignetting_;

	private float backup_intensity_;

	private float backup_blur_;

	private float backup_blurspread_;

	private Vector3 value_vector_;
}
