using System;
using System.Collections;
using UnityEngine;

public class ConfigMgr : BaseMgr<ConfigMgr>
{
	private void Start()
	{
	}

	private void Init()
	{
		string rootPath = "__GameMain__/SystemUI Root";
		this.m_goPanel = base.GetPanel("ConfigPanel", rootPath);
		this.m_configCtrl = base.GetCtrl<ConfigCtrl>();
		this.m_configCtrl.Init(this.m_goPanel);
		this.m_uiPanel = this.m_goPanel.GetComponent<UIPanel>();
		this.m_goPanel.SetActive(false);
		this.m_bInited = true;
		this.ChangeNormalConfig();
	}

	public bool IsOpenConfigPanel()
	{
		return !(this.m_goPanel == null) && this.m_goPanel.activeSelf;
	}

	public void OnSysButtonShowAlwaysEnabled()
	{
		this.m_configCtrl.SetButtonShowAlwaysEnabled(true);
	}

	public void OnSysButtonShowAlwaysDisabled()
	{
		this.m_configCtrl.SetButtonShowAlwaysEnabled(false);
	}

	public void OnFullScreenEnabled()
	{
		this.m_configCtrl.SetFullScreenEnabled(true);
	}

	public void OnFullScreenDisabled()
	{
		this.m_configCtrl.SetFullScreenEnabled(false);
	}

