Decompiled source of WKLib v0.3.0

plugins/WKLib.dll

Decompiled 2 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 TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("WKLib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0+783600fdf7a4da27907d61242ace9cff4b43419f")]
[assembly: AssemblyProduct("WKLib")]
[assembly: AssemblyTitle("WKLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WKLib
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.monksilly.WKLib", "WKLib", "0.3.0")]
	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.0";

		private static Harmony harmony;

		private void Awake()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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.0 is loaded!");
			SceneManager.sceneLoaded -= OnSceneLoaded;
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			bool flag = false;
			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.0", Chainloader.PluginInfos.Count);
				}
				GameObject val2 = GameObject.Find("Canvas - Main Menu/Main Menu/Support Menu/Update Info");
				if (!((Object)(object)val2 != (Object)null))
				{
					return;
				}
				GameObject val3 = Object.Instantiate<GameObject>(val2, val2.transform.parent);
				val3.transform.SetSiblingIndex(0);
				((Object)val3).name = "Toggle Overlay";
				UI_MenuButton component = val3.GetComponent<UI_MenuButton>();
				if (component != null)
				{
					Object.DestroyImmediate((Object)(object)component);
				}
				TextMeshProUGUI componentInChildren = val3.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "Toggle Overlay";
				}
				Button component2 = val3.GetComponent<Button>();
				if (!((Object)(object)component2 != (Object)null))
				{
					return;
				}
				((UnityEventBase)component2.onClick).RemoveAllListeners();
				ButtonClickedEvent onClick = component2.onClick;
				object obj2 = <>c.<>9__5_0;
				if (obj2 == null)
				{
					UnityAction val4 = delegate
					{
						MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen;
						EventSystem.current.SetSelectedGameObject((GameObject)null);
					};
					<>c.<>9__5_0 = val4;
					obj2 = (object)val4;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj2);
				return;
			}
			GameObject val5 = GameObject.Find("GameManager/Canvas/Pause/Pause Menu/Pause Buttons/Pause Layout");
			if (!((Object)(object)val5 != (Object)null))
			{
				return;
			}
			Transform val6 = val5.transform.Find("Gap.01");
			Transform val7 = val5.transform.Find("Settings");
			if (!((Object)(object)val6 != (Object)null) || !((Object)(object)val7 != (Object)null))
			{
				return;
			}
			GameObject val8 = Object.Instantiate<GameObject>(((Component)val6).gameObject, ((Component)val6).transform.parent);
			val8.transform.SetSiblingIndex(val6.parent.childCount - 1);
			((Object)val8).name = "Gap.03";
			GameObject val9 = Object.Instantiate<GameObject>(((Component)val7).gameObject, ((Component)val7).transform.parent);
			val9.transform.SetSiblingIndex(val7.parent.childCount - 1);
			((Object)val9).name = "Toggle Overlay";
			UI_MenuButton component3 = val9.GetComponent<UI_MenuButton>();
			if (component3 != null)
			{
				Object.DestroyImmediate((Object)(object)component3);
			}
			TextMeshProUGUI componentInChildren2 = val9.GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)componentInChildren2 != (Object)null)
			{
				((TMP_Text)componentInChildren2).text = "TOGGLE OVERLAY";
			}
			Button component4 = val9.GetComponent<Button>();
			if (!((Object)(object)component4 != (Object)null))
			{
				return;
			}
			((UnityEventBase)component4.onClick).RemoveAllListeners();
			ButtonClickedEvent onClick2 = component4.onClick;
			object obj3 = <>c.<>9__5_1;
			if (obj3 == null)
			{
				UnityAction val10 = delegate
				{
					MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen;
					EventSystem.current.SetSelectedGameObject((GameObject)null);
				};
				<>c.<>9__5_1 = val10;
				obj3 = (object)val10;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj3);
		}

		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;
		}
	}
	public 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: 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_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: 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_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: 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_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: 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_0020: 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)
			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_001a: 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_0040: 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_004b: 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 selected2 = selectedNodes.Contains(node.Name);
				ImGui obj = gui;
				ReadOnlySpan<char> readOnlySpan = node.Name.AsSpan();
				ImTreeNodeFlags val2 = val;
				bool flag = ImTree.BeginTreeNode(obj, ref selected2, readOnlySpan, default(ImSize), val2);
				SetSelected(node.Name, selected2);
				if (flag)
				{
					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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_002a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: 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_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_02a6: 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_01dc: 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_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: 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_0412: 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_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			if (ImTree.BeginTreeNode(gui, "Simple".AsSpan(), default(ImSize), (ImTreeNodeFlags)0))
			{
				_ = ref 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());
				_ = ref 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))
			{
				_ = ref 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_002c: 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)
			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_002c: 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)
			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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_0030: 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_00c9: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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);
			int length = prefix.Length;
			value.TryFormat(destination.Slice(length, destination.Length - 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 = null;

		private GraphicRaycaster mainGraphicRaycaster = null;

		private bool isOpen = false;

		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>();
						GraphicRaycaster[] array2 = array;
						foreach (GraphicRaycaster val in array2)
						{
							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 = null;

		public ImuiPanel ImuiPanel = null;

		public ThemeController ThemeController = null;

		public OverlayState OverlayState = null;

		private bool isDemoOpen = false;

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

		public override void OnEnable()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0024: 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 = false;

		public static ImTheme SetBaseTheme(ImTheme theme)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			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_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)
			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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0035: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0584: 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()))
			{
				flag |= ImNumericEdit.NumericEdit(gui, ref theme.ReadOnlyColorMultiplier, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 8f, (ImNumericEditFlag)2);
			}
			return flag;
		}

		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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01fb: 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.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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_00a1: 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_001e: 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_002a: 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)
			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();
			foreach (Assembly asm in assemblies)
			{
				CacheTypes(asm);
			}
		}

		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);
				RootPanel rootPanel = ((Component)val.Backend).gameObject.AddComponent<RootPanel>();
				rootPanel.ImuiPanel = val;
				((Component)val.Backend).gameObject.SetActive(true);
			}
		}
	}
}
namespace WKLib.Core.Config
{
	public 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_0090: 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));
				Type type = ((object)val).GetType();
				if (type.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 section2 = item.Definition.Section;
							if (!dictionary.TryGetValue(section2, out var value))
							{
								value = (dictionary[section2] = new List<ConfigEntryBase>());
							}
							value.Add(item);
						}
					}
					pluginContainer.ConfigSection = dictionary.Select((KeyValuePair<string, List<ConfigEntryBase>> section) => new PluginContainer.ConfigEntrySection
					{
						Section = section.Key,
						ConfigEntries = section.Value.ToArray()
					}).ToArray();
					if (pluginContainer.ConfigSection.Length == 0)
					{
						continue;
					}
				}
				list.Add(pluginContainer);
			}
			return list;
		}
	}
	public class PluginContainer
	{
		public class ConfigEntrySection
		{
			public string Section = "";

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

		public string PluginName = "";

		public PluginInfo PluginInfo = null;

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

		public bool IsWindowOpen = false;

		public WKLibAPI APIReference = null;
	}
}
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_0016: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			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;
			if (1 == 0)
			{
			}
			AudioMixerGroup outputAudioMixerGroup = (AudioMixerGroup)(mixerType switch
			{
				AudioMixerType.Music => AudioManager.instance.soundtrackMixer, 
				AudioMixerType.Sfx => AudioManager.instance.gameMixer, 
				AudioMixerType.UI => AudioManager.instance.UIMixer, 
				_ => val.outputAudioMixerGroup, 
			});
			if (1 == 0)
			{
			}
			val2.outputAudioMixerGroup = outputAudioMixerGroup;
			((Component)val).gameObject.SetActive(true);
			_playingSources.Add(val);
			val.Play();
			return val;
		}

		private void CreateAudioSource()
		{
			//IL_0006: 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; } = null;


		public AssetService AssetService { get; internal set; } = null;


		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
{
	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_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: 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_0043: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)(KeyCode)(ref keyCode)).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 gui, ref KeyCode keyCode)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Invalid comparison between Unknown and I4
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Invalid comparison between Unknown and I4
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Invalid comparison between Unknown and I4
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: 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)
				{
					keyCode = (KeyCode)0;
					return true;
				}
				keyCode = (KeyCode)(int)firstActiveKey.Value;
				return true;
			}
		}

		public static void DrawConfigEntry(ImGui gui, ConfigEntryBase configEntry)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: 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_03a1: 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_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_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0791: Unknown result type (might be due to invalid IL or missing references)
			//IL_0797: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0715: Unknown result type (might be due to invalid IL or missing references)
			//IL_0853: Unknown result type (might be due to invalid IL or missing references)
			//IL_0858: Unknown result type (might be due to invalid IL or missing references)
			//IL_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_0808: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08de: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0873: Unknown result type (might be due to invalid IL or missing references)
			//IL_0879: Unknown result type (might be due to invalid IL or missing references)
			//IL_0816: Unknown result type (might be due to invalid IL or missing references)
			//IL_090a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0910: Unknown result type (might be due to invalid IL or missing references)
			//IL_0887: Unknown result type (might be due to invalid IL or missing references)
			//IL_0993: Unknown result type (might be due to invalid IL or missing references)
			//IL_0998: Unknown result type (might be due to invalid IL or missing references)
			//IL_099f: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_091e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0925: Unknown result type (might be due to invalid IL or missing references)
			//IL_092c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0933: Unknown result type (might be due to invalid IL or missing references)
			//IL_093a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a16: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a28: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a88: 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)))
				{
					configEntry.BoxedValue = flag;
				}
			}
			else if (settingType == typeof(byte))
			{
				byte b = (byte)boxedValue;
				using (new LabeledScope(gui, key.AsSpan()))
				{
					if (ImNumericEdit.NumericEdit(gui, ref b, default(ImSize), default(ReadOnlySpan<char>), (byte)1, (byte)0, byte.MaxValue, (ImNumericEditFlag)2))
					{
						configEntry.BoxedValue = b;
					}
				}
			}
			else if (settingType == typeof(sbyte))
			{
				int num = (sbyte)boxedValue;
				using (new LabeledScope(gui, key.AsSpan()))
				{
					if (ImNumericEdit.NumericEdit(gui, ref num, default(ImSize), default(ReadOnlySpan<char>), 1, -128, 127, (ImNumericEditFlag)2))
					{
						configEntry.BoxedValue = (sbyte)num;
					}
				}
			}
			else if (settingType == typeof(short))
			{
				short num2 = (short)boxedValue;
				using (new LabeledScope(gui, key.AsSpan()))
				{
					if (ImNumericEdit.NumericEdit(gui, ref num2, default(ImSize), default(ReadOnlySpan<char>), (short)1, short.MinValue, short.MaxValue, (ImNumericEditFlag)2))
					{
						configEntry.BoxedValue = num2;
					}
				}
			}
			else if (settingType == typeof(ushort))
			{
				int num3 = (ushort)boxedValue;
				using (new LabeledScope(gui, key.AsSpan()))
				{
					if (ImNumericEdit.NumericEdit(gui, ref num3, default(ImSize), default(ReadOnlySpan<char>), 1, 0, 65535, (ImNumericEditFlag)2))
					{
						configEntry.BoxedValue = (ushort)num3;
					}
				}
			}
			else if (settingType == typeof(int))
			{
				int num4 = (int)boxedValue;
				using (new LabeledScope(gui, key.AsSpan()))
				{
					if (ImNumericEdit.NumericEdit(gui, ref num4, default(ImSize), default(ReadOnlySpan<char>), 1, int.MinValue, int.MaxValue, (ImNumericEditFlag)2))
					{
						configEntry.BoxedValue = num4;
					}
				}
			}
			else if (settingType == typeof(uint))
			{
				long num5 = (uint)boxedValue;
				using (new LabeledScope(gui, key.AsSpan()))
				{
					if (ImNumericEdit.NumericEdit(gui, ref num5, default(ImSize), default(ReadOnlySpan<char>), 1L, 0L, 4294967295L, (ImNumericEditFlag)2))
					{
						configEntry.BoxedValue = (uint)num5;
					}
				}
			}
			else if (settingType == typeof(long))
			{
				long num6 = (long)boxedValue;
				using (new LabeledScope(gui, key.AsSpan()))
				{
					if (ImNumericEdit.NumericEdit(gui, ref num6, default(ImSize), default(ReadOnlySpan<char>), 1L, long.MinValue, long.MaxValue, (ImNumericEditFlag)2))
					{
						configEntry.BoxedValue = num6;
					}
				}
			}
			else if (settingType == typeof(ulong))
			{
				long num7 = (long)boxedValue;
				using (new LabeledScope(gui, key.AsSpan()))
				{
					if (ImNumericEdit.NumericEdit(gui, ref num7, default(ImSize), default(ReadOnlySpan<char>), 1L, 0L, l