Decompiled source of AllfathersEye v0.30.7

plugins/AllfathersEye.dll

Decompiled a month ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Net.Security;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using Allfathers.Shared.Panel;
using Allfathers.Shared.Ui;
using AllfathersEye.Feed;
using AllfathersEye.Naming;
using AllfathersEye.Overlay;
using AllfathersEye.Patches;
using AllfathersEye.Points;
using AllfathersEye.Records;
using AllfathersEye.Shop;
using AllfathersEye.Twitch;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("AllfathersEye")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Twitch chatters take over creatures in Valheim, with an on-screen event feed.")]
[assembly: AssemblyFileVersion("0.30.7.0")]
[assembly: AssemblyInformationalVersion("0.30.7+82c81a0092f8ce085fd71cd380b2c3e827603530")]
[assembly: AssemblyProduct("Allfather's Eye")]
[assembly: AssemblyTitle("AllfathersEye")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.30.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public sealed class ConfigurationManagerAttributes
{
	public int? Order;

	public bool? IsAdvanced;

	public Action<ConfigEntryBase> CustomDrawer;

	public bool? HideDefaultButton;

	public bool? HideSettingName;
}
namespace Allfathers.Shared.Ui
{
	public static class PanelBackdrop
	{
		public static Func<bool> UseGameBackground = () => true;

		public static Func<float> Saturation = () => 0.25f;

		public static Func<float> Darkness = () => 0.63f;

		public static Func<string> WantedSprite = () => "";

		public static string AlternativesHint = "";

		public static string SpriteListHint = "";

		public static Action<string> LogInfo = PanelLog.Info;

		public static Action<string> LogWarning = PanelLog.Warning;

		private static Texture2D _plain;

		private static Texture _backdrop;

		private static Sprite _sprite;

		private static Texture2D _owned;

		private static float _saturatedFor = -1f;

		private static Rect _backdropCoords;

		private static bool _backdropSearched;

		private static Vector4 _backdropBorder;

		private static Rect _backdropRect;

		private static Color _backdropTint = Color.white;

		private static Texture2D Plain
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Expected O, but got Unknown
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_plain != (Object)null)
				{
					return _plain;
				}
				_plain = new Texture2D(1, 1, (TextureFormat)4, false);
				_plain.SetPixel(0, 0, new Color(0.04f, 0.04f, 0.05f, 0.92f));
				_plain.Apply();
				((Object)_plain).hideFlags = (HideFlags)61;
				return _plain;
			}
		}

		public static void Prepare()
		{
			if (UseGameBackground())
			{
				FindBackdrop();
				if (!((Object)(object)_sprite == (Object)null) && !Mathf.Approximately(_saturatedFor, Mathf.Clamp01(Saturation())))
				{
					ApplySaturation();
				}
			}
		}

		public static void Draw(Rect panel)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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)
			if (!UseGameBackground())
			{
				GUI.DrawTexture(panel, (Texture)(object)Plain, (ScaleMode)0);
				return;
			}
			if ((Object)(object)_backdrop == (Object)null)
			{
				GUI.DrawTexture(panel, (Texture)(object)Plain, (ScaleMode)0);
				return;
			}
			Color color = GUI.color;
			GUI.color = _backdropTint;
			DrawSliced(panel);
			float num = Mathf.Clamp01(Darkness());
			if (num > 0f)
			{
				GUI.color = new Color(0f, 0f, 0f, num);
				DrawSliced(panel);
			}
			GUI.color = color;
		}

		private static string Suffix(string hint)
		{
			if (!string.IsNullOrEmpty(hint))
			{
				return " " + hint;
			}
			return "";
		}

		public static Rect Snap(Rect rect)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Round(((Rect)(ref rect)).x);
			float num2 = Mathf.Round(((Rect)(ref rect)).y);
			return new Rect(num, num2, Mathf.Round(((Rect)(ref rect)).xMax) - num, Mathf.Round(((Rect)(ref rect)).yMax) - num2);
		}

		private static void DrawSliced(Rect panel)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00c9: 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_0172: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			Vector4 backdropBorder = _backdropBorder;
			float num = Mathf.Clamp((float)Screen.height / 1080f, 1f, 2.5f);
			panel = Snap(panel);
			float num2 = Mathf.Round(backdropBorder.x * num);
			float num3 = Mathf.Round(backdropBorder.y * num);
			float num4 = Mathf.Round(backdropBorder.z * num);
			float num5 = Mathf.Round(backdropBorder.w * num);
			if (num2 + num4 <= 0f || num5 + num3 <= 0f || num2 + num4 >= ((Rect)(ref panel)).width || num5 + num3 >= ((Rect)(ref panel)).height)
			{
				GUI.DrawTextureWithTexCoords(Snap(panel), _backdrop, _backdropCoords);
				return;
			}
			Rect backdropRect = _backdropRect;
			float x = backdropBorder.x;
			float y = backdropBorder.y;
			float z = backdropBorder.z;
			float w = backdropBorder.w;
			float num6 = ((Rect)(ref panel)).width - num2 - num4;
			float num7 = ((Rect)(ref panel)).height - num5 - num3;
			float num8 = ((Rect)(ref backdropRect)).width - x - z;
			float num9 = ((Rect)(ref backdropRect)).height - w - y;
			float x2 = ((Rect)(ref panel)).x;
			float num10 = ((Rect)(ref panel)).x + num2;
			float num11 = ((Rect)(ref panel)).xMax - num4;
			float y2 = ((Rect)(ref panel)).y;
			float num12 = ((Rect)(ref panel)).y + num5;
			float num13 = ((Rect)(ref panel)).yMax - num3;
			Patch(new Rect(x2, y2, num2, num5), 0f, num9 + y, x, w);
			Patch(new Rect(num10, y2, num6, num5), x, num9 + y, num8, w);
			Patch(new Rect(num11, y2, num4, num5), x + num8, num9 + y, z, w);
			Patch(new Rect(x2, num12, num2, num7), 0f, y, x, num9);
			Patch(new Rect(num10, num12, num6, num7), x, y, num8, num9);
			Patch(new Rect(num11, num12, num4, num7), x + num8, y, z, num9);
			Patch(new Rect(x2, num13, num2, num3), 0f, 0f, x, y);
			Patch(new Rect(num10, num13, num6, num3), x, 0f, num8, y);
			Patch(new Rect(num11, num13, num4, num3), x + num8, 0f, z, y);
		}

		private static void Patch(Rect dest, float sx, float sy, float sw, float sh)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Rect)(ref dest)).width <= 0f) && !(((Rect)(ref dest)).height <= 0f) && !(sw <= 0f) && !(sh <= 0f))
			{
				float num = _backdrop.width;
				float num2 = _backdrop.height;
				float num3 = Mathf.Min(0.5f, sw * 0.25f);
				float num4 = Mathf.Min(0.5f, sh * 0.25f);
				GUI.DrawTextureWithTexCoords(Snap(dest), _backdrop, new Rect((((Rect)(ref _backdropRect)).x + sx + num3) / num, (((Rect)(ref _backdropRect)).y + sy + num4) / num2, (sw - num3 * 2f) / num, (sh - num4 * 2f) / num2));
			}
		}

		private static void FindBackdrop()
		{
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			if (_backdropSearched)
			{
				return;
			}
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			_backdropSearched = true;
			try
			{
				List<Image> list = Candidates();
				Image val = null;
				int num = int.MinValue;
				string text = (WantedSprite() ?? "").Trim();
				for (int i = 0; i < list.Count; i++)
				{
					Sprite sprite = list[i].sprite;
					if (text.Length > 0)
					{
						if (string.Equals(((Object)sprite).name, text, StringComparison.OrdinalIgnoreCase))
						{
							val = list[i];
							break;
						}
						continue;
					}
					int num2 = Score(sprite);
					if (num2 > num)
					{
						num = num2;
						val = list[i];
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					LogWarning((text.Length > 0) ? ("No game sprite named '" + text + "'." + Suffix(SpriteListHint)) : "Found no usable panel sprite; using a plain one.");
					return;
				}
				Sprite sprite2 = val.sprite;
				Rect textureRect = sprite2.textureRect;
				_sprite = sprite2;
				_backdropTint = ((Graphic)val).color;
				_backdropBorder = sprite2.border;
				ApplySaturation();
				LogInfo("Panel backdrop: using the game's '" + ((Object)sprite2).name + "' (" + (int)((Rect)(ref textureRect)).width + "x" + (int)((Rect)(ref textureRect)).height + ") from " + PathOf(((Component)val).transform) + ", tinted " + ((object)((Graphic)val).color/*cast due to .constrained prefix*/).ToString() + ", border " + ((object)sprite2.border/*cast due to .constrained prefix*/).ToString() + ", drawn in " + ((object)QualitySettings.activeColorSpace/*cast due to .constrained prefix*/).ToString() + " colour." + Suffix(AlternativesHint));
			}
			catch (Exception ex)
			{
				LogWarning("Could not borrow the game's panel image (" + ex.Message + "); using a plain one.");
			}
		}

		private static void ApplySaturation()
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			float num = (_saturatedFor = Mathf.Clamp01(Saturation()));
			if ((Object)(object)_owned != (Object)null)
			{
				Object.Destroy((Object)(object)_owned);
				_owned = null;
			}
			if ((Object)(object)_sprite == (Object)null)
			{
				return;
			}
			if (num < 0.999f)
			{
				_owned = Grab(_sprite);
				if ((Object)(object)_owned != (Object)null)
				{
					Desaturate(_owned, num);
				}
			}
			if ((Object)(object)_owned != (Object)null)
			{
				_backdrop = (Texture)(object)_owned;
				_backdropRect = new Rect(0f, 0f, (float)((Texture)_owned).width, (float)((Texture)_owned).height);
			}
			else
			{
				_backdrop = (Texture)(object)_sprite.texture;
				_backdropRect = _sprite.textureRect;
			}
			_backdropCoords = new Rect(((Rect)(ref _backdropRect)).x / (float)_backdrop.width, ((Rect)(ref _backdropRect)).y / (float)_backdrop.height, ((Rect)(ref _backdropRect)).width / (float)_backdrop.width, ((Rect)(ref _backdropRect)).height / (float)_backdrop.height);
		}

		private static void Desaturate(Texture2D texture, float keep)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			Color32[] pixels = texture.GetPixels32();
			for (int i = 0; i < pixels.Length; i++)
			{
				Color32 val = pixels[i];
				int grey = val.r * 77 + val.g * 150 + val.b * 29 >> 8;
				pixels[i] = new Color32(Mix(grey, val.r, keep), Mix(grey, val.g, keep), Mix(grey, val.b, keep), val.a);
			}
			texture.SetPixels32(pixels);
			texture.Apply();
		}

		private static byte Mix(int grey, byte channel, float keep)
		{
			return (byte)Mathf.Clamp(Mathf.RoundToInt((float)grey + (float)(channel - grey) * keep), 0, 255);
		}

		private static Texture2D Grab(Sprite sprite)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture val = null;
			RenderTexture active = RenderTexture.active;
			try
			{
				Texture texture = (Texture)(object)sprite.texture;
				Rect textureRect = sprite.textureRect;
				int num = Mathf.Clamp(Mathf.FloorToInt(((Rect)(ref textureRect)).x), 0, texture.width - 1);
				int num2 = Mathf.Clamp(Mathf.FloorToInt(((Rect)(ref textureRect)).y), 0, texture.height - 1);
				int num3 = Mathf.Clamp(Mathf.FloorToInt(((Rect)(ref textureRect)).width), 1, texture.width - num);
				int num4 = Mathf.Clamp(Mathf.FloorToInt(((Rect)(ref textureRect)).height), 1, texture.height - num2);
				val = RenderTexture.GetTemporary(texture.width, texture.height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
				Graphics.Blit(texture, val);
				RenderTexture.active = val;
				Texture2D val2 = new Texture2D(num3, num4, (TextureFormat)4, false, false);
				val2.ReadPixels(new Rect((float)num, (float)num2, (float)num3, (float)num4), 0, 0);
				val2.Apply();
				((Texture)val2).wrapMode = (TextureWrapMode)1;
				((Texture)val2).filterMode = (FilterMode)1;
				((Object)val2).hideFlags = (HideFlags)61;
				return val2;
			}
			catch (Exception ex)
			{
				LogWarning("Could not copy the panel sprite (" + ex.Message + "); using it as it is.");
				return null;
			}
			finally
			{
				RenderTexture.active = active;
				if ((Object)(object)val != (Object)null)
				{
					RenderTexture.ReleaseTemporary(val);
				}
			}
		}

		private static int Score(Sprite sprite)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			string text = ((((Object)sprite).name != null) ? ((Object)sprite).name.ToLowerInvariant() : "");
			int num = 0;
			if (text.IndexOf("woodpanel", StringComparison.Ordinal) >= 0)
			{
				num += 100000;
			}
			else if (text.IndexOf("panel", StringComparison.Ordinal) >= 0)
			{
				num += 50000;
			}
			if (text.IndexOf("mask", StringComparison.Ordinal) >= 0)
			{
				num -= 500000;
			}
			if (text.IndexOf("crafting", StringComparison.Ordinal) >= 0)
			{
				num += 8000;
			}
			Vector4 border = sprite.border;
			if (border.x + border.y + border.z + border.w > 0f)
			{
				num += 20000;
			}
			if (text.IndexOf("separator", StringComparison.Ordinal) >= 0)
			{
				num -= 80000;
			}
			if (text.IndexOf("button", StringComparison.Ordinal) >= 0)
			{
				num -= 80000;
			}
			if (text.IndexOf("checkbox", StringComparison.Ordinal) >= 0)
			{
				num -= 80000;
			}
			Rect textureRect = sprite.textureRect;
			float width = ((Rect)(ref textureRect)).width;
			textureRect = sprite.textureRect;
			float height = ((Rect)(ref textureRect)).height;
			if (width < 24f || height < 24f)
			{
				num -= 60000;
			}
			return num + (int)Mathf.Min(width * height / 20f, 30000f);
		}

		private static void Collect(Transform root, List<Image> into)
		{
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			Image[] componentsInChildren = ((Component)root).GetComponentsInChildren<Image>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (!((Object)(object)componentsInChildren[i] == (Object)null) && !((Object)(object)componentsInChildren[i].sprite == (Object)null) && !((Object)(object)componentsInChildren[i].sprite.texture == (Object)null) && !into.Contains(componentsInChildren[i]))
				{
					into.Add(componentsInChildren[i]);
				}
			}
		}

		private static List<Image> Candidates()
		{
			List<Image> list = new List<Image>();
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return list;
			}
			Collect(((Component)instance).transform, list);
			Collect((Transform)(object)instance.m_crafting, list);
			Collect((Transform)(object)instance.m_player, list);
			Collect((Transform)(object)instance.m_container, list);
			Collect((Transform)(object)instance.m_info, list);
			return list;
		}

		private static string PathOf(Transform node)
		{
			if ((Object)(object)node == (Object)null)
			{
				return "?";
			}
			string text = ((Object)node).name;
			Transform parent = node.parent;
			int num = 0;
			while ((Object)(object)parent != (Object)null && num < 6)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
				num++;
			}
			return text;
		}

		public static string ListSprites(int limit)
		{
			List<Image> list = Candidates();
			if (list.Count == 0)
			{
				return "The inventory does not exist yet - load into a world first.";
			}
			List<string> list2 = new List<string>();
			List<int> list3 = new List<int>();
			for (int i = 0; i < list.Count; i++)
			{
				string name = ((Object)list[i].sprite).name;
				if (!list2.Contains(name))
				{
					list2.Add(name);
					list3.Add(Score(list[i].sprite));
				}
			}
			if (list2.Count == 0)
			{
				return "No sprites found.";
			}
			StringBuilder stringBuilder = new StringBuilder();
			for (int j = 0; j < limit; j++)
			{
				if (list2.Count <= 0)
				{
					break;
				}
				int index = 0;
				for (int k = 1; k < list3.Count; k++)
				{
					if (list3[k] > list3[index])
					{
						index = k;
					}
				}
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Append(", ");
				}
				stringBuilder.Append(list2[index]);
				list2.RemoveAt(index);
				list3.RemoveAt(index);
			}
			return stringBuilder.ToString();
		}

		public static string DumpPanel(int limit)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			List<Image> list = Candidates();
			if (list.Count == 0)
			{
				return "The inventory does not exist yet - load into a world first.";
			}
			List<Image> list2 = new List<Image>(list);
			list2.Sort((Image a, Image b) => Score(b.sprite).CompareTo(Score(a.sprite)));
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(list.Count).Append(" image(s) under the inventory, drawn in ").Append(QualitySettings.activeColorSpace)
				.Append(" colour. Best guess first:");
			List<string> list3 = new List<string>();
			int num = 0;
			for (int num2 = 0; num2 < list2.Count; num2++)
			{
				if (num >= limit)
				{
					break;
				}
				Sprite sprite = list2[num2].sprite;
				if (!list3.Contains(((Object)sprite).name))
				{
					list3.Add(((Object)sprite).name);
					num++;
					Rect textureRect = sprite.textureRect;
					stringBuilder.Append("\n").Append(num).Append(". ")
						.Append(((Object)sprite).name)
						.Append("  ")
						.Append((int)((Rect)(ref textureRect)).width)
						.Append("x")
						.Append((int)((Rect)(ref textureRect)).height)
						.Append("  border ")
						.Append(sprite.border)
						.Append("  tint ")
						.Append(Hex(((Graphic)list2[num2]).color))
						.Append("  pixels ")
						.Append(Hex(Average(sprite)))
						.Append("  at ")
						.Append(PathOf(((Component)list2[num2]).transform));
				}
			}
			return stringBuilder.ToString();
		}

		private static string Hex(Color colour)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return "#" + ColorUtility.ToHtmlStringRGBA(colour);
		}

		private static Color Average(Sprite sprite)
		{
			//IL_0024: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = Grab(sprite);
			if ((Object)(object)val == (Object)null)
			{
				return new Color(0f, 0f, 0f, 0f);
			}
			try
			{
				Color32[] pixels = val.GetPixels32();
				double num = 0.0;
				double num2 = 0.0;
				double num3 = 0.0;
				double num4 = 0.0;
				for (int i = 0; i < pixels.Length; i++)
				{
					double num5 = (double)(int)pixels[i].a / 255.0;
					if (!(num5 <= 0.02))
					{
						num += (double)(int)pixels[i].r * num5;
						num2 += (double)(int)pixels[i].g * num5;
						num3 += (double)(int)pixels[i].b * num5;
						num4 += num5;
					}
				}
				if (num4 <= 0.0)
				{
					return new Color(0f, 0f, 0f, 0f);
				}
				return new Color((float)(num / num4 / 255.0), (float)(num2 / num4 / 255.0), (float)(num3 / num4 / 255.0), 1f);
			}
			finally
			{
				Object.Destroy((Object)(object)val);
			}
		}
	}
	public static class PanelFont
	{
		private const float RetrySeconds = 2f;

		private static Font _body;

		private static Font _title;

		private static bool _found;

		private static float _nextLook;

		public static Font Body
		{
			get
			{
				Look();
				return _body;
			}
		}

		public static Font Title
		{
			get
			{
				Look();
				return _title ?? _body;
			}
		}

		public static void Forget()
		{
			_body = null;
			_title = null;
			_found = false;
			_nextLook = 0f;
		}

		public static Font[] Available()
		{
			Font[] array = Resources.FindObjectsOfTypeAll<Font>();
			List<Font> list = new List<Font>(array.Length);
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i] != (Object)null && !string.IsNullOrEmpty(((Object)array[i]).name))
				{
					list.Add(array[i]);
				}
			}
			return list.ToArray();
		}

		private static void Look()
		{
			if (_found || Time.unscaledTime < _nextLook)
			{
				return;
			}
			_nextLook = Time.unscaledTime + 2f;
			try
			{
				Font[] fonts = Available();
				_body = Find(fonts, "Averia", "Bold") ?? Find(fonts, "Averia", "") ?? Find(fonts, "Valheim", "");
				_title = Find(fonts, "Norse", "Bold") ?? Find(fonts, "Norse", "");
				_found = (Object)(object)_body != (Object)null;
			}
			catch (Exception ex)
			{
				PanelLog.Warning("Could not look for the game's fonts: " + ex.Message);
			}
		}

		private static Font Find(Font[] fonts, string family, string cut)
		{
			for (int i = 0; i < fonts.Length; i++)
			{
				string text = ((Object)fonts[i]).name ?? "";
				if (text.IndexOf(family, StringComparison.OrdinalIgnoreCase) >= 0 && text.IndexOf("Italic", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("Oblique", StringComparison.OrdinalIgnoreCase) < 0 && (cut.Length <= 0 || text.IndexOf(cut, StringComparison.OrdinalIgnoreCase) >= 0))
				{
					return fonts[i];
				}
			}
			return null;
		}
	}
	public static class PanelText
	{
		public static readonly Color WindowName = new Color(1f, 0.718f, 0.357f);

		public static readonly Color Heading = new Color(1f, 0.808f, 0f);

		public static readonly Color Reading = new Color(1f, 1f, 1f);

		public static readonly Color Quiet = new Color(0.78f, 0.76f, 0.72f);

		public static Color Ui(Color colour)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if ((int)QualitySettings.activeColorSpace != 1)
			{
				return colour;
			}
			return ((Color)(ref colour)).gamma;
		}

		public static void Label(Rect where, string text, GUIStyle style)
		{
			//IL_002a: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(text) && style != null)
			{
				float num = Mathf.Max(1f, (float)style.fontSize / 16f);
				Color textColor = style.normal.textColor;
				style.normal.textColor = Ui(new Color(0f, 0f, 0f, textColor.a * 0.9f));
				GUI.Label(new Rect(((Rect)(ref where)).x - num, ((Rect)(ref where)).y, ((Rect)(ref where)).width, ((Rect)(ref where)).height), text, style);
				GUI.Label(new Rect(((Rect)(ref where)).x + num, ((Rect)(ref where)).y, ((Rect)(ref where)).width, ((Rect)(ref where)).height), text, style);
				GUI.Label(new Rect(((Rect)(ref where)).x, ((Rect)(ref where)).y - num, ((Rect)(ref where)).width, ((Rect)(ref where)).height), text, style);
				GUI.Label(new Rect(((Rect)(ref where)).x, ((Rect)(ref where)).y + num, ((Rect)(ref where)).width, ((Rect)(ref where)).height), text, style);
				style.normal.textColor = textColor;
				GUI.Label(where, text, style);
			}
		}

		public static GUIStyle Styled(Font font, int size, Color colour)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = size,
				richText = false,
				wordWrap = false,
				alignment = (TextAnchor)0
			};
			val.normal.textColor = colour;
			val.normal.background = null;
			if ((Object)(object)font != (Object)null)
			{
				val.font = font;
			}
			return val;
		}

		public static Texture2D Solid(Color colour)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false);
			val.SetPixel(0, 0, colour);
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}
	}
}
namespace Allfathers.Shared.Panel
{
	internal sealed class PanelControls
	{
		private const float SwitchWidth = 74f;

