Decompiled source of TootTallyCustomCursor v1.2.1

plugins/TootTallyCustomCursor.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BaboonAPI.Hooks.Initializer;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TootTallyCore;
using TootTallyCore.Graphics.Animations;
using TootTallyCore.Utils.Helpers;
using TootTallyCore.Utils.TootTallyGlobals;
using TootTallyCore.Utils.TootTallyModules;
using TootTallySettings;
using TootTallySettings.TootTallySettingsObjects;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TootTallyCustomCursor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows to change the texture of your cursor and more")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("TootTallyCustomCursor")]
[assembly: AssemblyTitle("TootTallyCustomCursor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TootTallyCustomCursor
{
	public class CursorTrail : MonoBehaviour
	{
		private Queue<float> _verticesTimes;

		private List<Vector3> _verticesList;

		private LineRenderer _lineRenderer;

		private float _lifetime;

		private float _trailSpeed;

		private int _refreshRate;

		private Vector3 _velocity;

		public void Awake()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Component)this).gameObject.TryGetComponent<LineRenderer>(ref _lineRenderer))
			{
				_lineRenderer = ((Component)this).gameObject.AddComponent<LineRenderer>();
			}
			_lineRenderer.useWorldSpace = true;
			_verticesTimes = new Queue<float>();
			_verticesList = new List<Vector3> { ((Component)this).gameObject.transform.position };
			_velocity = Vector3.zero;
			AddPoint(0f);
		}

		public void Init(float startWidth, float lifetime, float trailSpeed, Color startColor, Color endColor, Material material, int renderQueue, int refreshRate, Texture2D texture = null)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			((Renderer)_lineRenderer).sortingOrder = 51;
			_lineRenderer.numCapVertices = 20;
			_lineRenderer.alignment = (LineAlignment)1;
			_lineRenderer.textureMode = (LineTextureMode)2;
			_lineRenderer.endWidth = 0f;
			_lineRenderer.startWidth = startWidth;
			if ((Object)(object)material != (Object)null)
			{
				((Renderer)_lineRenderer).material = Object.Instantiate<Material>(material);
			}
			((Renderer)_lineRenderer).material.renderQueue = renderQueue;
			if ((Object)(object)texture != (Object)null)
			{
				((Renderer)_lineRenderer).material.mainTexture = (Texture)(object)texture;
			}
			LineRenderer lineRenderer = _lineRenderer;
			Gradient val = new Gradient();
			val.mode = (GradientMode)0;
			val.colorKeys = (GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(startColor, 0f),
				new GradientColorKey(endColor, 1f)
			};
			lineRenderer.colorGradient = val;
			_lifetime = lifetime;
			_trailSpeed = trailSpeed;
			_refreshRate = refreshRate;
		}

		public void Update()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			while (_verticesTimes.Count > 2 && _verticesTimes.Peek() + _lifetime < time)
			{
				RemovePoint();
			}
			int num = (int)((_verticesList.First().y - ((Component)this).gameObject.transform.position.y) * 1000f);
			if (num != 0)
			{
				AddPoint(time);
			}
			else if (_refreshRate == 0 || (time - _verticesTimes.Last() > 1f / (float)_refreshRate && num == 0))
			{
				AddPoint(time);
			}
			_velocity.x = (0f - Time.deltaTime) * _trailSpeed;
			for (int i = 1; i < _verticesList.Count; i++)
			{
				List<Vector3> verticesList = _verticesList;
				int index = i;
				verticesList[index] += _velocity;
			}
			SetFirstVerticePosition();
			_lineRenderer.positionCount = _verticesList.Count;
			_lineRenderer.SetPositions(_verticesList.ToArray());
		}

		public void SetWidth(float width)
		{
			_lineRenderer.startWidth = width;
		}

		public void UpdateColors()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			LineRenderer lineRenderer = _lineRenderer;
			Gradient val = new Gradient();
			val.mode = (GradientMode)0;
			val.colorKeys = (GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Plugin.Instance.TrailStartColor.Value, 0f),
				new GradientColorKey(Plugin.Instance.TrailEndColor.Value, 1f)
			};
			lineRenderer.colorGradient = val;
		}

		public void SetColors(GradientColorKey[] colors)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			_lineRenderer.colorGradient = new Gradient
			{
				mode = (GradientMode)0,
				colorKeys = colors
			};
		}

		public void SetLifetime(float lifetime)
		{
			_lifetime = lifetime;
		}

		public void SetTrailSpeed(float trailSpeed)
		{
			_trailSpeed = trailSpeed;
		}

		public void SetRefreshRate(int refreshRate)
		{
			_refreshRate = refreshRate;
		}

		private void AddPoint(float time)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			_verticesTimes.Enqueue(time);
			_verticesList.Insert(1, ((Component)this).gameObject.transform.position);
		}

		private void SetFirstVerticePosition()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			_verticesList[0] = ((Component)this).gameObject.transform.position;
		}

		private void RemovePoint()
		{
			_verticesTimes.Dequeue();
			_verticesList.RemoveAt(_verticesList.Count - 1);
		}

		public void Dispose()
		{
			Object.DestroyImmediate((Object)(object)_lineRenderer);
			Object.DestroyImmediate((Object)(object)this);
		}
	}
	public static class CustomCursor
	{
		private const string NOTETARGET_PATH = "GameplayCanvas/GameSpace/TargetNote";

		private const string NOTEDOT_PATH = "GameplayCanvas/GameSpace/TargetNote/note-dot";

		private const string NOTEDOTGLOW_PATH = "GameplayCanvas/GameSpace/TargetNote/note-dot-glow";

		private const string NOTEDOTGLOW1_PATH = "GameplayCanvas/GameSpace/TargetNote/note-dot-glow/note-dot-glow (1)";

		private static Texture2D _noteTargetTexture;

		private static Texture2D _noteDotTexture;

		private static Texture2D _noteDotGlowTexture;

		private static Texture2D _noteDotGlow1Texture;

		private static Texture2D _trailTexture;

		private static string _lastCursorName;

		public static Action<GameController> OnTextureLoaded = OnAllTextureLoadedAfterConfigChange;

		public static Texture2D[] GetTextures => (Texture2D[])(object)new Texture2D[3] { _noteTargetTexture, _noteDotTexture, _trailTexture };

		public static void LoadCursorTexture(GameController __instance, string cursorName)
		{
			if (AreAllTexturesLoaded() && !ConfigCursorNameChanged())
			{
				return;
			}
			string text = Path.Combine(Paths.BepInExRootPath, Plugin.CURSORS_FOLDER_PATH, cursorName);
			((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/TargetNote.png", delegate(Texture2D texture)
			{
				_noteTargetTexture = texture;
				Plugin.LogInfo("Target Texture Loaded.");
				if (AreAllTexturesLoaded())
				{
					OnTextureLoaded(__instance);
				}
			}));
			((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/note-dot.png", delegate(Texture2D texture)
			{
				_noteDotTexture = texture;
				Plugin.LogInfo("Dot Texture Loaded.");
				if (AreAllTexturesLoaded())
				{
					OnTextureLoaded(__instance);
				}
			}));
			((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/note-dot-glow.png", delegate(Texture2D texture)
			{
				_noteDotGlowTexture = texture;
				Plugin.LogInfo("Dot Glow Texture Loaded.");
				if (AreAllTexturesLoaded())
				{
					OnTextureLoaded(__instance);
				}
			}));
			((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/note-dot-glow (1).png", delegate(Texture2D texture)
			{
				_noteDotGlow1Texture = texture;
				Plugin.LogInfo("Dot Glow1 Texture Loaded.");
				if (AreAllTexturesLoaded())
				{
					OnTextureLoaded(__instance);
				}
			}));
			((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(text + "/trail.png", delegate(Texture2D texture)
			{
				_trailTexture = texture;
				Plugin.LogInfo("Trail Texture Loaded.");
				if (AreAllTexturesLoaded())
				{
					OnTextureLoaded(__instance);
				}
			}));
		}

		public static void UnloadTextures()
		{
			Object.DestroyImmediate((Object)(object)_noteTargetTexture);
			Object.DestroyImmediate((Object)(object)_noteDotTexture);
			Object.DestroyImmediate((Object)(object)_noteDotGlowTexture);
			Object.DestroyImmediate((Object)(object)_noteDotGlow1Texture);
			Object.DestroyImmediate((Object)(object)_trailTexture);
			Plugin.LogInfo("Custom Cursor Textures Destroyed.");
		}

		public static void OnAllTextureLoadedAfterConfigChange(GameController __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && __instance.pointer.activeSelf)
			{
				ApplyCustomTextureToCursor(__instance);
				_lastCursorName = Plugin.Instance.CursorName.Value;
			}
		}

		public static bool AreAllTexturesLoaded()
		{
			return (Object)(object)_noteTargetTexture != (Object)null && (Object)(object)_noteDotTexture != (Object)null && (Object)(object)_noteDotGlowTexture != (Object)null && (Object)(object)_noteDotGlow1Texture != (Object)null && (Object)(object)_trailTexture != (Object)null;
		}

		public static bool CanApplyTextures()
		{
			return (Object)(object)_noteTargetTexture != (Object)null || (Object)(object)_noteDotTexture != (Object)null || (Object)(object)_noteDotGlowTexture != (Object)null || (Object)(object)_noteDotGlow1Texture != (Object)null || (Object)(object)_trailTexture != (Object)null;
		}

		public static bool ConfigCursorNameChanged()
		{
			return Plugin.Instance.CursorName.Value != _lastCursorName;
		}

		public static IEnumerator<UnityWebRequestAsyncOperation> LoadCursorTexture(string filePath, Action<Texture2D> callback)
		{
			UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(filePath);
			yield return webRequest.SendWebRequest();
			if (!webRequest.isNetworkError && !webRequest.isHttpError)
			{
				callback(DownloadHandlerTexture.GetContent(webRequest));
			}
			else
			{
				Plugin.LogInfo(Path.GetFileName(filePath) + " does not exist or have the wrong format.");
			}
		}

		public static void ApplyCustomTextureToCursor(GameController __instance)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			if (CanApplyTextures())
			{
				Plugin.LogInfo("Applying Custom Textures to cursor.");
				GameObject gameObject = GameObject.Find("GameplayCanvas/GameSpace/TargetNote").gameObject;
				gameObject.transform.localScale = Vector3.one * Plugin.Instance.CursorSize.Value;
				if ((Object)(object)_noteTargetTexture != (Object)null)
				{
					gameObject.GetComponent<Image>().sprite = Sprite.Create(_noteTargetTexture, new Rect(0f, 0f, (float)((Texture)_noteTargetTexture).width, (float)((Texture)_noteTargetTexture).height), Vector2.one);
					gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_noteTargetTexture).width, (float)((Texture)_noteTargetTexture).height) / 2f;
				}
				if ((Object)(object)_noteDotTexture != (Object)null)
				{
					GameObject gameObject2 = GameObject.Find("GameplayCanvas/GameSpace/TargetNote/note-dot").gameObject;
					gameObject2.GetComponent<Image>().sprite = Sprite.Create(_noteDotTexture, new Rect(0f, 0f, (float)((Texture)_noteDotTexture).width, (float)((Texture)_noteDotTexture).height), Vector2.zero);
					gameObject2.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_noteDotTexture).width, (float)((Texture)_noteDotTexture).height) / 2f;
				}
				if ((Object)(object)_noteDotGlowTexture != (Object)null)
				{
					GameObject gameObject3 = GameObject.Find("GameplayCanvas/GameSpace/TargetNote/note-dot-glow").gameObject;
					gameObject3.GetComponent<Image>().sprite = Sprite.Create(_noteDotGlowTexture, new Rect(0f, 0f, (float)((Texture)_noteDotGlowTexture).width, (float)((Texture)_noteDotGlowTexture).height), Vector2.zero);
					gameObject3.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_noteDotGlowTexture).width, (float)((Texture)_noteDotGlowTexture).height) / 2f;
				}
				if ((Object)(object)_noteDotGlow1Texture != (Object)null)
				{
					GameObject gameObject4 = GameObject.Find("GameplayCanvas/GameSpace/TargetNote/note-dot-glow/note-dot-glow (1)").gameObject;
					gameObject4.GetComponent<Image>().sprite = Sprite.Create(_noteDotGlow1Texture, new Rect(0f, 0f, (float)((Texture)_noteDotGlow1Texture).width, (float)((Texture)_noteDotGlow1Texture).height), Vector2.zero);
					gameObject4.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_noteDotGlow1Texture).width, (float)((Texture)_noteDotGlow1Texture).height) / 2f;
				}
			}
		}

		public static void AddTrail(GameController __instance)
		{
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.pointer.activeSelf)
			{
				return;
			}
			float scalerModifier = 1f;
			float trailSpeed = Plugin.Instance.TrailSpeed.Value;
			if (Plugin.Instance.TrailAdjustTrailSpeed.Value)
			{
				float num = ((GlobalVariables.testScreenRatio() == 1610) ? 0.9f : 1f);
				scalerModifier = __instance.tempo * TootTallyGlobalVariables.gameSpeedMultiplier * (float)__instance.defaultnotelength / 40600f * num;
				trailSpeed = 17f * scalerModifier;
			}
			if ((Object)(object)_trailTexture != (Object)null)
			{
				__instance.pointer.AddComponent<CursorTrail>().Init((float)((Texture)_trailTexture).height * Plugin.Instance.TrailSize.Value, Plugin.Instance.TrailLength.Value / scalerModifier, trailSpeed, Plugin.Instance.TrailStartColor.Value, Plugin.Instance.TrailEndColor.Value, ((Renderer)((Component)__instance.notelinesholder.transform.GetChild(0)).GetComponent<LineRenderer>()).material, 3500, (int)Plugin.Instance.TrailRefreshRate.Value, _trailTexture);
				return;
			}
			string filePath = Path.Combine(Paths.BepInExRootPath, Plugin.CURSORS_FOLDER_PATH, "TEMPLATE/trail.png");
			((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)LoadCursorTexture(filePath, delegate(Texture2D texture)
			{
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				_trailTexture = texture;
				__instance.pointer.AddComponent<CursorTrail>().Init((float)((Texture)_trailTexture).height * Plugin.Instance.TrailSize.Value, Plugin.Instance.TrailLength.Value / scalerModifier, trailSpeed, Plugin.Instance.TrailStartColor.Value, Plugin.Instance.TrailEndColor.Value, ((Renderer)((Component)__instance.notelinesholder.transform.GetChild(0)).GetComponent<LineRenderer>()).material, 3500, (int)Plugin.Instance.TrailRefreshRate.Value, _trailTexture);
			}));
		}

		public static void ResolvePresets(GameController __instance)
		{
			if ((!AreAllTexturesLoaded() || (Object)(object)__instance == (Object)null) && Plugin.Instance.CursorName.Value != "Default")
			{
				Plugin.LogInfo("[" + Plugin.Instance.CursorName.Value + "] preset loading...");
				LoadCursorTexture(__instance, Plugin.Instance.CursorName.Value);
			}
			else if (Plugin.Instance.CursorName.Value != "Default")
			{
				ApplyCustomTextureToCursor(__instance);
			}
			else
			{
				UnloadTextures();
				OnTextureLoaded(__instance);
				Plugin.LogInfo("[Default] preset selected. Not loading any Custom Cursor.");
			}
		}
	}
	internal class CustomCursorSettingPage : TootTallySettingPage
	{
		private static ColorBlock _pageBtnColors;

		private TootTallySettingDropdown _cursorDropdown;

		private TootTallySettingSlider _cursorSizeSlider;

		private TootTallySettingSlider _trailSizeSlider;

		private TootTallySettingSlider _trailLengthSlider;

		private TootTallySettingSlider _trailSpeedSlider;

		private TootTallySettingSlider _trailRefreshRateSlider;

		private TootTallySettingColorSliders _trailStartColorSliders;

		private TootTallySettingColorSliders _trailEndColorSliders;

		private TootTallySettingToggle _trailToggle;

		private TootTallySettingToggle _trailAutoadjustToggle;

		public GameObject defaultCursor;

		private GameObject _cursorPreview;

		private TootTallyAnimation _previewAnimation;

		private CursorTrail _trailPreview;

		private static Texture2D[] _textures;

		private static Texture2D _trailTexture;

		public CustomCursorSettingPage()
			: base("Custom Cursor", "Custom Cursor", 40f, new Color(0f, 0f, 0f, 0f), _pageBtnColors)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			_cursorDropdown = CreateDropdownFromFolder(Plugin.CURSORS_FOLDER_PATH, Plugin.Instance.CursorName, "Default");
			_cursorSizeSlider = ((TootTallySettingPage)this).AddSlider("Cursor Size", 0.01f, 2f, Plugin.Instance.CursorSize, false);
			((TootTallySettingPage)this).AddLabel("CustomTrailLabel", "Custom Trail", 24f, (FontStyles)0, (TextAlignmentOptions)1025);
			_trailToggle = ((TootTallySettingPage)this).AddToggle("Enable Cursor Trail", Plugin.Instance.CursorTrailEnabled, (UnityAction<bool>)null);
			_trailAutoadjustToggle = ((TootTallySettingPage)this).AddToggle("Auto adjust Trail speed", Plugin.Instance.TrailAdjustTrailSpeed, (UnityAction<bool>)null);
			_trailSizeSlider = ((TootTallySettingPage)this).AddSlider("Trail Size", 0f, 1f, Plugin.Instance.TrailSize, false);
			_trailLengthSlider = ((TootTallySettingPage)this).AddSlider("Trail Length", 0f, 1f, Plugin.Instance.TrailLength, false);
			_trailSpeedSlider = ((TootTallySettingPage)this).AddSlider("Trail Speed", 0f, 100f, Plugin.Instance.TrailSpeed, false);
			_trailRefreshRateSlider = ((TootTallySettingPage)this).AddSlider("Trail Refresh Rate", 0f, 200f, Plugin.Instance.TrailRefreshRate, true);
			((TootTallySettingPage)this).AddLabel("Trail Start Color", (FontStyles)0, (TextAlignmentOptions)4097);
			_trailStartColorSliders = ((TootTallySettingPage)this).AddColorSliders("Trail Start Color", "Trail Start Color", Plugin.Instance.TrailStartColor);
			((TootTallySettingPage)this).AddLabel("Trail End Color", (FontStyles)0, (TextAlignmentOptions)4097);
			_trailEndColorSliders = ((TootTallySettingPage)this).AddColorSliders("Trail End Color", "Trail End Color", Plugin.Instance.TrailEndColor);
		}

		public override void Initialize()
		{
			((TootTallySettingPage)this).Initialize();
			((UnityEvent<int>)(object)_cursorDropdown.dropdown.onValueChanged).AddListener((UnityAction<int>)delegate
			{
				CustomCursor.ResolvePresets(null);
			});
			((UnityEvent<bool>)(object)_trailToggle.toggle.onValueChanged).AddListener((UnityAction<bool>)OnTrailToggle);
			((UnityEvent<bool>)(object)_trailAutoadjustToggle.toggle.onValueChanged).AddListener((UnityAction<bool>)OnAutoResizeValueUpdate);
			((UnityEvent<float>)(object)_cursorSizeSlider.slider.onValueChanged).AddListener((UnityAction<float>)OnCursorSizeChange);
			((UnityEvent<float>)(object)_trailStartColorSliders.sliderR.onValueChanged).AddListener((UnityAction<float>)UpdateColor);
			((UnityEvent<float>)(object)_trailStartColorSliders.sliderG.onValueChanged).AddListener((UnityAction<float>)UpdateColor);
			((UnityEvent<float>)(object)_trailStartColorSliders.sliderB.onValueChanged).AddListener((UnityAction<float>)UpdateColor);
			((UnityEvent<float>)(object)_trailEndColorSliders.sliderR.onValueChanged).AddListener((UnityAction<float>)UpdateColor);
			((UnityEvent<float>)(object)_trailEndColorSliders.sliderG.onValueChanged).AddListener((UnityAction<float>)UpdateColor);
			((UnityEvent<float>)(object)_trailEndColorSliders.sliderB.onValueChanged).AddListener((UnityAction<float>)UpdateColor);
			((UnityEvent<float>)(object)_trailLengthSlider.slider.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
			{
				_trailPreview?.SetLifetime(value);
			});
			((UnityEvent<float>)(object)_trailSpeedSlider.slider.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
			{
				_trailPreview?.SetTrailSpeed(value * 3.4f);
			});
			((UnityEvent<float>)(object)_trailSizeSlider.slider.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
			{
				_trailPreview?.SetWidth(value * (float)((Texture)_trailTexture).height * 2f);
			});
			((UnityEvent<float>)(object)_trailRefreshRateSlider.slider.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
			{
				_trailPreview?.SetRefreshRate((int)value);
			});
			OnAutoResizeValueUpdate(Plugin.Instance.TrailAdjustTrailSpeed.Value);
		}

		private void OnAutoResizeValueUpdate(bool value)
		{
			((Component)_trailSpeedSlider.slider).gameObject.SetActive(!value);
			_trailPreview?.SetTrailSpeed((value ? 17f : _trailSpeedSlider.slider.value) * 3.4f);
		}

		private void OnCursorSizeChange(float value)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			_cursorPreview.transform.localScale = Vector3.one * value;
		}

		private void UpdateColor(float f)
		{
			_trailPreview?.UpdateColors();
		}

		public override void OnShow()
		{
			CustomCursor.OnTextureLoaded = (Action<GameController>)Delegate.Combine(CustomCursor.OnTextureLoaded, new Action<GameController>(InitPreview));
			((TootTallySettingPage)this).OnShow();
			InitPreview(null);
		}

		public override void OnHide()
		{
			CustomCursor.OnTextureLoaded = (Action<GameController>)Delegate.Remove(CustomCursor.OnTextureLoaded, new Action<GameController>(InitPreview));
			((TootTallySettingPage)this).OnHide();
			DestroyPreview();
		}

		private void InitPreview(GameController _instance)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			if ((Object)(object)_cursorPreview != (Object)null)
			{
				DestroyPreview();
			}
			_cursorPreview = Object.Instantiate<GameObject>(defaultCursor, base.gridPanel.transform.parent);
			_cursorPreview.transform.localScale = Vector3.one * Plugin.Instance.CursorSize.Value;
			GameObject gameObject = ((Component)_cursorPreview.transform.Find("note-dot")).gameObject;
			_cursorPreview.GetComponent<RectTransform>().anchoredPosition = new Vector2(950f, 100f);
			if (Plugin.Instance.CursorName.Value != "Default")
			{
				_textures = CustomCursor.GetTextures;
				_cursorPreview.GetComponent<Image>().sprite = Sprite.Create(_textures[0], new Rect(0f, 0f, (float)((Texture)_textures[0]).width, (float)((Texture)_textures[0]).height), Vector2.one);
				_cursorPreview.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_textures[0]).width, (float)((Texture)_textures[0]).height);
				_cursorPreview.GetComponent<RectTransform>().pivot = Vector2.one / 2f;
				gameObject.GetComponent<Image>().sprite = Sprite.Create(_textures[1], new Rect(0f, 0f, (float)((Texture)_textures[1]).width, (float)((Texture)_textures[1]).height), Vector2.zero);
				gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)_textures[1]).width, (float)((Texture)_textures[1]).height);
			}
			else
			{
				Texture mainTexture = ((Graphic)_cursorPreview.GetComponent<Image>()).mainTexture;
				Texture2D val = (Texture2D)(object)((mainTexture is Texture2D) ? mainTexture : null);
				Texture mainTexture2 = ((Graphic)gameObject.GetComponent<Image>()).mainTexture;
				Texture2D val2 = (Texture2D)(object)((mainTexture2 is Texture2D) ? mainTexture2 : null);
				_cursorPreview.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)val).width, (float)((Texture)val).height);
				_cursorPreview.GetComponent<RectTransform>().pivot = Vector2.one / 2f;
				gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2((float)((Texture)val2).width, (float)((Texture)val2).height);
			}
			_previewAnimation = TootTallyAnimationManager.AddNewPositionAnimation(_cursorPreview, Vector2.op_Implicit(new Vector2(950f, 0f)), 99999f, new SecondDegreeDynamicsAnimation(0.85f, 0f, -1f), (Action<GameObject>)null);
			OnTrailToggle(Plugin.Instance.CursorTrailEnabled.Value);
		}

		private void DestroyPreview()
		{
			Object.DestroyImmediate((Object)(object)_cursorPreview);
			TootTallyAnimation previewAnimation = _previewAnimation;
			if (previewAnimation != null)
			{
				previewAnimation.Dispose();
			}
		}

		private void OnTrailToggle(bool value)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_cursorPreview == (Object)null)
			{
				return;
			}
			if ((Object)(object)_trailPreview == (Object)null && value)
			{
				_trailPreview = _cursorPreview.AddComponent<CursorTrail>();
				if (Plugin.Instance.CursorName.Value != "Default")
				{
					_trailTexture = _textures[2];
					_trailPreview.Init((float)((Texture)_trailTexture).height * Plugin.Instance.TrailSize.Value * 2f, Plugin.Instance.TrailLength.Value, Plugin.Instance.TrailSpeed.Value * 3.4f, Plugin.Instance.TrailStartColor.Value, Plugin.Instance.TrailEndColor.Value, Material.GetDefaultLineMaterial(), 2500, (int)Plugin.Instance.TrailRefreshRate.Value, _trailTexture);
					return;
				}
				string filePath = Path.Combine(Paths.BepInExRootPath, Plugin.CURSORS_FOLDER_PATH, "TEMPLATE/trail.png");
				((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)CustomCursor.LoadCursorTexture(filePath, delegate(Texture2D texture)
				{
					//IL_005c: Unknown result type (might be due to invalid IL or missing references)
					//IL_006b: Unknown result type (might be due to invalid IL or missing references)
					_trailTexture = texture;
					_trailPreview.Init((float)((Texture)_trailTexture).height * Plugin.Instance.TrailSize.Value * 2f, Plugin.Instance.TrailLength.Value, Plugin.Instance.TrailSpeed.Value * 3.4f, Plugin.Instance.TrailStartColor.Value, Plugin.Instance.TrailEndColor.Value, Material.GetDefaultLineMaterial(), 2500, (int)Plugin.Instance.TrailRefreshRate.Value, _trailTexture);
				}));
			}
			else if ((Object)(object)_trailPreview != (Object)null && !value)
			{
				_trailPreview.Dispose();
				_trailPreview = null;
			}
		}

		private TootTallySettingDropdown CreateDropdownFromFolder(string folderName, ConfigEntry<string> config, string defaultValue)
		{
			List<string> folderNames = new List<string> { defaultValue };
			string path = Path.Combine(Paths.BepInExRootPath, folderName);
			if (Directory.Exists(path))
			{
				List<string> list = Directory.GetDirectories(path).ToList();
				list.ForEach(delegate(string d)
				{
					if (!d.Contains("TEMPLATE"))
					{
						folderNames.Add(Path.GetFileNameWithoutExtension(d));
					}
				});
			}
			((TootTallySettingPage)this).AddLabel(folderName, folderName, 24f, (FontStyles)0, (TextAlignmentOptions)1025);
			return ((TootTallySettingPage)this).AddDropdown(folderName + "Dropdown", config, folderNames.ToArray());
		}

		static CustomCursorSettingPage()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			ColorBlock pageBtnColors = default(ColorBlock);
			((ColorBlock)(ref pageBtnColors)).colorMultiplier = 1f;
			((ColorBlock)(ref pageBtnColors)).fadeDuration = 0.2f;
			((ColorBlock)(ref pageBtnColors)).disabledColor = Color.gray;
			((ColorBlock)(ref pageBtnColors)).normalColor = new Color(1f, 0f, 0f);
			((ColorBlock)(ref pageBtnColors)).pressedColor = new Color(1f, 0.2f, 0.2f);
			((ColorBlock)(ref pageBtnColors)).highlightedColor = new Color(0.8f, 0f, 0f);
			((ColorBlock)(ref pageBtnColors)).selectedColor = new Color(1f, 0f, 0f);
			_pageBtnColors = pageBtnColors;
		}
	}
	[BepInPlugin("TootTallyCustomCursor", "TootTallyCustomCursor", "1.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin, ITootTallyModule
	{
		public static class CustomCursorPatches
		{
			[HarmonyPatch(typeof(HomeController), "Start")]
			[HarmonyPostfix]
			public static void OnHomeStartLoadTexture(HomeController __instance)
			{
				(settingPage as CustomCursorSettingPage).defaultCursor = ((Component)((Component)__instance.testing_zone_mouse_text).transform.parent.parent.Find("GameSpace/TargetNote")).gameObject;
			}

			[HarmonyPatch(typeof(GameController), "Start")]
			[HarmonyPostfix]
			public static void PatchCustorTexture(GameController __instance)
			{
				CustomCursor.ResolvePresets(__instance);
				if (Instance.CursorTrailEnabled.Value)
				{
					CustomCursor.AddTrail(__instance);
				}
			}
		}

		public static Plugin Instance;

		private const string CONFIG_NAME = "CustomCursor.cfg";

		private const string CURSOR_CONFIG_FIELD = "CustomCursor";

		public const string DEFAULT_CURSORNAME = "Default";

		public static string CURSORS_FOLDER_PATH = "CustomCursors";

		private Harmony _harmony;

		public static TootTallySettingPage settingPage;

		public ConfigEntry<bool> ModuleConfigEnabled { get; set; }

		public bool IsConfigInitialized { get; set; }

		public string Name
		{
			get
			{
				return "CustomCursor";
			}
			set
			{
				Name = value;
			}
		}

		public ConfigEntry<string> CursorName { get; set; }

		public ConfigEntry<float> CursorSize { get; set; }

		public ConfigEntry<bool> CursorTrailEnabled { get; set; }

		public ConfigEntry<bool> TrailAdjustTrailSpeed { get; set; }

		public ConfigEntry<float> TrailSize { get; set; }

		public ConfigEntry<float> TrailLength { get; set; }

		public ConfigEntry<float> TrailSpeed { get; set; }

		public ConfigEntry<float> TrailRefreshRate { get; set; }

		public ConfigEntry<Color> TrailStartColor { get; set; }

		public ConfigEntry<Color> TrailEndColor { get; set; }

		public static void LogInfo(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}

		public static void LogError(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogError((object)msg);
		}

		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				Instance = this;
				_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				GameInitializationEvent.Register(((BaseUnityPlugin)this).Info, (Action)TryInitialize);
			}
		}

		private void TryInitialize()
		{
			ModuleConfigEnabled = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Modules", "Custom Cursor", true, "Enable Custom Cursor Module");
			TootTallyModuleManager.AddModule((ITootTallyModule)(object)this);
			Plugin.Instance.AddModuleToSettingPage((ITootTallyModule)(object)this);
		}

		public void LoadModule()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Paths.BepInExRootPath, "config/");
			ConfigFile val = new ConfigFile(text + "CustomCursor.cfg", true)
			{
				SaveOnConfigSet = true
			};
			CursorName = val.Bind<string>("CustomCursor", "CursorName", "Default", (ConfigDescription)null);
			CursorSize = val.Bind<float>("CustomCursor", "CursorSize", 1f, (ConfigDescription)null);
			CursorTrailEnabled = val.Bind<bool>("CustomCursor", "CursorTrailEnabled", false, (ConfigDescription)null);
			TrailAdjustTrailSpeed = val.Bind<bool>("CustomCursor", "TrailAdjustTrailSpeed", false, "Automatically adjust the speed of the trail to match the scroll speed.");
			TrailSize = val.Bind<float>("CustomCursor", "TrailSize", 0.5f, (ConfigDescription)null);
			TrailLength = val.Bind<float>("CustomCursor", "TrailLength", 0.1f, (ConfigDescription)null);
			TrailSpeed = val.Bind<float>("CustomCursor", "TrailSpeed", 15f, (ConfigDescription)null);
			TrailStartColor = val.Bind<Color>("CustomCursor", "TrailStartColor", Color.white, (ConfigDescription)null);
			TrailEndColor = val.Bind<Color>("CustomCursor", "TrailEndColor", Color.white, (ConfigDescription)null);
			TrailRefreshRate = val.Bind<float>("CustomCursor", "TrailRefreshRate", 0f, "Set to 0 for uncapped.");
			string text2 = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "CustomCursors");
			string text3 = Path.Combine(Paths.BepInExRootPath, "CustomCursors");
			FileHelper.TryMigrateFolder(text2, text3, true);
			settingPage = TootTallySettingsManager.AddNewPage((TootTallySettingPage)(object)new CustomCursorSettingPage());
			Plugin.TryAddThunderstoreIconToPageButton(((BaseUnityPlugin)Instance).Info.Location, Name, settingPage);
			CustomCursor.ResolvePresets(null);
			_harmony.PatchAll(typeof(CustomCursorPatches));
			LogInfo("Module loaded!");
		}

		public void UnloadModule()
		{
			_harmony.UnpatchSelf();
			settingPage.Remove();
			CustomCursor.UnloadTextures();
			LogInfo("Module unloaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TootTallyCustomCursor";

		public const string PLUGIN_NAME = "TootTallyCustomCursor";

		public const string PLUGIN_VERSION = "1.2.1";
	}
}