Decompiled source of WKLib v0.3.1

plugins/WKLib.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Imui.Controls;
using Imui.Core;
using Imui.IO;
using Imui.IO.Touch;
using Imui.IO.UGUI;
using Imui.Rendering;
using Imui.Style;
using ImuiBepInEx.API;
using Microsoft.CodeAnalysis;
using Rewired;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using WKLib.API;
using WKLib.API.Assets;
using WKLib.API.Input;
using WKLib.API.UI;
using WKLib.Core.Attributes;
using WKLib.Core.Classes;
using WKLib.Core.Config;
using WKLib.Core.Reflection;
using WKLib.Core.UI;
using WKLib.Core.UI.Windows;
using WKLib.Examples.UI;
using WKLib.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("WKLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1+c656ac402ca26df2e1f17a20551b5115d9418e65")]
[assembly: AssemblyProduct("WKLib")]
[assembly: AssemblyTitle("WKLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WKLib
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.monksilly.WKLib", "WKLib", "0.3.1")]
	public class WKLibPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__5_0;

			public static UnityAction <>9__5_1;

			internal void <OnSceneLoaded>b__5_0()
			{
				MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen;
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}

			internal void <OnSceneLoaded>b__5_1()
			{
				MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen;
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
		}

		public const string GUID = "com.monksilly.WKLib";

		public const string NAME = "WKLib";

		public const string VERSION = "0.3.1";

		private static Harmony harmony;

		private void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			WKLog.Initialize(((BaseUnityPlugin)this).Logger);
			WKLog.Debug("Initalizing reflection...");
			ReflectionUtility.Initialize();
			WKLog.Debug("Initalizing input utility...");
			InputUtility.Initialize();
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			harmony = new Harmony("com.monksilly.WKLib");
			Type[] types = typeof(WKLibPlugin).Assembly.GetTypes();
			foreach (Type type in types)
			{
				if (type.GetCustomAttribute<PatchOnEntryAttribute>() != null)
				{
					harmony.PatchAll(type);
				}
			}
			ConfigManager.CreateEntries(((BaseUnityPlugin)this).Config);
			WKLog.Info("Plugin WKLib v0.3.1 is loaded!");
			SceneManager.sceneLoaded -= OnSceneLoaded;
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			if (((Scene)(ref scene)).name == "Main-Menu")
			{
				GameObject obj = GameObject.Find("Canvas - Main Menu/Main Menu/Version Text");
				TextMeshProUGUI val = ((obj != null) ? obj.GetComponent<TextMeshProUGUI>() : null);
				if (val != null)
				{
					((TMP_Text)val).text = ((TMP_Text)val).text + string.Format(" (wklib-{0}) ({1} Mods)", "0.3.1", Chainloader.PluginInfos.Count);
				}
				GameObject val2 = GameObject.Find("Canvas - Main Menu/Main Menu/Support Menu/Update Info");
				if (!((Object)(object)val2 != (Object)null))
				{
					return;
				}
				GameObject obj2 = Object.Instantiate<GameObject>(val2, val2.transform.parent);
				obj2.transform.SetSiblingIndex(0);
				((Object)obj2).name = "Toggle Overlay";
				UI_MenuButton component = obj2.GetComponent<UI_MenuButton>();
				if (component != null)
				{
					Object.DestroyImmediate((Object)(object)component);
				}
				TextMeshProUGUI componentInChildren = obj2.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "Toggle Overlay";
				}
				Button component2 = obj2.GetComponent<Button>();
				if (!((Object)(object)component2 != (Object)null))
				{
					return;
				}
				((UnityEventBase)component2.onClick).RemoveAllListeners();
				ButtonClickedEvent onClick = component2.onClick;
				object obj3 = <>c.<>9__5_0;
				if (obj3 == null)
				{
					UnityAction val3 = delegate
					{
						MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen;
						EventSystem.current.SetSelectedGameObject((GameObject)null);
					};
					<>c.<>9__5_0 = val3;
					obj3 = (object)val3;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj3);
				return;
			}
			GameObject val4 = GameObject.Find("GameManager/Canvas/Pause/Pause Menu/Pause Buttons/Pause Layout");
			if (!((Object)(object)val4 != (Object)null))
			{
				return;
			}
			Transform val5 = val4.transform.Find("Gap.01");
			Transform val6 = val4.transform.Find("Settings");
			if (!((Object)(object)val5 != (Object)null) || !((Object)(object)val6 != (Object)null))
			{
				return;
			}
			GameObject obj4 = Object.Instantiate<GameObject>(((Component)val5).gameObject, ((Component)val5).transform.parent);
			obj4.transform.SetSiblingIndex(val5.parent.childCount - 1);
			((Object)obj4).name = "Gap.03";
			GameObject obj5 = Object.Instantiate<GameObject>(((Component)val6).gameObject, ((Component)val6).transform.parent);
			obj5.transform.SetSiblingIndex(val6.parent.childCount - 1);
			((Object)obj5).name = "Toggle Overlay";
			UI_MenuButton component3 = obj5.GetComponent<UI_MenuButton>();
			if (component3 != null)
			{
				Object.DestroyImmediate((Object)(object)component3);
			}
			TextMeshProUGUI componentInChildren2 = obj5.GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)componentInChildren2 != (Object)null)
			{
				((TMP_Text)componentInChildren2).text = "TOGGLE OVERLAY";
			}
			Button component4 = obj5.GetComponent<Button>();
			if (!((Object)(object)component4 != (Object)null))
			{
				return;
			}
			((UnityEventBase)component4.onClick).RemoveAllListeners();
			ButtonClickedEvent onClick2 = component4.onClick;
			object obj6 = <>c.<>9__5_1;
			if (obj6 == null)
			{
				UnityAction val7 = delegate
				{
					MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen;
					EventSystem.current.SetSelectedGameObject((GameObject)null);
				};
				<>c.<>9__5_1 = val7;
				obj6 = (object)val7;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj6);
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			Object.Destroy((Object)(object)MonoSingleton<RootPanel>.Instance.ImuiPanel.Canvas);
			SceneManager.sceneLoaded -= OnSceneLoaded;
			WKLog.Info("Plugin WKLib unloaded!");
		}
	}
}
namespace WKLib.Utilities
{
	internal static class WKLog
	{
		private static ManualLogSource _log;

		internal static void Initialize(ManualLogSource logSource)
		{
			_log = logSource;
		}

		public static void Info(object msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogInfo((object)$"[WKLib] {msg}");
			}
		}

		public static void Warn(object msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogWarning((object)$"[WKLib] {msg}");
			}
		}

		public static void Error(object msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogError((object)$"[WKLib] {msg}");
			}
		}

		public static void Debug(object msg)
		{
			ManualLogSource log = _log;
			if (log != null)
			{
				log.LogDebug((object)$"[WKLib] {msg}");
			}
		}
	}
}
namespace WKLib.Examples.UI
{
	[Flags]
	internal enum DemoEnumFlags
	{
		None = 0,
		Flag1 = 1,
		Flag2 = 2,
		Flag3 = 4,
		Flag1And3 = 5
	}
	internal struct DemoTreeNode
	{
		public string Name;

		public DemoTreeNode[] Childrens;

		public DemoTreeNode(string name, params DemoTreeNode[] childrens)
		{
			Name = name;
			Childrens = childrens;
		}
	}
	internal static class DemoWindow
	{
		private static char[] formatBuffer = new char[256];

		private static bool checkboxValue;

		private static int selectedValue = -1;

		private static float bouncingBallSize = 22f;

		private static float bouncingBallSpeed = 1f;

		private static int bouncingBallTrail = 32;

		private static float bouncingBallTime;

		private static string[] values = new string[12]
		{
			"Value 1", "Value 2", "Value 3", "Value 4", "Value 5", "Value 6", "Value 7", "Value 8", "Value 9", "Value 10",
			"Value 11", "Value 12"
		};

		private static string textWithHint = string.Empty;

		private static string singleLineText = "Single line text edit";

		private static string multiLineText = "Multiline text\nedit";

		private static float floatValue = 10.5f;

		private static int intValue = 105;

		private static bool isReadOnly;

		private static bool customDropdownOpen;

		private static ImDropdownPreviewType dropdownPreview;

		private static bool[] checkboxes = new bool[4];

		private static int clicks;

		private static int nestedFoldouts;

		private static bool showPlusMinusButtons = true;

		private static bool useNumericSlider = false;

		private static DemoEnumFlags demoFlags;

		private static int largeTableRows = 131072;

		private static int largeTableColumns = 512;

		private static float largeTableColumnSize = 150f;

		private static bool largeTableScrollable = true;

		private static bool largeTableResizable = true;

		private static Vector2 vec2 = new Vector2(1f, 2f);

		private static Vector3 vec3 = new Vector3(1f, 2f, 3f);

		private static Vector4 vec4 = new Vector4(1f, 2f, 3f, 4f);

		private static Vector2Int vec2int = new Vector2Int(1, 2);

		private static Vector3Int vec3int = new Vector3Int(1, 2, 3);

		private static bool textEditWrap;

		private static bool selectMultipleValues = false;

		private static HashSet<string> selectedNodes = new HashSet<string>(8);

		private static readonly DemoTreeNode[] treeNodes = new DemoTreeNode[3]
		{
			new DemoTreeNode("Node 0", new DemoTreeNode("Node 1"), new DemoTreeNode("Node 2")),
			new DemoTreeNode("Node 3"),
			new DemoTreeNode("Node 4", new DemoTreeNode("Node 5", new DemoTreeNode("Node 6"), new DemoTreeNode("Node 7")))
		};

		private static HashSet<int> selectedValues = new HashSet<int>(values.Length);

