Decompiled source of ModConfig v0.1.3

plugins/com.atomic.modconfig.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModConfig.Core;
using ModConfig.UI;
using ModConfig.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Localization.Components;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("GameAssembly")]
[assembly: IgnoresAccessChecksTo("SharedAssembly")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.atomic.modconfig")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.3.0")]
[assembly: AssemblyInformationalVersion("0.1.3+6531eb9adda1d0243108e954bdd77ead365a9e65")]
[assembly: AssemblyProduct("com.atomic.modconfig")]
[assembly: AssemblyTitle("ModConfig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = 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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace ModConfig
{
	[BepInPlugin("com.atomic.modconfig", "ModConfig", "0.1.3")]
	public class Plugin : BaseUnityPlugin
	{
		public static Harmony harmony;

		public static bool shownErrorThisSession;

		public const string Id = "com.atomic.modconfig";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "ModConfig";

		public static string Version => "0.1.3";

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			harmony = new Harmony("com.atomic.modconfig");
			harmony.PatchAll();
		}

		public static bool IsBepInExModInstalled(string guid)
		{
			return Chainloader.PluginInfos.ContainsKey(guid);
		}
	}
	[HarmonyPatch]
	public static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(MenuTabs), "Awake")]
		public static void HookIntoGUI(MenuTabs __instance)
		{
			ModConfigManager.Inject(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(FullScreenMessage), "ShowInternal")]
		public static void Keybind_Localization(ref string message, string header, bool isError, bool requiresMouse, params ButtonEntry[] buttonEntries)
		{
			if (message.Contains("UI/SETTINGS_Keybinds_ModConfigMap_"))
			{
				string text = message.Replace("UI/SETTINGS_Keybinds_ModConfigMap_", "");
				message = text;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ActionRebindOption), "RefreshBindingDisplay", new Type[] { })]
		public static void KeybindFinish(ControlsRebind __instance)
		{
			KeybindHook component = ((Component)__instance).GetComponent<KeybindHook>();
			if (!((Object)(object)component == (Object)null))
			{
				component.onRebind?.Invoke();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InputIconsSet), "GetIcon")]
		public static bool getIconFix(InputIconsSet __instance, string binding, ref Sprite __result)
		{
			if (binding == "<Keyboard>/none")
			{
				__result = UICreator.getEmptyKeyIcon();
				return false;
			}
			return true;
		}
	}
}
namespace ModConfig.Utilities
{
	public class ConfigHoverHandler : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		[CompilerGenerated]
		private sealed class <WaitAndShow>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public ConfigHoverHandler <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitAndShow>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Expected O, but got Unknown
				int num = <>1__state;
				ConfigHoverHandler configHoverHandler = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSecondsRealtime(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					configHoverHandler.ShowTooltip();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public string description;

		private static GameObject tooltipBox;

		private static TextMeshProUGUI tooltipText;

		private Coroutine hoverCoroutine;

		private RectTransform labelRect;

		private void Awake()
		{
			labelRect = ((Component)this).GetComponent<RectTransform>();
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			if (!string.IsNullOrEmpty(description))
			{
				hoverCoroutine = ((MonoBehaviour)this).StartCoroutine(WaitAndShow(0.5f));
			}
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			if (hoverCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(hoverCoroutine);
			}
			if ((Object)(object)tooltipBox != (Object)null)
			{
				tooltipBox.SetActive(false);
			}
		}

		[IteratorStateMachine(typeof(<WaitAndShow>d__8))]
		private IEnumerator WaitAndShow(float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitAndShow>d__8(0)
			{
				<>4__this = this,
				delay = delay
			};
		}

		private void ShowTooltip()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)tooltipBox == (Object)null)
			{
				CreateTooltipPrefab();
			}
			tooltipBox.SetActive(true);
			((TMP_Text)tooltipText).text = description;
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			labelRect.GetWorldCorners(array);
			float num = (array[0].x + array[2].x) / 2f;
			float y = array[1].y;
			tooltipBox.transform.position = new Vector3(num, y + 5f, 0f);
			tooltipBox.transform.SetAsLastSibling();
			Canvas.ForceUpdateCanvases();
			ClampToScreen();
		}

		private void CreateTooltipPrefab()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0089: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_0164: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.Find("Canvas");
			Transform val = ((obj != null) ? obj.transform : null);
			tooltipBox = new GameObject("DescriptionTooltip", new Type[3]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			tooltipBox.transform.SetParent(val ?? ((Component)this).transform.root, false);
			RectTransform component = tooltipBox.GetComponent<RectTransform>();
			component.pivot = new Vector2(0.5f, 0f);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			HorizontalLayoutGroup component2 = tooltipBox.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component2).childControlWidth = true;
			ContentSizeFitter component3 = tooltipBox.GetComponent<ContentSizeFitter>();
			component3.verticalFit = (FitMode)2;
			component3.horizontalFit = (FitMode)2;
			GameObject val2 = new GameObject("TooltipCard", new Type[5]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter),
				typeof(Outline)
			});
			val2.transform.SetParent(tooltipBox.transform, false);
			Image component4 = val2.GetComponent<Image>();
			((Graphic)component4).color = new Color(1f, 0.98f, 0.933f, 1f);
			((Graphic)component4).raycastTarget = false;
			Outline component5 = val2.GetComponent<Outline>();
			((Shadow)component5).effectColor = new Color(0.878f, 0.89f, 0.843f, 1f);
			((Shadow)component5).effectDistance = new Vector2(4f, -4f);
			VerticalLayoutGroup component6 = val2.GetComponent<VerticalLayoutGroup>();
			((LayoutGroup)component6).padding = new RectOffset(12, 12, 12, 12);
			((HorizontalOrVerticalLayoutGroup)component6).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component6).childControlWidth = true;
			ContentSizeFitter component7 = val2.GetComponent<ContentSizeFitter>();
			component7.verticalFit = (FitMode)2;
			component7.horizontalFit = (FitMode)2;
			GameObject val3 = new GameObject("DescriptionText", new Type[3]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI),
				typeof(LayoutElement)
			});
			val3.transform.SetParent(val2.transform, false);
			tooltipText = val3.GetComponent<TextMeshProUGUI>();
			((TMP_Text)tooltipText).font = UICloner.baseFont;
			((TMP_Text)tooltipText).fontSize = 18f;
			((Graphic)tooltipText).color = Color.black;
			((TMP_Text)tooltipText).alignment = (TextAlignmentOptions)514;
			((TMP_Text)tooltipText).textWrappingMode = (TextWrappingModes)1;
			((Graphic)tooltipText).raycastTarget = false;
			LayoutElement component8 = val3.GetComponent<LayoutElement>();
			component8.preferredWidth = 550f;
			tooltipBox.SetActive(false);
		}

		private void ClampToScreen()
		{
			//IL_0057: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = tooltipBox.GetComponent<RectTransform>();
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			component.GetWorldCorners(array);
			float num = array[2].x - array[0].x;
			float num2 = array[2].y - array[0].y;
			Vector3 position = tooltipBox.transform.position;
			if (position.x - num / 2f < 0f)
			{
				position.x = num / 2f + 10f;
			}
			else if (position.x + num / 2f > (float)Screen.width)
			{
				position.x = (float)Screen.width - num / 2f - 10f;
			}
			if (position.y + num2 > (float)Screen.height)
			{
				Vector3[] array2 = (Vector3[])(object)new Vector3[4];
				labelRect.GetWorldCorners(array2);
				position.y = array2[0].y - 10f;
				component.pivot = new Vector2(0.5f, 1f);
			}
			else
			{
				component.pivot = new Vector2(0.5f, 0f);
			}
			tooltipBox.transform.position = position;
		}
	}
	public class KeybindHook : MonoBehaviour
	{
		public Action onRebind;

		public KeyCode PathToKeyCode(string path)
		{
			//IL_0031: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			if (string.IsNullOrEmpty(path))
			{
				return (KeyCode)0;
			}
			string text = (path.Contains("/") ? path.Split('/')[1] : path);
			if (Enum.TryParse<KeyCode>(text, ignoreCase: true, out KeyCode result))
			{
				return result;
			}
			return (KeyCode)(text.ToLower() switch
			{
				"escape" => 27, 
				"enter" => 13, 
				"leftshift" => 304, 
				"rightshift" => 303, 
				_ => 0, 
			});
		}
	}
}
namespace ModConfig.UI
{
	public class ModConfigMain : MonoBehaviour
	{
		private static ModConfigMain Instance;