		private const float NumberWidth = 96f;

		private const float SliderWidth = 220f;

		private const float TextWidth = 380f;

		private const float ChoiceLabelWidth = 190f;

		private const float DefaultWidth = 100f;

		private readonly PanelSkin _look;

		private PanelEntry _editing;

		private string _buffer = "";

		private PanelEntry _capturing;

		private bool _cancelRequested;

		private bool _dropFocus;

		private readonly HashSet<string> _failedDrawers = new HashSet<string>();

		public bool Busy
		{
			get
			{
				if (_editing == null)
				{
					return _capturing != null;
				}
				return true;
			}
		}

		public PanelControls(PanelSkin look)
		{
			_look = look;
		}

		public void RequestCancel()
		{
			_cancelRequested = true;
		}

		public void DropFocus()
		{
			_dropFocus = true;
		}

		public void Begin()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_005c: 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_0081: Invalid comparison between Unknown and I4
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between Unknown and I4
			Event current = Event.current;
			if (_cancelRequested)
			{
				_cancelRequested = false;
				_editing = null;
				_buffer = "";
				_capturing = null;
				GUI.FocusControl((string)null);
			}
			if (_dropFocus)
			{
				_dropFocus = false;
				GUI.FocusControl((string)null);
			}
			if ((int)current.type == 4)
			{
				if (_capturing != null && (int)current.keyCode != 0)
				{
					Capture(current);
					current.Use();
				}
				else if (_editing != null && ((int)current.keyCode == 13 || (int)current.keyCode == 271))
				{
					Commit();
					GUI.FocusControl((string)null);
					current.Use();
				}
			}
		}