		public static void Draw(ImGui gui, ref bool open)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00ba: 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)
			if (ImWindow.BeginWindow(gui, "Demo", ref open, ImSize.op_Implicit((700f, 700f)), (ImWindowFlag)16))
			{
				ImMenuBar.BeginMenuBar(gui);
				DrawMenuBarItems(gui, ref open);
				ImMenuBar.EndMenuBar(gui);
				if (ImFoldout.BeginFoldout(gui, "Controls".AsSpan(), default(ImSize), false))
				{
					ImLayoutUtility.BeginIndent(gui);
					DrawControlsPage(gui, ref open);
					ImLayoutUtility.EndIndent(gui);
					ImFoldout.EndFoldout(gui);
				}
				gui.BeginReadOnly(isReadOnly);
				if (ImFoldout.BeginFoldout(gui, "Layout".AsSpan(), default(ImSize), false))
				{
					ImLayoutUtility.BeginIndent(gui);
					DrawLayoutPage(gui);
					ImLayoutUtility.EndIndent(gui);
					ImFoldout.EndFoldout(gui);
				}
				if (ImFoldout.BeginFoldout(gui, "Tables".AsSpan(), default(ImSize), false))
				{
					ImLayoutUtility.BeginIndent(gui);
					DrawTablesPage(gui);
					ImLayoutUtility.EndIndent(gui);
					ImFoldout.EndFoldout(gui);
				}
				gui.EndReadOnly();
				ImWindow.EndWindow(gui);
			}
		}

		private static void DrawControlsPage(ImGui gui, ref bool open)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: 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_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: 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_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: 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_0685: Unknown result type (might be due to invalid IL or missing references)
			ImCheckbox.Checkbox(gui, ref isReadOnly, "Read Only".AsSpan(), default(ImSize));
			gui.BeginReadOnly(isReadOnly);
			ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui);
			ImLayoutUtility.BeginHorizontal(gui, 0f, 0f);
			if (ImButton.Button(gui, Format("Clicks ".AsSpan(), clicks, "0".AsSpan()), ImSize.op_Implicit((ImSizeMode)2), (ImButtonFlag)0))
			{
				clicks++;
			}
			if (ImButton.Button(gui, "Reset Clicks".AsSpan(), ImSize.op_Implicit((ImSizeMode)0), (ImButtonFlag)0))
			{
				clicks = 0;
			}
			ImLayoutUtility.EndHorizontal(gui);
			ImCheckbox.Checkbox(gui, ref checkboxValue, "Checkbox".AsSpan(), default(ImSize));
			ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui);
			ImLayoutUtility.BeginHorizontal(gui, 0f, 0f);
			ImText.Text(gui, "Dropdown preview mode: ".AsSpan(), false, (ImTextOverflow)0);
			ImRadio.Radio<ImDropdownPreviewType>(gui, ref dropdownPreview, true);
			ImLayoutUtility.EndHorizontal(gui);
			ReadOnlySpan<string> readOnlySpan = values;
			ReadOnlySpan<char> readOnlySpan2 = "Dropdown without value selected".AsSpan();
			ImDropdownPreviewType val = dropdownPreview;
			ImDropdown.Dropdown(gui, ref selectedValue, readOnlySpan, default(ImSize), val, readOnlySpan2);
			ReadOnlySpan<char> readOnlySpan3 = "Custom Dropdown".AsSpan();
			val = dropdownPreview;
			if (ImDropdown.BeginDropdown(gui, readOnlySpan3, default(ImSize), val))
			{
				if (ImMenu.Menu(gui, "Menu Item".AsSpan()))
				{
					ImDropdown.CloseDropdown(gui);
				}
				ImTooltip.TooltipAtLastControl(gui, "Will close dropdown on click".AsSpan(), (ImTooltipShow)1);
				if (ImMenu.BeginMenu(gui, "Sub Menu Inside Dropdown".AsSpan()))
				{
					ImText.Text(gui, "Hello there".AsSpan(), false, (ImTextOverflow)0);
					ImMenu.EndMenu(gui);
				}
				ImCheckbox.Checkbox(gui, ref checkboxValue, "Checkbox".AsSpan(), default(ImSize));
				ImSeparator.Separator(gui, "Nested dropdown, if that's want you really want".AsSpan());
				ReadOnlySpan<string> readOnlySpan4 = values;
				readOnlySpan2 = "Nothing".AsSpan();
				val = dropdownPreview;
				ImDropdown.Dropdown(gui, ref selectedValue, readOnlySpan4, default(ImSize), val, readOnlySpan2);
				ImDropdown.EndDropdown(gui);
			}
			ImSeparator.Separator(gui, "Text editors".AsSpan());
			readOnlySpan2 = "Write something here".AsSpan();
			ImTextEdit.TextEdit(gui, ref textWithHint, default(ImSize), (bool?)null, 0, (ImTouchKeyboardType)0, readOnlySpan2);
			bool? flag = false;
			ImTextEdit.TextEdit(gui, ref singleLineText, default(ImSize), flag, 0, (ImTouchKeyboardType)0, default(ReadOnlySpan<char>));
			ImCheckbox.Checkbox(gui, ref textEditWrap, "Wrap Text".AsSpan(), default(ImSize));
			ImStyleScope<bool> val2 = ImControlStyleExtensions.StyleScope<bool>(gui, ref gui.Style.TextEdit.TextWrap, ref textEditWrap);
			try
			{
				flag = true;
				ImTextEdit.TextEdit(gui, ref multiLineText, default(ImSize), flag, 0, (ImTouchKeyboardType)0, default(ReadOnlySpan<char>));
			}
			finally
			{
				val2.Dispose();
			}
			ImSeparator.Separator(gui, "Sliders (with tooltips)".AsSpan());
			DrawSlidersDemo(gui);
			ImSeparator.Separator(gui, "Selection list (you can select multiple values)".AsSpan());
			ImList.BeginList(gui, ImSize.op_Implicit((ImLayoutUtility.GetLayoutWidth(gui), ImList.GetEnclosingHeight(gui, ImLayoutUtility.GetRowsHeightWithSpacing(gui, 3)))));
			for (int i = 0; i < values.Length; i++)
			{
				bool flag2 = selectedValues.Contains(i);
				if (ImList.ListItem(gui, flag2, values[i].AsSpan()))
				{
					if (flag2)
					{
						selectedValues.Remove(i);
					}
					else
					{
						selectedValues.Add(i);
					}
				}
			}
			ImList.EndList(gui);
			ImSeparator.Separator(gui, "Numeric editors".AsSpan());
			gui.BeginReadOnly(useNumericSlider);
			ImCheckbox.Checkbox(gui, ref showPlusMinusButtons, "Enable Plus/Minus buttons".AsSpan(), default(ImSize));
			gui.EndReadOnly();
			ImCheckbox.Checkbox(gui, ref useNumericSlider, "Enable Slider".AsSpan(), default(ImSize));
			ImNumericEditFlag val3 = (ImNumericEditFlag)0;
			val3 = (ImNumericEditFlag)(val3 | (showPlusMinusButtons ? 1 : 0));
			val3 = (ImNumericEditFlag)(val3 | (useNumericSlider ? 2 : 0));
			ImNumericEditFlag val4 = val3;
			readOnlySpan2 = "0.0### kg".AsSpan();
			ImNumericEdit.NumericEdit(gui, ref floatValue, default(ImSize), readOnlySpan2, 0.05f, float.MinValue, float.MaxValue, val4);
			val4 = val3;
			readOnlySpan2 = "0 miles".AsSpan();
			ImNumericEdit.NumericEdit(gui, ref intValue, default(ImSize), readOnlySpan2, 1, int.MinValue, int.MaxValue, val4);
			ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui);
			ImSeparator.Separator(gui, "Radio buttons (enum flags)".AsSpan());
			ImRadio.Radio<DemoEnumFlags>(gui, ref demoFlags, true);
			ImSeparator.Separator(gui, "Dropdown (enum flags)".AsSpan());
			ImDropdown.Dropdown<DemoEnumFlags>(gui, ref demoFlags, default(ImSize), (ImDropdownPreviewType)0);
			ImSeparator.Separator(gui, "Trees".AsSpan());
			DrawTreeDemo(gui);
			ImSeparator.Separator(gui, "Nested Foldout".AsSpan());
			NestedFoldout(gui, 0, ref nestedFoldouts);
			ImSeparator.Separator(gui, "Floating menu".AsSpan());
			ImRect val5 = ImLayoutUtility.AddLayoutRect(gui, ImLayoutUtility.GetLayoutWidth(gui), ImLayoutUtility.GetRowHeight(gui));
			ImMenuBar.BeginMenuBar(gui, val5);
			DrawMenuBarItems(gui, ref open);
			ImMenuBar.EndMenuBar(gui);
			ImSeparator.Separator(gui, "Tabs".AsSpan());
			ImLayoutUtility.AddSpacing(gui);
			ImTabsPane.BeginTabsPane(gui, ImLayoutUtility.AddLayoutRect(gui, ImLayoutUtility.GetLayoutWidth(gui), ImLayoutUtility.GetRowsHeightWithSpacing(gui, 2)), (ImTabsPaneFlags)0);
			for (int j = 0; j < 4; j++)
			{
				Span<char> span = gui.Formatter.Concat("Tab ".AsSpan(), j);
				if (ImTabsPane.BeginTab(gui, (ReadOnlySpan<char>)span))
				{
					ImText.Text(gui, (ReadOnlySpan<char>)span, false, (ImTextOverflow)0);
					ImTabsPane.EndTab(gui);
				}
			}
			ImTabsPane.EndTabsPane(gui);
			ImSeparator.Separator(gui, "Vectors (float)".AsSpan());
			ImText.Text(gui, "Two component vector".AsSpan(), false, (ImTextOverflow)0);
			ImVector.Vector(gui, ref vec2, default(ImSize));
			ImText.Text(gui, "Three component vector".AsSpan(), false, (ImTextOverflow)0);
			ImVector.Vector(gui, ref vec3, default(ImSize));
			ImText.Text(gui, "Four component vector".AsSpan(), false, (ImTextOverflow)0);
			ImVector.Vector(gui, ref vec4, default(ImSize));
			ImSeparator.Separator(gui, "Vectors (int)".AsSpan());
			ImText.Text(gui, "Two component vector".AsSpan(), false, (ImTextOverflow)0);
			ImVector.Vector(gui, ref vec2int, default(ImSize));
			ImText.Text(gui, "Three component vector".AsSpan(), false, (ImTextOverflow)0);
			ImVector.Vector(gui, ref vec3int, default(ImSize));
			gui.EndReadOnly();
		}

		private static void DrawSelectableTreeDemo(ImGui gui)
		{
			//IL_001f: 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)
			ImCheckbox.Checkbox(gui, ref selectMultipleValues, "Select multiple values".AsSpan(), default(ImSize));
			ImLayoutUtility.BeginHorizontal(gui, 0f, 0f);
			ImText.Text(gui, "Selected nodes: ".AsSpan(), false, (ImTextOverflow)0);
			foreach (string selectedNode in selectedNodes)
			{
				ImText.Text(gui, selectedNode.AsSpan(), false, (ImTextOverflow)0);
				ImLayoutUtility.AddSpacing(gui);
			}
			ImLayoutUtility.EndHorizontal(gui);
			for (int i = 0; i < treeNodes.Length; i++)
			{
				Node(ref treeNodes[i]);
			}
			void Node(ref DemoTreeNode node)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: 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_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				ImTreeNodeFlags val = (ImTreeNodeFlags)((selectMultipleValues ? 1 : 0) | ((node.Childrens.Length == 0) ? 4 : 0));
				bool selected = selectedNodes.Contains(node.Name);
				ImGui obj = gui;
				ReadOnlySpan<char> readOnlySpan = node.Name.AsSpan();
				ImTreeNodeFlags val2 = val;
				bool num = ImTree.BeginTreeNode(obj, ref selected, readOnlySpan, default(ImSize), val2);
				SetSelected(node.Name, selected);
				if (num)
				{
					for (int j = 0; j < node.Childrens.Length; j++)
					{
						Node(ref node.Childrens[j]);
					}
					ImTree.EndTreeNode(gui);
				}
			}
			static void SetSelected(string name, bool selected)
			{
				if (selected)
				{
					if (!selectMultipleValues)
					{
						selectedNodes.Clear();
					}
					selectedNodes.Add(name);
				}
				else
				{
					selectedNodes.Remove(name);
				}
			}
		}

		private static void DrawTreeDemo(ImGui gui)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			ImTree.TreeNode(gui, "Node 0".AsSpan(), default(ImSize), (ImTreeNodeFlags)0);
			if (ImTree.BeginTreeNode(gui, "Node 1".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
			{
				ImTree.TreeNode(gui, "Node 3".AsSpan(), default(ImSize), (ImTreeNodeFlags)0);
				if (ImTree.BeginTreeNode(gui, "Node 4".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					ImTree.TreeNode(gui, "Node 5".AsSpan(), default(ImSize), (ImTreeNodeFlags)0);
					ImTree.EndTreeNode(gui);
				}
				ImTree.EndTreeNode(gui);
			}
			ImTree.TreeNode(gui, "Node 5".AsSpan(), default(ImSize), (ImTreeNodeFlags)0);
			if (ImTree.BeginTreeNode(gui, "Selectable nodes demo".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
			{
				DrawSelectableTreeDemo(gui);
				ImTree.EndTreeNode(gui);
			}
		}

		private static void DrawSlidersDemo(ImGui gui)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			DrawBouncingBall(gui);
			ImSlider.SliderHeader(gui, "Size".AsSpan(), bouncingBallSize, "0.00 px".AsSpan());
			ImSlider.Slider(gui, ref bouncingBallSize, 1f, ImLayoutUtility.GetRowHeight(gui), default(ImSize), 0f, (ImSliderFlag)0);
			ImTooltip.TooltipAtLastControl(gui, "Size of the circles in pixels".AsSpan(), (ImTooltipShow)1);
			ImSlider.SliderHeader(gui, "Speed".AsSpan(), bouncingBallSpeed, "0.##".AsSpan());
			ImSlider.Slider(gui, ref bouncingBallSpeed, -2f, 2f, default(ImSize), 0f, (ImSliderFlag)0);
			ImTooltip.TooltipAtLastControl(gui, "Speed of moving circles".AsSpan(), (ImTooltipShow)1);
			ImSlider.SliderHeader(gui, "Trail Length".AsSpan(), (float)bouncingBallTrail, default(ReadOnlySpan<char>));
			ImSlider.Slider(gui, ref bouncingBallTrail, 1, 256, default(ImSize), 32, (ImSliderFlag)1);
			ImTooltip.TooltipAtLastControl(gui, "Number of circles drawn".AsSpan(), (ImTooltipShow)1);
		}

		private static void DrawMenuBarItems(ImGui gui, ref bool windowOpen)
		{
			if (!ImMenu.BeginMenu(gui, "Demo".AsSpan()))
			{
				return;
			}
			if (ImMenu.BeginMenu(gui, "Custom Menus".AsSpan()))
			{
				ImLayoutUtility.BeginVertical(gui, 300f, 0f);
				DrawSlidersDemo(gui);
				ImLayoutUtility.EndVertical(gui);
				ImMenu.EndMenu(gui);
			}
			if (ImMenu.BeginMenu(gui, "Recursive".AsSpan()))
			{
				DrawMenuBarItems(gui, ref windowOpen);
				ImMenu.EndMenu(gui);
			}
			ImSeparator.Separator(gui);
			if (ImMenu.BeginMenu(gui, "Test".AsSpan()))
			{
				if (ImMenu.BeginMenu(gui, "Same name submenu".AsSpan()))
				{
					ImMenu.Menu(gui, "Item".AsSpan());
					ImMenu.EndMenu(gui);
				}
				gui.PushId("Next Menu".AsSpan());
				if (ImMenu.BeginMenu(gui, "Same name submenu".AsSpan()))
				{
					ImMenu.Menu(gui, "Item".AsSpan());
					ImMenu.EndMenu(gui);
				}
				gui.PopId();
				ImMenu.EndMenu(gui);
			}
			ImSeparator.Separator(gui);
			if (ImMenu.Menu(gui, "Close".AsSpan()))
			{
				windowOpen = false;
			}
			ImMenu.EndMenu(gui);
		}

		private static void DrawLayoutPage(ImGui gui)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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)
			ImLayoutUtility.AddSpacing(gui);
			ImLayoutUtility.BeginHorizontal(gui, 0f, 0f);
			for (int i = 0; i < 3; i++)
			{
				ImButton.Button(gui, "Horizontal".AsSpan(), ImSize.op_Implicit((ImSizeMode)2), (ImButtonFlag)0);
			}
			ImLayoutUtility.EndHorizontal(gui);
			ImLayoutUtility.AddSpacing(gui);
			ImLayoutUtility.BeginVertical(gui, 0f, 0f);
			for (int j = 0; j < 3; j++)
			{
				ImButton.Button(gui, "Vertical".AsSpan(), ImSize.op_Implicit((ImSizeMode)2), (ImButtonFlag)0);
			}
			ImLayoutUtility.EndVertical(gui);
			ImLayoutUtility.AddSpacing(gui);
			ImGridState val = ImGrid.BeginGrid(gui, 5, ImLayoutUtility.GetRowHeight(gui));
			for (int k = 0; k < 12; k++)
			{
				ImText.TextAutoSize(gui, Format("Grid cell ".AsSpan(), k, "0".AsSpan()), ImGrid.GridNextCell(gui, ref val), false);
			}
			ImGrid.EndGrid(gui, ref val);
		}

		private static void DrawTablesPage(ImGui gui)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			if (ImTree.BeginTreeNode(gui, "Simple".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
			{
				ImTable.BeginTable(gui, 4, default(ImSize), (ImTableFlag)0);
				for (int i = 0; i < 5; i++)
				{
					ImTable.TableNextRow(gui);
					for (int j = 0; j < 4; j++)
					{
						ImTable.TableNextColumn(gui);
						ImText.Text(gui, (ReadOnlySpan<char>)gui.Formatter.Concat("Hello At ".AsSpan(), gui.Formatter.Format((long)j, default(ReadOnlySpan<char>)), ":".AsSpan(), gui.Formatter.Format((long)i, default(ReadOnlySpan<char>))), false, (ImTextOverflow)0);
					}
				}
				ImTable.EndTable(gui);
				ImSeparator.Separator(gui, "Resizable Columns".AsSpan());
				ImTable.BeginTable(gui, 4, default(ImSize), (ImTableFlag)1);
				for (int k = 0; k < 5; k++)
				{
					ImTable.TableNextRow(gui);
					for (int l = 0; l < 4; l++)
					{
						ImTable.TableNextColumn(gui);
						ImText.Text(gui, (ReadOnlySpan<char>)gui.Formatter.Concat("Hello At ".AsSpan(), gui.Formatter.Format((long)l, default(ReadOnlySpan<char>)), ":".AsSpan(), gui.Formatter.Format((long)k, default(ReadOnlySpan<char>))), true, (ImTextOverflow)0);
					}
				}
				ImTable.EndTable(gui);
				ImTree.EndTreeNode(gui);
			}
			if (ImTree.BeginTreeNode(gui, "With Scroll Bars".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
			{
				ImTable.BeginTable(gui, 4, ImSize.op_Implicit((ImLayoutUtility.GetLayoutWidth(gui), 200f)), (ImTableFlag)0);
				for (int m = 0; m < 12; m++)
				{
					ImTable.TableNextRow(gui);
					for (int n = 0; n < 4; n++)
					{
						ImTable.TableNextColumn(gui);
						ImText.Text(gui, (ReadOnlySpan<char>)gui.Formatter.Concat("Hello At ".AsSpan(), gui.Formatter.Format((long)n, default(ReadOnlySpan<char>)), ":".AsSpan(), gui.Formatter.Format((long)m, default(ReadOnlySpan<char>))), true, (ImTextOverflow)0);
					}
				}
				ImTable.EndTable(gui);
				ImTree.EndTreeNode(gui);
			}
			if (!ImTree.BeginTreeNode(gui, "Large Tables".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
			{
				return;
			}
			NumEditWithLabel(gui, ref largeTableRows, "Rows".AsSpan(), 1, 4194304);
			NumEditWithLabel(gui, ref largeTableColumns, "Columns".AsSpan(), 1, 4096);
			NumEditWithLabel(gui, ref largeTableColumnSize, "Col. Size".AsSpan(), 50f, 300f);
			ImCheckbox.Checkbox(gui, ref largeTableResizable, "Resizable Columns".AsSpan(), default(ImSize));
			ImCheckbox.Checkbox(gui, ref largeTableScrollable, "Scrollable".AsSpan(), default(ImSize));
			ImSize val = (largeTableScrollable ? new ImSize(ImLayoutUtility.GetLayoutWidth(gui), 300f) : new ImSize((ImSizeMode)0));
			ImTableFlag val2 = (ImTableFlag)(largeTableResizable ? 1 : 0);
			ref ImTableState reference = ref ImTable.BeginTable(gui, largeTableColumns, val, val2);
			ImTable.TableSetRowsHeight(gui, ImLayoutUtility.GetTextLineHeight(gui) + ((ImPadding)(ref gui.Style.Table.CellPadding)).Vertical);
			for (int num = 0; num < largeTableColumns; num++)
			{
				ImTable.TableSetColumnWidth(gui, num, largeTableColumnSize);
			}
			ImTextSettings val3 = default(ImTextSettings);
			((ImTextSettings)(ref val3))..ctor(gui.Style.Layout.TextSize, new ImAlignment(0.5f, 0.5f), false, (ImTextOverflow)1);
			ImTableRowsRange val4 = ImTable.TableGetVisibleRows(gui, largeTableRows);
			ImTableColumnsRange val5 = ImTable.TableGetVisibleColumns(gui);
			for (int num2 = val4.Min; num2 < val4.Max; num2++)
			{
				ImTable.TableSetRow(gui, num2, ref reference);
				for (int num3 = val5.Min; num3 < val5.Max; num3++)
				{
					ImTable.TableSetColumn(gui, num3, ref reference);
					ImText.Text(gui, (ReadOnlySpan<char>)gui.Formatter.Concat(gui.Formatter.Format((long)num3, default(ReadOnlySpan<char>)), "x".AsSpan(), gui.Formatter.Format((long)num2, default(ReadOnlySpan<char>))), ref val3);
				}
			}
			ImTable.EndTable(gui);
			ImTree.EndTreeNode(gui);
		}

		private static void NumEditWithLabel(ImGui gui, ref int value, ReadOnlySpan<char> label, int min, int max)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui);
			ImLayoutUtility.BeginHorizontal(gui, 0f, 0f);
			ImText.Text(gui, label, gui.Layout.AddRect(150f, ImLayoutUtility.GetRowHeight(gui)), false, (ImTextOverflow)0);
			ImNumericEdit.NumericEdit(gui, ref value, default(ImSize), default(ReadOnlySpan<char>), 1, min, max, (ImNumericEditFlag)1);
			ImLayoutUtility.EndHorizontal(gui);
		}

		private static void NumEditWithLabel(ImGui gui, ref float value, ReadOnlySpan<char> label, float min, float max)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui);
			ImLayoutUtility.BeginHorizontal(gui, 0f, 0f);
			ImText.Text(gui, label, gui.Layout.AddRect(150f, ImLayoutUtility.GetRowHeight(gui)), false, (ImTextOverflow)0);
			ImNumericEdit.NumericEdit(gui, ref value, default(ImSize), default(ReadOnlySpan<char>), 0.1f, min, max, (ImNumericEditFlag)1);
			ImLayoutUtility.EndHorizontal(gui);
		}

		public static void DrawBouncingBall(ImGui gui)
		{
			//IL_0013: 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_003d: 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_00d4: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			ImRect val = ImRectUtility.WithPadding(ImLayoutUtility.AddLayoutRectWithSpacing(gui, ImLayoutUtility.GetLayoutWidth(gui), ImLayoutUtility.GetRowHeight(gui) * 1.25f), bouncingBallSize / 2f, bouncingBallSize / 2f, 0f, 0f);
			float num = Time.unscaledDeltaTime * bouncingBallSpeed;
			bouncingBallTime += num;
			for (int i = 0; i < bouncingBallTrail; i++)
			{
				float num2 = mod(bouncingBallTime + (float)i * 0.01f * bouncingBallSpeed, 2f);
				float num3 = ((num2 <= 1f) ? num2 : (1f - (num2 - 1f)));
				float num4 = 0.5f + Mathf.Sin((bouncingBallTime + (float)i * 0.01f * bouncingBallSpeed) * MathF.PI * 2f) * 0.25f;
				Vector2 pointAtNormalPosition = ((ImRect)(ref val)).GetPointAtNormalPosition(num3, num4);
				Color32 val2 = ImColorUtility.WithAlpha(gui.Style.Text.Color, Mathf.Pow((float)(i + 1) / (float)bouncingBallTrail, 6f));
				gui.Canvas.Circle(pointAtNormalPosition, bouncingBallSize * 0.5f, val2);
			}
			static float mod(float x, float y)
			{
				return (x % y + y) % y;
			}
		}

		public static void NestedFoldout(ImGui gui, int current, ref int total)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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)
			ReadOnlySpan<char> readOnlySpan = ((current == 0) ? "Nested Foldout".AsSpan() : Format("Nested Foldout ".AsSpan(), current, "0".AsSpan()));
			if (!ImFoldout.BeginFoldout(gui, readOnlySpan, default(ImSize), false))
			{
				return;
			}
			ImLayoutUtility.BeginIndent(gui);
			if (current < total)
			{
				NestedFoldout(gui, current + 1, ref total);
			}
			else if (current == total)
			{
				if (total == 8)
				{
					ImText.Text(gui, "Let's just stop here".AsSpan(), false, (ImTextOverflow)0);
					if (ImButton.Button(gui, "Reset".AsSpan(), default(ImSize), (ImButtonFlag)0))
					{
						total = 0;
					}
				}
				else if (ImButton.Button(gui, "Add one more".AsSpan(), default(ImSize), (ImButtonFlag)0))
				{
					total++;
				}
			}
			ImLayoutUtility.EndIndent(gui);
			ImFoldout.EndFoldout(gui);
		}

		private static ReadOnlySpan<char> Format(ReadOnlySpan<char> prefix, float value, ReadOnlySpan<char> format = default(ReadOnlySpan<char>))
		{
			Span<char> destination = new Span<char>(formatBuffer);
			prefix.CopyTo(destination);
			value.TryFormat(destination.Slice(prefix.Length), out var charsWritten, format);
			return destination.Slice(0, prefix.Length + charsWritten);
		}
	}
}
namespace WKLib.Core.UI
{
	internal class OverlayState : MonoBehaviour
	{
		public static List<PopupSettings> Popups = new List<PopupSettings>();