		private static Transform graphicsPage;

		private static Transform audioPage;

		private static Transform modsPage;

		private static Transform modsContent;

		public static Transform controlsPage;

		private void Awake()
		{
			Instance = this;
			graphicsPage = ((Component)this).transform.Find("Graphics");
			audioPage = ((Component)this).transform.Find("Audio");
			controlsPage = ((Component)this).transform.Find("Controls");
			modsPage = ((Component)this).transform.Find("Mods");
			modsContent = modsPage.Find("ModContent");
			UICloner.GetUIRefs(graphicsPage, audioPage);
			if (Plugin.IsBepInExModInstalled("com.sinai.unityexplorer") && !Plugin.shownErrorThisSession)
			{
				Plugin.Log.LogWarning((object)"Unity explorer is a know incompatibility!");
			}
			UICreator.CreateMainTopBar(((Component)modsPage).gameObject, out GameObject topBarContent);
			ConfigGetter.InitialiseConfigs(((Component)modsPage).gameObject, topBarContent);
		}
	}
	public class UICloner
	{
		public static GameObject titleTMP;

		public static GameObject container;

		public static GameObject dropdown;

		public static GameObject slider;

		public static GameObject button;

		public static Sprite emptyKeyIcon;

		public static TMP_FontAsset baseFont;

