Decompiled source of Crossveil v0.1.1

Crossveil.dll

Decompiled 4 days ago
using System;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Crossveil.Core;
using Crossveil.Core.Models;
using Crossveil.Core.UI;
using Crossveil.Core.UI.Components;
using Crossveil.Crosshair;
using Crossveil.Crosshair.Collections;
using Crossveil.Utils;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.UI;
using Stunlock.Core;
using Stunlock.Localization;
using TMPro;
using UnityEngine;
using UnityEngine.TextCore;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Crossveil")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A V Rising mod to customize your crosshairs")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+2.Branch.master.Sha.f772f038b779167daa86da3f0ac833831eb8c558.f772f038b779167daa86da3f0ac833831eb8c558")]
[assembly: AssemblyProduct("Crossveil")]
[assembly: AssemblyTitle("Crossveil")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[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 Crossveil
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Crossveil";

		public const string PLUGIN_NAME = "Crossveil";

		public const string PLUGIN_VERSION = "0.1.1";
	}
}
namespace Crossveil.Utils
{
	public static class HotspotUtils
	{
		public static Vector2 GetHotspot(int index, Texture2D tex)
		{
			//IL_004d: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Texture)tex).width;
			float num2 = ((Texture)tex).height;
			return (Vector2)(index switch
			{
				0 => new Vector2(num * 0.5f, num2 * 0.5f), 
				1 => Vector2.zero, 
				2 => new Vector2(num - 1f, 0f), 
				3 => new Vector2(0f, num2 - 1f), 
				4 => new Vector2(num - 1f, num2 - 1f), 
				5 => new Vector2(0f, num2 * 0.5f), 
				6 => new Vector2(num - 1f, num2 * 0.5f), 
				7 => new Vector2(num * 0.5f, 0f), 
				8 => new Vector2(num * 0.5f, num2 - 1f), 
				_ => new Vector2(num * 0.5f, num2 * 0.5f), 
			});
		}
	}
	public static class TextureUtils
	{
		public static Texture2D LoadFromFile(string path, bool linear = true)
		{
			return LoadAndLinearise(File.ReadAllBytes(path), linear);
		}

		public static Texture2D FromByteArray(this byte[] bytes)
		{
			return LoadAndLinearise(bytes, linear: true);
		}

		public static Sprite ToSprite(this Texture2D tex, Rect pixelrect)
		{
			//IL_0001: 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)
			return Sprite.Create(tex, pixelrect, new Vector2(0.5f, 0.5f), 100f);
		}

		public static Texture2D ScaledCopy(this Texture2D src, float factor)
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00f7: Expected O, but got Unknown
			try
			{
				if ((Object)(object)src == (Object)null)
				{
					Plugin.Log.LogError((object)"[ScaledCopy] Source texture is null.");
					return null;
				}
				int num = Mathf.Max(1, Mathf.RoundToInt((float)((Texture)src).width * factor));
				int num2 = Mathf.Max(1, Mathf.RoundToInt((float)((Texture)src).height * factor));
				RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
				if ((Object)(object)temporary == (Object)null)
				{
					Plugin.Log.LogError((object)"[ScaledCopy] Failed to get temporary RenderTexture.");
					return null;
				}
				Graphics.Blit((Texture)(object)src, temporary);
				RenderTexture active = RenderTexture.active;
				RenderTexture.active = temporary;
				Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false, true);
				val.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0);
				val.Apply();
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
				((Object)val).name = ((Object)src).name + "_scaled";
				((Texture)val).filterMode = ((Texture)src).filterMode;
				((Texture)val).anisoLevel = ((Texture)src).anisoLevel;
				val.Apply(false, false);
				return val;
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ScaledCopy] Exception during scaling: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				log.LogError(val2);
				return null;
			}
		}

		private static Texture2D LoadAndLinearise(byte[] data, bool linear)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false, linear);
			ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(data));
			if (linear)
			{
				AdjustBrightnessInPlace(val, 1.25f);
			}
			return val;
		}

		public static void AdjustBrightnessInPlace(Texture2D tex, float factor)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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)
			Color[] array = Il2CppArrayBase<Color>.op_Implicit((Il2CppArrayBase<Color>)(object)tex.GetPixels());
			for (int i = 0; i < array.Length; i++)
			{
				Color val = array[i];
				val.r = Mathf.Clamp01(val.r * factor);
				val.g = Mathf.Clamp01(val.g * factor);
				val.b = Mathf.Clamp01(val.b * factor);
				array[i] = val;
			}
			tex.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
			tex.Apply();
		}
	}
}
namespace Crossveil.Patches
{
	[HarmonyPatch(typeof(SetCursorSystem), "OnUpdate")]
	internal static class Patch_SetCursorSystem_OnUpdate
	{
		private static bool _originalsCached;