		private Dictionary<GraphicRaycaster, bool> _originalState = new Dictionary<GraphicRaycaster, bool>();

		private CL_GameManager gameManager;

		private GraphicRaycaster mainGraphicRaycaster;

		private bool isOpen;

		public bool IsOpen
		{
			get
			{
				return isOpen;
			}
			set
			{
				if ((Object)(object)gameManager == (Object)null)
				{
					GameObject obj = GameObject.Find("GameManager");
					gameManager = ((obj != null) ? obj.GetComponent<CL_GameManager>() : null);
				}
				bool flag = (Object)(object)gameManager != (Object)null && gameManager.loading;
				bool flag2 = (Object)(object)gameManager != (Object)null && gameManager.reviving;
				if (!flag && !flag2)
				{
					if (isOpen == value)
					{
						return;
					}
				}
				else
				{
					value = false;
				}
				isOpen = value;
				bool flag3 = (Object)(object)gameManager != (Object)null && gameManager.isPaused;
				bool inUse = OS_Manager.inUse;
				bool flag4 = (Object)(object)gameManager != (Object)null && Object.op_Implicit((Object)(object)gameManager.pauseMenu);
				bool flag5 = (Object)(object)gameManager != (Object)null && gameManager.canPause;
				if (isOpen)
				{
					_originalState.Clear();
					if (flag4)
					{
						if (flag3)
						{
							return;
						}
						if (!inUse && flag5 && !flag && !flag2)
						{
							CL_GameManager obj2 = gameManager;
							if (obj2 != null)
							{
								obj2.Pause();
							}
							return;
						}
						isOpen = false;
						PopupSettings popupSettings = new PopupSettings();
						if (inUse)
						{
							popupSettings.PopupText = "Cannot open overlay in terminal.";
						}
						else if (!flag5)
						{
							popupSettings.PopupText = "Cannot open because game cannot be paused.";
						}
						else if (flag)
						{
							popupSettings.PopupText = "Cannot open overlay because the game is loading.";
						}
						else if (flag2)
						{
							popupSettings.PopupText = "Cannot open overlay because the player is reviving.";
						}
						popupSettings.TimeTillClose = Time.realtimeSinceStartup + popupSettings.PopupTime;
						Popups.Add(popupSettings);
					}
					else
					{
						if (!((Object)(object)mainGraphicRaycaster != (Object)null))
						{
							return;
						}
						GraphicRaycaster[] array = Object.FindObjectsOfType<GraphicRaycaster>();
						foreach (GraphicRaycaster val in array)
						{
							if (!((Object)(object)val == (Object)null))
							{
								_originalState[val] = ((UIBehaviour)val).IsActive();
								((Behaviour)val).enabled = false;
							}
						}
						((Behaviour)mainGraphicRaycaster).enabled = true;
					}
					return;
				}
				if (flag4)
				{
					if (flag3 && !inUse && flag5 && !flag && !flag2)
					{
						CL_GameManager obj3 = gameManager;
						if (obj3 != null)
						{
							obj3.UnPause();
						}
					}
					return;
				}
				foreach (KeyValuePair<GraphicRaycaster, bool> item in _originalState)
				{
					if (!((Object)(object)item.Key == (Object)null))
					{
						((Behaviour)item.Key).enabled = true;
					}
				}
			}
		}

