using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Colorful;
using DarkTonic.MasterAudio;
using PI.NGSS;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// Token: 0x020000C6 RID: 198
public class Options : MonoBehaviour
{
	// Token: 0x0600125C RID: 4700 RVA: 0x001648C0 File Offset: 0x00162AC0
	private void Awake()
	{
		this.contents1.SetActive(false);
		this.contents2.SetActive(false);
		this.contents3.SetActive(false);
		this.setting = true;
		if (!ES3.FileExists("Settings.es3"))
		{
			Debug.Log("Starting new game");
			this.nofile = true;
			ES3.Save<int>("_", 0, "Settings.es3");
		}
		try
		{
			ES3.KeyExists("_", "Settings.es3");
		}
		catch (IOException)
		{
			Debug.Log("error");
		}
		try
		{
			this.saveFile = new ES3File("Settings.es3");
		}
		catch (IOException)
		{
			Debug.Log("No save file created");
		}
	}

	// Token: 0x0600125D RID: 4701 RVA: 0x00164984 File Offset: 0x00162B84
	private void Start()
	{
		this.anim.enabled = false;
		Links.x.options = this;
		this.canvas.enabled = false;
		if (!Records.x.windows)
		{
			this.scrollRect1.scrollSensitivity = 9f;
		}
		this.confirmResolutionBox.SetActive(false);
	}

	// Token: 0x0600125E RID: 4702 RVA: 0x001649DC File Offset: 0x00162BDC
	public void LoadOptions()
	{
		this.setting = true;
		if (this.saveFile == null)
		{
			ES3.DeleteFile("Settings.es3");
			this.nofile = true;
			ES3.Save<int>("_", 0, "Settings.es3");
			this.saveFile = new ES3File("Settings.es3");
		}
		if (!this.saveFile.KeyExists("Quality Level") || !this.saveFile.KeyExists("V Sync") || !this.saveFile.KeyExists("Framerate Cap") || !this.saveFile.KeyExists("Antialiasing") || !this.saveFile.KeyExists("Quality Level") || !this.saveFile.KeyExists("Sound Volume") || !this.saveFile.KeyExists("Quality Level") || !this.saveFile.KeyExists("Windowed Mode"))
		{
			this.nofile = true;
		}
		if (this.nofile)
		{
			this.saveFile.Save<int>("V Sync", 1);
			this.saveFile.Save<int>("Framerate Cap", 60);
			if ((float)Screen.height < 1000f)
			{
				this.saveFile.Save<int>("Antialiasing", 0);
			}
			else
			{
				this.saveFile.Save<int>("Antialiasing", 1);
			}
			this.saveFile.Save<int>("Quality Level", 1);
			this.saveFile.Save<float>("Sound Volume", 5f);
			this.saveFile.Save<float>("Music Volume", 5f);
			this.saveFile.Save<int>("Windowed Mode", 0);
			this.saveFile.Save<float>("Camera Zoom", 0.5f);
			this.saveFile.Save<bool>("Use Controller", false);
			this.saveFile.Save<int>("Game Feed Int", 1);
			Records.x.usingController = false;
			this.saveFile.Save<bool>("Pathfinding", true);
			if (Links.x)
			{
				Links.x.pathfind = true;
			}
			this.saveFile.Save<int>("Screen Width", Screen.width);
			this.saveFile.Save<int>("Screen Height", Screen.height);
			this.saveFile.Sync();
		}
		this.vsync.value = (float)this.saveFile.Load<int>("V Sync");
		this.Vsync(false);
		QualitySettings.vSyncCount = (int)this.vsync.value;
		this.framerate.value = (float)this.saveFile.Load<int>("Framerate Cap");
		this.Framerate(false);
		this.antialiasing.value = (float)this.saveFile.Load<int>("Antialiasing");
		this.Antialiasing(false);
		this.quality.value = (float)this.saveFile.Load<int>("Quality Level");
		this.Quality(false);
		this.sound.value = this.saveFile.Load<float>("Sound Volume");
		this.Sound(false);
		this.music.value = this.saveFile.Load<float>("Music Volume");
		this.Music(false);
		this.zoom.value = this.saveFile.Load<float>("Camera Zoom");
		this.Zoom(false);
		this.screenResW = this.saveFile.Load<int>("Screen Width");
		this.screenResH = this.saveFile.Load<int>("Screen Height");
		if (this.saveFile.KeyExists("Game Feed Int"))
		{
			this.gameFeedState = this.saveFile.Load<int>("Game Feed Int");
		}
		else
		{
			this.gameFeedState = 1;
		}
		this.gameFeed.value = (float)this.gameFeedState;
		this.GameFeed(false);
		Links.x.gameFeed.SetState(this.gameFeedState);
		if (Links.x.pathfind)
		{
			this.pathfindingCheckbox.sprite = this.checkSprite;
		}
		else
		{
			this.pathfindingCheckbox.sprite = this.emptySprite;
		}
		if ((!Records.x.usingController || (Records.x.usingController && Links.x.gameplay.currentControllerCount == 0)) && this.saveFile.KeyExists("Use Controller"))
		{
			Records.x.usingController = this.saveFile.Load<bool>("Use Controller");
		}
		if (this.saveFile.KeyExists("Pathfinding"))
		{
			Links.x.pathfind = this.saveFile.Load<bool>("Pathfinding");
		}
		else
		{
			Links.x.pathfind = true;
		}
		if (this.saveFile.KeyExists("ScreenShake"))
		{
			this.screenShaking = this.saveFile.Load<bool>("ScreenShake");
			if (this.screenShaking)
			{
				this.screenShake.value = 1f;
			}
			else
			{
				this.screenShake.value = 0f;
			}
			this.ScreenShake(false);
		}
		else
		{
			this.screenShaking = true;
			this.screenShake.value = 1f;
		}
		if (this.saveFile.KeyExists("Brightness"))
		{
			this.bright = this.saveFile.Load<float>("Brightness");
			this.brightness.value = this.bright;
			this.Brightness(false);
		}
		else
		{
			this.bright = 0f;
			this.brightness.value = this.bright;
		}
		if (this.saveFile.KeyExists("RallyTimePrompt"))
		{
			this.rallyTimePrompt = this.saveFile.Load<bool>("RallyTimePrompt");
			if (this.rallyTimePrompt)
			{
				this.qte.value = 1f;
			}
			else
			{
				this.qte.value = 0f;
			}
			this.QTE(false);
		}
		else
		{
			this.rallyTimePrompt = true;
			this.qte.value = 1f;
		}
		this.ControlScheme(false);
		this.showingAllResolutions = false;
		this.SetResolutions(true, this.screenResW, this.screenResH, false);
		Links.x.gameplay.keyControl.Setup();
		if (Records.x.windows)
		{
			this.bcg.enabled = true;
			return;
		}
		this.bcg.enabled = true;
	}