		private static void Postfix(SetCursorSystem __instance)
		{
			Il2CppReferenceArray<CursorData> cursorDatas = CursorController._CursorDatas;
			if (!_originalsCached)
			{
				CrosshairCache.CacheOriginals(Il2CppArrayBase<CursorData>.op_Implicit((Il2CppArrayBase<CursorData>)(object)cursorDatas));
				_originalsCached = true;
			}
			CrosshairManager.ApplyCurrent();
		}
	}
}
namespace Crossveil.Patch
{
	[HarmonyPatch]
	internal static class HUDMenu_Patch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDMenu), "OnEnable")]
		private static void OnEnable()
		{
			Plugin.inMenuState = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDMenu), "OnDisable")]
		private static void OnDisable()
		{
			Plugin.inMenuState = false;
		}
	}
	[HarmonyPatch(typeof(OptionsPanel_Interface), "Start")]
	internal static class Patch_OptionsPanel_Interface
	{
		private static SettingsEntry_Dropdown _crosshairDropdown;

		[HarmonyPostfix]
		private static void Postfix(OptionsPanel_Interface __instance)
		{
			new CustomHeader().Panel(__instance).Label("Crossveil 0.1.1").Build();
			new CustomToggle().Panel(__instance).Label("Enable Mod").Tooltip("<align=\"center\">Enable or disable the mod.</align>")
				.DefaultValue(defaultValue: false)
				.InitialValue(Config.ModEnabled.Value)
				.OnValueChanged(OnModEnabledToggle)
				.Build();
			new CustomToggle().Panel(__instance).Label("Hide Crosshair").Tooltip("<align=\"center\">Hide the game crosshair except inside menus.</align>")
				.DefaultValue(defaultValue: false)
				.InitialValue(Config.HideCrosshair.Value)
				.OnValueChanged(OnHideCrosshairToggle)
				.Build();
			new CustomToggle().Panel(__instance).Label("Use Windows Cursor").Tooltip("<align=\"center\">Uses your system crosshair as the default crosshair.</align>")
				.DefaultValue(defaultValue: false)
				.InitialValue(Config.UseWindows.Value)
				.OnValueChanged(OnUseWindowsCursor)
				.Build();
			new CustomToggle().Panel(__instance).Label("Change In Menus").Tooltip("<align=\"center\">Show the crosshair inside game menus.</align>")
				.DefaultValue(defaultValue: false)
				.InitialValue(Config.ChangeInMenus.Value)
				.OnValueChanged(OnChangeInMenusToggle)
				.Build();
			new CustomDropdown().Panel(__instance).Type(CustomDropdown.DropdownType.COLLECTION).Label("Crosshair Collection")
				.Tooltip("<align=\"center\">Select a crosshair collection.\n\n\n<color=#ecdd1f><b>MANAGE COLLECTIONS</b></color>\n\n<size=75%>Go to the game install folder then open this path:\n<b><color=#e6e6e6>BepInEx\\config\\Crossveil</color></b>\n\nEach folder inside the directory containing <color=#FF0000>at least one <b>.png</b> image</color> will be imported as a unique collection at startup.\n\nFor the best results use evenly sized images like <b>32x32</b>, <b>64x64</b> or <b>128x128</b> for example.</size></align>")
				.InitialValue(Config.CollectionIndex.Value)
				.DefaultValue(0)
				.OnValueChanged(OnCollectionChanged)
				.Build();
			_crosshairDropdown = new CustomDropdown().Panel(__instance).Type(CustomDropdown.DropdownType.CROSSHAIR).Label("Selected Crosshair")
				.Tooltip("<align=\"center\">Select the crosshair you would like to use.</size>")
				.InitialValue(Config.CrosshairIndex.Value)
				.DefaultValue(0)
				.OnValueChanged(OnCrosshairChanged)
				.Build();
			new CustomDropdown().Panel(__instance).Type(CustomDropdown.DropdownType.HOTSPOT).Label("Selected Hotspot")
				.Tooltip("<align=\"center\">Switch the crosshair hotspot.\n\n\n<color=#ecdd1f><b>INFORMATION</b></color>\n\n<size=75%>The crosshair hotspot defines the exact point used for targeting. For example if set to \"Center\" the clickable area of the loaded crosshair will be in the exact center of the image.\n\nYou can try different hotspots for different crosshairs, as some textures such as ones pointing to a specific corner may work better with one of the other modes.</size></align>")
				.InitialValue(Config.HotspotIndex.Value)
				.DefaultValue(0)
				.OnValueChanged(OnHotspotChanged)
				.Build();
			new CustomToggle().Panel(__instance).Label("Enable Crosshair Scaling").Tooltip("<align=\"center\">Scale the crosshair size up or down.\n\n\n<color=#FF0000><b>WARNING</b></color>\n\n<size=75%>This setting forces software-rendering for the crosshair. In addition it will ONLY work ingame, not inside menus. The setting also may or may not have a negative impact on performance, colouration of the image or hotspot locations.\n\nFor best results only use imported images that are equal in dimensions and preferably ones that point to an obvious hotspot area like the middle of the image or the top left corner.</size></align>")
				.InitialValue(Config.ScaleEnabled.Value)
				.DefaultValue(defaultValue: false)
				.OnValueChanged(OnScalingEnabled)
				.Build();
			new CustomSlider().Panel(__instance).Label("Scaling factor").MinValue(0.1f)
				.MaxValue(5f)
				.InitialValue(Config.ScaleFactor.Value)
				.DefaultValue(1f)
				.OnValueChanged(OnScaleFactorChanged)
				.Build();
		}

		private static void OnModEnabledToggle(bool value)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Config.ModEnabled.Value = value;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Mod enabled changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
			}
			log.LogInfo(val);
			CrosshairManager.ApplyCurrent();
		}

		private static void OnHideCrosshairToggle(bool value)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Config.HideCrosshair.Value = value;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Hide crosshair changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
			}
			log.LogInfo(val);
			CrosshairManager.ApplyCurrent();
		}

		private static void OnUseWindowsCursor(bool value)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Config.UseWindows.Value = value;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Use windows crosshair changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
			}
			log.LogInfo(val);
			CrosshairManager.ApplyCurrent();
		}

		private static void OnChangeInMenusToggle(bool value)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Config.ChangeInMenus.Value = value;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Change in menu changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
			}
			log.LogInfo(val);
			CrosshairManager.ApplyCurrent();
		}

		private static void OnCollectionChanged(int index)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			Config.CollectionIndex.Value = index;
			Config.CrosshairIndex.Value = 0;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Collection index changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(index);
			}
			log.LogInfo(val);
			TMP_Dropdown componentInChildren = ((Component)_crosshairDropdown).GetComponentInChildren<TMP_Dropdown>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				List<string> crosshairOptions = Plugin.Collections.GetCrosshairOptions(Config.CollectionIndex.Value);
				componentInChildren.ClearOptions();
				componentInChildren.AddOptions(crosshairOptions);
				componentInChildren.RefreshShownValue();
			}
			CrosshairManager.ApplyCurrent();
		}

		private static void OnCrosshairChanged(int index)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Config.CrosshairIndex.Value = index;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Crosshair index changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(index);
			}
			log.LogInfo(val);
			CrosshairManager.ApplyCurrent();
		}

		private static void OnHotspotChanged(int index)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Config.HotspotIndex.Value = index;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Hotspot index changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(index);
			}
			log.LogInfo(val);
			CrosshairManager.ApplyCurrent();
		}

		private static void OnScalingEnabled(bool value)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Config.ScaleEnabled.Value = value;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Enable scaling changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
			}
			log.LogInfo(val);
			CrosshairManager.ApplyCurrent();
		}

		private static void OnScaleFactorChanged(float value)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Config.ScaleFactor.Value = value;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Scaling factor changed to: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(value);
			}
			log.LogInfo(val);
			CrosshairManager.ApplyCurrent();
		}
	}
}
namespace Crossveil.Crosshair
{
	public static class CrosshairCache
	{
		private static readonly Dictionary<(int collectionIndex, int crosshairIndex, float scale), Texture2D> _scaledCrosshairs = new Dictionary<(int, int, float), Texture2D>();