		private void OnEnable()
		{
			mainGraphicRaycaster = ((Component)this).gameObject.GetComponent<GraphicRaycaster>();
		}

		public void Draw(ImGui gui)
		{
			foreach (PopupSettings popup in Popups)
			{
				if (Time.realtimeSinceStartup < popup.TimeTillClose)
				{
					QuickPopupWindow.Draw(gui, popup.PopupText);
				}
			}
		}
	}
	[DefaultExecutionOrder(-999)]
	internal class RootPanel : MonoSingleton<RootPanel>
	{
		public ImGui gui;

		public ImuiPanel ImuiPanel;

		public ThemeController ThemeController;

		public OverlayState OverlayState;

		private bool isDemoOpen;

		public bool IsOpen
		{
			get
			{
				return OverlayState.IsOpen;
			}
			set
			{
				OverlayState.IsOpen = value;
			}
		}

		public override void OnEnable()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			base.OnEnable();
			SceneManager.sceneLoaded -= OnSceneChange;
			SceneManager.sceneLoaded += OnSceneChange;
			((Object)ImuiPanel.Canvas).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)ImuiPanel.Canvas);
			ImuiUnityGUIBackend component = ((Component)((Component)this).transform).GetComponent<ImuiUnityGUIBackend>();
			if (gui == null)
			{
				gui = new ImGui((IImuiRenderer)(object)component, (IImuiInput)(object)component);
			}
			OverlayState = ((Component)this).gameObject.GetComponent<OverlayState>();
			if ((Object)(object)OverlayState == (Object)null)
			{
				OverlayState = ((Component)this).gameObject.AddComponent<OverlayState>();
			}
			ThemeController = ((Component)this).gameObject.GetComponent<ThemeController>();
			if ((Object)(object)ThemeController == (Object)null)
			{
				ThemeController = ((Component)this).gameObject.AddComponent<ThemeController>();
			}
			ThemeController.SetTheme(gui);
			ModListWindow.Initialize();
			void OnSceneChange(Scene scene, LoadSceneMode loadSceneMode)
			{
				if (ConfigManager.AutoCloseOverlay.Value)
				{
					IsOpen = false;
				}
			}
		}

		private void Update()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			ThemeController.DetectChanges(gui);
			gui.BeginFrame();
			if (InputUtility.GetKeyDown(ConfigManager.OverlayKey.Value))
			{
				IsOpen = !IsOpen;
			}
			HandleAPIInput();
			OverlayState.Draw(gui);
			if (IsOpen)
			{
				DrawRootMenuBar();
			}
			ChangeLogWindow.Draw(gui, IsOpen);
			if (ConfigManager.EnableDemoWindow.Value)
			{
				DemoWindow.Draw(gui, ref isDemoOpen);
			}
			ModListWindow.Draw(gui, IsOpen);
			DrawAPIWindows();
			if (InputUtility.GetKeyDown((KeyCode)13))
			{
				gui.ResetActiveControl();
			}
			gui.EndFrame();
			gui.Render();
		}

		private void DrawRootMenuBar()
		{
			ImMenuBar.BeginMenuBar(gui);
			if (ImMenu.BeginMenu(gui, "General".AsSpan()))
			{
				ImMenu.Menu(gui, "Open mod list".AsSpan(), ref ModListWindow.isOpen);
				if (ConfigManager.EnableDemoWindow.Value)
				{
					ImMenu.Menu(gui, "Open demo menu".AsSpan(), ref isDemoOpen);
				}
				ImSeparator.Separator(gui);
				ImMenu.Menu(gui, "Open changelog".AsSpan(), ref ChangeLogWindow.isOpen);
				ImSeparator.Separator(gui);
				if (ImMenu.Menu(gui, "Close menu".AsSpan()))
				{
					IsOpen = false;
				}
				ImMenu.EndMenu(gui);
			}
			if (ImMenu.BeginMenu(gui, "Windows".AsSpan()))
			{
				if (ImMenu.Menu(gui, "Close all windows".AsSpan()))
				{
					ModListWindow.isOpen = false;
					ModListWindow.CloseConfigWindows();
					CloseAPIWindows();
				}
				ImMenu.EndMenu(gui);
			}
			ImMenuBar.EndMenuBar(gui);
		}

		private void DrawAPIWindows()
		{
			foreach (WKLibAPI internalAPI in WKLibAPI.internalAPIs)
			{
				if (internalAPI == null)
				{
					continue;
				}
				foreach (WKLibWindow window in internalAPI.Windows)
				{
					window?.Draw(gui, IsOpen);
				}
			}
		}

		private void HandleAPIInput()
		{
			foreach (WKLibAPI internalAPI in WKLibAPI.internalAPIs)
			{
				if (internalAPI == null)
				{
					continue;
				}
				foreach (WKLibWindow window in internalAPI.Windows)
				{
					window?.HandleInput(gui);
				}
			}
		}

		private void CloseAPIWindows()
		{
			foreach (WKLibAPI internalAPI in WKLibAPI.internalAPIs)
			{
				if (internalAPI == null)
				{
					continue;
				}
				foreach (WKLibWindow window in internalAPI.Windows)
				{
					if (window != null)
					{
						window.isOpen = false;
					}
				}
			}
		}
	}
	internal class ThemeController : MonoBehaviour
	{
		public ImTheme BaseTheme = SetBaseTheme(ImThemeBuiltin.Dark());

		private bool changesDetected;

		public static ImTheme SetBaseTheme(ImTheme theme)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			theme.Background = new Color(0f, 0f, 0f, 1f);
			theme.Foreground = new Color(1f, 1f, 1f, 1f);
			theme.Accent = ConfigManager.AccentColor.Value;
			theme.Control = new Color(0.15f, 0.15f, 0.15f, 1f);
			theme.Contrast = (ConfigManager.HighContrast.Value ? 1f : 0f);
			theme.BorderContrast = 1f;
			theme.TextSize = 16f;
			theme.BorderRadius = 1f;
			theme.ReadOnlyColorMultiplier = 0.25f;
			return theme;
		}

		public void RegisterChanges()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			changesDetected = true;
			BaseTheme.Contrast = (ConfigManager.HighContrast.Value ? 1f : 0f);
			BaseTheme.Accent = ConfigManager.AccentColor.Value;
		}

		public void DetectChanges(ImGui gui)
		{
			if (changesDetected)
			{
				changesDetected = false;
				SetTheme(gui);
			}
		}

		public void DrawAppearanceEditor(ImGui gui)
		{
			//IL_001a: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			bool value = ConfigManager.HighContrast.Value;
			if (ImCheckbox.Checkbox(gui, ref value, "High contrast".AsSpan(), default(ImSize)))
			{
				ConfigManager.HighContrast.Value = value;
				BaseTheme.Contrast = (ConfigManager.HighContrast.Value ? 1f : 0f);
				SetTheme(gui);
			}
			Color value2 = ConfigManager.AccentColor.Value;
			if (ImColorEdit.ColorEdit(gui, ref value2, default(ImSize)))
			{
				ConfigManager.AccentColor.Value = value2;
				BaseTheme.Accent = ConfigManager.AccentColor.Value;
				SetTheme(gui);
			}
		}

		public static bool DrawThemeEditor(ImGui gui, ref ImTheme theme)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: 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_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: 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_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			ImSeparator.Separator(gui, "Colors".AsSpan());
			using (new UIUtility.LabeledScope(gui, "Foreground".AsSpan()))
			{
				flag |= ImColorEdit.ColorEdit(gui, ref theme.Foreground, default(ImSize));
			}
			using (new UIUtility.LabeledScope(gui, "Background".AsSpan()))
			{
				flag |= ImColorEdit.ColorEdit(gui, ref theme.Background, default(ImSize));
			}
			using (new UIUtility.LabeledScope(gui, "Accent".AsSpan()))
			{
				flag |= ImColorEdit.ColorEdit(gui, ref theme.Accent, default(ImSize));
			}
			using (new UIUtility.LabeledScope(gui, "Control".AsSpan()))
			{
				flag |= ImColorEdit.ColorEdit(gui, ref theme.Control, default(ImSize));
			}
			using (new UIUtility.LabeledScope(gui, "Contrast".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.Contrast, default(ImSize), default(ReadOnlySpan<char>), 0.1f, -1f, 1f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "BorderContrast".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.BorderContrast, default(ImSize), default(ReadOnlySpan<char>), 0.1f, -1f, 2f, (ImNumericEditFlag)2);
			}
			ImSeparator.Separator(gui, "Values".AsSpan());
			using (new UIUtility.LabeledScope(gui, "TextSize".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.TextSize, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 4f, 128f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "Spacing".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.Spacing, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 32f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "InnerSpacing".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.InnerSpacing, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 32f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "Indent".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.Indent, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 128f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "ExtraRowHeight".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.ExtraRowHeight, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 128f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "ScrollBarSize".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.ScrollBarSize, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 2f, 128f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "WindowBorderRadius".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.WindowBorderRadius, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 32f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "WindowBorderThickness".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.WindowBorderThickness, default(ImSize), default(ReadOnlySpan<char>), 0.5f, 0f, 8f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "BorderRadius".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.BorderRadius, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 16f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "BorderThickness".AsSpan()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.BorderThickness, default(ImSize), default(ReadOnlySpan<char>), 0.5f, 0f, 8f, (ImNumericEditFlag)2);
			}
			using (new UIUtility.LabeledScope(gui, "ReadOnlyColorMultiplier".AsSpan()))
			{
				return flag | ImNumericEdit.NumericEdit(gui, ref theme.ReadOnlyColorMultiplier, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 8f, (ImNumericEditFlag)2);
			}
		}

		public void SetTheme(ImGui gui)
		{
			gui.SetTheme(ref BaseTheme);
		}
	}
}
namespace WKLib.Core.UI.Windows
{
	internal class ChangeLogWindow
	{
		public static bool isOpen;