	// Token: 0x0600125F RID: 4703 RVA: 0x00164FF4 File Offset: 0x001631F4
	public void ToggleExtraResolutions()
	{
		if (this.showingAllResolutions)
		{
			this.resolutionBtnText.text = "More Resolutions";
			this.SetResolutions(false, this.screenResW, this.screenResH, false);
			this.showingAllResolutions = false;
			return;
		}
		this.resolutionBtnText.text = "Less Resolutions";
		this.SetResolutions(false, this.screenResW, this.screenResH, true);
		this.showingAllResolutions = true;
	}

	// Token: 0x06001260 RID: 4704 RVA: 0x00165060 File Offset: 0x00163260
	private void SetResolutions(bool setResolution, int screenResW, int screenResH, bool extras)
	{
		this.setting = true;
		float num = (float)Screen.width / (float)Screen.height;
		this.resolutions = Screen.resolutions;
		int num2 = 0;
		for (int i = 0; i < this.resolutionData.Count; i++)
		{
			this.resolutionData[i].gameObject.SetActive(false);
			this.resolutionData[i].gameObject.GetComponent<Toggle>().isOn = false;
		}
		Data data = null;
		for (int j = 0; j < this.resolutionData.Count; j++)
		{
			if (j < this.resolutions.Length && (float)this.resolutions[j].width > 1000f)
			{
				if (Records.x.steamDeck)
				{
					if (j == 0)
					{
						this.AddResolution(num2, 1200, 800);
						data = this.resolutionData[num2];
						num2++;
					}
				}
				else
				{
					this.AddResolution(num2, this.resolutions[j].width, this.resolutions[j].height);
					data = this.resolutionData[num2];
					num2++;
				}
			}
		}
		if (extras)
		{
			if (!this.HasScreenResW(1280))
			{
				this.AddResolution(num2, 1280, 720);
				data = this.resolutionData[num2];
				num2++;
			}
			if (!this.HasScreenResW(1600))
			{
				this.AddResolution(num2, 1600, 900);
				data = this.resolutionData[num2];
				num2++;
			}
			if (!this.HasScreenResW(1920))
			{
				this.AddResolution(num2, 1920, 1080);
				data = this.resolutionData[num2];
				num2++;
			}
			if (!this.HasScreenResW(2560))
			{
				this.AddResolution(num2, 2560, 1440);
				data = this.resolutionData[num2];
				num2++;
			}
			if (!this.HasScreenResW(2880))
			{
				this.AddResolution(num2, 2880, 1620);
				data = this.resolutionData[num2];
				num2++;
			}
			if (!this.HasScreenResW(3200))
			{
				this.AddResolution(num2, 3200, 1800);
				data = this.resolutionData[num2];
				num2++;
			}
			if (!this.HasScreenResW(3840))
			{
				this.AddResolution(num2, 3840, 2160);
				data = this.resolutionData[num2];
				num2++;
			}
			if (!this.HasScreenResW(5120))
			{
				this.AddResolution(num2, 5120, 2880);
				data = this.resolutionData[num2];
				num2++;
			}
		}
		if (!this.HasScreenResW(Screen.width))
		{
			this.AddResolution(num2, Screen.width, Screen.height);
			data = this.resolutionData[num2];
			num2++;
		}
		if (!this.HasScreenResW(screenResW) && screenResW != 0)
		{
			this.AddResolution(num2, screenResW, screenResH);
			data = this.resolutionData[num2];
			num2++;
		}
		if (data)
		{
			Navigation navigation = data.gameObject.GetComponent<Toggle>().navigation;
			navigation.selectOnDown = this.moreResolutionsBtn;
			data.gameObject.GetComponent<Toggle>().navigation = navigation;
			navigation = this.moreResolutionsBtn.navigation;
			navigation.selectOnDown = data.gameObject.GetComponent<Toggle>();
			this.moreResolutionsBtn.navigation = navigation;
			this.FrameRateNav();
		}
		if (!setResolution)
		{
			this.setting = false;
			return;
		}
		if (this.saveFile.Load<int>("Windowed Mode") == 0)
		{
			this.SetResolution(true);
			return;
		}
		this.SetResolution(false);
	}