		public static readonly Dictionary<CursorType, CursorData> OriginalCrosshairs = new Dictionary<CursorType, CursorData>();

		public static void ClearScaled()
		{
			_scaledCrosshairs.Clear();
		}

		public static void ClearOriginal()
		{
			OriginalCrosshairs.Clear();
		}

		public static Texture2D GetOrAddScaled(int collectionIndex, int crosshairIndex, Texture2D tex, float scale)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			(int, int, float) key = (collectionIndex, crosshairIndex, scale);
			if (_scaledCrosshairs.TryGetValue(key, out var value))
			{
				return value;
			}
			Texture2D val = tex.ScaledCopy(scale);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(53, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Scaling] Failed to scale crosshair at ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(collectionIndex);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(":");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(crosshairIndex);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" with factor ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(scale);
				}
				log.LogError(val2);
				return null;
			}
			_scaledCrosshairs[key] = val;
			return val;
		}

		public static void CacheOriginals(CursorData[] dataArray)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			foreach (CursorData val in dataArray)
			{
				if (!OriginalCrosshairs.ContainsKey(val.CursorType))
				{
					CursorData value = new CursorData
					{
						CursorType = val.CursorType,
						Hotspot = val.Hotspot,
						Texture = val.Texture
					};
					OriginalCrosshairs[val.CursorType] = value;
				}
			}
			Plugin.Log.LogInfo((object)"Original crosshairs cached.");
		}

		public static CursorData RestoreOriginal(CursorType type)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (OriginalCrosshairs.TryGetValue(type, out var value))
			{
				return value;
			}
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cache not found for CursorType: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<CursorType>(type);
			}
			log.LogWarning(val);
			return null;
		}
	}
	public static class CrosshairManager
	{
		public static bool isMenuContext;

		public static void ApplyCurrent()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			bool num = ViewManager.IsInMenu();
			bool inMenuState = Plugin.inMenuState;
			isMenuContext = num || inMenuState;
			if (!Config.ModEnabled.Value)
			{
				if (isMenuContext)
				{
					RestoreOriginal((CursorType)1);
				}
				else
				{
					RestoreOriginal((CursorType)0);
				}
				return;
			}
			CursorType type = (CursorType)(isMenuContext ? 1 : 0);
			bool value = Config.ChangeInMenus.Value;
			if (isMenuContext && !value)
			{
				RestoreOriginal((CursorType)1);
				return;
			}
			CursorData customCrosshair = GetCustomCrosshair(type);
			if (customCrosshair != null)
			{
				ApplyCursor(customCrosshair);
			}
		}

		private static CursorData GetCustomCrosshair(CursorType type)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00de: Expected O, but got Unknown
			int value = Config.CollectionIndex.Value;
			int value2 = Config.CrosshairIndex.Value;
			float value3 = Config.ScaleFactor.Value;
			bool value4 = Config.ScaleEnabled.Value;
			CustomCollection customCollection = Plugin.Collections.GetList().ElementAtOrDefault(value);
			if (customCollection == null || customCollection.Crosshairs.Count == 0)
			{
				return null;
			}
			CustomCrosshair customCrosshair = customCollection.Crosshairs.ElementAtOrDefault(value2);
			if (customCrosshair == null || (Object)(object)customCrosshair.Texture == (Object)null)
			{
				return null;
			}
			Texture2D val = customCrosshair.Texture;
			if (value4 && value3 != 1f && !isMenuContext)
			{
				val = CrosshairCache.GetOrAddScaled(value, value2, customCrosshair.Texture, value3);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
			}
			Vector2 hotspot = HotspotUtils.GetHotspot(Config.HotspotIndex.Value, val);
			return new CursorData
			{
				CursorType = type,
				Texture = val,
				Hotspot = hotspot
			};
		}

		private static void RestoreOriginal(CursorType type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			CursorData val = CrosshairCache.RestoreOriginal(type);
			if (val != null)
			{
				ApplyCursor(val, (CursorMode)0);
			}
		}

		private static void ApplyCursor(CursorData cursor, CursorMode? overrideMode = null)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (cursor != null && !((Object)(object)cursor.Texture == (Object)null))
			{
				Texture2D val = cursor.Texture;
				CursorType cursorType = cursor.CursorType;
				CursorMode val2 = (CursorMode)(((int?)overrideMode) ?? (Config.ScaleEnabled.Value ? 1 : 0));
				if (Config.ModEnabled.Value)
				{
					val = ((((object)(CursorType)(ref cursorType)).Equals((object)(CursorType)1) && Config.ChangeInMenus.Value && Config.UseWindows.Value) ? null : val);
					val = ((((object)(CursorType)(ref cursorType)).Equals((object)(CursorType)0) && Config.UseWindows.Value) ? null : val);
				}
				Cursor.SetCursor(val, cursor.Hotspot, val2);
				if (Config.ModEnabled.Value && Config.HideCrosshair.Value && !isMenuContext)
				{
					Cursor.visible = false;
				}
			}
		}
	}
}
namespace Crossveil.Crosshair.Collections
{
	public static class CollectionImport
	{
		public static void Standard()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (!text.StartsWith("Crossveil.Embedded.") || !text.EndsWith(".png"))
				{
					continue;
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				if (stream != null)
				{
					byte[] bytes;
					using (MemoryStream memoryStream = new MemoryStream())
					{
						stream.CopyTo(memoryStream);
						bytes = memoryStream.ToArray();
					}
					Texture2D val = bytes.FromByteArray();
					((Object)val).name = text.Replace("Crossveil.Embedded.", "").Replace(".png", "");
					((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20);
					Plugin.Collections.Add(val, "Standard");
				}
			}
		}

