Decompiled source of ModSettingsMenu v1.1.3

BepInEx/plugins/ModSettingsMenu.dll

Decompiled 5 days ago
using System;
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.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using Candide;
using Candide.CandideUI;
using Candide.CandideUI.Components;
using Candide.CandideUI.Components.Buttons;
using Candide.CandideUI.Containers;
using Candide.CandideUI.Input;
using Candide.CandideUI.PauseMenuUi;
using Candide.CandideUI.UiInput;
using Candide.CandideUI.Windows;
using Candide.Database;
using Candide.Input;
using Candide.Input.InputManagers;
using Candide.Input.InputManagers.Native;
using Candide.Input.InputProviders.Native;
using Candide.Input.InputProviders.Steam;
using Candide.MainMenu.Ui;
using Candide.Sound;
using Candide.Toolkit;
using Candide.UserSettings;
using CandideCreator.Shared;
using CandideCreator.Shared.Graphics;
using FontStashSharp.RichText;
using HarmonyLib;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using ModSettingsMenu.Api;
using ModSettingsMenu.Metadata;
using ModSettingsMenu.Ui;
using ModSettingsMenu.Update;
using RomesteadLocalizationAPI.Api;
using Shared.Text;
using Steamworks;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mod Settings Menu")]
[assembly: AssemblyDescription("Mod Settings Menu for Romestead by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("Mod Settings Menu")]
[assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("A59CDBF0-FC3E-4DD6-B514-8479E0FC91A6")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyVersion("1.1.3.0")]
[module: RefSafetyRules(11)]
namespace ModSettingsMenu
{
	internal static class I18n
	{
		public static readonly RomesteadLocalizer L = RomesteadLocalization.For("IceBoxStudio.Romestead.ModSettingsMenu");
	}
	[BepInPlugin("IceBoxStudio.Romestead.ModSettingsMenu", "Mod Settings Menu", "1.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class ModSettingsMenu : BasePlugin
	{
		private Harmony _harmony;

		private bool _selfRegistrationSubscribed;

		public static ModSettingsMenu Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		public override void Load()
		{
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			Instance = this;
			Logger = ((BasePlugin)this).Log;
			bool flag = default(bool);
			try
			{
				Logger.LogInfo((object)"=============================================");
				ManualLogSource logger = Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Mod Settings Menu");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" initializing...");
				}
				logger.LogInfo(val);
				ManualLogSource logger2 = Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Author: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Ice Box Studio");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(https://steamcommunity.com/id/ibox666/)");
				}
				logger2.LogInfo(val);
				RegisterLocalization();
				RegisterSelf();
				_harmony = new Harmony("IceBoxStudio.Romestead.ModSettingsMenu");
				_harmony.PatchAll(Assembly.GetExecutingAssembly());
				ManualLogSource logger3 = Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Mod Settings Menu");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" initialized.");
				}
				logger3.LogInfo(val);
				Logger.LogInfo((object)"=============================================");
			}
			catch (Exception ex)
			{
				ManualLogSource logger4 = Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(24, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Mod Settings Menu");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" initialization error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\n");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.StackTrace);
				}
				logger4.LogError(val2);
			}
		}

		private void RegisterSelf()
		{
			if (!_selfRegistrationSubscribed)
			{
				ModSettingsRegistry.RefreshRequested += RegisterSelf;
				_selfRegistrationSubscribed = true;
			}
			ModSettingsRegistry.Register("IceBoxStudio.Romestead.ModSettingsMenu", "Mod Settings Menu", ((BasePlugin)this).Config, new ModSettingsModOptions
			{
				Icon = "cog",
				Version = "1.1.3",
				Author = "Ice Box Studio",
				Description = I18n.L.Text("mod.description", Array.Empty<object>()),
				NexusModsId = 8,
				ThunderstoreTeam = "Ice_Box_Studio_Romestead",
				ThunderstoreModName = "ModSettingsMenu",
				UpdateManifestUrl = "https://cdn.jsdelivr.net/gh/ibox233/MyMod_Version@main/ModSettingsMenu.json",
				HideWhenEmpty = false,
				Order = -100
			});
		}

		private static void RegisterLocalization()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			I18n.L.RegisterJson(Path.Combine(directoryName, "ModSettingsMenu.Localization.json"));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IceBoxStudio.Romestead.ModSettingsMenu";

		public const string PLUGIN_NAME = "Mod Settings Menu";

		public const string PLUGIN_VERSION = "1.1.3";

		public const string PLUGIN_AUTHOR = "Ice Box Studio";

		public const int NEXUS_MODS_ID = 8;

		public const string THUNDERSTORE_TEAM = "Ice_Box_Studio_Romestead";

		public const string THUNDERSTORE_MOD_NAME = "ModSettingsMenu";

		public const string UPDATE_MANIFEST_URL = "https://cdn.jsdelivr.net/gh/ibox233/MyMod_Version@main/ModSettingsMenu.json";
	}
}
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(ClientHandler)
		{
			Timeout = Timeout
		};

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

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

		private static async Task<ModUpdateCheckResult> CheckCoreAsync(string currentVersion, string manifestUrl)
		{
			try
			{
				if (!TryValidateHttpsUri(manifestUrl, out var uri))
				{
					return Failed();
				}
				using (CancellationTokenSource cts = new CancellationTokenSource(Timeout))
				{
					using HttpResponseMessage response = await Client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead, cts.Token).ConfigureAwait(continueOnCapturedContext: false);
					if (response.StatusCode != HttpStatusCode.OK)
					{
						return Failed();
					}
					string contentType = response.Content.Headers.ContentType?.MediaType;
					if (!string.IsNullOrWhiteSpace(contentType) && !contentType.Equals("application/json", StringComparison.OrdinalIgnoreCase) && !contentType.Equals("text/json", StringComparison.OrdinalIgnoreCase) && !contentType.Equals("text/plain", StringComparison.OrdinalIgnoreCase))
					{
						return Failed();
					}
					long? length = response.Content.Headers.ContentLength;
					if (length.HasValue && length.Value > 16384)
					{
						return Failed();
					}
					ModUpdateCheckResult result;
					await using (Stream stream = await response.Content.ReadAsStreamAsync(cts.Token).ConfigureAwait(continueOnCapturedContext: false))
					{
						result = ParseManifest(await ReadLimitedStringAsync(stream, cts.Token).ConfigureAwait(continueOnCapturedContext: false), currentVersion);
					}
					return result;
				}
				IL_048f:
				ModUpdateCheckResult result2;
				return result2;
			}
			catch (OperationCanceledException)
			{
				return Failed();
			}
			catch (Exception ex2)
			{
				Exception ex3 = ex2;
				ManualLogSource logger = ModSettingsMenu.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(21, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Update check failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.Message);
					}
					logger.LogWarning(val);
				}
				return Failed();
			}
		}

		private static ModUpdateCheckResult ParseManifest(string json, string currentVersion)
		{
			using JsonDocument jsonDocument = JsonDocument.Parse(json);
			JsonElement rootElement = jsonDocument.RootElement;
			if (rootElement.ValueKind != JsonValueKind.Object)
			{
				return Failed();
			}
			string text = GetString(rootElement, "version") ?? GetString(rootElement, "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(JsonElement root, string propertyName)
		{
			JsonElement value;
			return (root.TryGetProperty(propertyName, out value) && value.ValueKind == JsonValueKind.String) ? value.GetString() : null;
		}

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

		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();
				return addressBytes[0] == 10 || addressBytes[0] == 127 || addressBytes[0] == 0 || (addressBytes[0] == 169 && addressBytes[1] == 254) || (addressBytes[0] == 172 && addressBytes[1] >= 16 && addressBytes[1] <= 31) || (addressBytes[0] == 192 && addressBytes[1] == 168);
			}
			if (address.AddressFamily == AddressFamily.InterNetworkV6)
			{
				return address.IsIPv6LinkLocal || address.IsIPv6SiteLocal || address.IsIPv6Multicast || address.Equals(IPAddress.IPv6None) || address.Equals(IPAddress.IPv6Any) || address.Equals(IPAddress.IPv6Loopback);
			}
			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>();
			}
			return version.Split(new char[3] { '.', '-', '_' }, StringSplitOptions.RemoveEmptyEntries).Select(delegate(string part)
			{
				string s = new string(part.TakeWhile(char.IsDigit).ToArray());
				int result;
				return int.TryParse(s, 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.Ui
{
	internal sealed class ModConfigEntryEditor : CandideVerticalStackPanel
	{
		private readonly ConfigEntryBase _entry;

		private readonly bool _keybind;

		private object _originalValue;

		public ModConfigEntryEditor(ConfigEntryBase entry, Action onChanged, ModSettingsEntryOptions options = null)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			_entry = entry;
			_keybind = options != null && options.Keybind && ModKeybindValue.IsSupportedType(entry.SettingType);
			_originalValue = entry.BoxedValue;
			((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)3;
			((CandideUiElement)this).Margin = new CandideThickness(0, 0, 0, 7);
			((CandideUiContainerMultipleItems)this).AddChild(CreateHeader(entry, options), false);
			if (_keybind)
			{
				((CandideUiContainerMultipleItems)this).AddChild(CreateKeybindInfo(entry), false);
				return;
			}
			object obj;
			if (!string.IsNullOrWhiteSpace(options?.Description))
			{
				obj = options.Description;
			}
			else
			{
				ConfigDescription description = entry.Description;
				obj = ((description != null) ? description.Description : null);
			}
			string text = (string)obj;
			if (!string.IsNullOrWhiteSpace(text))
			{
				((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)new CandideTextLabel
				{
					Text = text,
					Wrap = true,
					TextStyle = (CandideTextStyle)9,
					Margin = new CandideThickness(0, 1, 0, 3),
					MaxWidth = 290
				}, false);
			}
			((CandideUiContainerMultipleItems)this).AddChild(CreateControl(entry, onChanged, options), false);
		}

		public bool HasChanges()
		{
			if (_keybind)
			{
				return false;
			}
			return !object.Equals(_originalValue, _entry.BoxedValue);
		}

		public void Undo()
		{
			if (!_keybind)
			{
				_entry.BoxedValue = _originalValue;
			}
		}

		private static CandideUiElement CreateHeader(ConfigEntryBase entry, ModSettingsEntryOptions options)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			return (CandideUiElement)new CandideTextLabel
			{
				Text = (string.IsNullOrWhiteSpace(options?.DisplayName) ? entry.Definition.Key : options.DisplayName),
				TextStyle = (CandideTextStyle)0,
				TextColor = Color.White,
				MaxWidth = 300,
				Wrap = true
			};
		}

		private static CandideUiElement CreateControl(ConfigEntryBase entry, Action onChanged, ModSettingsEntryOptions options)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			Type settingType = entry.SettingType;
			if (settingType == typeof(bool))
			{
				CandideCheckboxLabel val = new CandideCheckboxLabel((CheckboxType)1, (int?)210, false)
				{
					Text = I18n.L.Text("entry.bool_label", Array.Empty<object>()),
					Margin = new CandideThickness(0, 2, 0, 0)
				};
				val.Checkbox.IsToggledOn = (bool)entry.BoxedValue;
				val.Checkbox.Toggled += delegate(object _, bool value)
				{
					entry.BoxedValue = value;
					onChanged();
				};
				return (CandideUiElement)(object)val;
			}
			ConfigDescription description = entry.Description;
			if (((description != null) ? description.AcceptableValues : null) != null && TryCreateRangeSliderControl(entry, onChanged, options, out var control))
			{
				return control;
			}
			ConfigDescription description2 = entry.Description;
			if (((description2 != null) ? description2.AcceptableValues : null) != null && TryCreateValueListControl(entry, onChanged, out var control2))
			{
				return control2;
			}
			if (settingType.IsEnum)
			{
				return CreateEnumControl(entry, onChanged);
			}
			if (settingType == typeof(int))
			{
				return CreateIntControl(entry, onChanged);
			}
			if (settingType == typeof(string))
			{
				return CreateTextControl(entry, onChanged, isString: true);
			}
			return CreateTextControl(entry, onChanged, isString: false);
		}

		public void Commit()
		{
			if (!_keybind)
			{
				_originalValue = _entry.BoxedValue;
			}
		}

		private static CandideUiElement CreateKeybindInfo(ConfigEntryBase entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			CandideVerticalStackPanel val = new CandideVerticalStackPanel
			{
				HorizontalAlignment = (HorizontalAlignment)3,
				Margin = new CandideThickness(0, 1, 0, 0)
			};
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideTextLabel
			{
				Text = I18n.L.Text("entry.keybind_configure_hint", Array.Empty<object>()),
				Wrap = true,
				TextStyle = (CandideTextStyle)9,
				TextColor = new Color(255, 224, 161),
				MaxWidth = 290,
				Margin = new CandideThickness(0, 0, 0, 2)
			}, false);
			CandideTextLabel val2 = new CandideTextLabel();
			val2.Text = I18n.L.Text("entry.keybind_current", new object[1] { ModKeybindValue.FromEntry(entry).ToDisplayString() });
			val2.Wrap = true;
			val2.TextStyle = (CandideTextStyle)9;
			((CandideUiElement)val2).MaxWidth = 290;
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val2, false);
			return (CandideUiElement)(object)val;
		}

		private static bool TryCreateValueListControl(ConfigEntryBase entry, Action onChanged, out CandideUiElement control)
		{
			control = null;
			AcceptableValueBase acceptableValues = entry.Description.AcceptableValues;
			if (!(((object)acceptableValues).GetType().GetProperty("AcceptableValues")?.GetValue(acceptableValues) is Array { Length: not 0 } array))
			{
				return false;
			}
			ValueSpinnerValue<object>[] array2 = new ValueSpinnerValue<object>[array.Length];
			object boxedValue = entry.BoxedValue;
			ValueSpinnerValue<object> val = null;
			for (int i = 0; i < array.Length; i++)
			{
				object value = array.GetValue(i);
				ValueSpinnerValue<object> val2 = (array2[i] = new ValueSpinnerValue<object>
				{
					Value = value,
					Name = (value?.ToString() ?? string.Empty)
				});
				if (object.Equals(value, boxedValue))
				{
					val = val2;
				}
			}
			CandideValueSpinner<object> obj = new CandideValueSpinner<object>((IReadOnlyCollection<ValueSpinnerValue<object>>)(object)array2);
			((CandideUiElement)obj).Width = 180;
			obj.OnClickLeftOrRightSoundEvent = "event:/interface/main menu/ui_mainmenu_click";
			CandideValueSpinner<object> val3 = obj;
			if (val != null)
			{
				val3.Value = val;
			}
			val3.OnValueChanged += delegate(object _, ValueSpinnerValue<object> val4)
			{
				entry.BoxedValue = val4.Value;
				onChanged();
			};
			control = (CandideUiElement)(object)val3;
			return true;
		}

		private static bool TryCreateRangeSliderControl(ConfigEntryBase entry, Action onChanged, ModSettingsEntryOptions options, out CandideUiElement control)
		{
			//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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Expected O, but got Unknown
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Expected O, but got Unknown
			control = null;
			AcceptableValueBase acceptableValues = entry.Description.AcceptableValues;
			if (acceptableValues == null || !((object)acceptableValues).GetType().IsGenericType || ((object)acceptableValues).GetType().GetGenericTypeDefinition() != typeof(AcceptableValueRange<>))
			{
				return false;
			}
			Type settingType = entry.SettingType;
			if (!IsSupportedSliderRangeType(settingType))
			{
				return false;
			}
			if (!TryGetDouble(((object)acceptableValues).GetType().GetProperty("MinValue")?.GetValue(acceptableValues), out var min) || !TryGetDouble(((object)acceptableValues).GetType().GetProperty("MaxValue")?.GetValue(acceptableValues), out var max) || !TryGetDouble(entry.BoxedValue, out var result) || max <= min)
			{
				return false;
			}
			CandideGrid val = new CandideGrid
			{
				ColumnsProportions = { Proportion.Auto },
				ColumnsProportions = { Proportion.Auto },
				HorizontalAlignment = (HorizontalAlignment)0,
				Margin = new CandideThickness(0, 2, 0, 0)
			};
			double step = GetRangeStep(settingType, min, max, options);
			result = SnapRangeValue(result, min, max, step);
			object value = ConvertRangeValue(result, settingType);
			float sliderStepCount = GetSliderStepCount(min, max, step);
			CandideHorizontalSlider val2 = new CandideHorizontalSlider
			{
				Minimum = 0f,
				Maximum = sliderStepCount,
				StepValue = 1f,
				Value = GetSliderStepIndex(result, min, max, step, sliderStepCount),
				Width = 210
			};
			HorizontalBar val3 = new HorizontalBar
			{
				GridColumn = 0
			};
			((CandideUiContainerSingleItem)val3).SetChild((CandideUiElement)(object)val2);
			CandideTextLabel valueText = new CandideTextLabel
			{
				Text = FormatRangeValue(value, settingType),
				GridColumn = 1,
				Width = 70,
				TextAlign = (TextHorizontalAlignment)2,
				VerticalAlignment = (VerticalAlignment)1,
				Margin = new CandideThickness(6, 0, 0, 0)
			};
			val2.ValueChangedByUser += delegate(object _, float sliderValue)
			{
				object rangeValue = GetRangeValue(sliderValue, min, max, step, sliderStepCount, settingType);
				entry.BoxedValue = rangeValue;
				valueText.Text = FormatRangeValue(rangeValue, settingType);
				onChanged();
			};
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val3, false);
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)valueText, false);
			control = (CandideUiElement)(object)val;
			return true;
		}

		private static double GetRangeStep(Type settingType, double min, double max, ModSettingsEntryOptions options)
		{
			double? num = options?.SliderStep;
			if (num.HasValue)
			{
				double valueOrDefault = num.GetValueOrDefault();
				if (valueOrDefault > 0.0)
				{
					return Math.Min(valueOrDefault, max - min);
				}
			}
			return IsIntegerType(settingType) ? 1.0 : 0.1;
		}

		private static float GetSliderStepCount(double min, double max, double step)
		{
			if (step <= 0.0 || max <= min)
			{
				return 1f;
			}
			double num = (max - min) / step;
			double num2 = Math.Round(num);
			double num3 = ((Math.Abs(num - num2) < 1E-06) ? num2 : Math.Ceiling(num));
			if (num3 < 1.0)
			{
				return 1f;
			}
			if (num3 > 3.4028234663852886E+38)
			{
				return float.MaxValue;
			}
			return (float)num3;
		}

		private static float GetSliderStepIndex(double value, double min, double max, double step, float sliderStepCount)
		{
			if (step <= 0.0 || sliderStepCount <= 0f)
			{
				return 0f;
			}
			if (value >= max)
			{
				return sliderStepCount;
			}
			double num = Math.Round((value - min) / step);
			if (num < 0.0)
			{
				return 0f;
			}
			if (num > (double)sliderStepCount)
			{
				return sliderStepCount;
			}
			return (float)num;
		}

		private static object GetRangeValue(float sliderValue, double min, double max, double step, float sliderStepCount, Type settingType)
		{
			double value = ((sliderValue >= sliderStepCount) ? max : (min + step * (double)sliderValue));
			value = SnapRangeValue(value, min, max, step);
			return ConvertRangeValue(value, settingType);
		}

		private static object ConvertRangeValue(double value, Type settingType)
		{
			if (settingType == typeof(int))
			{
				return (int)Math.Round(value);
			}
			if (settingType == typeof(long))
			{
				return (long)Math.Round(value);
			}
			if (settingType == typeof(short))
			{
				return (short)Math.Round(value);
			}
			if (settingType == typeof(byte))
			{
				return (byte)Math.Round(value);
			}
			if (settingType == typeof(float))
			{
				return (float)value;
			}
			if (settingType == typeof(double))
			{
				return value;
			}
			if (settingType == typeof(decimal))
			{
				return (decimal)value;
			}
			return value;
		}

		private static double SnapRangeValue(double value, double min, double max, double step)
		{
			if (value <= min)
			{
				return min;
			}
			if (value >= max)
			{
				return max;
			}
			if (step > 0.0)
			{
				value = min + Math.Round((value - min) / step) * step;
			}
			if (value < min)
			{
				value = min;
			}
			if (value > max)
			{
				value = max;
			}
			return value;
		}

		private static bool TryGetDouble(object value, out double result)
		{
			try
			{
				result = Convert.ToDouble(value, CultureInfo.InvariantCulture);
				return true;
			}
			catch
			{
				result = 0.0;
				return false;
			}
		}

		private static bool IsSupportedSliderRangeType(Type type)
		{
			return IsIntegerType(type) || type == typeof(float) || type == typeof(double) || type == typeof(decimal);
		}

		private static bool IsIntegerType(Type type)
		{
			return type == typeof(int) || type == typeof(long) || type == typeof(short) || type == typeof(byte);
		}

		private static string FormatRangeValue(object value, Type settingType)
		{
			if (IsIntegerType(settingType))
			{
				return Convert.ToInt64(value, CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture);
			}
			return Convert.ToDouble(value, CultureInfo.InvariantCulture).ToString("G5", CultureInfo.InvariantCulture);
		}

		private static CandideUiElement CreateEnumControl(ConfigEntryBase entry, Action onChanged)
		{
			Array values = Enum.GetValues(entry.SettingType);
			ValueSpinnerValue<object>[] array = new ValueSpinnerValue<object>[values.Length];
			object boxedValue = entry.BoxedValue;
			ValueSpinnerValue<object> val = null;
			for (int i = 0; i < values.Length; i++)
			{
				object value = values.GetValue(i);
				ValueSpinnerValue<object> val2 = (array[i] = new ValueSpinnerValue<object>
				{
					Value = value,
					Name = value.ToString()
				});
				if (object.Equals(value, boxedValue))
				{
					val = val2;
				}
			}
			CandideValueSpinner<object> obj = new CandideValueSpinner<object>((IReadOnlyCollection<ValueSpinnerValue<object>>)(object)array);
			((CandideUiElement)obj).Width = 180;
			obj.OnClickLeftOrRightSoundEvent = "event:/interface/main menu/ui_mainmenu_click";
			CandideValueSpinner<object> val3 = obj;
			if (val != null)
			{
				val3.Value = val;
			}
			val3.OnValueChanged += delegate(object _, ValueSpinnerValue<object> val4)
			{
				entry.BoxedValue = val4.Value;
				onChanged();
			};
			return (CandideUiElement)(object)val3;
		}

		private static CandideUiElement CreateIntControl(ConfigEntryBase entry, Action onChanged)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			CandideIntSpinnerLabel val = new CandideIntSpinnerLabel
			{
				Text = "",
				Margin = new CandideThickness(0, 2, 0, 0)
			};
			val.IntSpinner.AllowPlayerInput = true;
			val.IntSpinner.Value = (int)entry.BoxedValue;
			val.IntSpinner.ValueChangedByUser += delegate(object _, int value)
			{
				entry.BoxedValue = value;
				onChanged();
			};
			return (CandideUiElement)(object)val;
		}

		private static CandideUiElement CreateTextControl(ConfigEntryBase entry, Action onChanged, bool isString)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0128: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			CandideGrid val = new CandideGrid
			{
				ColumnsProportions = { Proportion.Fill },
				ColumnsProportions = { Proportion.Auto },
				HorizontalAlignment = (HorizontalAlignment)3,
				MaxWidth = 300,
				Margin = new CandideThickness(0, 2, 0, 0)
			};
			CandideTextInputBox input = new CandideTextInputBox
			{
				Text = (isString ? (((string)entry.BoxedValue) ?? string.Empty) : entry.GetSerializedValue()),
				SelectAllWhenSelected = true,
				Width = 220,
				Height = 18,
				Padding = new CandideThickness(4, 2),
				Background = new Color(22, 19, 15, 190),
				GridColumn = 0
			};
			input.TextChangedByUser += delegate(object _, ValueChangedEventArgs<string> args)
			{
				if (isString)
				{
					entry.BoxedValue = args.NewValue ?? string.Empty;
				}
				else
				{
					entry.SetSerializedValue(args.NewValue ?? string.Empty);
				}
				onChanged();
			};
			CandideLabelButton val2 = new CandideLabelButton(48, (int?)null)
			{
				Text = I18n.L.Text("entry.reset", Array.Empty<object>()),
				GridColumn = 1,
				Margin = new CandideThickness(5, 0, 0, 0),
				Padding = new CandideThickness(4, 2),
				OnClickedSoundEvent = "event:/interface/navigate"
			};
			((CandideButtonBase)val2).OnClickAction = delegate
			{
				string text = entry.DefaultValue?.ToString() ?? string.Empty;
				input.Text = text;
				if (isString)
				{
					entry.BoxedValue = text;
				}
				else
				{
					entry.SetSerializedValue(text);
				}
				onChanged();
			};
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)input, false);
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val2, false);
			return (CandideUiElement)(object)val;
		}
	}
	internal sealed class ModConfigIconLabel : CandideGrid
	{
		private readonly CandideIcon _builtinIcon;

		private readonly ModIconImage _customIcon;

		private readonly CandideTextLabel _label;

		private bool _hideIcon;

		public string Icon
		{
			get
			{
				return _builtinIcon.Icon;
			}
			set
			{
				_builtinIcon.Icon = value;
				UpdateIconVisibility();
			}
		}

		public string IconPath
		{
			get
			{
				return _customIcon.IconPath;
			}
			set
			{
				_customIcon.IconPath = value;
				UpdateIconVisibility();
			}
		}

		public string Text
		{
			get
			{
				return _label.Text;
			}
			set
			{
				if (!(_label.Text == value))
				{
					_label.Text = value;
					((CandideUiElement)_label).Visible = !string.IsNullOrWhiteSpace(value);
					((CandideUiElement)this).InvalidateMeasure();
				}
			}
		}

		public Color TextColor
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return _label.TextColor;
			}
			set
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				_label.TextColor = value;
			}
		}

		public bool HideIcon
		{
			get
			{
				return _hideIcon;
			}
			set
			{
				_hideIcon = value;
				UpdateIconVisibility();
			}
		}

		public ModConfigIconLabel(IconFlag sizeFlags, bool flipOrientation = false, int? labelWidth = null, bool useTranslationCenteredText = false)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0022: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_0069: 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_00d5: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			_builtinIcon = new CandideIcon(sizeFlags)
			{
				GridColumn = (flipOrientation ? 1 : 0)
			};
			ModIconImage modIconImage = new ModIconImage(sizeFlags);
			((CandideUiElement)modIconImage).GridColumn = (flipOrientation ? 1 : 0);
			((CandideUiElement)modIconImage).Visible = false;
			_customIcon = modIconImage;
			_label = (CandideTextLabel)(useTranslationCenteredText ? new TranslationCenteredTextLayout
			{
				Width = labelWidth,
				Margin = (flipOrientation ? new CandideThickness(0, 0, 4, 0) : new CandideThickness(4, 0, 0, 0)),
				VerticalAlignment = (VerticalAlignment)1,
				TextAlign = (TextHorizontalAlignment)(flipOrientation ? 2 : 0),
				HorizontalAlignment = (HorizontalAlignment)3,
				GridColumn = ((!flipOrientation) ? 1 : 0),
				Visible = false
			} : new CandideTextLabel
			{
				Width = labelWidth,
				Margin = (flipOrientation ? new CandideThickness(0, 0, 4, 0) : new CandideThickness(4, 0, 0, 0)),
				VerticalAlignment = (VerticalAlignment)1,
				TextAlign = (TextHorizontalAlignment)(flipOrientation ? 2 : 0),
				HorizontalAlignment = (HorizontalAlignment)3,
				GridColumn = ((!flipOrientation) ? 1 : 0),
				Visible = false
			});
			if (flipOrientation)
			{
				base.ColumnsProportions.Add(Proportion.Fill);
				base.ColumnsProportions.Add(Proportion.Auto);
				((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_label, false);
				((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_builtinIcon, false);
				((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_customIcon, false);
			}
			else
			{
				base.ColumnsProportions.Add(Proportion.Auto);
				base.ColumnsProportions.Add(Proportion.Fill);
				((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_builtinIcon, false);
				((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_customIcon, false);
				((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_label, false);
			}
		}

		private void UpdateIconVisibility()
		{
			bool flag = !_hideIcon && _customIcon.HasTexture;
			((CandideUiElement)_customIcon).Visible = flag;
			((CandideUiElement)_builtinIcon).Visible = !_hideIcon && !flag;
			((CandideUiElement)this).InvalidateMeasure();
		}
	}
	internal static class ModConfigInfoBlock
	{
		internal static CandideUiElement Create(ModPluginConfig pluginConfig)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//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_00c3: Expected O, but got Unknown
			ModSettingsRegistration registration = pluginConfig.Registration;
			if (registration == null)
			{
				return null;
			}
			string text = BuildMetaText(registration);
			bool flag = !string.IsNullOrWhiteSpace(registration.Description);
			bool hasValue = registration.NexusModsId.HasValue;
			bool flag2 = HasThunderstoreLink(registration);
			bool flag3 = !string.IsNullOrWhiteSpace(registration.UpdateManifestUrl);
			if (string.IsNullOrWhiteSpace(text) && !flag && !hasValue && !flag2 && !flag3)
			{
				return null;
			}
			CandideVerticalStackPanel val = new CandideVerticalStackPanel
			{
				HorizontalAlignment = (HorizontalAlignment)3,
				Width = 300,
				MaxWidth = 300,
				Margin = new CandideThickness(0, 0, 0, 8)
			};
			CandideUiElement val2 = CreateLinksPanel(registration, hasValue, flag2, flag3);
			if (val2 != null)
			{
				((CandideUiContainerMultipleItems)val).AddChild(val2, false);
			}
			CandideUiElement val3 = CreateInfoPanel(text, registration.Description, flag);
			if (val3 != null)
			{
				((CandideUiContainerMultipleItems)val).AddChild(val3, false);
			}
			return (CandideUiElement)(object)val;
		}

		internal static string GetNexusModsUrl(int nexusModsId)
		{
			return (nexusModsId > 0) ? ("https://www.nexusmods.com/romestead/mods/" + nexusModsId) : null;
		}

		private static bool HasThunderstoreLink(ModSettingsRegistration registration)
		{
			return !string.IsNullOrWhiteSpace(registration.ThunderstoreTeam) && !string.IsNullOrWhiteSpace(registration.ThunderstoreModName);
		}

		private static CandideUiElement CreateInfoPanel(string meta, string description, bool hasDescription)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_010c: Expected O, but got Unknown
			if (string.IsNullOrWhiteSpace(meta) && !hasDescription)
			{
				return null;
			}
			CandideVerticalStackPanel val = new CandideVerticalStackPanel
			{
				HorizontalAlignment = (HorizontalAlignment)3,
				Width = 300,
				MaxWidth = 300,
				Padding = new CandideThickness(7, 6),
				Margin = new CandideThickness(0, 4, 0, 0),
				Background = new Color(26, 18, 12, 190)
			};
			if (!string.IsNullOrWhiteSpace(meta))
			{
				((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)CreateMetaLabel(meta, 286), false);
			}
			if (hasDescription)
			{
				((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideTextLabel
				{
					Text = description,
					TextStyle = (CandideTextStyle)9,
					TextColor = Color.White,
					Wrap = true,
					MaxWidth = 286,
					Margin = new CandideThickness(0, (!string.IsNullOrWhiteSpace(meta)) ? 4 : 0, 0, 0)
				}, false);
			}
			return (CandideUiElement)(object)val;
		}

		private static CandideTextLabel CreateMetaLabel(string meta, int maxWidth)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			return new CandideTextLabel
			{
				Text = meta,
				TextStyle = (CandideTextStyle)9,
				TextColor = new Color(226, 207, 177),
				AutoEllipsisMethod = (AutoEllipsisMethod)1,
				MaxWidth = maxWidth
			};
		}

		private static CandideUiElement CreateLinksPanel(ModSettingsRegistration registration, bool hasNexusModsLink, bool hasThunderstoreLink, bool hasUpdateCheck)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			if (!hasNexusModsLink && !hasThunderstoreLink && !hasUpdateCheck)
			{
				return null;
			}
			CandideHorizontalStackPanel val = new CandideHorizontalStackPanel
			{
				HorizontalAlignment = (HorizontalAlignment)3,
				Width = 300,
				MaxWidth = 300,
				Padding = new CandideThickness(7, 6),
				Background = new Color(26, 18, 12, 190)
			};
			if (hasNexusModsLink)
			{
				((CandideUiContainerMultipleItems)val).AddChild(CreateTextLink(I18n.L.Text("button.nexusmods", Array.Empty<object>()), GetNexusModsUrl(registration.NexusModsId.Value), 76), false);
			}
			if (hasThunderstoreLink)
			{
				((CandideUiContainerMultipleItems)val).AddChild(CreateTextLink(I18n.L.Text("button.thunderstore", Array.Empty<object>()), ModSettingsRegistry.GetThunderstoreUrl(registration.ThunderstoreTeam, registration.ThunderstoreModName), 112), false);
			}
			if (hasUpdateCheck)
			{
				ModUpdateStatusLabel modUpdateStatusLabel = new ModUpdateStatusLabel(registration);
				((CandideUiElement)modUpdateStatusLabel).HorizontalAlignment = (HorizontalAlignment)2;
				((CandideUiElement)modUpdateStatusLabel).Margin = new CandideThickness(0, 0, 0, 0);
				((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)modUpdateStatusLabel, false);
			}
			return (CandideUiElement)(object)val;
		}

		private static CandideUiElement CreateTextLink(string text, string url, int maxWidth)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			CandideTextLabel val = new CandideTextLabel
			{
				Text = text,
				TextStyle = (CandideTextStyle)9,
				TextColor = new Color(226, 207, 177),
				TextAlign = (TextHorizontalAlignment)2,
				HorizontalAlignment = (HorizontalAlignment)2,
				AutoEllipsisMethod = (AutoEllipsisMethod)1,
				MaxWidth = maxWidth,
				Margin = new CandideThickness(0, 0, 6, 0),
				OnClickedSoundEvent = "event:/interface/navigate"
			};
			((CandideUiElement)val).Clicked += delegate
			{
				UrlHelper.OpenUrl(url, false);
			};
			return (CandideUiElement)(object)val;
		}

		private static string BuildMetaText(ModSettingsRegistration registration)
		{
			if (!string.IsNullOrWhiteSpace(registration.Version) && !string.IsNullOrWhiteSpace(registration.Author))
			{
				return registration.Version + " - " + registration.Author;
			}
			if (!string.IsNullOrWhiteSpace(registration.Version))
			{
				return registration.Version;
			}
			return string.IsNullOrWhiteSpace(registration.Author) ? null : registration.Author;
		}
	}
	internal sealed class ModConfigListItem : CandideListBase
	{
		private readonly ModConfigIconLabel _iconLabel;

		public string Icon
		{
			get
			{
				return _iconLabel.Icon;
			}
			set
			{
				_iconLabel.Icon = value;
			}
		}

		public string IconPath
		{
			get
			{
				return _iconLabel.IconPath;
			}
			set
			{
				_iconLabel.IconPath = value;
			}
		}

		public string Text
		{
			get
			{
				return _iconLabel.Text;
			}
			set
			{
				_iconLabel.Text = value;
			}
		}

		public Color TextColor
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return _iconLabel.TextColor;
			}
			set
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				_iconLabel.TextColor = value;
			}
		}

		public ModConfigListItem(string iconId, string iconPath, IconFlag sizeFlag, int labelWidth)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			((CandideUiElement)this).Padding = new CandideThickness(2, 2, 6, 3);
			((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)3;
			((CandideToggleButton)this).LockWhenToggledOn = true;
			CandidePanel val = new CandidePanel
			{
				HorizontalAlignment = (HorizontalAlignment)3
			};
			_iconLabel = new ModConfigIconLabel(sizeFlag, flipOrientation: false, labelWidth, useTranslationCenteredText: true)
			{
				Icon = iconId,
				IconPath = iconPath
			};
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_iconLabel, false);
			((CandideUiContainerSingleItem)this).SetChild((CandideUiElement)(object)val);
		}
	}
	internal sealed class ModConfigPanel : CandideUiContainerSingleItem, ISettingsCategoryUi
	{
		private readonly ModConfigIconLabel _titleIconLabel;

		private readonly CandidePanelSingleChild _contentPanel;

		private readonly CandideHorizontalStackPanel _buttonPanel;

		private readonly YesButton _yesButton;

		private readonly NoIconLabelButton _noButton;

		private readonly List<ModConfigEntryEditor> _editors;

		private ConfigFile _currentConfigFile;

		private ModPluginConfig _currentPluginConfig;

		private bool _currentConfigFileOriginalSaveOnConfigSet;

		private bool _hasCurrentConfigFileOriginalSaveOnConfigSet;

		public string CurrentPluginGuid => _currentPluginConfig?.Guid;

		public ModConfigPanel()
		{
			//IL_002c: 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_0078: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0140: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01a4: 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_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_0245: 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_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			ModConfigIconLabel obj = new ModConfigIconLabel((IconFlag)1)
			{
				Text = "Mod Settings",
				Icon = "cog"
			};
			((CandideUiElement)obj).Padding = new CandideThickness(6);
			((CandideUiElement)obj).HorizontalAlignment = (HorizontalAlignment)3;
			((CandideUiElement)obj).Margin = new CandideThickness(6, 0, 0, 12);
			_titleIconLabel = obj;
			_editors = new List<ModConfigEntryEditor>();
			((CandideUiContainerSingleItem)this)..ctor();
			((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)3;
			((CandideUiElement)this).VerticalAlignment = (VerticalAlignment)3;
			CandideGrid val = new CandideGrid
			{
				RowsProportions = { Proportion.Auto },
				RowsProportions = { Proportion.Fill },
				RowsProportions = { Proportion.Auto },
				RowsProportions = { Proportion.Auto },
				ColumnsProportions = { Proportion.Fill },
				VerticalAlignment = (VerticalAlignment)3,
				HorizontalAlignment = (HorizontalAlignment)3
			};
			_contentPanel = new CandidePanelSingleChild
			{
				Padding = new CandideThickness(8, 0, 0, 0),
				GridRow = 1,
				HorizontalAlignment = (HorizontalAlignment)3
			};
			_buttonPanel = new CandideHorizontalStackPanel
			{
				GridRow = 3,
				Padding = new CandideThickness(8, 8, 0, 0),
				HorizontalAlignment = (HorizontalAlignment)1,
				ControllerUseDefaultNavigation = true
			};
			_yesButton = new YesButton(60)
			{
				StringId = StringId.op_Implicit("Ui_Apply"),
				OnClickAction = Save,
				OnClickedSoundEvent = "event:/interface/navigate",
				Enabled = false,
				Margin = new CandideThickness(3, 0, 3, 3),
				Padding = new CandideThickness(6, 4)
			};
			_noButton = new NoIconLabelButton(60)
			{
				StringId = StringId.op_Implicit("Ui_Cancel"),
				OnClickAction = Reset,
				OnClickedSoundEvent = "event:/interface/navigate",
				Enabled = false,
				Margin = new CandideThickness(3, 0, 3, 3),
				Padding = new CandideThickness(6, 4)
			};
			((CandideUiContainerMultipleItems)_buttonPanel).AddChild((CandideUiElement)(object)_yesButton, false);
			((CandideUiContainerMultipleItems)_buttonPanel).AddChild((CandideUiElement)(object)_noButton, false);
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_titleIconLabel, false);
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_contentPanel, false);
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideHorizontalSeparator
			{
				HorizontalAlignment = (HorizontalAlignment)3,
				GridRow = 2,
				Padding = new CandideThickness(0, 1, 0, 0)
			}, false);
			((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_buttonPanel, false);
			((CandideUiContainerSingleItem)this).SetChild((CandideUiElement)(object)val);
		}

		public void ShowPlugin(ModPluginConfig pluginConfig)
		{
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: 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_02cc: Expected O, but got Unknown
			//IL_0253: 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_0260: 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_0276: Expected O, but got Unknown
			ConfigFile configFile = pluginConfig.ConfigFile;
			if (_currentConfigFile != null && _currentConfigFile != configFile)
			{
				EndEditing(undo: true);
			}
			BeginEditing(configFile);
			_currentPluginConfig = pluginConfig;
			_editors.Clear();
			_titleIconLabel.Text = pluginConfig.Name;
			_titleIconLabel.Icon = pluginConfig.Icon;
			_titleIconLabel.IconPath = pluginConfig.IconPath;
			((CandideUiElement)_buttonPanel).Visible = true;
			ConfigEntryBase[] array = (from entry in configFile.Values
				where !ModSettingsMetadataResolver.IsEntryHidden(pluginConfig, entry)
				orderby ModSettingsMetadataResolver.GetSectionOrder(pluginConfig, entry.Definition.Section), ModSettingsMetadataResolver.GetEntryOrder(pluginConfig, entry), entry.Definition.Section, entry.Definition.Key
				select entry).ToArray();
			CandideVerticalStackPanel val = new CandideVerticalStackPanel
			{
				HorizontalAlignment = (HorizontalAlignment)3,
				MaxWidth = 306
			};
			CandideUiElement val2 = ModConfigInfoBlock.Create(pluginConfig);
			if (val2 != null)
			{
				((CandideUiContainerMultipleItems)val).AddChild(val2, false);
			}
			if (array.Length == 0)
			{
				((CandideUiElement)_buttonPanel).Visible = false;
				((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideTextLabel
				{
					Text = I18n.L.Text("panel.no_public_entries", Array.Empty<object>()),
					Wrap = true,
					TextStyle = (CandideTextStyle)9,
					MaxWidth = 290,
					HorizontalAlignment = (HorizontalAlignment)3,
					Margin = new CandideThickness(0, 4, 0, 0)
				}, false);
				((CandideUiContainerSingleItem)_contentPanel).SetChild((CandideUiElement)(object)CreateScroll((CandideUiElement)(object)val));
				return;
			}
			string text = null;
			ConfigEntryBase[] array2 = array;
			foreach (ConfigEntryBase val3 in array2)
			{
				if (text != val3.Definition.Section)
				{
					if (text != null)
					{
						((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideHorizontalSeparator
						{
							HorizontalAlignment = (HorizontalAlignment)3,
							Margin = new CandideThickness(0, 3, 0, 6)
						}, false);
					}
					((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideTextLabel
					{
						Text = ModSettingsMetadataResolver.GetSectionDisplayName(pluginConfig, val3.Definition.Section),
						TextColor = new Color(255, 224, 161),
						Margin = new CandideThickness(0, 0, 0, 4)
					}, false);
					text = val3.Definition.Section;
				}
				ModConfigEntryEditor modConfigEntryEditor = new ModConfigEntryEditor(val3, UpdateButtons, ModSettingsMetadataResolver.GetEntryOptions(pluginConfig, val3));
				_editors.Add(modConfigEntryEditor);
				((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)modConfigEntryEditor, false);
			}
			((CandideUiContainerSingleItem)_contentPanel).SetChild((CandideUiElement)(object)CreateScroll((CandideUiElement)(object)val));
			UpdateButtons();
		}

		public bool HasChanges()
		{
			return _editors.Any((ModConfigEntryEditor editor) => editor.HasChanges());
		}

		public void Undo()
		{
			Reset();
		}

		public void UserSave()
		{
			Save();
		}

		public override void Update(GameTime gameTime)
		{
			((CandideUiContainerSingleItem)this).Update(gameTime);
			if (_currentPluginConfig == null)
			{
				_titleIconLabel.Text = I18n.L.Text("panel.title", Array.Empty<object>());
				_titleIconLabel.Icon = "cog";
				_titleIconLabel.IconPath = null;
			}
			UpdateButtons();
		}

		private void Save()
		{
			ConfigFile currentConfigFile = _currentConfigFile;
			if (currentConfigFile != null)
			{
				currentConfigFile.Save();
			}
			foreach (ModConfigEntryEditor editor in _editors)
			{
				editor.Commit();
			}
			((CandideUiElement)_yesButton).Enabled = false;
			((CandideUiElement)_noButton).Enabled = false;
		}

		private void Reset()
		{
			UndoEditors();
			if (_currentConfigFile != null && _currentPluginConfig != null)
			{
				ShowPlugin(_currentPluginConfig);
			}
		}

		private void UpdateButtons()
		{
			bool enabled = HasChanges();
			((CandideUiElement)_yesButton).Enabled = enabled;
			((CandideUiElement)_noButton).Enabled = enabled;
		}

		public void EndEditing(bool undo)
		{
			if (undo)
			{
				UndoEditors();
			}
			RestoreSaveOnConfigSet();
			_editors.Clear();
			_currentConfigFile = null;
			_currentPluginConfig = null;
		}

		private void BeginEditing(ConfigFile configFile)
		{
			if (_currentConfigFile != configFile)
			{
				_currentConfigFile = configFile;
				_currentConfigFileOriginalSaveOnConfigSet = configFile.SaveOnConfigSet;
				_hasCurrentConfigFileOriginalSaveOnConfigSet = true;
				configFile.SaveOnConfigSet = false;
			}
		}

		private void RestoreSaveOnConfigSet()
		{
			if (_currentConfigFile != null && _hasCurrentConfigFileOriginalSaveOnConfigSet)
			{
				_currentConfigFile.SaveOnConfigSet = _currentConfigFileOriginalSaveOnConfigSet;
				_hasCurrentConfigFileOriginalSaveOnConfigSet = false;
			}
		}

		private void UndoEditors()
		{
			foreach (ModConfigEntryEditor editor in _editors)
			{
				editor.Undo();
			}
		}

		private static CandideVerticalScrollViewer CreateScroll(CandideUiElement child)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			CandideVerticalScrollViewer val = new CandideVerticalScrollViewer
			{
				Width = 316,
				Height = 340,
				ShowVerticalScrollBar = true
			};
			((CandideUiContainerSingleItem)val).SetChild(child);
			return val;
		}
	}
	internal sealed class ModConfigWindow : CandideExtendedCustomGraphicsWindow
	{
		private readonly CandideGrid _panel = new CandideGrid
		{
			HorizontalAlignment = (HorizontalAlignment)3,
			VerticalAlignment = (VerticalAlignment)3,
			Padding = new CandideThickness(5),
			DefaultColumnProportion = Proportion.Auto
		};

		private readonly CandideListView _listView = new CandideListView
		{
			Width = 109,
			Height = 438,
			Padding = new CandideThickness(0, 6),
			GridColumn = 0,
			ShowVerticalScrollBar = false,
			ControllerAutoSelectHovered = false
		};

		private readonly ModConfigPanel _settingsPanel;

		private readonly Action _onBack;

		private readonly ModMenuContext _context;

		private readonly CandideIconLabelButton _backButton;

		private readonly Dictionary<string, ModConfigListItem> _listItemsByGuid;

		private bool _isInitialized;

		private string _lastLocale;

		public ModConfigWindow(Action onBack, ModMenuContext context)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			ModConfigPanel modConfigPanel = new ModConfigPanel();
			((CandideUiElement)modConfigPanel).Width = 336;
			((CandideUiElement)modConfigPanel).Height = 438;
			((CandideUiElement)modConfigPanel).GridColumn = 1;
			((CandideUiElement)modConfigPanel).Padding = new CandideThickness(10, 0, 0, 0);
			_settingsPanel = modConfigPanel;
			_listItemsByGuid = new Dictionary<string, ModConfigListItem>(StringComparer.OrdinalIgnoreCase);
			((CandideExtendedCustomGraphicsWindow)this)..ctor(new CustomBackgroundArgs
			{
				SpriteSheet = Content.SpriteSheet("media/interface/new_ui_parts/ui_pause_menu")
			});
			_onBack = onBack;
			_context = context;
			SoundPlayer.PlayEventOneShot("event:/interface/open_window", 1f, 1f);
			base.ExitButton.OnClickAction = ((CandideWindow)this).Close;
			((CandideWindow)this).Closing += delegate
			{
				_settingsPanel.EndEditing(undo: true);
			};
			((CandideWindow)this).Closed += delegate
			{
				SoundPlayer.PlayEventOneShot("event:/interface/close_window", 1f, 1f);
				_onBack?.Invoke();
			};
			_backButton = new CandideIconLabelButton("arrow:left", (IconFlag)1, (int?)69)
			{
				StringId = StringId.op_Implicit("Ui_Back"),
				OnClickAction = ((CandideWindow)this).Close,
				Margin = new CandideThickness(1, 0, 1, 2),
				HorizontalAlignment = (HorizontalAlignment)0,
				VerticalAlignment = (VerticalAlignment)2
			};
			RebuildPanelChildren();
			((CandideUiContainerSingleItem)this).SetChild((CandideUiElement)(object)_panel);
			BuildUi();
			_lastLocale = I18n.L.CurrentLocale;
		}

		private void BuildUi()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			ModSettingsRegistry.RequestRefresh();
			_listView.ClearAllItems();
			_listItemsByGuid.Clear();
			CandideThickness padding = default(CandideThickness);
			((CandideThickness)(ref padding))..ctor(2, 2, 6, 3);
			CandideThickness margin = default(CandideThickness);
			((CandideThickness)(ref margin))..ctor(1, 0, 1, 2);
			_listView.AddNonItem((CandideUiElement)new TranslationCenteredTextLayout(109, 18)
			{
				Text = I18n.L.Text("window.mod_list_title", Array.Empty<object>()),
				TextAlign = (TextHorizontalAlignment)1,
				HorizontalAlignment = (HorizontalAlignment)3,
				Margin = new CandideThickness(0, 0, 0, 4)
			});
			ModPluginConfig[] array = ModPluginConfigSource.GetPluginConfigs(_context).ToArray();
			if (array.Length == 0)
			{
				_listView.AddNonItem((CandideUiElement)new CandideTextLabel
				{
					Text = I18n.L.Text("window.no_configs", Array.Empty<object>()),
					TextAlign = (TextHorizontalAlignment)1,
					HorizontalAlignment = (HorizontalAlignment)3,
					Margin = new CandideThickness(0, 4, 0, 0)
				});
				return;
			}
			ModPluginConfig[] array2 = array;
			foreach (ModPluginConfig config in array2)
			{
				ModConfigListItem obj = new ModConfigListItem(config.Icon, config.IconPath, (IconFlag)0, 92)
				{
					Text = config.Name
				};
				((CandideUiElement)obj).Padding = padding;
				((CandideUiElement)obj).Margin = margin;
				((CandideToggleButton)obj).OnToggledSoundEvent = "event:/interface/main menu/ui_mainmenu_click";
				((CandideToggleButton)obj).OnToggledOnAction = delegate
				{
					_settingsPanel.ShowPlugin(config);
				};
				ModConfigListItem modConfigListItem = obj;
				_listItemsByGuid[config.Guid] = modConfigListItem;
				_listView.AddItem((CandideToggleButton)(object)modConfigListItem, false);
			}
		}

		private void RebuildPanelChildren()
		{
			_panel.ClearChildren();
			((CandideUiContainerMultipleItems)_panel).AddChild((CandideUiElement)(object)_listView, false);
			((CandideUiContainerMultipleItems)_panel).AddChild((CandideUiElement)(object)_settingsPanel, false);
			((CandideUiContainerMultipleItems)_panel).AddChild((CandideUiElement)(object)_backButton, false);
		}

		public override bool OnUiClosePressed()
		{
			if (((CandideUiContainerSingleItem)this).OnUiClosePressed())
			{
				return true;
			}
			((CandideWindow)this).Close();
			return true;
		}

		public override void Update(GameTime gameTime)
		{
			((CandideWindow)this).Update(gameTime);
			if (_lastLocale != I18n.L.CurrentLocale)
			{
				_lastLocale = I18n.L.CurrentLocale;
				string currentPluginGuid = _settingsPanel.CurrentPluginGuid;
				RebuildPanelChildren();
				_isInitialized = false;
				BuildUi();
				if (!string.IsNullOrWhiteSpace(currentPluginGuid) && SelectPlugin(currentPluginGuid))
				{
					_isInitialized = true;
				}
			}
			if (!_isInitialized && _listView.Items.Count > 0)
			{
				_listView.Items[0].IsToggled = true;
				_isInitialized = true;
			}
		}

		private bool SelectPlugin(string pluginGuid)
		{
			if (_listItemsByGuid.TryGetValue(pluginGuid, out var value))
			{
				((CandideToggleButton)value).IsToggled = true;
				return true;
			}
			ModPluginConfig[] source = ModPluginConfigSource.GetPluginConfigs(_context).ToArray();
			ModPluginConfig modPluginConfig = source.FirstOrDefault((ModPluginConfig item) => item.Guid == pluginGuid);
			if (modPluginConfig == null)
			{
				return false;
			}
			_settingsPanel.ShowPlugin(modPluginConfig);
			return true;
		}
	}
	internal sealed class ModIconImage : CandideUiComponent
	{
		private IconFlag _iconFlags;

		private string _iconPath;

		public string IconPath
		{
			get
			{
				return _iconPath;
			}
			set
			{
				if (!(_iconPath == value))
				{
					_iconPath = value;
					((CandideUiElement)this).InvalidateMeasure();
				}
			}
		}

		public IconFlag IconFlags
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _iconFlags;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				_iconFlags = value;
				((CandideUiElement)this).InvalidateMeasure();
			}
		}

		public bool DrawSmooth { get; set; } = true;

		public bool HasTexture => ModIconLoader.TryLoad(_iconPath) != null;

		public ModIconImage(IconFlag iconFlags = (IconFlag)1)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			IconFlags = iconFlags;
		}

		public override void Update(GameTime gameTime)
		{
		}

		protected override void InternalDraw(UiRenderContext context)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = ModIconLoader.TryLoad(_iconPath);
			if (val != null)
			{
				Vector2 iconSizeForFlags = CandideIcon.GetIconSizeForFlags(_iconFlags);
				float num = MathHelper.Min(iconSizeForFlags.X / (float)val.Width, iconSizeForFlags.Y / (float)val.Height);
				Vector2 val2 = new Vector2((float)val.Width, (float)val.Height) * num * (float)CandideUiSystem.Scale;
				Vector2 val3 = iconSizeForFlags * (float)CandideUiSystem.Scale;
				Rectangle actualBounds = ((CandideUiElement)this).ActualBounds;
				Point location = ((Rectangle)(ref actualBounds)).Location;
				Vector2 val4 = ((Point)(ref location)).ToVector2() + (val3 - val2) / 2f;
				TextureFiltering textureFiltering = context.GetTextureFiltering();
				if (DrawSmooth)
				{
					context.SetTextureFiltering((TextureFiltering)1);
				}
				context.DrawSprite(val, (Rectangle?)null, val4, new Vector2(num), 0f);
				context.SetTextureFiltering(textureFiltering);
			}
		}

		protected override Vector2 InternalMeasure(Vector2 availableSize)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			return CandideIcon.GetIconSizeForFlags(_iconFlags) * (float)CandideUiSystem.Scale;
		}
	}
	internal static class ModIconLoader
	{
		private static readonly Dictionary<string, Texture2D> Cache = new Dictionary<string, Texture2D>(StringComparer.OrdinalIgnoreCase);

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

		public static Texture2D TryLoad(string path)
		{
			string text = NormalizePath(path);
			if (string.IsNullOrWhiteSpace(text))
			{
				return null;
			}
			if (Cache.TryGetValue(text, out var value))
			{
				return value;
			}
			if (FailedPaths.Contains(text))
			{
				return null;
			}
			try
			{
				if (Globals.GraphicsDevice == null)
				{
					return null;
				}
				if (!File.Exists(text))
				{
					FailedPaths.Add(text);
					return null;
				}
				using (FileStream fileStream = File.OpenRead(text))
				{
					value = Texture2D.FromStream(Globals.GraphicsDevice, (Stream)fileStream);
				}
				Cache[text] = value;
				return value;
			}
			catch
			{
				FailedPaths.Add(text);
				return null;
			}
		}

		private static string NormalizePath(string path)
		{
			if (string.IsNullOrWhiteSpace(path))
			{
				return null;
			}
			try
			{
				return Path.GetFullPath(path.Trim().Trim('"'));
			}
			catch
			{
				return path.Trim().Trim('"');
			}
		}
	}
	internal sealed class ModPluginConfig
	{
		public string Name { get; set; }

		public string Guid { get; set; }

		public ConfigFile ConfigFile { get; set; }

		public ModSettingsRegistration Registration { get; set; }

		public string Icon => Registration?.Icon ?? "cog";

		public string IconPath => Registration?.IconPath;

		public int Order => Registration?.Order ?? 1000;
	}
	internal enum ModMenuContext
	{
		All,
		MainMenu,
		InGame
	}
	internal static class ModPluginConfigSource
	{
		public static IEnumerable<ModPluginConfig> GetPluginConfigs(ModMenuContext context = ModMenuContext.All)
		{
			NetChainloader chainloader = NetChainloader.Instance;
			if (chainloader == null)
			{
				yield break;
			}
			HashSet<string> registeredGuids = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			foreach (ModSettingsRegistration registration in from item in ModSettingsRegistry.GetRegistrations()
				orderby item.Order, item.DisplayName
				select item)
			{
				registeredGuids.Add(registration.PluginGuid);
				if ((context != ModMenuContext.MainMenu || registration.ShowInMainMenu) && (context != ModMenuContext.InGame || registration.ShowInGame) && (!registration.HideWhenEmpty || registration.ConfigFile.Values.Count != 0))
				{
					yield return new ModPluginConfig
					{
						Name = registration.DisplayName,
						Guid = registration.PluginGuid,
						ConfigFile = registration.ConfigFile,
						Registration = registration
					};
				}
			}
			foreach (PluginInfo plugin in ((BaseChainloader<BasePlugin>)(object)chainloader).Plugins.Values.OrderBy((PluginInfo val) => val.Metadata.Name))
			{
				if (!registeredGuids.Contains(plugin.Metadata.GUID))
				{
					object instance = plugin.Instance;
					BasePlugin instance2 = (BasePlugin)((instance is BasePlugin) ? instance : null);
					if (instance2 != null && instance2.Config != null && instance2.Config.Values.Count != 0)
					{
						yield return new ModPluginConfig
						{
							Name = plugin.Metadata.Name,
							Guid = plugin.Metadata.GUID,
							ConfigFile = instance2.Config
						};
					}
				}
			}
		}
	}
	internal static class ModSettingsIconRegistry
	{
		public const string IconId = "mod_settings_menu:settings";

		private const string ResourceName = "ModSettingsMenu.Assets.mod_settings_icon.png";

		private static bool _registered;

		public static void Register()
		{
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00a0: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if ((_registered && IconDataBase.IconDataMap.ContainsKey("mod_settings_menu:settings")) || Globals.GraphicsDevice == null || Content.DefaultNormalMap == null || Content.DefaultMetalMap == null)
			{
				return;
			}
			try
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ModSettingsMenu.Assets.mod_settings_icon.png");
				if (stream != null)
				{
					Texture2D val = Texture2D.FromStream(Globals.GraphicsDevice, stream);
					((GraphicsResource)val).Name = "mod_settings_menu:settings";
					Icon value = new Icon(new SpriteSheet(val, Content.DefaultNormalMap, Content.DefaultMetalMap, 24, 24, default(Vector2)), 0);
					Dictionary<IconFlag, Icon> variations = new Dictionary<IconFlag, Icon>
					{
						[(IconFlag)1] = value,
						[(IconFlag)9] = value,
						[(IconFlag)17] = value,
						[(IconFlag)33] = value,
						[(IconFlag)25] = value,
						[(IconFlag)36] = value
					};
					IconDataBase.IconDataMap.Remove("mod_settings_menu:settings");
					IconDataBase.AddIcons((IEnumerable<IconData>)(object)new IconData[1]
					{
						new IconData
						{
							Id = "mod_settings_menu:settings",
							Variations = variations
						}
					});
					_registered = true;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = ModSettingsMenu.Logger;
				if (logger != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to register mod settings toolbar icon: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					logger.LogWarning(val2);
				}
			}
		}
	}
	internal sealed class ModUpdateStatusLabel : CandideTextLabel
	{
		private readonly ModSettingsRegistration _registration;

		private ModUpdateCheckStatus _lastStatus;

		private string _lastVersion;

		public ModUpdateStatusLabel(ModSettingsRegistration registration)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			_registration = registration;
			((CandideTextLabel)this).TextStyle = (CandideTextStyle)9;
			base.TextColor = Color.LightGray;
			((CandideTextLabel)this).TextAlign = (TextHorizontalAlignment)2;
			((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)2;
			((CandideTextLabel)this).Wrap = false;
			((CandideUiElement)this).MaxWidth = 78;
			UpdateText(force: true);
		}

		public override void Update(GameTime gameTime)
		{
			((CandideTextLabel)this).Update(gameTime);
			UpdateText(force: false);
		}

		private void UpdateText(bool force)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			ModUpdateCheckResult orStart = ModUpdateChecker.GetOrStart(_registration);
			if (force || _lastStatus != orStart.Status || !(_lastVersion == orStart.LatestVersion))
			{
				_lastStatus = orStart.Status;
				_lastVersion = orStart.LatestVersion;
				base.TextColor = GetStatusColor(orStart.Status);
				((CandideUiElement)this).Visible = orStart.Status == ModUpdateCheckStatus.UpdateAvailable || orStart.Status == ModUpdateCheckStatus.UpToDate || orStart.Status == ModUpdateCheckStatus.Failed;
				((CandideTextLabel)this).Text = GetStatusText(orStart);
			}
		}

		private static string GetStatusText(ModUpdateCheckResult result)
		{
			return result.Status switch
			{
				ModUpdateCheckStatus.UpToDate => I18n.L.Text("update.up_to_date", Array.Empty<object>()), 
				ModUpdateCheckStatus.UpdateAvailable => I18n.L.Text("update.available", new object[1] { result.LatestVersion }), 
				ModUpdateCheckStatus.Failed => I18n.L.Text("update.failed", Array.Empty<object>()), 
				_ => string.Empty, 
			};
		}

		private static Color GetStatusColor(ModUpdateCheckStatus status)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(status switch
			{
				ModUpdateCheckStatus.UpToDate => new Color(104, 205, 112), 
				ModUpdateCheckStatus.UpdateAvailable => new Color(255, 72, 72), 
				ModUpdateCheckStatus.Failed => new Color(196, 170, 132), 
				_ => new Color(226, 207, 177), 
			});
		}
	}
}
namespace ModSettingsMenu.Patches
{
	internal static class ModBindingModal
	{
		internal static readonly ConditionalWeakTable<BindingInputModalWindow, ModBindingModalState> States = new ConditionalWeakTable<BindingInputModalWindow, ModBindingModalState>();

