Decompiled source of RumbleModUI v1.3.1

Mods/ModUI.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using RumbleModUI;
using TMPro;
using UnhollowerBaseLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
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: MelonInfo(typeof(RumbleModUIClass), "ModUI", "1.3.1", "Baumritter", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(ConsoleColor.DarkGreen)]
[assembly: AssemblyTitle("ModUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModUI")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("caa17032-5000-4195-b343-c26492084360")]
[assembly: AssemblyFileVersion("1.3.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.3.1.0")]
namespace RumbleModUI;

internal class General
{
	internal class Delay
	{
		private readonly bool debug = false;

		private DateTime debugTime;

		private object CRObj;

		public string name;

		private bool Running = false;

		public bool Done = false;

		private DateTime StartTime;

		private double Wait;

		public void Delay_Start(double WaitTime, bool AllowRetrigger = false)
		{
			if (!Running || AllowRetrigger)
			{
				if (Running)
				{
					MelonCoroutines.Stop(CRObj);
				}
				Done = false;
				Wait = WaitTime;
				StartTime = DateTime.Now;
				debugTime = DateTime.Now;
				CRObj = MelonCoroutines.Start(WaitLoop());
				if (debug)
				{
					MelonLogger.Msg(name + " - Started");
				}
			}
		}

		public void Delay_Stop(bool Done = false)
		{
			if (Done)
			{
				this.Done = true;
			}
			if (Running)
			{
				MelonCoroutines.Stop(CRObj);
			}
			Running = false;
			if (debug && Done)
			{
				MelonLogger.Msg(name + " - Done");
			}
			if (debug && !Done)
			{
				MelonLogger.Msg(name + " - Stopped");
			}
			TimeSpan timeSpan = DateTime.Now - debugTime;
			if (debug && Done)
			{
				MelonLogger.Msg(name + " - " + timeSpan.TotalMilliseconds);
			}
		}

		private IEnumerator WaitLoop()
		{
			WaitForFixedUpdate waitForFixedUpdate = new WaitForFixedUpdate();
			Running = true;
			while (true)
			{
				if (DateTime.Now >= StartTime.AddSeconds(Wait))
				{
					Delay_Stop(Done: true);
					yield return null;
				}
				yield return waitForFixedUpdate;
			}
		}
	}

	internal class Folders
	{
		private readonly bool debug = false;

		private string ModFolder;

		private List<string> SubFolders = new List<string>();

		public void SetModFolderCustom(string ModName)
		{
			ModFolder = ModName;
			if (debug)
			{
				MelonLogger.Msg("Set ModFolder to " + ModFolder);
			}
		}

		public void SetModFolderNamespace()
		{
			ModFolder = GetType().Namespace;
			if (debug)
			{
				MelonLogger.Msg("Set ModFolder to " + ModFolder);
			}
		}

		public void AddSubFolder(string FolderName)
		{
			SubFolders.Add(FolderName);
			if (debug)
			{
				MelonLogger.Msg("Added Subfolder " + FolderName);
			}
		}

		public void RemoveSubFolder(string FolderName)
		{
			SubFolders.Remove(FolderName);
			if (debug)
			{
				MelonLogger.Msg("Removed Subfolder " + FolderName);
			}
		}

		public string GetModFolder()
		{
			return ModFolder;
		}

		public string GetSubFolder(int index)
		{
			if (SubFolders.Count == 0)
			{
				return null;
			}
			return SubFolders[index];
		}

		public void CheckAllFoldersExist()
		{
			CreateFolderIfNotExisting(GetFolderString());
			if (SubFolders.Count <= 0)
			{
				return;
			}
			foreach (string subFolder in SubFolders)
			{
				CreateFolderIfNotExisting(GetFolderString(subFolder));
			}
		}

		public void RemoveOtherFolders()
		{
			if (debug)
			{
				MelonLogger.Msg("Folder Removal: Start");
			}
			string[] directories = Directory.GetDirectories(GetFolderString("", IgnoreList: true));
			string[] array = directories;
			foreach (string text in array)
			{
				if (debug)
				{
					MelonLogger.Msg(text);
				}
				string text2 = text.Split(new char[1] { '\\' })[^1];
				if (CheckIfFolderInList(text2))
				{
					Directory.Delete(GetFolderString(text2, IgnoreList: true), recursive: true);
					if (debug)
					{
						MelonLogger.Msg("Deleted: " + GetFolderString(text2, IgnoreList: true));
					}
				}
			}
			if (debug)
			{
				MelonLogger.Msg("Folder Removal: End");
			}
		}

		public string GetFolderString(string SubFolder = "", bool IgnoreList = false)
		{
			string text = MelonUtils.UserDataDirectory + "\\" + ModFolder;
			if (SubFolder != "" && (SubFolders.Contains(SubFolder) || IgnoreList))
			{
				text = ((!IgnoreList) ? (text + "\\" + SubFolders.FirstOrDefault((string x) => x.Contains(SubFolder))) : (text + "\\" + SubFolder));
				if (debug)
				{
					MelonLogger.Msg("Generated Path: " + text);
				}
			}
			else if (debug)
			{
				MelonLogger.Msg("Generated Path with no SubFolder: " + text);
			}
			return text;
		}

		private void CreateFolderIfNotExisting(string Path)
		{
			if (debug && !Directory.Exists(Path))
			{
				MelonLogger.Msg("Path doesn't exist: " + Path);
			}
			else if (debug && Directory.Exists(Path))
			{
				MelonLogger.Msg("Path does exist: " + Path);
			}
			if (!Directory.Exists(Path))
			{
				Directory.CreateDirectory(Path);
			}
		}

		private bool CheckIfFolderInList(string FolderName)
		{
			bool flag = false;
			string folderString = GetFolderString(FolderName, IgnoreList: true);
			if (!SubFolders.Contains(FolderName) && Directory.Exists(folderString))
			{
				flag = true;
			}
			if (debug && flag)
			{
				MelonLogger.Msg("Folder not in List " + folderString);
			}
			else if (debug && !flag)
			{
				MelonLogger.Msg("Folder in List " + folderString);
			}
			return flag;
		}
	}
}
public class LinkGroup
{
	public string Name { get; set; }

	public int Index { get; set; }
}
public class Mod
{
	public const string SettingsFile = "Settings.txt";

	private const string DuplicateErrorMsg = "AddToList failed: Name not unique";

	private bool debug = false;

	private General.Folders Folders = new General.Folders();

	public List<ModSetting> Settings = new List<ModSetting>();

	public List<LinkGroup> LinkGroups = new List<LinkGroup>();

	public string ModName { get; set; }

	public string ModVersion { get; set; }

	private bool IsFileLoaded { get; set; }

	private bool IsSaved { get; set; }

	private bool IsAdded { get; set; }

	public void SetFolder(string Folder)
	{
		Folders.SetModFolderCustom(Folder);
	}

	public void SetSubFolder(string Folder)
	{
		Folders.RemoveSubFolder(Folder);
		Folders.AddSubFolder(Folder);
	}

	public void SetUIStatus(bool Status)
	{
		IsAdded = Status;
	}

	public string GetFolder()
	{
		return Folders.GetModFolder();
	}

	public string GetSubFolder()
	{
		return Folders.GetSubFolder(0);
	}

	public bool GetReadStatus()
	{
		return IsFileLoaded;
	}

	public bool GetSaveStatus()
	{
		return IsSaved;
	}

	public bool GetUIStatus()
	{
		return IsAdded;
	}

	public void ConfirmSave()
	{
		IsSaved = false;
	}

	public void SetLinkGroup(int index, string name = "Group")
	{
		string name2 = ((!(name == "Group")) ? name : ("Group" + index));
		if (LinkGroups.Count > 0 && LinkGroups.Exists((LinkGroup x) => x.Index == index) && name != "Group")
		{
			LinkGroups.Find((LinkGroup x) => x.Index == index).Name = name2;
			return;
		}
		LinkGroup item = new LinkGroup
		{
			Index = index,
			Name = name2
		};
		LinkGroups.Add(item);
	}

	public ModSetting<string> AddToList(string Name, ModSetting.AvailableTypes StringType, string Value = "", string Description = "")
	{
		if (StringType != 0 && StringType != ModSetting.AvailableTypes.String)
		{
			MelonLogger.Msg("AddToList failed: ValueType != String/Description");
			return null;
		}
		if (Settings.Count > 0 && Settings.Exists((ModSetting x) => x.Name == Name))
		{
			MelonLogger.Msg("AddToList failed: Name not unique: " + Name);
			return null;
		}
		ModSetting<string> modSetting = new ModSetting<string>
		{
			Name = Name,
			Description = Description,
			Value = Value,
			SavedValue = Value,
			LinkGroup = 0,
			ValueType = StringType
		};
		Settings.Add(modSetting);
		return modSetting;
	}