		public static void Custom()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			string path = Path.Combine(Paths.ConfigPath, "Crossveil");
			if (!Directory.Exists(path))
			{
				Directory.CreateDirectory(path);
			}
			string[] directories = Directory.GetDirectories(path);
			foreach (string path2 in directories)
			{
				string fileName = Path.GetFileName(path2);
				string[] files = Directory.GetFiles(path2, "*.png", SearchOption.TopDirectoryOnly);
				foreach (string path3 in files)
				{
					Texture2D val = TextureUtils.LoadFromFile(path3);
					((Object)val).name = Path.GetFileNameWithoutExtension(path3);
					((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20);
					Plugin.Collections.Add(val, fileName);
				}
			}
		}
	}
	public class CollectionRegistry
	{
		private readonly List<CustomCollection> _collections;

		public CollectionRegistry()
		{
			_collections = new List<CustomCollection>();
		}

		public List<string> GetCrosshairOptions(int collectionIndex)
		{
			CustomCollection customCollection = Plugin.Collections.GetList()[collectionIndex];
			List<string> val = new List<string>();
			foreach (CustomCrosshair crosshair in customCollection.Crosshairs)
			{
				string text = customCollection.Name + "_" + crosshair.Name;
				val.Add("<sprite name=\"" + text + "\">  " + crosshair.Name);
			}
			return val;
		}

