Decompiled source of UltraUnlock v2.0.1

UltraUnlock.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.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UltraUnlock")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("ULTRAKILL-styled launcher UI for UltraUnlock.")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1")]
[assembly: AssemblyProduct("UltraUnlock")]
[assembly: AssemblyTitle("UltraUnlock")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.1.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 SilentSmilee.ULTRAKILL.UltraUnlock
{
	[BepInPlugin("com.silentsmilee.ultraunlock", "UltraUnlock", "2.0.1")]
	[BepInProcess("ULTRAKILL.exe")]
	public sealed class UltraUnlock : BaseUnityPlugin
	{
		private enum Screen
		{
			Home,
			SaveSlot,
			BackupPrompt,
			BackupBrowser,
			MassBackupContents,
			RestoreConfirmation,
			DeleteBackupConfirmation,
			BackupResult,
			Unlock,
			Advanced,
			UnlockConfirmation,
			DontUnlockConfirmation,
			CalibrationConfirmation,
			Result
		}

		[HarmonyPatch(typeof(SceneHelper), "LoadScene")]
		private static class SceneLoadPatch
		{
			[HarmonyPrefix]
			private static bool Prefix(string __0)
			{
				if (!_modActive)
				{
					return true;
				}
				_pendingScene = __0;
				return false;
			}
		}

		public const string PluginGuid = "com.silentsmilee.ultraunlock";

		public const string PluginName = "UltraUnlock";

		public const string PluginVersion = "2.0.1";

		private static bool _modActive;

		private static string _pendingScene;

		private Harmony _harmony;

		private ConfigEntry<bool> _showOnStartup;

		private GameObject _overlayRoot;

		private GameObject _optionsStartupToggle;

		private GameObject _optionsReenabledPrompt;

		private RectTransform _content;

		private TMP_FontAsset _font;

		private Sprite _borderLarge;

		private Sprite _fillLarge;

		private Sprite _pausePanelFill;

		private Sprite _borderSmall;

		private Sprite _checkmark;

		private Sprite _folderIcon;

		private Texture2D _circuitTexture;

		private RawImage _circuitBackground;

		private bool _built;

		private bool _initialPanelAnimationPending = true;

		private int _selectedSlot = -1;

		private bool _selectedSlotExists;

		private UltraUnlockBackupInfo _selectedBackup;

		private UltraUnlockMassBackupInfo _selectedMassBackup;

		private bool _backupResultSucceeded;

		private string _backupResultMessage = string.Empty;

		private string _backupResultTitle = "BACKUP";

		private Screen _backupResultReturnScreen;

		private Screen _backupResultSuccessScreen;

		private Screen _restoreReturnScreen = Screen.BackupBrowser;

		private string _unlockNotice = string.Empty;

		private int _backedUpSlotIndex = -1;

		private UltraUnlockRequest _pendingUnlockRequest;

		private Screen _pendingUnlockReturnScreen = Screen.Unlock;

		private bool _bestiary;

		private bool _collectables;

		private bool _weapons;

		private bool _arms;

		private bool _sandbox;

		private bool _pRankAll;

		private bool _cyberGrind;

		private int _cyberGrindScore;

		private bool _lastUnlockSucceeded;

		private string _lastUnlockMessage = string.Empty;

		private Screen _resultReturnScreen = Screen.Unlock;

		private static readonly Color PausePanelColor = new Color(0f, 0f, 0f, 40f / 51f);

		private static readonly Color PauseFrameColor = new Color(0f, 0f, 0f, 0.78039217f);

		private static readonly Color ButtonHighlight = new Color(26f / 51f, 26f / 51f, 26f / 51f, 1f);

		private static readonly Color ButtonPressed = Color.red;

		private static readonly Color ButtonDisabled = new Color(40f / 51f, 40f / 51f, 40f / 51f, 0.5019608f);

		private const float UiPixelsPerUnitMultiplier = 5.4f;

		private const float InitialPanelAnimationDelay = 1.1f;

		private const float InitialPanelAnimationSpeed = 14f;

		private void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			_modActive = false;
			UltraUnlockCyberGrindSafety.Initialize(((BaseUnityPlugin)this).Logger);
			_showOnStartup = ((BaseUnityPlugin)this).Config.Bind<bool>("Startup", "ShowUltraUnlock", true, "Show the UltraUnlock when ULTRAKILL starts. This can also be changed in the Options menu.");
			SceneManager.sceneLoaded += OnSceneLoaded;
			_harmony = new Harmony("com.silentsmilee.ultraunlock");
			_harmony.PatchAll(typeof(UltraUnlock).Assembly);
			if (_showOnStartup.Value)
			{
				_modActive = true;
				Time.timeScale = 0f;
				AudioListener.pause = true;
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}

		private void Start()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			UltraUnlockCyberGrindSafety.OnSceneLoaded(SceneManager.GetActiveScene());
			((MonoBehaviour)this).StartCoroutine(InstallOptionsStartupToggle(SceneManager.GetActiveScene()));
			if (_modActive)
			{
				BuildOverlayIfNeeded();
			}
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (!_modActive)
			{
				return;
			}
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
			if ((Object)(object)_circuitBackground != (Object)null)
			{
				Rect uvRect = _circuitBackground.uvRect;
				((Rect)(ref uvRect)).y = ((Rect)(ref uvRect)).y - 0.1f * Time.unscaledDeltaTime;
				if (((Rect)(ref uvRect)).y <= -1f)
				{
					((Rect)(ref uvRect)).y = ((Rect)(ref uvRect)).y + 1f;
				}
				_circuitBackground.uvRect = uvRect;
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0000: 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)
			UltraUnlockCyberGrindSafety.OnSceneLoaded(scene);
			((MonoBehaviour)this).StartCoroutine(InstallOptionsStartupToggle(scene));
			if (_modActive)
			{
				BuildOverlayIfNeeded();
			}
		}

		private void BuildOverlayIfNeeded()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			if (!_built)
			{
				LoadThemeAssets();
				EnsureEventSystem();
				_overlayRoot = new GameObject("UltraUnlock_Overlay");
				Object.DontDestroyOnLoad((Object)(object)_overlayRoot);
				Canvas obj = _overlayRoot.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 32767;
				CanvasScaler obj2 = _overlayRoot.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 0.5f;
				_overlayRoot.AddComponent<GraphicRaycaster>();
				RectTransform val = MakeRect(_overlayRoot.transform, "Backdrop");
				Stretch(val);
				((Graphic)AddImage(((Component)val).gameObject, null, Color.black, sliced: false)).raycastTarget = false;
				RectTransform val2 = MakeRect((Transform)(object)val, "CircuitBackground");
				Stretch(val2);
				_circuitBackground = ((Component)val2).gameObject.AddComponent<RawImage>();
				_circuitBackground.texture = (Texture)(object)_circuitTexture;
				((Graphic)_circuitBackground).color = new Color(0.25f, 0.25f, 0.25f, 1f);
				_circuitBackground.uvRect = new Rect(0f, 0f, 3f, 3f);
				((Graphic)_circuitBackground).raycastTarget = false;
				_content = MakeRect((Transform)(object)val, "Content");
				Stretch(_content);
				_built = true;
				ShowScreen(Screen.Home);
			}
		}

		private void LoadThemeAssets()
		{
			_borderLarge = LoadSprite("UltraUnlock.Assets.Round_BorderLarge.png", "Round_BorderLarge", 41f);
			_fillLarge = LoadSprite("UltraUnlock.Assets.Round_FillLarge.png", "Round_FillLarge", 37f);
			_pausePanelFill = LoadSprite("UltraUnlock.Assets.Round_VertHandle_Invert_1.png", "Round_VertHandle_Invert 1", 117f);
			_borderSmall = LoadSprite("UltraUnlock.Assets.Round_BorderSmall.png", "Round_BorderSmall", 29f);
			_checkmark = LoadSprite("UltraUnlock.Assets.Check.png", "Check", 0f);
			_folderIcon = LoadSprite("UltraUnlock.Assets.SmileOsFolder.png", "smileOS 2 folder", 0f);
			_circuitTexture = LoadTexture("UltraUnlock.Assets.TextmodeCircuit.png", "TextmodeCircuit", repeat: true);
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			foreach (TMP_FontAsset val in array)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name == "VCR_OSD_MONO_1")
				{
					_font = val;
					break;
				}
			}
			if ((Object)(object)_font == (Object)null)
			{
				array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				foreach (TMP_FontAsset val2 in array)
				{
					if ((Object)(object)val2 != (Object)null && ((Object)val2).name.Contains("VCR_OSD"))
					{
						_font = val2;
						break;
					}
				}
			}
			if ((Object)(object)_font == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"UltraUnlock could not find VCR_OSD_MONO_1; TextMesh Pro will use its current default font.");
			}
		}

		private Sprite LoadSprite(string resourceName, string spriteName, float border)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = LoadTexture(resourceName, spriteName, repeat: false);
			Vector4 val2 = default(Vector4);
			((Vector4)(ref val2))..ctor(border, border, border, border);
			Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, val2);
			((Object)obj).name = spriteName;
			return obj;
		}

		private static Texture2D LoadTexture(string resourceName, string textureName, bool repeat)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0056: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				throw new InvalidOperationException("Missing embedded UI asset: " + resourceName);
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false))
			{
				throw new InvalidOperationException("Could not decode embedded UI asset: " + resourceName);
			}
			((Object)val).name = textureName;
			((Texture)val).wrapMode = (TextureWrapMode)(!repeat);
			((Texture)val).filterMode = (FilterMode)1;
			return val;
		}

		private static void EnsureEventSystem()
		{
			//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_001e: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Object.FindObjectOfType<EventSystem>() != (Object)null))
			{
				GameObject val = new GameObject("UltraUnlock_EventSystem");
				Object.DontDestroyOnLoad((Object)val);
				val.AddComponent<EventSystem>();
				val.AddComponent<StandaloneInputModule>();
			}
		}

		private IEnumerator InstallOptionsStartupToggle(Scene scene)
		{
			//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)
			if (_showOnStartup == null || _showOnStartup.Value)
			{
				yield break;
			}
			yield return null;
			for (int attempt = 0; attempt < 90; attempt++)
			{
				if ((Object)(object)_optionsStartupToggle != (Object)null)
				{
					break;
				}
				Transform navigationRail = FindOptionsNavigationRail(scene);
				if ((Object)(object)navigationRail == (Object)null)
				{
					yield return null;
					continue;
				}
				Button val = FindPluginConfiguratorButton(navigationRail);
				if ((Object)(object)val == (Object)null && attempt < 10)
				{
					yield return null;
					continue;
				}
				Button val2 = val ?? FindNavigationButtonTemplate(navigationRail);
				if ((Object)(object)val2 == (Object)null)
				{
					yield return null;
					continue;
				}
				_optionsStartupToggle = Object.Instantiate<GameObject>(((Component)val2).gameObject, navigationRail, false);
				((Object)_optionsStartupToggle).name = "UltraUnlockStartupToggle";
				_optionsStartupToggle.SetActive(true);
				Button component = _optionsStartupToggle.GetComponent<Button>();
				component.onClick = new ButtonClickedEvent();
				((UnityEvent)component.onClick).AddListener(new UnityAction(ReenableFromOptions));
				int siblingIndex = (((Object)(object)val != (Object)null) ? ((Component)val).transform.GetSiblingIndex() : 0);
				_optionsStartupToggle.transform.SetSiblingIndex(siblingIndex);
				UpdateOptionsStartupToggleLabel();
				for (int orderingAttempt = 0; orderingAttempt < 30; orderingAttempt++)
				{
					yield return null;
					if ((Object)(object)_optionsStartupToggle == (Object)null)
					{
						yield break;
					}
					val = FindPluginConfiguratorButton(navigationRail);
					if ((Object)(object)val != (Object)null)
					{
						_optionsStartupToggle.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex());
						break;
					}
					_optionsStartupToggle.transform.SetSiblingIndex(0);
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)"");
				break;
			}
		}

		private static Transform FindOptionsNavigationRail(Scene scene)
		{
			if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded)
			{
				return null;
			}
			Transform result = null;
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			foreach (GameObject val in rootGameObjects)
			{
				if (!(((Object)val).name != "Canvas"))
				{
					Transform obj = val.transform.Find("OptionsMenu");
					Transform val2 = ((obj != null) ? obj.Find("Navigation Rail") : null);
					if ((Object)(object)val2 != (Object)null)
					{
						result = val2;
					}
				}
			}
			return result;
		}

		private static Button FindPluginConfiguratorButton(Transform navigationRail)
		{
			for (int i = 0; i < navigationRail.childCount; i++)
			{
				Transform child = navigationRail.GetChild(i);
				Button component = ((Component)child).GetComponent<Button>();
				if ((Object)(object)component == (Object)null || ((Object)child).name == "UltraUnlockStartupToggle")
				{
					continue;
				}
				if (((Object)child).name.Replace(" ", string.Empty).IndexOf("PluginConfigurator", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return component;
				}
				TMP_Text[] componentsInChildren = ((Component)child).GetComponentsInChildren<TMP_Text>(true);
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					string text = componentsInChildren[j].text?.Replace(" ", string.Empty).Replace("\n", string.Empty);
					if (!string.IsNullOrEmpty(text) && text.IndexOf("PLUGINCONFIGURATOR", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return component;
					}
				}
				Text[] componentsInChildren2 = ((Component)child).GetComponentsInChildren<Text>(true);
				for (int j = 0; j < componentsInChildren2.Length; j++)
				{
					string text2 = componentsInChildren2[j].text?.Replace(" ", string.Empty).Replace("\n", string.Empty);
					if (!string.IsNullOrEmpty(text2) && text2.IndexOf("PLUGINCONFIGURATOR", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return component;
					}
				}
			}
			return null;
		}

		private static Button FindNavigationButtonTemplate(Transform navigationRail)
		{
			for (int i = 0; i < navigationRail.childCount; i++)
			{
				Transform child = navigationRail.GetChild(i);
				if (!string.Equals(((Object)child).name, "Back", StringComparison.OrdinalIgnoreCase))
				{
					Button component = ((Component)child).GetComponent<Button>();
					if ((Object)(object)component != (Object)null)
					{
						return component;
					}
				}
			}
			return null;
		}

		private void UpdateOptionsStartupToggleLabel()
		{
			if ((Object)(object)_optionsStartupToggle == (Object)null || _showOnStartup == null)
			{
				return;
			}
			TMP_Text[] componentsInChildren = _optionsStartupToggle.GetComponentsInChildren<TMP_Text>(true);
			if (componentsInChildren.Length != 0)
			{
				componentsInChildren[0].text = "UltUnlock";
				return;
			}
			Text[] componentsInChildren2 = _optionsStartupToggle.GetComponentsInChildren<Text>(true);
			if (componentsInChildren2.Length != 0)
			{
				componentsInChildren2[0].text = "UltUnlock";
			}
		}

		private void ReenableFromOptions()
		{
			SetStartupEnabled(enabled: true);
			if ((Object)(object)_optionsStartupToggle != (Object)null)
			{
				_optionsStartupToggle.SetActive(false);
				Object.Destroy((Object)(object)_optionsStartupToggle);
				_optionsStartupToggle = null;
			}
			ShowOptionsReenabledPrompt();
		}

		private void ShowOptionsReenabledPrompt()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_optionsReenabledPrompt != (Object)null))
			{
				if ((Object)(object)_pausePanelFill == (Object)null || (Object)(object)_borderLarge == (Object)null)
				{
					LoadThemeAssets();
				}
				EnsureEventSystem();
				_optionsReenabledPrompt = new GameObject("UltraUnlock_ReenabledPrompt");
				Canvas obj = _optionsReenabledPrompt.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 32767;
				CanvasScaler obj2 = _optionsReenabledPrompt.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 0.5f;
				_optionsReenabledPrompt.AddComponent<GraphicRaycaster>();
				RectTransform val = MakeRect(_optionsReenabledPrompt.transform, "Backdrop");
				Stretch(val);
				AddImage(((Component)val).gameObject, null, new Color(0f, 0f, 0f, 0.72f), sliced: false);
				RectTransform val2 = MakeRect((Transform)(object)val, "ReenabledPanel");
				Anchor(val2, new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(620f, 260f));
				AddImage(((Component)val2).gameObject, _pausePanelFill, PausePanelColor, sliced: true).pixelsPerUnitMultiplier = 2f;
				RectTransform val3 = MakeRect((Transform)(object)val2, "PauseMenuFrame");
				val3.anchorMin = Vector2.zero;
				val3.anchorMax = Vector2.one;
				val3.anchoredPosition = Vector2.zero;
				val3.sizeDelta = new Vector2(20f, 20f);
				AddImage(((Component)val3).gameObject, _borderLarge, PauseFrameColor, sliced: true).pixelsPerUnitMultiplier = 2f;
				Anchor(((TMP_Text)MakeText((Transform)(object)val2, "Title", "-- ULTRAUNLOCK IS RE-ENABLED --", 30f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -68f), new Vector2(560f, 44f));
				Anchor(((Component)MakeButton((Transform)(object)val2, "CONTINUE", CloseOptionsReenabledPrompt, 200f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(0f, 48f), new Vector2(200f, 42f));
			}
		}

		private void CloseOptionsReenabledPrompt()
		{
			if ((Object)(object)_optionsReenabledPrompt != (Object)null)
			{
				Object.Destroy((Object)(object)_optionsReenabledPrompt);
			}
			_optionsReenabledPrompt = null;
		}

		private void ShowScreen(Screen screen)
		{
			for (int num = ((Transform)_content).childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)((Transform)_content).GetChild(num)).gameObject);
			}
			switch (screen)
			{
			case Screen.Home:
				BuildHome();
				break;
			case Screen.SaveSlot:
				BuildSaveSlots();
				break;
			case Screen.BackupPrompt:
				BuildBackupPrompt();
				break;
			case Screen.BackupBrowser:
				BuildBackupBrowser();
				break;
			case Screen.MassBackupContents:
				BuildMassBackupContents();
				break;
			case Screen.RestoreConfirmation:
				BuildRestoreConfirmation();
				break;
			case Screen.DeleteBackupConfirmation:
				BuildDeleteBackupConfirmation();
				break;
			case Screen.BackupResult:
				BuildBackupResult();
				break;
			case Screen.Unlock:
				BuildUnlock();
				break;
			case Screen.Advanced:
				BuildAdvanced();
				break;
			case Screen.UnlockConfirmation:
				BuildUnlockConfirmation();
				break;
			case Screen.DontUnlockConfirmation:
				BuildDontUnlockConfirmation();
				break;
			case Screen.CalibrationConfirmation:
				BuildCalibrationConfirmation();
				break;
			case Screen.Result:
				BuildResult();
				break;
			}
		}

		private void BuildHome()
		{
			//IL_0010: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = MakePanel("HomePanel", new Vector2(540f, 330f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- ULTRA UNLOCK --", 38f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(500f, 52f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "UNLOCK", delegate
			{
				ShowScreen(Screen.SaveSlot);
			}, 230f, 48f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0.5f), new Vector2(0f, 35f), new Vector2(230f, 48f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "RESTORE BACKUP", delegate
			{
				ShowScreen(Screen.BackupBrowser);
			}, 230f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0.5f), new Vector2(0f, -25f), new Vector2(230f, 42f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "DON'T UNLOCK", delegate
			{
				ShowScreen(Screen.DontUnlockConfirmation);
			}, 190f, 38f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(0f, 38f), new Vector2(190f, 38f));
		}

		private void BuildSaveSlots()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Expected O, but got Unknown
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			MakeBackButton(delegate
			{
				ShowScreen(Screen.Home);
			});
			RectTransform parent = MakePanel("SlotsPanel", new Vector2(760f, 440f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- CHOOSE SAVE SLOT --", 30f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -48f), new Vector2(700f, 42f));
			SlotData[] slotData = GetSlotData();
			_selectedSlot = Mathf.Clamp(GameProgressSaver.currentSlot + 1, 1, 5);
			_selectedSlotExists = slotData[_selectedSlot - 1].exists;
			RectTransform val = MakeRect((Transform)(object)parent, "Slots");
			Anchor(val, new Vector2(0.5f, 0.5f), new Vector2(0f, 5f), new Vector2(660f, 240f));
			VerticalLayoutGroup obj = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			Button[] buttons = (Button[])(object)new Button[5];
			for (int num = 0; num < buttons.Length; num++)
			{
				int slot = num + 1;
				SlotData data = slotData[num];
				string label = $"SLOT {slot}    : {DescribeSlot(data)}";
				Button val2 = MakeButton((Transform)(object)val, label, null, 650f, 40f);
				buttons[num] = val2;
				TextMeshProUGUI componentInChildren = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)4097;
				((TMP_Text)componentInChildren).rectTransform.offsetMin = new Vector2(22f, 3f);
				((TMP_Text)componentInChildren).rectTransform.offsetMax = new Vector2(-12f, -3f);
				((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
				{
					_selectedSlot = slot;
					_selectedSlotExists = data.exists;
					_unlockNotice = string.Empty;
					SelectRealSlot(slot - 1);
					for (int i = 0; i < buttons.Length; i++)
					{
						SetSlotButtonState(buttons[i], i == slot - 1, slotData[i].exists);
					}
				});
				SetSlotButtonState(val2, _selectedSlot == slot, data.exists);
			}
			Anchor(((Component)MakeButton((Transform)(object)parent, "NEXT", delegate
			{
				if (_selectedSlot > 0)
				{
					ShowScreen(_selectedSlotExists ? Screen.BackupPrompt : Screen.Unlock);
				}
			}, 150f, 38f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(0f, 34f), new Vector2(150f, 38f));
		}

		private SlotData[] GetSlotData()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_0053: Expected O, but got Unknown
			try
			{
				SlotData[] slots = GameProgressSaver.GetSlots();
				if (slots != null && slots.Length == 5)
				{
					return slots;
				}
				((BaseUnityPlugin)this).Logger.LogWarning((object)"ULTRAKILL returned an incomplete save-slot list, missing rows will be shown as empty.");
				SlotData[] array = (SlotData[])(object)new SlotData[5];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = (SlotData)((slots != null && i < slots.Length && slots[i] != null) ? ((object)slots[i]) : ((object)new SlotData
					{
						exists = false
					}));
				}
				return array;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not read ULTRAKILL save slots: " + ex));
				SlotData[] array2 = (SlotData[])(object)new SlotData[5];
				for (int j = 0; j < array2.Length; j++)
				{
					array2[j] = new SlotData
					{
						exists = false
					};
				}
				return array2;
			}
		}

		private static string DescribeSlot(SlotData data)
		{
			if (data == null || !data.exists)
			{
				return "EMPTY";
			}
			try
			{
				return ((object)data).ToString().ToUpperInvariant();
			}
			catch
			{
				return $"IN USE (LEVEL {data.highestLvlNumber}, DIFFICULTY {data.highestDifficulty})";
			}
		}

		private void SelectRealSlot(int slotIndex)
		{
			try
			{
				GameProgressSaver.SetSlot(slotIndex);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"UltraUnlock selected ULTRAKILL save slot {slotIndex + 1}.");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Could not select ULTRAKILL save slot {slotIndex + 1}: {arg}");
			}
		}

		private void BuildBackupPrompt()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			MakeBackButton(delegate
			{
				ShowScreen(Screen.SaveSlot);
			});
			RectTransform parent = MakePanel("BackupPromptPanel", new Vector2(650f, 340f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", $"-- BACK UP SLOT {_selectedSlot}? --", 31f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(590f, 45f));
			string value = (_selectedSlotExists ? "CREATE A WORKING BACKUP OF THIS SAVE SLOT BEFORE CONTINUING?" : "THIS SAVE SLOT IS EMPTY. THERE IS NOTHING TO BACK UP.");
			TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Message", value, 18f, (Color)(_selectedSlotExists ? Color.white : new Color(0.75f, 0.75f, 0.75f, 1f)), (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, 20f), new Vector2(550f, 80f));
			((TMP_Text)obj).enableWordWrapping = true;
			Anchor(((Component)MakeButton((Transform)(object)parent, _selectedSlotExists ? "NO" : "CONTINUE", delegate
			{
				ShowScreen(Screen.Unlock);
			}, 190f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(_selectedSlotExists ? (-105f) : 0f, 48f), new Vector2(190f, 40f));
			if (_selectedSlotExists)
			{
				Anchor(((Component)MakeButton((Transform)(object)parent, "BACK UP", CreateBackupAndContinue, 190f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(105f, 48f), new Vector2(190f, 40f));
			}
		}

		private void CreateBackupAndContinue()
		{
			UltraUnlockBackupResult ultraUnlockBackupResult = UltraUnlockBackupManager.Create(_selectedSlot - 1, ((BaseUnityPlugin)this).Logger);
			if (ultraUnlockBackupResult.Success)
			{
				_backedUpSlotIndex = _selectedSlot - 1;
				_unlockNotice = ultraUnlockBackupResult.Message;
				ShowScreen(Screen.Unlock);
			}
			else
			{
				ShowBackupResult("BACKUP", ultraUnlockBackupResult, Screen.BackupPrompt);
			}
		}

		private void BuildBackupBrowser()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Expected O, but got Unknown
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
			MakeBackButton(delegate
			{
				ShowScreen(Screen.Home);
			});
			RectTransform parent = MakePanel("BackupBrowserPanel", new Vector2(900f, 650f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- RESTORE BACKUP --", 31f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -48f), new Vector2(820f, 45f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Subtitle", "SELECT A BACKUP", 16f, new Color(0.7f, 0.7f, 0.7f, 1f), (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -86f), new Vector2(820f, 25f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "BACK UP ALL SLOTS", CreateMassBackup, 230f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(0f, 38f), new Vector2(230f, 40f));
			string text = string.Empty;
			IReadOnlyList<UltraUnlockBackupInfo> readOnlyList;
			IReadOnlyList<UltraUnlockMassBackupInfo> readOnlyList2;
			try
			{
				readOnlyList = UltraUnlockBackupManager.GetBackups(((BaseUnityPlugin)this).Logger);
				readOnlyList2 = UltraUnlockBackupManager.GetMassBackups(((BaseUnityPlugin)this).Logger);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not enumerate UltraUnlock backups: " + ex));
				readOnlyList = Array.Empty<UltraUnlockBackupInfo>();
				readOnlyList2 = Array.Empty<UltraUnlockMassBackupInfo>();
				text = "BACKUP LIST COULD NOT BE READ: " + ex.Message.ToUpperInvariant();
			}
			if (readOnlyList.Count == 0 && readOnlyList2.Count == 0)
			{
				string value = (string.IsNullOrEmpty(text) ? "NO BACKUPS FOUND." : text);
				TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Empty", value, 19f, Color.red, (TextAlignmentOptions)514);
				Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, 20f), new Vector2(760f, 80f));
				((TMP_Text)obj).enableWordWrapping = true;
				return;
			}
			RectTransform val = MakeRect((Transform)(object)parent, "BackupScroll");
			Anchor(val, new Vector2(0.5f, 0.5f), new Vector2(0f, -20f), new Vector2(790f, 465f));
			((Graphic)AddImage(((Component)val).gameObject, _fillLarge, new Color(0f, 0f, 0f, 0.25f), sliced: true)).raycastTarget = true;
			ScrollRect obj2 = ((Component)val).gameObject.AddComponent<ScrollRect>();
			obj2.horizontal = false;
			obj2.vertical = true;
			obj2.movementType = (MovementType)2;
			obj2.scrollSensitivity = 30f;
			RectTransform val2 = MakeRect((Transform)(object)val, "Viewport");
			Stretch(val2);
			((Component)val2).gameObject.AddComponent<RectMask2D>();
			RectTransform val3 = MakeRect((Transform)(object)val2, "Content");
			val3.anchorMin = new Vector2(0f, 1f);
			val3.anchorMax = new Vector2(1f, 1f);
			val3.pivot = new Vector2(0.5f, 1f);
			val3.anchoredPosition = Vector2.zero;
			val3.sizeDelta = Vector2.zero;
			VerticalLayoutGroup obj3 = ((Component)val3).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj3).spacing = 8f;
			((LayoutGroup)obj3).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false;
			((LayoutGroup)obj3).padding = new RectOffset(8, 8, 4, 4);
			((Component)val3).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			obj2.viewport = val2;
			obj2.content = val3;
			foreach (UltraUnlockMassBackupInfo item in readOnlyList2)
			{
				UltraUnlockMassBackupInfo capturedMassBackup = item;
				string label = "MASS BACKUP    " + item.DisplayTimestamp + "    " + $"5 SLOTS / {item.FileCount} FILES / {FormatBytes(item.TotalBytes)}";
				RectTransform val4 = MakeRect((Transform)(object)val3, "MassBackupRow");
				((Component)val4).gameObject.AddComponent<LayoutElement>().preferredHeight = 46f;
				HorizontalLayoutGroup obj4 = ((Component)val4).gameObject.AddComponent<HorizontalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)obj4).spacing = 8f;
				((LayoutGroup)obj4).childAlignment = (TextAnchor)4;
				((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = false;
				((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
				Button val5 = MakeButton((Transform)(object)val4, label, delegate
				{
					_selectedMassBackup = capturedMassBackup;
					_selectedBackup = null;
					ShowScreen(Screen.MassBackupContents);
				}, 610f, 46f);
				TextMeshProUGUI componentInChildren = ((Component)val5).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)4097;
				((TMP_Text)componentInChildren).rectTransform.offsetMin = new Vector2(54f, 3f);
				((TMP_Text)componentInChildren).rectTransform.offsetMax = new Vector2(-12f, -3f);
				if ((Object)(object)_folderIcon != (Object)null)
				{
					RectTransform val6 = MakeRect(((Component)val5).transform, "FolderIcon");
					Anchor(val6, new Vector2(0f, 0.5f), new Vector2(28f, 0f), new Vector2(30f, 30f));
					Image obj5 = AddImage(((Component)val6).gameObject, _folderIcon, Color.white, sliced: false);
					obj5.preserveAspect = true;
					((Graphic)obj5).raycastTarget = false;
				}
				MakeButton((Transform)(object)val4, "DELETE", delegate
				{
					_selectedMassBackup = capturedMassBackup;
					_selectedBackup = null;
					ShowScreen(Screen.DeleteBackupConfirmation);
				}, 132f, 46f);
			}
			foreach (UltraUnlockBackupInfo item2 in readOnlyList)
			{
				UltraUnlockBackupInfo capturedBackup = item2;
				string label2 = $"SLOT {item2.SlotIndex + 1}    {item2.DisplayTimestamp}    " + $"{item2.FileCount} FILES / {FormatBytes(item2.TotalBytes)}";
				RectTransform val7 = MakeRect((Transform)(object)val3, $"Slot{item2.SlotIndex + 1}BackupRow");
				((Component)val7).gameObject.AddComponent<LayoutElement>().preferredHeight = 46f;
				HorizontalLayoutGroup obj6 = ((Component)val7).gameObject.AddComponent<HorizontalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)obj6).spacing = 8f;
				((LayoutGroup)obj6).childAlignment = (TextAnchor)4;
				((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandWidth = false;
				((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandHeight = false;
				TextMeshProUGUI componentInChildren2 = ((Component)MakeButton((Transform)(object)val7, label2, delegate
				{
					_selectedBackup = capturedBackup;
					_selectedMassBackup = null;
					_restoreReturnScreen = Screen.BackupBrowser;
					ShowScreen(Screen.RestoreConfirmation);
				}, 610f, 46f)).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)componentInChildren2).alignment = (TextAlignmentOptions)4097;
				((TMP_Text)componentInChildren2).rectTransform.offsetMin = new Vector2(18f, 3f);
				((TMP_Text)componentInChildren2).rectTransform.offsetMax = new Vector2(-12f, -3f);
				MakeButton((Transform)(object)val7, "DELETE", delegate
				{
					_selectedBackup = capturedBackup;
					_selectedMassBackup = null;
					ShowScreen(Screen.DeleteBackupConfirmation);
				}, 132f, 46f);
			}
		}

		private void CreateMassBackup()
		{
			UltraUnlockBackupResult ultraUnlockBackupResult = UltraUnlockBackupManager.CreateMass(((BaseUnityPlugin)this).Logger);
			if (ultraUnlockBackupResult.Success)
			{
				_selectedMassBackup = ultraUnlockBackupResult.MassBackup;
			}
			ShowBackupResult("MASS BACKUP", ultraUnlockBackupResult, Screen.BackupBrowser, Screen.BackupBrowser);
		}

		private void BuildMassBackupContents()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			if (_selectedMassBackup == null)
			{
				ShowScreen(Screen.BackupBrowser);
				return;
			}
			MakeBackButton(delegate
			{
				ShowScreen(Screen.BackupBrowser);
			});
			RectTransform parent = MakePanel("MassBackupContentsPanel", new Vector2(760f, 560f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- MASS BACKUP --", 31f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -48f), new Vector2(700f, 44f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Subtitle", _selectedMassBackup.DisplayTimestamp + "    " + $"{_selectedMassBackup.FileCount} FILES / {FormatBytes(_selectedMassBackup.TotalBytes)}", 16f, new Color(0.7f, 0.7f, 0.7f, 1f), (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -84f), new Vector2(700f, 25f));
			RectTransform val = MakeRect((Transform)(object)parent, "MassBackupSlots");
			Anchor(val, new Vector2(0.5f, 0.5f), new Vector2(0f, -12f), new Vector2(650f, 320f));
			VerticalLayoutGroup obj = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 10f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			foreach (UltraUnlockMassBackupSlotInfo slot in _selectedMassBackup.Slots)
			{
				UltraUnlockMassBackupSlotInfo capturedSlot = slot;
				string label = (slot.Exists ? ($"SLOT {slot.SlotIndex + 1}    {slot.Backup.FileCount} FILES / " + FormatBytes(slot.Backup.TotalBytes)) : $"SLOT {slot.SlotIndex + 1}    EMPTY");
				Button val2 = MakeButton((Transform)(object)val, label, slot.Exists ? ((Action)delegate
				{
					_selectedBackup = capturedSlot.Backup;
					_restoreReturnScreen = Screen.MassBackupContents;
					ShowScreen(Screen.RestoreConfirmation);
				}) : null, 620f, 48f);
				TextMeshProUGUI componentInChildren = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>();
				((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)4097;
				((TMP_Text)componentInChildren).rectTransform.offsetMin = new Vector2(24f, 3f);
				((TMP_Text)componentInChildren).rectTransform.offsetMax = new Vector2(-16f, -3f);
				if (!slot.Exists)
				{
					((Selectable)val2).interactable = false;
					((Graphic)componentInChildren).color = Color.red;
				}
			}
		}

		private void BuildRestoreConfirmation()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			if (_selectedBackup == null)
			{
				ShowScreen(Screen.BackupBrowser);
				return;
			}
			MakeBackButton(delegate
			{
				ShowScreen(_restoreReturnScreen);
			});
			RectTransform parent = MakePanel("RestoreConfirmationPanel", new Vector2(680f, 390f));
			int num = _selectedBackup.SlotIndex + 1;
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", $"-- RESTORE SLOT {num}? --", 31f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(620f, 45f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Details", $"BACKUP: {_selectedBackup.DisplayTimestamp}\n{_selectedBackup.FileCount} FILES / {FormatBytes(_selectedBackup.TotalBytes)}", 17f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, 42f), new Vector2(590f, 70f));
			TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Warning", $"THIS WILL REPLACE THE CURRENT CONTENTS OF SLOT {num}.", 17f, Color.red, (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, -28f), new Vector2(590f, 50f));
			((TMP_Text)obj).enableWordWrapping = true;
			Anchor(((Component)MakeButton((Transform)(object)parent, "BACK", delegate
			{
				ShowScreen(_restoreReturnScreen);
			}, 190f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(-105f, 48f), new Vector2(190f, 40f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "RESTORE", RestoreSelectedBackup, 190f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(105f, 48f), new Vector2(190f, 40f));
		}

		private void RestoreSelectedBackup()
		{
			UltraUnlockBackupResult ultraUnlockBackupResult = UltraUnlockBackupManager.Restore(_selectedBackup, ((BaseUnityPlugin)this).Logger);
			if (ultraUnlockBackupResult.Success && ultraUnlockBackupResult.Backup != null)
			{
				_selectedSlot = ultraUnlockBackupResult.Backup.SlotIndex + 1;
				_selectedSlotExists = true;
			}
			ShowBackupResult("RESTORE", ultraUnlockBackupResult, _restoreReturnScreen);
		}

		private void BuildDeleteBackupConfirmation()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			if (_selectedBackup == null && _selectedMassBackup == null)
			{
				ShowScreen(Screen.BackupBrowser);
				return;
			}
			MakeBackButton(delegate
			{
				ShowScreen(Screen.BackupBrowser);
			});
			RectTransform parent = MakePanel("DeleteBackupConfirmationPanel", new Vector2(680f, 390f));
			bool num = _selectedMassBackup != null;
			int num2 = ((!num) ? (_selectedBackup.SlotIndex + 1) : 0);
			string value = (num ? "-- DELETE MASS BACKUP? --" : $"-- DELETE SLOT {num2} BACKUP? --");
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", value, 30f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(620f, 45f));
			string arg = (num ? _selectedMassBackup.DisplayTimestamp : _selectedBackup.DisplayTimestamp);
			int num3 = (num ? _selectedMassBackup.FileCount : _selectedBackup.FileCount);
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Details", string.Format(arg2: FormatBytes(num ? _selectedMassBackup.TotalBytes : _selectedBackup.TotalBytes), format: "{0}\n{1} FILES / {2}", arg0: arg, arg1: num3), 17f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, 42f), new Vector2(590f, 70f));
			string value2 = (num ? "THIS PERMANENTLY DELETES THE ENTIRE MASS BACKUP FOLDER.\nTHE LIVE SAVE SLOTS WILL NOT BE CHANGED." : "THIS PERMANENTLY DELETES THE SELECTED BACKUP.\nTHE LIVE SAVE SLOT WILL NOT BE CHANGED.");
			TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Warning", value2, 17f, Color.red, (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, -36f), new Vector2(590f, 62f));
			((TMP_Text)obj).enableWordWrapping = true;
			Anchor(((Component)MakeButton((Transform)(object)parent, "BACK", delegate
			{
				ShowScreen(Screen.BackupBrowser);
			}, 190f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(-105f, 48f), new Vector2(190f, 40f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "DELETE", DeleteSelectedBackup, 190f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(105f, 48f), new Vector2(190f, 40f));
		}

		private void DeleteSelectedBackup()
		{
			bool flag = _selectedMassBackup != null;
			UltraUnlockBackupResult ultraUnlockBackupResult = (flag ? UltraUnlockBackupManager.Delete(_selectedMassBackup, ((BaseUnityPlugin)this).Logger) : UltraUnlockBackupManager.Delete(_selectedBackup, ((BaseUnityPlugin)this).Logger));
			if (ultraUnlockBackupResult.Success)
			{
				if (flag)
				{
					_selectedMassBackup = null;
				}
				else
				{
					_selectedBackup = null;
				}
			}
			ShowBackupResult("BACKUP DELETE", ultraUnlockBackupResult, Screen.BackupBrowser, Screen.BackupBrowser);
		}

		private void ShowBackupResult(string title, UltraUnlockBackupResult result, Screen returnScreen, Screen successScreen = Screen.Home)
		{
			_backupResultTitle = title;
			_backupResultSucceeded = result.Success;
			_backupResultMessage = result.Message;
			_backupResultReturnScreen = returnScreen;
			_backupResultSuccessScreen = successScreen;
			ShowScreen(Screen.BackupResult);
		}

		private void BuildBackupResult()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = MakePanel("BackupResultPanel", new Vector2(650f, 330f));
			string text = (_backupResultSucceeded ? "COMPLETE" : "FAILED");
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- " + _backupResultTitle + " " + text + " --", 31f, _backupResultSucceeded ? Color.white : Color.red, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(590f, 45f));
			TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Message", _backupResultMessage, 18f, Color.white, (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, 16f), new Vector2(550f, 90f));
			((TMP_Text)obj).enableWordWrapping = true;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
			string label = ((_backupResultSucceeded && _backupResultSuccessScreen == Screen.Home) ? "HOME" : "BACK");
			Action action = (_backupResultSucceeded ? ((Action)delegate
			{
				ShowScreen(_backupResultSuccessScreen);
			}) : ((Action)delegate
			{
				ShowScreen(_backupResultReturnScreen);
			}));
			Anchor(((Component)MakeButton((Transform)(object)parent, label, action, 180f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(0f, 48f), new Vector2(180f, 40f));
		}

		private static string FormatBytes(long bytes)
		{
			if (bytes < 1024)
			{
				return bytes + " B";
			}
			if (bytes < 1048576)
			{
				return ((double)bytes / 1024.0).ToString("0.0") + " KB";
			}
			return ((double)bytes / 1048576.0).ToString("0.0") + " MB";
		}

		private void BuildUnlock()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			MakeBackButton(delegate
			{
				ShowScreen(Screen.SaveSlot);
			});
			RectTransform parent = MakePanel("UnlockPanel", new Vector2(500f, 300f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- UNLOCK --", 38f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(440f, 52f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "ADVANCED", delegate
			{
				ShowScreen(Screen.Advanced);
			}, 190f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0.5f), new Vector2(-105f, -5f), new Vector2(190f, 42f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "UNLOCK ALL", delegate
			{
				RequestUnlockConfirmation(UltraUnlockRequest.Everything(_selectedSlot - 1), Screen.Unlock);
			}, 190f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0.5f), new Vector2(105f, -5f), new Vector2(190f, 42f));
			string value = (string.IsNullOrEmpty(_unlockNotice) ? "Select Advanced to choose what to unlock specifically" : _unlockNotice);
			Color color = (string.IsNullOrEmpty(_unlockNotice) ? new Color(0.7f, 0.7f, 0.7f, 1f) : new Color(0.5f, 1f, 0.5f, 1f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Note", value, 15f, color, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 0f), new Vector2(0f, 38f), new Vector2(430f, 24f));
		}

		private void BuildAdvanced()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_007a: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			MakeBackButton(delegate
			{
				ShowScreen(Screen.Unlock);
			});
			RectTransform parent = MakePanel("AdvancedPanel", new Vector2(620f, 350f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- ADVANCED UNLOCK --", 32f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -38f), new Vector2(560f, 45f));
			RectTransform val = MakeRect((Transform)(object)parent, "Grid");
			Anchor(val, new Vector2(0.5f, 0.5f), new Vector2(0f, 10f), new Vector2(560f, 174f));
			GridLayoutGroup obj = ((Component)val).gameObject.AddComponent<GridLayoutGroup>();
			obj.cellSize = new Vector2(273f, 36f);
			obj.spacing = new Vector2(14f, 10f);
			obj.constraint = (Constraint)1;
			obj.constraintCount = 2;
			((LayoutGroup)obj).childAlignment = (TextAnchor)4;
			MakeCheckbox((Transform)(object)val, "BESTIARY", _bestiary, delegate(bool value)
			{
				_bestiary = value;
			});
			MakeCheckbox((Transform)(object)val, "COLLECTABLES", _collectables, delegate(bool value)
			{
				_collectables = value;
			});
			MakeCheckbox((Transform)(object)val, "WEAPONS", _weapons, delegate(bool value)
			{
				_weapons = value;
			});
			MakeCheckbox((Transform)(object)val, "ARMS", _arms, delegate(bool value)
			{
				_arms = value;
			});
			MakeCheckbox((Transform)(object)val, "SANDBOX", _sandbox, delegate(bool value)
			{
				_sandbox = value;
			});
			MakeCheckbox((Transform)(object)val, "P-RANK ALL", _pRankAll, delegate(bool value)
			{
				_pRankAll = value;
			});
			RectTransform val2 = MakeCheckbox((Transform)(object)val, _cyberGrind ? "CYBER GRIND SCORE:" : "CYBER GRIND", _cyberGrind, delegate(bool value)
			{
				_cyberGrind = value;
				ShowScreen(Screen.Advanced);
			}, _cyberGrind ? 166f : 215f);
			if (_cyberGrind)
			{
				Transform obj2 = ((Transform)val2).Find("Label");
				TextMeshProUGUI val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<TextMeshProUGUI>() : null);
				if ((Object)(object)val3 != (Object)null)
				{
					((TMP_Text)val3).enableAutoSizing = true;
					((TMP_Text)val3).fontSizeMin = 12f;
					((TMP_Text)val3).fontSizeMax = 17f;
				}
				MakeScoreInput((Transform)(object)val2);
			}
			Anchor(((Component)MakeButton((Transform)(object)parent, "APPLY", ApplyAdvancedUnlocks, 160f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(0f, 44f), new Vector2(160f, 40f));
		}

		private void ApplyAdvancedUnlocks()
		{
			UltraUnlockRequest request = new UltraUnlockRequest
			{
				SlotIndex = _selectedSlot - 1,
				Bestiary = _bestiary,
				Collectables = _collectables,
				PrimeSanctums = _collectables,
				Weapons = _weapons,
				Arms = _arms,
				Sandbox = _sandbox,
				PRankAll = _pRankAll,
				CyberGrind = _cyberGrind,
				CyberGrindScore = _cyberGrindScore
			};
			RequestUnlockConfirmation(request, Screen.Advanced);
		}

		private void RequestUnlockConfirmation(UltraUnlockRequest request, Screen returnScreen)
		{
			_pendingUnlockRequest = request;
			_pendingUnlockReturnScreen = returnScreen;
			ShowScreen(Screen.UnlockConfirmation);
		}

		private void BuildUnlockConfirmation()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			if (_pendingUnlockRequest == null)
			{
				ShowScreen(_pendingUnlockReturnScreen);
				return;
			}
			MakeBackButton(delegate
			{
				ShowScreen(_pendingUnlockReturnScreen);
			});
			bool flag = _selectedSlotExists && _backedUpSlotIndex != _pendingUnlockRequest.SlotIndex;
			bool cyberGrind = _pendingUnlockRequest.CyberGrind;
			float num = ((!flag) ? (cyberGrind ? 410f : 350f) : (cyberGrind ? 470f : 410f));
			RectTransform parent = MakePanel("UnlockConfirmationPanel", new Vector2(720f, num));
			int num2 = _pendingUnlockRequest.SlotIndex + 1;
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- CONFIRM UNLOCK --", 32f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -56f), new Vector2(650f, 45f));
			TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Message", $"ARE YOU SURE YOU WANT TO APPLY THESE UNLOCKS TO SLOT {num2}?", 19f, Color.white, (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, (!flag) ? (cyberGrind ? 55f : 28f) : (cyberGrind ? 75f : 45f)), new Vector2(620f, 64f));
			((TMP_Text)obj).enableWordWrapping = true;
			if (cyberGrind)
			{
				TextMeshProUGUI obj2 = MakeText((Transform)(object)parent, "CyberGrindWarning", $"CYBER GRIND SCORE WILL BE SET TO {Math.Max(0, Math.Min(999, _pendingUnlockRequest.CyberGrindScore))}.\n" + "LEADERBOARD SUBMISSION WILL BE DISABLED FOR THIS SLOT.", 16f, new Color(1f, 0.75f, 0.2f, 1f), (TextAlignmentOptions)514);
				Anchor(((TMP_Text)obj2).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, flag ? 5f : (-20f)), new Vector2(620f, 54f));
				((TMP_Text)obj2).enableWordWrapping = true;
			}
			if (flag)
			{
				TextMeshProUGUI obj3 = MakeText((Transform)(object)parent, "BackupWarning", $"SLOT {num2} HAS NOT BEEN BACKED UP.\nCONTINUING WITHOUT A BACKUP CANNOT BE UNDONE.", 17f, Color.red, (TextAlignmentOptions)514);
				Anchor(((TMP_Text)obj3).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, cyberGrind ? (-66f) : (-42f)), new Vector2(620f, 64f));
				((TMP_Text)obj3).enableWordWrapping = true;
				Anchor(((Component)MakeButton((Transform)(object)parent, "CONTINUE", ExecutePendingUnlock, 190f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(-120f, 50f), new Vector2(190f, 42f));
				Anchor(((Component)MakeButton((Transform)(object)parent, "BACK UP AND CONTINUE", BackupAndExecutePendingUnlock, 250f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(115f, 50f), new Vector2(250f, 42f));
				return;
			}
			string value = (_selectedSlotExists ? $"SLOT {num2} WAS BACKED UP BEFORE THIS UNLOCK." : $"SLOT {num2} IS EMPTY. THERE IS NOTHING TO BACK UP YET.");
			Color color = (_selectedSlotExists ? new Color(0.5f, 1f, 0.5f, 1f) : new Color(1f, 0.75f, 0.2f, 1f));
			TextMeshProUGUI obj4 = MakeText((Transform)(object)parent, "BackupStatus", value, 17f, color, (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj4).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, -38f), new Vector2(620f, 44f));
			((TMP_Text)obj4).enableWordWrapping = true;
			Anchor(((Component)MakeButton((Transform)(object)parent, "CANCEL", delegate
			{
				ShowScreen(_pendingUnlockReturnScreen);
			}, 190f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(-105f, 48f), new Vector2(190f, 42f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "CONTINUE", ExecutePendingUnlock, 190f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(105f, 48f), new Vector2(190f, 42f));
		}

		private void BackupAndExecutePendingUnlock()
		{
			if (_pendingUnlockRequest == null)
			{
				ShowScreen(_pendingUnlockReturnScreen);
				return;
			}
			UltraUnlockBackupResult ultraUnlockBackupResult = UltraUnlockBackupManager.Create(_pendingUnlockRequest.SlotIndex, ((BaseUnityPlugin)this).Logger);
			if (!ultraUnlockBackupResult.Success)
			{
				ShowBackupResult("BACKUP", ultraUnlockBackupResult, Screen.UnlockConfirmation, Screen.UnlockConfirmation);
				return;
			}
			_backedUpSlotIndex = _pendingUnlockRequest.SlotIndex;
			_unlockNotice = ultraUnlockBackupResult.Message;
			ExecutePendingUnlock();
		}

		private void ExecutePendingUnlock()
		{
			if (_pendingUnlockRequest == null)
			{
				ShowScreen(_pendingUnlockReturnScreen);
				return;
			}
			UltraUnlockRequest pendingUnlockRequest = _pendingUnlockRequest;
			Screen pendingUnlockReturnScreen = _pendingUnlockReturnScreen;
			_pendingUnlockRequest = null;
			ExecuteUnlock(pendingUnlockRequest, pendingUnlockReturnScreen);
		}

		private void ExecuteUnlock(UltraUnlockRequest request, Screen returnScreen)
		{
			UltraUnlockResult ultraUnlockResult = UltraUnlockEngine.Apply(request, ((BaseUnityPlugin)this).Logger);
			_lastUnlockSucceeded = ultraUnlockResult.Success;
			_lastUnlockMessage = ultraUnlockResult.Message;
			_resultReturnScreen = returnScreen;
			ShowScreen(Screen.Result);
		}

		private void BuildResult()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = MakePanel("ResultPanel", new Vector2(620f, 310f));
			string value = (_lastUnlockSucceeded ? "-- UNLOCK COMPLETE --" : "-- UNLOCK FAILED --");
			Color color = (_lastUnlockSucceeded ? Color.white : Color.red);
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", value, 32f, color, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(560f, 45f));
			TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Message", _lastUnlockMessage, 18f, Color.white, (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, 12f), new Vector2(520f, 90f));
			((TMP_Text)obj).enableWordWrapping = true;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
			string label = (_lastUnlockSucceeded ? "CONTINUE" : "BACK");
			Action action = (_lastUnlockSucceeded ? new Action(ContinueToGame) : ((Action)delegate
			{
				ShowScreen(_resultReturnScreen);
			}));
			Anchor(((Component)MakeButton((Transform)(object)parent, label, action, 180f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(0f, 46f), new Vector2(180f, 40f));
		}

		private void BuildDontUnlockConfirmation()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			MakeBackButton(delegate
			{
				ShowScreen(Screen.Home);
			});
			RectTransform parent = MakePanel("DontUnlockConfirmationPanel", new Vector2(780f, 430f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- DON'T UNLOCK --", 32f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(710f, 45f));
			TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Question", "SHOULD ULTRAUNLOCK STOP OPENING AUTOMATICALLY THE NEXT TIME THE GAME STARTS?", 19f, Color.white, (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, 55f), new Vector2(660f, 70f));
			((TMP_Text)obj).enableWordWrapping = true;
			TextMeshProUGUI obj2 = MakeText((Transform)(object)parent, "Warning", "YOU CAN RE-ENABLE IT AT ANY TIME WITH THE ULTRA UNLOCK TOGGLE IN OPTIONS.\nIT APPEARS IN THE OPTIONS MENU SIDEBAR.", 16f, new Color(1f, 0.75f, 0.2f, 1f), (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj2).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, -34f), new Vector2(650f, 72f));
			((TMP_Text)obj2).enableWordWrapping = true;
			Anchor(((Component)MakeButton((Transform)(object)parent, "KEEP ENABLED", ContinueToGame, 210f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(-115f, 50f), new Vector2(210f, 42f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "DON'T RUN NEXT TIME", DisableStartupAndContinue, 210f, 42f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(115f, 50f), new Vector2(210f, 42f));
		}

		private void DisableStartupAndContinue()
		{
			SetStartupEnabled(enabled: false);
			ContinueToGame();
		}

		private void SetStartupEnabled(bool enabled)
		{
			if (_showOnStartup != null)
			{
				_showOnStartup.Value = enabled;
				((BaseUnityPlugin)this).Config.Save();
				UpdateOptionsStartupToggleLabel();
				((BaseUnityPlugin)this).Logger.LogInfo((object)("UltraUnlock automatic startup is now " + (enabled ? "enabled" : "disabled") + "."));
			}
		}

		private void BuildCalibrationConfirmation()
		{
			//IL_0010: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = MakePanel("CalibrationConfirmationPanel", new Vector2(650f, 330f));
			Anchor(((TMP_Text)MakeText((Transform)(object)parent, "Title", "-- RECALIBRATION --", 32f, Color.white, (TextAlignmentOptions)514)).rectTransform, new Vector2(0.5f, 1f), new Vector2(0f, -58f), new Vector2(590f, 45f));
			TextMeshProUGUI obj = MakeText((Transform)(object)parent, "Message", "ULTRAKILL IS ABOUT TO START RECALIBRATION.\nSKIP IT AND GO DIRECTLY TO THE MAIN MENU?", 18f, Color.white, (TextAlignmentOptions)514);
			Anchor(((TMP_Text)obj).rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0f, 16f), new Vector2(560f, 90f));
			((TMP_Text)obj).enableWordWrapping = true;
			Anchor(((Component)MakeButton((Transform)(object)parent, "RECALIBRATE", Dismiss, 190f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(-105f, 48f), new Vector2(190f, 40f));
			Anchor(((Component)MakeButton((Transform)(object)parent, "SKIP", SkipCalibration, 190f, 40f)).GetComponent<RectTransform>(), new Vector2(0.5f, 0f), new Vector2(105f, 48f), new Vector2(190f, 40f));
		}

		private void MakeScoreInput(Transform cyberGrindRow)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = MakeRect(cyberGrindRow, "ScoreInput");
			Anchor(val, new Vector2(0f, 0.5f), new Vector2(238f, 0f), new Vector2(58f, 30f));
			Image inputFrame = AddImage(((Component)val).gameObject, _borderLarge, Color.white, sliced: true);
			RectTransform val2 = MakeRect((Transform)(object)val, "Text");
			Stretch(val2);
			val2.offsetMin = new Vector2(6f, 2f);
			val2.offsetMax = new Vector2(-6f, -2f);
			TextMeshProUGUI text = ((Component)val2).gameObject.AddComponent<TextMeshProUGUI>();
			ApplyFont(text, 16f, Color.white, (TextAlignmentOptions)514);
			TMP_InputField input = ((Component)val).gameObject.AddComponent<TMP_InputField>();
			((Selectable)input).targetGraphic = (Graphic)(object)inputFrame;
			((Selectable)input).transition = (Transition)0;
			input.textComponent = (TMP_Text)(object)text;
			input.textViewport = val2;
			input.contentType = (ContentType)2;
			input.lineType = (LineType)0;
			input.characterLimit = 3;
			input.customCaretColor = true;
			input.caretColor = Color.red;
			input.caretWidth = 3;
			input.caretBlinkRate = 0.65f;
			input.selectionColor = new Color(1f, 0f, 0f, 0.35f);
			input.text = _cyberGrindScore.ToString();
			RectTransform visibleCaret = MakeRect((Transform)(object)val, "VisibleCaret");
			Anchor(visibleCaret, new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(3f, 20f));
			((Graphic)AddImage(((Component)visibleCaret).gameObject, null, Color.red, sliced: false)).raycastTarget = false;
			CanvasGroup visibleCaretGroup = ((Component)visibleCaret).gameObject.AddComponent<CanvasGroup>();
			visibleCaretGroup.alpha = 0f;
			PositionScoreCaret(visibleCaret, text, input.text);
			((UnityEvent<string>)(object)input.onSelect).AddListener((UnityAction<string>)delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)inputFrame).color = Color.red;
				PositionScoreCaret(visibleCaret, text, input.text);
				visibleCaretGroup.alpha = 1f;
			});
			((UnityEvent<string>)(object)input.onDeselect).AddListener((UnityAction<string>)delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)inputFrame).color = Color.white;
				visibleCaretGroup.alpha = 0f;
			});
			((UnityEvent<string>)(object)input.onValueChanged).AddListener((UnityAction<string>)delegate(string value)
			{
				if (int.TryParse(value, out var result))
				{
					_cyberGrindScore = Mathf.Clamp(result, 0, 999);
				}
				PositionScoreCaret(visibleCaret, text, value);
			});
			((MonoBehaviour)this).StartCoroutine(BlinkScoreCaret(visibleCaretGroup, input));
		}

		private static void PositionScoreCaret(RectTransform caret, TextMeshProUGUI text, string value)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)caret == (Object)null) && !((Object)(object)text == (Object)null))
			{
				float num = (string.IsNullOrEmpty(value) ? 0f : ((TMP_Text)text).GetPreferredValues(value).x);
				caret.anchoredPosition = new Vector2(Mathf.Clamp(num * 0.5f + 1.5f, 1.5f, 21f), 0f);
			}
		}

		private static IEnumerator BlinkScoreCaret(CanvasGroup caret, TMP_InputField input)
		{
			while ((Object)(object)caret != (Object)null && (Object)(object)input != (Object)null)
			{
				if (!input.isFocused)
				{
					caret.alpha = 0f;
					yield return null;
					continue;
				}
				caret.alpha = 1f;
				yield return (object)new WaitForSecondsRealtime(0.45f);
				if ((Object)(object)caret == (Object)null || (Object)(object)input == (Object)null)
				{
					break;
				}
				if (input.isFocused)
				{
					caret.alpha = 0f;
					yield return (object)new WaitForSecondsRealtime(0.45f);
				}
			}
		}

		private Button MakeButton(Transform parent, string label, Action action, float width, float height)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			RectTransform val = MakeRect(parent, label + "Button");
			val.sizeDelta = new Vector2(width, height);
			LayoutElement obj = ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj.preferredWidth = width;
			obj.preferredHeight = height;
			Image targetGraphic = AddImage(((Component)val).gameObject, _borderLarge, Color.white, sliced: true);
			Button val2 = ((Component)val).gameObject.AddComponent<Button>();
			((Selectable)val2).targetGraphic = (Graphic)(object)targetGraphic;
			((Selectable)val2).colors = ButtonColors();
			if (action != null)
			{
				((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
				{
					action();
				});
			}
			RectTransform obj2 = MakeRect((Transform)(object)val, "Label");
			Stretch(obj2);
			obj2.offsetMin = new Vector2(10f, 3f);
			obj2.offsetMax = new Vector2(-10f, -3f);
			TextMeshProUGUI val3 = ((Component)obj2).gameObject.AddComponent<TextMeshProUGUI>();
			ApplyFont(val3, 14f, Color.white, (TextAlignmentOptions)514);
			((TMP_Text)val3).text = label;
			((TMP_Text)val3).enableAutoSizing = true;
			((TMP_Text)val3).fontSizeMin = 10f;
			((TMP_Text)val3).fontSizeMax = 14f;
			((Graphic)val3).raycastTarget = false;
			return val2;
		}

		private void MakeBackButton(Action action)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Button obj = MakeButton((Transform)(object)_content, "<", action, 58f, 42f);
			Anchor(((Component)obj).GetComponent<RectTransform>(), new Vector2(0f, 1f), new Vector2(42f, -40f), new Vector2(58f, 42f));
			TextMeshProUGUI componentInChildren = ((Component)obj).GetComponentInChildren<TextMeshProUGUI>();
			((TMP_Text)componentInChildren).enableAutoSizing = false;
			((TMP_Text)componentInChildren).fontSize = 28f;
		}

		private RectTransform MakeCheckbox(Transform parent, string label, bool initial, Action<bool> changed, float labelWidth = 180f)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			RectTransform val = MakeRect(parent, label + "Checkbox");
			RectTransform val2 = MakeRect((Transform)(object)val, "Box");
			Anchor(val2, new Vector2(0f, 0.5f), new Vector2(14f, 0f), new Vector2(25f, 25f));
			Image targetGraphic = AddImage(((Component)val2).gameObject, _borderSmall, Color.white, sliced: true);
			RectTransform val3 = MakeRect((Transform)(object)val2, "Check");
			Stretch(val3);
			val3.offsetMin = new Vector2(4f, 4f);
			val3.offsetMax = new Vector2(-4f, -4f);
			Image checkImage = AddImage(((Component)val3).gameObject, _checkmark, initial ? Color.white : Color.clear, sliced: false);
			TextMeshProUGUI obj = MakeText((Transform)(object)val, "Label", label, 17f, Color.white, (TextAlignmentOptions)4097);
			((TMP_Text)obj).rectTransform.anchorMin = new Vector2(0f, 0.5f);
			((TMP_Text)obj).rectTransform.anchorMax = new Vector2(0f, 0.5f);
			((TMP_Text)obj).rectTransform.pivot = new Vector2(0f, 0.5f);
			((TMP_Text)obj).rectTransform.anchoredPosition = new Vector2(42f, 0f);
			((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(labelWidth, 28f);
			Button obj2 = ((Component)val).gameObject.AddComponent<Button>();
			((Selectable)obj2).targetGraphic = (Graphic)(object)targetGraphic;
			((Selectable)obj2).colors = ButtonColors();
			bool state = initial;
			((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
			{
				//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)
				state = !state;
				((Graphic)checkImage).color = (state ? Color.white : Color.clear);
				changed(state);
			});
			return val;
		}

		private RectTransform MakePanel(string name, Vector2 size)
		{
			//IL_0018: 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)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = MakeRect((Transform)(object)_content, name);
			Anchor(val, new Vector2(0.5f, 0.5f), Vector2.zero, size);
			AddImage(((Component)val).gameObject, _pausePanelFill, PausePanelColor, sliced: true).pixelsPerUnitMultiplier = 2f;
			RectTransform val2 = MakeRect((Transform)(object)val, "PauseMenuFrame");
			val2.anchorMin = Vector2.zero;
			val2.anchorMax = Vector2.one;
			val2.anchoredPosition = Vector2.zero;
			val2.sizeDelta = new Vector2(20f, 20f);
			AddImage(((Component)val2).gameObject, _borderLarge, PauseFrameColor, sliced: true).pixelsPerUnitMultiplier = 2f;
			if (_initialPanelAnimationPending)
			{
				_initialPanelAnimationPending = false;
				CanvasGroup val3 = ((Component)val).gameObject.AddComponent<CanvasGroup>();
				val3.alpha = 0f;
				val3.interactable = false;
				val3.blocksRaycasts = false;
				HudOpenEffect val4 = ((Component)val).gameObject.AddComponent<HudOpenEffect>();
				val4.speed = 14f;
				val4.originalSpeed = 14f;
				((Behaviour)val4).enabled = false;
				((Transform)val).localScale = new Vector3(0.05f, 0.05f, 1f);
				((MonoBehaviour)this).StartCoroutine(PlayInitialPanelAnimation(val, val3, val4));
			}
			return val;
		}

		private static IEnumerator PlayInitialPanelAnimation(RectTransform panel, CanvasGroup canvasGroup, HudOpenEffect openEffect)
		{
			yield return (object)new WaitForEndOfFrame();
			yield return (object)new WaitForSecondsRealtime(1.1f);
			if (!((Object)(object)panel == (Object)null) && !((Object)(object)canvasGroup == (Object)null) && !((Object)(object)openEffect == (Object)null))
			{
				canvasGroup.alpha = 1f;
				canvasGroup.interactable = true;
				canvasGroup.blocksRaycasts = true;
				((Behaviour)openEffect).enabled = true;
			}
		}

		private Image AddImage(GameObject target, Sprite sprite, Color color, bool sliced)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Image val = target.AddComponent<Image>();
			val.sprite = sprite;
			((Graphic)val).color = color;
			val.type = (Type)((sliced && (Object)(object)sprite != (Object)null) ? 1 : 0);
			val.fillCenter = true;
			if (sliced && (Object)(object)sprite != (Object)null)
			{
				val.pixelsPerUnitMultiplier = 5.4f;
			}
			return val;
		}

		private TextMeshProUGUI MakeText(Transform parent, string name, string value, float size, Color color, TextAlignmentOptions alignment = (TextAlignmentOptions)514)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = ((Component)MakeRect(parent, name)).gameObject.AddComponent<TextMeshProUGUI>();
			ApplyFont(val, size, color, alignment);
			((TMP_Text)val).text = value;
			((Graphic)val).raycastTarget = false;
			return val;
		}

		private void ApplyFont(TextMeshProUGUI text, float size, Color color, TextAlignmentOptions alignment)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_font != (Object)null)
			{
				((TMP_Text)text).font = _font;
			}
			((TMP_Text)text).fontSize = size;
			((Graphic)text).color = color;
			((TMP_Text)text).alignment = alignment;
			((TMP_Text)text).enableWordWrapping = false;
		}

		private static RectTransform MakeRect(Transform parent, string name)
		{
			//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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			return val.AddComponent<RectTransform>();
		}

		private static void Stretch(RectTransform rect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.offsetMin = Vector2.zero;
			rect.offsetMax = Vector2.zero;
		}

		private static void Anchor(RectTransform rect, Vector2 anchor, Vector2 position, Vector2 size)
		{
			//IL_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = anchor;
			rect.anchorMax = anchor;
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.anchoredPosition = position;
			rect.sizeDelta = size;
		}

		private static ColorBlock ButtonColors()
		{
			//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