		private static readonly FieldInfo AdditionalProviderField = AccessTools.Field(typeof(InputManager), "_additionalProvider");

		private static readonly FieldInfo SteamActiveControllerField = AccessTools.Field(typeof(SteamInputProvider), "_activeController");

		private static readonly FieldInfo SteamActionLayersField = AccessTools.Field(typeof(SteamInputProvider), "_actionLayers");

		private static readonly FieldInfo SteamAnalogHandlesField = AccessTools.Field(typeof(SteamInputProvider), "_analogHandles");

		private static readonly FieldInfo SteamAnalogStatesField = AccessTools.Field(typeof(SteamInputProvider), "_analogStates");

		private static readonly FieldInfo SteamDigitalStatesField = AccessTools.Field(typeof(SteamInputProvider), "_digitalStates");

		private static readonly FieldInfo SteamDigitalHandlesField = AccessTools.Field(typeof(SteamInputProvider), "_digitalHandles");

		private static readonly FieldInfo SteamActionSetsField = AccessTools.Field(typeof(SteamInputProvider), "_actionSets");

		private static readonly Buttons[] GamepadButtons;

		internal static void Add(BindingInputModalWindow modal, Func<Buttons, bool> onButtonRegistered)
		{
			States.Add(modal, new ModBindingModalState(onButtonRegistered, ReadSteamInput()));
		}

		internal static bool TryGet(BindingInputModalWindow modal, out ModBindingModalState state)
		{
			return States.TryGetValue(modal, out state);
		}

		internal static bool TryPressed(BindingInputModalWindow modal, ModBindingModalState state, GamePadState current, SteamInputState steamInput)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a9: 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_00d5: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			if (state.WaitingForRelease)
			{
				state.PreviousGamePadState = current;
				state.PreviousSteamInput = steamInput;
				if (!AnyGamepadButtonDown(current) && !steamInput.IsAnyDown)
				{
					state.WaitingForRelease = false;
				}
				return false;
			}
			Buttons? button = FindPressedButton(state.Previo