Decompiled source of MenuLib v1.0.0

MenuLib.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MenuLib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MenuLib")]
[assembly: AssemblyTitle("MenuLib")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MenuLib
{
	[BepInPlugin("nickklmao.menulib", "Menu Lib", "1.0.0")]
	internal sealed class Entry : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Action<MenuManager>, MenuManager> <0>__MenuManager_StartHook;

			public static Action<Action<MenuPageMain>, MenuPageMain> <1>__MenuPageMain_StartHook;

			public static Action<Action<MenuPageEsc>, MenuPageEsc> <2>__MenuPageEsc_StartHook;

			public static Manipulator <3>__SemiFunc_UIMouseHoverILHook;
		}

		private const string MOD_NAME = "Menu Lib";

		internal static readonly ManualLogSource logger = Logger.CreateLogSource("Menu Lib");

		private static void MenuManager_StartHook(Action<MenuManager> orig, MenuManager self)
		{
			orig(self);
			MenuAPI.Initialize();
		}

		private static void MenuPageMain_StartHook(Action<MenuPageMain> orig, MenuPageMain self)
		{
			orig(self);
			MenuAPI.addToMainMenuEvent?.Invoke(self);
		}

		private static void MenuPageEsc_StartHook(Action<MenuPageEsc> orig, MenuPageEsc self)
		{
			orig(self);
			MenuAPI.addToEscapeMenuEvent?.Invoke(self);
		}

		private static void SemiFunc_UIMouseHoverILHook(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val4 = default(ILLabel);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchBrfalse(instruction, ref val4) && val4.Target.OpCode == OpCodes.Ldarg_1
			});
			val.Index += 2;
			val.RemoveRange(27);
			val.Emit(OpCodes.Ldloc_0);
			val.EmitDelegate<Func<MenuScrollBox, Vector2, bool>>((Func<MenuScrollBox, Vector2, bool>)delegate(MenuScrollBox menuScrollBox, Vector2 vector)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Expected O, but got Unknown
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val3 = (RectTransform)((Component)menuScrollBox).transform.Find("Mask");
				float y = ((Transform)val3).position.y;
				float num = y + val3.sizeDelta.y;
				return vector.y > y && vector.y < num;
			});
			ILLabel val2 = val.DefineLabel();
			val.Emit(OpCodes.Brtrue_S, (object)val2);
			val.Emit(OpCodes.Ldc_I4_0);
			val.Emit(OpCodes.Ret);
			val.MarkLabel(val2);
		}

		private void Awake()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			logger.LogDebug((object)"Hooking `MenuManager.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(MenuManager), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuManager>, MenuManager>(MenuManager_StartHook));
			logger.LogDebug((object)"Hooking `MenuPageMain.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(MenuPageMain), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageMain>, MenuPageMain>(MenuPageMain_StartHook));
			logger.LogDebug((object)"Hooking `MenuPageEsc.Start`");
			new Hook((MethodBase)AccessTools.Method(typeof(MenuPageEsc), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageEsc>, MenuPageEsc>(MenuPageEsc_StartHook));
			logger.LogDebug((object)"Hooking `SemiFunc.UIMouseHover`");
			MethodInfo methodInfo = AccessTools.Method(typeof(SemiFunc), "UIMouseHover", (Type[])null, (Type[])null);
			object obj = <>O.<3>__SemiFunc_UIMouseHoverILHook;
			if (obj == null)
			{
				Manipulator val = SemiFunc_UIMouseHoverILHook;
				<>O.<3>__SemiFunc_UIMouseHoverILHook = val;
				obj = (object)val;
			}
			new ILHook((MethodBase)methodInfo, (Manipulator)obj);
		}
	}
	public static class MenuAPI
	{
		internal static Action<MenuPageMain> addToMainMenuEvent;

		internal static Action<MenuPageEsc> addToEscapeMenuEvent;

		private static bool initialized;

		internal static RectTransform pageDimmer { get; private set; }

		internal static RectTransform simplePageTemplate { get; private set; }

		internal static RectTransform buttonTemplate { get; private set; }

		internal static RectTransform popupPageTemplate { get; private set; }

		internal static RectTransform toggleTemplate { get; private set; }

		internal static RectTransform sliderTemplate { get; private set; }

		public static void AddElementToMainMenu(REPOElement repoElement, Vector2 newPosition)
		{
			//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)
			addToMainMenuEvent = (Action<MenuPageMain>)Delegate.Combine(addToMainMenuEvent, (Action<MenuPageMain>)delegate(MenuPageMain instance)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val = repoElement.Instantiate();
				((Transform)val).SetParent(((Component)instance).transform);
				repoElement.SetPosition(newPosition);
				repoElement.afterBeingParented?.Invoke(((Component)instance).GetComponent<MenuPage>());
			});
		}

		public static void AddElementToEscapeMenu(REPOElement repoElement, Vector2 newPosition)
		{
			//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)
			addToEscapeMenuEvent = (Action<MenuPageEsc>)Delegate.Combine(addToEscapeMenuEvent, (Action<MenuPageEsc>)delegate(MenuPageEsc instance)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val = repoElement.Instantiate();
				((Transform)val).SetParent(((Component)instance).transform);
				repoElement.SetPosition(newPosition);
				repoElement.afterBeingParented?.Invoke(((Component)instance).GetComponent<MenuPage>());
			});
		}

		internal static void Initialize()
		{
			//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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected I4, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			if (initialized)
			{
				return;
			}
			List<MenuPages> menuPages = MenuManager.instance.menuPages;
			foreach (MenuPages item in menuPages)
			{
				MenuPageIndex menuPageIndex = item.menuPageIndex;
				MenuPageIndex val = menuPageIndex;
				switch ((int)val)
				{
				case 0:
					simplePageTemplate = (RectTransform)item.menuPage.transform;
					buttonTemplate = (RectTransform)((Transform)simplePageTemplate).Find("Menu Button - Quit game");
					break;
				case 2:
					pageDimmer = (RectTransform)item.menuPage.transform.GetChild(0);
					break;
				case 4:
					popupPageTemplate = (RectTransform)item.menuPage.transform;
					break;
				case 5:
					toggleTemplate = (RectTransform)item.menuPage.transform.Find("Menu Scroll Box/Mask/Scroller/Bool Setting - Push to Talk");
					sliderTemplate = (RectTransform)item.menuPage.transform.Find("Menu Scroll Box/Mask/Scroller/Slider - microphone");
					break;
				}
			}
			initialized = true;
		}
	}
	internal sealed class REPOMenuSliderFloat : MonoBehaviour
	{
		private static readonly FieldInfo getMenuID = AccessTools.Field(typeof(MenuSelectableElement), "menuID");

		internal MenuPage menuPage;

		internal Action<float> onValueChanged;

		internal string displayPrefix;

		internal string displayPostfix;

		internal float min;

		internal float max;

		internal float precision;

		internal int decimalPlaces;

		private TextMeshProUGUI headerTMP;

		private TextMeshProUGUI barTMP;

		private TextMeshProUGUI maskedTMP;

		private TextMeshProUGUI descriptionTextTMP;

		private MenuSelectableElement menuSelectableElement;

		private RectTransform rectTransform;

		private RectTransform maskedRectTransform;

		private RectTransform barRectTransform;

		private RectTransform barSizeRectTransform;

		private RectTransform bigTextOutline;

		private RectTransform bigTextFill;

		private Transform barPointer;

		private Vector2 barSizeDelta = new Vector2(0f, 10f);

		private float currentValue;

		private float previousValue;

		private bool isHovering;

		private bool valueChanged => (double)Mathf.Abs(currentValue - previousValue) >= 0.01;

		internal void Initialize(float defaultValue)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0033: 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_0074: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			rectTransform = (RectTransform)((Component)this).transform;
			headerTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
			((TMP_Text)headerTMP).rectTransform.sizeDelta = new Vector2(200f, 40f);
			barTMP = ((Component)((Component)this).transform.Find("Bar Text")).GetComponent<TextMeshProUGUI>();
			maskedRectTransform = (RectTransform)((Component)this).transform.Find("MaskedText");
			maskedTMP = ((Component)maskedRectTransform).GetComponentInChildren<TextMeshProUGUI>();
			descriptionTextTMP = ((Component)((Component)this).transform.Find("Big Setting Text")).GetComponent<TextMeshProUGUI>();
			barSizeRectTransform = (RectTransform)((Component)this).transform.Find("BarSize");
			Transform val = ((Component)this).transform.Find("SliderBG");
			bigTextOutline = (RectTransform)val.Find("RawImage (3)");
			bigTextFill = (RectTransform)val.Find("RawImage (2)");
			Object.Destroy((Object)(object)((Component)val.Find("RawImage (4)")).gameObject);
			Object.Destroy((Object)(object)((Component)val.Find("RawImage (5)")).gameObject);
			menuSelectableElement = ((Component)this).GetComponent<MenuSelectableElement>();
			barPointer = ((Component)this).transform.Find("Bar Pointer");
			Transform val2 = ((Component)this).transform.Find("Bar");
			barRectTransform = (RectTransform)((Component)val2.GetChild(0)).transform;
			barRectTransform.pivot = new Vector2(0f, 0.5f);
			((Transform)barRectTransform).localPosition = Vector3.zero;
			Object.Destroy((Object)(object)((Component)val2.Find("Extra Bar")).gameObject);
			Button[] componentsInChildren = ((Component)this).GetComponentsInChildren<Button>();
			Button val3 = componentsInChildren[0];
			((UnityEvent)val3.onClick).AddListener(new UnityAction(Decrement));
			Button val4 = componentsInChildren[1];
			((UnityEvent)val4.onClick).AddListener(new UnityAction(Increment));
			previousValue = (currentValue = defaultValue);
			string text = precision.ToString(CultureInfo.InvariantCulture);
			int num = text.IndexOf('.');
			if (num == -1)
			{
				decimalPlaces = 0;
			}
			else
			{
				decimalPlaces = text.Length - num - 1;
			}
			UpdateBarPosition();
			UpdateBarLabel();
		}

		internal void SetHeader(string text)
		{
			((TMP_Text)headerTMP).text = text;
		}

		internal void SetDescriptionText(string text)
		{
			//IL_0059: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(text))
			{
				bigTextOutline.sizeDelta = new Vector2(108f, 29.5f);
				bigTextFill.sizeDelta = new Vector2(109.8f, 32f);
			}
			else
			{
				bigTextOutline.sizeDelta = new Vector2(108f, 15.5f);
				bigTextFill.sizeDelta = new Vector2(109.8f, 15.5f);
			}
			((TMP_Text)descriptionTextTMP).text = text;
		}

		private void Update()
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.UIMouseHover(menuPage, barSizeRectTransform, getMenuID.GetValue(menuSelectableElement) as string, 5f, 5f))
			{
				if (!isHovering)
				{
					MenuManager.instance.MenuEffectHover(SemiFunc.MenuGetPitchFromYPos(rectTransform), -1f);
					isHovering = true;
				}
				SemiFunc.MenuSelectionBoxTargetSet(menuPage, barSizeRectTransform, new Vector2(-3f, 0f), new Vector2(20f, 10f));
				OnHover();
			}
			else
			{
				isHovering = false;
				if (((Component)barPointer).gameObject.activeSelf)
				{
					Vector3 localPosition = barPointer.localPosition;
					localPosition.x = -1000f;
					barPointer.localPosition = localPosition;
					((Component)barPointer).gameObject.SetActive(false);
				}
			}
			if (valueChanged)
			{
				UpdateBarPosition();
				UpdateBarLabel();
				previousValue = currentValue;
				onValueChanged?.Invoke(currentValue);
			}
		}

		private void OnHover()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00be: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			if (!((Component)barPointer).gameObject.activeSelf)
			{
				((Component)barPointer).gameObject.SetActive(true);
			}
			float x = SemiFunc.UIMouseGetLocalPositionWithinRectTransform(barSizeRectTransform).x;
			float num = max - min;
			float num2 = precision / num;
			float num3 = Mathf.Round(Mathf.Clamp01(x / barSizeRectTransform.sizeDelta.x) / num2) * num2;
			float x2 = Mathf.Clamp(((Transform)barSizeRectTransform).localPosition.x + num3 * barSizeRectTransform.sizeDelta.x, ((Transform)barSizeRectTransform).localPosition.x, ((Transform)barSizeRectTransform).localPosition.x + barSizeRectTransform.sizeDelta.x) - 2f;
			Transform obj = barPointer;
			Vector3 localPosition = barPointer.localPosition;
			localPosition.x = x2;
			obj.localPosition = localPosition;
			if (Input.GetMouseButton(0))
			{
				currentValue = min + num3 * num;
				if (valueChanged)
				{
					MenuManager.instance.MenuEffectClick((MenuClickEffectType)4, menuPage, -1f, -1f, false);
				}
			}
		}

		private void UpdateBarPosition()
		{
			SetBarPosition((currentValue - min) / (max - min));
		}

		private void SetBarPosition(float normalizedValue)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			barSizeDelta.x = normalizedValue * 100f;
			RectTransform obj = maskedRectTransform;
			Vector2 sizeDelta = (barRectTransform.sizeDelta = barSizeDelta);
			obj.sizeDelta = sizeDelta;
		}

		private void Increment()
		{
			float num = currentValue + precision * 2f;
			if (Math.Abs(max - currentValue) < float.Epsilon)
			{
				num = min;
			}
			else if (num > max)
			{
				num = max;
			}
			currentValue = num;
		}

		private void Decrement()
		{
			float num = currentValue - precision * 2f;
			if (Math.Abs(currentValue - min) < float.Epsilon)
			{
				num = max;
			}
			else if (num < min)
			{
				num = min;
			}
			currentValue = num;
		}

		private void UpdateBarLabel()
		{
			string s = currentValue.ToString(CultureInfo.InvariantCulture);
			s = (int.TryParse(s, out var result) ? result.ToString() : currentValue.ToString($"F{decimalPlaces}", CultureInfo.InvariantCulture));
			TextMeshProUGUI obj = barTMP;
			string text2 = (((TMP_Text)maskedTMP).text = (displayPrefix ?? (displayPrefix = string.Empty)) + s + (displayPostfix ?? (displayPostfix = string.Empty)));
			((TMP_Text)obj).text = text2;
		}
	}
	public struct Padding
	{
		public readonly float left;

		public readonly float top;

		public readonly float right;

		public readonly float bottom;

		public Padding(float left, float top, float right, float bottom)
		{
			this.left = left;
			this.top = top;
			this.right = right;
			this.bottom = bottom;
		}
	}
	public enum PopupSide
	{
		Left,
		Right
	}
	public sealed class REPOButton : REPOElement
	{
		internal MenuButton menuButton;

		private MenuButtonPopUp menuButtonPopUp;

		private TextMeshProUGUI buttonTextTMP;

		private Button button;

		public string text { get; private set; }

		public Action onClick { get; private set; }

		public REPOButton(string text, Action onClick)
		{
			this.text = text;
			this.onClick = onClick;
		}

		public void SetText(string newText)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)buttonTextTMP))
			{
				((TMP_Text)buttonTextTMP).text = newText;
				transform.sizeDelta = ((TMP_Text)buttonTextTMP).GetPreferredValues();
			}
			text = newText;
		}

		public void SetOnClick(Action newOnClick)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)button) && newOnClick != null)
			{
				button.onClick = new ButtonClickedEvent();
				((UnityEvent)button.onClick).AddListener(new UnityAction(newOnClick.Invoke));
			}
			onClick = newOnClick;
		}

		public void OpenDialog(string header, string content, Action onConfirm)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)menuButtonPopUp))
			{
				menuButtonPopUp = ((Component)transform).gameObject.AddComponent<MenuButtonPopUp>();
			}
			menuButtonPopUp.option1Event = new UnityEvent();
			menuButtonPopUp.option1Event.AddListener(new UnityAction(onConfirm.Invoke));
			MenuManager.instance.PagePopUpTwoOptions(menuButtonPopUp, header, menuButtonPopUp.headerColor, content, "Yes", "No");
		}

		public override RectTransform GetReference()
		{
			return MenuAPI.buttonTemplate;
		}

		public override void SetDefaults()
		{
			menuButton = ((Component)transform).GetComponent<MenuButton>();
			ref TextMeshProUGUI reference = ref buttonTextTMP;
			object? value = AccessTools.Field(typeof(MenuButton), "buttonText").GetValue(menuButton);
			reference = (TextMeshProUGUI)((value is TextMeshProUGUI) ? value : null);
			button = ((Component)transform).GetComponent<Button>();
			((Object)transform).name = "Menu Button - " + text;
			SetText(text);
			SetOnClick(onClick);
			Object.Destroy((Object)(object)((Component)transform).GetComponent<MenuButtonPopUp>());
			afterBeingParented = delegate(MenuPage menuPage)
			{
				AccessTools.Field(typeof(MenuButton), "parentPage").SetValue(menuButton, menuPage);
			};
		}
	}
	public abstract class REPOElement
	{
		public Action<MenuPage> afterBeingParented;

		internal RectTransform transform;

		public Vector2 position { get; private set; }

		public void SetPosition(Vector2 newLocalPosition)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)transform))
			{
				((Transform)transform).localPosition = Vector2.op_Implicit(newLocalPosition);
			}
			position = newLocalPosition;
		}

		public abstract RectTransform GetReference();

		public virtual void SetDefaults()
		{
		}

		public RectTransform Instantiate()
		{
			transform = Object.Instantiate<RectTransform>(GetReference());
			SetDefaults();
			return transform;
		}
	}
	public sealed class REPOPopupPage : REPOSimplePage
	{
		private RectTransform backgroundPanelTransform;

		private RectTransform maskTransform;

		private RectTransform scrollBarTransform;

		private RectTransform headerTransform;

		private RectTransform hoverAreaTransform;

		private RectTransform scrollBarOutlineTransform;

		private RectTransform scrollBarFillTransform;

		private RectTransform scrollBarBackgroundTransform;

		private Transform pageDimmerTransform;

		private Transform contentTransform;

		private MenuScrollBox menuScrollBox;

		public Vector2 localPosition { get; private set; } = new Vector2(195.64f, 190.6f);


		public bool backgroundDimming { get; private set; }

		public Vector2 panelSize { get; private set; } = new Vector2(250f, 342f);


		public Padding? maskPadding { get; private set; }

		public REPOPopupPage(string text, Action<REPOPopupPage> setup = null)
			: base(text, null)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			setup?.Invoke(this);
		}

		public void SetLocalPosition(Vector2 newLocalPosition)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)backgroundPanelTransform))
			{
				((Transform)backgroundPanelTransform).localPosition = Vector2.op_Implicit(newLocalPosition);
			}
			UpdateOtherElements();
			localPosition = newLocalPosition;
		}

		public void SetSize(Vector2 newPanelSize)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)backgroundPanelTransform))
			{
				backgroundPanelTransform.sizeDelta = newPanelSize;
			}
			UpdateOtherElements();
			panelSize = newPanelSize;
		}

		public void SetBackgroundDimming(bool newBackgroundDimming)
		{
			if (Object.op_Implicit((Object)(object)transform))
			{
				if (!newBackgroundDimming)
				{
					if (Object.op_Implicit((Object)(object)pageDimmerTransform))
					{
						Object.Destroy((Object)(object)((Component)pageDimmerTransform).gameObject);
					}
				}
				else if (!Object.op_Implicit((Object)(object)pageDimmerTransform))
				{
					pageDimmerTransform = (Transform)(object)Object.Instantiate<RectTransform>(MenuAPI.pageDimmer, (Transform)(object)transform);
					pageDimmerTransform.SetAsFirstSibling();
				}
			}
			backgroundDimming = newBackgroundDimming;
		}

		public void SetMaskPadding(Padding? padding)
		{
			maskPadding = padding;
			UpdateOtherElements();
		}

		public void AddElementToScrollView(REPOElement repoElement, Vector2 newPosition)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			initializeButtons = (Action)Delegate.Combine(initializeButtons, (Action)delegate
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val = repoElement.Instantiate();
				((Transform)val).SetParent(contentTransform);
				repoElement.SetPosition(newPosition);
				repoElement.afterBeingParented?.Invoke(menuPage);
			});
		}

		public void ClearButtons()
		{
			initializeButtons = null;
		}

		public override RectTransform GetReference()
		{
			return MenuAPI.popupPageTemplate;
		}

		public override void SetDefaults()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			menuPage = ((Component)transform).GetComponent<MenuPage>();
			backgroundPanelTransform = (RectTransform)((Transform)transform).Find("Panel");
			headerTransform = (RectTransform)((Transform)transform).Find("Header");
			Transform val = ((Transform)transform).Find("Menu Scroll Box");
			hoverAreaTransform = (RectTransform)val.Find("ScrollBoxHoverArea");
			maskTransform = (RectTransform)val.Find("Mask");
			scrollBarTransform = (RectTransform)val.Find("Scroll Bar");
			scrollBarOutlineTransform = (RectTransform)((Transform)scrollBarTransform).Find("Scroll Bar Bg (1)");
			scrollBarFillTransform = (RectTransform)((Transform)scrollBarTransform).Find("Scroll Bar Bg (2)");
			scrollBarBackgroundTransform = (RectTransform)((Transform)scrollBarTransform).Find("Scroll Bar Bg");
			((Object)transform).name = "Menu Page " + base.text;
			((Transform)transform).SetParent(((Component)MenuHolder.instance).transform);
			SetLocalPosition(localPosition);
			SetBackgroundDimming(backgroundDimming);
			menuPage.menuPageIndex = (MenuPageIndex)(-1);
			menuPage.disableIntroAnimation = false;
			SetText(base.text);
			RectTransform obj = backgroundPanelTransform;
			RectTransform obj2 = backgroundPanelTransform;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			obj2.anchorMin = val2;
			obj.anchorMax = val2;
			SetSize(panelSize);
			contentTransform = ((Transform)maskTransform).Find("Scroller");
			for (int num = contentTransform.childCount - 1; num >= 0; num--)
			{
				Transform child = contentTransform.GetChild(num);
				if (num >= 2)
				{
					Object.Destroy((Object)(object)((Component)child).gameObject);
				}
			}
			initializeButtons?.Invoke();
			menuScrollBox = ((Component)val).GetComponent<MenuScrollBox>();
			menuScrollBox.heightPadding = 50f;
			((MonoBehaviour)menuScrollBox).StartCoroutine(ResetScrollBox(menuScrollBox));
			((Component)transform).gameObject.AddComponent<MenuPageSettings>();
			IEnumerator ResetScrollBox(MenuScrollBox menuScrollBoxInstance)
			{
				yield return null;
				float scrollHandlePosition = scrollBarBackgroundTransform.sizeDelta.y - menuScrollBoxInstance.scrollHandle.sizeDelta.y * 0.5f;
				RectTransform scrollHandle = menuScrollBoxInstance.scrollHandle;
				Vector3 val3 = ((Transform)menuScrollBoxInstance.scrollHandle).localPosition;
				val3.y = scrollHandlePosition;
				((Transform)scrollHandle).localPosition = val3;
				AccessTools.Field(typeof(MenuScrollBox), "scrollHandleTargetPosition").SetValue(menuScrollBoxInstance, scrollHandlePosition);
				AccessTools.Method(typeof(MenuScrollBox), "Start", (Type[])null, (Type[])null).Invoke(menuScrollBoxInstance, null);
			}
		}

		private void UpdateOtherElements()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0065: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: 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_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: 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)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)backgroundPanelTransform))
			{
				return;
			}
			Vector2 sizeDelta = backgroundPanelTransform.sizeDelta;
			Vector2 val = sizeDelta * 0.5f;
			if (Object.op_Implicit((Object)(object)headerTransform))
			{
				((Transform)headerTransform).position = ((Transform)backgroundPanelTransform).position + new Vector3(0f, val.y - headerTransform.sizeDelta.y * 0.35f, 0f);
			}
			if (Object.op_Implicit((Object)(object)maskTransform))
			{
				RectTransform obj = hoverAreaTransform;
				Vector3 val3 = (((Transform)maskTransform).position = ((Transform)backgroundPanelTransform).position - new Vector3(val.x, val.y, 0f));
				((Transform)obj).position = val3;
				RectTransform obj2 = hoverAreaTransform;
				Vector2 sizeDelta2 = (maskTransform.sizeDelta = sizeDelta);
				obj2.sizeDelta = sizeDelta2;
				Padding padding = maskPadding ?? new Padding(0f, 80f, 0f, 0f);
				if (padding.left != 0f)
				{
					RectTransform obj3 = maskTransform;
					sizeDelta2 = maskTransform.sizeDelta;
					sizeDelta2.x = maskTransform.sizeDelta.x - padding.left;
					obj3.sizeDelta = sizeDelta2;
					RectTransform obj4 = maskTransform;
					val3 = ((Transform)maskTransform).position;
					val3.x = ((Transform)maskTransform).position.x + padding.left;
					((Transform)obj4).position = val3;
				}
				if (padding.top != 0f)
				{
					RectTransform obj5 = maskTransform;
					sizeDelta2 = maskTransform.sizeDelta;
					sizeDelta2.y = maskTransform.sizeDelta.y - padding.top;
					obj5.sizeDelta = sizeDelta2;
				}
				if (padding.right != 0f)
				{
					RectTransform obj6 = maskTransform;
					sizeDelta2 = maskTransform.sizeDelta;
					sizeDelta2.x = maskTransform.sizeDelta.x - padding.right;
					obj6.sizeDelta = sizeDelta2;
				}
				if (padding.bottom != 0f)
				{
					RectTransform obj7 = maskTransform;
					sizeDelta2 = maskTransform.sizeDelta;
					sizeDelta2.y = maskTransform.sizeDelta.y - padding.bottom;
					obj7.sizeDelta = sizeDelta2;
					RectTransform obj8 = maskTransform;
					val3 = ((Transform)maskTransform).position;
					val3.y = ((Transform)maskTransform).position.y + padding.bottom;
					((Transform)obj8).position = val3;
				}
				if (Object.op_Implicit((Object)(object)scrollBarTransform))
				{
					Vector2 sizeDelta3 = maskTransform.sizeDelta;
					RectTransform obj9 = scrollBarTransform;
					sizeDelta2 = scrollBarTransform.sizeDelta;
					sizeDelta2.y = sizeDelta3.y;
					obj9.sizeDelta = sizeDelta2;
					RectTransform obj10 = scrollBarBackgroundTransform;
					RectTransform obj11 = scrollBarFillTransform;
					Vector2 sizeDelta4 = scrollBarFillTransform.sizeDelta;
					sizeDelta4.y = sizeDelta3.y - 4f;
					sizeDelta2 = (obj11.sizeDelta = sizeDelta4);
					obj10.sizeDelta = sizeDelta2;
					RectTransform obj12 = scrollBarOutlineTransform;
					sizeDelta2 = scrollBarOutlineTransform.sizeDelta;
					sizeDelta2.y = sizeDelta3.y;
					obj12.sizeDelta = sizeDelta2;
					float num = scrollBarTransform.sizeDelta.x * 0.5f;
					((Transform)scrollBarTransform).position = ((Transform)maskTransform).position + new Vector3(sizeDelta3.x - num, 0f, 0f);
					RectTransform obj13 = hoverAreaTransform;
					sizeDelta2 = hoverAreaTransform.sizeDelta;
					sizeDelta2.x = hoverAreaTransform.sizeDelta.x + num + 4f;
					obj13.sizeDelta = sizeDelta2;
				}
			}
		}
	}
	public class REPOSimplePage : REPOElement
	{
		internal MenuPage menuPage;

		internal Action initializeButtons;

		public string text { get; private set; }

		public REPOSimplePage(string text, Action<REPOSimplePage> onSetup)
		{
			this.text = text;
			onSetup?.Invoke(this);
		}

		public void SetText(string newText)
		{
			if (Object.op_Implicit((Object)(object)menuPage?.menuHeader))
			{
				((TMP_Text)menuPage.menuHeader).text = newText;
			}
			text = newText;
		}

		public void AddElementToPage(REPOElement repoElement, Vector2 newPosition)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			initializeButtons = (Action)Delegate.Combine(initializeButtons, (Action)delegate
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val = repoElement.Instantiate();
				((Transform)val).SetParent((Transform)(object)transform);
				repoElement.SetPosition(newPosition);
				repoElement.afterBeingParented?.Invoke(menuPage);
			});
		}

		public void OpenPage(bool addOnTop)
		{
			Instantiate();
			if (addOnTop)
			{
				OpenPageOnTop();
			}
			else
			{
				OpenPageNormal();
			}
		}

		public void ClosePage(bool closePagesAddedOnTop)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (closePagesAddedOnTop)
			{
				MenuManager.instance.PageCloseAllAddedOnTop();
			}
			menuPage.PageStateSet((PageState)2);
			object? value = AccessTools.Field(typeof(MenuPage), "pageUnderThisPage").GetValue(menuPage);
			MenuPage val = (MenuPage)((value is MenuPage) ? value : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				MenuManager.instance.PageSetCurrent(val.menuPageIndex, val);
			}
		}

		public override RectTransform GetReference()
		{
			return MenuAPI.simplePageTemplate;
		}

		public override void SetDefaults()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			menuPage = ((Component)transform).GetComponent<MenuPage>();
			((Object)transform).name = "Menu Page " + text;
			((Transform)transform).SetParent(((Component)MenuHolder.instance).transform);
			menuPage.menuPageIndex = (MenuPageIndex)(-1);
			menuPage.disableIntroAnimation = false;
			SetText(text);
			for (int num = ((Transform)transform).childCount - 1; num >= 0; num--)
			{
				Transform child = ((Transform)transform).GetChild(num);
				if (((Object)child).name.Contains("Menu Button"))
				{
					Object.Destroy((Object)(object)((Component)child).gameObject);
				}
			}
			Object.Destroy((Object)(object)((Component)transform).GetComponent<MenuPageMain>());
			initializeButtons?.Invoke();
		}

		private void OpenPageNormal()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			object? value = AccessTools.Field(typeof(MenuManager), "currentMenuPage").GetValue(MenuManager.instance);
			MenuPage val = (MenuPage)((value is MenuPage) ? value : null);
			AccessTools.Method(typeof(MenuManager), "PageInactiveAdd", (Type[])null, (Type[])null).Invoke(MenuManager.instance, new object[1] { val });
			if (val != null)
			{
				val.PageStateSet((PageState)3);
			}
			((Component)menuPage).transform.localPosition = Vector3.zero;
			MenuManager.instance.PageAdd(menuPage);
			((MonoBehaviour)menuPage).StartCoroutine(AccessTools.Method(typeof(MenuPage), "LateStart", (Type[])null, (Type[])null).Invoke(menuPage, null) as IEnumerator);
			AccessTools.Field(typeof(MenuPage), "addedPageOnTop").SetValue(menuPage, false);
			MenuManager.instance.PageSetCurrent(menuPage.menuPageIndex, menuPage);
			AccessTools.Field(typeof(MenuPage), "pageIsOnTopOfOtherPage").SetValue(menuPage, true);
			AccessTools.Field(typeof(MenuPage), "pageUnderThisPage").SetValue(menuPage, val);
		}

		private void OpenPageOnTop()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			object? value = AccessTools.Field(typeof(MenuManager), "currentMenuPage").GetValue(MenuManager.instance);
			MenuPage val = (MenuPage)((value is MenuPage) ? value : null);
			if (AccessTools.Field(typeof(MenuManager), "addedPagesOnTop").GetValue(MenuManager.instance) is List<MenuPage> list && !list.Contains(val))
			{
				((Component)menuPage).transform.localPosition = Vector3.zero;
				MenuManager.instance.PageAdd(menuPage);
				((MonoBehaviour)menuPage).StartCoroutine(AccessTools.Method(typeof(MenuPage), "LateStart", (Type[])null, (Type[])null).Invoke(menuPage, null) as IEnumerator);
				AccessTools.Field(typeof(MenuPage), "addedPageOnTop").SetValue(menuPage, false);
				AccessTools.Field(typeof(MenuPage), "parentPage").SetValue(menuPage, val);
				if (!list.Contains(val))
				{
					list.Add(menuPage);
				}
			}
		}
	}
	public sealed class REPOSlider : REPOElement
	{
		internal REPOMenuSliderFloat menuSliderFloat;

		private readonly float defaultValue;

		public string text { get; private set; }

		public string description { get; private set; }

		public float min { get; private set; }

		public float max { get; private set; }

		public int precision { get; private set; }

		public Action<float> onValueChanged { get; private set; }

		public REPOSlider(string text, string description, Action<float> onValueChanged, float min, float max, int precision, float defaultValue)
		{
			this.text = text;
			this.description = description;
			this.onValueChanged = onValueChanged;
			this.min = min;
			this.max = max;
			this.precision = precision;
			this.defaultValue = defaultValue;
		}

		public void SetText(string newText)
		{
			if (Object.op_Implicit((Object)(object)menuSliderFloat))
			{
				menuSliderFloat.SetHeader(newText);
			}
			text = newText;
		}

		public void SetMin(float newMin)
		{
			if (Object.op_Implicit((Object)(object)menuSliderFloat))
			{
				menuSliderFloat.min = newMin;
			}
			min = newMin;
		}

		public void SetMax(float newMax)
		{
			if (Object.op_Implicit((Object)(object)menuSliderFloat))
			{
				menuSliderFloat.max = newMax;
			}
			max = newMax;
		}

		public void SetPrecision(int newPrecision)
		{
			if (Object.op_Implicit((Object)(object)menuSliderFloat))
			{
				menuSliderFloat.decimalPlaces = newPrecision;
				menuSliderFloat.precision = (float)Math.Pow(10.0, -newPrecision);
			}
			precision = newPrecision;
		}

		public void SetOnValueChanged(Action<float> newOnValueChanged)
		{
			if (Object.op_Implicit((Object)(object)menuSliderFloat))
			{
				menuSliderFloat.onValueChanged = newOnValueChanged;
			}
			onValueChanged = newOnValueChanged;
		}

		public override RectTransform GetReference()
		{
			return MenuAPI.sliderTemplate;
		}

		public override void SetDefaults()
		{
			Object.Destroy((Object)(object)((Component)transform).GetComponent<MenuSliderMicrophone>());
			Object.Destroy((Object)(object)((Component)transform).GetComponent<MenuSlider>());
			menuSliderFloat = ((Component)transform).gameObject.AddComponent<REPOMenuSliderFloat>();
			((Object)transform).name = "Slider - " + text;
			SetMin(min);
			SetMax(max);
			SetPrecision(precision);
			SetOnValueChanged(onValueChanged);
			menuSliderFloat.Initialize(defaultValue);
			menuSliderFloat.SetHeader(text);
			menuSliderFloat.SetDescriptionText(description);
			afterBeingParented = delegate(MenuPage menuPage)
			{
				menuSliderFloat.menuPage = menuPage;
				MenuButton[] componentsInChildren = ((Component)transform).GetComponentsInChildren<MenuButton>();
				foreach (MenuButton obj in componentsInChildren)
				{
					AccessTools.Field(typeof(MenuButton), "parentPage").SetValue(obj, menuPage);
				}
			};
		}
	}
	public sealed class REPOToggle : REPOElement
	{
		private MenuTwoOptions menuTwoOptions;

		private TextMeshProUGUI toggleTextTMP;

		private TextMeshProUGUI onTextTMP;

		private TextMeshProUGUI offTextTMP;

		private readonly bool defaultValue;

		public string labelText { get; private set; }

		public string onText { get; private set; }

		public string offText { get; private set; }

		public Action<bool> onClick { get; private set; }

		public REPOToggle(string labelText, Action<bool> onClick, string onText, string offText, bool defaultValue)
		{
			this.labelText = labelText;
			this.onClick = onClick;
			this.onText = onText;
			this.offText = offText;
			this.defaultValue = defaultValue;
		}

		public void SetLabelText(string newLabelText)
		{
			if (Object.op_Implicit((Object)(object)toggleTextTMP))
			{
				((TMP_Text)toggleTextTMP).text = newLabelText;
			}
			labelText = newLabelText;
		}

		public void SetOnText(string newOnText)
		{
			if (Object.op_Implicit((Object)(object)onTextTMP))
			{
				((TMP_Text)onTextTMP).text = newOnText;
			}
			onText = newOnText;
		}

		public void SetOffText(string newOffText)
		{
			if (Object.op_Implicit((Object)(object)offTextTMP))
			{
				((TMP_Text)offTextTMP).text = newOffText;
			}
			offText = newOffText;
		}

		public void SetOnClick(Action<bool> newOnClick)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)menuTwoOptions))
			{
				menuTwoOptions.onOption1 = (UnityEvent)new ButtonClickedEvent();
				menuTwoOptions.onOption1.AddListener((UnityAction)delegate
				{
					newOnClick?.Invoke(obj: true);
				});
				menuTwoOptions.onOption2 = (UnityEvent)new ButtonClickedEvent();
				menuTwoOptions.onOption2.AddListener((UnityAction)delegate
				{
					newOnClick?.Invoke(obj: false);
				});
			}
			onClick = newOnClick;
		}

		public override RectTransform GetReference()
		{
			return MenuAPI.toggleTemplate;
		}

		public override void SetDefaults()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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)
			menuTwoOptions = ((Component)transform).GetComponent<MenuTwoOptions>();
			toggleTextTMP = ((Component)transform).GetComponentInChildren<TextMeshProUGUI>();
			onTextTMP = menuTwoOptions.option1TextMesh;
			offTextTMP = menuTwoOptions.option2TextMesh;
			((Object)transform).name = "Toggle Button - " + labelText;
			menuTwoOptions.customEvents = true;
			menuTwoOptions.settingSet = false;
			RectTransform rectTransform = ((TMP_Text)toggleTextTMP).rectTransform;
			Vector2 sizeDelta = ((TMP_Text)toggleTextTMP).rectTransform.sizeDelta;
			sizeDelta.y = ((TMP_Text)toggleTextTMP).rectTransform.sizeDelta.y - 2f;
			rectTransform.sizeDelta = sizeDelta;
			SetLabelText(labelText);
			SetOnText(onText);
			SetOffText(offText);
			Object.Destroy((Object)(object)((Component)transform).GetComponent<AudioButtonPushToTalk>());
			((MonoBehaviour)menuTwoOptions).StartCoroutine(SetupLate());
			afterBeingParented = delegate(MenuPage menuPage)
			{
				MenuButton[] componentsInChildren = ((Component)transform).GetComponentsInChildren<MenuButton>();
				MenuButton[] array = componentsInChildren;
				foreach (MenuButton obj in array)
				{
					AccessTools.Field(typeof(MenuButton), "parentPage").SetValue(obj, menuPage);
				}
			};
			IEnumerator SetupLate()
			{
				yield return null;
				if (defaultValue)
				{
					menuTwoOptions.OnOption1();
				}
				else
				{
					menuTwoOptions.OnOption2();
				}
				SetOnClick(onClick);
			}
		}
	}
}