Decompiled source of ModSettingsMenu v1.0.0

BepInEx/plugins/ModSettingsMenu/ModSettingsMenu.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GraveyardKeeper2LocalizationAPI.Api;
using HarmonyLib;
using LazyBearTechnology;
using ModSettingsMenu.Api;
using ModSettingsMenu.Configuration;
using ModSettingsMenu.Localization;
using ModSettingsMenu.Runtime;
using ModSettingsMenu.Update;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ModSettingsMenu")]
[assembly: AssemblyDescription("Mod Settings Menu mod for Graveyard Keeper 2 by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("ModSettingsMenu")]
[assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("d041f388-c515-4768-abca-f1b9cd68a54b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ModSettingsMenu
{
	[BepInPlugin("IceBoxStudio.GraveyardKeeper2.ModSettingsMenu", "ModSettingsMenu", "1.0.0")]
	[BepInDependency("IceBoxStudio.GraveyardKeeper2.LocalizationAPI", "1.0.0")]
	public sealed class ModSettingsMenu : BaseUnityPlugin
	{
		private Harmony _harmony;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ModSettingsRegistry.RefreshRequested += RefreshMenus;
			LocalizationApi.LanguageChanged += OnLanguageChanged;
			try
			{
				RegisterSelf();
				_harmony = new Harmony("IceBoxStudio.GraveyardKeeper2.ModSettingsMenu");
				_harmony.PatchAll(Assembly.GetExecutingAssembly());
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed to initialize Mod Settings Menu: {arg}");
			}
		}

		private static void RefreshMenus()
		{
			ModSettingsMenuController.Refresh();
		}

		private static void OnLanguageChanged(string language)
		{
			RegisterSelf();
			ModSettingsMenuController.RefreshLocalizedText();
		}

		private static void RegisterSelf()
		{
			ModSettingsRegistry.Register("IceBoxStudio.GraveyardKeeper2.ModSettingsMenu", new ModSettingsModOptions
			{
				Name = "ModSettingsMenu",
				LocalizedName = () => I18n.Text("mod.name"),
				Description = I18n.Text("mod.description"),
				Author = "Ice Box Studio",
				Version = "1.0.0",
				UpdateManifestUrl = "https://cdn.jsdelivr.net/gh/ibox233/MyMod_Version@main/GraveyardKeeper2/ModSettingsMenu.json",
				NexusModsId = 245,
				ThunderstoreModName = "ModSettingsMenu",
				ThunderstoreTeam = "Ice_Box_Studio_GK2"
			});
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IceBoxStudio.GraveyardKeeper2.ModSettingsMenu";

		public const string PLUGIN_NAME = "ModSettingsMenu";

		public const string PLUGIN_VERSION = "1.0.0";

		public const string PLUGIN_AUTHOR = "Ice Box Studio";

		public const string UPDATE_MANIFEST_URL = "https://cdn.jsdelivr.net/gh/ibox233/MyMod_Version@main/GraveyardKeeper2/ModSettingsMenu.json";

		public const int NEXUS_MODS_ID = 245;

		public const string THUNDERSTORE_TEAM = "Ice_Box_Studio_GK2";

		public const string THUNDERSTORE_MOD_NAME = "ModSettingsMenu";
	}
}
namespace ModSettingsMenu.Update
{
	internal static class ModUpdateChecker
	{
		private const int MaxManifestBytes = 16384;

		private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(4.0);

		private static readonly Dictionary<string, ModUpdateCheckResult> Results = new Dictionary<string, ModUpdateCheckResult>(StringComparer.OrdinalIgnoreCase);

		private static readonly HashSet<string> StartedChecks = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static readonly object Sync = new object();

		private static readonly HttpClientHandler ClientHandler = new HttpClientHandler
		{
			AllowAutoRedirect = false
		};

		private static readonly HttpClient Client = new HttpClient((HttpMessageHandler)(object)ClientHandler)
		{
			Timeout = Timeout
		};

		public static ModUpdateCheckResult GetOrStart(ModSettingsRegistration registration, string currentVersion)
		{
			if (registration == null || string.IsNullOrWhiteSpace(registration.UpdateManifestUrl))
			{
				return ModUpdateCheckResult.NotConfigured();
			}
			ModUpdateCheckResult value;
			bool flag;
			lock (Sync)
			{
				if (Results.TryGetValue(registration.PluginGuid, out value))
				{
					return value;
				}
				flag = StartedChecks.Add(registration.PluginGuid);
				value = ModUpdateCheckResult.Checking();
				Results[registration.PluginGuid] = value;
			}
			if (flag)
			{
				CheckAsync(registration.PluginGuid, currentVersion, registration.UpdateManifestUrl);
			}
			return value;
		}

		private static async Task CheckAsync(string pluginGuid, string currentVersion, string manifestUrl)
		{
			ModUpdateCheckResult value = await CheckCoreAsync(currentVersion, manifestUrl).ConfigureAwait(continueOnCapturedContext: false);
			lock (Sync)
			{
				Results[pluginGuid] = value;
			}
		}

		private static async Task<ModUpdateCheckResult> CheckCoreAsync(string currentVersion, string manifestUrl)
		{
			_ = 2;
			try
			{
				if (!TryValidateHttpsUri(manifestUrl, out var uri))
				{
					return Failed();
				}
				using CancellationTokenSource cts = new CancellationTokenSource(Timeout);
				HttpResponseMessage response = await Client.GetAsync(uri, (HttpCompletionOption)1, cts.Token).ConfigureAwait(continueOnCapturedContext: false);
				try
				{
					if (response.StatusCode != HttpStatusCode.OK)
					{
						return Failed();
					}
					MediaTypeHeaderValue contentType = response.Content.Headers.ContentType;
					string text = ((contentType != null) ? contentType.MediaType : null);
					if (!string.IsNullOrWhiteSpace(text) && !text.Equals("application/json", StringComparison.OrdinalIgnoreCase) && !text.Equals("text/json", StringComparison.OrdinalIgnoreCase) && !text.Equals("text/plain", StringComparison.OrdinalIgnoreCase))
					{
						return Failed();
					}
					long? contentLength = response.Content.Headers.ContentLength;
					if (contentLength.HasValue && contentLength.Value > 16384)
					{
						return Failed();
					}
					using Stream stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(continueOnCapturedContext: false);
					return ParseManifest(await ReadLimitedStringAsync(stream, cts.Token).ConfigureAwait(continueOnCapturedContext: false), currentVersion);
				}
				finally
				{
					((IDisposable)response)?.Dispose();
				}
			}
			catch (OperationCanceledException)
			{
				return Failed();
			}
			catch (Exception ex2)
			{
				ManualLogSource log = ModSettingsMenu.Log;
				if (log != null)
				{
					log.LogWarning((object)("Update check failed: " + ex2.Message));
				}
				return Failed();
			}
		}

		private static ModUpdateCheckResult ParseManifest(string json, string currentVersion)
		{
			JObject root = JObject.Parse(json);
			string text = GetString(root, "version") ?? GetString(root, "latestVersion");
			if (string.IsNullOrWhiteSpace(text) || text.Length > 64)
			{
				return Failed();
			}
			bool flag = IsRemoteVersionNewer(currentVersion, text);
			return new ModUpdateCheckResult
			{
				Status = (flag ? ModUpdateCheckStatus.UpdateAvailable : ModUpdateCheckStatus.UpToDate),
				LatestVersion = text
			};
		}

		private static string GetString(JObject root, string propertyName)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			JToken val = root[propertyName];
			if (val == null || (int)val.Type != 8)
			{
				return null;
			}
			return Extensions.Value<string>((IEnumerable<JToken>)val);
		}

		private static async Task<string> ReadLimitedStringAsync(Stream stream, CancellationToken cancellationToken)
		{
			using MemoryStream memory = new MemoryStream();
			byte[] buffer = new byte[1024];
			while (true)
			{
				int num = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				if (num == 0)
				{
					break;
				}
				if (memory.Length + num > 16384)
				{
					throw new InvalidOperationException("Manifest too large.");
				}
				memory.Write(buffer, 0, num);
			}
			string text = Encoding.UTF8.GetString(memory.ToArray());
			return (text.Length > 0 && text[0] == '\ufeff') ? text.Substring(1) : text;
		}

		private static bool TryValidateHttpsUri(string url, out Uri uri)
		{
			uri = null;
			if (string.IsNullOrWhiteSpace(url) || url.Length > 2048 || !Uri.TryCreate(url, UriKind.Absolute, out uri))
			{
				return false;
			}
			if (!uri.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase))
			{
				return false;
			}
			if (uri.UserInfo.Length > 0 || uri.IsFile || uri.IsLoopback || uri.HostNameType == UriHostNameType.Unknown)
			{
				return false;
			}
			if ((uri.HostNameType == UriHostNameType.IPv4 || uri.HostNameType == UriHostNameType.IPv6) && IPAddress.TryParse(uri.DnsSafeHost, out IPAddress address) && IsUnsafeAddress(address))
			{
				return false;
			}
			return true;
		}

		private static bool IsUnsafeAddress(IPAddress address)
		{
			if (IPAddress.IsLoopback(address))
			{
				return true;
			}
			if (address.AddressFamily == AddressFamily.InterNetwork)
			{
				byte[] addressBytes = address.GetAddressBytes();
				if (addressBytes[0] != 10 && addressBytes[0] != 127 && addressBytes[0] != 0 && (addressBytes[0] != 169 || addressBytes[1] != 254) && (addressBytes[0] != 172 || addressBytes[1] < 16 || addressBytes[1] > 31))
				{
					if (addressBytes[0] == 192)
					{
						return addressBytes[1] == 168;
					}
					return false;
				}
				return true;
			}
			if (address.AddressFamily == AddressFamily.InterNetworkV6)
			{
				if (!address.IsIPv6LinkLocal && !address.IsIPv6SiteLocal && !address.IsIPv6Multicast && !address.Equals(IPAddress.IPv6None) && !address.Equals(IPAddress.IPv6Any))
				{
					return address.Equals(IPAddress.IPv6Loopback);
				}
				return true;
			}
			return true;
		}

		private static bool IsRemoteVersionNewer(string currentVersion, string latestVersion)
		{
			int[] array = ParseVersionParts(currentVersion);
			int[] array2 = ParseVersionParts(latestVersion);
			int num = Math.Max(array.Length, array2.Length);
			for (int i = 0; i < num; i++)
			{
				int num2 = ((i < array.Length) ? array[i] : 0);
				int num3 = ((i < array2.Length) ? array2[i] : 0);
				if (num3 > num2)
				{
					return true;
				}
				if (num3 < num2)
				{
					return false;
				}
			}
			return false;
		}

		private static int[] ParseVersionParts(string version)
		{
			if (string.IsNullOrWhiteSpace(version))
			{
				return Array.Empty<int>();
			}
			int result;
			return (from part in version.Split(new char[3] { '.', '-', '_' }, StringSplitOptions.RemoveEmptyEntries)
				select int.TryParse(new string(part.TakeWhile(char.IsDigit).ToArray()), out result) ? result : 0).ToArray();
		}

		private static ModUpdateCheckResult Failed()
		{
			return new ModUpdateCheckResult
			{
				Status = ModUpdateCheckStatus.Failed
			};
		}
	}
	internal enum ModUpdateCheckStatus
	{
		NotConfigured,
		Checking,
		UpToDate,
		UpdateAvailable,
		Failed
	}
	internal sealed class ModUpdateCheckResult
	{
		public ModUpdateCheckStatus Status { get; set; }

		public string LatestVersion { get; set; }

		public static ModUpdateCheckResult NotConfigured()
		{
			return new ModUpdateCheckResult
			{
				Status = ModUpdateCheckStatus.NotConfigured
			};
		}

		public static ModUpdateCheckResult Checking()
		{
			return new ModUpdateCheckResult
			{
				Status = ModUpdateCheckStatus.Checking
			};
		}
	}
}
namespace ModSettingsMenu.Runtime
{
	internal sealed class ConfigRows
	{
		private readonly Transform _content;

		private readonly GameObject _row;

		private readonly GameObject _heading;

		private readonly GameObject _divider;

		private readonly GameObject _toggle;

		private readonly GameObject _dropdown;

		private readonly LazyButton _button;

		private readonly TMP_InputField _input;

		private readonly KeybindEditor _keybindCapture;

		private readonly ModInfoRow _info;

		private readonly List<GameObject> _createdRows = new List<GameObject>();

		private readonly List<TMP_InputField> _inputs = new List<TMP_InputField>();

		private readonly Dictionary<GamepadNavigationItem, Action<int>> _changes = new Dictionary<GamepadNavigationItem, Action<int>>();

		private ConfigTextLocalization _localization;

		public TMP_InputField Editing => ((IEnumerable<TMP_InputField>)_inputs).FirstOrDefault((Func<TMP_InputField, bool>)((TMP_InputField input) => (Object)(object)input != (Object)null && input.isFocused));

		private float Width
		{
			get
			{
				//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_0015: Unknown result type (might be due to invalid IL or missing references)
				Rect rect = ((RectTransform)_content).rect;
				return Mathf.Max(1f, ((Rect)(ref rect)).width - 8f);
			}
		}

		public ConfigRows(Transform content, GameObject row, GameObject heading, GameObject divider, GameObject toggle, GameObject dropdown, KeybindEditor keybindCapture, ModInfoRow info, LazyButton button, TMP_InputField input)
		{
			_content = content;
			_row = row;
			_heading = heading;
			_divider = divider;
			_toggle = toggle;
			_dropdown = dropdown;
			_keybindCapture = keybindCapture;
			_info = info;
			_button = button;
			_input = input;
		}

		public void Update()
		{
			_info?.Update();
		}

		public void Build(ModConfig mod)
		{
			ClearRows();
			_localization = ConfigTextLocalizations.Get(mod);
			if (mod == null)
			{
				CreateHeading(I18n.Text("menu.no_configurable_mods"));
			}
			else
			{
				GameObject val = _info?.Create(mod);
				if ((Object)(object)val != (Object)null)
				{
					CompleteRow(val);
				}
				List<ConfigEntryBase> list = (from entry in mod.ConfigFile.GetConfigEntries()
					orderby ModSettingsOrder.GetSectionOrder(mod, entry.Definition.Section)
					select entry).ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Section, StringComparer.OrdinalIgnoreCase).ThenBy((ConfigEntryBase entry) => ModSettingsOrder.GetEntryOrder(mod, entry)).ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Key, StringComparer.OrdinalIgnoreCase)
					.ToList();
				string text = null;
				foreach (ConfigEntryBase item in list)
				{
					if (!string.Equals(text, item.Definition.Section, StringComparison.OrdinalIgnoreCase))
					{
						text = item.Definition.Section;
						CreateHeading(SplitName(_localization?.GetSection(text) ?? LocalizationApi.GetConfigSection(text, mod.ConfigFile)));
					}
					CreateEntryRow(mod, item);
				}
			}
			LayoutRebuild();
		}

		public void Reset(ModConfig mod)
		{
			if (mod != null)
			{
				TMP_InputField editing = Editing;
				if (editing != null)
				{
					editing.DeactivateInputField(false);
				}
				ConfigEntryBase[] configEntries = mod.ConfigFile.GetConfigEntries();
				foreach (ConfigEntryBase obj in configEntries)
				{
					ConfigValues.TrySetValue(obj, obj.DefaultValue);
				}
				Build(mod);
			}
		}

		public bool Adjust(GamepadNavigationItem item, int direction)
		{
			if ((Object)(object)item == (Object)null || !_changes.TryGetValue(item, out var value))
			{
				return false;
			}
			value(direction);
			return true;
		}

		private void ClearRows()
		{
			_keybindCapture.Cancel();
			foreach (GameObject createdRow in _createdRows)
			{
				if ((Object)(object)createdRow != (Object)null)
				{
					createdRow.SetActive(false);
					Object.Destroy((Object)(object)createdRow);
				}
			}
			_createdRows.Clear();
			_changes.Clear();
			_inputs.Clear();
		}

		private void CreateHeading(string text)
		{
			//IL_0050: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = NativeUi.Clone(_heading, _content, "Mod Settings Section - " + text);
			TMP_Text component = val.GetComponent<TMP_Text>();
			component.text = text;
			component.textWrappingMode = (TextWrappingModes)1;
			NativeUi.Align(component, (TextAlignmentOptions)257);
			float y = component.GetPreferredValues(text, Width - 8f, 0f).y;
			component.margin = new Vector4(4f, 10f, 0f, 10f);
			NativeUi.Height(val, y + 24f);
			GameObject obj = NativeUi.CloneDivider(_divider, val.transform, "Section Divider");
			RectTransform val2 = (RectTransform)obj.transform;
			val2.anchorMin = new Vector2(0f, 0f);
			val2.anchorMax = new Vector2(1f, 0f);
			val2.offsetMin = new Vector2(4f, 1f);
			val2.offsetMax = new Vector2(-4f, 2.5f);
			Image component2 = obj.GetComponent<Image>();
			component2.sprite = null;
			((Graphic)component2).material = null;
			component2.type = (Type)0;
			Color color = ((Graphic)component).color;
			color.a = 0.55f;
			((Graphic)component2).color = color;
			CompleteRow(val);
		}

		private void CreateEntryRow(ModConfig mod, ConfigEntryBase entry)
		{
			Type settingType = entry.SettingType;
			ConfigDescription description = entry.Description;
			AcceptableValueBase acceptable = ((description != null) ? description.AcceptableValues : null);
			IReadOnlyList<object> values;
			float min;
			float max;
			if (settingType == typeof(bool))
			{
				CreateBoolRow(entry);
			}
			else if (settingType == typeof(KeyCode) || settingType == typeof(KeyboardShortcut))
			{
				CreateKeybindRow(entry);
			}
			else if (settingType.IsEnum)
			{
				CreateDropdownRow(entry, Enum.GetValues(settingType).Cast<object>().ToList());
			}
			else if (ConfigValues.TryGetAcceptableValues(acceptable, out values))
			{
				CreateDropdownRow(entry, values);
			}
			else if (ConfigValues.TryGetNumericRange(acceptable, out min, out max) && ConfigValues.IsSliderType(settingType))
			{
				CreateSliderRow(mod, entry, min, max);
			}
			else
			{
				CreateInputRow(entry);
			}
		}

		private void CreateBoolRow(ConfigEntryBase entry)
		{
			CreateSwitchRow(entry, _toggle, new object[2] { false, true }, (object value) => _localization?.GetValue(entry, value) ?? I18n.Text(((bool)value) ? "menu.on" : "menu.off"));
		}

		private void CreateDropdownRow(ConfigEntryBase entry, IReadOnlyList<object> values)
		{
			CreateSwitchRow(entry, _dropdown, values, (object value) => GetConfigValueText(entry, value));
		}

		private void CreateSwitchRow(ConfigEntryBase entry, GameObject source, IReadOnlyList<object> values, Func<object, string> format)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			GameObject val = NewRow(source, entry);
			Transform obj = val.transform.Find("Control");
			Transform val2 = obj.Find("Back");
			TMP_Text label = ((Component)val2.Find("Value")).GetComponent<TMP_Text>();
			Button component = ((Component)obj.Find("ToLeft")).GetComponent<Button>();
			Button component2 = ((Component)obj.Find("ToRight")).GetComponent<Button>();
			NativeUi.Bottom((RectTransform)val2, 0f, 1f, 1f, 24f);
			RectTransform val3 = (RectTransform)val2;
			val3.offsetMin += new Vector2(28f, 0f);
			val3.offsetMax -= new Vector2(28f, 0f);
			PlaceEdge((RectTransform)((Component)component).transform, right: false);
			PlaceEdge((RectTransform)((Component)component2).transform, right: true);
			label.textWrappingMode = (TextWrappingModes)0;
			label.overflowMode = (TextOverflowModes)1;
			Action<int> change = delegate(int direction)
			{
				int num = 0;
				for (int i = 0; i < values.Count; i++)
				{
					if (object.Equals(values[i], entry.BoxedValue))
					{
						num = i;
						break;
					}
				}
				if (values.Count > 0)
				{
					num = (num + direction + values.Count) % values.Count;
					ConfigValues.TrySetValue(entry, values[num]);
				}
				label.text = format(entry.BoxedValue);
			};
			label.text = format(entry.BoxedValue);
			((Selectable)component).interactable = values.Count > 1;
			((Selectable)component2).interactable = values.Count > 1;
			NativeUi.Bind(component, (UnityAction)delegate
			{
				change(-1);
			});
			NativeUi.Bind(component2, (UnityAction)delegate
			{
				change(1);
			});
			GamepadNavigationItem key = SetupItem(val, entry, (UnityAction)delegate
			{
				change(1);
			});
			_changes[key] = change;
			CompleteRow(val);
		}

		private void CreateKeybindRow(ConfigEntryBase entry)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			GameObject val = NewRow(_row, entry);
			HideValues(val);
			LazyButton button = NativeUi.CloneButton(_button, val.transform.Find("Control"), "Keybind");
			NativeUi.Bottom((RectTransform)((Component)button).transform, 0f, 1f, 0f, 26f);
			TMP_Text text = NativeUi.FitButton(button);
			text.fontSize = Mathf.Min(text.fontSize, 14f);
			text.textWrappingMode = (TextWrappingModes)0;
			text.overflowMode = (TextOverflowModes)1;
			NativeUi.SetText(((Component)button).gameObject, KeybindCapture.FormatKeyCode(entry.BoxedValue));
			((Component)button).gameObject.SetActive(true);
			NativeUi.Bind((Button)(object)button, (UnityAction)delegate
			{
				_keybindCapture.Begin(entry, (Button)(object)button, text);
			});
			SetupItem(val, entry, (UnityAction)delegate
			{
				((UnityEvent)((Button)button).onClick).Invoke();
			});
			CompleteRow(val);
		}

		private void CreateSliderRow(ModConfig mod, ConfigEntryBase entry, float min, float max)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Expected O, but got Unknown
			GameObject val = NewRow(_row, entry);
			Transform val2 = val.transform.Find("Control");
			Slider slider = val.GetComponentInChildren<Slider>(true);
			TMP_Text valueText = ((Component)val2.Find("Value")).GetComponent<TMP_Text>();
			Button component = ((Component)val2.Find("Minus")).GetComponent<Button>();
			Button component2 = ((Component)val2.Find("Plus")).GetComponent<Button>();
			NativeUi.Bottom((RectTransform)((Component)slider).transform, 0f, 0.68f, 4f, 18f);
			RectTransform val3 = (RectTransform)((Component)slider).transform;
			val3.offsetMin += new Vector2(28f, 0f);
			NativeUi.Bottom((RectTransform)valueText.transform, 0.68f, 1f, 1f, 24f);
			RectTransform val4 = (RectTransform)valueText.transform;
			val4.offsetMax -= new Vector2(28f, 0f);
			valueText.enableAutoSizing = false;
			NativeUi.Align(valueText, (TextAlignmentOptions)514);
			PlaceEdge((RectTransform)((Component)component).transform, right: false);
			PlaceEdge((RectTransform)((Component)component2).transform, right: true);
			double step = ConfigValues.GetSliderStep(configuredStep: ModSettingsMetadata.GetSliderStep(mod, entry), min: min, max: max, targetType: entry.SettingType);
			float valueWithoutNotify = ConfigValues.SnapSliderValue(Convert.ToSingle(entry.BoxedValue, CultureInfo.InvariantCulture), min, max, entry.SettingType, step);
			slider.onValueChanged = new SliderEvent();
			slider.minValue = min;
			slider.maxValue = max;
			slider.wholeNumbers = ConfigValues.IsIntegralType(entry.SettingType);
			slider.SetValueWithoutNotify(valueWithoutNotify);
			Navigation navigation = ((Selectable)slider).navigation;
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)slider).navigation = navigation;
			((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)delegate(float sliderValue)
			{
				object value = ConfigValues.ConvertSliderValue(ConfigValues.SnapSliderValue(sliderValue, min, max, entry.SettingType, step), entry.SettingType);
				ConfigValues.TrySetValue(entry, value);
				slider.SetValueWithoutNotify(Convert.ToSingle(entry.BoxedValue, CultureInfo.InvariantCulture));
				valueText.text = ConfigValues.FormatValue(entry.BoxedValue);
			});
			valueText.text = ConfigValues.FormatValue(entry.BoxedValue);
			Action<int> change = delegate(int direction)
			{
				float value = Convert.ToSingle(entry.BoxedValue, CultureInfo.InvariantCulture);
				float sliderStepCount = ConfigValues.GetSliderStepCount(min, max, step);
				float sliderValue = ConfigValues.GetSliderValue(Mathf.Clamp(ConfigValues.GetSliderStepIndex(value, min, max, step, sliderStepCount) + (float)direction, 0f, sliderStepCount), min, max, entry.SettingType, step, sliderStepCount);
				slider.value = sliderValue;
			};
			NativeUi.Bind(component, (UnityAction)delegate
			{
				change(-1);
			});
			NativeUi.Bind(component2, (UnityAction)delegate
			{
				change(1);
			});
			GamepadNavigationItem key = SetupItem(val, entry, (UnityAction)delegate
			{
				change(1);
			});
			_changes[key] = change;
			CompleteRow(val);
		}

		private void CreateInputRow(ConfigEntryBase entry)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Expected O, but got Unknown
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Expected O, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			GameObject val = NewRow(_row, entry);
			HideValues(val);
			GameObject val2 = NativeUi.Clone(((Component)_input).gameObject, val.transform.Find("Control"), "Value Input");
			val2.SetActive(false);
			TMP_InputField input = val2.GetComponent<TMP_InputField>();
			TMP_Text textComponent = input.textComponent;
			TMP_Text textComponent2 = NativeUi.Label(_heading.GetComponent<TMP_Text>(), (Transform)(object)input.textViewport, "Text", string.Empty);
			input.textComponent = textComponent2;
			Object.DestroyImmediate((Object)(object)((Component)textComponent).gameObject);
			NativeUi.Bottom((RectTransform)((Component)input).transform, 0f, 1f, 0f, 26f);
			NativeUi.Stretch(input.textViewport);
			input.textViewport.offsetMin = new Vector2(8f, 2f);
			input.textViewport.offsetMax = new Vector2(-8f, -2f);
			((Component)input.textViewport).GetComponent<RectMask2D>().padding = Vector4.zero;
			NativeUi.Stretch(input.textComponent.rectTransform);
			NativeUi.Align(input.textComponent, (TextAlignmentOptions)4097);
			input.textComponent.textWrappingMode = (TextWrappingModes)0;
			input.textComponent.enableAutoSizing = false;
			input.textComponent.fontSize = _heading.GetComponent<TMP_Text>().fontSize;
			input.textComponent.margin = Vector4.zero;
			input.richText = false;
			Image component = val2.GetComponent<Image>();
			Image component2 = ((Component)_dropdown.transform.Find("Back")).GetComponent<Image>();
			component.sprite = component2.sprite;
			component.type = component2.type;
			((Graphic)component).color = ((Graphic)component2).color;
			((Graphic)component).material = ((Graphic)component2).material;
			input.fontAsset = input.textComponent.font;
			input.pointSize = input.textComponent.fontSize;
			input.customCaretColor = true;
			input.caretColor = ((Graphic)input.textComponent).color;
			input.contentType = (ContentType)0;
			input.characterValidation = (CharacterValidation)0;
			input.lineType = (LineType)0;
			input.characterLimit = 0;
			input.onFocusSelectAll = false;
			Graphic placeholder = input.placeholder;
			TMP_Text val3 = (TMP_Text)(object)((placeholder is TMP_Text) ? placeholder : null);
			if (val3 != null)
			{
				val3.text = string.Empty;
			}
			Navigation navigation = ((Selectable)input).navigation;
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)input).navigation = navigation;
			input.onValidateInput = null;
			input.onValueChanged = new OnChangeEvent();
			input.onEndEdit = new SubmitEvent();
			input.onSubmit = new SubmitEvent();
			input.onSelect = new SelectionEvent();
			input.onDeselect = new SelectionEvent();
			((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)delegate(string value)
			{
				if (!input.wasCanceled)
				{
					if (entry.SettingType == typeof(string))
					{
						ConfigValues.TrySetValue(entry, value);
					}
					else
					{
						ConfigValues.TrySetSerializedValue(entry, value);
					}
				}
				input.SetTextWithoutNotify((entry.SettingType == typeof(string)) ? ((string)entry.BoxedValue) : entry.GetSerializedValue());
			});
			input.text = ((entry.SettingType == typeof(string)) ? ((string)entry.BoxedValue) : entry.GetSerializedValue());
			val2.SetActive(true);
			SetupItem(val, entry, (UnityAction)delegate
			{
				((Selectable)input).Select();
				input.ActivateInputField();
			});
			_inputs.Add(input);
			CompleteRow(val);
		}

		private GameObject NewRow(GameObject source, ConfigEntryBase entry)
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: 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)
			GameObject val = NativeUi.Clone(source, _content, GetRowName(entry));
			UIMouseTooltip[] componentsInChildren = val.GetComponentsInChildren<UIMouseTooltip>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			val.SetActive(true);
			TMP_Text title = NativeUi.SetRowTitle(val, GetSettingText(entry));
			RectTransform val2 = NativeUi.Rect("Control", val.transform);
			for (int num = val.transform.childCount - 1; num >= 0; num--)
			{
				Transform child = val.transform.GetChild(num);
				if ((Object)(object)child != (Object)(object)val2 && (Object)(object)child != (Object)(object)title.transform && ((Object)child).name != "GamepadRect")
				{
					child.SetParent((Transform)(object)val2, false);
				}
			}
			bool flag = Width < 340f;
			float num2 = (flag ? Width : (Width * 0.42f - 8f));
			float num3 = Mathf.Max(18f, title.GetPreferredValues(title.text, num2, 0f).y);
			float num4 = (flag ? (num3 + 32f) : Mathf.Max(30f, num3 + 4f));
			NativeUi.Height(val, num4);
			NativeUi.Place(title.rectTransform, 0f, flag ? 1f : 0.42f, flag ? 30f : 0f, 0f);
			RectTransform rectTransform = title.rectTransform;
			rectTransform.offsetMax += new Vector2(flag ? 0f : (-8f), 0f);
			NativeUi.Align(title, (TextAlignmentOptions)(flag ? 257 : 4097));
			NativeUi.Bottom(val2, flag ? 0f : 0.44f, 1f, flag ? 0f : ((num4 - 26f) * 0.5f), 26f);
			string description = _localization?.GetDescription(entry) ?? LocalizationApi.GetConfigDescription(entry);
			if (!string.IsNullOrWhiteSpace(description))
			{
				UIMouseTooltip.AttachCustom(((Component)title).gameObject, (Action)delegate
				{
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_0019: Unknown result type (might be due to invalid IL or missing references)
					UITooltip.ShowSimpleInfo((Transform)(object)title.rectTransform, description, default(Vector2), title.text);
				}, true, false, default(UIMouseTooltipEdges), default(Vector2));
			}
			return val;
		}

		private static void HideValues(GameObject row)
		{
			Transform obj = row.transform.Find("Control");
			((Component)obj.Find("Slider")).gameObject.SetActive(false);
			((Component)obj.Find("Value")).gameObject.SetActive(false);
			((Component)obj.Find("Minus")).gameObject.SetActive(false);
			((Component)obj.Find("Plus")).gameObject.SetActive(false);
		}

		private static void PlaceEdge(RectTransform rect, bool right)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			float num = (right ? 1f : 0f);
			rect.anchorMin = new Vector2(num, 0f);
			rect.anchorMax = new Vector2(num, 0f);
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.anchoredPosition = new Vector2(right ? (-12.5f) : 12.5f, 13f);
			rect.sizeDelta = new Vector2(25f, 26f);
		}

		private GamepadNavigationItem SetupItem(GameObject row, ConfigEntryBase entry, UnityAction select)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00c5: Expected O, but got Unknown
			GamepadNavigationItem component = row.GetComponent<GamepadNavigationItem>();
			GamepadNavigationItem[] componentsInChildren = row.GetComponentsInChildren<GamepadNavigationItem>(true);
			foreach (GamepadNavigationItem obj in componentsInChildren)
			{
				obj.Active = (Object)(object)obj == (Object)(object)component;
			}
			component.group = 2;
			component.ignoreScroll = true;
			component.FocusRectTransform = (RectTransform)row.transform;
			component.ResetCustomDirections();
			TMP_Text title = ((Component)row.transform.Find("LeftName")).GetComponent<TMP_Text>();
			FontStyles style = title.fontStyle;
			string description = _localization?.GetDescription(entry) ?? LocalizationApi.GetConfigDescription(entry);
			component.SetCallbacks((UnityAction)delegate
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: 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)
				if (!LazyInput.IsGamepadActive)
				{
					title.fontStyle = (FontStyles)(style | 4);
				}
				else if (!string.IsNullOrWhiteSpace(description))
				{
					UITooltip.ShowSimpleInfo((Transform)(object)title.rectTransform, description, default(Vector2), title.text);
				}
			}, (UnityAction)delegate
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				title.fontStyle = style;
				UIMouseTooltip.HideIfShowingAt(title.rectTransform, false);
			}, select);
			return component;
		}

		private void CompleteRow(GameObject row)
		{
			row.SetActive(true);
			_createdRows.Add(row);
		}

		private void LayoutRebuild()
		{
			RectTransform component = ((Component)_content).GetComponent<RectTransform>();
			LayoutRebuilder.ForceRebuildLayoutImmediate(component);
			_info?.Repair();
			LayoutRebuilder.ForceRebuildLayoutImmediate(component);
			ScrollRect componentInParent = ((Component)_content).GetComponentInParent<ScrollRect>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				componentInParent.verticalNormalizedPosition = 1f;
			}
		}

		private static string GetRowName(ConfigEntryBase entry)
		{
			return "Mod Setting - " + entry.Definition.Key;
		}

		private string GetSettingText(ConfigEntryBase entry)
		{
			return SplitName(_localization?.GetName(entry) ?? LocalizationApi.GetConfigDisplayName(entry));
		}

		private string GetConfigValueText(ConfigEntryBase entry, object value)
		{
			string text = _localization?.GetValue(entry, value);
			if (!string.IsNullOrWhiteSpace(text))
			{
				return text;
			}
			string result = default(string);
			if (!LocalizationApi.TryGetConfigDisplayValue(entry, value, ref result))
			{
				return ConfigValues.FormatValue(value);
			}
			return result;
		}

		private static string SplitName(string text)
		{
			if (string.IsNullOrWhiteSpace(text))
			{
				return text;
			}
			StringBuilder stringBuilder = new StringBuilder(text.Length + 8);
			for (int i = 0; i < text.Length; i++)
			{
				char c = text[i];
				if (c == '_')
				{
					if (stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] != ' ')
					{
						stringBuilder.Append(' ');
					}
					continue;
				}
				bool flag = i > 0 && !char.IsWhiteSpace(text[i - 1]);
				if (char.IsUpper(c) && flag && (char.IsLower(text[i - 1]) || (i + 1 < text.Length && char.IsLower(text[i + 1]))) && stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] != ' ')
				{
					stringBuilder.Append(' ');
				}
				stringBuilder.Append(c);
			}
			return stringBuilder.ToString().Trim();
		}
	}
	internal sealed class KeybindCapture
	{
		private ConfigEntryBase _entry;

		private TMP_Text _buttonText;

		private int _startFrame;

		public bool IsActive => _entry != null;

		public void Begin(ConfigEntryBase entry, Button button, TMP_Text buttonText)
		{
			_entry = entry;
			_buttonText = buttonText;
			_startFrame = Time.frameCount;
			_buttonText.text = I18n.Text("menu.press_a_key");
			NativeUi.SelectObject(((Component)button).gameObject);
		}

		public void CaptureInput()
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (Time.frameCount <= _startFrame)
			{
				return;
			}
			foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
			{
				if ((int)value != 0 && Input.GetKeyDown(value))
				{
					if ((int)value == 27)
					{
						Finish(save: false, (KeyCode)0);
					}
					else
					{
						Finish(save: true, value);
					}
					break;
				}
			}
		}

		public void Cancel()
		{
			if (IsActive)
			{
				Finish(save: false, (KeyCode)0);
			}
		}

		public unsafe static string FormatKeyCode(object value)
		{
			//IL_0009: 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)
			if (!(value is KeyCode val))
			{
				return ConfigValues.FormatValue(value);
			}
			return ((object)(*(KeyCode*)(&val))/*cast due to .constrained prefix*/).ToString();
		}

		private void Finish(bool save, KeyCode keyCode)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			if (save && _entry != null && !ConfigValues.TrySetValue(_entry, keyCode))
			{
				keyCode = (KeyCode)_entry.BoxedValue;
			}
			else if (_entry != null)
			{
				keyCode = (KeyCode)_entry.BoxedValue;
			}
			if ((Object)(object)_buttonText != (Object)null)
			{
				_buttonText.text = FormatKeyCode(keyCode);
			}
			_entry = null;
			_buttonText = null;
		}
	}
	internal sealed class KeybindEditor
	{
		private static readonly KeyCode[] Keys = ((KeyCode[])Enum.GetValues(typeof(KeyCode))).Distinct().ToArray();

		private readonly KeybindCapture _capture = new KeybindCapture();

		private readonly List<KeyCode> _held = new List<KeyCode>();

		private readonly Action<bool> _changed;

		private ConfigEntryBase _entry;

		private TMP_Text _text;

		private KeyCode _modifier;

		private bool _ready;

		private int _startFrame;

		private int _finishFrame = -1;

		public bool IsActive => _entry != null;

		public KeybindEditor(Action<bool> changed)
		{
			_changed = changed;
		}

		public void Update()
		{
			if (!IsActive && Time.frameCount > _finishFrame && !Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2))
			{
				_changed(obj: false);
			}
		}

		public void Begin(ConfigEntryBase entry, Button button, TMP_Text text)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!IsActive && Time.frameCount > _finishFrame + 1)
			{
				_entry = entry;
				_text = text;
				_modifier = (KeyCode)0;
				_ready = false;
				_startFrame = Time.frameCount;
				_held.Clear();
				_held.AddRange(Keys.Where((KeyCode key) => (int)key != 0 && Input.GetKey(key)));
				if (entry.SettingType == typeof(KeyCode))
				{
					_capture.Begin(entry, button, text);
				}
				else
				{
					text.text = I18n.Text("menu.press_a_key");
					NativeUi.SelectObject(((Component)button).gameObject);
				}
				_changed(obj: true);
			}
		}

		public void CaptureInput()
		{
			//IL_00be: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			if (!IsActive || Time.frameCount <= _startFrame)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				Cancel();
				return;
			}
			if (!_ready)
			{
				_held.RemoveAll((KeyCode key) => !Input.GetKey(key));
				_ready = _held.Count == 0;
				if (!_ready)
				{
					return;
				}
			}
			if (_entry.SettingType == typeof(KeyCode))
			{
				_capture.CaptureInput();
				if (!_capture.IsActive)
				{
					Finish();
				}
				return;
			}
			KeyCode[] keys = Keys;
			foreach (KeyCode val in keys)
			{
				if ((int)val == 0 || !Input.GetKeyDown(val))
				{
					continue;
				}
				if (IsModifier(val))
				{
					_modifier = val;
					continue;
				}
				KeyCode[] array = Keys.Where((KeyCode value) => IsModifier(value) && Input.GetKey(value)).ToArray();
				ConfigValues.TrySetValue(_entry, (object)new KeyboardShortcut(val, array));
				Finish();
				return;
			}
			if ((int)_modifier != 0 && Input.GetKeyUp(_modifier) && !Keys.Any((KeyCode key) => IsModifier(key) && Input.GetKey(key)))
			{
				ConfigValues.TrySetValue(_entry, (object)new KeyboardShortcut(_modifier, Array.Empty<KeyCode>()));
				Finish();
			}
		}

		public void Cancel()
		{
			if (IsActive)
			{
				_capture.Cancel();
				Finish();
			}
		}

		private void Finish()
		{
			if ((Object)(object)_text != (Object)null)
			{
				_text.text = KeybindCapture.FormatKeyCode(_entry.BoxedValue);
			}
			_entry = null;
			_text = null;
			_held.Clear();
			_finishFrame = Time.frameCount;
		}

		private static bool IsModifier(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			if ((int)key != 306 && (int)key != 305 && (int)key != 304 && (int)key != 303 && (int)key != 308 && (int)key != 307 && (int)key != 310 && (int)key != 309 && (int)key != 311 && (int)key != 312)
			{
				return (int)key == 313;
			}
			return true;
		}
	}
	internal sealed class ModInfoRow
	{
		private sealed class MetadataPart
		{
			public string Text { get; }

			public string Name { get; }

			public string Url { get; }

			public MetadataPart(string text, string name = null, string url = null)
			{
				Text = text;
				Name = name;
				Url = url;
			}
		}

		private sealed class ModLink
		{
			public string Name { get; }

			public string Url { get; }

			public int Start { get; }

			public int Length { get; }

			public ModLink(string name, string url, int start, int length)
			{
				Name = name;
				Url = url;
				Start = start;
				Length = length;
			}
		}

		private readonly Transform _content;

		private readonly GameObject _slider;

		private readonly GameObject _divider;

		private readonly GameObject _linkButton;

		private readonly GameObject _description;

		private readonly TMP_Text _descriptionFont;

		private GameObject _row;

		private IReadOnlyList<ModLink> _links = Array.Empty<ModLink>();

		private bool _linksCreated;

		private ModSettingsRegistration _registration;

		private string _currentVersion;

		private TMP_Text _statusLabel;

		private ModUpdateCheckStatus _lastStatus;

		private string _lastVersion;

		public ModInfoRow(Transform content, GameObject slider, GameObject divider, GameObject linkButton, GameObject description, TMP_Text descriptionFont)
		{
			_content = content;
			_slider = slider;
			_divider = divider;
			_linkButton = linkButton;
			_description = description;
			_descriptionFont = descriptionFont;
		}

		public GameObject Create(ModConfig mod)
		{
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: 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_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: 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_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			_row = null;
			_links = Array.Empty<ModLink>();
			_linksCreated = false;
			_registration = null;
			_currentVersion = null;
			_statusLabel = null;
			_lastStatus = ModUpdateCheckStatus.NotConfigured;
			_lastVersion = null;
			ModSettingsRegistration modSettingsRegistration = mod?.Registration;
			if (modSettingsRegistration == null)
			{
				return null;
			}
			List<ModLink> links;
			string text = BuildText(modSettingsRegistration, out links);
			string text2 = modSettingsRegistration.Description?.Trim();
			bool flag = !string.IsNullOrWhiteSpace(modSettingsRegistration.UpdateManifestUrl);
			if (string.IsNullOrWhiteSpace(text) && string.IsNullOrWhiteSpace(text2) && !flag)
			{
				return null;
			}
			if (string.IsNullOrWhiteSpace(text) && !flag)
			{
				text = text2;
				text2 = null;
			}
			GameObject val = NewRow();
			HideRowContents(val);
			RectTransform component = val.GetComponent<RectTransform>();
			RectTransform component2 = _slider.GetComponent<RectTransform>();
			RectTransform component3 = _description.GetComponent<RectTransform>();
			RectTransform component4 = _divider.GetComponent<RectTransform>();
			if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null || (Object)(object)component4 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			Rect rect = ((RectTransform)_content).rect;
			float width = ((Rect)(ref rect)).width;
			float num = Mathf.Max(1f, width);
			float num2 = Mathf.Max(1f, num);
			float num3 = (flag ? Mathf.Clamp(num2 * 0.3f, 60f, 120f) : 0f);
			float width2 = Mathf.Max(1f, num2 - num3 - (flag ? 8f : 0f));
			RectTransform infoRect;
			TMP_Text infoLabel;
			float height;
			GameObject val2 = CreateText(val, text, width2, out infoRect, out infoLabel, out height);
			if ((Object)(object)val2 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			GameObject val3 = null;
			RectTransform infoRect2 = null;
			float height2 = 0f;
			if (!string.IsNullOrWhiteSpace(text2))
			{
				val3 = CreateText(val, text2, num2, out infoRect2, out var _, out height2);
				if ((Object)(object)val3 == (Object)null)
				{
					Object.Destroy((Object)(object)val);
					return null;
				}
				((Object)val3).name = "Information Description";
			}
			GameObject val4 = null;
			RectTransform infoRect3 = null;
			TMP_Text infoLabel3 = null;
			if (flag)
			{
				val4 = CreateText(val, string.Empty, num3, out infoRect3, out infoLabel3, out var _);
				if ((Object)(object)val4 == (Object)null)
				{
					Object.Destroy((Object)(object)val);
					return null;
				}
				((Object)val4).name = "Update Status";
				infoLabel3.textWrappingMode = (TextWrappingModes)0;
				infoLabel3.overflowMode = (TextOverflowModes)1;
				NativeUi.Align(infoLabel3, (TextAlignmentOptions)260);
			}
			float fontSize = _descriptionFont.fontSize;
			float num4 = height + 2f + 12f + 6f;
			if ((Object)(object)val3 != (Object)null)
			{
				num4 += height2 + fontSize;
			}
			component.sizeDelta = new Vector2(num, num4);
			SetTextRect(infoRect, component3, height, num4, 6f, 0f);
			if (flag)
			{
				infoRect.offsetMax = new Vector2(0f - num3 - 8f, infoRect.offsetMax.y);
				SetStatusRect(infoRect3, num3, height, 6f);
				val4.SetActive(true);
			}
			val2.SetActive(true);
			if ((Object)(object)val3 != (Object)null)
			{
				SetTextRect(infoRect2, component3, height2, num4, 6f + height + fontSize, 0f);
				val3.SetActive(true);
			}
			GameObject val5 = NativeUi.CloneDivider(_divider, val.transform, "Information Divider");
			val5.SetActive(false);
			HideChildren(val5);
			Image component5 = val5.GetComponent<Image>();
			RectTransform component6 = val5.GetComponent<RectTransform>();
			if ((Object)(object)component5 == (Object)null || (Object)(object)component6 == (Object)null)
			{
				Object.Destroy((Object)(object)val5);
				Object.Destroy((Object)(object)val);
				return null;
			}
			((Graphic)component5).raycastTarget = false;
			component5.sprite = null;
			((Graphic)component5).material = null;
			component5.type = (Type)0;
			Color color = ((Graphic)_descriptionFont).color;
			color.a = 0.55f;
			((Graphic)component5).color = color;
			DisableLayoutDrivers(val5);
			component6.anchorMin = new Vector2(0f, 0.5f);
			component6.anchorMax = new Vector2(1f, 0.5f);
			component6.pivot = new Vector2(0.5f, 0.5f);
			component6.sizeDelta = new Vector2(0f, 2f);
			component6.anchoredPosition = new Vector2(0f, (0f - num4) * 0.5f + 6f + 1f);
			((Transform)component6).localScale = ((Transform)component4).localScale;
			((Transform)component6).localRotation = ((Transform)component4).localRotation;
			val5.SetActive(true);
			_row = val;
			_links = links;
			_registration = modSettingsRegistration;
			_currentVersion = (string.IsNullOrWhiteSpace(modSettingsRegistration.Version) ? mod.Info.Metadata.Version.ToString() : modSettingsRegistration.Version);
			_statusLabel = infoLabel3;
			return val;
		}

		public void Repair()
		{
			//IL_00a6: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_row == (Object)null)
			{
				return;
			}
			Transform transform = _row.transform;
			RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			Transform obj = transform.Find("Information Text");
			RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			Transform obj2 = transform.Find("Information Description");
			RectTransform val3 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null);
			Transform obj3 = transform.Find("Update Status");
			RectTransform val4 = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null);
			Transform obj4 = transform.Find("Information Divider");
			RectTransform val5 = (RectTransform)(object)((obj4 is RectTransform) ? obj4 : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val5 == (Object)null)
			{
				return;
			}
			TMP_Text val6 = ((Component)val2).GetComponent<TMP_Text>() ?? ((Component)val2).GetComponentInChildren<TMP_Text>(true);
			if (!((Object)(object)val6 == (Object)null))
			{
				Rect rect = ((RectTransform)_content).rect;
				float width = ((Rect)(ref rect)).width;
				float num = (((Object)(object)val4 == (Object)null) ? 0f : Mathf.Clamp(width * 0.3f, 60f, 120f));
				float fontSize = _descriptionFont.fontSize;
				rect = val.rect;
				StretchRow(val, width, ((Rect)(ref rect)).height);
				((Transform)val).localScale = Vector3.one;
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = new Vector2(0f, val2.offsetMin.y);
				val2.offsetMax = new Vector2(((Object)(object)val4 == (Object)null) ? 0f : (0f - num - 8f), val2.offsetMax.y);
				((Transform)val2).localScale = Vector3.one;
				TMP_Text val7 = (((Object)(object)val3 == (Object)null) ? null : (((Component)val3).GetComponent<TMP_Text>() ?? ((Component)val3).GetComponentInChildren<TMP_Text>(true)));
				if ((Object)(object)val3 != (Object)null)
				{
					val3.anchorMin = Vector2.zero;
					val3.anchorMax = Vector2.one;
					val3.offsetMin = new Vector2(0f, val3.offsetMin.y);
					val3.offsetMax = new Vector2(0f, val3.offsetMax.y);
					((Transform)val3).localScale = Vector3.one;
				}
				Canvas.ForceUpdateCanvases();
				val6.ForceMeshUpdate(true, true);
				if (val7 != null)
				{
					val7.ForceMeshUpdate(true, true);
				}
				float num2 = Mathf.Max(_descriptionFont.fontSize, val6.renderedHeight);
				float num3 = num2 + 2f + 12f + 6f;
				if ((Object)(object)val7 != (Object)null)
				{
					num3 += Mathf.Max(_descriptionFont.fontSize, val7.renderedHeight) + fontSize;
				}
				StretchRow(val, width, num3);
				SetTextRect(val2, null, num2, num3, 6f, 0f);
				if ((Object)(object)val4 != (Object)null)
				{
					val2.offsetMax = new Vector2(0f - num - 8f, val2.offsetMax.y);
					SetStatusRect(val4, num, num2, 6f);
				}
				if ((Object)(object)val7 != (Object)null)
				{
					float height = Mathf.Max(_descriptionFont.fontSize, val7.renderedHeight);
					SetTextRect(val3, null, height, num3, 6f + num2 + fontSize, 0f);
				}
				val5.anchorMin = new Vector2(0f, 0.5f);
				val5.anchorMax = new Vector2(1f, 0.5f);
				val5.sizeDelta = new Vector2(0f, 2f);
				val5.anchoredPosition = new Vector2(0f, (0f - num3) * 0.5f + 6f + 1f);
				((Transform)val5).localScale = Vector3.one;
				if (!_linksCreated && _links.Count > 0)
				{
					Canvas.ForceUpdateCanvases();
					val6.ForceMeshUpdate(true, true);
					CreateLinkButtons(_row, val2, val6, _links);
				}
				_linksCreated = true;
			}
		}

		public void Update()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_statusLabel == (Object)null || _registration == null)
			{
				return;
			}
			ModUpdateCheckResult orStart = ModUpdateChecker.GetOrStart(_registration, _currentVersion);
			if (_lastStatus != orStart.Status || !(_lastVersion == orStart.LatestVersion))
			{
				_lastStatus = orStart.Status;
				_lastVersion = orStart.LatestVersion;
				switch (orStart.Status)
				{
				case ModUpdateCheckStatus.UpToDate:
					_statusLabel.text = I18n.Text("menu.update_latest");
					((Graphic)_statusLabel).color = Color32.op_Implicit(new Color32((byte)104, (byte)205, (byte)112, byte.MaxValue));
					break;
				case ModUpdateCheckStatus.UpdateAvailable:
					_statusLabel.text = I18n.Text("menu.update_available", orStart.LatestVersion);
					((Graphic)_statusLabel).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)72, (byte)72, byte.MaxValue));
					break;
				case ModUpdateCheckStatus.Failed:
					_statusLabel.text = I18n.Text("menu.update_failed");
					((Graphic)_statusLabel).color = Color32.op_Implicit(new Color32((byte)196, (byte)170, (byte)132, byte.MaxValue));
					break;
				default:
					_statusLabel.text = string.Empty;
					break;
				}
			}
		}

		private GameObject CreateText(GameObject row, string text, float width, out RectTransform infoRect, out TMP_Text infoLabel, out float height)
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			infoRect = null;
			infoLabel = null;
			height = 0f;
			GameObject val = Object.Instantiate<GameObject>(_description, row.transform);
			((Object)val).name = "Information Text";
			val.SetActive(false);
			NativeUi.DisableLocalization(val);
			infoRect = val.GetComponent<RectTransform>();
			infoLabel = val.GetComponent<TMP_Text>() ?? val.GetComponentInChildren<TMP_Text>(true);
			if ((Object)(object)infoRect == (Object)null || (Object)(object)infoLabel == (Object)null || (Object)(object)_descriptionFont == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				infoRect = null;
				infoLabel = null;
				return null;
			}
			infoLabel.enableAutoSizing = false;
			infoLabel.textWrappingMode = (TextWrappingModes)1;
			infoLabel.richText = true;
			infoLabel.overflowMode = (TextOverflowModes)0;
			((Graphic)infoLabel).raycastTarget = false;
			NativeUi.Align(infoLabel, (TextAlignmentOptions)257);
			infoLabel.fontSize = _descriptionFont.fontSize;
			infoLabel.text = text.Trim();
			DisableLayoutDrivers(val);
			height = Mathf.Max(_descriptionFont.fontSize, infoLabel.GetPreferredValues(infoLabel.text, width, 0f).y);
			return val;
		}

		private void CreateLinkButtons(GameObject row, RectTransform infoRect, TMP_Text infoText, IReadOnlyList<ModLink> links)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)infoRect == (Object)null || (Object)(object)infoText == (Object)null)
			{
				return;
			}
			infoText.ForceMeshUpdate(true, true);
			for (int i = 0; i < links.Count; i++)
			{
				ModLink link = links[i];
				List<Rect> linkBounds = GetLinkBounds(infoText, link);
				for (int j = 0; j < linkBounds.Count; j++)
				{
					CreateLinkButton(row, infoRect, infoText, link, linkBounds[j], j);
				}
			}
		}

		private void CreateLinkButton(GameObject row, RectTransform infoRect, TMP_Text infoText, ModLink link, Rect bounds, int segment)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00b4: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: 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_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: 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_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: 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)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(_linkButton, row.transform);
			((Object)val).name = link.Name + " Link " + segment;
			val.SetActive(false);
			NativeUi.DisableLocalization(val);
			NativeUi.SetText(val, string.Empty);
			Button component = val.GetComponent<Button>();
			Image component2 = val.GetComponent<Image>();
			if ((Object)(object)component2 == (Object)null)
			{
				GameObject val2 = new GameObject("Link Hit Area", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val2.transform.SetParent(val.transform, false);
				RectTransform component3 = val2.GetComponent<RectTransform>();
				component3.anchorMin = Vector2.zero;
				component3.anchorMax = Vector2.one;
				component3.offsetMin = Vector2.zero;
				component3.offsetMax = Vector2.zero;
				component2 = val2.GetComponent<Image>();
			}
			if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return;
			}
			Graphic[] componentsInChildren = val.GetComponentsInChildren<Graphic>(true);
			foreach (Graphic val3 in componentsInChildren)
			{
				if (!((Object)(object)val3 == (Object)(object)component2))
				{
					Color color = val3.color;
					color.a = 0f;
					val3.color = color;
					val3.raycastTarget = false;
				}
			}
			Image component4 = ((Component)_linkButton.transform.Find("Content/Back")).GetComponent<Image>();
			component2.sprite = component4.sprite;
			component2.type = component4.type;
			((Graphic)component2).material = ((Graphic)component4).material;
			Color color2 = ((Graphic)component4).color;
			color2.a = 0.8f;
			((Graphic)component2).color = Color.clear;
			((Graphic)component2).raycastTarget = true;
			((Selectable)component).targetGraphic = (Graphic)(object)component2;
			NativeUi.Bind(component, (UnityAction)delegate
			{
				Application.OpenURL(link.Url);
			});
			((Selectable)component).transition = (Transition)0;
			((Selectable)component).interactable = true;
			Navigation navigation = ((Selectable)component).navigation;
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)component).navigation = navigation;
			RectTransform component5 = val.GetComponent<RectTransform>();
			if ((Object)(object)component5 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return;
			}
			component5.anchorMin = new Vector2(0.5f, 0.5f);
			component5.anchorMax = new Vector2(0.5f, 0.5f);
			component5.pivot = new Vector2(0.5f, 0.5f);
			component5.sizeDelta = ((Rect)(ref bounds)).size + new Vector2(4f, 4f);
			((Transform)component5).localScale = ((Transform)infoRect).localScale;
			((Transform)component5).localRotation = ((Transform)infoRect).localRotation;
			((Transform)component5).localPosition = row.transform.InverseTransformPoint(((Transform)infoRect).TransformPoint(new Vector3(((Rect)(ref bounds)).center.x, ((Rect)(ref bounds)).center.y, 0f)));
			val.transform.SetSiblingIndex(((Transform)infoRect).GetSiblingIndex());
			ConfigureHover(val, component2, color2, infoText, link);
			val.SetActive(true);
		}

		private static void ConfigureHover(GameObject buttonObject, Image image, Color selectedColor, TMP_Text infoText, ModLink link)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			if (!((Object)(object)buttonObject == (Object)null) && !((Object)(object)infoText == (Object)null) && link.Start >= 0 && link.Start + link.Length <= infoText.text.Length)
			{
				string normalText = infoText.text;
				string hoverText = normalText.Substring(0, link.Start) + "<color=#FFCC75><u>" + normalText.Substring(link.Start, link.Length) + "</u></color>" + normalText.Substring(link.Start + link.Length);
				EventTrigger obj = buttonObject.GetComponent<EventTrigger>() ?? buttonObject.AddComponent<EventTrigger>();
				obj.triggers.Clear();
				Entry val = new Entry
				{
					eventID = (EventTriggerType)0
				};
				((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)image).color = selectedColor;
					infoText.text = hoverText;
				});
				obj.triggers.Add(val);
				Entry val2 = new Entry
				{
					eventID = (EventTriggerType)1
				};
				((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)image).color = Color.clear;
					infoText.text = normalText;
				});
				obj.triggers.Add(val2);
				GamepadNavigationItem component = buttonObject.GetComponent<GamepadNavigationItem>();
				component.ignoreScroll = true;
				component.group = 2;
				component.OnFocus.AddListener((UnityAction)delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)image).color = selectedColor;
					infoText.text = hoverText;
				});
				component.OnUnfocus.AddListener((UnityAction)delegate
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)image).color = Color.clear;
					infoText.text = normalText;
				});
			}
		}

		private static List<Rect> GetLinkBounds(TMP_Text text, ModLink link)
		{
			//IL_0059: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			List<Rect> list = new List<Rect>();
			TMP_TextInfo textInfo = text.textInfo;
			int num = Math.Min(link.Start + link.Length, textInfo.characterCount);
			int num2 = -1;
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			float num6 = 0f;
			for (int i = link.Start; i < num; i++)
			{
				TMP_CharacterInfo val = textInfo.characterInfo[i];
				if (!val.isVisible)
				{
					continue;
				}
				if (num2 != val.lineNumber)
				{
					if (num2 >= 0)
					{
						list.Add(Rect.MinMaxRect(num3, num4, num5, num6));
					}
					num2 = val.lineNumber;
					num3 = val.bottomLeft.x;
					num4 = val.bottomLeft.y;
					num5 = val.topRight.x;
					num6 = val.topRight.y;
				}
				else
				{
					num3 = Mathf.Min(num3, val.bottomLeft.x);
					num4 = Mathf.Min(num4, val.bottomLeft.y);
					num5 = Mathf.Max(num5, val.topRight.x);
					num6 = Mathf.Max(num6, val.topRight.y);
				}
			}
			if (num2 >= 0)
			{
				list.Add(Rect.MinMaxRect(num3, num4, num5, num6));
			}
			return list;
		}

		private static string BuildText(ModSettingsRegistration registration, out List<ModLink> links)
		{
			List<MetadataPart> list = new List<MetadataPart>();
			bool hasValue = registration.NexusModsId.HasValue;
			bool flag = !string.IsNullOrWhiteSpace(registration.ThunderstoreTeam);
			bool flag2 = hasValue && flag;
			if (!string.IsNullOrWhiteSpace(registration.Version))
			{
				list.Add(new MetadataPart("V" + registration.Version.Trim()));
			}
			if (!string.IsNullOrWhiteSpace(registration.Author))
			{
				list.Add(new MetadataPart(registration.Author.Trim()));
			}
			if (hasValue)
			{
				list.Add(new MetadataPart(flag2 ? "Nexus" : I18n.Text("menu.open_nexus_page"), "Nexus Mods", ModSettingsRegistry.GetNexusModsUrl(registration.NexusModsId.Value)));
			}
			if (flag)
			{
				list.Add(new MetadataPart(flag2 ? "Thunderstore" : I18n.Text("menu.open_thunderstore_page"), "Thunderstore", ModSettingsRegistry.GetThunderstoreUrl(registration.ThunderstoreTeam, registration.ThunderstoreModName)));
			}
			links = new List<ModLink>();
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < list.Count; i++)
			{
				if (i > 0)
				{
					stringBuilder.Append(" · ");
				}
				MetadataPart metadataPart = list[i];
				int length = stringBuilder.Length;
				stringBuilder.Append(metadataPart.Text);
				if (!string.IsNullOrWhiteSpace(metadataPart.Url))
				{
					links.Add(new ModLink(metadataPart.Name, metadataPart.Url, length, metadataPart.Text.Length));
				}
			}
			return stringBuilder.ToString();
		}

		private GameObject NewRow()
		{
			GameObject obj = Object.Instantiate<GameObject>(_slider, _content);
			((Object)obj).name = "Mod Settings Information";
			obj.SetActive(false);
			NativeUi.DisableLocalization(obj);
			HorizontalLayoutGroup component = obj.GetComponent<HorizontalLayoutGroup>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			return obj;
		}

		private static void HideRowContents(GameObject row)
		{
			HideChildren(row);
			Slider componentInChildren = row.GetComponentInChildren<Slider>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((Component)componentInChildren).gameObject.SetActive(false);
			}
			GamepadNavigationItem component = row.GetComponent<GamepadNavigationItem>();
			if ((Object)(object)component != (Object)null)
			{
				component.Active = false;
			}
		}

		private static void HideChildren(GameObject root)
		{
			for (int i = 0; i < root.transform.childCount; i++)
			{
				((Component)root.transform.GetChild(i)).gameObject.SetActive(false);
			}
		}

		private static void SetTextRect(RectTransform rect, RectTransform source, float height, float rowHeight, float verticalPadding, float horizontalPadding)
		{
			//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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.offsetMin = new Vector2(horizontalPadding, rowHeight - verticalPadding - height);
			rect.offsetMax = new Vector2(0f - horizontalPadding, 0f - verticalPadding);
			((Transform)rect).localScale = (((Object)(object)source == (Object)null) ? Vector3.one : ((Transform)source).localScale);
			((Transform)rect).localRotation = (((Object)(object)source == (Object)null) ? Quaternion.identity : ((Transform)source).localRotation);
		}

		private static void SetStatusRect(RectTransform rect, float width, float height, float top)
		{
			//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)
			//IL_0017: 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_0036: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = Vector2.one;
			rect.anchorMax = Vector2.one;
			rect.pivot = Vector2.one;
			rect.anchoredPosition = new Vector2(0f, 0f - top);
			rect.sizeDelta = new Vector2(width, height);
			((Transform)rect).localScale = Vector3.one;
			((Transform)rect).localRotation = Quaternion.identity;
		}

		private static void StretchRow(RectTransform rect, float nativeWidth, float height)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_005f: 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)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = new Vector2(0f, rect.anchorMin.y);
			rect.anchorMax = new Vector2(1f, rect.anchorMax.y);
			Vector2 sizeDelta = rect.sizeDelta;
			sizeDelta.x = 0f;
			sizeDelta.y = height;
			rect.sizeDelta = sizeDelta;
			rect.offsetMin = new Vector2(0f, rect.offsetMin.y);
			rect.offsetMax = new Vector2(0f, rect.offsetMax.y);
			Rect rect2 = rect.rect;
			if (((Rect)(ref rect2)).width < 1f)
			{
				rect.sizeDelta = new Vector2(nativeWidth, height);
			}
		}

		private static void DisableLayoutDrivers(GameObject root)
		{
			if (!((Object)(object)root == (Object)null))
			{
				LayoutGroup[] componentsInChildren = root.GetComponentsInChildren<LayoutGroup>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
				}
				ContentSizeFitter[] componentsInChildren2 = root.GetComponentsInChildren<ContentSizeFitter>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
				}
				AspectRatioFitter[] componentsInChildren3 = root.GetComponentsInChildren<AspectRatioFitter>(true);
				for (int i = 0; i < componentsInChildren3.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
				}
				LayoutElement[] componentsInChildren4 = root.GetComponentsInChildren<LayoutElement>(true);
				for (int i = 0; i < componentsInChildren4.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren4[i]);
				}
			}
		}
	}
	public static class ModSettingsMenuController
	{
		private static LazyButton _titleSource;

		private static LazyButton _pauseSource;

		private static LazyButton _titleButton;

		private static LazyButton _pauseButton;

		private static ModSettingsPanel _panel;

		public static void AddTitleButton(UIMainMenuWindow menu)
		{
			_titleButton = AddButton(_titleButton, ref _titleSource, NativeUi.Get<LazyButton>(menu, "gameSettingsButton"), inTitleMenu: true);
		}

		public static void AddPauseButton(UIGamePauseWindow menu)
		{
			_pauseButton = AddButton(_pauseButton, ref _pauseSource, NativeUi.Get<LazyButton>(menu, "settingsBtn"), inTitleMenu: false);
		}

		public static bool CaptureInput(LazyWindowInputController input)
		{
			if (_panel == null || !_panel.IsShown || _panel.InputController != input)
			{
				return true;
			}
			_panel.CaptureInput();
			return false;
		}

		public static bool Update(UIGameSettingsWindow settings)
		{
			if (_panel == null || !_panel.IsHost(settings) || !_panel.IsShown)
			{
				return true;
			}
			_panel.Update();
			return false;
		}

		public static void Refresh()
		{
			_panel?.Refresh();
		}

		public static void RefreshLocalizedText()
		{
			NativeUi.SetText(((Object)(object)_titleButton == (Object)null) ? null : ((Component)_titleButton).gameObject, I18n.Text("menu.mod_settings"));
			NativeUi.SetText(((Object)(object)_pauseButton == (Object)null) ? null : ((Component)_pauseButton).gameObject, I18n.Text("menu.mod_settings"));
			_panel?.Refresh();
		}

		public static void Close(UIGameSettingsWindow settings)
		{
			if (_panel != null && _panel.IsHost(settings))
			{
				_panel.Close();
			}
		}

		private static LazyButton AddButton(LazyButton current, ref LazyButton currentSource, LazyButton source, bool inTitleMenu)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			if ((Object)(object)current == (Object)null || (Object)(object)currentSource != (Object)(object)source)
			{
				if ((Object)(object)current != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)current).gameObject);
				}
				current = NativeUi.CloneButton(source, ((Component)source).transform.parent, "Mod Settings Button");
				((Component)current).transform.SetSiblingIndex(((Component)source).transform.GetSiblingIndex() + 1);
				currentSource = source;
				((Component)current).gameObject.SetActive(true);
			}
			NativeUi.Bind((Button)(object)current, (UnityAction)delegate
			{
				Open(inTitleMenu);
			});
			NativeUi.SetText(((Component)current).gameObject, I18n.Text("menu.mod_settings"));
			RectTransform val = (RectTransform)((Component)source).transform.parent;
			ContentSizeFitter component = ((Component)val).GetComponent<ContentSizeFitter>();
			bool enabled = (Object)(object)component != (Object)null && ((Behaviour)component).enabled;
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = true;
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(val);
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = enabled;
			}
			return current;
		}

		private static void Open(bool inTitleMenu)
		{
			UIGameSettingsWindow val = null;
			try
			{
				LazyWindow<LazyWidgetDataBase> menu = (LazyWindow<LazyWidgetDataBase>)(inTitleMenu ? ((object)LazyUI.GetWindow<UIMainMenuWindow>()) : ((object)LazyUI.GetWindow<UIGamePauseWindow>()));
				LazyButton button = (inTitleMenu ? _titleButton : _pauseButton);
				val = LazyUI.GetWindow<UIGameSettingsWindow>();
				menu.Close();
				val.onClosed = delegate
				{
					menu.Open((LazyWidgetDataBase)null);
					GamepadNavigationController component = ((Component)menu).GetComponent<GamepadNavigationController>();
					component.ReinitItems(false, (List<GamepadNavigationItem>)null, (GamepadNavigationItem)null);
					component.SetFocusedItem(((Component)button).GetComponent<GamepadNavigationItem>());
				};
				((LazyWindow<LazyWidgetDataBase>)(object)val).Open((LazyWidgetDataBase)null);
				if (_panel == null || !_panel.IsHost(val))
				{
					_panel?.Destroy();
					_panel = ModSettingsPanel.Create(val, button);
				}
				_panel.Show();
			}
			catch (Exception arg)
			{
				ManualLogSource log = ModSettingsMenu.Log;
				if (log != null)
				{
					log.LogError((object)$"Failed to open mod settings: {arg}");
				}
				if ((Object)(object)val != (Object)null && ((LazyWindow<LazyWidgetDataBase>)(object)val).IsShown)
				{
					((LazyWindow<LazyWidgetDataBase>)(object)val).Close();
				}
			}
		}
	}
	internal sealed class ModSettingsPanel
	{
		private readonly UIGameSettingsWindow _settings;

		private readonly GameObject _nativeContent;

		private readonly GameObject _panel;

		private readonly RectTransform _content;

		private readonly ScrollRect _modScroll;

		private readonly ScrollRect _optionScroll;

		private readonly GamepadNavigationController _navigation;

		private readonly LazyButton _buttonTemplate;

		private readonly LazyButton _listButtonTemplate;

		private readonly GameObject _captureBlock;

		private readonly Sprite _idleSprite;

		private readonly Color _idleColor;

		private readonly Sprite _selectedSprite;

		private readonly Color _selectedColor;

		private readonly LazyButton _backButton;

		private readonly LazyButton _resetButton;

		private readonly TMP_Text _resetLabel;

		private readonly KeybindEditor _keybindCapture;

		private readonly ConfigRows _rows;

		private readonly List<LazyButton> _buttons = new List<LazyButton>();

		private readonly List<GamepadNavigationItem> _items = new List<GamepadNavigationItem>();

		private IReadOnlyList<ModConfig> _mods = Array.Empty<ModConfig>();

		private string _selectedGuid;

		private bool _contentState;

		private bool _shown;

		private bool _refresh;

		private bool _built;

		private Vector2 _size;

		private int _lastColumn = 1;

		private int _editingFrame = -10;

		private EventSystem _events;

		private bool _navigationEvents;

		private GamepadNavigationItem _focused;

		public LazyWindowInputController InputController { get; }

		public bool IsShown => _shown;

		private ModSettingsPanel(UIGameSettingsWindow settings, LazyButton button)
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: 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_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Expected O, but got Unknown
			//IL_030d: 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_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Expected O, but got Unknown
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Expected O, but got Unknown
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Expected O, but got Unknown
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_071e: Unknown result type (might be due to invalid IL or missing references)
			_settings = settings;
			_nativeContent = ((Component)((Component)settings).transform.Find("GenericWIndowLayout")).gameObject;
			_navigation = ((Component)settings).GetComponent<GamepadNavigationController>();
			InputController = NativeUi.Get<LazyWindowInputController>(settings, "lazyWindowInputController");
			GameObject gameObject = ((Component)NativeUi.Rect("Mod Settings Templates", ((Component)settings).transform)).gameObject;
			gameObject.SetActive(false);
			try
			{
				_panel = NativeUi.Clone(_nativeContent, gameObject.transform, "Mod Settings Panel");
				_panel.SetActive(false);
				_panel.transform.SetParent(((Component)settings).transform, false);
				_content = (RectTransform)_panel.transform.Find("Content");
				NativeUi.ClearLayout((Transform)(object)_content);
				Object.DestroyImmediate((Object)(object)((Component)_content).GetComponent<VerticalLayoutGroup>());
				Object.DestroyImmediate((Object)(object)((Component)_content).GetComponent<ContentSizeFitter>());
				((Component)_content).GetComponent<LayoutElement>().minHeight = 0f;
				((Component)_panel.transform.Find("Frame/HeaderGroup/CloseButton")).gameObject.SetActive(false);
				((Component)_panel.transform.Find("Frame/ButtonTipsStr")).gameObject.SetActive(false);
				RectTransform val = NativeUi.Rect("Templates", _panel.transform);
				((Component)val).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
				((Component)val).gameObject.SetActive(false);
				_buttonTemplate = NativeUi.CloneButton(button, (Transform)(object)val, "Button");
				GameObject val2 = NativeUi.Clone(((Component)NativeUi.Get<UISlider>(settings, "masterVolumeSlider")).gameObject, (Transform)(object)val, "Slider Row");
				Object.DestroyImmediate((Object)(object)val2.GetComponent<UISlider>());
				GameObject val3 = NativeUi.Clone(((Component)NativeUi.Get<UISwitchButton>(settings, "fullscreenButton")).gameObject, (Transform)(object)val, "Switch Row");
				Object.DestroyImmediate((Object)(object)val3.GetComponent<UISwitchButton>());