Decompiled source of PluginConfigurator v1.10.3

plugins/PluginConfigurator/PluginConfigurator.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using PluginConfig.Patches;
using PluginConfiguratorComponents;
using SettingsMenu.Components;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PluginConfigurator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Ultrakill mod that makes configuring mods easier")]
[assembly: AssemblyFileVersion("1.10.3.0")]
[assembly: AssemblyInformationalVersion("1.10.3+a2b51aaab3847151ecf25eac50f5a28e401c109b")]
[assembly: AssemblyProduct("PluginConfigurator")]
[assembly: AssemblyTitle("PluginConfigurator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.10.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PluginConfig
{
	public static class NotificationPanel
	{
		private class NotificationPanelComp : MonoBehaviour
		{
			private void OnEnable()
			{
				((Component)this).transform.SetAsLastSibling();
				MonoSingleton<OptionsManager>.Instance.dontUnpause = true;
			}

			private void OnDisable()
			{
				MonoSingleton<OptionsManager>.Instance.dontUnpause = false;
			}
		}

		private class OptionsMenuListener : MonoBehaviour
		{
			private void OnEnable()
			{
				if ((Object)(object)root != (Object)null && currentNotification != null)
				{
					((Component)root).gameObject.SetActive(true);
				}
			}
		}

		public abstract class Notification
		{
			internal bool closed;

			public abstract void OnUI(RectTransform panel);

			public void Close()
			{
				if (!closed)
				{
					closed = true;
					if (this == currentNotification)
					{
						CloseInternal();
					}
				}
			}
		}

		internal static Queue<Notification> notificationQueue = new Queue<Notification>();

		internal static Notification currentNotification = null;

		private static RectTransform root;

		private static Image currentBackground;

		internal static void UpdateBackgroundColor()
		{
			//IL_0013: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)currentBackground == (Object)null))
			{
				Color value = PluginConfiguratorController.notificationPanelBackground.value;
				value.a = PluginConfiguratorController.notificationPanelOpacity.value / 100f;
				((Graphic)currentBackground).color = value;
			}
		}

		internal static void InitUI()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00a8: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root == (Object)null && (Object)(object)PluginConfiguratorController.optionsMenu != (Object)null)
			{
				((Component)PluginConfiguratorController.optionsMenu).gameObject.AddComponent<OptionsMenuListener>();
				root = new GameObject().AddComponent<RectTransform>();
				((Transform)root).SetParent(PluginConfiguratorController.optionsMenu);
				root.anchorMin = new Vector2(0f, 0f);
				root.anchorMax = new Vector2(1f, 1f);
				root.pivot = new Vector2(0f, 0f);
				root.sizeDelta = new Vector2(0f, 0f);
				root.anchoredPosition = new Vector2(0f, 0f);
				((Transform)root).localScale = Vector3.one;
				((Component)root).gameObject.AddComponent<NotificationPanelComp>();
				currentBackground = ((Component)root).gameObject.AddComponent<Image>();
				Color value = PluginConfiguratorController.notificationPanelBackground.value;
				value.a = PluginConfiguratorController.notificationPanelOpacity.value / 100f;
				((Graphic)currentBackground).color = value;
				((Component)root).gameObject.AddComponent<MenuEsc>().DontClose = true;
				if (currentNotification != null)
				{
					currentNotification.OnUI(root);
					((Component)root).gameObject.SetActive(true);
				}
				else
				{
					((Component)root).gameObject.SetActive(false);
				}
			}
		}

		private static void ClearUI()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			foreach (Transform item in ((Component)root).transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
		}

		public static void Open(Notification notification)
		{
			if (currentNotification != null)
			{
				notificationQueue.Enqueue(notification);
				return;
			}
			currentNotification = notification;
			if (!((Object)(object)root == (Object)null))
			{
				ClearUI();
				((Component)root).gameObject.SetActive(true);
				currentNotification.OnUI(root);
			}
		}

		internal static void CloseInternal()
		{
			ClearUI();
			currentNotification = null;
			while (notificationQueue.Count != 0)
			{
				currentNotification = notificationQueue.Dequeue();
				if (!currentNotification.closed)
				{
					break;
				}
				currentNotification = null;
			}
			if (currentNotification != null)
			{
				if ((Object)(object)root != (Object)null)
				{
					currentNotification.OnUI(root);
					((Component)root).gameObject.SetActive(true);
				}
			}
			else if ((Object)(object)root != (Object)null)
			{
				((Component)root).gameObject.SetActive(false);
			}
		}

		public static int CurrentNotificationCount()
		{
			return notificationQueue.Count + ((currentNotification != null) ? 1 : 0);
		}
	}
	internal class OptionsMenuCloseListener : MonoBehaviour
	{
		private void OnDisable()
		{
			PluginConfiguratorController.FlushAllConfigs();
		}
	}
	internal class MainPanelComponent : MonoBehaviour
	{
		private void OnEnable()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			PluginConfiguratorController.activePanel = ((Component)this).gameObject;
			PluginConfiguratorController.backButton.onClick = new ButtonClickedEvent();
			((UnityEvent)PluginConfiguratorController.backButton.onClick).AddListener((UnityAction)delegate
			{
				if ((Object)(object)PluginConfiguratorController.activePanel != (Object)null && (Object)(object)PluginConfiguratorController.activePanel != (Object)(object)((Component)this).gameObject)
				{
					PluginConfiguratorController.activePanel.SetActive(false);
				}
				MonoSingleton<OptionsManager>.Instance.CloseOptions();
			});
		}

		private void OnDisable()
		{
			if (!PluginConfiguratorController.rememberConfigPage.value && (Object)(object)PluginConfiguratorController.activePanel == (Object)(object)((Component)this).gameObject)
			{
				PluginConfiguratorController.activePanel = null;
			}
		}
	}
	[BepInPlugin("com.eternalUnion.pluginConfigurator", "PluginConfigurator", "1.10.3")]
	public class PluginConfiguratorController : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__16_0;

			public static Func<GameObject, bool> <>9__26_1;

			public static UnityAction <>9__26_0;

			public static UnityAction <>9__26_3;

			public static UnityAction <>9__26_2;

			public static ButtonArrayField.OnClick <>9__39_0;

			public static ButtonArrayField.OnClick <>9__39_1;

			public static ColorField.PostColorValueChangeEvent <>9__39_2;

			public static FloatSliderField.PostFloatSliderValueChangeEvent <>9__39_3;

			public static Action <>9__39_9;

			public static Action<bool> <>9__39_10;

			internal void <HandleUltraTweakerUI>b__16_0()
			{
				if ((Object)(object)activePanel != (Object)null)
				{
					activePanel.SetActive(false);
				}
				activePanel = null;
				((Component)mainPanel).gameObject.SetActive(false);
			}

			internal bool <OnSceneLoadAsync>b__26_1(GameObject obj)
			{
				return ((Object)obj).name == "Canvas";
			}

			internal void <OnSceneLoadAsync>b__26_0()
			{
				SelectPluginConfigInOptions(forceMainPanelFallback: true);
			}

			internal void <OnSceneLoadAsync>b__26_2()
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Expected O, but got Unknown
				((Component)mainPanel).gameObject.SetActive(false);
				if ((Object)(object)activePanel != (Object)null)
				{
					activePanel.SetActive(false);
				}
				backButton.onClick = new ButtonClickedEvent();
				ButtonClickedEvent onClick = backButton.onClick;
				object obj = <>9__26_3;
				if (obj == null)
				{
					UnityAction val = delegate
					{
						MonoSingleton<OptionsMenuToManager>.Instance.CloseOptions();
					};
					<>9__26_3 = val;
					obj = (object)val;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
			}

			internal void <OnSceneLoadAsync>b__26_3()
			{
				MonoSingleton<OptionsMenuToManager>.Instance.CloseOptions();
			}

			internal void <Awake>b__39_0()
			{
				Application.OpenURL(PresetOldFileManager.trashBinDir);
			}

			internal void <Awake>b__39_1()
			{
				Application.OpenURL(PresetOldFileManager.resetBinDir);
			}

			internal void <Awake>b__39_2(Color v)
			{
				NotificationPanel.UpdateBackgroundColor();
			}

			internal void <Awake>b__39_3(float v, Tuple<float, float> r)
			{
				NotificationPanel.UpdateBackgroundColor();
			}

			internal void <Awake>b__39_9()
			{
				foreach (PluginConfigurator config in configs)
				{
					config.FlushAll();
				}
			}

			internal void <Awake>b__39_10(bool hasFocus)
			{
				if (hasFocus)
				{
					return;
				}
				foreach (PluginConfigurator config in configs)
				{
					config.FlushAll();
				}
			}
		}

		public static ManualLogSource logger;

		public const string PLUGIN_NAME = "PluginConfigurator";

		public const string PLUGIN_GUID = "com.eternalUnion.pluginConfigurator";

		public const string PLUGIN_VERSION = "1.10.3";

		private const string ASSET_PATH_CONFIG_BUTTON = "PluginConfigurator/PluginConfiguratorButton.prefab";

		private const string ASSET_PATH_CONFIG_MENU = "PluginConfigurator/PluginConfigField.prefab";

		private const string ASSET_PATH_CONFIG_PANEL = "PluginConfigurator/Fields/ConcretePanel.prefab";

		public static string workingPath;

		public static string workingDir;

		public static string catalogPath;

		internal static List<PluginConfigurator> configs = new List<PluginConfigurator>();

		internal static Transform optionsMenu;

		internal static GameObject pluginConfigObj;

		internal static ConfigPanelConcrete mainPanel;

		internal static GameObject activePanel;

		internal static Button backButton;

		internal static Harmony configuratorPatches;

		internal static PluginConfigurator config;

		internal static KeyCodeField toggleConfigBind;

		internal static BoolField rememberConfigPage;

		internal static BoolField patchCheatKeys;

		internal static BoolField patchPause;

		internal static BoolField cancelOnEsc;

		internal static BoolField devToggle;

		internal static BoolField devConfigs;

		internal static ColorField notificationPanelBackground;

		internal static FloatSliderField notificationPanelOpacity;

		internal static Sprite defaultPluginIcon;

		internal static void RegisterConfigurator(PluginConfigurator config)
		{
			configs.Add(config);
		}

		public static bool ConfigExists(string guid)
		{
			return configs.Where((PluginConfigurator c) => c.guid == guid).FirstOrDefault() != null;
		}

		public static PluginConfigurator GetConfig(string guid)
		{
			return configs.Where((PluginConfigurator c) => c.guid == guid).FirstOrDefault();
		}

		public static void FlushAllConfigs()
		{
			foreach (PluginConfigurator config in configs)
			{
				config.FlushAll();
			}
		}

		private void CreateConfigUI(Transform optionsMenu)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			foreach (PluginConfigurator config in configs)
			{
				try
				{
					GameObject obj = Addressables.InstantiateAsync((object)"PluginConfigurator/PluginConfigField.prefab", mainPanel.content, false, true).WaitForCompletion();
					ConfigPluginMenuField component = obj.GetComponent<ConfigPluginMenuField>();
					((TMP_Text)component.name).text = config.displayName;
					component.icon.sprite = config.image ?? defaultPluginIcon;
					config.configMenu = component;
					obj.SetActive(!config.hidden);
					((Selectable)component.button).interactable = config.interactable;
					config.CreateUI(component.button, optionsMenu);
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"Error while creating ui for {config.guid}: {arg}");
				}
			}
		}

		private static void HandleUltraTweakerUI(GameObject ___newBtn)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//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_002b: Expected O, but got Unknown
			Button component = ___newBtn.GetComponent<Button>();
			ButtonClickedEvent onClick = component.onClick;
			object obj = <>c.<>9__16_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					if ((Object)(object)activePanel != (Object)null)
					{
						activePanel.SetActive(false);
					}
					activePanel = null;
					((Component)mainPanel).gameObject.SetActive(false);
				};
				<>c.<>9__16_0 = val;
				obj = (object)val;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			((Component)component).GetComponent<RectTransform>().anchoredPosition = new Vector2(30f, 330f);
		}

		private static void SelectPluginConfigInOptions(bool forceMainPanelFallback = false)
		{
			Transform val = ((Component)optionsMenu).transform.Find("Navigation Rail");
			Transform obj = ((Component)optionsMenu).transform.Find("Pages");
			ButtonHighlightParent component = ((Component)val).GetComponent<ButtonHighlightParent>();
			Image component2 = pluginConfigObj.GetComponent<Image>();
			if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
			{
				component.ChangeButton(component2);
			}
			GamepadObjectSelector val2 = default(GamepadObjectSelector);
			foreach (Transform item in UnityUtils.GetChilds(obj).Concat(UnityUtils.GetChilds(val)))
			{
				if (!((Object)(object)item == (Object)(object)((Component)mainPanel).transform) && !((Object)(object)item == (Object)(object)pluginConfigObj.transform) && ((Component)item).gameObject.TryGetComponent<GamepadObjectSelector>(ref val2))
				{
					((Component)val2).gameObject.SetActive(false);
				}
			}
			if (!rememberConfigPage.value)
			{
				if ((Object)(object)activePanel != (Object)null && (Object)(object)activePanel != (Object)(object)((Component)mainPanel).gameObject)
				{
					ConfigPanelComponent configPanelComponent = default(ConfigPanelComponent);
					if (activePanel.TryGetComponent<ConfigPanelComponent>(ref configPanelComponent))
					{
						if (configPanelComponent.panel != null)
						{
							configPanelComponent.panel.rootConfig.FlushAll();
						}
						else
						{
							Debug.LogWarning((object)"Panel component does not have a config panel attached, could not flush");
						}
					}
					else
					{
						Debug.LogWarning((object)"Could not find panel's component");
					}
					activePanel.SetActive(false);
				}
				((Component)mainPanel).gameObject.SetActive(true);
			}
			else if ((Object)(object)activePanel != (Object)null && !activePanel.activeInHierarchy)
			{
				activePanel.SetActive(true);
			}
			else if ((Object)(object)activePanel == (Object)null || (forceMainPanelFallback && (Object)(object)activePanel != (Object)(object)((Component)mainPanel).gameObject))
			{
				if ((Object)(object)activePanel != (Object)null)
				{
					activePanel.SetActive(false);
				}
				((Component)mainPanel).gameObject.SetActive(true);
			}
		}

		private IEnumerator SelectPluginConfigInOptionsNextFrame()
		{
			yield return null;
			SelectPluginConfigInOptions();
		}

		private IEnumerator loadObjectAsync(Transform panel)
		{
			AsyncOperationHandle<GameObject> pluginConfigObj = Addressables.InstantiateAsync((object)"PluginConfigurator/PluginConfiguratorButton.prefab", panel, false, true);
			yield return pluginConfigObj;
			logger.LogInfo((object)"Load object status:");
			logger.LogInfo((object)pluginConfigObj.Status);
		}

		private void OnSceneLoad(Scene currentScene, LoadSceneMode mode)
		{
			//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)
			((MonoBehaviour)this).StartCoroutine(OnSceneLoadAsync(currentScene, mode));
		}

		private IEnumerator OnSceneLoadAsync(Scene currentScene, LoadSceneMode mode)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			yield return null;
			if ((int)mode == 1 || (Object)(object)mainPanel != (Object)null)
			{
				yield break;
			}
			GameObject val = null;
			foreach (GameObject item in from val8 in ((Scene)(ref currentScene)).GetRootGameObjects()
				where ((Object)val8).name == "Canvas"
				select val8)
			{
				optionsMenu = item.transform.Find("OptionsMenu");
				if (!((Object)(object)optionsMenu == (Object)null))
				{
					val = item;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				yield break;
			}
			((Component)optionsMenu).gameObject.AddComponent<OptionsMenuCloseListener>();
			Transform val2 = ((Component)optionsMenu).transform.Find("Text");
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			Transform val3 = ((Component)optionsMenu).transform.Find("Navigation Rail");
			Transform val4 = ((Component)optionsMenu).transform.Find("Pages");
			backButton = ((Component)((Component)optionsMenu).transform.Find("Navigation Rail/Back")).GetComponent<Button>();
			pluginConfigObj = Addressables.InstantiateAsync((object)"PluginConfigurator/PluginConfiguratorButton.prefab", val3, false, true).WaitForCompletion();
			pluginConfigObj.SetActive(true);
			Button component = pluginConfigObj.GetComponent<Button>();
			pluginConfigObj.transform.SetSiblingIndex(0);
			ButtonClickedEvent onClick = component.onClick;
			object obj = <>c.<>9__26_0;
			if (obj == null)
			{
				UnityAction val5 = delegate
				{
					SelectPluginConfigInOptions(forceMainPanelFallback: true);
				};
				<>c.<>9__26_0 = val5;
				obj = (object)val5;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			mainPanel = Addressables.InstantiateAsync((object)"PluginConfigurator/Fields/ConcretePanel.prefab", val4, false, true).WaitForCompletion().GetComponent<ConfigPanelConcrete>();
			((Component)mainPanel).gameObject.AddComponent<MainPanelComponent>();
			((TMP_Text)mainPanel.header).text = "--PLUGIN CONFIGURATOR--";
			((Component)mainPanel).gameObject.SetActive(false);
			((Component)mainPanel).GetComponent<GamepadObjectSelector>();
			Button val6 = default(Button);
			foreach (Transform item2 in UnityUtils.GetChilds(val4).Concat(UnityUtils.GetChilds(val3)))
			{
				if ((Object)(object)item2 == (Object)(object)((Component)mainPanel).transform || (Object)(object)item2 == (Object)(object)pluginConfigObj.transform || !((Component)item2).gameObject.TryGetComponent<Button>(ref val6))
				{
					continue;
				}
				ButtonClickedEvent onClick2 = val6.onClick;
				object obj2 = <>c.<>9__26_2;
				if (obj2 == null)
				{
					UnityAction val7 = delegate
					{
						//IL_002d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0037: Expected O, but got Unknown
						//IL_0055: Unknown result type (might be due to invalid IL or missing references)
						//IL_005a: Unknown result type (might be due to invalid IL or missing references)
						//IL_0060: Expected O, but got Unknown
						((Component)mainPanel).gameObject.SetActive(false);
						if ((Object)(object)activePanel != (Object)null)
						{
							activePanel.SetActive(false);
						}
						backButton.onClick = new ButtonClickedEvent();
						ButtonClickedEvent onClick3 = backButton.onClick;
						object obj3 = <>c.<>9__26_3;
						if (obj3 == null)
						{
							UnityAction val8 = delegate
							{
								MonoSingleton<OptionsMenuToManager>.Instance.CloseOptions();
							};
							<>c.<>9__26_3 = val8;
							obj3 = (object)val8;
						}
						((UnityEvent)onClick3).AddListener((UnityAction)obj3);
					};
					<>c.<>9__26_2 = val7;
					obj2 = (object)val7;
				}
				((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			}
			CreateConfigUI(optionsMenu);
			mainPanel.rect.normalizedPosition = new Vector2(0f, 1f);
			NotificationPanel.InitUI();
		}

		private void Awake()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_009b: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Expected O, but got Unknown
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Expected O, but got Unknown
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
			logger = ((BaseUnityPlugin)this).Logger;
			workingPath = Assembly.GetExecutingAssembly().Location;
			workingDir = Path.GetDirectoryName(workingPath);
			catalogPath = Path.Combine(workingDir, "Assets");
			PresetOldFileManager.Init();
			PresetOldFileManager.CheckForOldFiles();
			Addressables.InitializeAsync().WaitForCompletion();
			Addressables.LoadContentCatalogAsync(Path.Combine(catalogPath, "catalog.json"), true, (string)null).WaitForCompletion();
			defaultPluginIcon = Addressables.LoadAssetAsync<Sprite>((object)"PluginConfigurator/Textures/default-icon.png").WaitForCompletion();
			configuratorPatches = new Harmony("com.eternalUnion.pluginConfigurator");
			config = PluginConfigurator.Create("Plugin Configurator", "com.eternalUnion.pluginConfigurator");
			config.SetIconWithURL(Path.Combine(workingDir, "icon.png"));
			ButtonArrayField buttonArrayField = new ButtonArrayField(config.rootPanel, "binButtons", 2, new float[2] { 0.5f, 0.5f }, new string[2] { "Deleted Presets Folder", "Reset Presets Folder" });
			buttonArrayField.OnClickEventHandler(0).onClick += delegate
			{
				Application.OpenURL(PresetOldFileManager.trashBinDir);
			};
			buttonArrayField.OnClickEventHandler(1).onClick += delegate
			{
				Application.OpenURL(PresetOldFileManager.resetBinDir);
			};
			new ConfigHeader(config.rootPanel, "Patches").textColor = new Color(50f / 51f, 32f / 51f, 32f / 51f);
			patchCheatKeys = new BoolField(config.rootPanel, "Patch cheat keys", "cheatKeyPatch", defaultValue: true);
			patchPause = new BoolField(config.rootPanel, "Patch unpause", "unpausePatch", defaultValue: true);
			new ConfigSpace(config.rootPanel, 10f);
			new ConfigHeader(config.rootPanel, "Behaviour").textColor = new Color(50f / 51f, 32f / 51f, 32f / 51f);
			toggleConfigBind = new KeyCodeField(config.rootPanel, "Open plugin config", "toggleConfigBind", (KeyCode)93);
			rememberConfigPage = new BoolField(config.rootPanel, "Remember last config page", "rememberConfigPage", defaultValue: false);
			cancelOnEsc = new BoolField(config.rootPanel, "Cancel on ESC", "cancelOnEsc", defaultValue: false);
			new ConfigSpace(config.rootPanel, 10f);
			new ConfigHeader(config.rootPanel, "Notification Panel").textColor = new Color(50f / 51f, 32f / 51f, 32f / 51f);
			notificationPanelBackground = new ColorField(config.rootPanel, "Background color", "notificationPanelBg", Color.black);
			notificationPanelBackground.postValueChangeEvent += delegate
			{
				NotificationPanel.UpdateBackgroundColor();
			};
			notificationPanelOpacity = new FloatSliderField(config.rootPanel, "Opacity", "notificationPanelAlpha", new Tuple<float, float>(0f, 100f), 89.64f);
			notificationPanelOpacity.postValueChangeEvent += delegate
			{
				NotificationPanel.UpdateBackgroundColor();
			};
			new ConfigSpace(config.rootPanel, 10f);
			new ConfigHeader(config.rootPanel, "Developer Stuff").textColor = new Color(0.5372549f, 69f / 85f, 0.9411765f);
			devToggle = new BoolField(config.rootPanel, "Enable developer features", "devToggle", defaultValue: false);
			ConfigDivision devDiv = new ConfigDivision(config.rootPanel, "devDiv");
			devToggle.postValueChangeEvent += delegate(bool newVal)
			{
				devDiv.hidden = !newVal;
			};
			devToggle.TriggerPostValueChangeEvent();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Working path: " + workingPath + ", Working dir: " + workingDir));
			patchCheatKeys.onValueChange += CheatKeyListener;
			if (patchCheatKeys.value)
			{
				CheatKeyListener(new BoolField.BoolValueChangeEvent
				{
					value = true
				});
			}
			patchPause.onValueChange += UnpauseListener;
			if (patchPause.value)
			{
				UnpauseListener(new BoolField.BoolValueChangeEvent
				{
					value = true
				});
			}
			configuratorPatches.Patch((MethodBase)GetInstanceMethod<SettingsMenu>("Start"), (HarmonyMethod)null, new HarmonyMethod(GetStaticMethod<MenuFinderPatch>("Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			configuratorPatches.Patch((MethodBase)GetInstanceMethod<MenuEsc>("Update"), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(GetStaticMethod<MenuEscPatch>("FixNullExcpCausedByUncheckedField")), (HarmonyMethod)null, (HarmonyMethod)null);
			config.FlushAll();
			SceneManager.sceneLoaded += OnSceneLoad;
			Application.quitting += delegate
			{
				foreach (PluginConfigurator config in configs)
				{
					config.FlushAll();
				}
			};
			Application.focusChanged += delegate(bool hasFocus)
			{
				if (!hasFocus)
				{
					foreach (PluginConfigurator config2 in configs)
					{
						config2.FlushAll();
					}
				}
			};
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.eternalUnion.pluginConfigurator is loaded!");
			static void CheatKeyListener(BoolField.BoolValueChangeEvent data)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Expected O, but got Unknown
				if (data.value)
				{
					configuratorPatches.Patch((MethodBase)GetInstanceMethod<CheatsManager>("HandleCheatBind"), new HarmonyMethod(GetStaticMethod<HandleCheatBindPatch>("Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					configuratorPatches.Unpatch((MethodBase)GetInstanceMethod<CheatsManager>("HandleCheatBind"), GetStaticMethod<HandleCheatBindPatch>("Prefix"));
				}
			}
			static MethodInfo GetInstanceMethod<T>(string name)
			{
				return typeof(T).GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
			static MethodInfo GetStaticMethod<T>(string name)
			{
				return typeof(T).GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			}
			static void UnpauseListener(BoolField.BoolValueChangeEvent data)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Expected O, but got Unknown
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Expected O, but got Unknown
				if (data.value)
				{
					configuratorPatches.Patch((MethodBase)GetInstanceMethod<OptionsManager>("UnPause"), new HarmonyMethod(GetStaticMethod<UnpausePatch>("Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					configuratorPatches.Patch((MethodBase)GetInstanceMethod<OptionsManager>("CloseOptions"), new HarmonyMethod(GetStaticMethod<CloseOptionsPatch>("Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					configuratorPatches.Unpatch((MethodBase)GetInstanceMethod<OptionsManager>("UnPause"), GetStaticMethod<UnpausePatch>("Prefix"));
					configuratorPatches.Unpatch((MethodBase)GetInstanceMethod<OptionsManager>("CloseOptions"), GetStaticMethod<CloseOptionsPatch>("Prefix"));
				}
			}
		}

		private void OnDestroy()
		{
			//IL_0005: 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_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)
			Scene val = SceneManager.GetActiveScene();
			Debug.LogError((object)("Plugin configurator controller instance destroyed in scene '" + ((Scene)(ref val)).name + "'"));
			val = ((Component)this).gameObject.scene;
			Debug.LogError((object)("Plugin was in scene '" + ((Scene)(ref val)).name + "'"));
			Debug.LogError((object)("Object name was '" + ((Object)((Component)this).gameObject).name + "'"));
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(toggleConfigBind.value))
			{
				if ((Object)(object)activePanel != (Object)null && activePanel.activeInHierarchy)
				{
					CloseOptionsPatch.bypassBlock = true;
					MonoSingleton<OptionsManager>.Instance.CloseOptions();
					CloseOptionsPatch.bypassBlock = false;
					MonoSingleton<OptionsManager>.Instance.UnPause();
				}
				else
				{
					MonoSingleton<OptionsManager>.Instance.Pause();
					MonoSingleton<OptionsManager>.Instance.OpenOptions();
					((MonoBehaviour)this).StartCoroutine(SelectPluginConfigInOptionsNextFrame());
				}
			}
		}
	}
	public static class UnityUtils
	{
		public static void PrintGameobject(GameObject o, int iters = 0)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			for (int i = 0; i < iters; i++)
			{
				text += "|";
			}
			text += ((Object)o).name;
			Debug.Log((object)text);
			foreach (Transform item in o.transform)
			{
				PrintGameobject(((Component)item).gameObject, iters + 1);
			}
		}

		public static IEnumerable<Transform> GetChilds(Transform obj)
		{
			return (from i in Enumerable.Range(0, obj.childCount)
				select obj.GetChild(i)).ToArray().AsEnumerable();
		}

		public static IEnumerable<T> GetComponentsInChildrenRecursively<T>(Transform obj)
		{
			foreach (Transform item in obj)
			{
				Transform child = item;
				T component = ((Component)child).gameObject.GetComponent<T>();
				if (component != null)
				{
					yield return component;
				}
				foreach (T item2 in GetComponentsInChildrenRecursively<T>(child))
				{
					yield return item2;
				}
			}
		}

		public static T GetComponentInChildrenRecursively<T>(Transform obj)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			foreach (Transform item in obj)
			{
				Transform val = item;
				if (!((Object)(object)val == (Object)(object)obj))
				{
					T component = ((Component)val).gameObject.GetComponent<T>();
					if (component != null)
					{
						return component;
					}
					component = GetComponentInChildrenRecursively<T>(val);
					if (component != null)
					{
						return component;
					}
				}
			}
			return default(T);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "PluginConfigurator";

		public const string PLUGIN_NAME = "PluginConfigurator";

		public const string PLUGIN_VERSION = "1.10.3";
	}
}
namespace PluginConfig.Patches
{
	[HarmonyPatch(typeof(CheatsManager), "HandleCheatBind")]
	public class HandleCheatBindPatch
	{
		public static bool Prefix(CheatsManager __instance)
		{
			if (((Object)(object)MenuFinderPatch.pauseMenu != (Object)null && ((Component)MenuFinderPatch.pauseMenu).gameObject.activeInHierarchy) || ((Object)(object)MenuFinderPatch.optionsMenu != (Object)null && ((Component)MenuFinderPatch.optionsMenu).gameObject.activeInHierarchy))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(MenuEsc))]
	public class MenuEscPatch
	{
		public static MethodInfo vm_UnityEngine_UI_Selectable_Select = (from m in typeof(Selectable).GetMethods()
			where m.IsVirtual && !m.IsStatic && m.Name == "Select"
			select m).FirstOrDefault();

		public static MethodInfo sm_MenuEscPatch_HandleField = typeof(MenuEscPatch).GetMethod("HandleField", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

		public static void HandleField(Selectable field)
		{
			if ((Object)(object)field != (Object)null)
			{
				field.Select();
			}
			else
			{
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("Update")]
		public static IEnumerable<CodeInstruction> FixNullExcpCausedByUncheckedField(IEnumerable<CodeInstruction> inst)
		{
			List<CodeInstruction> list = inst.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Callvirt && CodeInstructionExtensions.OperandIs(list[i], (MemberInfo)vm_UnityEngine_UI_Selectable_Select))
				{
					list[i].opcode = OpCodes.Call;
					list[i].operand = sm_MenuEscPatch_HandleField;
				}
			}
			return list.AsEnumerable();
		}
	}
	public class MenuFinderPatch
	{
		public static Transform pauseMenu;

		public static Transform optionsMenu;

		public static void Postfix(SettingsMenu __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject val = (from obj in ((Scene)(ref activeScene)).GetRootGameObjects()
				where ((Object)obj).name == "Canvas"
				select obj).FirstOrDefault();
			if (!((Object)(object)val == (Object)null))
			{
				pauseMenu = val.transform.Find("PauseMenu");
				optionsMenu = val.transform.Find("OptionsMenu");
			}
		}
	}
	[HarmonyPatch(typeof(OptionsManager), "CloseOptions")]
	public class CloseOptionsPatch
	{
		internal static bool bypassBlock;

		private static bool Prefix(OptionsManager __instance)
		{
			if ((Object)(object)PluginConfiguratorController.activePanel == (Object)null || !PluginConfiguratorController.activePanel.activeSelf)
			{
				return true;
			}
			if (!bypassBlock && (Object)(object)PluginConfiguratorController.activePanel != (Object)null && (Object)(object)PluginConfiguratorController.activePanel != (Object)(object)((Component)PluginConfiguratorController.mainPanel).gameObject)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(OptionsManager), "UnPause")]
	public class UnpausePatch
	{
		private static bool Prefix(OptionsManager __instance)
		{
			if ((Object)(object)MenuFinderPatch.optionsMenu != (Object)null && ((Component)MenuFinderPatch.optionsMenu).gameObject.activeInHierarchy)
			{
				return false;
			}
			return true;
		}
	}
}
namespace PluginConfig.API
{
	public class ConfigBridge : ConfigField
	{
		public readonly ConfigField targetField;

		public override string displayName
		{
			get
			{
				return targetField.displayName;
			}
			set
			{
				if (targetField != null)
				{
					targetField.displayName = value;
				}
			}
		}

		public override bool hidden
		{
			get
			{
				return targetField.hidden;
			}
			set
			{
				if (targetField != null)
				{
					targetField.hidden = value;
				}
			}
		}

		public override bool interactable
		{
			get
			{
				return targetField.interactable;
			}
			set
			{
				if (targetField != null)
				{
					targetField.interactable = value;
				}
			}
		}

		public ConfigBridge(ConfigField targetField, ConfigPanel parentPanel)
			: base(targetField.displayName, "bridge_" + targetField.guid, parentPanel)
		{
			base.strictGuid = false;
			if (targetField == null)
			{
				throw new NullReferenceException("Target field cannot be null");
			}
			if (targetField.bridged)
			{
				throw new ArgumentException("Tried to create config bridge but target field " + targetField.guid + " is already connected to another config bridge");
			}
			if (targetField.parentPanel == null)
			{
				throw new ArgumentException("Root panels cannot be bridged");
			}
			if (targetField.parentPanel == targetField)
			{
				throw new ArgumentException("Panels cannot be bridged to themselves");
			}
			this.targetField = targetField;
			DestroyFieldUI(targetField);
			Stack<ConfigPanel> stack = new Stack<ConfigPanel>();
			if (targetField is ConfigPanel item)
			{
				stack.Push(item);
			}
			while (stack.Count != 0)
			{
				ConfigPanel configPanel = stack.Pop();
				configPanel.fieldsCreated = false;
				if ((Object)(object)configPanel.currentPanel != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)configPanel.currentPanel).gameObject);
				}
				foreach (ConfigField field in configPanel.fields)
				{
					if (field is ConfigPanel item2)
					{
						stack.Push(item2);
					}
				}
			}
			targetField.bridged = true;
			targetField.bridge = this;
			parentPanel.Register(this);
			static void DestroyFieldUI(ConfigField field)
			{
				ConfigPanel configPanel2 = field.parentPanel;
				if (configPanel2.fieldsCreated)
				{
					int num = configPanel2.fields.IndexOf(field);
					if (num != -1)
					{
						foreach (Transform item3 in configPanel2.fieldObjects[num])
						{
							Object.Destroy((Object)(object)((Component)item3).gameObject);
						}
					}
				}
			}
		}

		protected internal override GameObject CreateUI(Transform content)
		{
			return targetField.CreateUI(content);
		}

		internal override void ReloadDefault()
		{
			throw new NotImplementedException();
		}

		internal override void ReloadFromString(string data)
		{
			throw new NotImplementedException();
		}
	}
	internal class ConfigDivisionComp : UIBehaviour
	{
		public ConfigDivision div;

		public bool dirty;

		public override void OnRectTransformDimensionsChange()
		{
			((UIBehaviour)this).OnRectTransformDimensionsChange();
			div.RecalculateLayout();
		}

		public override void OnEnable()
		{
			div.RecalculateLayout();
		}

		public override void OnDisable()
		{
			div.RecalculateLayout();
		}

		public void Update()
		{
			if (dirty)
			{
				dirty = false;
				div.RecalculateLayout();
			}
		}
	}
	public class ConfigDivision : ConfigPanel
	{
		public const string ASSET_PATH = "PluginConfigurator/Fields/VirtualPanel.prefab";

		internal ConfigPanelVirtual currentVirtualPanel;

		internal ConfigDivisionComp currentDivComp;

		public override string displayName { get; set; }

		public override bool hidden
		{
			get
			{
				return base.hidden;
			}
			set
			{
				base.hidden = value;
				if ((Object)(object)currentVirtualPanel != (Object)null)
				{
					((Component)currentVirtualPanel).gameObject.SetActive(!hidden && !base.parentHidden);
				}
				foreach (ConfigField field in fields)
				{
					field.parentHidden = value || hidden || base.parentHidden;
				}
			}
		}

		public override bool interactable
		{
			get
			{
				return base.interactable;
			}
			set
			{
				base.interactable = value;
				foreach (ConfigField field in fields)
				{
					field.parentInteractable = value && interactable && base.parentInteractable;
				}
			}
		}

		protected internal override void RecalculateLayoutDeepestFirst()
		{
			foreach (ConfigPanel childPanel in childPanels)
			{
				childPanel.RecalculateLayoutDeepestFirst();
			}
			if (!((Object)(object)currentVirtualPanel == (Object)null))
			{
				((Component)currentVirtualPanel.contentSizeFitter).SendMessage("SetDirty");
				LayoutRebuilder.ForceRebuildLayoutImmediate(currentVirtualPanel.trans);
			}
		}

		protected internal override void RecalculateLayout()
		{
			if ((Object)(object)currentVirtualPanel != (Object)null)
			{
				((Component)currentVirtualPanel.contentSizeFitter).SendMessage("SetDirty");
				LayoutRebuilder.ForceRebuildLayoutImmediate(currentVirtualPanel.trans);
			}
			base.parentPanel.RecalculateLayout();
		}

		public override void FieldDimensionChanged()
		{
			if ((Object)(object)currentDivComp != (Object)null)
			{
				currentDivComp.dirty = true;
			}
		}

		public ConfigDivision(ConfigPanel panel, string guid)
			: base(panel, guid)
		{
			panel.Register(this);
			panel.childPanels.Add(this);
			base.currentDirectory = base.parentPanel.currentDirectory + "/" + guid;
		}

		internal override void Register(ConfigField field)
		{
			fields.Add(field);
			if ((Object)(object)currentVirtualPanel != (Object)null)
			{
				int i = currentVirtualPanel.content.childCount;
				if (field.createUI && !field.bridged)
				{
					field.CreateUI(currentVirtualPanel.content);
				}
				List<Transform> list = new List<Transform>();
				for (; i < currentVirtualPanel.content.childCount; i++)
				{
					list.Add(currentVirtualPanel.content.GetChild(i));
				}
				fieldObjects.Add(list);
			}
		}

		internal override void ActivatePanel()
		{
			if (base.parentPanel != null)
			{
				base.parentPanel.ActivatePanel();
			}
		}

		internal override GameObject GetConcretePanelObj()
		{
			return base.parentPanel.GetConcretePanelObj();
		}

		internal override ConfigPanel GetConcretePanel()
		{
			return base.parentPanel.GetConcretePanel();
		}

		protected internal override GameObject CreateUI(Transform content)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			currentPanel = base.parentPanel.currentPanel;
			currentComp = base.parentPanel.currentComp;
			GameObject val = Addressables.InstantiateAsync((object)"PluginConfigurator/Fields/VirtualPanel.prefab", content, false, true).WaitForCompletion();
			currentVirtualPanel = val.GetComponent<ConfigPanelVirtual>();
			val.SetActive(false);
			fieldsCreated = true;
			fieldObjects.Clear();
			int i = currentVirtualPanel.content.childCount;
			foreach (ConfigField field in fields)
			{
				List<Transform> list = new List<Transform>();
				if (field.createUI && !field.bridged)
				{
					field.CreateUI(currentVirtualPanel.content);
				}
				for (; i < currentVirtualPanel.content.childCount; i++)
				{
					list.Add(currentVirtualPanel.content.GetChild(i));
				}
				fieldObjects.Add(list);
			}
			currentDivComp = val.AddComponent<ConfigDivisionComp>();
			currentDivComp.div = this;
			((Component)currentVirtualPanel.contentSizeFitter).SendMessage("OnRectTransformDimensionsChange");
			val.SetActive(!hidden && !base.parentHidden);
			return val;
		}
	}
	public abstract class ConfigField
	{
		public readonly bool createUI = true;

		public int presetLoadPriority;

		private bool _parentHidden;

		private bool _parentInteractable = true;

		public abstract string displayName { get; set; }

		public string guid { get; private set; }

		public bool strictGuid { get; protected set; }

		public abstract bool hidden { get; set; }

		internal bool parentHidden
		{
			get
			{
				return _parentHidden;
			}
			set
			{
				_parentHidden = value;
				hidden = hidden;
			}
		}

		public bool hierarchyHidden
		{
			get
			{
				if (!hidden)
				{
					return _parentHidden;
				}
				return true;
			}
		}

		public abstract bool interactable { get; set; }

		internal bool parentInteractable
		{
			get
			{
				return _parentInteractable;
			}
			set
			{
				_parentInteractable = value;
				interactable = interactable;
			}
		}

		public bool hierarchyInteractable
		{
			get
			{
				if (interactable)
				{
					return _parentInteractable;
				}
				return false;
			}
		}

		public PluginConfigurator rootConfig { get; private set; }

		public ConfigPanel parentPanel { get; internal set; }

		public bool bridged { get; internal set; }

		public ConfigBridge bridge { get; internal set; }

		public int siblingIndex
		{
			get
			{
				if (parentPanel == null)
				{
					return 0;
				}
				return parentPanel.fields.IndexOf(this);
			}
			set
			{
				if (parentPanel == null)
				{
					return;
				}
				List<ConfigField> fields = parentPanel.fields;
				int count = fields.Count;
				if (value < 0)
				{
					value = 0;
				}
				else if (value >= count)
				{
					value = count - 1;
				}
				int num = fields.IndexOf(this);
				if (num == value)
				{
					return;
				}
				fields.RemoveAt(num);
				fields.Insert(value, this);
				if (!((Object)(object)parentPanel.currentPanel != (Object)null) || parentPanel.currentPanel.content.childCount == 0)
				{
					return;
				}
				List<Transform> item = parentPanel.fieldObjects[num];
				parentPanel.fieldObjects.RemoveAt(num);
				parentPanel.fieldObjects.Insert(value, item);
				int num2 = 0;
				foreach (List<Transform> fieldObject in parentPanel.fieldObjects)
				{
					foreach (Transform item2 in fieldObject)
					{
						if (!((Object)(object)item2 == (Object)null))
						{
							item2.SetSiblingIndex(num2++);
						}
					}
				}
			}
		}

		internal ConfigField(string displayName, string guid, PluginConfigurator rootConfig)
		{
			strictGuid = true;
			this.displayName = displayName;
			this.guid = guid;
			parentPanel = null;
			this.rootConfig = rootConfig;
		}

		public ConfigField(string displayName, string guid, ConfigPanel parentPanel, bool createUI)
		{
			strictGuid = true;
			this.createUI = createUI;
			this.displayName = displayName;
			this.guid = guid;
			this.parentPanel = parentPanel;
			rootConfig = parentPanel.rootConfig;
			if (parentPanel is ConfigDivision configDivision)
			{
				_parentHidden = configDivision.hidden || configDivision.parentHidden;
				_parentInteractable = configDivision.interactable && configDivision.parentInteractable;
			}
		}

		public ConfigField(string displayName, string guid, ConfigPanel parentPanel)
			: this(displayName, guid, parentPanel, createUI: true)
		{
		}

		protected internal abstract GameObject CreateUI(Transform content);

		internal abstract void ReloadFromString(string data);

		internal abstract void ReloadDefault();
	}
	internal struct PanelInfo
	{
		public RectTransform rect;

		public ContentSizeFitter content;
	}
	internal class ConfigPanelComponent : MonoBehaviour
	{
		public static ConfigPanelComponent lastActivePanel;

		public ConfigPanel panel;

		public bool dirty;

		private void Awake()
		{
			try
			{
				panel.CreateFieldUI();
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Exception thrown while creating panel UI\n{arg}");
			}
			panel.RecalculateLayoutDeepestFirst();
		}

		protected void OnEnable()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			lastActivePanel = this;
			PluginConfiguratorController.activePanel = ((Component)this).gameObject;
			PluginConfiguratorController.backButton.onClick = new ButtonClickedEvent();
			((UnityEvent)PluginConfiguratorController.backButton.onClick).AddListener((UnityAction)delegate
			{
				((Component)this).gameObject.SetActive(false);
				if (!panel.bridged)
				{
					if (panel.parentPanel == null)
					{
						panel.rootConfig.FlushAll();
						((Component)PluginConfiguratorController.mainPanel).gameObject.SetActive(true);
					}
					else
					{
						panel.parentPanel.ActivatePanel();
					}
				}
				else
				{
					panel.bridge.parentPanel.ActivatePanel();
				}
			});
			if (!panel.bridged)
			{
				if (panel.parentPanel == null)
				{
					panel.currentEsc.previousPage = ((Component)PluginConfiguratorController.mainPanel).gameObject;
				}
				else
				{
					panel.currentEsc.previousPage = panel.parentPanel.GetConcretePanelObj();
				}
			}
			else
			{
				panel.currentEsc.previousPage = panel.bridge.parentPanel.GetConcretePanelObj();
			}
			PluginConfigurator pluginConfigurator = panel.ParentBridgedRootConfig();
			pluginConfigurator.presetButtonCanBeShown = true;
			((Component)pluginConfigurator.presetMenuButton).gameObject.SetActive(!pluginConfigurator.presetButtonHidden);
			try
			{
				panel.OnPanelOpen(panel.externalPanelOpenFlag);
				panel.externalPanelOpenFlag = false;
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Exception thrown while calling on pannel open event\n{arg}");
			}
		}

		private void OnDisable()
		{
			PluginConfigurator pluginConfigurator = panel.ParentBridgedRootConfig();
			pluginConfigurator.presetButtonCanBeShown = false;
			((Component)pluginConfigurator.presetMenuButton).gameObject.SetActive(false);
			if (!PluginConfiguratorController.rememberConfigPage.value && (Object)(object)PluginConfiguratorController.activePanel == (Object)(object)((Component)this).gameObject)
			{
				PluginConfiguratorController.activePanel = null;
			}
			try
			{
				panel.OnPanelClose();
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Exception thrown while calling on pannel close event\n{arg}");
			}
		}

		public void Update()
		{
			if (dirty)
			{
				dirty = false;
				panel.RecalculateLayout();
			}
		}
	}
	public class ConfigPanel : ConfigField
	{
		public enum PanelFieldType
		{
			Standard,
			StandardWithIcon,
			StandardWithBigIcon,
			BigButton
		}

		public delegate void OpenPanelEventDelegate(bool openedExternally);

		public delegate void ClosePanelEventDelegate();

		private const string ASSET_PATH_PANEL = "PluginConfigurator/Fields/ConcretePanel.prefab";

		private const string ASSET_PATH_MENU_STANDARD = "PluginConfigurator/Fields/ConfigMenu.prefab";

		private const string ASSET_PATH_MENU_ICON = "PluginConfigurator/Fields/ConfigMenuIcon.prefab";

		private const string ASSET_PATH_MENU_ICON_BIG = "PluginConfigurator/Fields/ConfigMenuBigIcon.prefab";

		private const string ASSET_PATH_MENU_BIG_BUTTON = "PluginConfigurator/Fields/ConfigMenuBigButton.prefab";

		protected internal ConfigPanelConcrete currentPanel;

		protected internal ConfigMenuField currentMenu;

		protected internal MenuEsc currentEsc;

		internal ConfigPanelComponent currentComp;

		private Color _fieldColor = Color.black;

		protected internal List<ConfigPanel> childPanels = new List<ConfigPanel>();

		private string _displayName;

		private string _headerText;

		private string _buttonText = "Open";

		private PanelFieldType fieldType;

		private Sprite _icon;

		internal List<ConfigField> fields = new List<ConfigField>();

		private bool _hidden;

		private bool _interactable = true;

		internal List<List<Transform>> fieldObjects = new List<List<Transform>>();

		internal bool fieldsCreated;

		internal bool externalPanelOpenFlag;

		public Color fieldColor
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _fieldColor;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: 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)
				_fieldColor = value;
				if (!((Object)(object)currentMenu == (Object)null) && (Object)(object)currentMenu.fieldBg != (Object)null)
				{
					((Graphic)currentMenu.fieldBg).color = fieldColor;
				}
			}
		}

		public override string displayName
		{
			get
			{
				return _displayName;
			}
			set
			{
				_displayName = value;
				if ((Object)(object)currentMenu != (Object)null)
				{
					((TMP_Text)currentMenu.name).text = _displayName;
				}
			}
		}

		public string headerText
		{
			get
			{
				return _headerText;
			}
			set
			{
				_headerText = value;
				if ((Object)(object)currentPanel != (Object)null)
				{
					((TMP_Text)currentPanel.header).text = _headerText;
				}
			}
		}

		public string buttonText
		{
			get
			{
				return _buttonText;
			}
			set
			{
				_buttonText = value;
				if ((Object)(object)currentMenu != (Object)null)
				{
					((TMP_Text)currentMenu.buttonText).text = _buttonText;
				}
			}
		}

		public Sprite icon
		{
			get
			{
				return _icon;
			}
			set
			{
				_icon = value;
				if ((Object)(object)currentMenu != (Object)null && (Object)(object)currentMenu.icon != (Object)null)
				{
					currentMenu.icon.sprite = icon;
				}
			}
		}

		public ConfigField this[int index] => FieldAt(index);

		public ConfigField this[string guid] => fields.Where((ConfigField field) => field.guid == guid).FirstOrDefault();

		public int fieldCount => fields.Count;

		public string currentDirectory { get; protected set; }

		public override bool hidden
		{
			get
			{
				return _hidden;
			}
			set
			{
				_hidden = value;
				if ((Object)(object)currentMenu != (Object)null)
				{
					((Component)currentMenu).gameObject.SetActive(!_hidden && !base.parentHidden);
				}
			}
		}

		public override bool interactable
		{
			get
			{
				return _interactable;
			}
			set
			{
				_interactable = value;
				if ((Object)(object)currentMenu != (Object)null)
				{
					((Selectable)currentMenu.button).interactable = _interactable && base.parentInteractable;
					SetInteractableColor(_interactable && base.parentInteractable);
				}
			}
		}

		public event OpenPanelEventDelegate onPannelOpenEvent;

		public event ClosePanelEventDelegate onPannelCloseEvent;

		internal PluginConfigurator ParentBridgedRootConfig()
		{
			for (ConfigPanel configPanel = this; configPanel != null; configPanel = configPanel.parentPanel)
			{
				if (configPanel.bridged)
				{
					return configPanel.bridge.rootConfig;
				}
			}
			return base.rootConfig;
		}

		protected internal virtual void RecalculateLayoutDeepestFirst()
		{
			foreach (ConfigPanel childPanel in childPanels)
			{
				childPanel.RecalculateLayoutDeepestFirst();
			}
			((Component)currentPanel.contentSizeFitter).SendMessage("SetDirty");
			LayoutRebuilder.ForceRebuildLayoutImmediate(currentPanel.trans);
		}

		protected internal virtual void RecalculateLayout()
		{
			((Component)currentPanel.contentSizeFitter).SendMessage("SetDirty");
			LayoutRebuilder.ForceRebuildLayoutImmediate(currentPanel.trans);
		}

		public virtual void FieldDimensionChanged()
		{
			if ((Object)(object)currentComp != (Object)null)
			{
				currentComp.dirty = true;
			}
		}

		public void SetIconWithURL(string url)
		{
			if (fieldType != PanelFieldType.StandardWithIcon && fieldType != PanelFieldType.StandardWithBigIcon)
			{
				return;
			}
			UnityWebRequest iconDownload = UnityWebRequestTexture.GetTexture(url);
			((AsyncOperation)iconDownload.SendWebRequest()).completed += delegate
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (!iconDownload.isHttpError && !iconDownload.isNetworkError)
					{
						Texture2D content = DownloadHandlerTexture.GetContent(iconDownload);
						Sprite val = Sprite.Create(content, new Rect(0f, 0f, (float)((Texture)content).width, (float)((Texture)content).height), new Vector2(0.5f, 0.5f));
						icon = val;
					}
				}
				finally
				{
					iconDownload.Dispose();
				}
			};
		}

		public ConfigField FieldAt(int index)
		{
			if (index < 0 || index >= fields.Count)
			{
				return null;
			}
			return fields[index];
		}

		public ConfigField[] GetAllFields()
		{
			return fields.ToArray();
		}

		private void SetInteractableColor(bool interactable)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)currentMenu == (Object)null))
			{
				((Graphic)currentMenu.name).color = (interactable ? Color.white : Color.gray);
			}
		}

		internal ConfigPanel(PluginConfigurator config)
			: base(config.displayName, "", config)
		{
		}//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)


		internal ConfigPanel(ConfigPanel panel, string name)
			: base(name, "", panel)
		{
		}//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)


		public ConfigPanel(ConfigPanel parentPanel, string name, string guid, PanelFieldType fieldType)
			: base(name, guid, parentPanel)
		{
			//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)
			headerText = "--" + displayName + "--";
			this.fieldType = fieldType;
			parentPanel.Register(this);
			currentDirectory = parentPanel.currentDirectory + "/" + guid;
		}

		public ConfigPanel(ConfigPanel parentPanel, string name, string guid)
			: this(parentPanel, name, guid, PanelFieldType.Standard)
		{
		}

		internal virtual void Register(ConfigField field)
		{
			fields.Add(field);
			if ((Object)(object)currentPanel != (Object)null && fieldsCreated)
			{
				int i = currentPanel.content.childCount;
				if (field.createUI && !field.bridged)
				{
					field.CreateUI(currentPanel.content);
				}
				List<Transform> list = new List<Transform>();
				for (; i < currentPanel.content.childCount; i++)
				{
					list.Add(currentPanel.content.GetChild(i));
				}
				fieldObjects.Add(list);
			}
		}

		internal virtual void ActivatePanel()
		{
			if ((Object)(object)currentPanel != (Object)null)
			{
				((Component)currentPanel).gameObject.SetActive(true);
			}
		}

		internal virtual GameObject GetConcretePanelObj()
		{
			if (!((Object)(object)currentPanel == (Object)null))
			{
				return ((Component)currentPanel).gameObject;
			}
			return null;
		}

		internal virtual ConfigPanel GetConcretePanel()
		{
			return this;
		}

		protected internal override GameObject CreateUI(Transform content)
		{
			//IL_0013: 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_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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_0139: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			fieldsCreated = false;
			GameObject val = Addressables.InstantiateAsync((object)"PluginConfigurator/Fields/ConcretePanel.prefab", PluginConfiguratorController.optionsMenu, false, true).WaitForCompletion();
			currentPanel = val.GetComponent<ConfigPanelConcrete>();
			val.SetActive(false);
			currentComp = val.AddComponent<ConfigPanelComponent>();
			currentComp.panel = this;
			((TMP_Text)currentPanel.header).text = _headerText;
			MenuEsc val2 = (currentEsc = val.AddComponent<MenuEsc>());
			if (!base.bridged)
			{
				if (base.parentPanel == null)
				{
					val2.previousPage = ((Component)PluginConfiguratorController.mainPanel).gameObject;
				}
				else
				{
					val2.previousPage = base.parentPanel.GetConcretePanelObj();
				}
			}
			else
			{
				val2.previousPage = base.bridge.parentPanel.GetConcretePanelObj();
			}
			if ((Object)(object)content != (Object)null)
			{
				GameObject val3 = null;
				val3 = ((fieldType == PanelFieldType.StandardWithIcon) ? Addressables.InstantiateAsync((object)"PluginConfigurator/Fields/ConfigMenuIcon.prefab", content, false, true).WaitForCompletion() : ((fieldType == PanelFieldType.StandardWithBigIcon) ? Addressables.InstantiateAsync((object)"PluginConfigurator/Fields/ConfigMenuBigIcon.prefab", content, false, true).WaitForCompletion() : ((fieldType != PanelFieldType.BigButton) ? Addressables.InstantiateAsync((object)"PluginConfigurator/Fields/ConfigMenu.prefab", content, false, true).WaitForCompletion() : Addressables.InstantiateAsync((object)"PluginConfigurator/Fields/ConfigMenuBigButton.prefab", content, false, true).WaitForCompletion())));
				currentMenu = val3.GetComponent<ConfigMenuField>();
				((TMP_Text)currentMenu.name).text = displayName;
				if ((Object)(object)currentMenu.icon != (Object)null)
				{
					currentMenu.icon.sprite = icon;
				}
				if ((Object)(object)currentMenu.buttonText != (Object)null)
				{
					((TMP_Text)currentMenu.buttonText).text = _buttonText;
				}
				currentMenu.button.onClick = new ButtonClickedEvent();
				((UnityEvent)currentMenu.button.onClick).AddListener((UnityAction)delegate
				{
					OpenPanelInternally(openedExternally: false);
				});
				if ((Object)(object)currentMenu.fieldBg != (Object)null)
				{
					((Graphic)currentMenu.fieldBg).color = _fieldColor;
				}
				((Component)currentMenu).gameObject.SetActive(!hidden && !base.parentHidden);
				((Selectable)currentMenu.button).interactable = interactable && base.parentInteractable;
			}
			return val;
		}

		internal void CreateFieldUI()
		{
			if ((Object)(object)currentPanel == (Object)null || fieldsCreated)
			{
				return;
			}
			fieldsCreated = true;
			fieldObjects.Clear();
			int i = currentPanel.content.childCount;
			foreach (ConfigField field in fields)
			{
				List<Transform> list = new List<Transform>();
				if (field.createUI && !field.bridged)
				{
					field.CreateUI(currentPanel.content);
				}
				for (; i < currentPanel.content.childCount; i++)
				{
					list.Add(currentPanel.content.GetChild(i));
				}
				fieldObjects.Add(list);
			}
		}

		internal void OnPanelClose()
		{
			if (this.onPannelCloseEvent != null)
			{
				this.onPannelCloseEvent();
			}
		}

		internal void OnPanelOpen(bool external)
		{
			if (this.onPannelOpenEvent != null)
			{
				this.onPannelOpenEvent(external);
			}
		}

		internal void OpenPanelInternally(bool openedExternally)
		{
			if ((!openedExternally || !((Object)(object)PluginConfiguratorController.activePanel == (Object)null)) && !((Object)(object)currentPanel == (Object)null))
			{
				if ((Object)(object)PluginConfiguratorController.activePanel != (Object)null)
				{
					PluginConfiguratorController.activePanel.SetActive(false);
				}
				externalPanelOpenFlag = openedExternally;
				((Component)currentPanel).gameObject.SetActive(true);
				PluginConfiguratorController.activePanel = ((Component)currentPanel).gameObject;
			}
		}

		public void OpenPanel()
		{
			OpenPanelInternally(openedExternally: true);
		}

		public void ClosePanel()
		{
			if ((Object)(object)currentPanel != (Object)null && ((Component)currentPanel).gameObject.activeSelf)
			{
				((Component)currentPanel).gameObject.SetActive(false);
				if (base.parentPanel == null)
				{
					base.rootConfig.FlushAll();
					((Component)PluginConfiguratorController.mainPanel).gameObject.SetActive(true);
					PluginConfiguratorController.activePanel = ((Component)PluginConfiguratorController.mainPanel).gameObject;
				}
				else
				{
					base.parentPanel.ActivatePanel();
				}
			}
		}

		internal override void ReloadFromString(string data)
		{
			throw new NotImplementedException();
		}

		internal override void ReloadDefault()
		{
			throw new NotImplementedException();
		}
	}
	internal class PresetPanelComp : MonoBehaviour
	{
		private MenuEsc esc;

		private void Awake()
		{
			esc = ((Component)this).GetComponent<MenuEsc>();
		}

		private void OnEnable()
		{
			esc.previousPage = PluginConfiguratorController.activePanel;
			((Component)this).transform.SetSiblingIndex(((Component)this).transform.parent.childCount - 1);
		}

		private void OnDisable()
		{
			((Component)this).gameObject.SetActive(false);
		}
	}
	internal static class PresetOldFileManager
	{
		public static string trashBinDir;

		public static string resetBinDir;

		private static readonly char[] pathSafeCharacters = new char[4] { '.', '-', '_', ' ' };

		public static void Init()
		{
			trashBinDir = Path.Combine(Paths.ConfigPath, "PluginConfigurator", "preset_trash_bin");
			resetBinDir = Path.Combine(Paths.ConfigPath, "PluginConfigurator", "preset_reset_bin");
			if (!Directory.Exists(trashBinDir))
			{
				Directory.CreateDirectory(trashBinDir);
			}
			if (!Directory.Exists(resetBinDir))
			{
				Directory.CreateDirectory(resetBinDir);
			}
		}

		public static void CheckForOldFiles()
		{
			string[] files = Directory.GetFiles(trashBinDir);
			for (int i = 0; i < files.Length; i++)
			{
				FileInfo fileInfo = new FileInfo(files[i]);
				if (fileInfo.CreationTime < DateTime.Now.AddDays(-7.0))
				{
					fileInfo.Delete();
				}
			}
			files = Directory.GetFiles(resetBinDir);
			for (int i = 0; i < files.Length; i++)
			{
				FileInfo fileInfo2 = new FileInfo(files[i]);
				if (fileInfo2.CreationTime < DateTime.Now.AddDays(-7.0))
				{
					fileInfo2.Delete();
				}
			}
		}

		private static string TurnToUniquePath(string path)
		{
			string directoryName = Path.GetDirectoryName(path);
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
			string extension = Path.GetExtension(path);
			int num = 0;
			string text = path;
			while (File.Exists(text))
			{
				text = Path.Combine(directoryName, $"{fileNameWithoutExtension}_{num++}{extension}");
			}
			return text;
		}

		private static string GetPathSafeString(string s)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (char c in s)
			{
				if (char.IsLetter(c) || char.IsDigit(c) || Array.IndexOf(pathSafeCharacters, c) != -1)
				{
					stringBuilder.Append(c);
				}
				else if (stringBuilder.Length != 0 && stringBuilder[stringBuilder.Length - 1] != '_')
				{
					stringBuilder.Append('_');
				}
			}
			if (stringBuilder.Length != 0)
			{
				return stringBuilder.ToString();
			}
			return "file";
		}

		public static void MoveFileToTrashBin(string path, string fileName)
		{
			if (File.Exists(path))
			{
				fileName = GetPathSafeString(fileName);
				string destFileName = TurnToUniquePath(Path.Combine(trashBinDir, fileName));
				File.Move(path, destFileName);
			}
		}

		public static void CopyFileToResetBin(string path, string fileName)
		{
			if (File.Exists(path))
			{
				fileName = GetPathSafeString(fileName);
				string destFileName = TurnToUniquePath(Path.Combine(resetBinDir, fileName));
				File.Copy(path, destFileName);
			}
		}
	}
	public class PluginConfigurator
	{
		internal class Preset
		{
			public readonly PluginConfigurator rootConfig;

			public string name;

			public string filePath;

			public string fileId;

			public int listIndex;

			public ConfigCustomPresetField currentUI;

			public bool markedForDelete;

			public Preset(PluginConfigurator config)
			{
				rootConfig = config;
			}

			public void SetButtonColor()
			{
				//IL_002f: 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_0034: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)currentUI == (Object)null))
				{
					((Selectable)currentUI.preset).colors = GetButtonColor((rootConfig.currentPreset == this) ? Color.red : Color.white);
				}
			}

			public void SetResetInteractable()
			{
				if (!((Object)(object)currentUI == (Object)null))
				{
					((Selectable)currentUI.reset).interactable = rootConfig.currentPreset == this;
				}
			}

			public void CreateUI()
			{
				//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_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Expected O, but got Unknown
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Expected O, but got Unknown
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Expected O, but got Unknown
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Expected O, but got Unknown
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Expected O, but got Unknown
				//IL_014f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Expected O, but got Unknown
				if ((Object)(object)currentUI != (Object)null)
				{
					return;
				}
				currentUI = Addressables.InstantiateAsync((object)"PluginConfigurator/CustomPresetButton.prefab", rootConfig.presetPanel.content, false, true).WaitForCompletion().GetComponent<ConfigCustomPresetField>();
				currentUI.nameInput.SetTextWithoutNotify(name);
				((UnityEvent)currentUI.preset.onClick).AddListener((UnityAction)delegate
				{
					if (rootConfig.currentPreset != this)
					{
						rootConfig.ChangePreset(this);
					}
				});
				((Selectable)currentUI.reset).interactable = rootConfig.currentPreset == this;
				((UnityEvent)currentUI.reset.onClick).AddListener((UnityAction)delegate
				{
					if (rootConfig.currentPreset != this)
					{
						((Selectable)currentUI.reset).interactable = false;
					}
					else
					{
						rootConfig.ResetPreset(this);
					}
				});
				((UnityEvent)currentUI.edit.onClick).AddListener((UnityAction)delegate
				{
					((Selectable)currentUI.nameInput).interactable = true;
					((Selectable)currentUI.nameInput).Select();
				});
				((UnityEvent<string>)(object)currentUI.nameInput.onEndEdit).AddListener((UnityAction<string>)delegate(string newVal)
				{
					((Selectable)currentUI.nameInput).interactable = false;
					if (!(name == newVal))
					{
						rootConfig.isPresetHeaderDirty = true;
						name = newVal;
						currentUI.nameInput.SetTextWithoutNotify(newVal);
					}
				});
				((UnityEvent)currentUI.delete.onClick).AddListener((UnityAction)delegate
				{
					rootConfig.DeletePreset(this);
				});
				((UnityEvent)currentUI.moveUp.onClick).AddListener((UnityAction)delegate
				{
					if (((Component)currentUI).transform.GetSiblingIndex() > 1)
					{
						((Component)currentUI).transform.SetSiblingIndex(((Component)currentUI).transform.GetSiblingIndex() - 1);
						rootConfig.SetPresetIndexFromUi();
					}
				});
				((UnityEvent)currentUI.moveDown.onClick).AddListener((UnityAction)delegate
				{
					if (((Component)currentUI).transform.GetSiblingIndex() < ((Component)currentUI).transform.parent.childCount - 2)
					{
						((Component)currentUI).transform.SetSiblingIndex(((Component)currentUI).transform.GetSiblingIndex() + 1);
						rootConfig.SetPresetIndexFromUi();
					}
				});
				SetButtonColor();
			}

			public int GetListIndexFromUI()
			{
				if (!((Object)(object)currentUI == (Object)null))
				{
					return ((Component)currentUI).transform.GetSiblingIndex() - 1;
				}
				return listIndex;
			}
		}

		public delegate void PreConfigChangeEvent();

		public delegate void PostConfigChangeEvent();

		public delegate void PrePresetChangeEvent(string presetIdBefore, string presetIdAfter);

		public delegate void PostPresetChangeEvent(string presetIdBefore, string presetIdAfter);

		public delegate void PrePresetResetEvent(string presetId);

		public delegate void PostPresetResetEvent(string presetId);

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Preset, int> <>9__80_0;

			public static Func<KeyValuePair<int, List<ConfigField>>, int> <>9__85_0;

			public static Func<KeyValuePair<int, List<ConfigField>>, List<ConfigField>> <>9__85_1;

			public static Func<KeyValuePair<int, List<ConfigField>>, int> <>9__86_0;

			public static Func<KeyValuePair<int, List<ConfigField>>, List<ConfigField>> <>9__86_1;

			public static Func<Preset, bool> <>9__117_0;

			public static UnityAction <>9__127_0;

			internal int <ReorderAllPresetsFromId>b__80_0(Preset p)
			{
				return p.listIndex;
			}

			internal int <ChangePreset>b__85_0(KeyValuePair<int, List<ConfigField>> i)
			{
				return i.Key;
			}

			internal List<ConfigField> <ChangePreset>b__85_1(KeyValuePair<int, List<ConfigField>> i)
			{
				return i.Value;
			}

			internal int <ResetPreset>b__86_0(KeyValuePair<int, List<ConfigField>> i)
			{
				return i.Key;
			}

			internal List<ConfigField> <ResetPreset>b__86_1(KeyValuePair<int, List<ConfigField>> i)
			{
				return i.Value;
			}

			internal bool <FlushPresets>b__117_0(Preset preset)
			{
				return !preset.markedForDelete;
			}

			internal void <CreateUI>b__127_0()
			{
				((Component)PluginConfiguratorController.mainPanel).gameObject.SetActive(false);
			}
		}

		private const string ASSET_PATH_PRESET_BUTTON = "PluginConfigurator/PresetButton.prefab";

		private const string ASSET_PATH_PRESET_PANEL = "PluginConfigurator/PresetPanel.prefab";

		private const string ASSET_PATH_PRESET_ADD_BUTTON = "PluginConfigurator/PresetAddButton.prefab";

		private const string ASSET_PATH_DEFAULT_PRESET_BUTTON = "PluginConfigurator/DefaultPresetButton.prefab";

		private const string ASSET_PATH_CUSTOM_PRESET_BUTTON = "PluginConfigurator/CustomPresetButton.prefab";

		private string _displayName;

		private bool _hidden;

		private bool _interactable = true;

		private Sprite _image;

		private bool _presetButtonHidden;

		private bool _presetButtonInteractable = true;

		internal bool presetButtonCanBeShown;

		internal ConfigPluginMenuField configMenu;

		internal ConfigButtonField presetMenuButton;

		internal ConfigPresetPanelField presetPanel;

		internal ConfigDefaultPresetButtonField defaultPresetButton;

		internal ConfigButtonField addPresetButton;

		internal bool isDirty;

		internal Dictionary<string, string> config = new Dictionary<string, string>();

		internal Dictionary<string, ConfigField> fields = new Dictionary<string, ConfigField>();

		internal bool isPresetHeaderDirty;

		internal List<Preset> presets = new List<Preset>();

		private Preset currentPreset;

		public bool saveToFile = true;

		public string displayName
		{
			get
			{
				return _displayName;
			}
			set
			{
				_displayName = value;
				if ((Object)(object)configMenu != (Object)null)
				{
					((TMP_Text)configMenu.name).text = _displayName;
				}
			}
		}

		public string guid { get; private set; }

		public ConfigPanel rootPanel { get; private set; }

		public bool hidden
		{
			get
			{
				return _hidden;
			}
			set
			{
				_hidden = value;
				if ((Object)(object)configMenu != (Object)null)
				{
					((Component)configMenu).gameObject.SetActive(!value);
				}
			}
		}

		public bool interactable
		{
			get
			{
				return _interactable;
			}
			set
			{
				_interactable = value;
				if ((Object)(object)configMenu != (Object)null)
				{
					((Selectable)configMenu.button).interactable = value;
				}
			}
		}

		public Sprite image
		{
			get
			{
				return _image;
			}
			set
			{
				_image = value;
				if ((Object)(object)configMenu != (Object)null)
				{
					configMenu.icon.sprite = _image ?? PluginConfiguratorController.defaultPluginIcon;
				}
			}
		}

		public Sprite icon
		{
			get
			{
				return image;
			}
			set
			{
				image = value;
			}
		}

		public bool presetButtonHidden
		{
			get
			{
				return _presetButtonHidden;
			}
			set
			{
				_presetButtonHidden = value;
				if ((Object)(object)presetMenuButton != (Object)null)
				{
					((Component)presetMenuButton).gameObject.SetActive(presetButtonCanBeShown && !_presetButtonHidden);
				}
			}
		}

		public bool presetButtonInteractable
		{
			get
			{
				return _presetButtonInteractable;
			}
			set
			{
				_presetButtonInteractable = value;
				if ((Object)(object)presetMenuButton != (Object)null)
				{
					((Selectable)presetMenuButton.button).interactable = value;
				}
			}
		}

		public string currentPresetName
		{
			get
			{
				if (currentPreset != null)
				{
					return currentPreset.name;
				}
				return null;
			}
		}

		public string currentPresetId
		{
			get
			{
				if (currentPreset != null)
				{
					return currentPreset.fileId;
				}
				return null;
			}
		}

		public string defaultConfigFilePath => Path.Combine(Paths.ConfigPath, "PluginConfigurator", guid + ".config");

		public string currentConfigFilePath
		{
			get
			{
				if (currentPreset != null)
				{
					return currentPreset.filePath;
				}
				return defaultConfigFilePath;
			}
		}

		public string configFolderPath => Path.Combine(Paths.ConfigPath, "PluginConfigurator");

		public string configPresetsFolderPath => Path.Combine(Paths.ConfigPath, "PluginConfigurator", guid + "_presets");

		public bool changingPreset { get; private set; }

		public bool resetting { get; private set; }

		internal string configPresetsHeaderPath => Path.Combine(Paths.ConfigPath, "PluginConfigurator", guid + "_presets", "config.txt");

		private string currentPresetHeaderName
		{
			get
			{
				if (currentPreset != null)
				{
					return currentPreset.name;
				}
				return "[Default Config]";
			}
		}

		public bool firstTime { get; private set; }

		public event PreConfigChangeEvent preConfigChange;

		public event PostConfigChangeEvent postConfigChange;

		public event PrePresetChangeEvent prePresetChangeEvent;

		public event PostPresetChangeEvent postPresetChangeEvent;

		public event PrePresetResetEvent prePresetResetEvent;

		public event PostPresetResetEvent postPresetResetEvent;

		public void SetIconWithURL(string url)
		{
			UnityWebRequest iconDownload = UnityWebRequestTexture.GetTexture(url);
			((AsyncOperation)iconDownload.SendWebRequest()).completed += delegate
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (!iconDownload.isHttpError && !iconDownload.isNetworkError)
					{
						Texture2D content = DownloadHandlerTexture.GetContent(iconDownload);
						Sprite val = Sprite.Create(content, new Rect(0f, 0f, (float)((Texture)content).width, (float)((Texture)content).height), new Vector2(0.5f, 0.5f));
						image = val;
					}
				}
				finally
				{
					iconDownload.Dispose();
				}
			};
		}

		private static ColorBlock GetButtonColor(Color clr)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0022: 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_0034: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			ColorBlock defaultColorBlock = ColorBlock.defaultColorBlock;
			((ColorBlock)(ref defaultColorBlock)).normalColor = clr;
			((ColorBlock)(ref defaultColorBlock)).pressedColor = clr * 0.5f;
			((ColorBlock)(ref defaultColorBlock)).selectedColor = clr * 0.7f;
			((ColorBlock)(ref defaultColorBlock)).highlightedColor = clr * 0.6f;
			return defaultColorBlock;
		}

		private Preset CreatePreset(Preset newPreset)
		{
			presets.Add(newPreset);
			if ((Object)(object)presetPanel != (Object)null)
			{
				newPreset.CreateUI();
			}
			isPresetHeaderDirty = true;
			return newPreset;
		}

		private void ReorderAllPresetsFromId()
		{
			if ((Object)(object)presetPanel == (Object)null)
			{
				return;
			}
			((Component)defaultPresetButton).transform.SetSiblingIndex(0);
			int num = 0;
			foreach (Preset item in presets.OrderBy((Preset p) => p.listIndex))
			{
				if ((Object)(object)item.currentUI == (Object)null)
				{
					item.CreateUI();
				}
				((Component)item.currentUI).transform.SetSiblingIndex(num + 1);
				if (item.listIndex != num)
				{
					item.listIndex = num;
					isPresetHeaderDirty = true;
				}
				num++;
			}
			if (isPresetHeaderDirty)
			{
				FlushPresets();
			}
			((Component)addPresetButton).transform.SetAsLastSibling();
		}

		private void RecolorAllPresets()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)presetPanel == (Object)null)
			{
				return;
			}
			((Selectable)defaultPresetButton.button).colors = GetButtonColor((currentPreset == null) ? Color.red : Color.white);
			foreach (Preset preset in presets)
			{
				preset.SetButtonColor();
			}
		}

		private void ResetPresetButtons()
		{
			if ((Object)(object)presetPanel == (Object)null)
			{
				return;
			}
			((Selectable)defaultPresetButton.reset).interactable = currentPreset == null;
			foreach (Preset preset in presets)
			{
				preset.SetResetInteractable();
			}
		}

		private void SetPresetIndexFromUi()
		{
			if ((Object)(object)presetPanel == (Object)null)
			{
				return;
			}
			foreach (Preset preset in presets)
			{
				if ((Object)(object)preset.currentUI == (Object)null)
				{
					preset.CreateUI();
					((Component)preset.currentUI).transform.SetSiblingIndex(((Component)preset.currentUI).transform.parent.childCount - 2);
				}
				int num = ((Component)preset.currentUI).transform.GetSiblingIndex() - 1;
				if (num != preset.listIndex)
				{
					isPresetHeaderDirty = true;
				}
				preset.listIndex = num;
			}
		}

		internal void CreatePresetUI(Transform optionsMenu)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Expected O, but got Unknown
			presetMenuButton = Addressables.InstantiateAsync((object)"PluginConfigurator/PresetButton.prefab", optionsMenu, false, true).WaitForCompletion().GetComponent<ConfigButtonField>();
			((Component)presetMenuButton).gameObject.SetActive(false);
			((TMP_Text)presetMenuButton.text).text = currentPresetHeaderName;
			((Selectable)presetMenuButton.button).interactable = _presetButtonInteractable;
			((UnityEvent)presetMenuButton.button.onClick).AddListener((UnityAction)delegate
			{
				DiscoverNewPresetFiles();
				((Component)presetPanel).gameObject.SetActive(true);
			});
			GameObject val = Addressables.InstantiateAsync((object)"PluginConfigurator/PresetPanel.prefab", optionsMenu, false, true).WaitForCompletion();
			val.SetActive(false);
			presetPanel = val.GetComponent<ConfigPresetPanelField>();
			val.AddComponent<PresetPanelComp>();
			GameObject val2 = Addressables.InstantiateAsync((object)"PluginConfigurator/DefaultPresetButton.prefab", presetPanel.content, false, true).WaitForCompletion();
			defaultPresetButton = val2.GetComponent<ConfigDefaultPresetButtonField>();
			((Selectable)defaultPresetButton.button).colors = GetButtonColor((currentPreset == null) ? Color.red : Color.white);
			((UnityEvent)defaultPresetButton.button.onClick).AddListener((UnityAction)delegate
			{
				ChangePreset(null);
			});
			((Selectable)defaultPresetButton.reset).interactable = currentPreset == null;
			((UnityEvent)defaultPresetButton.reset.onClick).AddListener((UnityAction)delegate
			{
				ResetPreset(null);
			});
			foreach (Preset preset2 in presets)
			{
				preset2.CreateUI();
			}
			addPresetButton = Addressables.InstantiateAsync((object)"PluginConfigurator/PresetAddButton.prefab", presetPanel.content, false, true).WaitForCompletion().GetComponent<ConfigButtonField>();
			((UnityEvent)addPresetButton.button.onClick).AddListener((UnityAction)delegate
			{
				string name = "Copy of " + currentPresetName;
				if (currentPreset == null)
				{
					name = "Copy of Default Config";
				}
				string text = Guid.NewGuid().ToString();
				string text2 = currentConfigFilePath;
				string text3 = Path.Combine(configPresetsFolderPath, text + ".config");
				if (!Directory.Exists(configPresetsFolderPath))
				{
					Directory.CreateDirectory(configPresetsFolderPath);
				}
				if (File.Exists(text2))
				{
					File.Copy(text2, text3);
				}
				Preset preset = CreatePreset(new Preset(this)
				{
					name = name,
					fileId = text,
					filePath = text3,
					listIndex = ((Component)addPresetButton).transform.GetSiblingIndex() - 1
				});
				((Component)preset.currentUI).transform.SetSiblingIndex(preset.listIndex + 1);
			});
			ReorderAllPresetsFromId();
			((UnityEvent)presetPanel.export.onClick).AddListener((UnityAction)delegate
			{
				ExportCurrentPreset();
			});
			((UnityEvent)presetPanel.openFolder.onClick).AddListener((UnityAction)delegate
			{
				Application.OpenURL(configPresetsFolderPath);
			});
		}

		private void ChangePreset(Preset newPreset)
		{
			if (newPreset == currentPreset)
			{
				return;
			}
			changingPreset = true;
			string presetIdBefore = ((currentPreset == null) ? null : currentPreset.fileId);
			string presetIdAfter = newPreset?.fileId;
			if (this.prePresetChangeEvent != null)
			{
				try
				{
					this.prePresetChangeEvent(presetIdBefore, presetIdAfter);
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"Exception thrown while calling pre preset change event for {guid}:\n{arg}");
				}
			}
			FlushAll();
			currentPreset = newPreset;
			if ((Object)(object)presetMenuButton != (Object)null)
			{
				((TMP_Text)presetMenuButton.text).text = currentPresetHeaderName;
			}
			RecolorAllPresets();
			ResetPresetButtons();
			config.Clear();
			string text = currentConfigFilePath;
			if (File.Exists(text))
			{
				PluginConfiguratorController.logger.LogInfo((object)("Loading preset from " + text));
				using StreamReader streamReader = File.OpenText(text);
				while (!streamReader.EndOfStream)
				{
					string text2 = streamReader.ReadLine();
					if (string.IsNullOrEmpty(text2))
					{
						break;
					}
					string text3 = streamReader.ReadLine();
					if (text3 == null)
					{
						text3 = "";
					}
					config[text2] = text3;
				}
			}
			Dictionary<int, List<ConfigField>> dictionary = new Dictionary<int, List<ConfigField>>();
			foreach (ConfigField value4 in fields.Values)
			{
				if (dictionary.TryGetValue(value4.presetLoadPriority, out var value))
				{
					value.Add(value4);
					continue;
				}
				dictionary.Add(value4.presetLoadPriority, new List<ConfigField> { value4 });
			}
			List<KeyValuePair<int, List<ConfigField>>> source = dictionary.ToList();
			bool flag = false;
			foreach (List<ConfigField> item in from i in source
				orderby i.Key descending
				select i.Value)
			{
				foreach (ConfigField item2 in item)
				{
					if (config.TryGetValue(item2.guid, out var value2))
					{
						try
						{
							item2.ReloadFromString(value2);
						}
						catch (Exception arg2)
						{
							Debug.LogError((object)$"Exception thrown while changing preset (thrown by {item2.guid})\n{arg2}");
						}
						if (!flag && (!config.TryGetValue(item2.guid, out var value3) || value2 != value3))
						{
							flag = true;
						}
					}
					else
					{
						flag = true;
						item2.ReloadDefault();
					}
				}
			}
			changingPreset = false;
			isDirty = flag;
			isPresetHeaderDirty = true;
			if (this.postPresetChangeEvent != null)
			{
				try
				{
					this.postPresetChangeEvent(presetIdBefore, presetIdAfter);
				}
				catch (Exception arg3)
				{
					Debug.LogError((object)$"Exception thrown while calling pre preset change event for {guid}:\n{arg3}");
				}
			}
			FlushAll();
		}

		private void ResetPreset(Preset preset)
		{
			if (preset != currentPreset)
			{
				if ((Object)(object)presetPanel != (Object)null)
				{
					if (preset == null)
					{
						((Selectable)defaultPresetButton.reset).interactable = false;
					}
					else
					{
						((Selectable)preset.currentUI.reset).interactable = false;
					}
				}
				return;
			}
			PresetOldFileManager.CopyFileToResetBin(currentConfigFilePath, $"{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}_{guid}_{currentPresetName}.config");
			resetting = true;
			string presetId = ((currentPreset == null) ? null : currentPreset.fileId);
			if (this.prePresetResetEvent != null)
			{
				try
				{
					this.prePresetResetEvent(presetId);
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"Exception thrown while calling pre preset reset event\n{arg}");
				}
			}
			config.Clear();
			Dictionary<int, List<ConfigField>> dictionary = new Dictionary<int, List<ConfigField>>();
			foreach (ConfigField value2 in fields.Values)
			{
				if (dictionary.TryGetValue(value2.presetLoadPriority, out var value))
				{
					value.Add(value2);
					continue;
				}
				dictionary.Add(value2.presetLoadPriority, new List<ConfigField> { value2 });
			}
			foreach (List<ConfigField> item in from i in dictionary.ToList()
				orderby i.Key descending
				select i.Value)
			{
				foreach (ConfigField item2 in item)
				{
					try
					{
						item2.ReloadDefault();
					}
					catch (Exception arg2)
					{
						Debug.LogError((object)$"Exception thrown while resetting field {item2.guid}\n{arg2}");
					}
				}
			}
			resetting = false;
			if (this.postPresetResetEvent != null)
			{
				try
				{
					this.postPresetResetEvent(presetId);
				}
				catch (Exception arg3)
				{
					Debug.LogError((object)$"Exception thrown while calling pre preset reset event\n{arg3}");
				}
			}
			FlushAll();
		}

		private void DeletePreset(Preset preset)
		{
			if (preset == currentPreset)
			{
				ChangePreset(null);
			}
			presets.Remove(preset);
			if ((Object)(object)preset.currentUI != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)preset.currentUI).gameObject);
			}
			if (File.Exists(preset.filePath))
			{
				try
				{
					PresetOldFileManager.MoveFileToTrashBin(preset.filePath, $"{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}_{guid}_{preset.name}.config");
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"Exception thrown while trying to delete preset:\n{arg}");
				}
			}
			isPresetHeaderDirty = true;
			FlushPresets();
		}

		public bool DeletePreset(string presetID)
		{
			Preset preset = presets.Where((Preset preset2) => preset2.fileId == presetID).FirstOrDefault();
			if (preset == null)
			{
				return false;
			}
			DeletePreset(preset);
			return true;
		}

		private void DiscoverNewPresetFiles()
		{
			if (!Directory.Exists(configPresetsFolderPath))
			{
				Directory.CreateDirectory(configPresetsFolderPath);
				return;
			}
			string text = configPresetsHeaderPath;
			string[] files = Directory.GetFiles(configPresetsFolderPath);
			foreach (string text2 in files)
			{
				if (!(text2 == text) && text2.EndsWith(".config"))
				{
					string fileID = Path.GetFileNameWithoutExtension(text2);
					if (!string.IsNullOrWhiteSpace(fileID) && !presets.Where((Preset p) => p.fileId == fileID).Any())
					{
						CreatePreset(new Preset(this)
						{
							filePath = text2,
							fileId = fileID,
							listIndex = presets.Count,
							name = fileID
						});
					}
				}
			}
		}

		private void Init_LoadPresets()
		{
			presets.Clear();
			currentPreset = null;
			if (!Directory.Exists(configPresetsFolderPath))
			{
				Directory.CreateDirectory(configPresetsFolderPath);
			}
			if (!File.Exists(configPresetsHeaderPath))
			{
				using StreamWriter streamWriter = new StreamWriter(File.Open(configPresetsHeaderPath, FileMode.Create, FileAccess.Write));
				streamWriter.WriteLine("");
			}
			else
			{
				string currentPresetPath = "";
				using (StreamReader streamReader = File.OpenText(configPresetsHeaderPath))
				{
					currentPresetPath = streamReader.ReadLine();
					if (currentPresetPath == null)
					{
						Debug.LogWarning((object)("Invalid preset config for " + guid));
						currentPresetPath = "";
						currentPreset = null;
					}
					while (!streamReader.EndOfStream)
					{
						string id = streamReader.ReadLine();
						if (id == null)
						{
							break;
						}
						string text = streamReader.ReadLine();
						if (text == null)
						{
							Debug.LogWarning((object)("Invalid preset config ending for " + guid));
							break;
						}
						string text2 = streamReader.ReadLine();
						if (text2 == null)
						{
							Debug.LogWarning((object)("Invalid preset config ending for " + guid));
							break;
						}
						if (!int.TryParse(text2, out var result))
						{
							Debug.LogWarning((object)("Invalid list index for " + guid + ":" + id + ":" + text));
							result = 0;
						}
						if (!presets.Where((Preset p) => p.fileId == id).Any())
						{
							CreatePreset(new Preset(this)
							{
								fileId = id,
								filePath = Path.Combine(configPresetsFolderPath, id + ".config"),
								listIndex = result,
								name = text
							});
						}
					}
				}
				if (currentPresetPath == "" || string.IsNullOrWhiteSpace(currentPresetPath))
				{
					currentPreset = null;
				}
				else
				{
					currentPreset = presets.Find((Preset preset) => preset.fileId == currentPresetPath);
					if (currentPreset == null)
					{
						Debug.LogWarning((object)("Could not find preset with id " + guid + ":" + currentPresetPath));
					}
				}
			}
			DiscoverNewPresetFiles();
		}

		private void Init_LoadFromFile()
		{
			string path = configFolderPath;
			if (!Directory.Exists(path))
			{
				Directory.CreateDirectory(path);
			}
			string path2 = currentConfigFilePath;
			if (!File.Exists(defaultConfigFilePath))
			{
				File.Create(path2).Close();
				return;
			}
			using StreamReader streamReader = File.OpenText(path2);
			while (!streamReader.EndOfStream)
			{
				string text = streamReader.ReadLine();
				if (text == null || string.IsNullOrEmpty(text))
				{
					break;
				}
				string text2 = streamReader.ReadLine();
				if (text2 == null)
				{
					text2 = "";
				}
				config[text] = text2;
			}
		}

		private void FlushPresets()
		{
			if (!isPresetHeaderDirty)
			{
				return;
			}
			if (!Directory.Exists(configPresetsFolderPath))
			{
				Directory.CreateDirectory(configPresetsFolderPath);
			}
			string path = configPresetsHeaderPath;
			if (!File.Exists(path))
			{
				File.Create(path).Close();
			}
			using (StreamWriter streamWriter = new StreamWriter(File.Open(path, FileMode.Truncate)))
			{
				streamWriter.WriteLine((currentPreset == null) ? "" : currentPreset.fileId);
				foreach (Preset preset in presets)
				{
					if (preset.markedForDelete)
					{
						if (File.Exists(preset.filePath))
						{
							try
							{
								File.Delete(preset.filePath);
							}
							catch (Exception ex)
							{
								Debug.LogError((object)ex.ToString());
							}
						}
					}
					else
					{
						streamWriter.WriteLine(preset.fileId);
						streamWriter.WriteLine(preset.name);
						streamWriter.WriteLine(preset.GetListIndexFromUI());
					}
				}
			}
			presets = presets.Where((Preset preset) => !preset.markedForDelete).ToList();
			isPresetHeaderDirty = false;
		}

		public void FlushAll()
		{
			FlushPresets();
			Flush();
		}

		public void Flush()
		{
			if (!isDirty)
			{
				return;
			}
			if (this.preConfigChange != null)
			{
				try
				{
					this.preConfigChange();
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"Pre config event for {guid} threw an error: {arg}");
				}
			}
			if (!saveToFile)
			{
				try
				{
					if (this.postConfigChange != null)
					{
						this.postConfigChange();
					}
					return;
				}
				catch (Exception arg2)
				{
					Debug.LogError((object)$"Post config event for {guid} threw an error: {arg2}");
					return;
				}
			}
			PluginConfiguratorController.logger.LogInfo((object)("Dirty config detected. Saving configuration for " + displayName + " : " + guid));
			string text = currentConfigFilePath;
			if (!Directory.Exists(configFolderPath))
			{
				Directory.CreateDirectory(configFolderPath);
			}
			if (!Directory.Exists(configPresetsFolderPath))
			{
				Directory.CreateDirectory(configPresetsFolderPath);
			}
			if (!File.Exists(text))
			{
				File.Create(text).Close();
			}
			PluginConfiguratorController.logger.LogInfo((object)("Saving to " + text));
			using (StreamWriter streamWriter = new StreamWriter(File.Open(text, FileMode.Truncate)))
			{
				foreach (KeyValuePair<string, string> item in config)
				{
					if (item.Key != null)
					{
						streamWriter.WriteLine(item.Key);
						streamWriter.WriteLine((item.Value == null) ? "" : item.V

plugins/PluginConfigurator/PluginConfiguratorComponents.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PluginConfiguratorComponents")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3e28133839bfd4163d7147029d15fd04f73bdbc5")]
[assembly: AssemblyProduct("PluginConfiguratorComponents")]
[assembly: AssemblyTitle("PluginConfiguratorComponents")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PluginConfiguratorComponents;

public class ConfigButtonField : MonoBehaviour
{
	public TextMeshProUGUI text;

	public Button button;

	public RectTransform rect;
}
public class ConfigColorField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public Image fieldBg;

	public Image image;

	public Slider red;

	public Slider green;

	public Slider blue;

	public TMP_InputField redInput;

	public TMP_InputField greenInput;

	public TMP_InputField blueInput;

	public Button resetButton;

	public void SliderSetR(float newR)
	{
		redInput.SetTextWithoutNotify(((int)(red.normalizedValue * 255f)).ToString());
		SetColor();
	}

	public void SliderSetG(float newG)
	{
		greenInput.SetTextWithoutNotify(((int)(green.normalizedValue * 255f)).ToString());
		SetColor();
	}

	public void SliderSetB(float newB)
	{
		blueInput.SetTextWithoutNotify(((int)(blue.normalizedValue * 255f)).ToString());
		SetColor();
	}

	public void SetColor()
	{
		SetColor(red.value, green.value, blue.value);
	}

	public void SetColor(float newR, float newG, float newB)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		((Graphic)image).color = new Color(newR, newG, newB);
	}
}
public class ConfigCustomPresetField : MonoBehaviour
{
	public Button preset;

	public TMP_InputField nameInput;

	public Button reset;

	public Button edit;

	public Button delete;

	public Button moveUp;

	public Button moveDown;
}
public class ConfigDefaultPresetButtonField : MonoBehaviour
{
	public Button button;

	public Button reset;
}
public class ConfigDropdownField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public TMP_Dropdown dropdown;

	public Image fieldBg;

	public Button resetButton;
}
public class ConfigFormattedInputField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public TMP_InputField input;

	public TextMeshProUGUI text;

	public Button edit;

	public Image fieldBg;

	public Button reset;
}
public class ConfigFormattedStringEditorField : MonoBehaviour
{
	public MenuEsc menuEsc;