		public static void Draw(ImGui gui, bool isRootPanelOpen)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			if (isRootPanelOpen && ImWindow.BeginWindow(gui, "WKLib changelog", ref isOpen, new ImSize(500f, 400f), (ImWindowFlag)0))
			{
				ImSeparator.Separator(gui, "Versions".AsSpan());
				if (ImTree.BeginTreeNode(gui, "Version 0.3.1".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					ImText.Text(gui, "+ Update to Unity 6".AsSpan(), false, (ImTextOverflow)0);
					ImText.Text(gui, "+ Fix Text replacing".AsSpan(), false, (ImTextOverflow)0);
					ImTree.EndTreeNode(gui);
				}
				if (ImTree.BeginTreeNode(gui, "Version 0.3.0".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					ImText.Text(gui, "+ Rework Input system to work with more keys".AsSpan(), false, (ImTextOverflow)0);
					ImText.Text(gui, "- Remove old config system and adapted BepInEx config system".AsSpan(), false, (ImTextOverflow)0);
					ImText.Text(gui, "- Remove config window, now found in Mod List".AsSpan(), false, (ImTextOverflow)0);
					ImTree.EndTreeNode(gui);
				}
				if (ImTree.BeginTreeNode(gui, "Version 0.2.3".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					ImText.Text(gui, "+ Change config system default saving folder location, dont use WKLib as the default".AsSpan(), false, (ImTextOverflow)0);
					ImText.Text(gui, "+ Fix configs not saving as jsons".AsSpan(), false, (ImTextOverflow)0);
					ImTree.EndTreeNode(gui);
				}
				if (ImTree.BeginTreeNode(gui, "Version 0.2.2".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					ImText.Text(gui, "+ Fix plugin object being deleted".AsSpan(), false, (ImTextOverflow)0);
					ImText.Text(gui, "+ Fix error on scene loaded".AsSpan(), false, (ImTextOverflow)0);
					ImTree.EndTreeNode(gui);
				}
				if (ImTree.BeginTreeNode(gui, "Version 0.2.1".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					ImText.Text(gui, "+ Change config system saving and loading".AsSpan(), false, (ImTextOverflow)0);
					ImTree.EndTreeNode(gui);
				}
				if (ImTree.BeginTreeNode(gui, "Version 0.2.0".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					ImText.Text(gui, "+ Added ChangeLog window".AsSpan(), false, (ImTextOverflow)0);
					ImText.Text(gui, "+ Updated AssetService".AsSpan(), false, (ImTextOverflow)0);
					ImText.Text(gui, "+ Added Overlay button on main menu and pause menu".AsSpan(), false, (ImTextOverflow)0);
					ImTree.EndTreeNode(gui);
				}
				if (ImTree.BeginTreeNode(gui, "Version 0.1.0".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					ImText.Text(gui, "+ Reworked UI and Config API".AsSpan(), false, (ImTextOverflow)0);
					ImTree.EndTreeNode(gui);
				}
				ImWindow.EndWindow(gui);
			}
		}
	}
	internal static class ModListWindow
	{
		public static bool isOpen = true;

		private static PluginContainer[] pluginContainers = Array.Empty<PluginContainer>();

		private static string searchString = "";

		public static void Initialize()
		{
			List<PluginContainer> pluginSettings = PluginConfigSearcher.GetPluginSettings();
			foreach (PluginContainer item in pluginSettings)
			{
				item.PluginName = PrettifyName(item.PluginInfo.Metadata.Name);
			}
			pluginContainers = pluginSettings.OrderBy<PluginContainer, string>((PluginContainer x) => x.PluginName, StringComparer.OrdinalIgnoreCase).ToArray();
			static string PrettifyName(string input)
			{
				input = Regex.Replace(input, "([a-z])([A-Z])", "$1 $2");
				input = Regex.Replace(input, "([A-Z])([A-Z][a-z])", "$1 $2");
				input = Regex.Replace(input, "\\s+", " ");
				input = Regex.Replace(input, "([A-Z]\\.)\\s([A-Z]\\.)", "$1$2");
				return input.Trim();
			}
		}

		public static void Draw(ImGui gui, bool open)
		{
			//IL_0019: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			if (!open || !ImWindow.BeginWindow(gui, "Mod list", ref isOpen, new ImSize(250f, 500f), (ImWindowFlag)0))
			{
				return;
			}
			ImLayoutUtility.BeginVertical(gui, 0f, 0f);
			ImSeparator.Separator(gui, "Mods".AsSpan());
			ReadOnlySpan<char> readOnlySpan = "Search for mod".AsSpan();
			ImTextEdit.TextEdit(gui, ref searchString, default(ImSize), (bool?)null, 0, (ImTouchKeyboardType)0, readOnlySpan);
			ImLayoutUtility.AddSpacing(gui);
			for (int i = 0; i < pluginContainers.Length; i++)
			{
				ref PluginContainer reference = ref pluginContainers[i];
				if (reference == null || reference.PluginInfo == null)
				{
					continue;
				}
				WKLibAPI aPIReference = reference.APIReference;
				if (aPIReference == null || (aPIReference != null && aPIReference.ModTab == null))
				{
					string name = reference.PluginInfo.Metadata.Name;
					if (!Utility.IsNullOrWhiteSpace(name) && (!(searchString.Trim() != string.Empty) || name.Contains(searchString, StringComparison.OrdinalIgnoreCase)))
					{
						gui.PushId(reference.PluginInfo.Metadata.GUID.AsSpan());
						if (ImButton.Button(gui, name.AsSpan(), default(ImSize), (ImButtonFlag)0))
						{
							reference.IsWindowOpen = !reference.IsWindowOpen;
						}
						gui.PopId();
					}
				}
				else if (aPIReference.ModTab != null && (!(searchString.Trim() != string.Empty) || aPIReference.ModTab.DisplayName.Contains(searchString, StringComparison.OrdinalIgnoreCase)) && ImTree.BeginTreeNode(gui, aPIReference.ModTab.DisplayName.AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
				{
					aPIReference.ModTab.DrawSubMenu(gui);
					ImTree.EndTreeNode(gui);
				}
			}
			ImLayoutUtility.EndVertical(gui);
			ImWindow.EndWindow(gui);
			DrawConfigWindows(gui);
		}

		public static void CloseConfigWindows()
		{
			for (int i = 0; i < pluginContainers.Length; i++)
			{
				ref PluginContainer reference = ref pluginContainers[i];
				if (reference != null)
				{
					reference.IsWindowOpen = false;
				}
			}
		}

		private static void DrawConfigWindows(ImGui gui)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < pluginContainers.Length; i++)
			{
				ref PluginContainer reference = ref pluginContainers[i];
				if (reference == null || reference.PluginInfo == null || !reference.IsWindowOpen)
				{
					continue;
				}
				string name = reference.PluginInfo.Metadata.Name;
				if (Utility.IsNullOrWhiteSpace(name) || !ImWindow.BeginWindow(gui, name + " " + reference.PluginInfo.Metadata.Version, ref reference.IsWindowOpen, new ImSize(500f, 500f), (ImWindowFlag)0))
				{
					continue;
				}
				PluginContainer.ConfigEntrySection[] configSection = reference.ConfigSection;
				foreach (PluginContainer.ConfigEntrySection configEntrySection in configSection)
				{
					if (!Utility.IsNullOrWhiteSpace(configEntrySection.Section))
					{
						ImLayoutUtility.AddSpacing(gui);
						ImSeparator.Separator(gui, configEntrySection.Section.AsSpan());
					}
					ConfigEntryBase[] configEntries = configEntrySection.ConfigEntries;
					foreach (ConfigEntryBase configEntry in configEntries)
					{
						UIUtility.DrawConfigEntry(gui, configEntry);
					}
				}
				ImWindow.EndWindow(gui);
			}
		}

		public static void HandleInput(ImGui gui, bool open)
		{
		}
	}
	internal static class QuickPopupWindow
	{
		public static void Draw(ImGui gui, string text)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (!(text.Trim() == string.Empty))
			{
				Vector2 val = ImText.MeasureTextSize(gui, text.AsSpan());
				ImWindow.BeginWindow(gui, "Popup", new ImSize(val.x * 1.5f, ImLayoutUtility.GetRowHeight(gui) * 5f), (ImWindowFlag)0);
				ImText.Text(gui, text.AsSpan(), false, (ImTextOverflow)0);
				ImWindow.EndWindow(gui);
			}
		}
	}
}
namespace WKLib.Core.Reflection
{
	internal class ReflectionUtility
	{
		private static readonly SortedDictionary<string, Type> AllTypes = new SortedDictionary<string, Type>(StringComparer.OrdinalIgnoreCase);

		internal static void Initialize()
		{
			SetupTypeCache();
		}

		internal static Type GetTypeByName(string fullName)
		{
			AllTypes.TryGetValue(fullName, out var value);
			if (value == null)
			{
				return Type.GetType(fullName);
			}
			return value;
		}

		private static void SetupTypeCache()
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				CacheTypes(assemblies[i]);
			}
		}

		private static void CacheTypes(Assembly asm)
		{
			Type[] array = null;
			try
			{
				array = asm.GetTypes();
			}
			catch
			{
				return;
			}
			if (array != null)
			{
				Type[] array2 = array;
				foreach (Type type in array2)
				{
					AllTypes[type.FullName] = type;
				}
			}
		}
	}
}
namespace WKLib.Core.Patches
{
	[PatchOnEntry]
	[HarmonyPatch]
	internal static class CL_GameManagerPatch
	{
		[HarmonyPatch(typeof(CL_GameManager), "UnPause")]
		[HarmonyPostfix]
		private static void CL_GameManager_UnPause(CL_GameManager __instance)
		{
			if (!((Object)(object)MonoSingleton<RootPanel>.Instance == (Object)null) && ConfigManager.AutoCloseOverlay.Value && MonoSingleton<RootPanel>.Instance.IsOpen && !__instance.isPaused)
			{
				MonoSingleton<RootPanel>.Instance.IsOpen = false;
			}
		}
	}
	[PatchOnEntry]
	[HarmonyPatch]
	internal static class InputManagerPatch
	{
		[HarmonyPatch(typeof(InputManager), "Start")]
		[HarmonyPostfix]
		private static void InputManager_Start(InputManager __instance)
		{
			if (!((Object)(object)MonoSingleton<RootPanel>.Instance != (Object)null))
			{
				ImuiPanel val = ImuiBepInExAPI.CreateImuiPanel();
				((Component)val.Backend).gameObject.SetActive(false);
				((Component)val.Backend).gameObject.AddComponent<RootPanel>().ImuiPanel = val;
				((Component)val.Backend).gameObject.SetActive(true);
			}
		}
	}
}
namespace WKLib.Core.Config
{
	internal static class ConfigManager
	{
		public static ConfigEntry<KeyCode> OverlayKey;

		public static ConfigEntry<bool> AutoCloseOverlay;

		public static ConfigEntry<bool> EnableDemoWindow;

		public static ConfigEntry<bool> HighContrast;

		public static ConfigEntry<Color> AccentColor;

		public static void CreateEntries(ConfigFile Config)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			OverlayKey = Config.Bind<KeyCode>("General", "Overlay Key", (KeyCode)287, "Keybind for opening and closing the overlay menu");
			AutoCloseOverlay = Config.Bind<bool>("General", "Auto Close Overlay", true, "Automatically close overlay on scene change");
			EnableDemoWindow = Config.Bind<bool>("General", "Enable Demo Window", false, "Enable demo window, used to showcase the WKLib UI");
			HighContrast = Config.Bind<bool>("Theme", "High Contrast", false, "Apply high contrast to the UI");
			AccentColor = Config.Bind<Color>("Theme", "Accent color", new Color(0.05f, 0.45f, 0.75f, 1f), "Change accent color of the UI");
			HighContrast.SettingChanged += delegate
			{
				MonoSingleton<RootPanel>.Instance?.ThemeController?.RegisterChanges();
			};
			AccentColor.SettingChanged += delegate
			{
				MonoSingleton<RootPanel>.Instance?.ThemeController?.RegisterChanges();
			};
		}
	}
	internal static class PluginConfigSearcher
	{
		public static BaseUnityPlugin[] FindPlugins()
		{
			return (from x in Chainloader.PluginInfos.Values
				select x.Instance into plugin
				where (Object)(object)plugin != (Object)null
				select plugin).Union(Object.FindObjectsOfType(typeof(BaseUnityPlugin)).Cast<BaseUnityPlugin>()).ToArray();
		}

		public static List<PluginContainer> GetPluginSettings()
		{
			List<PluginContainer> list = new List<PluginContainer>();
			BaseUnityPlugin[] array = FindPlugins();
			foreach (BaseUnityPlugin val in array)
			{
				string GUID = val.Info.Metadata.GUID;
				WKLibAPI wKLibAPI = WKLibAPI.internalAPIs.Find((WKLibAPI api) => string.Equals(api.GUID, GUID, StringComparison.Ordinal));
				if (((object)val).GetType().GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>()
					.Any((BrowsableAttribute x) => !x.Browsable) && wKLibAPI == null)
				{
					continue;
				}
				PluginContainer pluginContainer = new PluginContainer
				{
					PluginName = val.Info.Metadata.Name,
					PluginInfo = val.Info,
					APIReference = wKLibAPI
				};
				if (wKLibAPI == null || (wKLibAPI != null && wKLibAPI.ModTab == null))
				{
					Dictionary<string, List<ConfigEntryBase>> dictionary = new Dictionary<string, List<ConfigEntryBase>>();
					foreach (ConfigEntryBase item in ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)val.Config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> configEntry) => configEntry.Value))
					{
						ConfigDescription description = item.Description;
						object[] array2 = ((description != null) ? description.Tags : null);
						if (array2 == null || !array2.Contains("Hidden"))
						{
							string section = item.Definition.Section;
							if (!dictionary.TryGetValue(section, out var value))
							{
								value = (dictionary[section] = new List<ConfigEntryBase>());
							}
							value.Add(item);
						}
					}
					pluginContainer.ConfigSection = dictionary.Select((KeyValuePair<string, List<ConfigEntryBase>> keyValuePair) => new PluginContainer.ConfigEntrySection
					{
						Section = keyValuePair.Key,
						ConfigEntries = keyValuePair.Value.ToArray()
					}).ToArray();
					if (pluginContainer.ConfigSection.Length == 0)
					{
						continue;
					}
				}
				list.Add(pluginContainer);
			}
			return list;
		}
	}
	internal class PluginContainer
	{
		public class ConfigEntrySection
		{
			public string Section = "";

			public ConfigEntryBase[] ConfigEntries = Array.Empty<ConfigEntryBase>();
		}

		public string PluginName = "";

		public PluginInfo PluginInfo;

		public ConfigEntrySection[] ConfigSection = Array.Empty<ConfigEntrySection>();

		public bool IsWindowOpen;

		public WKLibAPI APIReference;
	}
}
namespace WKLib.Core.Classes
{
	public enum AudioMixerType
	{
		Music,
		Sfx,
		UI
	}
	internal class AudioManager : MonoSingleton<AudioManager>
	{
		private Queue<AudioSource> _audioSourcePool = new Queue<AudioSource>();