	public ModSetting<bool> AddToList(string Name, bool Value = false, int LinkGroup = 0, string Description = "")
	{
		if (Settings.Count > 0 && Settings.Exists((ModSetting x) => x.Name == Name))
		{
			MelonLogger.Msg("AddToList failed: Name not unique: " + Name);
			return null;
		}
		ModSetting<bool> modSetting = new ModSetting<bool>
		{
			Name = Name,
			Description = Description,
			Value = Value,
			SavedValue = Value,
			LinkGroup = LinkGroup,
			ValueType = ModSetting.AvailableTypes.Boolean
		};
		if (LinkGroup != 0)
		{
			SetLinkGroup(LinkGroup);
		}
		Settings.Add(modSetting);
		return modSetting;
	}

	public ModSetting<int> AddToList(string Name, int Value = 0, string Description = "")
	{
		if (Settings.Count > 0 && Settings.Exists((ModSetting x) => x.Name == Name))
		{
			MelonLogger.Msg("AddToList failed: Name not unique: " + Name);
			return null;
		}
		ModSetting<int> modSetting = new ModSetting<int>
		{
			Name = Name,
			Description = Description,
			Value = Value,
			SavedValue = Value,
			LinkGroup = 0,
			ValueType = ModSetting.AvailableTypes.Integer
		};
		Settings.Add(modSetting);
		return modSetting;
	}

	public ModSetting<float> AddToList(string Name, float Value = 0f, string Description = "")
	{
		if (Settings.Count > 0 && Settings.Exists((ModSetting x) => x.Name == Name))
		{
			MelonLogger.Msg("AddToList failed: Name not unique: " + Name);
			return null;
		}
		ModSetting<float> modSetting = new ModSetting<float>
		{
			Name = Name,
			Description = Description,
			Value = Value,
			SavedValue = Value,
			LinkGroup = 0,
			ValueType = ModSetting.AvailableTypes.Float
		};
		Settings.Add(modSetting);
		return modSetting;
	}

	public ModSetting<double> AddToList(string Name, double Value = 0.0, string Description = "")
	{
		if (Settings.Count > 0 && Settings.Exists((ModSetting x) => x.Name == Name))
		{
			MelonLogger.Msg("AddToList failed: Name not unique: " + Name);
			return null;
		}
		ModSetting<double> modSetting = new ModSetting<double>
		{
			Name = Name,
			Description = Description,
			Value = Value,
			SavedValue = Value,
			LinkGroup = 0,
			ValueType = ModSetting.AvailableTypes.Double
		};
		Settings.Add(modSetting);
		return modSetting;
	}

	public void AddValidation(string name, ValidationParameters parameters)
	{
		Settings.Find((ModSetting x) => x.Name == name).ValidationParameters = parameters;
	}

	public bool ChangeValue(string Name, string Value = "")
	{
		foreach (ModSetting setting in Settings)
		{
			if (!(setting.Name == Name))
			{
				continue;
			}
			if (setting.LinkGroup != 0 && setting.ValueType == ModSetting.AvailableTypes.Boolean && Value == "true")
			{
				foreach (ModSetting setting2 in Settings)
				{
					if (setting2.Name != Name && setting2.LinkGroup == setting.LinkGroup)
					{
						setting2.Value = false;
					}
				}
			}
			return ValueValidation(Value, setting);
		}
		MelonLogger.Msg(ModName + " - Setting does not exist.");
		return false;
	}

	private bool ValueValidation(string value, ModSetting ReferenceSetting)
	{
		switch (ReferenceSetting.ValueType)
		{
		case ModSetting.AvailableTypes.Boolean:
			if (value.ToLower().Equals("true") || value.ToLower().Equals("false"))
			{
				ModSetting<bool> modSetting2 = (ModSetting<bool>)ReferenceSetting;
				if (value.ToLower().Equals("true"))
				{
					modSetting2.Value = true;
				}
				else
				{
					modSetting2.Value = false;
				}
				return true;
			}
			return false;
		case ModSetting.AvailableTypes.Integer:
		{
			if (int.TryParse(value, out var _))
			{
				ModSetting<int> modSetting5 = (ModSetting<int>)ReferenceSetting;
				modSetting5.Value = int.Parse(value);
				return true;
			}
			return false;
		}
		case ModSetting.AvailableTypes.Float:
		{
			if (float.TryParse(value, out var _))
			{
				ModSetting<float> modSetting3 = (ModSetting<float>)ReferenceSetting;
				modSetting3.Value = float.Parse(value);
				return true;
			}
			return false;
		}
		case ModSetting.AvailableTypes.Double:
		{
			if (double.TryParse(value, out var _))
			{
				ModSetting<double> modSetting4 = (ModSetting<double>)ReferenceSetting;
				modSetting4.Value = double.Parse(value);
				return true;
			}
			return false;
		}
		case ModSetting.AvailableTypes.String:
		{
			ModSetting<string> modSetting = (ModSetting<string>)ReferenceSetting;
			if (!modSetting.ValidationParameters.DoValidation(value))
			{
				return false;
			}
			modSetting.Value = value;
			return true;
		}
		default:
			return false;
		}
	}

	public void SaveModData(string UI_String)
	{
		string path = ((Folders.GetSubFolder(0) == null) ? (Folders.GetFolderString() + "\\Settings.txt") : (Folders.GetFolderString(Folders.GetSubFolder(0)) + "\\Settings.txt"));
		Folders.CheckAllFoldersExist();
		string text = ModName + " " + ModVersion + Environment.NewLine + UI_String + Environment.NewLine;
		foreach (ModSetting setting in Settings)
		{
			if (setting.ValueType != 0)
			{
				text = text + setting.Name + ": " + setting.GetValueAsString() + Environment.NewLine;
			}
		}
		File.WriteAllText(path, text);
		for (int i = 0; i < Settings.Count; i++)
		{
			Settings[i].SavedValue = Settings[i].Value;
		}
		IsSaved = true;
	}

	public void DiscardModData()
	{
		for (int i = 0; i < Settings.Count; i++)
		{
			Settings[i].Value = Settings[i].SavedValue;
		}
	}

	public void GetFromFile()
	{
		bool flag = false;
		string path = ((Folders.GetSubFolder(0) == null) ? (Folders.GetFolderString() + "\\Settings.txt") : (Folders.GetFolderString(Folders.GetSubFolder(0)) + "\\Settings.txt"));
		if (!File.Exists(path))
		{
			return;
		}
		string[] array = File.ReadAllLines(path);
		if (array[0].Contains(ModName) && array[0].Contains(ModVersion))
		{
			flag = true;
			array[0] = "";
			array[1] = "";
		}
		if (flag)
		{
			string[] array2 = array;
			foreach (string text in array2)
			{
				foreach (ModSetting setting in Settings)
				{
					if (!text.Contains(setting.Name))
					{
						continue;
					}
					bool flag2 = ValueValidation(text.Substring(setting.Name.Length + 2), setting);
					if (flag2)
					{
						setting.SavedValue = setting.Value;
					}
					if (!flag2)
					{
						MelonLogger.Msg(ModName + " - " + setting.Name + " File Read Error.");
						continue;
					}
					bool flag3 = true;
					if (debug)
					{
						MelonLogger.Msg(ModName + " - " + setting.Name + " " + setting.Value.ToString());
					}
				}
			}
			IsFileLoaded = true;
		}
		else
		{
			IsFileLoaded = false;
		}
	}
}
public abstract class ModSetting
{
	public enum AvailableTypes
	{
		Description,
		String,
		Integer,
		Float,
		Double,
		Boolean
	}

	public string Name = "";

	public AvailableTypes ValueType = AvailableTypes.String;

	public string Description = "";

	public int LinkGroup = 0;

	public ValidationParameters ValidationParameters = new ValidationTemplate();

	public abstract object Value { get; set; }

	public abstract object SavedValue { get; set; }

	public ModSetting()
	{
	}

	public abstract string GetValueAsString();
}
public class ModSetting<T> : ModSetting
{
	private T BG_SaveVariable;

	private T BG_TempVariable;

	public override object Value
	{
		get
		{
			return BG_TempVariable;
		}
		set
		{
			BG_TempVariable = (T)value;
		}
	}

	public override object SavedValue
	{
		get
		{
			return BG_SaveVariable;
		}
		set
		{
			BG_SaveVariable = (T)value;
		}
	}

	public override string GetValueAsString()
	{
		if (ValueType == AvailableTypes.Boolean)
		{
			return BG_TempVariable.ToString().ToLower();
		}
		return BG_TempVariable.ToString();
	}
}
public static class BuildInfo
{
	public const string ModName = "ModUI";

	public const string ModVersion = "1.3.1";

	public const string Description = "Adds a universal UI for Mod Creators";

	public const string Author = "Baumritter";

	public const string Company = "";
}
public class RumbleModUIClass : MelonMod
{
	private bool VRButtonsPressed = false;

	private bool VRButtonsAllowed = false;

	private General.Delay Delay = new General.Delay
	{
		name = "Delay"
	};

	public static UI UI_Obj = new UI();

	private static InputActionMap map = new InputActionMap("Tha Map");

	private static InputAction rightTrigger = InputActionSetupExtensions.AddAction(map, "Right Trigger", (InputActionType)0, (string)null, (string)null, (string)null, (string)null, (string)null);