		public List<CustomCollection> GetList()
		{
			return _collections;
		}

		public void Add(Texture2D texture, string collection)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			bool flag = default(bool);
			if (!_collections.Any((CustomCollection col) => col.Name == collection))
			{
				_collections.Add(new CustomCollection(collection, new List<CustomCrosshair>()));
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Created collection with: name=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(collection);
				}
				log.LogInfo(val);
			}
			CustomCollection customCollection = _collections.FirstOrDefault((CustomCollection c) => c.Name.Equals(collection, StringComparison.OrdinalIgnoreCase));
			if (customCollection != null)
			{
				customCollection.Crosshairs.Add(new CustomCrosshair(texture));
				ManualLogSource log2 = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Added texture with name=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)texture).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".png");
				}
				log2.LogInfo(val);
			}
		}
	}
}
namespace Crossveil.Core
{
	public class Config
	{
		internal static ConfigEntry<bool> ModEnabled;

		internal static ConfigEntry<bool> HideCrosshair;

		internal static ConfigEntry<bool> UseWindows;

		internal static ConfigEntry<bool> ChangeInMenus;

		internal static ConfigEntry<int> CollectionIndex;

		internal static ConfigEntry<int> CrosshairIndex;

		internal static ConfigEntry<int> HotspotIndex;

		internal static ConfigEntry<bool> ScaleEnabled;

		internal static ConfigEntry<float> ScaleFactor;

		internal static void Initialize(ConfigFile config)
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			config.SaveOnConfigSet = true;
			ModEnabled = config.Bind<bool>("Options", "EnableCustomCrosshair", false, "Selected option to enable the mod.");
			HideCrosshair = config.Bind<bool>("Options", "HideCrosshair", false, "Hides the game crosshair.");
			UseWindows = config.Bind<bool>("Options", "UseWindows", false, "Uses the windows cursor");
			ChangeInMenus = config.Bind<bool>("Options", "ChangeInMenus", false, "Selected option to change menu crosshairs.");
			ScaleEnabled = config.Bind<bool>("Options", "ScaleEnabled", false, "Selected option to change menu crosshairs.");
			CollectionIndex = config.Bind<int>("Variables", "CrosshairCollection", 0, "Selected collection.");
			CrosshairIndex = config.Bind<int>("Variables", "CrosshairStyle", 0, "Selected crosshair.");
			HotspotIndex = config.Bind<int>("Variables", "HotspotIndex", 0, "Selected hotspot.");
			ScaleFactor = config.Bind<float>("Variables", "ScaleFactor", 1f, "Scale factor");
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Initialized configuration file");
			}
			log.LogInfo(val);
		}
	}
	[BepInPlugin("Crossveil", "Crossveil", "0.1.1")]
	public class Plugin : BasePlugin
	{
		private static Harmony _harmony;

		public static ManualLogSource Log { get; private set; }

		public static CollectionRegistry Collections { get; set; }

		public static SpriteAtlas SpriteAsset { get; set; }

		public static bool inMenuState { get; set; }

		public override void Load()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			Config.Initialize(((BasePlugin)this).Config);
			Collections = new CollectionRegistry();
			CollectionImport.Standard();
			CollectionImport.Custom();
			SpriteAsset = new SpriteAtlas();
			_harmony = new Harmony("Crossveil");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Crossveil");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.1");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
		}

		public override bool Unload()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
}
namespace Crossveil.Core.Models
{
	public class CustomCollection
	{
		public string Name { get; }

		public List<CustomCrosshair> Crosshairs { get; }

		public CustomCollection(string name, List<CustomCrosshair> items)
		{
			Name = name;
			Crosshairs = items;
		}
	}
	public class CustomCrosshair
	{
		public Texture2D Texture { get; }