		private List<AudioSource> _playingSources = new List<AudioSource>();

		public static void CreateAudioManager()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)MonoSingleton<AudioManager>.Instance))
			{
				MonoSingleton<AudioManager>.Instance = new GameObject("AudioManager").AddComponent<AudioManager>();
			}
		}

		public AudioSource PlaySound(AudioClip clip, Vector3 position, Transform parent = null, float volume = 1f, float pitch = 1f, bool loop = false, float spatial = 1f, float reverbMix = 1f, bool bypassEffects = false, float minDistance = 0f, float? maxDistance = null, float? dopplerLevel = null, float? spread = null, AudioRolloffMode? rolloffMode = null, AnimationCurve customRolloffCurve = null, AudioMixerType mixerType = AudioMixerType.Sfx, string sourceType = "")
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)clip))
			{
				return null;
			}
			if (_audioSourcePool.Count == 0)
			{
				CreateAudioSource();
			}
			AudioSource val = _audioSourcePool.Dequeue();
			val.clip = clip;
			((Component)val).transform.position = position;
			if (Object.op_Implicit((Object)(object)parent))
			{
				((Component)val).transform.SetParent(parent, true);
			}
			val.volume = volume;
			val.pitch = pitch;
			val.loop = loop;
			val.spatialBlend = spatial;
			val.reverbZoneMix = reverbMix;
			val.bypassEffects = bypassEffects;
			val.minDistance = minDistance;
			if (!string.IsNullOrEmpty(sourceType) && AudioManager.sourceTypeDict.TryGetValue(sourceType, out var value))
			{
				AudioSource audioSourcePrefab = value.audioSourcePrefab;
				val.dopplerLevel = dopplerLevel ?? audioSourcePrefab.dopplerLevel;
				val.spread = spread ?? audioSourcePrefab.spread;
				val.maxDistance = maxDistance ?? audioSourcePrefab.maxDistance;
				if (!rolloffMode.HasValue)
				{
					AnimationCurve customCurve = audioSourcePrefab.GetCustomCurve((AudioSourceCurveType)0);
					val.rolloffMode = (AudioRolloffMode)2;
					val.SetCustomCurve((AudioSourceCurveType)0, customRolloffCurve ?? customCurve);
				}
			}
			else
			{
				AudioSource defaultAudio = AudioManager.defaultAudio;
				val.dopplerLevel = dopplerLevel ?? defaultAudio.dopplerLevel;
				val.spread = spread ?? defaultAudio.spread;
				val.maxDistance = maxDistance ?? defaultAudio.maxDistance;
				if (!rolloffMode.HasValue)
				{
					AnimationCurve customCurve2 = defaultAudio.GetCustomCurve((AudioSourceCurveType)0);
					val.rolloffMode = (AudioRolloffMode)2;
					val.SetCustomCurve((AudioSourceCurveType)0, customRolloffCurve ?? customCurve2);
				}
			}
			val.rolloffMode = (AudioRolloffMode)(((??)rolloffMode) ?? val.rolloffMode);
			AudioSource val2 = val;
			val2.outputAudioMixerGroup = (AudioMixerGroup)(mixerType switch
			{
				AudioMixerType.Music => AudioManager.instance.soundtrackMixer, 
				AudioMixerType.Sfx => AudioManager.instance.gameMixer, 
				AudioMixerType.UI => AudioManager.instance.UIMixer, 
				_ => val.outputAudioMixerGroup, 
			});
			((Component)val).gameObject.SetActive(true);
			_playingSources.Add(val);
			val.Play();
			return val;
		}

		private void CreateAudioSource()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			AudioSource val = new GameObject("AudioSource").AddComponent<AudioSource>();
			((Component)val).transform.SetParent(((Component)this).transform);
			val.playOnAwake = false;
			_audioSourcePool.Enqueue(val);
		}

		private void SendBackToPool(AudioSource source)
		{
			_audioSourcePool.Enqueue(source);
			((Component)source).transform.SetParent(((Component)this).transform);
			((Component)source).gameObject.SetActive(false);
		}

		private void Update()
		{
			for (int num = _playingSources.Count - 1; num >= 0; num--)
			{
				AudioSource val = _playingSources[num];
				if (!Object.op_Implicit((Object)(object)val))
				{
					_playingSources.RemoveAt(num);
				}
				else if (!val.isPlaying)
				{
					_playingSources.RemoveAt(num);
					SendBackToPool(val);
				}
			}
		}
	}
	[DefaultExecutionOrder(-200)]
	internal abstract class MonoSingleton : MonoBehaviour
	{
	}
	internal abstract class MonoSingleton<T> : MonoSingleton where T : MonoSingleton<T>
	{
		private static T instance;

		public static T Instance
		{
			get
			{
				return instance;
			}
			set
			{
				instance = value;
			}
		}

		public virtual void Awake()
		{
			if (Object.op_Implicit((Object)(object)Instance) && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
			}
			else
			{
				Instance = (T)this;
			}
		}

		public virtual void OnEnable()
		{
			Instance = (T)this;
		}
	}
}
namespace WKLib.Core.Attributes
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false)]
	internal sealed class PatchOnEntryAttribute : Attribute
	{
	}
}
namespace WKLib.API
{
	public class WKLibAPI
	{
		internal static List<WKLibAPI> internalAPIs = new List<WKLibAPI>();