		public static void GetUIRefs(Transform graphicsPage, Transform audioPage)
		{
			if (!((Object)(object)graphicsPage == (Object)null))
			{
				titleTMP = Object.Instantiate<GameObject>(((Component)graphicsPage.Find("Title")).gameObject, (Transform)null);
				((Object)titleTMP).name = "MODCONFIG_TITLE_TEMPLATE";
				Object.DestroyImmediate((Object)(object)titleTMP.GetComponentInChildren<LocalizeStringEvent>());
				baseFont = ((TMP_Text)titleTMP.GetComponent<TextMeshProUGUI>()).font;
				Transform val = Object.Instantiate<Transform>(graphicsPage.Find("Option Container"));
				((Object)val).name = "MODCONFIG_CONTAINER_TEMPLATE";
				dropdown = Object.Instantiate<GameObject>(((Component)val.Find("Resolution")).gameObject, (Transform)null);
				((Object)dropdown).name = "MODCONFIG_DROPDOWN_TEMPLATE";
				Object.DestroyImmediate((Object)(object)dropdown.GetComponentInChildren<LocalizeDropdown>());
				Object.DestroyImmediate((Object)(object)dropdown.GetComponentInChildren<LocalizeStringEvent>());
				dropdown.GetComponent<DropdownOption>().localized = null;
				button = Object.Instantiate<GameObject>(((Component)graphicsPage.parent.Find("General/Tutorial").GetChild(0)).gameObject, (Transform)null);
				((Object)button).name = "MODCONFIG_BUTTON_TEMPLATE";
				Object.DestroyImmediate((Object)(object)button.GetComponentInChildren<LocalizeStringEvent>());
				slider = Object.Instantiate<GameObject>(((Component)audioPage.Find("Volume Options/Master Volume")).gameObject);
				((Object)slider).name = "MODCONFIG_SLIDER_TEMPLATE";
				Object.DestroyImmediate((Object)(object)slider.GetComponentInChildren<LocalizeStringEvent>());
				while (((Component)val).transform.childCount > 0)
				{
					Object.DestroyImmediate((Object)(object)((Component)((Component)val).transform.GetChild(0)).gameObject);
				}
				container = ((Component)val).gameObject;
			}
		}
	}
	public class UICreator
	{
		public static void CreateMainTopBar(GameObject modsPage, out GameObject topBarContent)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_005c: 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)
			//IL_0073: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			GameObject val = new GameObject("MainTopBar", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(ScrollRect)
			});
			val.transform.SetParent(modsPage.transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0.92f);
			component.anchorMax = Vector2.one;
			Vector2 offsetMin = (component.offsetMax = Vector2.zero);
			component.offsetMin = offsetMin;
			((Graphic)val.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
			GameObject val2 = new GameObject("Viewport", new Type[2]
			{
				typeof(RectTransform),
				typeof(RectMask2D)
			});
			val2.transform.SetParent(val.transform, false);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.sizeDelta = Vector2.zero;
			topBarContent = new GameObject("Content", new Type[3]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			topBarContent.transform.SetParent(val2.transform, false);
			RectTransform component3 = topBarContent.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(0f, 1f);
			component3.pivot = new Vector2(0f, 0.5f);
			HorizontalLayoutGroup component4 = topBarContent.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component4).spacing = 20f;
			((LayoutGroup)component4).padding = new RectOffset(30, 30, 5, 5);
			topBarContent.GetComponent<ContentSizeFitter>().horizontalFit = (FitMode)2;
			topBarContent.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			ScrollRect component5 = val.GetComponent<ScrollRect>();
			component5.content = component3;
			component5.viewport = component2;
			component5.horizontal = true;
			component5.vertical = false;
		}

		public static void CreateModPage(GameObject modsPage, string modName, out GameObject page)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0097: 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_00cc: Expected O, but got Unknown
			//IL_00e7: 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)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			page = new GameObject("PAGE_" + modName, new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(ScrollRect)
			});
			page.transform.SetParent(modsPage.transform, false);
			RectTransform component = page.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = new Vector2(1f, 0.92f);
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			((Graphic)page.GetComponent<Image>()).color = Color.clear;
			GameObject val = new GameObject("Viewport", new Type[2]
			{
				typeof(RectTransform),
				typeof(RectMask2D)
			});
			val.transform.SetParent(page.transform, false);
			RectTransform component2 = val.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			GameObject val2 = new GameObject("Content", new Type[3]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			val2.transform.SetParent(val.transform, false);
			RectTransform component3 = val2.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 1f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.anchoredPosition = Vector2.zero;
			component3.sizeDelta = Vector2.zero;
			VerticalLayoutGroup component4 = val2.GetComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component4).spacing = 10f;
			((LayoutGroup)component4).padding = new RectOffset(190, 190, 20, 20);
			((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false;
			val2.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			GameObject val3 = new GameObject("Scrollbar", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Scrollbar)
			});
			val3.transform.SetParent(page.transform, false);
			RectTransform component5 = val3.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(1f, 0f);
			component5.anchorMax = new Vector2(1f, 1f);
			component5.pivot = new Vector2(0.5f, 0.5f);
			component5.sizeDelta = new Vector2(12f, -40f);
			component5.anchoredPosition = new Vector2(-15f, 4f);
			Image component6 = val3.GetComponent<Image>();
			((Graphic)component6).color = new Color(1f, 1f, 1f, 0f);
			GameObject val4 = new GameObject("Track", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val4.transform.SetParent(val3.transform, false);
			RectTransform component7 = val4.GetComponent<RectTransform>();
			component7.anchorMin = new Vector2(0.5f, 0f);
			component7.anchorMax = new Vector2(0.5f, 1f);
			component7.pivot = new Vector2(0.5f, 0.5f);
			component7.sizeDelta = new Vector2(12f, -25f);
			Image component8 = val4.GetComponent<Image>();
			((Graphic)component8).color = new Color(0.87f, 0.89f, 0.84f, 1f);
			GameObject val5 = new GameObject("Handle", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val5.transform.SetParent(val3.transform, false);
			RectTransform component9 = val5.GetComponent<RectTransform>();
			component9.anchorMin = new Vector2(0.5f, 0f);
			component9.anchorMax = new Vector2(0.5f, 1f);
			component9.pivot = new Vector2(0.5f, 0.5f);
			component9.sizeDelta = new Vector2(12f, 0f);
			Image component10 = val5.GetComponent<Image>();
			component10.sprite = ((Component)UICloner.slider.transform.Find("Option Contents/Slider/Handle Slide Area/Handle/Graphic")).GetComponent<Image>().sprite;
			((Graphic)component10).color = Color.white;
			component10.type = (Type)1;
			Scrollbar component11 = val3.GetComponent<Scrollbar>();
			component11.handleRect = component9;
			component11.direction = (Direction)2;
			((Selectable)component11).targetGraphic = (Graphic)(object)component10;
			component11.size = 0.1f;
			ScrollRect component12 = page.GetComponent<ScrollRect>();
			component12.content = component3;
			component12.viewport = component2;
			component12.verticalScrollbar = component11;
			component12.horizontal = false;
			component12.vertical = true;
			component12.movementType = (MovementType)2;
			component12.scrollSensitivity = 30f;
			component12.verticalScrollbarVisibility = (ScrollbarVisibility)1;
			page.SetActive(false);
		}

		public static void CreateNewSection(GameObject modPage, string name, out GameObject container)
		{
			Transform val = modPage.transform.Find("Viewport/Content");
			if ((Object)(object)val == (Object)null && ((Object)modPage).name == "Content")
			{
				val = modPage.transform;
			}
			container = Object.Instantiate<GameObject>(UICloner.container, val);
			((Object)container).name = "CONTAINER_" + name;
		}

		private static void HideAllOtherModPages(GameObject modsPage, GameObject targetPage)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			foreach (Transform item in modsPage.transform)
			{
				Transform val = item;
				if (!(((Object)val).name == "MainTopBar"))
				{
					if ((Object)(object)val == (Object)(object)targetPage.transform)
					{
						((Component)val).gameObject.SetActive(true);
					}
					else
					{
						((Component)val).gameObject.SetActive(false);
					}
				}
			}
		}

		public static void CreateModPageNavigationButton(GameObject topBarContent, GameObject modsPage, GameObject modPage, string name)
		{
			GameObject modsPage2 = modsPage;
			GameObject modPage2 = modPage;
			CreateNewSection(topBarContent, name, out GameObject container);
			CreateButton(container, name, "", delegate
			{
				HideAllOtherModPages(modsPage2, modPage2);
			});
		}

		public static void CreateTitle(GameObject modPage, string name)
		{
			Transform val = modPage.transform.Find("Viewport/Content");
			GameObject val2 = Object.Instantiate<GameObject>(UICloner.titleTMP, val);
			((Object)val2).name = "TITLE_" + name;
			((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).text = name;
		}

		public static void CreateSubHeading(GameObject modPage, string name, out GameObject titleObj)
		{
			Transform val = modPage.transform.Find("Viewport/Content");
			titleObj = Object.Instantiate<GameObject>(UICloner.titleTMP, val);
			((Object)titleObj).name = "SUBHEADING_" + name;
			TextMeshProUGUI component = titleObj.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = name;
			((TMP_Text)component).fontSize = ((TMP_Text)component).fontSize - 4f;
			((TMP_Text)component).fontSizeMin = ((TMP_Text)component).fontSizeMin - 4f;
			((TMP_Text)component).fontSizeMax = ((TMP_Text)component).fontSizeMax - 4f;
		}

		public static void CreateDropdown(GameObject container, string configName, List<string> options, string description, out DropdownOption dropdownOption)
		{
			GameObject val = Object.Instantiate<GameObject>(UICloner.dropdown, container.transform);
			((Object)val).name = "DROPDOWN_" + configName;
			((TMP_Text)((Component)val.transform.Find("Label Text")).GetComponent<TextMeshProUGUI>()).text = configName;
			dropdownOption = val.GetComponent<DropdownOption>();
			dropdownOption.localized = null;
			dropdownOption.SetOptions(options);
			CreateDescriptionBox(((Component)val.transform.Find("Label Text")).gameObject, description);
			Plugin.Log.LogInfo((object)("Created dropdown for config: " + configName + " in section: " + ((Object)container).name + " with options: " + string.Join(", ", options) + ")"));
		}

		public static void CreateFloatSlider(GameObject container, float value, float minValue, float maxValue, string configName, string description, out SliderOption sliderOption)
		{
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_01a8: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: 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_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(UICloner.slider, container.transform);
			((Object)val).name = "SLIDER_" + configName;
			Transform val2 = val.transform.Find("Label Text");
			TextMeshProUGUI component = ((Component)val2).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = configName;
			Transform labelValueText = val.transform.Find("Option Contents/Slider Value");
			TextMeshProUGUI valueTextComponent = ((Component)labelValueText).GetComponent<TextMeshProUGUI>();
			RectTransform component2 = ((Component)labelValueText).GetComponent<RectTransform>();
			TextMeshProUGUI obj = valueTextComponent;
			((TMP_Text)obj).fontSize = ((TMP_Text)obj).fontSize - 6f;
			TextMeshProUGUI obj2 = valueTextComponent;
			((TMP_Text)obj2).fontSizeMin = ((TMP_Text)obj2).fontSizeMin - 6f;
			TextMeshProUGUI obj3 = valueTextComponent;
			((TMP_Text)obj3).fontSizeMax = ((TMP_Text)obj3).fontSizeMax - 6f;
			sliderOption = val.GetComponent<SliderOption>();
			sliderOption.SetLimits(minValue, maxValue);
			sliderOption.SetValue(value);
			string text = ((value % 1f == 0f) ? value.ToString("F0") : value.ToString("0.###"));
			sliderOption.SetValueText($"{value}");
			SliderOption localSliderOption = sliderOption;
			GameObject inputTextView = new GameObject("Input Text View");
			inputTextView.transform.SetParent(labelValueText.parent, false);
			RectTransform val3 = inputTextView.AddComponent<RectTransform>();
			val3.anchorMin = component2.anchorMin;
			val3.anchorMax = component2.anchorMax;
			val3.pivot = component2.pivot;
			val3.offsetMin = component2.offsetMin;
			val3.offsetMax = component2.offsetMax;
			val3.sizeDelta = component2.sizeDelta;
			val3.anchoredPosition = component2.anchoredPosition;
			inputTextView.transform.SetSiblingIndex(labelValueText.GetSiblingIndex() + 1);
			TextMeshProUGUI inputTextComponent = inputTextView.AddComponent<TextMeshProUGUI>();
			((TMP_Text)inputTextComponent).font = ((TMP_Text)valueTextComponent).font;
			((TMP_Text)inputTextComponent).fontSize = ((TMP_Text)valueTextComponent).fontSize;
			((TMP_Text)inputTextComponent).fontStyle = ((TMP_Text)valueTextComponent).fontStyle;
			((TMP_Text)inputTextComponent).alignment = ((TMP_Text)valueTextComponent).alignment;
			((Graphic)inputTextComponent).color = ((Graphic)valueTextComponent).color;
			((TMP_Text)inputTextComponent).text = ((TMP_Text)valueTextComponent).text;
			((Graphic)inputTextComponent).raycastTarget = true;
			TMP_InputField inputField = inputTextView.AddComponent<TMP_InputField>();
			inputField.textComponent = (TMP_Text)(object)inputTextComponent;
			inputField.textViewport = ((Component)labelValueText.parent).GetComponent<RectTransform>();
			inputField.contentType = (ContentType)3;
			inputField.lineType = (LineType)0;
			((Selectable)inputField).interactable = true;
			((Selectable)inputField).targetGraphic = (Graphic)(object)inputTextComponent;
			inputTextView.SetActive(false);
			EventTrigger val4 = ((Component)labelValueText).gameObject.AddComponent<EventTrigger>();
			Entry val5 = new Entry();
			val5.eventID = (EventTriggerType)4;
			((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				((Component)labelValueText).gameObject.SetActive(false);
				inputField.text = localSliderOption.value.ToString();
				inputTextView.SetActive(true);
				inputField.ActivateInputField();
				((Selectable)inputField).Select();
			});
			val4.triggers.Add(val5);
			((UnityEvent<string>)(object)inputField.onEndEdit).AddListener((UnityAction<string>)delegate(string newValue)
			{
				if (float.TryParse(newValue, out var result))
				{
					result = Mathf.Clamp(result, minValue, maxValue);
					localSliderOption.SetValue(result);
					string text2 = ((result % 1f == 0f) ? result.ToString("F0") : result.ToString("0.###"));
					localSliderOption.SetValueText(text2);
					((TMP_Text)valueTextComponent).text = text2;
					((TMP_Text)inputTextComponent).text = text2;
					localSliderOption.onChanged?.Invoke();
				}
				inputTextView.SetActive(false);
				((Component)labelValueText).gameObject.SetActive(true);
			});
			CreateDescriptionBox(((Component)val.transform.Find("Label Text")).gameObject, description);
		}

		public static void CreateIntSlider(GameObject container, int value, int minValue, int maxValue, string configName, string description, out SliderOption sliderOption)
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Expected O, but got Unknown
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(UICloner.slider, container.transform);
			((Object)val).name = "SLIDER_" + configName;
			Transform val2 = val.transform.Find("Label Text");
			TextMeshProUGUI component = ((Component)val2).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = configName;
			Transform labelValueText = val.transform.Find("Option Contents/Slider Value");
			TextMeshProUGUI valueTextComponent = ((Component)labelValueText).GetComponent<TextMeshProUGUI>();
			RectTransform component2 = ((Component)labelValueText).GetComponent<RectTransform>();
			TextMeshProUGUI obj = valueTextComponent;
			((TMP_Text)obj).fontSize = ((TMP_Text)obj).fontSize - 6f;
			TextMeshProUGUI obj2 = valueTextComponent;
			((TMP_Text)obj2).fontSizeMin = ((TMP_Text)obj2).fontSizeMin - 6f;
			TextMeshProUGUI obj3 = valueTextComponent;
			((TMP_Text)obj3).fontSizeMax = ((TMP_Text)obj3).fontSizeMax - 6f;
			sliderOption = val.GetComponent<SliderOption>();
			sliderOption.slider.wholeNumbers = true;
			sliderOption.SetLimits((float)minValue, (float)maxValue);
			sliderOption.SetValue((float)value);
			sliderOption.SetValueText(value.ToString("F0"));
			SliderOption localSliderOption = sliderOption;
			GameObject inputTextView = new GameObject("Input Text View");
			inputTextView.transform.SetParent(labelValueText.parent, false);
			RectTransform val3 = inputTextView.AddComponent<RectTransform>();
			val3.anchorMin = component2.anchorMin;
			val3.anchorMax = component2.anchorMax;
			val3.pivot = component2.pivot;
			val3.offsetMin = component2.offsetMin;
			val3.offsetMax = component2.offsetMax;
			val3.sizeDelta = component2.sizeDelta;
			val3.anchoredPosition = component2.anchoredPosition;
			inputTextView.transform.SetSiblingIndex(labelValueText.GetSiblingIndex() + 1);
			TextMeshProUGUI inputTextComponent = inputTextView.AddComponent<TextMeshProUGUI>();
			((TMP_Text)inputTextComponent).font = ((TMP_Text)valueTextComponent).font;
			((TMP_Text)inputTextComponent).fontSize = ((TMP_Text)valueTextComponent).fontSize;
			((TMP_Text)inputTextComponent).fontStyle = ((TMP_Text)valueTextComponent).fontStyle;
			((TMP_Text)inputTextComponent).alignment = ((TMP_Text)valueTextComponent).alignment;
			((Graphic)inputTextComponent).color = ((Graphic)valueTextComponent).color;
			((TMP_Text)inputTextComponent).text = ((TMP_Text)valueTextComponent).text;
			((Graphic)inputTextComponent).raycastTarget = true;
			TMP_InputField inputField = inputTextView.AddComponent<TMP_InputField>();
			inputField.textComponent = (TMP_Text)(object)inputTextComponent;
			inputField.textViewport = ((Component)labelValueText.parent).GetComponent<RectTransform>();
			inputField.contentType = (ContentType)2;
			inputField.lineType = (LineType)0;
			((Selectable)inputField).interactable = true;
			inputField.characterValidation = (CharacterValidation)2;
			((Selectable)inputField).targetGraphic = (Graphic)(object)inputTextComponent;
			inputTextView.SetActive(false);
			EventTrigger val4 = ((Component)labelValueText).gameObject.AddComponent<EventTrigger>();
			Entry val5 = new Entry();
			val5.eventID = (EventTriggerType)4;
			((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				((Component)labelValueText).gameObject.SetActive(false);
				inputField.text = localSliderOption.value.ToString();
				inputTextView.SetActive(true);
				inputField.ActivateInputField();
				((Selectable)inputField).Select();
			});
			val4.triggers.Add(val5);
			((UnityEvent<string>)(object)inputField.onEndEdit).AddListener((UnityAction<string>)delegate(string newValue)
			{
				if (int.TryParse(newValue, out var result))
				{
					result = Mathf.Clamp(result, minValue, maxValue);
					localSliderOption.SetValue((float)result);
					string text = result.ToString();
					localSliderOption.SetValueText(text);
					((TMP_Text)valueTextComponent).text = text;
					((TMP_Text)inputTextComponent).text = text;
					localSliderOption.onChanged?.Invoke();
				}
				else
				{
					((TMP_Text)inputTextComponent).text = ((TMP_Text)valueTextComponent).text;
				}
				inputTextView.SetActive(false);
				((Component)labelValueText).gameObject.SetActive(true);
			});
			CreateDescriptionBox(((Component)val.transform.Find("Label Text")).gameObject, description);
		}

		public static void CreateStringInput(GameObject container, string name, Action<string> onChange, string description, string defaultValue = "", bool isColor = false)
		{
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Expected O, but got Unknown
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Expected O, but got Unknown
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			Action<string> onChange2 = onChange;
			GameObject val = Object.Instantiate<GameObject>(UICloner.slider, container.transform);
			((Object)val).name = "INPUT_" + name;
			((TMP_Text)((Component)val.transform.Find("Label Text")).GetComponent<TextMeshProUGUI>()).text = name;
			Transform val2 = val.transform.Find("Option Contents");
			RectTransform component = ((Component)val2).GetComponent<RectTransform>();
			if ((Object)(object)((Component)val2).GetComponent<RectMask2D>() == (Object)null)
			{
				((Component)val2).gameObject.AddComponent<RectMask2D>();
			}
			Object.DestroyImmediate((Object)(object)val.GetComponent<SliderOption>());
			Transform val3 = val2.Find("Slider");
			if ((Object)(object)val3 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)val3).gameObject);
			}
			Transform val4 = val2.Find("Caret");
			if ((Object)(object)val4 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)val4).gameObject);
			}
			GameObject displayTextObj = ((Component)val2.Find("Slider Value")).gameObject;
			((Object)displayTextObj).name = "Display Text";
			TextMeshProUGUI displayTextComponent = displayTextObj.GetComponent<TextMeshProUGUI>();
			RectTransform component2 = displayTextObj.GetComponent<RectTransform>();
			Image colorPreviewImage = null;
			float num = -10f;
			if (isColor)
			{
				num = -55f;
				GameObject val5 = new GameObject("ColorStroke", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val5.transform.SetParent(val2, false);
				RectTransform component3 = val5.GetComponent<RectTransform>();
				component3.anchorMin = new Vector2(1f, 0.5f);
				component3.anchorMax = new Vector2(1f, 0.5f);
				component3.sizeDelta = new Vector2(40f, 40f);
				component3.anchoredPosition = new Vector2(-25f, 0f);
				((Graphic)val5.GetComponent<Image>()).color = new Color(0.878f, 0.89f, 0.843f, 1f);
				GameObject val6 = new GameObject("ColorPreview", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val6.transform.SetParent(val5.transform, false);
				RectTransform component4 = val6.GetComponent<RectTransform>();
				component4.anchorMin = Vector2.zero;
				component4.anchorMax = Vector2.one;
				component4.offsetMin = new Vector2(2f, 2f);
				component4.offsetMax = new Vector2(-2f, -2f);
				colorPreviewImage = val6.GetComponent<Image>();
				Color color = default(Color);
				if (ColorUtility.TryParseHtmlString(defaultValue.StartsWith("#") ? defaultValue : ("#" + defaultValue), ref color))
				{
					((Graphic)colorPreviewImage).color = color;
				}
			}
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = new Vector2(10f, 0f);
			component2.offsetMax = new Vector2(num, 0f);
			((TMP_Text)displayTextComponent).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)displayTextComponent).text = defaultValue;
			((TMP_Text)displayTextComponent).alignment = (TextAlignmentOptions)513;
			((TMP_Text)displayTextComponent).overflowMode = (TextOverflowModes)2;
			GameObject inputTextView = new GameObject("Input Text View");
			inputTextView.transform.SetParent(val2, false);
			RectTransform val7 = inputTextView.AddComponent<RectTransform>();
			val7.anchorMin = component2.anchorMin;
			val7.anchorMax = component2.anchorMax;
			val7.offsetMin = component2.offsetMin;
			val7.offsetMax = component2.offsetMax;
			TextMeshProUGUI val8 = inputTextView.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val8).font = ((TMP_Text)displayTextComponent).font;
			((TMP_Text)val8).fontSize = ((TMP_Text)displayTextComponent).fontSize;
			((TMP_Text)val8).alignment = (TextAlignmentOptions)513;
			((Graphic)val8).color = ((Graphic)displayTextComponent).color;
			((Graphic)val8).raycastTarget = true;
			((TMP_Text)val8).textWrappingMode = (TextWrappingModes)0;
			TMP_InputField inputField = inputTextView.AddComponent<TMP_InputField>();
			inputField.textViewport = component;
			inputField.textComponent = (TMP_Text)(object)val8;
			inputField.contentType = (ContentType)0;
			inputField.lineType = (LineType)0;
			inputTextView.SetActive(false);
			EventTrigger val9 = displayTextObj.AddComponent<EventTrigger>();
			Entry val10 = new Entry
			{
				eventID = (EventTriggerType)4
			};
			((UnityEvent<BaseEventData>)(object)val10.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				displayTextObj.SetActive(false);
				inputTextView.SetActive(true);
				inputField.text = ((TMP_Text)displayTextComponent).text;
				inputField.ActivateInputField();
			});
			val9.triggers.Add(val10);
			((UnityEvent<string>)(object)inputField.onEndEdit).AddListener((UnityAction<string>)delegate(string newValue)
			{
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				((TMP_Text)displayTextComponent).text = newValue;
				Color color2 = default(Color);
				if (isColor && (Object)(object)colorPreviewImage != (Object)null && ColorUtility.TryParseHtmlString(newValue.StartsWith("#") ? newValue : ("#" + newValue), ref color2))
				{
					((Graphic)colorPreviewImage).color = color2;
				}
				onChange2?.Invoke(newValue);
				inputTextView.SetActive(false);
				displayTextObj.SetActive(true);
			});
			CreateDescriptionBox(((Component)val.transform.Find("Label Text")).gameObject, description);
		}

		public static void CreateButton(GameObject container, string name, string description, Action action)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			Action action2 = action;
			GameObject val = Object.Instantiate<GameObject>(UICloner.button, container.transform);
			((Object)val).name = "BUTTON_" + name;
			((TMP_Text)val.GetComponentInChildren<TextMeshProUGUI>()).text = name;
			((UnityEventBase)val.GetComponent<Button>().onClick).RemoveAllListeners();
			((UnityEvent)val.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				action2();
			});
			val.GetComponent<Transform>().localPosition = Vector3.zero;
			CreateDescriptionBox(((Component)val.GetComponentInChildren<TextMeshProUGUI>()).gameObject, description);
		}

		private static string KeyCodeToPath(KeyCode key)
		{
			return "<Keyboard>/" + ((object)(KeyCode)(ref key)).ToString().ToLower();
		}

		public static void CreateKeybinding(GameObject container, string configName, KeyCode defaultValue, string description, out ActionRebindOption actionRebindOption, out KeybindHook actionHook)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Expected O, but got Unknown
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			InputActionMap val = new InputActionMap("ModConfigMap");
			InputAction val2 = InputActionSetupExtensions.AddAction(val, configName, (InputActionType)0, (string)null, (string)null, (string)null, (string)null, (string)null);
			BindingSyntax val3 = InputActionSetupExtensions.AddBinding(val2, "<Keyboard>/none", (string)null, (string)null, (string)null);
			InputBinding binding = ((BindingSyntax)(ref val3)).binding;
			int hashCode = ((object)(InputBinding)(ref binding)).GetHashCode();
			hashCode = 0;
			InputActionRebindingExtensions.ApplyBindingOverride(val2, hashCode, KeyCodeToPath(defaultValue));
			val2.Enable();
			GameObject val4 = Object.Instantiate<GameObject>(UICloner.dropdown, container.transform);
			((Object)val4).name = "MC_KEYBIND_" + configName;
			((TMP_Text)((Component)val4.transform.Find("Label Text")).GetComponent<TextMeshProUGUI>()).text = configName;
			Transform val5 = val4.transform.Find("Option Contents");
			if (Object.op_Implicit((Object)(object)val5.Find("Dropdown")))
			{
				Object.DestroyImmediate((Object)(object)((Component)val5.Find("Dropdown")).gameObject);
			}
			HorizontalLayoutGroup val6 = GameObjectExtensions.AddOrGetComponent<HorizontalLayoutGroup>(((Component)val5).gameObject);
			((HorizontalOrVerticalLayoutGroup)val6).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)val6).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)val6).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val6).spacing = 10f;
			((LayoutGroup)val6).childAlignment = (TextAnchor)5;
			GameObject val7 = new GameObject("KbdButton", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Button)
			});
			val7.transform.SetParent(val5, false);
			float num = 40f;
			RectTransform component = val7.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(num, num);
			Image component2 = val7.GetComponent<Image>();
			component2.preserveAspect = true;
			GameObject val8 = new GameObject("Text", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val8.transform.SetParent(val7.transform, false);
			TextMeshProUGUI component3 = val8.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component3).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component3).fontSize = 18f;
			((Graphic)component3).color = Color.white;
			((Graphic)component3).raycastTarget = false;
			RectTransform component4 = val8.GetComponent<RectTransform>();
			component4.anchorMin = Vector2.zero;
			component4.anchorMax = Vector2.one;
			component4.offsetMin = Vector2.zero;
			component4.offsetMax = Vector2.zero;
			GameObject val9 = new GameObject("ResetButton", new Type[2]
			{
				typeof(RectTransform),
				typeof(Button)
			});
			val9.transform.SetParent(val5, false);
			val9.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
			actionRebindOption = val4.AddComponent<ActionRebindOption>();
			actionRebindOption.keyboardRebindButton = new RebindButton
			{
				parentObject = val7,
				button = val7.GetComponent<Button>(),
				bindingIcon = component2,
				tmpBinding = component3,
				resetButton = val9.GetComponent<Button>()
			};
			GameObject val10 = new GameObject("Dummy_Gamepad");
			val10.transform.SetParent(val4.transform);
			val10.SetActive(false);
			actionRebindOption.gamepadRebindButton = new RebindButton
			{
				parentObject = val10,
				button = val10.AddComponent<Button>(),
				resetButton = val10.AddComponent<Button>(),
				bindingIcon = val10.AddComponent<Image>(),
				tmpBinding = val10.AddComponent<TextMeshProUGUI>()
			};
			ControlsRebind component5 = ((Component)ModConfigMain.controlsPage).GetComponent<ControlsRebind>();
			GameObject val11 = (GameObject)(((Object)(object)component5 != (Object)null) ? ((object)((Component)component5).gameObject) : ((object)container));
			actionHook = val4.AddComponent<KeybindHook>();
			if ((int)defaultValue == 0)
			{
				component2.sprite = getEmptyKeyIcon();
				((Behaviour)component2).enabled = true;
			}
			CreateDescriptionBox(((Component)val4.transform.Find("Label Text")).gameObject, description);
			try
			{
				actionRebindOption.Initialize(component5, val2, hashCode, -1);
			}
			catch (Exception)
			{
			}
		}

		public static void CreateDescriptionBox(GameObject textObj, string description)
		{
			if (!string.IsNullOrEmpty(description))
			{
				TextMeshProUGUI component = textObj.GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component != (Object)null)
				{
					((Graphic)component).raycastTarget = true;
				}
				ConfigHoverHandler configHoverHandler = textObj.AddComponent<ConfigHoverHandler>();
				configHoverHandler.description = description;
			}
		}

		public static Sprite getEmptyKeyIcon()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0091: 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)
			if ((Object)(object)UICloner.emptyKeyIcon != (Object)null)
			{
				return UICloner.emptyKeyIcon;
			}
			string text = "ModConfig.UI.empty-key.png";
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using (Stream stream = executingAssembly.GetManifestResourceStream(text))
			{
				if (stream == null)
				{
					Plugin.Log.LogError((object)("Resource not found: " + text));
					return null;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (ImageConversion.LoadImage(val, array))
				{
					return UICloner.emptyKeyIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
				}
			}
			return null;
		}
	}
}
namespace ModConfig.Core
{
	public class ConfigGetter
	{
		public static void InitialiseConfigs(GameObject modsPage, GameObject topBar)
		{
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = true;
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				string name = pluginInfo.Value.Metadata.Name;
				ConfigFile config = pluginInfo.Value.Instance.Config;
				if (config.Keys.Count == 0)
				{
					continue;
				}
				UICreator.CreateModPage(modsPage, name, out GameObject page);
				UICreator.CreateModPageNavigationButton(topBar, modsPage, page, name);
				if (flag)
				{
					page.SetActive(true);
					flag = false;
				}
				IEnumerable<IGrouping<string, KeyValuePair<ConfigDefinition, ConfigEntryBase>>> enumerable = from entry in (IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)config
					group entry by entry.Value.Definition.Section;
				UICreator.CreateTitle(page, name);
				foreach (IGrouping<string, KeyValuePair<ConfigDefinition, ConfigEntryBase>> item3 in enumerable)
				{
					string key = item3.Key;
					UICreator.CreateSubHeading(page, key, out GameObject _);
					UICreator.CreateNewSection(page, key, out GameObject container);
					foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item4 in item3)
					{
						ConfigEntryBase entryBase = item4.Value;
						Type settingType = entryBase.SettingType;
						if (settingType == typeof(bool))
						{
							UICreator.CreateDropdown(container, entryBase.Definition.Key, new List<string> { "True", "False" }, entryBase.Description.Description.ToString(), out DropdownOption dropdownOption2);
							bool flag2 = (bool)entryBase.BoxedValue;
							dropdownOption2.SetValue((!flag2) ? 1 : 0);
							DropdownOption obj = dropdownOption2;
							obj.onChanged = (Action)Delegate.Combine(obj.onChanged, (Action)delegate
							{
								entryBase.BoxedValue = dropdownOption2.value == 0;
								Plugin.Log.LogInfo((object)$"Config {entryBase.Definition.Key} updated to {entryBase.BoxedValue}");
							});
							continue;
						}
						if (settingType == typeof(float))
						{
							AcceptableValueRange<float> val = entryBase.Description.AcceptableValues as AcceptableValueRange<float>;
							float num = 0f;
							float num2 = 999f;
							float? step = null;
							if (val != null)
							{
								num = val.MinValue;
								num2 = val.MaxValue;
								float num3 = num2 - num;
								if (num3 <= 1f)
								{
									step = 0.01f;
								}
								else if (num3 <= 10f)
								{
									step = 0.1f;
								}
								else
								{
									step = 1f;
								}
							}
							UICreator.CreateFloatSlider(container, (float)entryBase.BoxedValue, num, num2, entryBase.Definition.Key, entryBase.Description.Description.ToString(), out SliderOption sliderOption);
							SliderOption obj2 = sliderOption;
							obj2.onChanged = (Action)Delegate.Combine(obj2.onChanged, (Action)delegate
							{
								float num4 = sliderOption.value;
								if (num4 != (float)entryBase.BoxedValue)
								{
									if (step.HasValue)
									{
										num4 = (float)Math.Round(num4 / step.Value) * step.Value;
										sliderOption.valueWithoutNotify = num4;
									}
									entryBase.BoxedValue = num4;
									sliderOption.SetValueText(num4.ToString("0.##"));
									Plugin.Log.LogInfo((object)$"Config {entryBase.Definition.Key} updated to {num4}");
								}
							});
							continue;
						}
						if (settingType == typeof(int))
						{
							if (entryBase.Description.AcceptableValues is AcceptableValueRange<int> val2)
							{
								UICreator.CreateIntSlider(container, (int)entryBase.BoxedValue, val2.MinValue, val2.MaxValue, entryBase.Definition.Key, entryBase.Description.Description.ToString(), out SliderOption sliderOption2);
								SliderOption obj3 = sliderOption2;
								obj3.onChanged = (Action)Delegate.Combine(obj3.onChanged, (Action)delegate
								{
									entryBase.BoxedValue = (int)sliderOption2.value;
									sliderOption2.SetValueText(entryBase.BoxedValue.ToString());
									Plugin.Log.LogInfo((object)$"Config {entryBase.Definition.Key} updated to {entryBase.BoxedValue}");
								});
							}
							else
							{
								UICreator.CreateIntSlider(container, (int)entryBase.BoxedValue, 0, 999, entryBase.Definition.Key, entryBase.Description.Description.ToString(), out SliderOption sliderOption3);
								SliderOption obj4 = sliderOption3;
								obj4.onChanged = (Action)Delegate.Combine(obj4.onChanged, (Action)delegate
								{
									entryBase.BoxedValue = (int)sliderOption3.value;
									sliderOption3.SetValueText(entryBase.BoxedValue.ToString());
									Plugin.Log.LogInfo((object)$"Config {entryBase.Definition.Key} updated to {entryBase.BoxedValue}");
								});
							}
							continue;
						}
						if (settingType == typeof(string))
						{
							if (entryBase.Description.AcceptableValues is AcceptableValueList<string> val3)
							{
								List<string> options = val3.AcceptableValues.ToList();
								UICreator.CreateDropdown(container, entryBase.Definition.Key, options, entryBase.Description.Description.ToString(), out DropdownOption dropdownOption3);
								string item = (string)entryBase.BoxedValue;
								dropdownOption3.SetValue(options.IndexOf(item));
								DropdownOption obj5 = dropdownOption3;
								obj5.onChanged = (Action)Delegate.Combine(obj5.onChanged, (Action)delegate
								{
									entryBase.BoxedValue = options[dropdownOption3.value];
									Plugin.Log.LogInfo((object)$"Config {entryBase.Definition.Key} updated to {entryBase.BoxedValue}");
								});
							}
							else
							{
								UICreator.CreateStringInput(container, entryBase.Definition.Key, delegate(string newVal)
								{
									entryBase.BoxedValue = newVal;
									Plugin.Log.LogInfo((object)$"Config {entryBase.Definition.Key} updated to {entryBase.BoxedValue}");
								}, (string)entryBase.BoxedValue);
							}
							continue;
						}
						if (settingType == typeof(Color))
						{
							Color val4 = (Color)entryBase.BoxedValue;
							string defaultValue = ColorUtility.ToHtmlStringRGBA(val4);
							UICreator.CreateStringInput(container, entryBase.Definition.Key, delegate(string newText)
							{
								//IL_002c: Unknown result type (might be due to invalid IL or missing references)
								string text = (newText.StartsWith("#") ? newText : ("#" + newText));
								Color val9 = default(Color);
								if (ColorUtility.TryParseHtmlString(text, ref val9))
								{
									entryBase.BoxedValue = val9;
									Plugin.Log.LogInfo((object)("Config " + entryBase.Definition.Key + " updated to " + newText));
								}
							}, entryBase.Description.Description.ToString(), defaultValue, isColor: true);
							continue;
						}
						if (settingType == typeof(KeyCode))
						{
							ConfigEntry<KeyCode> configEntry2 = (ConfigEntry<KeyCode>)(object)entryBase;
							UICreator.CreateKeybinding(container, ((ConfigEntryBase)configEntry2).Definition.Key, configEntry2.Value, entryBase.Description.Description.ToString(), out ActionRebindOption actionRebindOption2, out KeybindHook actionHook2);
							KeybindHook keybindHook = actionHook2;
							keybindHook.onRebind = (Action)Delegate.Combine(keybindHook.onRebind, (Action)delegate
							{
								//IL_000b: Unknown result type (might be due to invalid IL or missing references)
								//IL_0010: Unknown result type (might be due to invalid IL or missing references)
								//IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references)
								//IL_0038: 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_0064: Unknown result type (might be due to invalid IL or missing references)
								InputBinding val7 = actionRebindOption2.action.bindings[actionRebindOption2.keyboardBindingIndex];
								string effectivePath2 = ((InputBinding)(ref val7)).effectivePath;
								KeyCode val8 = actionHook2.PathToKeyCode(effectivePath2);
								((ConfigEntryBase)configEntry2).BoxedValue = val8;
								Plugin.Log.LogInfo((object)$"Config {((ConfigEntryBase)configEntry2).Definition.Key} updated to {val8}");
							});
							continue;
						}
						if (settingType == typeof(KeyboardShortcut))
						{
							ConfigEntry<KeyboardShortcut> configEntry = (ConfigEntry<KeyboardShortcut>)(object)entryBase;
							GameObject container2 = container;
							string key2 = ((ConfigEntryBase)configEntry).Definition.Key;
							KeyboardShortcut value = configEntry.Value;
							UICreator.CreateKeybinding(container2, key2, ((KeyboardShortcut)(ref value)).MainKey, entryBase.Description.Description.ToString(), out ActionRebindOption actionRebindOption, out KeybindHook actionHook);
							KeybindHook keybindHook2 = actionHook;
							keybindHook2.onRebind = (Action)Delegate.Combine(keybindHook2.onRebind, (Action)delegate
							{
								//IL_000b: Unknown result type (might be due to invalid IL or missing references)
								//IL_0010: Unknown result type (might be due to invalid IL or missing references)
								//IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references)
								//IL_0038: 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_0045: Unknown result type (might be due to invalid IL or missing references)
								//IL_0069: Unknown result type (might be due to invalid IL or missing references)
								InputBinding val5 = actionRebindOption.action.bindings[actionRebindOption.keyboardBindingIndex];
								string effectivePath = ((InputBinding)(ref val5)).effectivePath;
								KeyCode val6 = actionHook.PathToKeyCode(effectivePath);
								configEntry.Value = new KeyboardShortcut(val6, Array.Empty<KeyCode>());
								Plugin.Log.LogInfo((object)$"Config {((ConfigEntryBase)configEntry).Definition.Key} updated to {val6}");
							});
							continue;
						}
						if (settingType.IsEnum)
						{
							List<string> enumNames = Enum.GetNames(settingType).ToList();
							UICreator.CreateDropdown(container, entryBase.Definition.Key, enumNames, entryBase.Description.Description.ToString(), out DropdownOption dropdownOption);
							string item2 = entryBase.BoxedValue.ToString();
							int value2 = enumNames.IndexOf(item2);
							dropdownOption.SetValue(value2);
							DropdownOption obj6 = dropdownOption;
							obj6.onChanged = (Action)Delegate.Combine(obj6.onChanged, (Action)delegate
							{
								string value3 = enumNames[dropdownOption.value];
								object boxedValue = Enum.Parse(settingType, value3);
								entryBase.BoxedValue = boxedValue;
							});
							continue;
						}
						string description = entryBase.BoxedValue?.ToString() ?? "";
						UICreator.CreateStringInput(container, "[?] " + entryBase.Definition.Key, delegate(string newText)
						{
							try
							{
								entryBase.BoxedValue = newText;
							}
							catch (Exception ex)
							{
								Plugin.Log.LogWarning((object)$"[ModConfig] Failed to set unrecognised type {settingType}: {ex.Message}");
							}
						}, description);
					}
				}
			}
		}

		public static void SaveAllConfigs()
		{
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				try
				{
					pluginInfo.Value.Instance.Config.Save();
					Plugin.Log.LogInfo((object)("Saved config for: " + pluginInfo.Value.Metadata.Name));
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)("Failed to save config for " + pluginInfo.Value.Metadata.Name + ": " + ex.Message));
				}
			}
		}
	}
	public static class ModConfigManager
	{
		private const string TAB_NAME = "Mods";

		private static readonly Color BG_COLOR = new Color(1f, 0.8024f, 0.8584f, 1f);

		private static readonly float SPACING = -45f;

		private static readonly Vector3 BUTTON_SCALE = new Vector3(0.8f, 0.8f, 0.8f);

		private static readonly float PADDING_X = 190f;

		public static Dictionary<string, List<ConfigEntryBase>> LoadAllModConfigs()
		{
			Dictionary<string, List<ConfigEntryBase>> dictionary = new Dictionary<string, List<ConfigEntryBase>>();
			foreach (PluginInfo item in Chainloader.PluginInfos.Values.OrderBy((PluginInfo p) => p.Metadata.Name))
			{
				if (!((Object)(object)item.Instance == (Object)null) && item.Instance.Config != null)
				{
					List<ConfigEntryBase> list = (from e in (IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)item.Instance.Config
						where !e.Value.Description.Tags.Contains("Hidden")
						select e.Value).ToList();
					if (list.Count > 0)
					{
						dictionary[item.Metadata.Name] = list;
						Debug.Log((object)$"Found {list.Count} config entries for mod: {item.Metadata.Name}");
					}
				}
			}
			return dictionary;
		}

		public static void Inject(MenuTabs menuTabs)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)menuTabs == (Object)null || (Object)(object)((Component)menuTabs).transform.Find("Menu/Options Tab/Mods") != (Object)null)
			{
				return;
			}
			Transform val = ((Component)menuTabs).transform.Find("Menu/Options Tab");
			Transform val2 = val.Find("Controls");
			GameObject val3 = ((IEnumerable<GameObject>)menuTabs.tabs).FirstOrDefault((Func<GameObject, bool>)((GameObject t) => ((Object)t).name.Contains("Controls")));
			if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null))
			{
				((HorizontalOrVerticalLayoutGroup)((Component)val).GetComponent<HorizontalLayoutGroup>()).spacing = SPACING;
				ChangeButtons(menuTabs);
				GameObject val4 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val);
				((Object)val4).name = "Mods";
				((Graphic)val4.GetComponent<Image>()).color = BG_COLOR;
				((Graphic)((Component)val4.transform.Find("Highlight/Background")).GetComponent<Image>()).color = BG_COLOR;
				((Graphic)((Component)val4.transform.Find("Highlight/Background/Stripes")).GetComponent<Image>()).color = BG_COLOR - new Color(0.05f, 0.05f, 0.05f, 0f);
				SetupButtonText(val4);
				GameObject val5 = Object.Instantiate<GameObject>(val3, val3.transform.parent);
				((Object)val5).name = "Mods";
				while (val5.transform.childCount > 0)
				{
					Object.DestroyImmediate((Object)(object)((Component)val5.transform.GetChild(0)).gameObject);
				}
				CleanContentPage(val5);
				ModConfigMain modConfigMain = ((Component)val5.transform.parent).gameObject.AddComponent<ModConfigMain>();
				UpdateMenuTabs(menuTabs, val4, val5);
			}
		}

		private static void UpdateMenuTabs(MenuTabs menuTabs, GameObject buttonObj, GameObject page)
		{
			//IL_0080: 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_00d5: Expected O, but got Unknown
			MenuTabs menuTabs2 = menuTabs;
			List<Button> list = menuTabs2.tabButtons.ToList();
			List<GameObject> list2 = menuTabs2.tabs.ToList();
			list.Add(buttonObj.GetComponent<Button>());
			list2.Add(page);
			menuTabs2.tabButtons = list.ToArray();
			menuTabs2.tabs = list2.ToArray();
			menuTabs2.textColors = menuTabs2.textColors.Append(menuTabs2.textColors.Last()).ToArray();
			int index = menuTabs2.tabButtons.Length - 1;
			((UnityEventBase)buttonObj.GetComponent<Button>().onClick).RemoveAllListeners();
			((UnityEvent)buttonObj.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				menuTabs2.SelectTab(index);
			});
		}

		private static void SetupButtonText(GameObject button)
		{
			Object.DestroyImmediate((Object)(object)button.GetComponentInChildren<LocalizeStringEvent>());
			TMP_Text[] componentsInChildren = button.GetComponentsInChildren<TMP_Text>();
			foreach (TMP_Text val in componentsInChildren)
			{
				val.text = "Mods";
			}
		}

		private static void CleanContentPage(GameObject page)
		{
			string[] source = new string[6] { "RectTransform", "CanvasRenderer", "Canvas", "Image", "ScrollRect", "Mask" };
			Component[] components = page.GetComponents<Component>();
			foreach (Component val in components)
			{
				if (val is MonoBehaviour && !source.Contains(((object)val).GetType().Name))
				{
					Object.DestroyImmediate((Object)(object)val);
				}
			}
		}

		private static void ChangeButtons(MenuTabs menu)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			List<Button> list = menu.tabButtons.ToList();
			foreach (Button item in list)
			{
				((Component)item).transform.localScale = BUTTON_SCALE;
			}
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ConstantExpectedAttribute : Attribute
	{
		public object? Min { get; set; }

		public object? Max { get; set; }
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class OverloadResolutionPriorityAttribute : Attribute
	{
		public int Priority { get; }

		public OverloadResolutionPriorityAttribute(int priority)
		{
			Priority = priority;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}