	// Token: 0x06001261 RID: 4705 RVA: 0x001653F8 File Offset: 0x001635F8
	private void FrameRateNav()
	{
		Navigation navigation = this.vsync.navigation;
		if (this.framerate.interactable)
		{
			navigation.selectOnDown = this.framerate;
		}
		else
		{
			navigation.selectOnDown = this.creditsButton;
		}
		this.vsync.navigation = navigation;
		navigation = this.creditsButton.navigation;
		if (this.framerate.interactable)
		{
			navigation.selectOnUp = this.framerate;
		}
		else
		{
			navigation.selectOnUp = this.vsync;
		}
		this.creditsButton.navigation = navigation;
	}

	// Token: 0x06001262 RID: 4706 RVA: 0x00165487 File Offset: 0x00163687
	public void ResolutionButton(Data data)
	{
		if (data.gameObject.GetComponent<Toggle>().isOn && !this.setting)
		{
			this.confirmData = data;
			this.SetResolutionFromConfirm();
		}
	}

	// Token: 0x06001263 RID: 4707 RVA: 0x001654B0 File Offset: 0x001636B0
	public void SetResolutionFromConfirm()
	{
		if (!this.setting)
		{
			this.screenResW = this.confirmData.x;
			this.screenResH = this.confirmData.y;
			this.saveFile.Save<int>("Screen Width", this.confirmData.x);
			this.saveFile.Save<int>("Screen Height", this.confirmData.y);
			this.saveFile.Sync();
			this.SetResolution(Screen.fullScreen);
		}
	}

	// Token: 0x06001264 RID: 4708 RVA: 0x00165533 File Offset: 0x00163733
	public void SetResolution(bool fullscreen)
	{
		this.setting = true;
		Screen.SetResolution(this.screenResW, this.screenResH, fullscreen);
		base.StartCoroutine(this.SetResFrameLater(fullscreen));
	}

	// Token: 0x06001265 RID: 4709 RVA: 0x0016555C File Offset: 0x0016375C
	private IEnumerator SetResFrameLater(bool fullscreen)
	{
		yield return new WaitForSecondsRealtime(0.1f);
		Links.x.cameraEffects.UpdateShaderVariables();
		this.setting = false;
		if (fullscreen)
		{
			this.fullscreenCheckbox.sprite = this.checkSprite;
		}
		else
		{
			this.fullscreenCheckbox.sprite = this.emptySprite;
		}
		yield break;
	}

	// Token: 0x06001266 RID: 4710 RVA: 0x00165574 File Offset: 0x00163774
	private void AddResolution(int count, int width, int height)
	{
		if (count < this.resolutionData.Count)
		{
			this.resolutionData[count].gameObject.SetActive(true);
			this.resolutionData[count].x = width;
			this.resolutionData[count].y = height;
			this.resolutionData[count].gameObject.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = width.ToString() + " x " + height.ToString();
			this.resolutionData[count].gameObject.GetComponent<Toggle>().isOn = false;
			if (this.resolutionData[count].x == Screen.width)
			{
				this.resolutionData[count].gameObject.GetComponent<Toggle>().isOn = true;
			}
		}
	}

	// Token: 0x06001267 RID: 4711 RVA: 0x00165660 File Offset: 0x00163860
	private bool HasScreenResW(int x)
	{
		for (int i = 0; i < this.resolutionData.Count; i++)
		{
			if (this.resolutionData[i].x == x && this.resolutionData[i].gameObject.activeSelf)
			{
				return true;
			}
		}
		return false;
	}

	// Token: 0x06001268 RID: 4712 RVA: 0x001656B4 File Offset: 0x001638B4
	public void SaveOptions()
	{
		if (this.setting)
		{
			return;
		}
		this.saveFile.Save<int>("V Sync", (int)this.vsync.value);
		this.saveFile.Save<int>("Framerate Cap", (int)this.framerate.value);
		this.saveFile.Save<int>("Antialiasing", (int)this.antialiasing.value);
		this.saveFile.Save<int>("Quality Level", (int)this.quality.value);
		this.saveFile.Save<float>("Sound Volume", this.sound.value);
		this.saveFile.Save<float>("Music Volume", this.music.value);
		if (Screen.fullScreen)
		{
			this.saveFile.Save<int>("Windowed Mode", 0);
		}
		else
		{
			this.saveFile.Save<int>("Windowed Mode", 1);
		}
		if (this.screenResW != 0)
		{
			this.saveFile.Save<int>("Screen Width", this.screenResW);
			this.saveFile.Save<int>("Screen Height", this.screenResH);
		}
		else
		{
			this.saveFile.Save<int>("Screen Width", Screen.width);
			this.saveFile.Save<int>("Screen Height", Screen.height);
		}
		this.saveFile.Save<int>("Game Feed Int", this.gameFeedState);
		this.saveFile.Save<bool>("Pathfinding", Links.x.pathfind);
		this.saveFile.Save<float>("Brightness", this.brightness.value);
		this.saveFile.Save<bool>("RallyTimePrompt", this.rallyTimePrompt);
		this.saveFile.Save<bool>("ScreenShake", this.screenShake);
		this.saveFile.Save<bool>("Use Controller", Records.x.usingController);
		this.saveFile.Sync();
	}