	public void OnResolutionChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		string value = UIPopupList.current.value;
		this.m_configCtrl.ChangePopupListResolutionValue(value);
	}

	public void OnAntiAliasChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		string value = UIPopupList.current.value;
		base.IsValidatePopupValue<CMSystem.AntiAliasType>(value);
		this.m_configCtrl.ChangePopupListValue<CMSystem.AntiAliasType>(value);
	}

	public void OnShadowQualityChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		string value = UIPopupList.current.value;
		base.IsValidatePopupValue<CMSystem.ShadowQualityType>(value);
		this.m_configCtrl.ChangePopupListValue<CMSystem.ShadowQualityType>(value);
	}

	public void OnTextureQualityChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		string value = UIPopupList.current.value;
		base.IsValidatePopupValue<CMSystem.TextureQualityType>(value);
		this.m_configCtrl.ChangePopupListValue<CMSystem.TextureQualityType>(value);
	}

	public void OnFpsDisplayEnabled()
	{
		this.m_configCtrl.SetFpsDisplayEnabled(true);
	}

	public void OnFpsDisplayDisabled()
	{
		this.m_configCtrl.SetFpsDisplayEnabled(false);
	}

	public void OnCaptureMagnificationChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		string value = UIPopupList.current.value;
		base.IsValidatePopupValue<CMSystem.SSSuperSizeType>(value);
		this.m_configCtrl.ChangePopupListValue<CMSystem.SSSuperSizeType>(value);
	}

	public void OnSubtitleDisplayTypeChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		string value = UIPopupList.current.value;
		this.SubtitleDisplayTypeChange(value);
	}

	public void SubtitleDisplayTypeChange(string typeName)
	{
		IEnumerator enumerator = Enum.GetValues(typeof(SubtitleDisplayManager.DisplayType)).GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				string term = SubtitleDisplayManager.EnumConvert.GetTerm((SubtitleDisplayManager.DisplayType)obj);
				if (typeName == term)
				{
					GameMain.Instance.CMSystem.SubtitleType = (SubtitleDisplayManager.DisplayType)obj;
					break;
				}
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
	}

	public void OnBloomChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.Bloom, value);
	}

	public void OnPlayerModelTransparencyChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.PlayerModelTransparency, value);
	}

	public void OnMessageWindowTransparencyChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.MessageWindowTransparency, value);
	}

	public void OnTextSpeedChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.TextSpeed, value);
	}

	public void OnAutoSpeedChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.AutoSpeed, value);
	}

	public void OnMasterVolumeChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.MasterVolume, value);
	}

	public void OnSystemVolumeChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.SystemVolume, value);
	}

	public void OnMusicVolumeChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.MusicVolume, value);
	}

	public void OnDanceVolumeChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.DanceVolume, value);
	}

	public void OnVoiceVolumeChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.VoiceVolume, value);
	}

	public void OnSoundEffectVolumeChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.SoundEffectVolume, value);
	}

	public void OnSoundEnvironmentVolumeChange()
	{
		if (!this.m_bInited)
		{
			return;
		}
		float value = UIProgressBar.current.value;
		this.m_configCtrl.ChangeSliderValue(ConfigMgr.SliderType.SoundEnvironmentVolume, value);
	}

	public void OnAlreadyReadSkipEnabled()
	{
		this.m_configCtrl.SetAlreadyReadSkipEnabled(true);
	}

	public void OnAlreadyReadSkipDisabled()
	{
		this.m_configCtrl.SetAlreadyReadSkipEnabled(false);
	}

	public void OnSequentialVoiceEnabled()
	{
		this.m_configCtrl.SetSequentialVoiceEnabled(true);
	}

	public void OnSequentialVoiceDisabled()
	{
		this.m_configCtrl.SetSequentialVoiceEnabled(false);
	}

	public void SetEjaculationSeEnabled()
	{
		this.m_configCtrl.SetEjaculationSeEnabled(true);
	}

	public void SetEjaculationSeDisabled()
	{
		this.m_configCtrl.SetEjaculationSeEnabled(false);
	}

	public void OnMusic3DActive()
	{
		this.m_configCtrl.SetMusic3DActive();
	}

	public void OnVoice3DActive()
	{
		this.m_configCtrl.SetVoice3DActive();
	}

	public void OnSoundEffect3DActive()
	{
		this.m_configCtrl.SetSoundEffect3DActive();
	}

	public void OnSoundEnvironment3DActive()
	{
		this.m_configCtrl.SetSoundEnvironment3DActive();
	}

	public void OpenConfigPanel()
	{
		if (!this.m_bInited)
		{
			this.Init();
		}
		this.m_configCtrl.LoadConfigData();
		this.m_configCtrl.SetOKButtonActive(true);
		this.m_goPanel.SetActive(true);
		TweenAlpha tweenAlpha = this.m_goPanel.AddComponent<TweenAlpha>();
		tweenAlpha.from = 0f;
		tweenAlpha.to = 1f;
		tweenAlpha.duration = 0.3f;
		tweenAlpha.PlayForward();
	}

	public void CloseConfigPanel()
	{
		this.m_configCtrl.SetOKButtonActive(false);
		this.cblConfig.OnClose();
		TweenAlpha tweenAlpha = TweenAlpha.Begin(this.m_goPanel, 0.3f, 0f);
		EventDelegate.Set(tweenAlpha.onFinished, delegate()
		{
			this.m_goPanel.SetActive(false);
		});
		GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver);
	}

	public void ChangeNormalConfig()
	{
		this.m_configCtrl.SetContentsVisible(true);
		this.cblConfig.visible = false;
	}

	public void ChangeCBLConfig()
	{
		this.m_configCtrl.SetContentsVisible(false);
		this.cblConfig.visible = true;
	}

	public void Update()
	{
		int num = int.MinValue;
		if (Input.GetKeyDown(KeyCode.F1))
		{
			num = 0;
		}
		else if (Input.GetKeyDown(KeyCode.F2))
		{
			num = 1;
		}
		else if (Input.GetKeyDown(KeyCode.F3))
		{
			num = 2;
		}
		else if (Input.GetKeyDown(KeyCode.F4))
		{
			num = 3;
		}
		if (num != -2147483648)
		{
			if (this.m_configCtrl == null)
			{
				GameMain.Instance.CMSystem.SubtitleType = (SubtitleDisplayManager.DisplayType)num;
			}
			else
			{
				this.m_configCtrl.m_plSubtitleType.value = SubtitleDisplayManager.EnumConvert.GetTerm((SubtitleDisplayManager.DisplayType)num);
			}
		}
	}

	[SerializeField]
	public ConfigCblManager cblConfig;

	private ConfigCtrl m_configCtrl;

	private const float DURATION_TO_FADE = 0.3f;

	private UIPanel m_uiPanel;

	private bool m_bInited;

	public enum SliderType
	{
		Bloom,
		PlayerModelTransparency,
		MessageWindowTransparency,
		TextSpeed,
		AutoSpeed,
		MasterVolume,
		SystemVolume,
		MusicVolume,
		DanceVolume,
		VoiceVolume,
		SoundEffectVolume,
		SoundEnvironmentVolume
	}
}