		public string DisplayName { get; internal set; } = string.Empty;

		public string GUID { get; internal set; } = string.Empty;

		public List<WKLibWindow> Windows { get; internal set; } = new List<WKLibWindow>();

		public ModTab ModTab { get; internal set; }

		public AssetService AssetService { get; internal set; }

		private WKLibAPI(string displayName, string guid, string defaultConfigFileName)
		{
			DisplayName = displayName;
			GUID = guid;
			AssetService = new AssetService(this);
		}

		public static WKLibAPI Create(string displayName, string guid)
		{
			return Create_Internal(displayName, guid);
		}

		public static WKLibAPI Create(string displayName, string guid, string defaultConfigFileName)
		{
			return Create_Internal(displayName, guid, defaultConfigFileName);
		}

		private static WKLibAPI Create_Internal(string displayName, string guid, string defaultConfigFileName = "DefaultConfig")
		{
			foreach (WKLibAPI internalAPI in internalAPIs)
			{
				if (string.Equals(guid, internalAPI.GUID))
				{
					throw new Exception(displayName + " collides with " + internalAPI.DisplayName + ", they both have the same guid, " + guid);
				}
			}
			WKLibAPI wKLibAPI = new WKLibAPI(displayName, guid, defaultConfigFileName);
			internalAPIs.Add(wKLibAPI);
			internalAPIs.Sort((WKLibAPI a, WKLibAPI b) => string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase));
			return wKLibAPI;
		}