		public void End()
		{
			if (_editing != null && GUI.GetNameOfFocusedControl() != _editing.Control)
			{
				Commit();
			}
		}

		public void Commit()
		{
			PanelEntry editing = _editing;
			string buffer = _buffer;
			_editing = null;
			_buffer = "";
			if (editing != null && !editing.ReadOnly && !string.Equals(buffer, Format(editing), StringComparison.Ordinal))
			{
				if (!TryParse(editing, buffer, out var value))
				{
					PanelLog.Info("'" + buffer + "' is not a value " + editing.Section + " / " + editing.Key + " can take; it keeps " + Format(editing) + ".");
				}
				else
				{
					Set(editing, value);
				}
			}
		}

		public void Row(PanelEntry entry, float keyWidth)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (!entry.HideName)
			{
				GUILayout.Label(new GUIContent(entry.Key, entry.Description), _look.Key, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(keyWidth) });
			}
			if (entry.Drawer != null)
			{
				Drawn(entry);
			}
			else
			{
				Editor(entry, compact: false, 0f);
			}
			GUILayout.FlexibleSpace();
			if (!entry.HideDefaultButton && !entry.ReadOnly && !IsDefault(entry) && GUILayout.Button(new GUIContent(PanelTexts.Default, PanelTexts.DefaultTip), _look.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
			{
				if (_editing == entry)
				{
					_editing = null;
					GUI.FocusControl((string)null);
				}
				Set(entry, entry.Entry.DefaultValue);
			}
			GUILayout.EndHorizontal();
		}

		public void Cell(PanelEntry entry, float width)
		{
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) });
			if (entry == null)
			{
				GUILayout.Label("", Array.Empty<GUILayoutOption>());
			}
			else if (entry.Drawer != null)
			{
				Drawn(entry);
			}
			else
			{
				Editor(entry, compact: true, width - 8f);
			}
			GUILayout.EndHorizontal();
		}

		private void Editor(PanelEntry entry, bool compact, float width)
		{
			Type settingType = entry.Entry.SettingType;
			if (entry.ReadOnly)
			{
				GUILayout.Label(Format(entry), _look.Value, Array.Empty<GUILayoutOption>());
			}
			else if (settingType == typeof(bool))
			{
				Switch(entry, compact ? width : 74f);
			}
			else if (entry.Choices != null && entry.Choices.Length > 0)
			{
				Choices(entry, compact, width);
			}
			else if (settingType == typeof(KeyboardShortcut))
			{
				Shortcut(entry);
			}
			else if (IsNumber(settingType))
			{
				if (!compact && entry.HasRange)
				{
					Slider(entry);
				}
				Field(entry, compact ? width : 96f);
			}
			else if (settingType == typeof(string) || TomlTypeConverter.CanConvert(settingType))
			{
				Field(entry, compact ? width : 380f);
			}
			else
			{
				GUILayout.Label(Format(entry), _look.Value, Array.Empty<GUILayoutOption>());
			}
		}

		private void Switch(PanelEntry entry, float width)
		{
			bool flag = entry.Entry.BoxedValue is bool && (bool)entry.Entry.BoxedValue;
			if (GUILayout.Button(flag ? PanelTexts.On : PanelTexts.Off, flag ? _look.SwitchOn : _look.SwitchOff, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }))
			{
				Set(entry, !flag);
			}
		}

		private void Choices(PanelEntry entry, bool compact, float width)
		{
			Array choices = entry.Choices;
			object boxedValue = entry.Entry.BoxedValue;
			if (!compact && choices.Length <= 4)
			{
				for (int i = 0; i < choices.Length; i++)
				{
					object value = choices.GetValue(i);
					bool flag = object.Equals(value, boxedValue);
					if (GUILayout.Button(Name(value), flag ? _look.ChoiceSelected : _look.Choice, Array.Empty<GUILayoutOption>()) && !flag)
					{
						Set(entry, value);
					}
				}
				return;
			}
			int num = Math.Max(0, Array.IndexOf(choices, boxedValue));
			if (GUILayout.Button("<", _look.Choice, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
			{
				Set(entry, choices.GetValue((num - 1 + choices.Length) % choices.Length));
			}
			GUILayout.Label(Name(boxedValue), _look.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(compact ? Math.Max(20f, width - 68f) : 190f) });
			if (GUILayout.Button(">", _look.Choice, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
			{
				Set(entry, choices.GetValue((num + 1) % choices.Length));
			}
		}

		private void Slider(PanelEntry entry)
		{
			float num = Convert.ToSingle(entry.Entry.BoxedValue, CultureInfo.InvariantCulture);
			float num2 = GUILayout.HorizontalSlider(num, entry.Min, entry.Max, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) });
			if (num2 == num)
			{
				return;
			}
			if (_editing == entry)
			{
				_editing = null;
				GUI.FocusControl((string)null);
			}
			Type settingType = entry.Entry.SettingType;
			if (settingType == typeof(int))
			{
				int num3 = Mathf.RoundToInt(num2);
				if (num3 != Mathf.RoundToInt(num))
				{
					Set(entry, num3);
				}
			}
			else if (settingType == typeof(float))
			{
				float num4 = PanelNumbers.FromSlider(num2, entry.Min, entry.Max);
				if (num4 != num)
				{
					Set(entry, num4);
				}
			}
			else if (settingType == typeof(double))
			{
				float num5 = PanelNumbers.FromSlider(num2, entry.Min, entry.Max);
				if (num5 != num)
				{
					Set(entry, (double)num5);
				}
			}
		}

		private void Shortcut(PanelEntry entry)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			if (_capturing == entry)
			{
				GUILayout.Button(new GUIContent(PanelTexts.PressKey, PanelTexts.PressKeyTip), _look.ChoiceSelected, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) });
			}
			else if (GUILayout.Button(new GUIContent(Format(entry), PanelTexts.PressKeyTip), _look.Choice, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) }))
			{
				Commit();
				GUI.FocusControl((string)null);
				_capturing = entry;
			}
		}

		private void Capture(Event key)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_001a: 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_0036: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_0093: 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)
			PanelEntry capturing = _capturing;
			if ((int)key.keyCode == 27)
			{
				_capturing = null;
			}
			else
			{
				if (IsModifier(key.keyCode))
				{
					return;
				}
				_capturing = null;
				if ((int)key.keyCode == 127 || (int)key.keyCode == 8)
				{
					Set(capturing, KeyboardShortcut.Empty);
					return;
				}
				List<KeyCode> list = new List<KeyCode>();
				if (key.control)
				{
					list.Add((KeyCode)306);
				}
				if (key.shift)
				{
					list.Add((KeyCode)304);
				}
				if (key.alt)
				{
					list.Add((KeyCode)308);
				}
				Set(capturing, (object)new KeyboardShortcut(key.keyCode, list.ToArray()));
			}
		}

		private void Field(PanelEntry entry, float width)
		{
			bool flag = _editing == entry;
			string text = (flag ? _buffer : Format(entry));
			GUI.SetNextControlName(entry.Control);
			string buffer = GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) });
			if (flag)
			{
				_buffer = buffer;
			}
			else if (GUI.GetNameOfFocusedControl() == entry.Control)
			{
				if (_editing != null)
				{
					Commit();
				}
				_editing = entry;
				_buffer = buffer;
			}
		}

		private void Drawn(PanelEntry entry)
		{
			if (_failedDrawers.Contains(entry.Control))
			{
				GUILayout.Label("—", _look.Value, Array.Empty<GUILayoutOption>());
				return;
			}
			try
			{
				entry.Drawer(entry.Entry);
			}
			catch (Exception ex)
			{
				_failedDrawers.Add(entry.Control);
				PanelLog.Error("The control for " + entry.Section + " / " + entry.Key + " could not be drawn: " + ex);
			}
		}

		public unsafe static string Format(PanelEntry entry)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			object boxedValue = entry.Entry.BoxedValue;
			if (boxedValue == null)
			{
				return "";
			}
			if (boxedValue is float)
			{
				return PanelNumbers.Format((float)boxedValue);
			}
			if (boxedValue is double)
			{
				return PanelNumbers.Format((float)(double)boxedValue);
			}
			if (boxedValue is string)
			{
				return (string)boxedValue;
			}
			if (boxedValue is bool)
			{
				if (!(bool)boxedValue)
				{
					return PanelTexts.Off;
				}
				return PanelTexts.On;
			}
			if (boxedValue is KeyboardShortcut val)
			{
				if ((int)((KeyboardShortcut)(ref val)).MainKey != 0)
				{
					return ((object)(*(KeyboardShortcut*)(&val))/*cast due to .constrained prefix*/).ToString();
				}
				return PanelTexts.NoKey;
			}
			try
			{
				return TomlTypeConverter.ConvertToString(boxedValue, entry.Entry.SettingType);
			}
			catch
			{
				return Convert.ToString(boxedValue, CultureInfo.InvariantCulture) ?? "";
			}
		}

		private static bool TryParse(PanelEntry entry, string text, out object value)
		{
			value = null;
			Type settingType = entry.Entry.SettingType;
			if (settingType == typeof(string))
			{
				value = text ?? "";
				return true;
			}
			if (settingType == typeof(int))
			{
				if (!PanelNumbers.TryParseInt(text, out var value2))
				{
					return false;
				}
				value = value2;
				return true;
			}
			if (settingType == typeof(float) || settingType == typeof(double))
			{
				if (!PanelNumbers.TryParseFloat(text, out var value3))
				{
					return false;
				}
				value = ((settingType == typeof(float)) ? ((object)value3) : ((object)(double)value3));
				return true;
			}
			if (settingType.IsEnum)
			{
				try
				{
					value = Enum.Parse(settingType, (text ?? "").Trim(), ignoreCase: true);
					return true;
				}
				catch
				{
					return false;
				}
			}
			try
			{
				if (!TomlTypeConverter.CanConvert(settingType))
				{
					return false;
				}
				value = TomlTypeConverter.ConvertToValue(text ?? "", settingType);
				return value != null;
			}
			catch
			{
				return false;
			}
		}

		private static void Set(PanelEntry entry, object value)
		{
			try
			{
				entry.Entry.BoxedValue = value;
			}
			catch (Exception ex)
			{
				PanelLog.Warning("Could not change " + entry.Section + " / " + entry.Key + ": " + ex.Message);
			}
		}

		private static bool IsDefault(PanelEntry entry)
		{
			return object.Equals(entry.Entry.BoxedValue, entry.Entry.DefaultValue);
		}

		private static bool IsNumber(Type type)
		{
			if (!(type == typeof(int)) && !(type == typeof(float)))
			{
				return type == typeof(double);
			}
			return true;
		}

		private static bool IsModifier(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			if ((int)key != 306 && (int)key != 305 && (int)key != 304 && (int)key != 303 && (int)key != 308 && (int)key != 307 && (int)key != 313 && (int)key != 310)
			{
				return (int)key == 309;
			}
			return true;
		}

		private static string Name(object value)
		{
			object obj;
			if (value != null)
			{
				obj = Convert.ToString(value, CultureInfo.InvariantCulture);
				if (obj == null)
				{
					return "";
				}
			}
			else
			{
				obj = "";
			}
			return (string)obj;
		}
	}
	public struct PanelCandidate
	{
		public string Guid;

		public int Version;
	}
	public static class PanelElection
	{
		public static string Winner(IList<PanelCandidate> candidates)
		{
			if (candidates == null || candidates.Count == 0)
			{
				return "";
			}
			PanelCandidate panelCandidate = candidates[0];
			for (int i = 1; i < candidates.Count; i++)
			{
				PanelCandidate panelCandidate2 = candidates[i];
				if (panelCandidate2.Version > panelCandidate.Version || (panelCandidate2.Version == panelCandidate.Version && string.CompareOrdinal(panelCandidate2.Guid, panelCandidate.Guid) < 0))
				{
					panelCandidate = panelCandidate2;
				}
			}
			return panelCandidate.Guid ?? "";
		}
	}
	internal sealed class PanelEntry
	{
		public ConfigEntryBase Entry;

		public string Control;

		public string Section;

		public string Key;

		public string Description;

		public int Order;

		public bool Advanced;

		public bool HideDefaultButton;

		public bool HideName;

		public bool ReadOnly;

		public bool Hidden;

		public Action<ConfigEntryBase> Drawer;

		public Array Choices;

		public bool HasRange;

		public float Min;

		public float Max;

		public string Searchable;

		public static PanelEntry From(ConfigDefinition definition, ConfigEntryBase entry, string control)
		{
			PanelEntry panelEntry = new PanelEntry
			{
				Entry = entry,
				Control = control,
				Section = (definition.Section ?? ""),
				Key = (definition.Key ?? ""),
				Description = ((entry.Description != null) ? (entry.Description.Description ?? "") : "")
			};
			object[] array = ((entry.Description != null) ? entry.Description.Tags : null);
			if (array != null)
			{
				foreach (object obj in array)
				{
					if (obj != null && !(obj.GetType().Name != "ConfigurationManagerAttributes"))
					{
						panelEntry.Read(obj);
					}
				}
			}
			panelEntry.ReadLimits();
			string text = entry.BoxedValue as string;
			panelEntry.Searchable = (panelEntry.Section + "\n" + panelEntry.Key + "\n" + panelEntry.Description + ((text != null) ? ("\n" + text) : "")).ToLowerInvariant();
			return panelEntry;
		}

		private void ReadLimits()
		{
			Type settingType = Entry.SettingType;
			if (settingType.IsEnum)
			{
				Choices = Enum.GetValues(settingType);
			}
			AcceptableValueBase val = ((Entry.Description != null) ? Entry.Description.AcceptableValues : null);
			if (val == null)
			{
				return;
			}
			Type type = ((object)val).GetType();
			if (!type.IsGenericType)
			{
				return;
			}
			try
			{
				Type genericTypeDefinition = type.GetGenericTypeDefinition();
				if (genericTypeDefinition == typeof(AcceptableValueRange<>))
				{
					float num = Convert.ToSingle(type.GetProperty("MinValue").GetValue(val, null), CultureInfo.InvariantCulture);
					float num2 = Convert.ToSingle(type.GetProperty("MaxValue").GetValue(val, null), CultureInfo.InvariantCulture);
					if (num2 > num)
					{
						HasRange = true;
						Min = num;
						Max = num2;
					}
				}
				else if (genericTypeDefinition == typeof(AcceptableValueList<>) && type.GetProperty("AcceptableValues").GetValue(val, null) is Array { Length: >0 } array)
				{
					Choices = array;
				}
			}
			catch (Exception ex)
			{
				PanelLog.Warning("Could not read the limits of " + Section + " / " + Key + ": " + ex.Message);
			}
		}

		private void Read(object tag)
		{
			Type type = tag.GetType();
			int? num = Field<int?>(type, tag, "Order");
			if (num.HasValue)
			{
				Order = num.Value;
			}
			Advanced = Field<bool?>(type, tag, "IsAdvanced") ?? Advanced;
			HideDefaultButton = Field<bool?>(type, tag, "HideDefaultButton") ?? HideDefaultButton;
			HideName = Field<bool?>(type, tag, "HideSettingName") ?? HideName;
			ReadOnly = Field<bool?>(type, tag, "ReadOnly") ?? ReadOnly;
			bool? flag = Field<bool?>(type, tag, "Browsable");
			if (flag.HasValue)
			{
				Hidden = !flag.Value;
			}
			Action<ConfigEntryBase> action = Field<Action<ConfigEntryBase>>(type, tag, "CustomDrawer");
			if (action != null)
			{
				Drawer = action;
			}
		}

		private static T Field<T>(Type type, object tag, string name)
		{
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public);
			if (field == null)
			{
				return default(T);
			}
			object value = field.GetValue(tag);
			if (!(value is T))
			{
				return default(T);
			}
			return (T)value;
		}
	}
	internal static class PanelHost
	{
		public const int Version = 5;

		public const string GuidPrefix = "sohneg.Allfathers";

		private const string HostTypeName = "Allfathers.Shared.Panel.PanelHost";

		private static bool _decided;

		private static bool _mine;

		public static bool IsMine
		{
			get
			{
				if (_decided)
				{
					return _mine;
				}
				_decided = true;
				_mine = Elect();
				return _mine;
			}
		}

		private static bool Elect()
		{
			Assembly assembly = typeof(PanelHost).Assembly;
			string text = "";
			List<PanelCandidate> list = new List<PanelCandidate>();
			foreach (PluginInfo value in Chainloader.PluginInfos.Values)
			{
				if (value == null || value.Metadata == null || (Object)(object)value.Instance == (Object)null)
				{
					continue;
				}
				string text2 = value.Metadata.GUID ?? "";
				if (!text2.StartsWith("sohneg.Allfathers", StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				Assembly assembly2 = ((object)value.Instance).GetType().Assembly;
				if (TryReadVersion(assembly2, out var version))
				{
					list.Add(new PanelCandidate
					{
						Guid = text2,
						Version = version
					});
					if (assembly2 == assembly)
					{
						text = text2;
					}
				}
			}
			string a = PanelElection.Winner(list);
			bool flag = text.Length > 0 && string.Equals(a, text, StringComparison.Ordinal);
			if (flag)
			{
				PanelLog.Info("Drawing the panel (version " + 5 + ", " + list.Count + " Allfather's mod(s) carry it).");
			}
			return flag;
		}

		private static bool TryReadVersion(Assembly assembly, out int version)
		{
			version = 0;
			try
			{
				Type type = assembly.GetType("Allfathers.Shared.Panel.PanelHost", throwOnError: false);
				if (type == null)
				{
					return false;
				}
				FieldInfo field = type.GetField("Version", BindingFlags.Static | BindingFlags.Public);
				if (field == null)
				{
					return false;
				}
				object value = field.GetValue(null);
				if (!(value is int))
				{
					return false;
				}
				version = (int)value;
				return true;
			}
			catch (Exception ex)
			{
				PanelLog.Warning("Could not read the panel version of " + assembly.GetName().Name + ": " + ex.Message);
				return false;
			}
		}
	}
	public struct LayoutInput
	{
		public string Section;

		public string Key;

		public int Order;
	}
	public sealed class LayoutSection
	{
		public string Name;

		public readonly List<int> Plain = new List<int>();

		public readonly LayoutTable Table = new LayoutTable();
	}
	public sealed class LayoutTable
	{
		public readonly List<string> Columns = new List<string>();

		public readonly List<LayoutLine> Lines = new List<LayoutLine>();

		public bool IsEmpty => Lines.Count == 0;
	}
	public sealed class LayoutLine
	{
		public string Name;

		public int[] Cells;
	}
	public static class PanelLayout
	{
		public static List<LayoutSection> Build(IList<LayoutInput> entries)
		{
			List<LayoutSection> list = new List<LayoutSection>();
			if (entries == null)
			{
				return list;
			}
			Dictionary<string, List<int>> dictionary = new Dictionary<string, List<int>>(StringComparer.Ordinal);
			List<string> list2 = new List<string>();
			for (int i = 0; i < entries.Count; i++)
			{
				string text = entries[i].Section ?? "";
				if (!dictionary.TryGetValue(text, out var value))
				{
					value = (dictionary[text] = new List<int>());
					list2.Add(text);
				}
				value.Add(i);
			}
			list2.Sort(CompareSections);
			for (int j = 0; j < list2.Count; j++)
			{
				list.Add(Arrange(list2[j], dictionary[list2[j]], entries));
			}
			return list;
		}

		public static int CompareSections(string a, string b)
		{
			int num = LeadingNumber(a);
			int num2 = LeadingNumber(b);
			if (num != num2)
			{
				return num.CompareTo(num2);
			}
			return string.Compare(a, b, StringComparison.OrdinalIgnoreCase);
		}

		public static bool TrySplit(string key, out string name, out string column)
		{
			name = "";
			column = "";
			if (string.IsNullOrEmpty(key))
			{
				return false;
			}
			int num = key.LastIndexOf('.');
			if (num <= 0 || num >= key.Length - 1)
			{
				return false;
			}
			name = key.Substring(0, num);
			column = key.Substring(num + 1);
			return true;
		}

		private static LayoutSection Arrange(string name, List<int> members, IList<LayoutInput> entries)
		{
			LayoutSection layoutSection = new LayoutSection
			{
				Name = name
			};
			Dictionary<string, int> dictionary = new Dictionary<string, int>(StringComparer.Ordinal);
			for (int i = 0; i < members.Count; i++)
			{
				if (TrySplit(entries[members[i]].Key, out var name2, out var _))
				{
					dictionary.TryGetValue(name2, out var value);
					dictionary[name2] = value + 1;
				}
			}
			Dictionary<string, LayoutLine> dictionary2 = new Dictionary<string, LayoutLine>(StringComparer.Ordinal);
			List<KeyValuePair<LayoutLine, KeyValuePair<string, int>>> list = new List<KeyValuePair<LayoutLine, KeyValuePair<string, int>>>();
			for (int j = 0; j < members.Count; j++)
			{
				int num = members[j];
				if (!TrySplit(entries[num].Key, out var name3, out var column2) || dictionary[name3] < 2)
				{
					layoutSection.Plain.Add(num);
					continue;
				}
				if (!layoutSection.Table.Columns.Contains(column2))
				{
					layoutSection.Table.Columns.Add(column2);
				}
				if (!dictionary2.TryGetValue(name3, out var value2))
				{
					LayoutLine obj = new LayoutLine
					{
						Name = name3
					};
					value2 = (dictionary2[name3] = obj);
					layoutSection.Table.Lines.Add(value2);
				}
				list.Add(new KeyValuePair<LayoutLine, KeyValuePair<string, int>>(value2, new KeyValuePair<string, int>(column2, num)));
			}
			for (int k = 0; k < layoutSection.Table.Lines.Count; k++)
			{
				int[] array = new int[layoutSection.Table.Columns.Count];
				for (int l = 0; l < array.Length; l++)
				{
					array[l] = -1;
				}
				layoutSection.Table.Lines[k].Cells = array;
			}
			for (int m = 0; m < list.Count; m++)
			{
				int num2 = layoutSection.Table.Columns.IndexOf(list[m].Value.Key);
				list[m].Key.Cells[num2] = list[m].Value.Value;
			}
			layoutSection.Plain.Sort(delegate(int a, int b)
			{
				int num3 = entries[b].Order.CompareTo(entries[a].Order);
				return (num3 != 0) ? num3 : string.Compare(entries[a].Key, entries[b].Key, StringComparison.OrdinalIgnoreCase);
			});
			return layoutSection;
		}

		private static int LeadingNumber(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return int.MaxValue;
			}
			int num = 0;
			int i;
			for (i = 0; i < text.Length && i < 6 && char.IsDigit(text[i]); i++)
			{
				num = num * 10 + (text[i] - 48);
			}
			if (i != 0)
			{
				return num;
			}
			return int.MaxValue;
		}
	}
	internal static class PanelLog
	{
		private static readonly ManualLogSource Source = Logger.CreateLogSource("Allfather's Panel");

		public static void Info(string message)
		{
			Source.LogInfo((object)message);
		}

		public static void Warning(string message)
		{
			Source.LogWarning((object)message);
		}

		public static void Error(string message)
		{
			Source.LogError((object)message);
		}
	}
	internal static class PanelLogFile
	{
		public static string FilePath => Path.Combine(Paths.BepInExRootPath, "LogOutput.log");

		public static void Show()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			string filePath = FilePath;
			string bepInExRootPath = Paths.BepInExRootPath;
			try
			{
				if ((int)Application.platform == 2 && File.Exists(filePath))
				{
					Process.Start("explorer.exe", "/select,\"" + filePath + "\"");
				}
				else
				{
					Application.OpenURL(new Uri(bepInExRootPath).AbsoluteUri);
				}
				PanelLog.Info("Showed the log file: " + filePath);
			}
			catch (Exception ex)
			{
				PanelLog.Warning("Could not open the log folder (" + ex.Message + "). The file is " + filePath);
			}
		}
	}
	[HarmonyPatch]
	internal static class PanelMenuButton
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__Open;
		}

		private const string ObjectName = "Allfathers_MenuButton";

		private static Button _button;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Menu), "Start")]
		private static void AfterStart(Menu __instance)
		{
			try
			{
				if (PanelHost.IsMine)
				{
					PanelWindow.Ensure();
					Build(__instance);
				}
			}
			catch (Exception ex)
			{
				PanelLog.Error("The Escape menu entry could not be added: " + ex);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Menu), "UpdateNavigation")]
		private static void AfterUpdateNavigation(Menu __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_button == (Object)null))
			{
				Button settingsButton = __instance.m_settingsButton;
				Button logoutButton = __instance.m_logoutButton;
				if (!((Object)(object)settingsButton == (Object)null) && !((Object)(object)logoutButton == (Object)null))
				{
					Navigation navigation = ((Selectable)settingsButton).navigation;
					((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)_button;
					((Selectable)settingsButton).navigation = navigation;
					Navigation navigation2 = ((Selectable)_button).navigation;
					((Navigation)(ref navigation2)).mode = (Mode)4;
					((Navigation)(ref navigation2)).selectOnUp = (Selectable)(object)settingsButton;
					((Navigation)(ref navigation2)).selectOnDown = (Selectable)(object)logoutButton;
					((Selectable)_button).navigation = navigation2;
					Navigation navigation3 = ((Selectable)logoutButton).navigation;
					((Navigation)(ref navigation3)).selectOnUp = (Selectable)(object)_button;
					((Selectable)logoutButton).navigation = navigation3;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Menu), "Update")]
		private static bool BeforeUpdate()
		{
			if (!PanelWindow.HoldsMenu)
			{
				return true;
			}
			Game instance = Game.instance;
			if ((Object)(object)instance != (Object)null && instance.IsShuttingDown())
			{
				PanelWindow.Abandon();
				return true;
			}
			return false;
		}

		private static void Build(Menu menu)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			Button settingsButton = menu.m_settingsButton;
			if ((Object)(object)settingsButton == (Object)null)
			{
				PanelLog.Error("Menu has no Settings button to copy; the Escape menu entry is missing.");
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)settingsButton).gameObject, ((Component)settingsButton).transform.parent, false);
			((Object)val).name = "Allfathers_MenuButton";
			val.transform.SetSiblingIndex(((Component)settingsButton).transform.GetSiblingIndex() + 1);
			Localize[] componentsInChildren = val.GetComponentsInChildren<Localize>(true);
			foreach (Localize val2 in componentsInChildren)
			{
				Object.Destroy((Object)(object)val2);
			}
			_button = val.GetComponent<Button>();
			if ((Object)(object)_button != (Object)null)
			{
				_button.onClick = new ButtonClickedEvent();
				ButtonClickedEvent onClick = _button.onClick;
				object obj = <>O.<0>__Open;
				if (obj == null)
				{
					UnityAction val3 = PanelWindow.Open;
					<>O.<0>__Open = val3;
					obj = (object)val3;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
			}
			TMP_Text[] componentsInChildren2 = val.GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text val4 in componentsInChildren2)
			{
				val4.text = "Allfather's";
			}
			PanelLog.Info("Escape menu entry added.");
		}
	}
	public static class PanelNumbers
	{
		public static bool TryParseFloat(string text, out float value)
		{
			value = 0f;
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			string text2 = text.Trim();
			if (text2.IndexOf('.') < 0)
			{
				text2 = text2.Replace(',', '.');
			}
			if (!float.TryParse(text2, NumberStyles.Float, CultureInfo.InvariantCulture, out value))
			{
				return false;
			}
			if (!float.IsNaN(value))
			{
				return !float.IsInfinity(value);
			}
			return false;
		}

		public static bool TryParseInt(string text, out int value)
		{
			value = 0;
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			return int.TryParse(text.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out value);
		}

		public static string Format(float value)
		{
			return value.ToString("0.###", CultureInfo.InvariantCulture);
		}

		public static int SliderDecimals(float min, float max)
		{
			float num = Math.Abs(max - min);
			if (num <= 10f)
			{
				return 2;
			}
			if (num <= 100f)
			{
				return 1;
			}
			return 0;
		}

		public static float FromSlider(float value, float min, float max)
		{
			float num = Math.Min(min, max);
			float num2 = Math.Max(min, max);
			float num3 = (float)Math.Round(value, SliderDecimals(min, max), MidpointRounding.AwayFromZero);
			if (num3 < num)
			{
				return num;
			}
			if (num3 > num2)
			{
				return num2;
			}
			return num3;
		}
	}
	internal sealed class PanelSkin
	{
		public static readonly Color Gold = PanelText.Heading;

		public static readonly Color Text = PanelText.Reading;

		public static readonly Color Muted = PanelText.Quiet;

		public GUISkin Skin;

		public GUIStyle Title;

		public GUIStyle Tab;

		public GUIStyle TabSelected;

		public GUIStyle Section;

		public GUIStyle Key;

		public GUIStyle Value;

		public GUIStyle Column;

		public GUIStyle Footnote;

		public GUIStyle Placeholder;

		public GUIStyle Stripe;

		public GUIStyle SwitchOn;

		public GUIStyle SwitchOff;

		public GUIStyle Choice;

		public GUIStyle ChoiceSelected;

		public GUIStyle Small;

		public GUIStyle Tooltip;

		public static PanelSkin Build()
		{
			//IL_0049: 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_0089: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0157: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_0178: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: 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_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Expected O, but got Unknown
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Expected O, but got Unknown
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Expected O, but got Unknown
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Expected O, but got Unknown
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Expected O, but got Unknown
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Expected O, but got Unknown
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Expected O, but got Unknown
			//IL_0585: Expected O, but got Unknown
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05df: Expected O, but got Unknown
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Expected O, but got Unknown
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_0669: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Expected O, but got Unknown
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_069e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Expected O, but got Unknown
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Expected O, but got Unknown
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Expected O, but got Unknown
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Expected O, but got Unknown
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_070e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0713: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0727: Expected O, but got Unknown
			//IL_0732: Unknown result type (might be due to invalid IL or missing references)
			//IL_0737: Unknown result type (might be due to invalid IL or missing references)
			//IL_0748: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Expected O, but got Unknown
			//IL_076e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			//IL_077e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0788: Expected O, but got Unknown
			//IL_07a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c7: Expected O, but got Unknown
			//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0819: Unknown result type (might be due to invalid IL or missing references)
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			//IL_0834: Unknown result type (might be due to invalid IL or missing references)
			//IL_083e: Expected O, but got Unknown
			//IL_085d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0867: Unknown result type (might be due to invalid IL or missing references)
			//IL_0878: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0885: Unknown result type (might be due to invalid IL or missing references)
			//IL_088a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Expected O, but got Unknown
			//IL_0899: Expected O, but got Unknown
			//IL_08a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bc: Expected O, but got Unknown
			//IL_08c1: Expected O, but got Unknown
			//IL_08c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08da: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e4: Expected O, but got Unknown
			//IL_08e9: Expected O, but got Unknown
			//IL_0908: Unknown result type (might be due to invalid IL or missing references)
			//IL_0912: Unknown result type (might be due to invalid IL or missing references)
			//IL_0923: Unknown result type (might be due to invalid IL or missing references)
			//IL_092d: Expected O, but got Unknown
			PanelSkin panelSkin = new PanelSkin();
			Font body = PanelFont.Body;
			Font title = PanelFont.Title;
			GUISkin val = Object.Instantiate<GUISkin>(GUI.skin);
			((Object)val).hideFlags = (HideFlags)61;
			if ((Object)(object)body != (Object)null)
			{
				val.font = body;
			}
			Texture2D background = Solid(new Color(0.22f, 0.16f, 0.1f, 0.95f));
			Texture2D background2 = Solid(new Color(0.32f, 0.23f, 0.13f, 0.98f));
			Texture2D background3 = Solid(new Color(0.45f, 0.32f, 0.16f, 1f));
			Texture2D background4 = Solid(new Color(0f, 0f, 0f, 0.45f));
			Texture2D background5 = Solid(new Color(0.05f, 0.04f, 0.03f, 0.8f));
			val.label.fontSize = 15;
			val.label.wordWrap = true;
			val.label.clipping = (TextClipping)0;
			val.label.padding = new RectOffset(2, 2, 2, 6);
			val.label.normal.textColor = PanelText.Ui(Text);
			val.button.fontSize = 15;
			val.button.alignment = (TextAnchor)4;
			val.button.padding = new RectOffset(10, 10, 5, 5);
			val.button.border = new RectOffset(0, 0, 0, 0);
			Fill(val.button.normal, background, Text);
			Fill(val.button.hover, background2, Color.white);
			Fill(val.button.active, background3, Color.white);
			Fill(val.button.focused, background, Text);
			val.textField.fontSize = 15;
			val.textField.padding = new RectOffset(7, 7, 5, 5);
			val.textField.border = new RectOffset(0, 0, 0, 0);
			Fill(val.textField.normal, background4, Text);
			Fill(val.textField.hover, background4, Color.white);
			Fill(val.textField.focused, background5, Color.white);
			Fill(val.textField.active, background5, Color.white);
			val.toggle.fontSize = 15;
			val.toggle.normal.textColor = PanelText.Ui(Text);
			val.toggle.onNormal.textColor = PanelText.Ui(Gold);
			val.horizontalSlider.normal.background = Solid(new Color(1f, 1f, 1f, 0.14f));
			val.horizontalSlider.fixedHeight = 10f;
			val.horizontalSlider.border = new RectOffset(0, 0, 0, 0);
			val.horizontalSlider.margin = new RectOffset(4, 8, 11, 0);
			val.horizontalSliderThumb.normal.background = Solid(Gold);
			val.horizontalSliderThumb.hover.background = Solid(Color.white);
			val.horizontalSliderThumb.active.background = Solid(Color.white);
			val.horizontalSliderThumb.fixedWidth = 12f;
			val.horizontalSliderThumb.fixedHeight = 10f;
			val.horizontalSliderThumb.border = new RectOffset(0, 0, 0, 0);
			val.verticalScrollbar.normal.background = Solid(new Color(1f, 1f, 1f, 0.05f));
			val.verticalScrollbar.fixedWidth = 8f;
			val.verticalScrollbar.border = new RectOffset(0, 0, 0, 0);
			val.verticalScrollbarThumb.normal.background = Solid(new Color(Muted.r, Muted.g, Muted.b, 0.55f));
			val.verticalScrollbarThumb.fixedWidth = 8f;
			val.verticalScrollbarThumb.border = new RectOffset(0, 0, 0, 0);
			val.box.normal.background = Solid(new Color(0f, 0f, 0f, 0.85f));
			val.box.normal.textColor = PanelText.Ui(Text);
			val.box.fontSize = 14;
			val.box.wordWrap = true;
			val.box.alignment = (TextAnchor)0;
			val.box.padding = new RectOffset(10, 10, 8, 8);
			val.settings.cursorColor = PanelText.Ui(Gold);
			val.settings.selectionColor = new Color(Gold.r, Gold.g, Gold.b, 0.35f);
			panelSkin.Skin = val;
			panelSkin.Title = new GUIStyle(val.label)
			{
				fontSize = 32,
				wordWrap = false
			};
			if ((Object)(object)title != (Object)null)
			{
				panelSkin.Title.font = title;
			}
			panelSkin.Title.normal.textColor = PanelText.Ui(PanelText.WindowName);
			panelSkin.Tab = new GUIStyle(val.label)
			{
				fontSize = 18,
				wordWrap = false,
				padding = new RectOffset(0, 0, 4, 6)
			};
			if ((Object)(object)title != (Object)null)
			{
				panelSkin.Tab.font = title;
			}
			panelSkin.Tab.normal.textColor = PanelText.Ui(Muted);
			panelSkin.Tab.hover.textColor = PanelText.Ui(Text);
			panelSkin.TabSelected = new GUIStyle(panelSkin.Tab);
			panelSkin.TabSelected.normal.textColor = PanelText.Ui(Gold);
			panelSkin.TabSelected.hover.textColor = PanelText.Ui(Gold);
			panelSkin.Section = new GUIStyle(val.label)
			{
				fontSize = 18,
				wordWrap = false
			};
			if ((Object)(object)title != (Object)null)
			{
				panelSkin.Section.font = title;
			}
			panelSkin.Section.normal.textColor = PanelText.Ui(Gold);
			panelSkin.Key = new GUIStyle(val.label)
			{
				wordWrap = false
			};
			panelSkin.Key.normal.textColor = PanelText.Ui(Muted);
			panelSkin.Key.padding = new RectOffset(0, 0, 6, 6);
			panelSkin.Value = new GUIStyle(val.label);
			panelSkin.Value.padding = new RectOffset(0, 0, 6, 6);
			panelSkin.Column = new GUIStyle(val.label)
			{
				fontSize = 13,
				wordWrap = false
			};
			panelSkin.Column.normal.textColor = PanelText.Ui(Muted);
			panelSkin.Footnote = new GUIStyle(val.label)
			{
				fontSize = 13,
				wordWrap = false
			};
			panelSkin.Footnote.normal.textColor = PanelText.Ui(Muted);
			panelSkin.Placeholder = new GUIStyle(val.textField);
			panelSkin.Placeholder.normal.background = null;
			panelSkin.Placeholder.normal.textColor = PanelText.Ui(Muted);
			panelSkin.Stripe = new GUIStyle();
			panelSkin.Stripe.normal.background = Solid(new Color(1f, 1f, 1f, 0.04f));
			panelSkin.SwitchOn = new GUIStyle(val.button);
			Fill(panelSkin.SwitchOn.normal, Solid(new Color(0.45f, 0.31f, 0.1f, 1f)), Gold);
			Fill(panelSkin.SwitchOn.hover, Solid(new Color(0.55f, 0.38f, 0.12f, 1f)), Color.white);
			panelSkin.SwitchOff = new GUIStyle(val.button);
			Fill(panelSkin.SwitchOff.normal, Solid(new Color(0.12f, 0.1f, 0.08f, 0.95f)), Muted);
			panelSkin.Choice = new GUIStyle(val.button)
			{
				fontSize = 14,
				padding = new RectOffset(8, 8, 4, 4)
			};
			panelSkin.ChoiceSelected = new GUIStyle(panelSkin.SwitchOn)
			{
				fontSize = 14,
				padding = new RectOffset(8, 8, 4, 4)
			};
			panelSkin.Small = new GUIStyle(val.button)
			{
				fontSize = 13,
				padding = new RectOffset(8, 8, 3, 3)
			};
			Fill(panelSkin.Small.normal, Solid(new Color(0.16f, 0.12f, 0.08f, 0.9f)), Muted);
			panelSkin.Tooltip = new GUIStyle(val.box);
			return panelSkin;
		}

		private static void Fill(GUIStyleState state, Texture2D background, Color text)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			state.background = background;
			state.textColor = PanelText.Ui(text);
		}

		public static Texture2D Solid(Color colour)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, colour);
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}
	}
	internal static class PanelTexts
	{
		public const string MenuEntry = "Allfather's";

		public const string Title = "Allfather's";

		public static string Close
		{
			get
			{
				if (!German)
				{
					return "Close";
				}
				return "Schliessen";
			}
		}

		public static string NoMods
		{
			get
			{
				if (!German)
				{
					return "No Allfather's mod is loaded.";
				}
				return "Keine Allfather's-Mod geladen.";
			}
		}

		public static string NothingFound
		{
			get
			{
				if (!German)
				{
					return "Nothing found.";
				}
				return "Nichts gefunden.";
			}
		}

		public static string Search
		{
			get
			{
				if (!German)
				{
					return "Search …";
				}
				return "Suchen …";
			}
		}

		public static string ShowAdvanced
		{
			get
			{
				if (!German)
				{
					return "Show advanced";
				}
				return "Erweiterte anzeigen";
			}
		}

		public static string Default
		{
			get
			{
				if (!German)
				{
					return "Default";
				}
				return "Standard";
			}
		}

		public static string DefaultTip
		{
			get
			{
				if (!German)
				{
					return "Back to the default value";
				}
				return "Zurück auf den Standardwert";
			}
		}

		public static string On
		{
			get
			{
				if (!German)
				{
					return "on";
				}
				return "an";
			}
		}

		public static string Off
		{
			get
			{
				if (!German)
				{
					return "off";
				}
				return "aus";
			}
		}

		public static string NoKey
		{
			get
			{
				if (!German)
				{
					return "none";
				}
				return "keine";
			}
		}

		public static string PressKey
		{
			get
			{
				if (!German)
				{
					return "Press a key …";
				}
				return "Taste drücken …";
			}
		}

		public static string PressKeyTip
		{
			get
			{
				if (!German)
				{
					return "The next key is taken, with Ctrl, Shift or Alt held alongside. Delete clears, Esc cancels.";
				}
				return "Die nächste Taste wird übernommen, mit Strg, Umschalt oder Alt dazu. Entf leert, Esc bricht ab.";
			}
		}

		public static string ShowLog
		{
			get
			{
				if (!German)
				{
					return "Show log file";
				}
				return "Log-Datei zeigen";
			}
		}

		public static string ShowLogTip
		{
			get
			{
				if (!German)
				{
					return "Opens the folder with LogOutput.log, the file selected - that is the one to send when something goes wrong. It is replaced every time the game starts: copy it before restarting.";
				}
				return "Öffnet den Ordner mit LogOutput.log, die Datei ist markiert - die schickst du, wenn etwas nicht klappt. Sie wird bei jedem Spielstart ersetzt: kopieren, bevor du neu startest.";
			}
		}

		private static bool German
		{
			get
			{
				Localization instance = Localization.instance;
				if (instance != null)
				{
					return instance.GetSelectedLanguage() == "German";
				}
				return false;
			}
		}

		public static string Footer(int settings, string version)
		{
			if (!German)
			{
				return settings + " settings · version " + version;
			}
			return settings + " Einstellungen · Version " + version;
		}
	}
	internal sealed class PanelWindow : MonoBehaviour
	{
		private sealed class Tab
		{
			public string Name;

			public string Version;

			public readonly List<PanelEntry> Entries = new List<PanelEntry>();

			public List<LayoutSection> Sections;
		}

		private const float DesignHeight = 1080f;

		private const float KeyWidth = 300f;

		private const float CellWidth = 112f;

		private const string SearchControl = "afp:search";

		private static PanelWindow _instance;

		private static int _closedOnFrame = -1;

		private readonly List<Tab> _tabs = new List<Tab>();

		private int _selected;

		private Vector2 _scroll;

		private string _search = "";

		private bool _showAdvanced;

		private bool _anyAdvanced;

		private PanelSkin _look;

		private PanelControls _controls;

		private bool _drawFailed;

		public static bool IsOpen { get; private set; }

		public static bool HoldsMenu
		{
			get
			{
				if (!IsOpen)
				{
					return _closedOnFrame == Time.frameCount;
				}
				return true;
			}
		}

		public static void Ensure()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			if (!((Object)(object)_instance != (Object)null))
			{
				GameObject val = new GameObject("Allfathers_Panel");
				Object.DontDestroyOnLoad((Object)(object)val);
				_instance = val.AddComponent<PanelWindow>();
			}
		}

		public static void Open()
		{
			if (!((Object)(object)_instance == (Object)null) && !_instance._drawFailed)
			{
				Menu instance = Menu.instance;
				if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_menuDialog == (Object)null))
				{
					_instance.Refresh();
					((Component)instance.m_menuDialog).gameObject.SetActive(false);
					IsOpen = true;
				}
			}
		}

		public static void Close()
		{
			if (IsOpen)
			{
				if ((Object)(object)_instance != (Object)null && _instance._controls != null)
				{
					_instance._controls.Commit();
					_instance._controls.DropFocus();
				}
				IsOpen = false;
				_closedOnFrame = Time.frameCount;
				Menu instance = Menu.instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_menuDialog != (Object)null)
				{
					((Component)instance.m_menuDialog).gameObject.SetActive(true);
				}
			}
		}

		public static void Abandon()
		{
			if (IsOpen && (Object)(object)_instance != (Object)null && _instance._controls != null)
			{
				_instance._controls.Commit();
			}
			IsOpen = false;
		}

		private void Update()
		{
			if (!IsOpen)
			{
				return;
			}
			Menu instance = Menu.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_root == (Object)null || !((Component)instance.m_root).gameObject.activeSelf)
			{
				Abandon();
				return;
			}
			PanelBackdrop.Prepare();
			if (ZInput.GetKeyDown((KeyCode)27, true) || ZInput.GetButtonDown("JoyButtonB"))
			{
				if (((_controls != null && _controls.Busy) || GUIUtility.keyboardControl != 0) && _controls != null)
				{
					_controls.RequestCancel();
				}
				else
				{
					Close();
				}
			}
		}

		private void OnGUI()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!IsOpen || _drawFailed)
			{
				return;
			}
			Matrix4x4 matrix = GUI.matrix;
			GUISkin skin = GUI.skin;
			try
			{
				Draw();
			}
			catch (Exception ex)
			{
				_drawFailed = true;
				PanelLog.Error("The panel could not be drawn and has been closed: " + ex);
				Close();
			}
			finally
			{
				GUI.matrix = matrix;
				GUI.skin = skin;
			}
		}

		private void Refresh()
		{
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			_tabs.Clear();
			_anyAdvanced = false;
			List<PluginInfo> list = new List<PluginInfo>();
			foreach (PluginInfo value in Chainloader.PluginInfos.Values)
			{
				if (value != null && value.Metadata != null && !((Object)(object)value.Instance == (Object)null) && (value.Metadata.GUID ?? "").StartsWith("sohneg.Allfathers", StringComparison.OrdinalIgnoreCase))
				{
					list.Add(value);
				}
			}
			list.Sort((PluginInfo a, PluginInfo b) => string.Compare(a.Metadata.Name, b.Metadata.Name, StringComparison.OrdinalIgnoreCase));
			for (int num = 0; num < list.Count; num++)
			{
				PluginInfo val = list[num];
				Tab tab = new Tab
				{
					Name = val.Metadata.Name,
					Version = val.Metadata.Version.ToString()
				};
				List<LayoutInput> list2 = new List<LayoutInput>();
				foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in val.Instance.Config)
				{
					PanelEntry panelEntry = PanelEntry.From(item.Key, item.Value, "afp:" + num + ":" + tab.Entries.Count);
					tab.Entries.Add(panelEntry);
					list2.Add(new LayoutInput
					{
						Section = panelEntry.Section,
						Key = panelEntry.Key,
						Order = panelEntry.Order
					});
					if (panelEntry.Advanced && !panelEntry.Hidden)
					{
						_anyAdvanced = true;
					}
				}
				tab.Sections = PanelLayout.Build(list2);
				_tabs.Add(tab);
			}
			if (_selected >= _tabs.Count)
			{
				_selected = 0;
			}
			_scroll = Vector2.zero;
		}

		private bool Shows(PanelEntry entry, string needle)
		{
			if (entry == null || entry.Hidden)
			{
				return false;
			}
			if (needle.Length > 0)
			{
				return entry.Searchable.Contains(needle);
			}
			if (!_showAdvanced)
			{
				return !entry.Advanced;
			}
			return true;
		}

		private int CountShown(Tab tab, string needle)
		{
			int num = 0;
			for (int i = 0; i < tab.Entries.Count; i++)
			{
				if (Shows(tab.Entries[i], needle))
				{
					num++;
				}
			}
			return num;
		}

		private void Draw()
		{
			//IL_00bc: 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_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_014b: 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_023c: Expected O, but got Unknown
			if (_look == null)
			{
				_look = PanelSkin.Build();
				_controls = new PanelControls(_look);
			}
			float num = Mathf.Max(1f, (float)Screen.height / 1080f);
			float num2 = (float)Screen.width / num;
			float num3 = (float)Screen.height / num;
			float num4 = Mathf.Min(num2 - 80f, 960f);
			float num5 = Mathf.Min(num3 - 80f, num3 * 0.84f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor((num2 - num4) / 2f, (num3 - num5) / 2f, num4, num5);
			GUI.depth = -100;
			PanelBackdrop.Draw(PanelBackdrop.Snap(new Rect(((Rect)(ref val)).x * num, ((Rect)(ref val)).y * num, ((Rect)(ref val)).width * num, ((Rect)(ref val)).height * num)));
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			GUI.skin = _look.Skin;
			_controls.Begin();
			string needle = (_search ?? "").Trim().ToLowerInvariant();
			GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 34f, ((Rect)(ref val)).y + 26f, ((Rect)(ref val)).width - 68f, ((Rect)(ref val)).height - 50f));
			Header();
			Tabs(needle);
			GUILayout.Space(6f);
			Tab tab = ((_tabs.Count > 0) ? _tabs[_selected] : null);
			if (tab == null)
			{
				GUILayout.Label(PanelTexts.NoMods, _look.Footnote, Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
			}
			else
			{
				Body(tab, needle);
			}
			GUILayout.Space(10f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (tab != null)
			{
				GUILayout.Label(PanelTexts.Footer(tab.Entries.Count, tab.Version), _look.Footnote, Array.Empty<GUILayoutOption>());
			}
			GUILayout.FlexibleSpace();
			if (GUILayout.Button(new GUIContent(PanelTexts.ShowLog, PanelTexts.ShowLogTip), _look.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				PanelLogFile.Show();
			}
			GUILayout.Space(10f);
			if (GUILayout.Button(PanelTexts.Close, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(170f),
				GUILayout.Height(36f)
			}))
			{
				Close();
			}
			GUILayout.EndHorizontal();
			GUILayout.EndArea();
			_controls.End();
			Tooltip(num2, num3);
		}

		private void Header()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Allfather's", _look.Title, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (_anyAdvanced)
			{
				if (GUILayout.Button(PanelTexts.ShowAdvanced, _showAdvanced ? _look.SwitchOn : _look.SwitchOff, Array.Empty<GUILayoutOption>()))
				{
					_showAdvanced = !_showAdvanced;
				}
				GUILayout.Space(10f);
			}
			GUI.SetNextControlName("afp:search");
			_search = GUILayout.TextField(_search ?? "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) });
			if (_search.Length == 0 && GUI.GetNameOfFocusedControl() != "afp:search")
			{
				GUI.Label(GUILayoutUtility.GetLastRect(), PanelTexts.Search, _look.Placeholder);
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}

		private void Tabs(string needle)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int i = 0; i < _tabs.Count; i++)
			{
				string text = _tabs[i].Name;
				if (needle.Length > 0)
				{
					text = text + " (" + CountShown(_tabs[i], needle) + ")";
				}
				if (GUILayout.Button(text, (i == _selected) ? _look.TabSelected : _look.Tab, Array.Empty<GUILayoutOption>()) && i != _selected)
				{
					_selected = i;
					_scroll = Vector2.zero;
				}
				GUILayout.Space(22f);
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
		}

		private void Body(Tab tab, string needle)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			_scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			bool flag = false;
			for (int i = 0; i < tab.Sections.Count; i++)
			{
				if (Section(tab, tab.Sections[i], needle, flag))
				{
					flag = true;
				}
			}
			if (!flag)
			{
				GUILayout.Label(PanelTexts.NothingFound, _look.Footnote, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
		}

		private bool Section(Tab tab, LayoutSection section, string needle, bool spaceBefore)
		{
			List<PanelEntry> list = new List<PanelEntry>();
			for (int i = 0; i < section.Plain.Count; i++)
			{
				PanelEntry panelEntry = tab.Entries[section.Plain[i]];
				if (Shows(panelEntry, needle))
				{
					list.Add(panelEntry);
				}
			}
			List<LayoutLine> list2 = new List<LayoutLine>();
			for (int j = 0; j < section.Table.Lines.Count; j++)
			{
				LayoutLine layoutLine = section.Table.Lines[j];
				if (LineShows(tab, layoutLine, needle))
				{
					list2.Add(layoutLine);
				}
			}
			if (list.Count == 0 && list2.Count == 0)
			{
				return false;
			}
			GUILayout.Space(spaceBefore ? 16f : 2f);
			GUILayout.Label(section.Name, _look.Section, Array.Empty<GUILayoutOption>());
			for (int k = 0; k < list.Count; k++)
			{
				_controls.Row(list[k], 300f);
			}
			if (list2.Count > 0)
			{
				Table(tab, section.Table, list2);
			}
			return true;
		}

		private bool LineShows(Tab tab, LayoutLine line, string needle)
		{
			if (needle.Length > 0 && line.Name.ToLowerInvariant().Contains(needle))
			{
				return true;
			}
			for (int i = 0; i < line.Cells.Length; i++)
			{
				if (line.Cells[i] >= 0 && Shows(tab.Entries[line.Cells[i]], needle))
				{
					return true;
				}
			}
			return false;
		}

		private void Table(Tab tab, LayoutTable table, List<LayoutLine> lines)
		{
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("", _look.Column, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) });
			for (int i = 0; i < table.Columns.Count; i++)
			{
				GUILayout.Label(table.Columns[i], _look.Column, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(112f) });
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			for (int j = 0; j < lines.Count; j++)
			{
				LayoutLine layoutLine = lines[j];
				GUILayout.BeginHorizontal((j % 2 == 0) ? _look.Stripe : GUIStyle.none, Array.Empty<GUILayoutOption>());
				GUILayout.Label(layoutLine.Name, _look.Key, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) });
				for (int k = 0; k < layoutLine.Cells.Length; k++)
				{
					int num = layoutLine.Cells[k];
					_controls.Cell((num < 0) ? null : tab.Entries[num], 112f);
				}
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
			}
		}

		private void Tooltip(float screenWidth, float screenHeight)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0032: 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_0038: Unknown result type (might be due to invalid IL or missing re