	// Token: 0x06001269 RID: 4713 RVA: 0x0016589C File Offset: 0x00163A9C
	public void Vsync(bool fromSlider)
	{
		string text = "Off";
		int num = 0;
		this.framerate.interactable = true;
		this.frameCapText.color = this.textColorNormal;
		if (this.vsync.value == 1f)
		{
			text = "On (60)";
			num = 1;
			Application.targetFrameRate = 60;
			this.framerate.value = 60f;
			this.framerate.interactable = false;
			this.frameCapText.color = this.textColorInactive;
			this.frameCapText.text = "Framerate Cap: 60";
		}
		if (this.vsync.value == 2f)
		{
			text = "On (30)";
			num = 1;
			Application.targetFrameRate = 30;
			this.framerate.value = 30f;
			this.framerate.interactable = false;
			this.frameCapText.color = this.textColorInactive;
			this.frameCapText.text = "Framerate Cap: 30";
		}
		if (QualitySettings.vSyncCount != num)
		{
			if (num == 0)
			{
				QualitySettings.vSyncCount = num;
			}
			else if (num == 1)
			{
				QualitySettings.vSyncCount = num;
			}
			else if (num == 2)
			{
				QualitySettings.vSyncCount = num;
			}
		}
		this.vsyncText.text = "V Sync: " + text;
		if (fromSlider)
		{
			this.SaveOptions();
			this.FrameRateNav();
		}
	}

	// Token: 0x0600126A RID: 4714 RVA: 0x001659D8 File Offset: 0x00163BD8
	public void Framerate(bool fromSlider)
	{
		int num = (int)this.framerate.value;
		string text = num.ToString();
		if (!fromSlider)
		{
			Application.targetFrameRate = num;
		}
		this.frameCapText.text = "Framerate Cap: " + text;
		if (fromSlider)
		{
			this.SaveOptions();
		}
	}

	// Token: 0x0600126B RID: 4715 RVA: 0x00165A24 File Offset: 0x00163C24
	public void Antialiasing(bool fromSlider)
	{
		string text = "Off";
		int num = 0;
		if (this.antialiasing.value == 1f)
		{
			text = "2x";
			num = 2;
		}
		if (this.antialiasing.value == 2f)
		{
			text = "4x";
			num = 4;
		}
		if (this.antialiasing.value == 3f)
		{
			text = "8x";
			num = 8;
		}
		QualitySettings.antiAliasing = num;
		this.antialiasingText.text = "Antialiasing: " + text;
		if (fromSlider)
		{
			this.SaveOptions();
			Links.x.cameraEffects.CreateTexture(false);
			Links.x.characterSheet.SetupTexture();
			Links.x.renderPortraits.UpdateAA();
			Links.x.cameraEffects.UpdateShaderVariables();
		}
	}

	// Token: 0x0600126C RID: 4716 RVA: 0x00165AEC File Offset: 0x00163CEC
	public void GameFeed(bool fromSlider)
	{
		string text = "Hide Game Feed";
		this.gameFeedState = 0;
		if (this.gameFeed.value > 0.5f && this.gameFeed.value < 1.5f)
		{
			text = "Show Game Feed";
			this.gameFeedState = 1;
		}
		if (this.gameFeed.value > 1.5f && this.gameFeed.value < 3f)
		{
			text = "Show Game Feed + Calculations";
			this.gameFeedState = 2;
		}
		this.gameFeedText.text = text;
		if (!this.setting && fromSlider)
		{
			Links.x.gameFeed.SetState(this.gameFeedState);
			this.SaveOptions();
		}
	}

	// Token: 0x0600126D RID: 4717 RVA: 0x00165B9C File Offset: 0x00163D9C
	public void Quality(bool fromSlider)
	{
		string text = "Normal";
		if (this.quality.value == 0f)
		{
			text = "Low";
			this.graphicsQuality = 0;
			QualitySettings.shadowResolution = ShadowResolution.Low;
			Links.x.cameraEffects.gameObject.GetComponent<NGSS_FrustumShadows>().m_raySamples = 40;
			if (Links.x.diorama)
			{
				Links.x.diorama.SetTerrainQuality(0f);
			}
		}
		if (this.quality.value == 1f)
		{
			text = "Normal";
			this.graphicsQuality = 1;
			QualitySettings.shadowResolution = ShadowResolution.High;
			Links.x.cameraEffects.gameObject.GetComponent<NGSS_FrustumShadows>().m_raySamples = 57;
			if (Links.x.diorama)
			{
				Links.x.diorama.SetTerrainQuality(0.6f);
			}
		}
		if (this.quality.value == 2f)
		{
			text = "High";
			this.graphicsQuality = 2;
			if (Links.x.diorama)
			{
				Links.x.diorama.SetTerrainQuality(1f);
			}
			QualitySettings.shadowResolution = ShadowResolution.VeryHigh;
			Links.x.cameraEffects.gameObject.GetComponent<NGSS_FrustumShadows>().m_raySamples = 60;
		}
		this.qualityText.text = "Graphics Quality: " + text;
		if (fromSlider)
		{
			this.SaveOptions();
		}
	}