		public void AddWindow(WKLibWindow window)
		{
			if (!Windows.Contains(window))
			{
				Windows.Add(window);
			}
		}

		public void AddToModList(ModTab modTab)
		{
			if (ModTab != null)
			{
				throw new Exception("Mod tab already exists, cant add new one");
			}
			ModTab = modTab;
		}

		public void Destroy()
		{
			if (internalAPIs.Contains(this))
			{
				internalAPIs.Remove(this);
			}
		}
	}
}
namespace WKLib.API.UI
{
	[RequireComponent(typeof(TMP_Text))]
	public class InputTextReplace : MonoBehaviour
	{
		public string forceSchemeName = string.Empty;

		private TMP_Text _text;

		private string _originalText;

		private bool _lastIsGamepad;

		private void OnEnable()
		{
			_lastIsGamepad = InputManager.IsGamepad();
			if ((Object)(object)_text == (Object)null)
			{
				_text = ((Component)this).GetComponent<TMP_Text>();
				if ((Object)(object)_text == (Object)null)
				{
					return;
				}
				_originalText = _text.text;
			}
			ReloadText();
		}

		private void Update()
		{
			if (_lastIsGamepad != InputManager.IsGamepad())
			{
				ReloadText();
				_lastIsGamepad = InputManager.IsGamepad();
			}
		}

		public void ReloadText()
		{
			_text.text = _originalText;
			for (int num = _text.text.IndexOf("{", StringComparison.Ordinal); num != -1; num = _text.text.IndexOf("{", num + 1, StringComparison.Ordinal))
			{
				string text = _text.text.Substring(num, _text.text.IndexOf("}", num, StringComparison.Ordinal) - num + 1);
				string text2 = text.Replace("{", "").Replace("}", "");
				if (text2.StartsWith("k:", StringComparison.Ordinal) || text2.StartsWith("c:", StringComparison.Ordinal) || text2.StartsWith("a:", StringComparison.Ordinal))
				{
					string[] array = text2.Split(',');
					string tag = text2;
					if (array.Length == 2)
					{
						tag = (InputManager.IsGamepad() ? array[1] : array[0]);
					}
					_text.text = _text.text.Replace(text, GetInputName(tag));
				}
			}
		}

		private string GetInputName(string tag)
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(tag))
			{
				return "Unknown Key";
			}
			char c = tag[0];
			tag = tag.Remove(0, 2);
			switch (c)
			{
			case 'c':
			{
				InputControl val2 = InputSystem.FindControl(tag);
				if (val2 != null)
				{
					return val2.displayName;
				}
				break;
			}
			case 'a':
			{
				Player playerInput = InputManager.GetPlayerInput();
				if (playerInput == null)
				{
					break;
				}
				int actionId = ReInput.mapping.GetActionId(tag);
				if (actionId < 0)
				{
					break;
				}
				foreach (ControllerMap allMap in playerInput.controllers.maps.GetAllMaps())
				{
					if (!string.IsNullOrEmpty(forceSchemeName) && !string.Equals(allMap.name, forceSchemeName, StringComparison.OrdinalIgnoreCase))
					{
						continue;
					}
					foreach (ActionElementMap allMap2 in allMap.AllMaps)
					{
						if (allMap2.actionId == actionId)
						{
							return allMap2.elementIdentifierName;
						}
					}
				}
				break;
			}
			case 'k':
			{
				if (Enum.TryParse<KeyCode>(tag, out KeyCode result))
				{
					object? obj = InputUtility.KeyCodeToControl(result);
					InputControl val = (InputControl)((obj is InputControl) ? obj : null);
					if (val != null)
					{
						return val.displayName;
					}
				}
				break;
			}
			}
			return "Unknown Key";
		}
	}
	public abstract class ModTab
	{
		public abstract string DisplayName { get; }

		public abstract void DrawSubMenu(ImGui gui);
	}
	public class PopupSettings
	{
		public string PopupText = "";

		public float PopupTime = 2.5f;

		public float TimeTillClose = -1f;

		public PopupSettings()
		{
		}

		public PopupSettings(string text, float seconds = 2.5f)
		{
			PopupText = text;
			PopupTime = seconds;
			TimeTillClose = Time.realtimeSinceStartup + PopupTime;
		}
	}
	public static class UIUtility
	{
		public struct LabeledScope : IDisposable
		{
			private ImGui gui;

			public LabeledScope(ImGui gui, ReadOnlySpan<char> label, float firstRectSize = 0.4f)
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				this.gui = gui;
				gui.PushId(label);
				ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui);
				ImLayoutUtility.BeginHorizontal(gui, 0f, 0f);
				ImRect val = ImLayoutUtility.AddLayoutRect(gui, ImLayoutUtility.GetLayoutWidth(gui) * firstRectSize, ImLayoutUtility.GetRowHeight(gui));
				ImText.Text(gui, label, val, false, (ImTextOverflow)1);
				ImLayoutUtility.BeginVertical(gui, 0f, 0f);
			}

			public void Dispose()
			{
				ImLayoutUtility.EndVertical(gui);
				ImLayoutUtility.EndHorizontal(gui);
				gui.PopId();
			}
		}

		public static bool Keybind(this ImGui gui, string label, ref KeyCode keyCode)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			bool result = false;
			uint controlId = gui.GetControlId(label.AsSpan());
			gui.PushId(controlId);
			ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui);
			ImLayoutUtility.BeginHorizontal(gui, 0f, 0f);
			ImRect val = ImLayoutUtility.AddLayoutRect(gui, ImLayoutUtility.GetLayoutWidth(gui) * 0.8f, ImLayoutUtility.GetRowHeight(gui));
			ImText.Text(gui, label.AsSpan(), val, false, (ImTextOverflow)1);
			ImLayoutUtility.BeginVertical(gui, 0f, 0f);
			if (gui.GetActiveControl() == controlId)
			{
				ImButton.Button(gui, "...".AsSpan(), default(ImSize), (ImButtonFlag)0);
				if (SetToPressedKey(gui, ref keyCode))
				{
					result = true;
					gui.ResetActiveControl();
				}
			}
			else if (ImButton.Button(gui, ((object)Unsafe.As<KeyCode, KeyCode>(ref keyCode)/*cast due to .constrained prefix*/).ToString().AsSpan(), default(ImSize), (ImButtonFlag)0))
			{
				gui.SetActiveControl(controlId, (ImControlFlag)0);
			}
			ImLayoutUtility.EndVertical(gui);
			ImLayoutUtility.EndHorizontal(gui);
			gui.PopId();
			return result;
			static bool SetToPressedKey(ImGui val2, ref KeyCode reference)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Invalid comparison between Unknown and I4
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Invalid comparison between Unknown and I4
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Invalid comparison between Unknown and I4
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Expected I4, but got Unknown
				KeyCode? firstActiveKey = InputUtility.GetFirstActiveKey();
				if (!firstActiveKey.HasValue)
				{
					return false;
				}
				if ((int)firstActiveKey.GetValueOrDefault() == 323 || (int)firstActiveKey.GetValueOrDefault() == 324)
				{
					return true;
				}
				if ((int)firstActiveKey.GetValueOrDefault() == 27)
				{
					reference = (KeyCode)0;
					return true;
				}
				reference = (KeyCode)(int)firstActiveKey.Value;
				return true;
			}
		}

		public static void DrawConfigEntry(ImGui gui, ConfigEntryBase configEntry)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: 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_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: 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_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_075e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			//IL_071c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0783: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0804: Unknown result type (might be due to invalid IL or missing references)
			//IL_080a: Unknown result type (might be due to invalid IL or missing references)
			//IL_078d: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_0889: Unknown result type (might be due to invalid IL or missing references)
			//IL_088f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0814: Unknown result type (might be due to invalid IL or missing references)
			//IL_081b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0822: Unknown result type (might be due to invalid IL or missing references)
			//IL_0829: Unknown result type (might be due to invalid IL or missing references)
			//IL_0830: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0899: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0948: Unknown result type (might be due to invalid IL or missing references)
			//IL_094e: Unknown result type (might be due to invalid IL or missing references)
			string key = configEntry.Definition.Key;
			string description = configEntry.Description.Description;
			description = InsertLineBreaks(description, 40);
			object boxedValue = configEntry.BoxedValue;
			Type settingType = configEntry.SettingType;
			float availableWidth = gui.Layout.GetAvailableWidth();
			float rowHeight = ImLayoutUtility.GetRowHeight(gui);
			Vector2 nextPosition = gui.Layout.GetNextPosition(rowHeight);
			ImRect val = default(ImRect);
			((ImRect)(ref val))..ctor(nextPosition.x, nextPosition.y, availableWidth, rowHeight);
			uint nextControlId = gui.GetNextControlId();
			gui.RegisterGroup(nextControlId, val);
			if (settingType == typeof(bool))
			{
				bool flag = (bool)boxedValue;
				if (ImCheckbox.Checkbox(gui, ref flag, key.AsSpan(), default(ImSize)))
				{
					con