	private static InputAction rightPrimary = InputActionSetupExtensions.AddAction(map, "Right Primary", (InputActionType)0, (string)null, (string)null, (string)null, (string)null, (string)null);

	private static InputAction leftTrigger = InputActionSetupExtensions.AddAction(map, "Left Trigger", (InputActionType)0, (string)null, (string)null, (string)null, (string)null, (string)null);

	private static InputAction leftPrimary = InputActionSetupExtensions.AddAction(map, "Left Primary", (InputActionType)0, (string)null, (string)null, (string)null, (string)null, (string)null);

	private Mod ModUI;

	public override void OnLateInitializeMelon()
	{
		((MelonBase)this).OnLateInitializeMelon();
		InputActionSetupExtensions.AddBinding(rightTrigger, "<XRController>{RightHand}/trigger", (string)null, (string)null, (string)null);
		InputActionSetupExtensions.AddBinding(rightPrimary, "<XRController>{RightHand}/primaryButton", (string)null, (string)null, (string)null);
		InputActionSetupExtensions.AddBinding(leftTrigger, "<XRController>{LeftHand}/trigger", (string)null, (string)null, (string)null);
		InputActionSetupExtensions.AddBinding(leftPrimary, "<XRController>{LeftHand}/primaryButton", (string)null, (string)null, (string)null);
		map.Enable();
	}

	public override void OnUpdate()
	{
		((MelonBase)this).OnUpdate();
		if (!UI_Obj.GetInit() && Delay.Done)
		{
			ModUI = UI_Obj.InitUI("Mod_Setting_UI");
			VRButtonsAllowed = (bool)ModUI.Settings.Find((ModSetting x) => x.Name == "Enable VR Menu Input").Value;
		}
		if (ModUI != null && ModUI.GetSaveStatus())
		{
			VRButtonsAllowed = (bool)ModUI.Settings.Find((ModSetting x) => x.Name == "Enable VR Menu Input").Value;
		}
		if (Input.GetKeyDown((KeyCode)291) || (VRButtonsAllowed && VRActivationAction()))
		{
			if (UI_Obj.IsUIVisible())
			{
				UI_Obj.HideUI();
			}
			else
			{
				UI_Obj.ShowUI();
			}
		}
	}

	private bool VRActivationAction()
	{
		float num = 0.9f;
		float num2 = 0.1f;
		if (rightTrigger.ReadValue<float>() >= num && rightPrimary.ReadValue<float>() >= num && leftTrigger.ReadValue<float>() >= num && leftPrimary.ReadValue<float>() >= num && !VRButtonsPressed)
		{
			VRButtonsPressed = true;
			return true;
		}
		if (rightTrigger.ReadValue<float>() <= num2 && rightPrimary.ReadValue<float>() <= num2 && leftTrigger.ReadValue<float>() <= num2 && leftPrimary.ReadValue<float>() <= num2 && VRButtonsPressed)
		{
			VRButtonsPressed = false;
		}
		return false;
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName);
		Delay.Delay_Start(3.0);
	}
}
public class UI
{
	public enum AnchorPresets
	{
		TopLeft,
		TopCenter,
		TopRight,
		MiddleLeft,
		MiddleCenter,
		MiddleRight,
		BottomLeft,
		BottomCenter,
		BottomRight,
		BottomStretch,
		VertStretchLeft,
		VertStretchRight,
		VertStretchCenter,
		HorStretchTop,
		HorStretchMiddle,
		HorStretchBottom,
		StretchAll
	}

	public enum PivotPresets
	{
		TopLeft,
		TopCenter,
		TopRight,
		MiddleLeft,
		MiddleCenter,
		MiddleRight,
		BottomLeft,
		BottomCenter,
		BottomRight
	}

	public enum Themes
	{
		Light,
		Dark,
		HighContrast
	}

	private const string ModName = "ModUI";

	private const string ModVersion = "1.3.1";

	private const string ModDescription = "This is the Mod UI by Baumritter.";

	private const int ThemeCount = 3;

	private Color Light_Text = Color.black;

	private Color Dark_Text = Color.white;

	private Color HighContrast_Text = Color.yellow;

	private Color Light_FG = new Color(0.9f, 0.9f, 0.9f, 0.9f);

	private Color Light_BG = new Color(0.7f, 0.7f, 0.7f, 0.9f);

	private Color Dark_FG = new Color(0.3f, 0.3f, 0.3f, 0.9f);

	private Color Dark_BG = new Color(0.1f, 0.1f, 0.1f, 0.9f);

	private Color HighContrast_FG = new Color(0f, 0.7f, 1f, 1f);

	private Color HighContrast_BG = new Color(1f, 0f, 0.7f, 1f);

	private Vector3 Scl_1x1 = new Vector3(1f, 1f, 0f);

	private Vector3 Pos_BaseObj = new Vector3(0f, 0f, 0f);

	private Vector3 Pos_OuterBG = new Vector3(0f, 0f, 0f);

	private Vector3 Pos_DescBG = new Vector3(10f, -190f, 0f);

	private Vector3 Pos_DescText = new Vector3(5f, -5f, 0f);

	private Vector3 Pos_Title = new Vector3(0f, 0f, 0f);

	private Vector3 Pos_DD1 = new Vector3(10f, -40f, 0f);

	private Vector3 Pos_DD2 = new Vector3(10f, -90f, 0f);

	private Vector3 Pos_IF = new Vector3(10f, -140f, 0f);

	private Vector3 Pos_TB = new Vector3(0f, 90f, 0f);

	private Vector3 Pos_B1 = new Vector3(10f, 10f, 0f);

	private Vector3 Pos_B2 = new Vector3(240f, 10f, 0f);

	private Vector2 Size_Base = new Vector2(400f, 500f);

	private Vector2 Size_Title = new Vector2(140f, 30f);

	private Vector2 Size_DD = new Vector2(380f, 40f);

	private Vector2 Size_DD_Ext = new Vector2(0f, 200f);

	private Vector2 Size_IF = new Vector2(380f, 40f);

	private Vector2 Size_TB = new Vector2(200f, 40f);

	private Vector2 Size_DescBG = new Vector2(-20f, -240f);

	private Vector2 Size_DescText = new Vector2(-5f, 5f);

	private Vector2 Size_Button = new Vector2(150f, 30f);

	public string Name = "";

	private bool debug_UI = false;

	private bool DoRefresh = false;

	private bool IsInit = false;

	private bool IsVisible = false;

	private bool Running = false;

	private int ModSelection = 0;

	private int SettingsSelection = 0;

	private Themes currentTheme = Themes.Light;

	private GameObject UI_Parent;

	private GameObject UI_Object = new GameObject();

	private GameObject UI_Title = new GameObject();

	private GameObject UI_OuterBG = new GameObject();

	private GameObject UI_Desc = new GameObject();

	private GameObject UI_DropDown_Mod = new GameObject();

	private GameObject UI_DropDown_Settings = new GameObject();

	private GameObject UI_InputField = new GameObject();

	private GameObject UI_ToggleBox = new GameObject();

	private GameObject UI_ButtonSave = new GameObject();

	private GameObject UI_ButtonDisc = new GameObject();

	private Texture2D[] CustomAssets = (Texture2D[])(object)new Texture2D[4];

	private string[] CustomAssetsNames = new string[4];

	private object Enum_Theme;

	private object Enum_Save;

	private object Enum_Discard;

	private object Enum_Dragger;

	private List<Mod> Mod_Options = new List<Mod>();

	private List<TextMeshProUGUI> Theme_Text = new List<TextMeshProUGUI>();

	private List<Image> Theme_Foreground = new List<Image>();

	private List<Image> Theme_Background = new List<Image>();

	public bool GetInit()
	{
		return IsInit;
	}