	// Token: 0x0600126E RID: 4718 RVA: 0x00165CFD File Offset: 0x00163EFD
	public void ResetDockPositions()
	{
		Links.x.gameFeed.ShowNotice("Dock Reset");
		Links.x.hudControl.SetWindowsAtStartPosition();
	}

	// Token: 0x0600126F RID: 4719 RVA: 0x00165D24 File Offset: 0x00163F24
	public bool CheckControllers()
	{
		string[] joystickNames = Input.GetJoystickNames();
		bool flag = false;
		string[] array = joystickNames;
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i] != "")
			{
				flag = true;
			}
		}
		return flag;
	}

	// Token: 0x06001270 RID: 4720 RVA: 0x00165D59 File Offset: 0x00163F59
	public void SetKeys()
	{
	}

	// Token: 0x06001271 RID: 4721 RVA: 0x00165D5C File Offset: 0x00163F5C
	public void SetSlider()
	{
		float x = Links.x.fellowship.direction.x;
		GameObject currentEventObject = Links.x.gameplay.currentEventObject;
		Slider slider = null;
		if (currentEventObject == this.vsync.gameObject)
		{
			slider = this.vsync;
		}
		if (currentEventObject == this.framerate.gameObject)
		{
			slider = this.framerate;
		}
		if (currentEventObject == this.quality.gameObject)
		{
			slider = this.quality;
		}
		if (currentEventObject == this.antialiasing.gameObject)
		{
			slider = this.antialiasing;
		}
		if (currentEventObject == this.sound.gameObject)
		{
			slider = this.sound;
		}
		if (currentEventObject == this.music.gameObject)
		{
			slider = this.music;
		}
		if (currentEventObject == this.gameFeed.gameObject)
		{
			slider = this.gameFeed;
		}
		float num = 1f;
		if (slider && (Time.realtimeSinceStartup > this.lastSliderTime + 0.3f || this.lastSliderTime == 0f))
		{
			if (x > 0f)
			{
				slider.value += num;
			}
			else if (x < 0f)
			{
				slider.value -= num;
			}
			if (slider == this.framerate)
			{
				this.lastSliderTime = Time.realtimeSinceStartup - 0.2f;
				return;
			}
			this.lastSliderTime = Time.realtimeSinceStartup;
		}
	}

	// Token: 0x06001272 RID: 4722 RVA: 0x00165ECC File Offset: 0x001640CC
	public void UseMK()
	{
		if (this.mk.isOn)
		{
			Records.x.usingController = false;
			this.ControlScheme(true);
			this.keys.SetActive(true);
			Cursor.lockState = CursorLockMode.None;
			Cursor.visible = true;
			this.SetKeys();
			Links.x.hudControl.SwitchController(false);
			this.cancelButton.CheckController(false);
			Links.x.fellowship.UpdateHotkeys();
			if (this.open)
			{
				Links.x.hudControl.CloseMenuSwitcher();
			}
			Links.x.pocketWheel.SetHotkeys(true);
		}
	}

	// Token: 0x06001273 RID: 4723 RVA: 0x00165F6C File Offset: 0x0016416C
	public void UsePathfindingMK()
	{
		if (this.mkPathfind.isOn)
		{
			Records.x.usingController = false;
			this.ControlScheme(true);
			this.keys.SetActive(true);
			Cursor.lockState = CursorLockMode.None;
			Cursor.visible = true;
			this.SetKeys();
			Links.x.hudControl.SwitchController(false);
			this.cancelButton.CheckController(false);
			Links.x.fellowship.UpdateHotkeys();
			if (this.open)
			{
				Links.x.hudControl.CloseMenuSwitcher();
			}
			Links.x.pocketWheel.SetHotkeys(true);
		}
	}

	// Token: 0x06001274 RID: 4724 RVA: 0x0016600C File Offset: 0x0016420C
	public void UseController()
	{
		if (this.controller.isOn)
		{
			Records.x.usingController = true;
			this.ControlScheme(true);
			if (!this.CheckControllers() && Links.x.gaia.sceneLoaded && this.canvas.enabled && Records.x.usingController)
			{
				Links.x.gameFeed.ShowNotice("No controller detected");
			}
			if (Links.x.gameplay.currentControllerCount > 0 && this.open && Links.x.gaia.sceneLoaded)
			{
				base.StartCoroutine(this.ControllerWait());
			}
			this.keys.SetActive(false);
			if (this.CheckControllers())
			{
				Links.x.hudControl.SwitchController(true);
			}
			Links.x.fellowship.UpdateHotkeys();
			Links.x.pocketWheel.SetHotkeys(false);
		}
	}

	// Token: 0x06001275 RID: 4725 RVA: 0x001660FC File Offset: 0x001642FC
	private IEnumerator ControllerWait()
	{
		yield return new WaitForSecondsRealtime(0.25f);
		EventSystem.current.SetSelectedGameObject(this.controller.gameObject);
		this.controller.gameObject.GetComponent<UITriggerButton>().SetSelected(true);
		Links.x.gameplay.SetControlsText(false);
		Links.x.hudControl.OpenMenuSwitcher("Options");
		this.cancelButton.CheckController(true);
		Links.x.hudControl.SwitchController(true);
		yield break;
	}

	// Token: 0x06001276 RID: 4726 RVA: 0x0016610B File Offset: 0x0016430B
	public void SetControllerOn()
	{
		this.controller.isOn = true;
	}

	// Token: 0x06001277 RID: 4727 RVA: 0x0016611C File Offset: 0x0016431C
	public void ControlScheme(bool fromButtons)
	{
		if (Records.x.usingController)
		{
			if (!fromButtons)
			{
				this.mk.isOn = false;
				this.mkPathfind.isOn = false;
				this.controller.isOn = true;
				Links.x.partyColliderAdventure.itemCollector.UpdateSize();
			}
			this.controllerOverlay.SetActive(true);
			if (Links.x.gameplay.currentControllerCount == 0)
			{
				EventSystem.current.SetSelectedGameObject(null);
			}
		}
		else
		{
			if (!fromButtons)
			{
				this.mk.isOn = true;
				this.mkPathfind.isOn = false;
				this.controller.isOn = false;
			}
			this.controllerOverlay.SetActive(false);
			EventSystem.current.SetSelectedGameObject(null);
			this.SetKeys();
		}
		if (fromButtons)
		{
			this.SaveOptions();
		}
	}

	// Token: 0x06001278 RID: 4728 RVA: 0x001661E8 File Offset: 0x001643E8
	public void Sound(bool fromSlider)
	{
		this.soundVolume = this.sound.value;
		string text = this.soundVolume.ToString();
		this.soundVolume *= 0.1f;
		this.soundText.text = "Sound Volume: " + text;
		if (fromSlider)
		{
			this.SaveOptions();
		}
		MasterAudio.MasterVolumeLevel = Links.x.options.soundVolume;
		if (Links.x && Links.x.diorama)
		{
			Links.x.diorama.SetVolume();
		}
		Links.x.soundtrack.SetVolume(Links.x.options.soundVolume, Links.x.options.musicVolume);
	}

	// Token: 0x06001279 RID: 4729 RVA: 0x001662B4 File Offset: 0x001644B4
	public void Music(bool fromSlider)
	{
		this.musicVolume = this.music.value;
		string text = this.musicVolume.ToString();
		this.musicVolume *= 0.1f;
		this.musicVolume *= 0.9f;
		this.musicText.text = "Music Volume: " + text;
		if (fromSlider)
		{
			this.SaveOptions();
		}
		Links.x.soundtrack.SetVolume(Links.x.options.soundVolume, Links.x.options.musicVolume);
	}

	// Token: 0x0600127A RID: 4730 RVA: 0x0016634F File Offset: 0x0016454F
	public void Zoom(bool fromSlider)
	{
		this.cameraZoom = this.zoom.value;
		this.cameraZoom.ToString();
		if (fromSlider)
		{
			this.SaveOptions();
		}
	}

	// Token: 0x0600127B RID: 4731 RVA: 0x00166378 File Offset: 0x00164578
	public void ScreenShake(bool fromSlider)
	{
		if (this.screenShake.value > 0f)
		{
			this.screenShaking = true;
			this.screenShakeText.text = "Screen Shake Effects: On";
		}
		else
		{
			this.screenShaking = false;
			this.screenShakeText.text = "Screen Shake Effects: Off";
		}
		if (fromSlider)
		{
			this.SaveOptions();
		}
	}

	// Token: 0x0600127C RID: 4732 RVA: 0x001663D4 File Offset: 0x001645D4
	public void QTE(bool fromSlider)
	{
		if (this.qte.value > 0f)
		{
			this.rallyTimePrompt = true;
			this.qteText.text = "Rally Timing Prompts: On";
		}
		else
		{
			this.rallyTimePrompt = false;
			this.qteText.text = "Rally Timing Prompts: Off";
		}
		if (fromSlider)
		{
			this.SaveOptions();
		}
	}

	// Token: 0x0600127D RID: 4733 RVA: 0x00166430 File Offset: 0x00164630
	public void Brightness(bool fromSlider)
	{
		float value = this.brightness.value;
		this.bright = this.brightness.value;
		if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer)
		{
			this.bcg.Brightness = this.bright;
		}
		else
		{
			this.bcg.Brightness = this.bright + 7f;
		}
		if (this.bcg.Brightness >= 0f)
		{
			this.bcg.Gamma = Mathf.Lerp(1f, 1.15f, this.bright / this.brightness.maxValue);
		}
		else
		{
			this.bcg.Gamma = Mathf.Lerp(1f, 0.9f, this.bright / this.brightness.maxValue * -1f);
		}
		if (this.bcg.Brightness == 0f)
		{
			this.bcg.enabled = false;
		}
		else
		{
			this.bcg.enabled = true;
		}
		if (fromSlider)
		{
			this.SaveOptions();
		}
	}

	// Token: 0x0600127E RID: 4734 RVA: 0x0016653C File Offset: 0x0016473C
	public void CloseResolutionBox()
	{
		this.confirmResolutionBox.SetActive(false);
		this.confirmData = null;
	}

	// Token: 0x0600127F RID: 4735 RVA: 0x00166551 File Offset: 0x00164751
	public void OpenResolutionBox(Data data)
	{
		this.confirmData = data;
		this.confirmResolutionBox.SetActive(true);
	}

	// Token: 0x06001280 RID: 4736 RVA: 0x00166568 File Offset: 0x00164768
	public void ToggleFullscreen()
	{
		if (!this.setting)
		{
			if (Screen.fullScreen)
			{
				this.SetResolution(false);
				this.fullscreenCheckbox.sprite = this.emptySprite;
			}
			else
			{
				this.SetResolution(true);
				this.fullscreenCheckbox.sprite = this.checkSprite;
			}
			this.SaveOptions();
		}
	}

	// Token: 0x06001281 RID: 4737 RVA: 0x001665BC File Offset: 0x001647BC
	public void TogglePathfinding()
	{
		if (!this.setting)
		{
			if (!Links.x.pathfind)
			{
				Links.x.pathfind = true;
				this.pathfindingCheckbox.sprite = this.checkSprite;
			}
			else
			{
				Links.x.pathfind = false;
				this.pathfindingCheckbox.sprite = this.emptySprite;
			}
			this.SaveOptions();
		}
	}

	// Token: 0x06001282 RID: 4738 RVA: 0x00166620 File Offset: 0x00164820
	public void ToggleCredits()
	{
		if (this.creditsAnimator.GetCurrentAnimatorStateInfo(0).IsName("Credits_Close") || this.creditsAnimator.GetCurrentAnimatorStateInfo(0).IsName("Credits_Idle"))
		{
			this.creditsAnimator.Play("Credits_Open");
			return;
		}
		this.creditsAnimator.Play("Credits_Close");
	}

	// Token: 0x06001283 RID: 4739 RVA: 0x00166684 File Offset: 0x00164884
	public void CloseMenu()
	{
		if (Records.x.mainMenuOpen)
		{
			Links.x.hudControl.CloseMenuSwitcher();
		}
		this.open = false;
		this.Framerate(false);
		this.lastSliderTime = 0f;
		this.Vsync(false);
		this.contents1.SetActive(false);
		this.contents2.SetActive(false);
		this.contents3.SetActive(false);
		this.SaveOptions();
		Links.x.hudControl.UpdateKeys();
		base.enabled = false;
		this.canvas.enabled = false;
		this.anim.enabled = false;
		if (Links.x.creation)
		{
			Links.x.creation.ToggleInteractable(true);
			Links.x.creation.CloseKeyboard();
		}
		if (Records.x.mainMenuOpen && Links.x.joy)
		{
			GameObject gameObject = GameObject.Find("Main Menu");
			Links.x.gameplay.SetInteractableSelected(EventSystem.current, gameObject.GetComponent<MainMenu>().newGameButton.gameObject);
		}
	}

	// Token: 0x06001284 RID: 4740 RVA: 0x0016679C File Offset: 0x0016499C
	public void StartEndMenu(bool fromCloseButton)
	{
		this.open = false;
		Records.x.RemoveMenu(base.gameObject);
		if (fromCloseButton)
		{
			Links.x.gameplay.CloseDock();
		}
		Links.x.gameplay.SetControlsText(false);
		bool flag = false;
		if (Links.x.joy && (Links.x.gameplay.dockStart || Links.x.gameplay.itemsStart))
		{
			flag = true;
		}
		if (!flag)
		{
			this.anim.Play("Close");
		}
		else
		{
			this.anim.Play("Close", 0, 1f);
		}
		Links.x.hudControl.JoyBox(false);
	}

	// Token: 0x06001285 RID: 4741 RVA: 0x00166850 File Offset: 0x00164A50
	public void OpenMenu()
	{
		if (this.contents1.activeSelf)
		{
			return;
		}
		Links.x.gameplay.lastMenu = "Options";
		Links.x.gameplay.openingAnotherMenu = true;
		Links.x.gameplay.CloseAllMenus();
		Records.x.AddMenu(base.gameObject);
		this.anim.enabled = true;
		this.anim.Play("Open");
		this.canvas.enabled = true;
		this.contents1.SetActive(true);
		this.contents2.SetActive(true);
		this.contents3.SetActive(true);
		if (Links.x.joy)
		{
			Links.x.gameplay.SetInteractableSelected(EventSystem.current, this.firstBtn.gameObject);
		}
		base.enabled = true;
		if (Links.x.pathfind)
		{
			this.pathfindingCheckbox.sprite = this.checkSprite;
		}
		else
		{
			this.pathfindingCheckbox.sprite = this.emptySprite;
		}
		if (Screen.fullScreen)
		{
			this.fullscreenCheckbox.sprite = this.checkSprite;
		}
		else
		{
			this.fullscreenCheckbox.sprite = this.emptySprite;
		}
		this.open = true;
		if (Links.x.creation)
		{
			Links.x.creation.ToggleInteractable(false);
		}
	}

	// Token: 0x04001E44 RID: 7748
	public GameObject contents1;

	// Token: 0x04001E45 RID: 7749
	public GameObject contents2;

	// Token: 0x04001E46 RID: 7750
	public GameObject contents3;

	// Token: 0x04001E47 RID: 7751
	private ES3File saveFile;

	// Token: 0x04001E48 RID: 7752
	public Slider vsync;

	// Token: 0x04001E49 RID: 7753
	public Slider framerate;

	// Token: 0x04001E4A RID: 7754
	public Slider quality;

	// Token: 0x04001E4B RID: 7755
	public Slider antialiasing;

	// Token: 0x04001E4C RID: 7756
	public Slider sound;

	// Token: 0x04001E4D RID: 7757
	public Slider music;

	// Token: 0x04001E4E RID: 7758
	public Slider zoom;

	// Token: 0x04001E4F RID: 7759
	public Slider windowed;

	// Token: 0x04001E50 RID: 7760
	public Slider gameFeed;

	// Token: 0x04001E51 RID: 7761
	public Slider qte;

	// Token: 0x04001E52 RID: 7762
	public Slider brightness;

	// Token: 0x04001E53 RID: 7763
	public Slider screenShake;

	// Token: 0x04001E54 RID: 7764
	public Animator creditsAnimator;

	// Token: 0x04001E55 RID: 7765
	public Animator anim;

	// Token: 0x04001E56 RID: 7766
	public TextMeshProUGUI antialiasingText;

	// Token: 0x04001E57 RID: 7767
	public TextMeshProUGUI frameCapText;

	// Token: 0x04001E58 RID: 7768
	public TextMeshProUGUI vsyncText;

	// Token: 0x04001E59 RID: 7769
	public TextMeshProUGUI qualityText;

	// Token: 0x04001E5A RID: 7770
	public TextMeshProUGUI fullscreenText;

	// Token: 0x04001E5B RID: 7771
	public TextMeshProUGUI fullscreenButtonText;

	// Token: 0x04001E5C RID: 7772
	public TextMeshProUGUI soundText;

	// Token: 0x04001E5D RID: 7773
	public TextMeshProUGUI musicText;

	// Token: 0x04001E5E RID: 7774
	public TextMeshProUGUI zoomText;

	// Token: 0x04001E5F RID: 7775
	public TextMeshProUGUI gameFeedText;

	// Token: 0x04001E60 RID: 7776
	public TextMeshProUGUI screenShakeText;

	// Token: 0x04001E61 RID: 7777
	public TextMeshProUGUI resolutionBtnText;

	// Token: 0x04001E62 RID: 7778
	public TextMeshProUGUI qteText;

	// Token: 0x04001E63 RID: 7779
	public Image fullscreenCheckbox;

	// Token: 0x04001E64 RID: 7780
	public Image pathfindingCheckbox;

	// Token: 0x04001E65 RID: 7781
	public Sprite checkSprite;

	// Token: 0x04001E66 RID: 7782
	public Sprite emptySprite;

	// Token: 0x04001E67 RID: 7783
	public int graphicsQuality = 1;

	// Token: 0x04001E68 RID: 7784
	private bool setting;

	// Token: 0x04001E69 RID: 7785
	public float soundVolume;

	// Token: 0x04001E6A RID: 7786
	public float musicVolume;

	// Token: 0x04001E6B RID: 7787
	public float cameraZoom;

	// Token: 0x04001E6C RID: 7788
	private Resolution[] resolutions;

	// Token: 0x04001E6D RID: 7789
	public List<Data> resolutionData = new List<Data>();

	// Token: 0x04001E6E RID: 7790
	public Color textColorNormal;

	// Token: 0x04001E6F RID: 7791
	public Color textColorInactive;

	// Token: 0x04001E70 RID: 7792
	public Canvas canvas;

	// Token: 0x04001E71 RID: 7793
	public ScrollRectNoDragging scrollRect1;

	// Token: 0x04001E72 RID: 7794
	public Toggle mk;

	// Token: 0x04001E73 RID: 7795
	public Toggle mkPathfind;

	// Token: 0x04001E74 RID: 7796
	public Toggle controller;

	// Token: 0x04001E75 RID: 7797
	public GameObject controllerOverlay;

	// Token: 0x04001E76 RID: 7798
	public GameObject keys;

	// Token: 0x04001E77 RID: 7799
	public GameObject firstBtn;

	// Token: 0x04001E78 RID: 7800
	private bool nofile;

	// Token: 0x04001E79 RID: 7801
	private bool showingAllResolutions;

	// Token: 0x04001E7A RID: 7802
	public bool screenShaking;

	// Token: 0x04001E7B RID: 7803
	public bool rallyTimePrompt;

	// Token: 0x04001E7C RID: 7804
	public float bright;

	// Token: 0x04001E7D RID: 7805
	public Button creditsButton;

	// Token: 0x04001E7E RID: 7806
	public Button moreResolutionsBtn;

	// Token: 0x04001E7F RID: 7807
	public int gameFeedState = 1;

	// Token: 0x04001E80 RID: 7808
	public Data confirmData;

	// Token: 0x04001E81 RID: 7809
	public GameObject confirmResolutionBox;

	// Token: 0x04001E82 RID: 7810
	public GameObject windowSlider;

	// Token: 0x04001E83 RID: 7811
	public int screenResW;

	// Token: 0x04001E84 RID: 7812
	public int screenResH;

	// Token: 0x04001E85 RID: 7813
	private PointerEventData pointer;

	// Token: 0x04001E86 RID: 7814
	private List<RaycastResult> raycastResults = new List<RaycastResult>();

	// Token: 0x04001E87 RID: 7815
	public AnimateButton cancelButton;

	// Token: 0x04001E88 RID: 7816
	public bool open;

	// Token: 0x04001E89 RID: 7817
	private float lastSliderTime;

	// Token: 0x04001E8A RID: 7818
	public BrightnessContrastGamma bcg;
}