		public int Width { get; }

		public int Height { get; }

		public string Name { get; }

		public CustomCrosshair(Texture2D texture)
		{
			Texture = texture;
			Name = ((Object)texture).name;
			Width = ((Texture)texture).width;
			Height = ((Texture)texture).height;
		}
	}
}
namespace Crossveil.Core.UI
{
	public sealed class SpriteAtlas
	{
		private TMP_SpriteAsset _atlas;

		public TMP_SpriteAsset Atlas => _atlas;

		public SpriteAtlas()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			TMP_SpriteAsset defaultSpriteAsset = TMP_Settings.defaultSpriteAsset;
			_atlas = Object.Instantiate<TMP_SpriteAsset>(defaultSpriteAsset);
			((Object)_atlas).name = "CrosshairPreviews";
			TMP_SpriteAsset atlas = _atlas;
			((Object)atlas).hideFlags = (HideFlags)(((Object)atlas).hideFlags | 0x20);
			_atlas.spriteInfoList.Clear();
			_atlas.spriteGlyphTable.Clear();
			_atlas.spriteCharacterTable.Clear();
			_atlas.spriteCharacterLookupTable.Clear();
			_atlas.fallbackSpriteAssets.Clear();
			BuildSpriteAsset();
		}

		private void BuildSpriteAsset()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Expected O, but got Unknown
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Expected O, but got Unknown
			var array = (from col in Plugin.Collections.GetList()
				where col != null
				select col).SelectMany(delegate(CustomCollection col)
			{
				IEnumerable<CustomCrosshair> crosshairs = col.Crosshairs;
				return from ch in crosshairs ?? Enumerable.Empty<CustomCrosshair>()
					where (Object)(object)ch?.Texture != (Object)null
					select new
					{
						Collection = col.Name,
						Texture = ch.Texture
					};
			}).ToArray();
			if (array.Length == 0)
			{
				return;
			}
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			Rect[] array2 = Il2CppArrayBase<Rect>.op_Implicit((Il2CppArrayBase<Rect>)(object)val.PackTextures(Il2CppReferenceArray<Texture2D>.op_Implicit(array.Select(e => e.Texture).ToArray()), 2, 2048));
			val.Apply();
			_atlas.spriteSheet = (Texture)(object)val;
			Material val2 = new Material(Shader.Find("TextMeshPro/Sprite"))
			{
				mainTexture = (Texture)(object)val
			};
			((TMP_Asset)_atlas).material = val2;
			((TMP_Asset)_atlas).materialHashCode = ((Object)val2).GetInstanceID();
			uint num = 57344u;
			Rect pixelrect = default(Rect);
			GlyphRect glyphRect = default(GlyphRect);
			for (int i = 0; i < array.Length; i++)
			{
				var anon = array[i];
				Texture2D texture = anon.Texture;
				Rect val3 = array2[i];
				((Rect)(ref pixelrect))..ctor(((Rect)(ref val3)).x * (float)((Texture)val).width, ((Rect)(ref val3)).y * (float)((Texture)val).height, ((Rect)(ref val3)).width * (float)((Texture)val).width, ((Rect)(ref val3)).height * (float)((Texture)val).height);
				((GlyphRect)(ref glyphRect))..ctor((int)((Rect)(ref pixelrect)).x, (int)((Rect)(ref pixelrect)).y, (int)((Rect)(ref pixelrect)).width, (int)((Rect)(ref pixelrect)).height);
				Sprite val4 = val.ToSprite(pixelrect);
				((Object)val4).name = anon.Collection + "_" + ((Object)texture).name;
				TMP_SpriteGlyph val5 = new TMP_SpriteGlyph
				{
					index = (uint)i,
					glyphRect = glyphRect,
					scale = 1f,
					sprite = val4
				};
				((Glyph)val5).metrics = new GlyphMetrics((float)(int)((Rect)(ref pixelrect)).width, (float)(int)((Rect)(ref pixelrect)).height, 0f, (float)(int)((Rect)(ref pixelrect)).height * 0.8f, (float)(int)((Rect)(ref pixelrect)).width);
				_atlas.spriteGlyphTable.Add(val5);
				TMP_SpriteCharacter val6 = new TMP_SpriteCharacter((uint)(num + i), val5)
				{
					name = ((Object)val4).name,
					scale = 1f
				};
				_atlas.spriteCharacterTable.Add(val6);
				_atlas.spriteInfoList.Add(new TMP_Sprite
				{
					name = ((Object)val4).name,
					unicode = (int)(num + i),
					hashCode = TMP_TextUtilities.GetSimpleHashCode(((Object)val4).name),
					pivot = val4.pivot,
					sprite = val4
				});
			}
			_atlas.UpdateLookupTables();
			_atlas.SortGlyphTable();
			_atlas.SortCharacterTable();
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val7 = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("Built sprite atlas with ");
				((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<int>(array.Length);
				((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(" imported textures");
			}
			log.LogInfo(val7);
			for (int j = 0; j < _atlas.spriteInfoList.Count; j++)
			{
				TMP_Sprite val8 = _atlas.spriteInfoList[j];
				ManualLogSource log2 = Plugin.Log;
				val7 = new BepInExInfoLogInterpolatedStringHandler(29, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("[");
					((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<int>(j);
					((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("] name=\"");
					((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<string>(val8.name);
					((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("\"  unicode=0x");
					((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<int>(val8.unicode, "X");
					((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("  hash=");
					((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<int>(val8.hashCode);
				}
				log2.LogInfo(val7);
			}
		}
	}
}
namespace Crossveil.Core.UI.Components
{
	internal class CustomDropdown
	{
		public enum DropdownType
		{
			COLLECTION,
			CROSSHAIR,
			HOTSPOT
		}

		private OptionsPanel_Interface _panel;

		private DropdownType _type;

		private string _label;

		private string _tooltip;

		private List<string> _options = new List<string>();

		private int _defaultValue;

		private int _initialValue;

		private Action<int> _onValueChanged;

		public CustomDropdown Panel(OptionsPanel_Interface panel)
		{
			_panel = panel;
			return this;
		}

		public CustomDropdown Type(DropdownType type)
		{
			_type = type;
			return this;
		}

		public CustomDropdown Label(string label)
		{
			_label = label;
			return this;
		}

		public CustomDropdown Tooltip(string tooltip)
		{
			_tooltip = tooltip;
			return this;
		}

		public CustomDropdown DefaultValue(int defaultValue)
		{
			_defaultValue = defaultValue;
			return this;
		}

		public CustomDropdown InitialValue(int initialValue)
		{
			_initialValue = initialValue;
			return this;
		}

		public CustomDropdown OnValueChanged(Action<int> callback)
		{
			_onValueChanged = callback;
			return this;
		}

		public SettingsEntry_Dropdown Build()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			AssetGuid val = AssetGuid.NewGuid();
			LocalizationKey val2 = default(LocalizationKey);
			((LocalizationKey)(ref val2))..ctor(val);
			AssetGuid val3 = AssetGuid.NewGuid();
			LocalizationKey val4 = default(LocalizationKey);
			((LocalizationKey)(ref val4))..ctor(val3);
			if (_label != null)
			{
				Localization.LocalizedStrings.Add(val, _label);
			}
			if (_tooltip != null)
			{
				Localization.LocalizedStrings.Add(val3, _tooltip);
			}
			PopulateOptions(_type);
			SettingsEntry_Dropdown val5 = OptionsHelper.AddDropdown(_panel.ContentNode, _panel.DropdownPrefab, false, val2, val4, _options, _defaultValue, _initialValue, Action<int>.op_Implicit(_onValueChanged));
			TMP_Dropdown componentInChildren = ((Component)val5).GetComponentInChildren<TMP_Dropdown>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return null;
			}
			RectTransform component = ((Component)componentInChildren).GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(-300f, component.sizeDelta.y);
			componentInChildren.captionText.richText = true;
			componentInChildren.captionText.spriteAsset = Plugin.SpriteAsset.Atlas;
			componentInChildren.captionText.alignment = (TextAlignmentOptions)513;
			componentInChildren.itemText.richText = true;
			componentInChildren.itemText.spriteAsset = Plugin.SpriteAsset.Atlas;
			componentInChildren.itemText.alignment = (TextAlignmentOptions)514;
			((DatalessSelectionGroupBase<SettingsEntryBase>)(object)_panel.EntriesSelectionGroup).Entries.Add((SettingsEntryBase)(object)val5);
			return val5;
		}

		private void PopulateOptions(DropdownType type)
		{
			List<CustomCollection> list = Plugin.Collections.GetList();
			List<string> crosshairOptions = Plugin.Collections.GetCrosshairOptions(Config.CollectionIndex.Value);
			switch (type)
			{
			case DropdownType.COLLECTION:
			{
				foreach (CustomCollection item in list)
				{
					_options.Add(item.Name);
				}
				break;
			}
			case DropdownType.CROSSHAIR:
			{
				Enumerator<string> enumerator = crosshairOptions.GetEnumerator();
				while (enumerator.MoveNext())
				{
					string current = enumerator.Current;
					_options.Add(current);
				}
				break;
			}
			case DropdownType.HOTSPOT:
				_options.Add("Center");
				_options.Add("Top Left");
				_options.Add("Top Right");
				_options.Add("Bottom Left");
				_options.Add("Bottom Right");
				_options.Add("Center Left");
				_options.Add("Center Right");
				_options.Add("Top Center");
				_options.Add("Bottom Center");
				break;
			}
		}
	}
	internal class CustomHeader
	{
		private OptionsPanel_Interface _panel;

		private string _label;

		public CustomHeader Panel(OptionsPanel_Interface panel)
		{
			_panel = panel;
			return this;
		}

		public CustomHeader Label(string label)
		{
			_label = label;
			return this;
		}

		public SettingsEntry_Label Build()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			AssetGuid val = AssetGuid.NewGuid();
			LocalizationKey val2 = default(LocalizationKey);
			((LocalizationKey)(ref val2))..ctor(val);
			Localization.LocalizedStrings.Add(val, _label);
			SettingsEntry_Label obj = OptionsHelper.AddHeader(_panel.ContentNode, _panel.HeaderPrefab, val2);
			((TMP_Text)((SettingsEntryBase)obj).HeaderText.Text).text = _label;
			return obj;
		}
	}
	internal class CustomSlider
	{
		private OptionsPanel_Interface _panel;

		private string _label;

		private float _minvalue;

		private float _maxvalue;

		private float _defaultvalue;

		private float _initialvalue;

		private Action<float> _onValueChanged;

		public CustomSlider Panel(OptionsPanel_Interface panel)
		{
			_panel = panel;
			return this;
		}

		public CustomSlider Label(string label)
		{
			_label = label;
			return this;
		}

		public CustomSlider MinValue(float defaultValue)
		{
			_minvalue = defaultValue;
			return this;
		}

		public CustomSlider MaxValue(float initialValue)
		{
			_maxvalue = initialValue;
			return this;
		}

		public CustomSlider DefaultValue(float defaultValue)
		{
			_defaultvalue = defaultValue;
			return this;
		}

		public CustomSlider InitialValue(float initialValue)
		{
			_initialvalue = initialValue;
			return this;
		}

		public CustomSlider OnValueChanged(Action<float> callback)
		{
			_onValueChanged = callback;
			return this;
		}

		public SettingsEntry_Slider Build()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			AssetGuid val = AssetGuid.NewGuid();
			LocalizationKey val2 = default(LocalizationKey);
			((LocalizationKey)(ref val2))..ctor(val);
			if (_label != null)
			{
				Localization.LocalizedStrings.Add(val, _label);
			}
			return OptionsHelper.AddSlider(_panel.ContentNode, _panel.SliderPrefab, false, val2, default(Nullable_Unboxed<LocalizationKey>), _minvalue, _maxvalue, _defaultvalue, _initialvalue, 1, false, Action<float>.op_Implicit(_onValueChanged));
		}
	}
	internal class CustomToggle
	{
		private OptionsPanel_Interface _panel;

		private string _label;

		private string _tooltip;

		private bool _defaultValue;

		private bool _initialValue;

		private Action<bool> _onValueChanged;

		public CustomToggle Panel(OptionsPanel_Interface panel)
		{
			_panel = panel;
			return this;
		}

		public CustomToggle Label(string label)
		{
			_label = label;
			return this;
		}

		public CustomToggle Tooltip(string tooltip)
		{
			_tooltip = tooltip;
			return this;
		}

		public CustomToggle DefaultValue(bool defaultValue)
		{
			_defaultValue = defaultValue;
			return this;
		}

		public CustomToggle InitialValue(bool initialValue)
		{
			_initialValue = initialValue;
			return this;
		}

		public CustomToggle OnValueChanged(Action<bool> callback)
		{
			_onValueChanged = callback;
			return this;
		}

		public SettingsEntry_Checkbox Build()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			AssetGuid val = AssetGuid.NewGuid();
			LocalizationKey val2 = default(LocalizationKey);
			((LocalizationKey)(ref val2))..ctor(val);
			AssetGuid val3 = AssetGuid.NewGuid();
			LocalizationKey val4 = default(LocalizationKey);
			((LocalizationKey)(ref val4))..ctor(val3);
			if (_label != null)
			{
				Localization.LocalizedStrings.Add(val, _label);
			}
			if (_tooltip != null)
			{
				Localization.LocalizedStrings.Add(val3, _tooltip);
			}
			SettingsEntry_Checkbox val5 = OptionsHelper.AddCheckbox(_panel.ContentNode, _panel.CheckboxPrefab, false, val2, val4, _defaultValue, _initialValue, Action<bool>.op_Implicit(_onValueChanged), (Func<bool>)null);
			if (_tooltip != null)
			{
				((DatalessSelectionGroupBase<SettingsEntryBase>)(object)_panel.EntriesSelectionGroup).Entries.Add((SettingsEntryBase)(object)val5);
			}
			return val5;
		}
	}
}