	public InputField input;

	public Text displayText;

	public Text formattedText;

	public Image preview;

	public Slider redSlider;

	public Slider greenSlider;

	public Slider blueSlider;

	public TMP_InputField redInput;

	public TMP_InputField greenInput;

	public TMP_InputField blueInput;

	public Toggle bold;

	public Toggle italic;

	public void SetRed(float val)
	{
		redInput.SetTextWithoutNotify(((int)(redSlider.normalizedValue * 255f)).ToString());
		SetColor();
	}

	public void SetGreen(float val)
	{
		greenInput.SetTextWithoutNotify(((int)(greenSlider.normalizedValue * 255f)).ToString());
		SetColor();
	}

	public void SetBlue(float val)
	{
		blueInput.SetTextWithoutNotify(((int)(blueSlider.normalizedValue * 255f)).ToString());
		SetColor();
	}

	public void SetColor()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		Color color = default(Color);
		((Color)(ref color))..ctor(redSlider.normalizedValue, greenSlider.normalizedValue, blueSlider.normalizedValue);
		((Graphic)preview).color = color;
	}
}
public class ConfigHeaderField : MonoBehaviour
{
	public RectTransform rect;

	public TextMeshProUGUI text;
}
public class ConfigInputField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public TMP_InputField input;

	public Image fieldBg;

	public Button resetButton;
}
public class ConfigKeycodeField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public Button keycode;

	public TextMeshProUGUI keycodeText;

	public Image fieldBg;

	public Button resetButton;
}
public class ConfigMenuField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public Button button;

	public Image fieldBg;

	public TextMeshProUGUI buttonText;

	public Image icon;
}
public class ConfigPanelConcrete : MonoBehaviour
{
	public TextMeshProUGUI header;

	public VerticalLayoutGroup layout;

	public RectTransform trans;

	public ScrollRect rect;

	public Transform content;

	public ContentSizeFitter contentSizeFitter;
}
public class ConfigPanelField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public Button button;

	public Image icon;
}
public class ConfigPanelVirtual : MonoBehaviour
{
	public VerticalLayoutGroup layout;

	public RectTransform trans;

	public ContentSizeFitter contentSizeFitter;

	public Transform content;
}
public class ConfigPluginMenuField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public Image icon;

	public Button button;
}
public class ConfigPresetPanelField : MonoBehaviour
{
	public Transform content;

	public ScrollRect rect;

	public Button export;

	public Button openFolder;
}
public class ConfigSliderField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public Slider slider;

	public Button resetButton;
}
public class ConfigToggleField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public Toggle toggle;

	public Image checkmark;

	public Image fieldBg;

	public Button resetButton;
}
public class ConfigValueSliderField : MonoBehaviour
{
	public TextMeshProUGUI name;

	public Slider slider;

	public TMP_InputField input;

	public Image fieldBg;

	public Button resetButton;
}
public class DisableWhenHidden : MonoBehaviour
{
	private void OnDisable()
	{
		((Component)this).gameObject.SetActive(false);
	}
}