	public Mod InitUI(string Name)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_00a9: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: 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_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: 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_029b: Unknown result type (might be due to invalid IL or missing references)
		if (!IsInit)
		{
			InitCustomTextures();
			Pos_BaseObj = new Vector3((float)(Screen.width / 2), (float)(Screen.height / 2), 0f);
			UI_Parent = GameObject.Find("Game Instance/UI");
			this.Name = Name;
			UI_Object = new GameObject();
			UI_Object.SetActive(false);
			((Object)UI_Object).name = Name;
			UI_Object.transform.SetParent(UI_Parent.transform);
			UI_Object.AddComponent<RectTransform>();
			UI_Object.GetComponent<RectTransform>().sizeDelta = Size_Base;
			UI_Object.transform.position = Pos_BaseObj;
			UI_Object.transform.localScale = new Vector3(1.5f, 1.5f, 0f);
			SetAnchors(UI_Object, AnchorPresets.MiddleCenter);
			SetPivot(UI_Object, PivotPresets.MiddleCenter);
			UI_OuterBG = CreateBackgroundBox("Outer BG", Pos_OuterBG);
			UI_Desc = CreateDescription("Description BG");
			UI_Title = CreateTitle("Title", Pos_Title);
			UI_DropDown_Mod = CreateDropdown("DropDown_Mods", Pos_DD1);
			((UnityEvent<int>)(object)UI_DropDown_Mod.GetComponent<TMP_Dropdown>().onValueChanged).AddListener(UnityAction<int>.op_Implicit((Action<int>)delegate(int value)
			{
				OnModSelectionChange(value);
			}));
			UI_DropDown_Settings = CreateDropdown("DropDown_Settings", Pos_DD2);
			((UnityEvent<int>)(object)UI_DropDown_Settings.GetComponent<TMP_Dropdown>().onValueChanged).AddListener(UnityAction<int>.op_Implicit((Action<int>)delegate(int value)
			{
				OnSettingsSelectionChange(value);
			}));
			UI_InputField = CreateInputField("InputField", Pos_IF);
			((UnityEvent<string>)(object)UI_InputField.GetComponent<TMP_InputField>().onSubmit).AddListener(UnityAction<string>.op_Implicit((Action<string>)delegate(string value)
			{
				OnInputFieldChange(value);
			}));
			UI_ToggleBox = CreateToggleBox("ToggleBox", Pos_TB);
			((UnityEvent<bool>)(object)UI_ToggleBox.GetComponent<Toggle>().onValueChanged).AddListener(UnityAction<bool>.op_Implicit((Action<bool>)delegate(bool value)
			{
				OnToggleChange(value);
			}));
			UI_ToggleBox.SetActive(false);
			UI_ButtonSave = CreateButton("SaveButton", Pos_B1, "Save");
			((UnityEvent)UI_ButtonSave.GetComponent<Button>().onClick).AddListener(UnityAction.op_Implicit((Action)delegate
			{
				ButtonHandler(0);
			}));
			UI_ButtonDisc = CreateButton("DiscardButton", Pos_B2, "Discard");
			((UnityEvent)UI_ButtonDisc.GetComponent<Button>().onClick).AddListener(UnityAction.op_Implicit((Action)delegate
			{
				ButtonHandler(1);
			}));
			Mod result = AddSelf();
			IsInit = true;
			if (debug_UI)
			{
				MelonLogger.Msg("UI - Initialised");
			}
			return result;
		}
		if (debug_UI)
		{
			MelonLogger.Msg("UI - Already initialised");
		}
		return null;
	}

	public void ShowUI()
	{
		if (IsInit)
		{
			UI_Object.SetActive(true);
			DoOnShow();
			IsVisible = true;
			if (debug_UI)
			{
				MelonLogger.Msg("UI - Shown");
			}
		}
	}

	public void HideUI()
	{
		if (IsInit)
		{
			UI_Object.SetActive(false);
			DoOnHide();
			IsVisible = false;
			if (debug_UI)
			{
				MelonLogger.Msg("UI - Hidden");
			}
		}
	}

	public void ForceRefresh()
	{
		DoRefresh = true;
	}

	public bool IsModSelected(string name)
	{
		if (Mod_Options[ModSelection].ModName == name)
		{
			return true;
		}
		return false;
	}

	public bool IsOptionSelected(string name)
	{
		if (Mod_Options[ModSelection].Settings[SettingsSelection].Name == name)
		{
			return true;
		}
		return false;
	}

	public bool IsUIVisible()
	{
		return IsVisible;
	}

	public void AddMod(Mod Input)
	{
		bool flag = false;
		foreach (Mod mod_Option in Mod_Options)
		{
			if (mod_Option.ModName == Input.ModName)
			{
				flag = true;
			}
		}
		if (!flag && Input.ModName != "" && Input.ModVersion != "" && Input.GetFolder() != "")
		{
			Mod_Options.Add(Input);
			Input.SetUIStatus(Status: true);
			return;
		}
		if (debug_UI)
		{
			MelonLogger.Msg("Modlist - Mod already exists.");
		}
		if (Input.ModName == "" || Input.ModVersion == "" || Input.GetFolder() == "")
		{
			MelonLogger.Msg("Mandatory Values not set.");
		}
	}

	public void RemoveMod(Mod Input)
	{
		bool flag = false;
		foreach (Mod mod_Option in Mod_Options)
		{
			if (mod_Option.ModName == Input.ModName)
			{
				Mod_Options.Remove(mod_Option);
				Input.SetUIStatus(Status: false);
				flag = true;
			}
		}
		if (!flag && debug_UI)
		{
			MelonLogger.Msg("Modlist - Mod doesn't exist.");
		}
	}

	private Mod AddSelf()
	{
		Mod mod = new Mod();
		mod.ModName = "ModUI";
		mod.ModVersion = "1.3.1";
		mod.SetFolder("ModUI");
		mod.AddToList("Description", ModSetting.AvailableTypes.Description, "", "This is the Mod UI by Baumritter.");
		mod.AddToList("Light Theme", Value: true, 1, "Turns Light Theme on/off.");
		mod.AddToList("Dark Theme", Value: false, 1, "Turns Dark Theme on/off.");
		mod.AddToList("High Contrast Theme", Value: false, 1, "Turns High Contrast Theme on/off.");
		mod.AddToList("Enable VR Menu Input", Value: true, 0, "Allows the user to open/close the menu by pressing both triggers and primary buttons at the same time");
		mod.SetLinkGroup(1, "Themes");
		mod.GetFromFile();
		foreach (ModSetting setting in mod.Settings)
		{
			if (setting.ValueType == ModSetting.AvailableTypes.Boolean && (bool)setting.Value)
			{
				switch (setting.Name)
				{
				case "Light Theme":
					currentTheme = Themes.Light;
					break;
				case "Dark Theme":
					currentTheme = Themes.Dark;
					break;
				case "High Contrast Theme":
					currentTheme = Themes.HighContrast;
					break;
				}
				ChangeTheme(currentTheme);
				break;
			}
		}
		AddMod(mod);
		return mod;
	}

	private void OnModSelectionChange(int Input)
	{
		ModSelection = Input;
		DoOnModSelect();
	}

	private void OnSettingsSelectionChange(int Input)
	{
		SettingsSelection = Input;
		DoOnSettingsSelect();
	}

	private void OnInputFieldChange(string Input)
	{
		DoOnInput(Input);
	}

	private void OnToggleChange(bool Input)
	{
		DoOnToggle(Input);
	}

	private void DoOnShow()
	{
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		List<string> val = new List<string>();
		foreach (Mod mod_Option in Mod_Options)
		{
			val.Add(mod_Option.ModVersion + " " + mod_Option.ModName);
		}
		UI_DropDown_Mod.GetComponent<TMP_Dropdown>().ClearOptions();
		UI_DropDown_Mod.GetComponent<TMP_Dropdown>().AddOptions(val);
		val.Clear();
		foreach (ModSetting setting in Mod_Options[0].Settings)
		{
			if (setting.ValueType == ModSetting.AvailableTypes.Boolean && setting.LinkGroup != 0)
			{
				LinkGroup linkGroup = Mod_Options[0].LinkGroups.Find((LinkGroup x) => x.Index == setting.LinkGroup);
				val.Add(linkGroup.Name + " - " + setting.Name);
			}
			else
			{
				val.Add(setting.Name);
			}
		}
		UI_DropDown_Settings.GetComponent<TMP_Dropdown>().ClearOptions();
		UI_DropDown_Settings.GetComponent<TMP_Dropdown>().AddOptions(val);
		UI_ToggleBox.SetActive(false);
		UI_InputField.SetActive(true);
		ModSelection = 0;
		SettingsSelection = 0;
		Inputfield_SetPlaceholder();
		((TMP_Text)((Component)UI_Desc.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Mod_Options[ModSelection].Settings[SettingsSelection].Description;
		UI_Object.transform.position = Pos_BaseObj;
		Enum_Theme = MelonCoroutines.Start(WaitForThemeChange());
		Enum_Dragger = MelonCoroutines.Start(Dragger());
	}

	private void DoOnHide()
	{
		if (Enum_Theme != null)
		{
			MelonCoroutines.Stop(Enum_Theme);
		}
		if (Enum_Dragger != null)
		{
			MelonCoroutines.Stop(Enum_Dragger);
		}
	}

	private void DoOnModSelect()
	{
		List<string> val = new List<string>();
		foreach (ModSetting setting in Mod_Options[ModSelection].Settings)
		{
			if (setting.ValueType == ModSetting.AvailableTypes.Boolean && setting.LinkGroup != 0)
			{
				LinkGroup linkGroup = Mod_Options[ModSelection].LinkGroups.Find((LinkGroup x) => x.Index == setting.LinkGroup);
				val.Add(linkGroup.Name + " - " + setting.Name);
			}
			else
			{
				val.Add(setting.Name);
			}
		}
		UI_DropDown_Settings.GetComponent<TMP_Dropdown>().ClearOptions();
		SettingsSelection = 0;
		UI_DropDown_Settings.GetComponent<TMP_Dropdown>().AddOptions(val);
		DoOnSettingsSelect();
		Inputfield_SetPlaceholder();
	}

	private void DoOnSettingsSelect()
	{
		((TMP_Text)((Component)UI_Desc.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Mod_Options[ModSelection].Settings[SettingsSelection].Description;
		if (Mod_Options[ModSelection].Settings[SettingsSelection].ValueType == ModSetting.AvailableTypes.Boolean)
		{
			UI_InputField.SetActive(false);
			UI_ToggleBox.SetActive(true);
			ToggleBox_AdjustValue();
		}
		else
		{
			UI_ToggleBox.SetActive(false);
			UI_InputField.SetActive(true);
			Inputfield_SetPlaceholder();
		}
	}

	private void DoOnInput(string Input)
	{
		bool valid = Mod_Options[ModSelection].ChangeValue(Mod_Options[ModSelection].Settings[SettingsSelection].Name, Input);
		Inputfield_SetPlaceholder(valid);
		UI_InputField.GetComponent<TMP_InputField>().text = "";
	}

	private void DoOnToggle(bool value)
	{
		if (value)
		{
			Mod_Options[ModSelection].ChangeValue(Mod_Options[ModSelection].Settings[SettingsSelection].Name, "true");
			if (debug_UI)
			{
				MelonLogger.Msg("Enum - Toggle true");
			}
		}
		else
		{
			Mod_Options[ModSelection].ChangeValue(Mod_Options[ModSelection].Settings[SettingsSelection].Name, "false");
			if (debug_UI)
			{
				MelonLogger.Msg("Enum - Toggle false");
			}
		}
	}

	private void ToggleBox_AdjustValue()
	{
		if ((bool)Mod_Options[ModSelection].Settings[SettingsSelection].Value)
		{
			UI_ToggleBox.GetComponent<Toggle>().isOn = true;
		}
		else
		{
			UI_ToggleBox.GetComponent<Toggle>().isOn = false;
		}
	}

	private void Inputfield_SetPlaceholder(bool Valid = true)
	{
		//IL_01bf: 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_0160: 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)
		if (Mod_Options[ModSelection].Settings[SettingsSelection].Name == "Description")
		{
			((TMP_Text)((Component)UI_InputField.transform.GetChild(0).FindChild("Placeholder")).GetComponent<TextMeshProUGUI>()).text = "Available Settings: " + (Mod_Options[ModSelection].Settings.Count - 1);
		}
		else
		{
			((TMP_Text)((Component)UI_InputField.transform.GetChild(0).FindChild("Placeholder")).GetComponent<TextMeshProUGUI>()).text = "Current Value: " + Mod_Options[ModSelection].Settings[SettingsSelection].GetValueAsString();
		}
		if (Valid)
		{
			switch (currentTheme)
			{
			case Themes.Light:
				((TMP_Text)((Component)UI_InputField.transform.GetChild(0).FindChild("Placeholder")).GetComponent<TextMeshProUGUI>()).color = Light_Text;
				break;
			case Themes.Dark:
				((TMP_Text)((Component)UI_InputField.transform.GetChild(0).FindChild("Placeholder")).GetComponent<TextMeshProUGUI>()).color = Dark_Text;
				break;
			case Themes.HighContrast:
				((TMP_Text)((Component)UI_InputField.transform.GetChild(0).FindChild("Placeholder")).GetComponent<TextMeshProUGUI>()).color = HighContrast_Text;
				break;
			}
		}
		else
		{
			((TMP_Text)((Component)UI_InputField.transform.GetChild(0).FindChild("Placeholder")).GetComponent<TextMeshProUGUI>()).color = Color.red;
		}
	}

	private IEnumerator WaitForThemeChange()
	{
		WaitForFixedUpdate waitForFixedUpdate = new WaitForFixedUpdate();
		bool[] ThemeOld = new bool[3];
		bool[] ThemeNew = new bool[3];
		int index = Mod_Options.FindIndex((Mod x) => x.ModName == "ModUI");
		for (int k = 1; k < 4; k++)
		{
			ThemeOld[k - 1] = (bool)Mod_Options[index].Settings[k].Value;
		}
		while (true)
		{
			if (ModSelection == index)
			{
				for (int j = 1; j < 4; j++)
				{
					ThemeNew[j - 1] = (bool)Mod_Options[index].Settings[j].Value;
				}
				for (int i = 0; i < ThemeOld.Length; i++)
				{
					if (!ThemeOld[i] && ThemeNew[i])
					{
						switch (i)
						{
						case 0:
							ChangeTheme(Themes.Light);
							break;
						case 1:
							ChangeTheme(Themes.Dark);
							break;
						case 2:
							ChangeTheme(Themes.HighContrast);
							break;
						}
					}
				}
			}
			yield return waitForFixedUpdate;
		}
	}

	private void ButtonHandler(int index)
	{
		switch (index)
		{
		case 0:
			SaveSettings();
			if (debug_UI)
			{
				MelonLogger.Msg("Button - Save");
			}
			break;
		case 1:
			DiscardSettings();
			if (debug_UI)
			{
				MelonLogger.Msg("Button - Discard");
			}
			break;
		}
	}

	private void SaveSettings()
	{
		if (!Running)
		{
			Mod_Options[ModSelection].SaveModData("Created by: ModUI 1.3.1");
			Enum_Save = MelonCoroutines.Start(ButtonFeedback(UI_ButtonSave, 0.5));
		}
	}

	private void DiscardSettings()
	{
		if (!Running)
		{
			Mod_Options[ModSelection].DiscardModData();
			Enum_Discard = MelonCoroutines.Start(ButtonFeedback(UI_ButtonDisc, 0.5));
			DoOnModSelect();
		}
	}

	private IEnumerator ButtonFeedback(GameObject Button, double Delay)
	{
		WaitForFixedUpdate waitForFixedUpdate = new WaitForFixedUpdate();
		Running = true;
		DateTime time = DateTime.Now;
		if (((Object)Button).name == "SaveButton")
		{
			((TMP_Text)((Component)Button.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Saved";
		}
		else
		{
			((TMP_Text)((Component)Button.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Discarded";
		}
		while (DateTime.Now <= ((DateTime)(ref time)).AddSeconds(Delay))
		{
			yield return waitForFixedUpdate;
		}
		if (((Object)Button).name == "SaveButton")
		{
			((TMP_Text)((Component)Button.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Save";
		}
		else
		{
			((TMP_Text)((Component)Button.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Discard";
		}
		Running = false;
		if (Enum_Save != null)
		{
			MelonCoroutines.Stop(Enum_Save);
		}
		if (Enum_Discard != null)
		{
			MelonCoroutines.Stop(Enum_Discard);
		}
		yield return null;
	}

	private IEnumerator Dragger()
	{
		WaitForFixedUpdate waitForFixedUpdate = new WaitForFixedUpdate();
		while ((int)((Selectable)UI_Title.GetComponent<Button>()).currentSelectionState != 2)
		{
			yield return waitForFixedUpdate;
		}
		Vector2 Mouse2 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
		Vector2 Offset = Vector2.op_Implicit(UI_Object.transform.position) - Mouse2;
		while ((int)((Selectable)UI_Title.GetComponent<Button>()).currentSelectionState == 2)
		{
			Mouse2 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
			UI_Object.transform.position = Vector2.op_Implicit(Mouse2 + Offset);
			yield return waitForFixedUpdate;
		}
		RestartDragger();
		yield return null;
	}

	private void RestartDragger()
	{
		if (Enum_Dragger != null)
		{
			MelonCoroutines.Stop(Enum_Dragger);
		}
		Enum_Dragger = MelonCoroutines.Start(Dragger());
	}

	private void InitCustomTextures()
	{
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Expected O, but got Unknown
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		CustomAssetsNames[0] = executingAssembly.GetName().Name + ".Assets.UI_Arrow.png";
		CustomAssetsNames[1] = executingAssembly.GetName().Name + ".Assets.UI_BaseLight.png";
		CustomAssetsNames[2] = executingAssembly.GetName().Name + ".Assets.UI_BaseLight.png";
		CustomAssetsNames[3] = executingAssembly.GetName().Name + ".Assets.UI_Mask.png";
		for (int i = 0; i < CustomAssets.Length; i++)
		{
			Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(CustomAssetsNames[i]);
			byte[] array = new byte[manifestResourceStream.Length];
			manifestResourceStream.Read(array, 0, array.Length);
			CustomAssets[i] = new Texture2D(2, 2);
			ImageConversion.LoadImage(CustomAssets[i], Il2CppStructArray<byte>.op_Implicit(array));
			((Object)CustomAssets[i]).hideFlags = (HideFlags)61;
			if (debug_UI)
			{
				MelonLogger.Msg("UI - Import:" + CustomAssetsNames[i]);
			}
		}
	}

	private Sprite ConvertToSprite(Texture2D Input, bool DoBorders = false, float border = 20f)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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_0085: 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_0060: 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)
		Rect val = default(Rect);
		((Rect)(ref val)).x = 0f;
		((Rect)(ref val)).y = 0f;
		((Rect)(ref val)).width = ((Texture)Input).width;
		((Rect)(ref val)).height = ((Texture)Input).height;
		Rect val2 = val;
		if (DoBorders)
		{
			Vector4 val3 = default(Vector4);
			((Vector4)(ref val3))..ctor(border, border, border, border);
			return Sprite.Create(Input, val2, new Vector2(0f, 0f), (float)((Texture)Input).width, 0u, (SpriteMeshType)0, val3);
		}
		return Sprite.Create(Input, val2, new Vector2(0f, 0f));
	}

	private GameObject CreateTitle(string Name, Vector3 Position)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0145: 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_017c: 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_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject
		{
			name = Name
		};
		GameObject val2 = new GameObject
		{
			name = "Text"
		};
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Objects set");
		}
		val.transform.SetParent(UI_Object.transform);
		val2.transform.SetParent(val.transform);
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Parents set");
		}
		val.AddComponent<Image>();
		val.AddComponent<Button>();
		val2.AddComponent<TextMeshProUGUI>();
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Components set");
		}
		SetTextProperties(val2, "ModUI V1.3.1", 20f);
		((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).horizontalAlignment = (HorizontalAlignmentOptions)2;
		((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).verticalAlignment = (VerticalAlignmentOptions)512;
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Text set");
		}
		val.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val);
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Image set");
		}
		val.GetComponent<RectTransform>().sizeDelta = Size_Title;
		val2.GetComponent<RectTransform>().sizeDelta = Vector2.zero;
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Image Transforms set");
		}
		SetPosition(val, Position, Scl_1x1);
		SetPosition(val2, Vector3.zero, Scl_1x1);
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Position set");
		}
		SetAnchors(val, AnchorPresets.TopLeft);
		SetPivot(val, PivotPresets.TopLeft);
		SetAnchors(val2, AnchorPresets.StretchAll);
		SetPivot(val2, PivotPresets.TopLeft);
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Anchors/Pivots set");
		}
		return val;
	}

	private GameObject CreateBackgroundBox(string Name, Vector3 Position)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject
		{
			name = Name
		};
		val.transform.SetParent(UI_Object.transform);
		SetPosition(val, Position, Scl_1x1);
		val.AddComponent<Image>();
		val.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val.GetComponent<Image>().type = (Type)2;
		val.GetComponent<RectTransform>().sizeDelta = Vector2.zero;
		AddToFGTheme(val);
		SetAnchors(val, AnchorPresets.StretchAll);
		SetPivot(val, PivotPresets.TopLeft);
		return val;
	}

	private GameObject CreateDropdown(string Name, Vector3 Position)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0021: 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_0033: Expected O, but got Unknown
		//IL_0033: 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_0045: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_007e: 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_0091: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		//IL_00a4: 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_00b7: Expected O, but got Unknown
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		//IL_00ca: 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_00dd: Expected O, but got Unknown
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0453: Unknown result type (might be due to invalid IL or missing references)
		//IL_046e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0480: Unknown result type (might be due to invalid IL or missing references)
		//IL_049c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_050c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Unknown result type (might be due to invalid IL or missing references)
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		//IL_066a: Unknown result type (might be due to invalid IL or missing references)
		//IL_066c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0679: Unknown result type (might be due to invalid IL or missing references)
		//IL_067f: Unknown result type (might be due to invalid IL or missing references)
		//IL_068c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0692: Unknown result type (might be due to invalid IL or missing references)
		//IL_069f: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06db: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0703: Unknown result type (might be due to invalid IL or missing references)
		//IL_0709: Unknown result type (might be due to invalid IL or missing references)
		//IL_0717: Unknown result type (might be due to invalid IL or missing references)
		//IL_071d: Unknown result type (might be due to invalid IL or missing references)
		//IL_072b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0731: Unknown result type (might be due to invalid IL or missing references)
		//IL_073f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0745: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject
		{
			name = Name
		};
		GameObject val2 = new GameObject
		{
			name = "Label"
		};
		GameObject val3 = new GameObject
		{
			name = "Arrow"
		};
		GameObject val4 = new GameObject
		{
			name = "Template"
		};
		GameObject val5 = new GameObject
		{
			name = "Viewport"
		};
		GameObject val6 = new GameObject
		{
			name = "Content"
		};
		GameObject val7 = new GameObject
		{
			name = "Item"
		};
		GameObject val8 = new GameObject
		{
			name = "Item Label"
		};
		GameObject val9 = new GameObject
		{
			name = "Item Background"
		};
		GameObject val10 = new GameObject
		{
			name = "Scrollbar"
		};
		GameObject val11 = new GameObject
		{
			name = "Slide"
		};
		GameObject val12 = new GameObject
		{
			name = "Handle"
		};
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Objects initialised");
		}
		val.transform.SetParent(UI_Object.transform);
		val2.transform.SetParent(val.transform);
		val3.transform.SetParent(val.transform);
		val4.transform.SetParent(val.transform);
		val5.transform.SetParent(val4.transform);
		val6.transform.SetParent(val5.transform);
		val7.transform.SetParent(val6.transform);
		val9.transform.SetParent(val7.transform);
		val8.transform.SetParent(val7.transform);
		val10.transform.SetParent(val4.transform);
		val11.transform.SetParent(val10.transform);
		val12.transform.SetParent(val11.transform);
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Parents set");
		}
		val.AddComponent<Image>();
		val.AddComponent<TMP_Dropdown>();
		val2.AddComponent<TextMeshProUGUI>();
		val3.AddComponent<Image>();
		val4.AddComponent<Image>();
		val4.AddComponent<ScrollRect>();
		val5.AddComponent<Image>();
		val5.AddComponent<Mask>();
		val6.AddComponent<RectTransform>();
		val7.AddComponent<Toggle>();
		val7.AddComponent<RectTransform>();
		val8.AddComponent<TextMeshProUGUI>();
		val9.AddComponent<Image>();
		val10.AddComponent<Scrollbar>();
		val10.AddComponent<Image>();
		val11.AddComponent<RectTransform>();
		val12.AddComponent<Image>();
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Components set");
		}
		SetTextProperties(val2, "", 20f);
		SetTextProperties(val8, "", 20f);
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Text set");
		}
		val3.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[0]);
		AddToBGTheme(val3);
		val.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val);
		val12.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val12.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val12);
		val4.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val4.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val4);
		val10.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[2], DoBorders: true);
		val10.GetComponent<Image>().type = (Type)2;
		AddToBGTheme(val10);
		val5.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[3], DoBorders: true, 12f);
		val5.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val5);
		AddToFGTheme(val9);
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Images set");
		}
		val.GetComponent<RectTransform>().sizeDelta = Size_DD;
		val2.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
		val3.GetComponent<RectTransform>().sizeDelta = new Vector2(20f, 20f);
		val4.GetComponent<RectTransform>().sizeDelta = Size_DD_Ext;
		val6.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 40f);
		val7.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 38f);
		val8.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
		val9.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
		val10.GetComponent<RectTransform>().sizeDelta = new Vector2(30f, 0f);
		val11.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
		val12.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Image Transforms set");
		}
		((Selectable)val.GetComponent<TMP_Dropdown>()).image = val.GetComponent<Image>();
		val.GetComponent<TMP_Dropdown>().template = val4.GetComponent<RectTransform>();
		val.GetComponent<TMP_Dropdown>().captionText = (TMP_Text)(object)val2.GetComponent<TextMeshProUGUI>();
		val.GetComponent<TMP_Dropdown>().itemText = (TMP_Text)(object)val8.GetComponent<TextMeshProUGUI>();
		val4.GetComponent<ScrollRect>().content = val6.GetComponent<RectTransform>();
		val4.GetComponent<ScrollRect>().viewport = val5.GetComponent<RectTransform>();
		val4.GetComponent<ScrollRect>().verticalScrollbar = val10.GetComponent<Scrollbar>();
		((Selectable)val7.GetComponent<Toggle>()).targetGraphic = (Graphic)(object)val9.GetComponent<Image>();
		((Selectable)val10.GetComponent<Scrollbar>()).targetGraphic = (Graphic)(object)val12.GetComponent<Image>();
		val10.GetComponent<Scrollbar>().handleRect = val12.GetComponent<RectTransform>();
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Objects linked");
		}
		val4.GetComponent<ScrollRect>().verticalScrollbarVisibility = (ScrollbarVisibility)2;
		val4.GetComponent<ScrollRect>().movementType = (MovementType)2;
		val10.GetComponent<Scrollbar>().SetDirection((Direction)2, false);
		SetPosition(val, Position, Scl_1x1);
		SetPosition(val2, Vector3.zero, Scl_1x1);
		SetPosition(val3, Vector3.zero, Scl_1x1);
		SetPosition(val4, Vector3.zero, Scl_1x1);
		SetPosition(val5, Vector3.zero, Scl_1x1);
		SetPosition(val6, Vector3.zero, Scl_1x1);
		SetPosition(val7, Vector3.zero, Scl_1x1);
		SetPosition(val8, Vector3.zero, Scl_1x1);
		SetPosition(val9, Vector3.zero, Scl_1x1);
		SetPosition(val10, Vector3.zero, Scl_1x1);
		SetPosition(val11, Vector3.zero, Scl_1x1);
		SetPosition(val12, Vector3.zero, Scl_1x1);
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Position set");
		}
		SetAnchors(val, AnchorPresets.TopLeft);
		SetPivot(val, PivotPresets.TopLeft);
		SetAnchors(val2, AnchorPresets.StretchAll);
		SetPivot(val2, PivotPresets.MiddleCenter);
		SetAnchorPos(val2, 10f, 0f);
		SetAnchors(val3, AnchorPresets.MiddleRight);
		SetPivot(val3, PivotPresets.MiddleCenter);
		SetAnchorPos(val3, -20f, -1f);
		SetAnchors(val4, AnchorPresets.HorStretchBottom);
		SetPivot(val4, PivotPresets.TopCenter);
		SetAnchors(val5, AnchorPresets.StretchAll);
		SetPivot(val5, PivotPresets.TopLeft);
		SetAnchors(val6, AnchorPresets.HorStretchTop);
		SetPivot(val6, PivotPresets.TopCenter);
		SetAnchors(val7, AnchorPresets.HorStretchMiddle);
		SetPivot(val7, PivotPresets.MiddleCenter);
		SetAnchors(val8, AnchorPresets.StretchAll);
		SetPivot(val8, PivotPresets.MiddleCenter);
		SetAnchorPos(val8, 15f, 0f);
		SetAnchors(val9, AnchorPresets.StretchAll);
		SetPivot(val9, PivotPresets.MiddleCenter);
		SetAnchors(val10, AnchorPresets.VertStretchRight);
		SetPivot(val10, PivotPresets.TopRight);
		SetAnchors(val11, AnchorPresets.StretchAll);
		SetPivot(val11, PivotPresets.MiddleCenter);
		SetAnchors(val12, AnchorPresets.BottomLeft);
		SetPivot(val12, PivotPresets.MiddleCenter);
		if (debug_UI)
		{
			MelonLogger.Msg("DropDown - Anchors/Pivots set");
		}
		return val;
	}

	private GameObject CreateInputField(string Name, Vector3 Position)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0021: 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_0033: Expected O, but got Unknown
		//IL_0033: 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_0045: Expected O, but got Unknown
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_035a: 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_036d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject
		{
			name = Name
		};
		GameObject val2 = new GameObject
		{
			name = "TextArea"
		};
		GameObject val3 = new GameObject
		{
			name = "Placeholder"
		};
		GameObject val4 = new GameObject
		{
			name = "Text"
		};
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Objects set");
		}
		val.transform.SetParent(UI_Object.transform);
		val2.transform.SetParent(val.transform);
		val3.transform.SetParent(val2.transform);
		val4.transform.SetParent(val2.transform);
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Parents set");
		}
		val.AddComponent<Image>();
		val.AddComponent<TMP_InputField>();
		val2.AddComponent<RectTransform>();
		val2.AddComponent<RectMask2D>();
		val3.AddComponent<LayoutElement>();
		val3.AddComponent<TextMeshProUGUI>();
		val4.AddComponent<TextMeshProUGUI>();
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Components set");
		}
		SetTextProperties(val3, "Enter text...", 20f, IsPlaceholder: true);
		SetTextProperties(val4, "", 20f);
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Text set");
		}
		val3.GetComponent<LayoutElement>().ignoreLayout = true;
		val3.GetComponent<LayoutElement>().layoutPriority = 1;
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Placeholder set");
		}
		val2.GetComponent<RectMask2D>().padding = new Vector4(-8f, -8f, -5f, -5f);
		val2.GetComponent<RectMask2D>().softness = new Vector2Int(0, 0);
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - TextArea set");
		}
		val.GetComponent<TMP_InputField>().onFocusSelectAll = true;
		val.GetComponent<TMP_InputField>().resetOnDeActivation = true;
		val.GetComponent<TMP_InputField>().restoreOriginalTextOnEscape = true;
		val.GetComponent<TMP_InputField>().richText = true;
		val.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val);
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Images set");
		}
		val.GetComponent<RectTransform>().sizeDelta = Size_IF;
		val2.GetComponent<RectTransform>().sizeDelta = new Vector2(-20f, 0f);
		val3.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
		val4.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f);
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Image Transforms set");
		}
		((Selectable)val.GetComponent<TMP_InputField>()).targetGraphic = (Graphic)(object)val.GetComponent<Image>();
		val.GetComponent<TMP_InputField>().textViewport = val2.GetComponent<RectTransform>();
		val.GetComponent<TMP_InputField>().textComponent = (TMP_Text)(object)val4.GetComponent<TextMeshProUGUI>();
		val.GetComponent<TMP_InputField>().placeholder = (Graphic)(object)val3.GetComponent<TextMeshProUGUI>();
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Objects linked");
		}
		SetPosition(val, Position, Scl_1x1);
		SetPosition(val2, Vector3.zero, Scl_1x1);
		SetPosition(val3, Vector3.zero, Scl_1x1);
		SetPosition(val4, Vector3.zero, Scl_1x1);
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Positions set");
		}
		SetAnchors(val, AnchorPresets.TopLeft);
		SetPivot(val, PivotPresets.TopLeft);
		SetAnchors(val2, AnchorPresets.StretchAll);
		SetPivot(val2, PivotPresets.MiddleCenter);
		SetAnchors(val3, AnchorPresets.StretchAll);
		SetPivot(val3, PivotPresets.MiddleCenter);
		SetAnchors(val4, AnchorPresets.StretchAll);
		SetPivot(val4, PivotPresets.MiddleCenter);
		if (debug_UI)
		{
			MelonLogger.Msg("InputField - Alignments set");
		}
		return val;
	}

	private GameObject CreateToggleBox(string Name, Vector3 Position)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0021: 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_0033: Expected O, but got Unknown
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: 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)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject
		{
			name = Name
		};
		GameObject val2 = new GameObject
		{
			name = "Background"
		};
		GameObject val3 = new GameObject
		{
			name = "Checkmark"
		};
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Objects set");
		}
		val.transform.SetParent(UI_Object.transform);
		val2.transform.SetParent(val.transform);
		val3.transform.SetParent(val2.transform);
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Parents set");
		}
		val.AddComponent<Toggle>();
		val2.AddComponent<RectTransform>();
		val2.AddComponent<Image>();
		val3.AddComponent<RectTransform>();
		val3.AddComponent<Image>();
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Components set");
		}
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Text set");
		}
		val3.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val3.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val3);
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Checkmark set");
		}
		val2.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val2.GetComponent<Image>().type = (Type)2;
		AddToBGTheme(val2);
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Background set");
		}
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Toggle set");
		}
		val.GetComponent<RectTransform>().sizeDelta = Size_TB;
		val2.GetComponent<RectTransform>().sizeDelta = Size_TB;
		val3.GetComponent<RectTransform>().sizeDelta = new Vector2(Size_TB.x - 5f, Size_TB.y - 5f);
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Transforms set");
		}
		val.GetComponent<Toggle>().graphic = (Graphic)(object)val3.GetComponent<Image>();
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Objects linked");
		}
		SetPosition(val, Position, Scl_1x1);
		SetPosition(val2, Vector3.zero, Scl_1x1);
		SetPosition(val3, Vector3.zero, Scl_1x1);
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Positions set");
		}
		SetAnchors(val, AnchorPresets.MiddleCenter);
		SetPivot(val, PivotPresets.MiddleCenter);
		SetAnchors(val2, AnchorPresets.MiddleCenter);
		SetPivot(val2, PivotPresets.MiddleCenter);
		SetAnchors(val3, AnchorPresets.MiddleCenter);
		SetPivot(val3, PivotPresets.MiddleCenter);
		if (debug_UI)
		{
			MelonLogger.Msg("ToggleBox - Alignments set");
		}
		return val;
	}

	private GameObject CreateDescription(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)
		//IL_000f: Expected O, but got Unknown
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_014b: 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_0184: 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)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject
		{
			name = Name
		};
		GameObject val2 = new GameObject
		{
			name = "Text"
		};
		if (debug_UI)
		{
			MelonLogger.Msg("Description - Objects set");
		}
		val.transform.SetParent(UI_Object.transform);
		val2.transform.SetParent(val.transform);
		if (debug_UI)
		{
			MelonLogger.Msg("Description - Parents set");
		}
		val.AddComponent<Image>();
		val2.AddComponent<TextMeshProUGUI>();
		if (debug_UI)
		{
			MelonLogger.Msg("Description - Components set");
		}
		SetTextProperties(val2, "", 18f);
		((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).verticalAlignment = (VerticalAlignmentOptions)256;
		((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).enableWordWrapping = true;
		((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).overflowMode = (TextOverflowModes)3;
		if (debug_UI)
		{
			MelonLogger.Msg("Description - Text set");
		}
		val.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val);
		if (debug_UI)
		{
			MelonLogger.Msg("Description - Image set");
		}
		val.GetComponent<RectTransform>().sizeDelta = Size_DescBG;
		val2.GetComponent<RectTransform>().sizeDelta = Size_DescText;
		if (debug_UI)
		{
			MelonLogger.Msg("Description - Image Transforms set");
		}
		SetPosition(val, Pos_DescBG, Scl_1x1);
		SetPosition(val2, Pos_DescText, Scl_1x1);
		if (debug_UI)
		{
			MelonLogger.Msg("Description - Position set");
		}
		SetAnchors(val, AnchorPresets.StretchAll);
		SetPivot(val, PivotPresets.TopLeft);
		SetAnchors(val2, AnchorPresets.StretchAll);
		SetPivot(val2, PivotPresets.TopLeft);
		if (debug_UI)
		{
			MelonLogger.Msg("Title - Anchors/Pivots set");
		}
		return val;
	}

	private GameObject CreateButton(string Name, Vector3 Position, string Text)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0141: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject
		{
			name = Name
		};
		GameObject val2 = new GameObject
		{
			name = "Text"
		};
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Objects set");
		}
		val.transform.SetParent(UI_Object.transform);
		val2.transform.SetParent(val.transform);
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Parents set");
		}
		val.AddComponent<Image>();
		val.AddComponent<Button>();
		val2.AddComponent<TextMeshProUGUI>();
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Components set");
		}
		SetTextProperties(val2, Text, 20f);
		((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).horizontalAlignment = (HorizontalAlignmentOptions)2;
		((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).verticalAlignment = (VerticalAlignmentOptions)512;
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Text set");
		}
		val.GetComponent<Image>().sprite = ConvertToSprite(CustomAssets[1], DoBorders: true);
		val.GetComponent<Image>().type = (Type)2;
		AddToFGTheme(val);
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Image set");
		}
		val.GetComponent<RectTransform>().sizeDelta = Size_Button;
		val2.GetComponent<RectTransform>().sizeDelta = Vector2.zero;
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Image Transforms set");
		}
		((Selectable)val.GetComponent<Button>()).targetGraphic = (Graphic)(object)val.GetComponent<Image>();
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Links set");
		}
		SetPosition(val, Position, Scl_1x1);
		SetPosition(val2, Vector3.zero, Scl_1x1);
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Position set");
		}
		SetAnchors(val, AnchorPresets.BottomLeft);
		SetPivot(val, PivotPresets.BottomLeft);
		SetAnchors(val2, AnchorPresets.StretchAll);
		SetPivot(val2, PivotPresets.MiddleCenter);
		if (debug_UI)
		{
			MelonLogger.Msg("Button - Anchors/Pivots set");
		}
		return val;
	}

	private void SetPosition(GameObject Input, Vector3 Pos, Vector3 Scale)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		Input.transform.localPosition = Pos;
		Input.transform.localScale = Scale;
	}

	private void SetAnchorPos(GameObject Input, float x, float y)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		Input.GetComponent<RectTransform>().anchoredPosition = new Vector2(x, y);
	}

	private void SetAnchors(GameObject Input, AnchorPresets alignment)
	{
		switch (alignment)
		{
		case AnchorPresets.TopLeft:
			AnchorHelper(Input, 0f, 1f, 0f, 1f);
			break;
		case AnchorPresets.TopCenter:
			AnchorHelper(Input, 0.5f, 1f, 0.5f, 1f);
			break;
		case AnchorPresets.TopRight:
			AnchorHelper(Input, 1f, 1f, 1f, 1f);
			break;
		case AnchorPresets.MiddleLeft:
			AnchorHelper(Input, 0f, 0.5f, 0f, 0.5f);
			break;
		case AnchorPresets.MiddleCenter:
			AnchorHelper(Input, 0.5f, 0.5f, 0.5f, 0.5f);
			break;
		case AnchorPresets.MiddleRight:
			AnchorHelper(Input, 1f, 0.5f, 1f, 0.5f);
			break;
		case AnchorPresets.BottomLeft:
			AnchorHelper(Input, 0f, 0f, 0f, 0f);
			break;
		case AnchorPresets.BottomCenter:
			AnchorHelper(Input, 0.5f, 0f, 0.5f, 0f);
			break;
		case AnchorPresets.BottomRight:
			AnchorHelper(Input, 1f, 0f, 1f, 0f);
			break;
		case AnchorPresets.BottomStretch:
			AnchorHelper(Input, 0f, 0f, 1f, 0f);
			break;
		case AnchorPresets.VertStretchLeft:
			AnchorHelper(Input, 0f, 0f, 0f, 1f);
			break;
		case AnchorPresets.VertStretchCenter:
			AnchorHelper(Input, 0.5f, 0f, 0.5f, 1f);
			break;
		case AnchorPresets.VertStretchRight:
			AnchorHelper(Input, 1f, 0f, 1f, 1f);
			break;
		case AnchorPresets.HorStretchTop:
			AnchorHelper(Input, 0f, 1f, 1f, 1f);
			break;
		case AnchorPresets.HorStretchMiddle:
			AnchorHelper(Input, 0f, 0.5f, 1f, 0.5f);
			break;
		case AnchorPresets.HorStretchBottom:
			AnchorHelper(Input, 0f, 0f, 1f, 0f);
			break;
		case AnchorPresets.StretchAll:
			AnchorHelper(Input, 0f, 0f, 1f, 1f);
			break;
		}
	}

	private void SetPivot(GameObject Input, PivotPresets pivot)
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		switch (pivot)
		{
		case PivotPresets.TopLeft:
			Input.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
			break;
		case PivotPresets.TopCenter:
			Input.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 1f);
			break;
		case PivotPresets.TopRight:
			Input.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
			break;
		case PivotPresets.MiddleLeft:
			Input.GetComponent<RectTransform>().pivot = new Vector2(0f, 0.5f);
			break;
		case PivotPresets.MiddleCenter:
			Input.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
			break;
		case PivotPresets.MiddleRight:
			Input.GetComponent<RectTransform>().pivot = new Vector2(1f, 0.5f);
			break;
		case PivotPresets.BottomLeft:
			Input.GetComponent<RectTransform>().pivot = new Vector2(0f, 0f);
			break;
		case PivotPresets.BottomCenter:
			Input.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0f);
			break;
		case PivotPresets.BottomRight:
			Input.GetComponent<RectTransform>().pivot = new Vector2(1f, 0f);
			break;
		}
	}

	private void AnchorHelper(GameObject Input, float xmin, float ymin, float xmax, float ymax)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		Input.GetComponent<RectTransform>().anchorMin = new Vector2(xmin, ymin);
		Input.GetComponent<RectTransform>().anchorMax = new Vector2(xmax, ymax);
	}

	private void SetTextProperties(GameObject Input, string Text = "", float fontsize = 16f, bool IsPlaceholder = false)
	{
		AddToTextTheme(Input);
		((TMP_Text)Input.GetComponent<TextMeshProUGUI>()).text = Text;
		((TMP_Text)Input.GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)513;
		((TMP_Text)Input.GetComponent<TextMeshProUGUI>()).fontSize = fontsize;
		if (IsPlaceholder)
		{
			((TMP_Text)Input.GetComponent<TextMeshProUGUI>()).fontStyle = (FontStyles)2;
		}
	}

	private void ChangeTheme(Themes Theme)
	{
		//IL_003d: 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_0057: 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_007a: 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_009d: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
		bool flag = false;
		if (Enum_Theme != null)
		{
			MelonCoroutines.Stop(Enum_Theme);
			flag = true;
		}
		switch (Theme)
		{
		case Themes.Light:
			ChangeTextColor(Light_Text);
			ChangeFGColor(Light_FG);
			ChangeBGColor(Light_BG);
			currentTheme = Themes.Light;
			break;
		case Themes.Dark:
			ChangeTextColor(Dark_Text);
			ChangeFGColor(Dark_FG);
			ChangeBGColor(Dark_BG);
			currentTheme = Themes.Dark;
			break;
		case Themes.HighContrast:
			ChangeTextColor(HighContrast_Text);
			ChangeFGColor(HighContrast_FG);
			ChangeBGColor(HighContrast_BG);
			currentTheme = Themes.HighContrast;
			break;
		}
		if (debug_UI)
		{
			MelonLogger.Msg("Theme - Theme changed");
		}
		if (flag)
		{
			Enum_Theme = MelonCoroutines.Start(WaitForThemeChange());
		}
	}

	private void AddToTextTheme(GameObject Input)
	{
		Theme_Text.Add(Input.GetComponent<TextMeshProUGUI>());
	}

	private void AddToFGTheme(GameObject Input)
	{
		Theme_Foreground.Add(Input.GetComponent<Image>());
	}

	private void AddToBGTheme(GameObject Input)
	{
		Theme_Background.Add(Input.GetComponent<Image>());
	}

	private void ChangeTextColor(Color Color)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		foreach (TextMeshProUGUI item in Theme_Text)
		{
			((TMP_Text)item).color = Color;
		}
		if (debug_UI)
		{
			MelonLogger.Msg("Theme - Text Color changed");
		}
	}

	private void ChangeFGColor(Color Color)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		foreach (Image item in Theme_Foreground)
		{
			((Graphic)item).color = Color;
		}
		if (debug_UI)
		{
			MelonLogger.Msg("Theme - Foreground Color changed");
		}
	}

	private void ChangeBGColor(Color Color)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		foreach (Image item in Theme_Background)
		{
			((Graphic)item).color = Color;
		}
		if (debug_UI)
		{
			MelonLogger.Msg("Theme - Background Color changed");
		}
	}
}
public abstract class ValidationParameters
{
	public abstract bool DoValidation(string Input);
}
public class ValidationTemplate : ValidationParameters
{
	public override bool DoValidation(string Input)
	{
		return true;
	}
}