Decompiled source of TradersExtended v2.0.3

TradersExtended.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using AzuExtendedPlayerInventory;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConditionalConfigSync;
using ExtraSlots;
using GUIFramework;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro;
using TradersExtended.Compatibility;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using YamlDotNet.Serialization;

[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: Guid("6d6f243e-c80e-4a33-b2d0-a2657d3b9f7f")]
[assembly: ComVisible(false)]
[assembly: AssemblyTitle("Traders Extended")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyFileVersion("2.0.3")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Traders Extended")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[<cfe51157-c58c-419c-be36-88778d098f96>Embedded]
	[CompilerGenerated]
	internal sealed class <cfe51157-c58c-419c-be36-88778d098f96>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<cfe51157-c58c-419c-be36-88778d098f96>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TradersExtended
{
	internal sealed class ConfigEditor : IDisposable
	{
		private enum ItemSortColumn
		{
			Prefab,
			LocalizedName,
			Stack,
			Price,
			Quality,
			Currency,
			RequiredGlobalKey,
			BlockedGlobalKey,
			RequiredPlayerKey,
			BlockedPlayerKey
		}

		private enum ItemPickerSortColumn
		{
			Prefab,
			LocalizedName
		}

		private enum ItemRowAction
		{
			None,
			Delete,
			MoveUp,
			MoveDown
		}

		private enum KeyPickerKind
		{
			Global,
			Player
		}

		private sealed class ItemRowValidation
		{
			internal string Prefab = string.Empty;

			internal string Stack = string.Empty;

			internal string Price = string.Empty;

			internal string Quality = string.Empty;

			internal string Currency = string.Empty;

			internal string RequiredGlobalKey = string.Empty;

			internal string BlockedGlobalKey = string.Empty;

			internal string RequiredPlayerKey = string.Empty;

			internal string BlockedPlayerKey = string.Empty;

			internal bool HasErrors => !string.IsNullOrEmpty(Combined);

			internal string Combined => string.Join(" ", new string[9] { Prefab, Stack, Price, Quality, Currency, RequiredGlobalKey, BlockedGlobalKey, RequiredPlayerKey, BlockedPlayerKey }.Where((string value) => !string.IsNullOrWhiteSpace(value)).Distinct<string>(StringComparer.Ordinal));
		}

		private sealed class ItemSortValueComparer : IComparer<object>
		{
			internal static readonly ItemSortValueComparer Instance = new ItemSortValueComparer();

			public int Compare(object left, object right)
			{
				if (left == right)
				{
					return 0;
				}
				if (left == null)
				{
					return -1;
				}
				if (right == null)
				{
					return 1;
				}
				if (left is int num && right is int value)
				{
					return num.CompareTo(value);
				}
				return string.Compare(Convert.ToString(left, CultureInfo.CurrentCulture), Convert.ToString(right, CultureInfo.CurrentCulture), StringComparison.CurrentCultureIgnoreCase);
			}
		}

		private sealed class ItemOption
		{
			internal string Prefab { get; }

			internal string LocalizedName { get; }

			internal Sprite Icon { get; }

			internal bool VisibleByDefault { get; }

			internal ItemOption(string prefab, string localizedName, Sprite icon, bool visibleByDefault)
			{
				Prefab = prefab;
				LocalizedName = localizedName;
				Icon = icon;
				VisibleByDefault = visibleByDefault;
			}
		}

		private sealed class TraderOption
		{
			internal string Prefab { get; }

			internal string DisplayName { get; }

			internal TraderOption(string prefab, string displayName)
			{
				Prefab = prefab;
				DisplayName = displayName;
			}
		}

		private sealed class Theme
		{
			private static readonly Color WindowColor = new Color(0.16f, 0.16f, 0.16f, 1f);

			private static readonly Color BorderColor = new Color(0.48f, 0.48f, 0.48f, 1f);

			private static readonly Color EntryColor = new Color(0.12f, 0.12f, 0.12f, 0.95f);

			private static readonly Color TextColorValue = new Color(0.92f, 0.92f, 0.92f, 1f);

			private static readonly Color ButtonColor = new Color(0.24f, 0.24f, 0.24f, 1f);

			private static readonly Color AccentColorValue = new Color(0.38f, 0.55f, 0.72f, 1f);

			private GUISkin sourceSkin;

			private GUISkin runtimeSkin;

			private int currentFontSize = -1;

			private Texture2D windowTexture;

			private Texture2D borderTexture;

			private Texture2D entryTexture;

			private Texture2D buttonTexture;

			private Texture2D buttonHoverTexture;

			private Texture2D buttonActiveTexture;

			private Texture2D accentTexture;

			private Texture2D accentHoverTexture;

			private Texture2D scrollbarTrackTexture;

			private Texture2D toggleOffTexture;

			private Texture2D toggleOnTexture;

			private Texture2D toggleOffHoverTexture;

			private Texture2D toggleOnHoverTexture;

			private GUIStyle accentButtonStyle;

			private GUIStyle resizeHandleStyle;

			private GUIStyle compactToggleOffStyle;

			private GUIStyle compactToggleOnStyle;

			internal GUISkin Skin
			{
				get
				{
					EnsureStyles();
					return runtimeSkin ?? GUI.skin;
				}
			}

			internal Texture2D WindowTexture
			{
				get
				{
					EnsureStyles();
					return windowTexture;
				}
			}

			internal Texture2D BorderTexture
			{
				get
				{
					EnsureStyles();
					return borderTexture;
				}
			}

			internal GUIStyle AccentButtonStyle
			{
				get
				{
					EnsureStyles();
					return accentButtonStyle ?? GUI.skin.button;
				}
			}

			internal GUIStyle ResizeHandleStyle
			{
				get
				{
					EnsureStyles();
					return resizeHandleStyle ?? GUI.skin.box;
				}
			}

			internal GUIStyle CompactToggleOffStyle
			{
				get
				{
					EnsureStyles();
					return compactToggleOffStyle ?? GUI.skin.box;
				}
			}

			internal GUIStyle CompactToggleOnStyle
			{
				get
				{
					EnsureStyles();
					return compactToggleOnStyle ?? GUI.skin.box;
				}
			}

			internal float CompactToggleSize
			{
				get
				{
					EnsureStyles();
					return Mathf.Clamp((float)(TradersExtended.configEditorFontSize?.Value ?? 13) - 2f, 9f, 16f);
				}
			}

			internal Color TextColor => TextColorValue;

			internal void EnsureStyles()
			{
				GUISkin skin = GUI.skin;
				int num = Mathf.Clamp(TradersExtended.configEditorFontSize?.Value ?? 13, 9, 28);
				if (!((Object)(object)runtimeSkin != (Object)null) || currentFontSize != num || (!((Object)(object)sourceSkin == (Object)(object)skin) && !((Object)(object)runtimeSkin == (Object)(object)skin)))
				{
					Rebuild(((Object)(object)skin == (Object)(object)runtimeSkin) ? sourceSkin : skin, num);
				}
			}

			internal void Shutdown()
			{
				DestroyResources();
			}

			private void Rebuild(GUISkin baseSkin, int fontSize)
			{
				//IL_0027: 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_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: 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_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0222: Unknown result type (might be due to invalid IL or missing references)
				//IL_0255: Unknown result type (might be due to invalid IL or missing references)
				//IL_025f: Expected O, but got Unknown
				//IL_026f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0279: Expected O, but got Unknown
				//IL_0289: Unknown result type (might be due to invalid IL or missing references)
				//IL_0293: Expected O, but got Unknown
				//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Expected O, but got Unknown
				//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02de: Expected O, but got Unknown
				//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f8: Expected O, but got Unknown
				//IL_031f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0329: Expected O, but got Unknown
				//IL_0339: Unknown result type (might be due to invalid IL or missing references)
				//IL_0343: Expected O, but got Unknown
				//IL_0353: Unknown result type (might be due to invalid IL or missing references)
				//IL_035d: Expected O, but got Unknown
				//IL_037f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0389: Expected O, but got Unknown
				//IL_0399: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a3: Expected O, but got Unknown
				//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03bd: Expected O, but got Unknown
				//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d7: Expected O, but got Unknown
				//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f1: Expected O, but got Unknown
				//IL_041d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0427: Expected O, but got Unknown
				//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b5: Expected O, but got Unknown
				//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c5: Expected O, but got Unknown
				//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_04d5: Expected O, but got Unknown
				//IL_04db: Expected O, but got Unknown
				//IL_0527: Unknown result type (might be due to invalid IL or missing references)
				//IL_052c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0531: Unknown result type (might be due to invalid IL or missing references)
				//IL_053b: Expected O, but got Unknown
				//IL_053c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0541: Unknown result type (might be due to invalid IL or missing references)
				//IL_054b: Expected O, but got Unknown
				//IL_054c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0551: Unknown result type (might be due to invalid IL or missing references)
				//IL_055b: Expected O, but got Unknown
				//IL_0561: Expected O, but got Unknown
				//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_05bc: Expected O, but got Unknown
				//IL_05c2: Expected O, but got Unknown
				DestroyResources();
				sourceSkin = baseSkin;
				currentFontSize = fontSize;
				if (!((Object)(object)baseSkin == (Object)null))
				{
					windowTexture = CreateTexture(WindowColor);
					borderTexture = CreateTexture(BorderColor);
					entryTexture = CreateTexture(EntryColor);
					buttonTexture = CreateTexture(ButtonColor);
					buttonHoverTexture = CreateTexture(Lighten(ButtonColor, 0.12f));
					buttonActiveTexture = CreateTexture(Darken(AccentColorValue, 0.1f));
					accentTexture = CreateTexture(AccentColorValue);
					accentHoverTexture = CreateTexture(Lighten(AccentColorValue, 0.12f));
					scrollbarTrackTexture = CreateTexture(Darken(EntryColor, 0.08f));
					Color val = CreateNeutralToggleColor(EntryColor, ButtonColor);
					toggleOffTexture = CreateBorderedTexture(val, BorderColor);
					toggleOnTexture = CreateBorderedTexture(AccentColorValue, BorderColor);
					toggleOffHoverTexture = CreateBorderedTexture(Lighten(val, 0.12f), Lighten(BorderColor, 0.2f));
					toggleOnHoverTexture = CreateBorderedTexture(Lighten(AccentColorValue, 0.12f), Lighten(BorderColor, 0.2f));
					runtimeSkin = Object.Instantiate<GUISkin>(baseSkin);
					((Object)runtimeSkin).name = "TradersExtendedConfigEditorSkin";
					((Object)runtimeSkin).hideFlags = (HideFlags)61;
					ConfigureTextStyle(runtimeSkin.label, TextColorValue, fontSize);
					ConfigureTextStyle(runtimeSkin.box, TextColorValue, fontSize);
					ConfigureTextStyle(runtimeSkin.window, Color.white, fontSize);
					ConfigureTextStyle(runtimeSkin.button, Color.white, fontSize);
					ConfigureTextStyle(runtimeSkin.toggle, TextColorValue, fontSize);
					ConfigureTextStyle(runtimeSkin.textField, TextColorValue, fontSize);
					ConfigureTextStyle(runtimeSkin.textArea, TextColorValue, fontSize);
					SetAllBackgrounds(runtimeSkin.window, windowTexture);
					runtimeSkin.window.padding = new RectOffset(4, 4, 21, 4);
					runtimeSkin.window.margin = new RectOffset(0, 0, 0, 0);
					runtimeSkin.window.border = new RectOffset(0, 0, 0, 0);
					SetAllBackgrounds(runtimeSkin.box, entryTexture);
					runtimeSkin.box.padding = new RectOffset(4, 4, 3, 3);
					runtimeSkin.box.margin = new RectOffset(1, 1, 1, 1);
					runtimeSkin.box.border = new RectOffset(0, 0, 0, 0);
					SetAllBackgrounds(runtimeSkin.textField, entryTexture);
					runtimeSkin.textField.padding = new RectOffset(4, 4, 1, 1);
					runtimeSkin.textField.margin = new RectOffset(1, 1, 1, 1);
					runtimeSkin.textField.border = new RectOffset(0, 0, 0, 0);
					runtimeSkin.textField.alignment = (TextAnchor)3;
					runtimeSkin.button.padding = new RectOffset(5, 5, 2, 2);
					runtimeSkin.button.margin = new RectOffset(2, 2, 1, 1);
					runtimeSkin.button.border = new RectOffset(0, 0, 0, 0);
					runtimeSkin.toggle.margin = new RectOffset(1, 1, 1, 1);
					runtimeSkin.label.margin = new RectOffset(1, 1, 0, 0);
					SetButtonBackgrounds(runtimeSkin.button);
					ConfigureSquareScrollbars(runtimeSkin);
					accentButtonStyle = new GUIStyle(runtimeSkin.button);
					SetAllBackgrounds(accentButtonStyle, accentTexture);
					accentButtonStyle.hover.background = accentHoverTexture;
					accentButtonStyle.onHover.background = accentHoverTexture;
					accentButtonStyle.active.background = buttonActiveTexture;
					accentButtonStyle.onActive.background = buttonActiveTexture;
					resizeHandleStyle = new GUIStyle(runtimeSkin.box)
					{
						padding = new RectOffset(0, 0, 0, 0),
						margin = new RectOffset(0, 0, 0, 0),
						border = new RectOffset(0, 0, 0, 0)
					};
					SetAllBackgrounds(resizeHandleStyle, accentTexture);
					resizeHandleStyle.hover.background = accentHoverTexture;
					resizeHandleStyle.active.background = buttonActiveTexture;
					compactToggleOffStyle = new GUIStyle(runtimeSkin.box)
					{
						padding = new RectOffset(0, 0, 0, 0),
						margin = new RectOffset(0, 0, 0, 0),
						border = new RectOffset(1, 1, 1, 1)
					};
					SetAllBackgrounds(compactToggleOffStyle, toggleOffTexture);
					compactToggleOffStyle.hover.background = toggleOffHoverTexture;
					compactToggleOffStyle.active.background = toggleOffHoverTexture;
					compactToggleOnStyle = new GUIStyle(compactToggleOffStyle)
					{
						border = new RectOffset(1, 1, 1, 1)
					};
					SetAllBackgrounds(compactToggleOnStyle, toggleOnTexture);
					compactToggleOnStyle.hover.background = toggleOnHoverTexture;
					compactToggleOnStyle.active.background = toggleOnHoverTexture;
				}
			}

			private void ConfigureSquareScrollbars(GUISkin skin)
			{
				ConfigureScrollbarTrack(skin.horizontalScrollbar, horizontal: true, 13f);
				ConfigureScrollbarTrack(skin.verticalScrollbar, horizontal: false, 13f);
				ConfigureScrollbarThumb(skin.horizontalScrollbarThumb, horizontal: true, 13f);
				ConfigureScrollbarThumb(skin.verticalScrollbarThumb, horizontal: false, 13f);
				HideScrollbarButton(skin.horizontalScrollbarLeftButton);
				HideScrollbarButton(skin.horizontalScrollbarRightButton);
				HideScrollbarButton(skin.verticalScrollbarUpButton);
				HideScrollbarButton(skin.verticalScrollbarDownButton);
			}

			private void ConfigureScrollbarTrack(GUIStyle style, bool horizontal, float size)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Expected O, but got Unknown
				if (style != null)
				{
					SetAllBackgrounds(style, scrollbarTrackTexture);
					style.border = new RectOffset(0, 0, 0, 0);
					style.margin = (horizontal ? new RectOffset(0, 0, 0, 0) : new RectOffset(0, 1, 0, 0));
					style.padding = new RectOffset(0, 0, 0, 0);
					if (horizontal)
					{
						style.fixedHeight = size;
					}
					else
					{
						style.fixedWidth = size;
					}
				}
			}

			private void ConfigureScrollbarThumb(GUIStyle style, bool horizontal, float size)
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Expected O, but got Unknown
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Expected O, but got Unknown
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Expected O, but got Unknown
				if (style != null)
				{
					SetAllBackgrounds(style, accentTexture);
					style.hover.background = accentHoverTexture;
					style.active.background = buttonActiveTexture;
					style.border = new RectOffset(0, 0, 0, 0);
					style.margin = new RectOffset(1, 1, 1, 1);
					style.padding = new RectOffset(0, 0, 0, 0);
					if (horizontal)
					{
						style.fixedHeight = Mathf.Max(1f, size - 2f);
					}
					else
					{
						style.fixedWidth = Mathf.Max(1f, size - 2f);
					}
				}
			}

			private static void HideScrollbarButton(GUIStyle style)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Expected O, but got Unknown
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Expected O, but got Unknown
				if (style != null)
				{
					SetAllBackgrounds(style, null);
					style.border = new RectOffset(0, 0, 0, 0);
					style.margin = new RectOffset(0, 0, 0, 0);
					style.padding = new RectOffset(0, 0, 0, 0);
					style.fixedWidth = 0f;
					style.fixedHeight = 0f;
					style.stretchWidth = false;
					style.stretchHeight = false;
				}
			}

			private void SetButtonBackgrounds(GUIStyle style)
			{
				style.normal.background = buttonTexture;
				style.onNormal.background = accentTexture;
				style.hover.background = buttonHoverTexture;
				style.onHover.background = buttonHoverTexture;
				style.active.background = buttonActiveTexture;
				style.onActive.background = buttonActiveTexture;
				style.focused.background = buttonTexture;
				style.onFocused.background = accentTexture;
			}

			private static void SetAllBackgrounds(GUIStyle style, Texture2D texture)
			{
				if (style != null)
				{
					style.normal.background = texture;
					style.hover.background = texture;
					style.active.background = texture;
					style.focused.background = texture;
					style.onNormal.background = texture;
					style.onHover.background = texture;
					style.onActive.background = texture;
					style.onFocused.background = texture;
				}
			}

			private static void ConfigureTextStyle(GUIStyle style, Color color, int fontSize)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				if (style != null)
				{
					style.fontSize = fontSize;
					SetTextColor(style.normal, color);
					SetTextColor(style.hover, color);
					SetTextColor(style.active, color);
					SetTextColor(style.focused, color);
					SetTextColor(style.onNormal, color);
					SetTextColor(style.onHover, color);
					SetTextColor(style.onActive, color);
					SetTextColor(style.onFocused, color);
				}
			}

			private static void SetTextColor(GUIStyleState state, Color color)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				if (state != null)
				{
					state.textColor = color;
				}
			}

			private static Texture2D CreateTexture(Color color)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: 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_0020: Expected O, but got Unknown
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false)
				{
					hideFlags = (HideFlags)61,
					name = "TradersExtendedConfigEditorColor"
				};
				val.SetPixel(0, 0, color);
				val.Apply(false, true);
				return val;
			}

			private static Texture2D CreateBorderedTexture(Color fill, Color border)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: 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_0020: Expected O, but got Unknown
				//IL_003c: 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)
				Texture2D val = new Texture2D(3, 3, (TextureFormat)4, false)
				{
					hideFlags = (HideFlags)61,
					name = "TradersExtendedConfigEditorBorderedColor"
				};
				for (int i = 0; i < 3; i++)
				{
					for (int j = 0; j < 3; j++)
					{
						val.SetPixel(j, i, (j == 0 || i == 0 || j == 2 || i == 2) ? border : fill);
					}
				}
				val.Apply(false, true);
				return val;
			}

			private static Color Lighten(Color color, float amount)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: 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_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				return new Color(Mathf.Lerp(color.r, 1f, amount), Mathf.Lerp(color.g, 1f, amount), Mathf.Lerp(color.b, 1f, amount), color.a);
			}

			private static Color Darken(Color color, float amount)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: 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_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				return new Color(color.r * (1f - amount), color.g * (1f - amount), color.b * (1f - amount), color.a);
			}

			private static Color CreateNeutralToggleColor(Color entry, Color button)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: 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)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0056: Unknown result type (might be due to invalid IL or missing references)
				Color val = Color.Lerp(entry, button, 0.55f);
				float num = val.r * 0.299f + val.g * 0.587f + val.b * 0.114f;
				num = Mathf.Lerp(num, 1f, 0.08f);
				return new Color(num, num, num, 1f);
			}

			private void DestroyResources()
			{
				Destroy((Object)(object)runtimeSkin);
				Destroy((Object)(object)windowTexture);
				Destroy((Object)(object)borderTexture);
				Destroy((Object)(object)entryTexture);
				Destroy((Object)(object)buttonTexture);
				Destroy((Object)(object)buttonHoverTexture);
				Destroy((Object)(object)buttonActiveTexture);
				Destroy((Object)(object)accentTexture);
				Destroy((Object)(object)accentHoverTexture);
				Destroy((Object)(object)scrollbarTrackTexture);
				Destroy((Object)(object)toggleOffTexture);
				Destroy((Object)(object)toggleOnTexture);
				Destroy((Object)(object)toggleOffHoverTexture);
				Destroy((Object)(object)toggleOnHoverTexture);
				runtimeSkin = null;
				sourceSkin = null;
				accentButtonStyle = null;
				resizeHandleStyle = null;
				compactToggleOffStyle = null;
				compactToggleOnStyle = null;
			}

			private static void Destroy(Object value)
			{
				if (value != (Object)null)
				{
					Object.Destroy(value);
				}
			}
		}

		private static class Controls
		{
			internal static bool ToggleLayout(Theme theme, bool value, GUIContent content, float width, GUIStyle labelStyle = null, float verticalOffset = 1f, float minimumHeight = 0f)
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				GUIStyle val = labelStyle ?? GUI.skin.label;
				float num = Mathf.Max(new float[3]
				{
					18f,
					val.lineHeight + 4f,
					minimumHeight
				});
				Rect rect = GUILayoutUtility.GetRect(width, num, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(width),
					GUILayout.Height(num)
				});
				return Toggle(theme, rect, value, content, val, verticalOffset);
			}

			internal static bool Toggle(Theme theme, Rect rect, bool value, GUIContent content, GUIStyle labelStyle = null, float verticalOffset = 1f)
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Expected O, but got Unknown
				//IL_0094: 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)
				//IL_00b7: Expected O, but got Unknown
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Expected O, but got Unknown
				GUIStyle val = labelStyle ?? GUI.skin.label;
				string text = ((content != null) ? content.tooltip : null) ?? string.Empty;
				bool flag = GUI.Toggle(rect, value, new GUIContent(string.Empty, text), GUIStyle.none);
				float num = theme?.CompactToggleSize ?? 10f;
				float num2 = Mathf.Ceil(Mathf.Max(0f, (((Rect)(ref rect)).height - num) * 0.5f));
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + num2 + verticalOffset, num, num);
				GUI.Box(val2, new GUIContent(string.Empty, text), flag ? theme.CompactToggleOnStyle : theme.CompactToggleOffStyle);
				string text2 = ((content != null) ? content.text : null) ?? string.Empty;
				if (!string.IsNullOrEmpty(text2))
				{
					float num3 = ((Rect)(ref val2)).xMax + 4f;
					GUI.Label(new Rect(num3, ((Rect)(ref rect)).y, Mathf.Max(0f, ((Rect)(ref rect)).xMax - num3), ((Rect)(ref rect)).height), new GUIContent(text2, text), val);
				}
				return flag;
			}
		}

		private sealed class GuiScale
		{
			private bool temporaryUnity6000Window = true;

			internal float ScaleFactor
			{
				get
				{
					float num = TradersExtended.configEditorUiScale?.Value ?? 1f;
					float num2 = ((float.IsNaN(num) || float.IsInfinity(num)) ? 1f : Mathf.Clamp(num, 0.25f, 4f));
					ConfigEntry<bool> configEditorUseValheimGuiScale = TradersExtended.configEditorUseValheimGuiScale;
					if (configEditorUseValheimGuiScale == null || configEditorUseValheimGuiScale.Value)
					{
						num2 *= GetValheimGuiScale();
					}
					return Mathf.Max(0.01f, num2);
				}
			}

			internal int PhysicalWidth => temporaryUnity6000Window ? GetDisplayWidth() : Mathf.Max(1, Screen.width);

			internal int PhysicalHeight => temporaryUnity6000Window ? GetDisplayHeight() : Mathf.Max(1, Screen.height);

			internal float LogicalWidth => (float)PhysicalWidth / ScaleFactor;

			internal float LogicalHeight => (float)PhysicalHeight / ScaleFactor;

			internal Matrix4x4 Matrix => Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(ScaleFactor, ScaleFactor, 1f));

			internal void MarkGameWindowReady()
			{
				temporaryUnity6000Window = false;
			}

			internal Vector2 GetLogicalMousePosition()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//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_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: 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_002e: 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_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				Matrix4x4 val = Matrix;
				val = ((Matrix4x4)(ref val)).inverse;
				Vector3 val2 = ((Matrix4x4)(ref val)).MultiplyPoint(UnityInput.Current.mousePosition);
				return new Vector2(val2.x, LogicalHeight - val2.y);
			}

			private float GetValheimGuiScale()
			{
				try
				{
					float num = (float)PhysicalWidth / (float)GuiScaler.m_minWidth;
					float num2 = (float)PhysicalHeight / (float)GuiScaler.m_minHeight;
					float num3 = Mathf.Min(num, num2) * GuiScaler.m_largeGuiScale;
					return (float.IsNaN(num3) || float.IsInfinity(num3)) ? 1f : Mathf.Max(0.01f, num3);
				}
				catch
				{
					return 1f;
				}
			}

			private static int GetDisplayWidth()
			{
				try
				{
					return (Display.main != null) ? Mathf.Max(1, Display.main.systemWidth) : Mathf.Max(1, Screen.width);
				}
				catch
				{
					return Mathf.Max(1, Screen.width);
				}
			}

			private static int GetDisplayHeight()
			{
				try
				{
					return (Display.main != null) ? Mathf.Max(1, Display.main.systemHeight) : Mathf.Max(1, Screen.height);
				}
				catch
				{
					return Mathf.Max(1, Screen.height);
				}
			}
		}

		private const int WindowId = 924617;

		private const int NewFileWindowId = 924618;

		private const int ItemPickerWindowId = 924619;

		private const int GlobalKeyWindowId = 924620;

		private const int ConfirmWindowId = 924621;

		private const float DefaultLeftPanelWidth = 382f;

		private const float MinimumLeftPanelWidth = 240f;

		private const float MaximumLeftPanelWidth = 800f;

		private const float ColumnSplitterWidth = 7f;

		private const float MinimumWidth = 1000f;

		private const float MinimumHeight = 600f;

		private const float TitleBarHeight = 22f;

		private const float ResizeEdgeHitSize = 4f;

		private const float ResizeHandleHitSize = 12f;

		private const float ResizeHandleVisualSize = 8f;

		private const float WindowBorderWidth = 1f;

		private const float LayoutSaveDelay = 0.5f;

		private const float CompactControlHeight = 20f;

		private const float CompactRowHeight = 22f;

		private const float ItemPickerControlHeight = 18f;

		private const float ItemPickerRowHeight = 20f;

		private const float ItemIconSize = 17f;

		private const float InlinePickerButtonWidth = 20f;

		private const float InlinePickerButtonHeight = 14f;

		private const float QuickDeleteButtonWidth = 18f;

		private const float ItemColumnSpacing = 3f;

		private const int ItemRowsPerPage = 100;

		private const float RequestTimeoutSeconds = 15f;

		private static readonly ItemSortColumn[] ItemColumnOrder = new ItemSortColumn[10]
		{
			ItemSortColumn.Prefab,
			ItemSortColumn.LocalizedName,
			ItemSortColumn.Stack,
			ItemSortColumn.Price,
			ItemSortColumn.Quality,
			ItemSortColumn.Currency,
			ItemSortColumn.RequiredGlobalKey,
			ItemSortColumn.BlockedGlobalKey,
			ItemSortColumn.RequiredPlayerKey,
			ItemSortColumn.BlockedPlayerKey
		};

		private long targetRevision;

		private bool targetChanged;

		private readonly ConfigEditorCursor cursor = new ConfigEditorCursor();

		private readonly GuiScale scale = new GuiScale();

		private readonly Theme theme = new Theme();

		private readonly Dictionary<string, string> traderDisplayNames = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		private readonly List<ItemOption> itemOptions = new List<ItemOption>();

		private readonly Dictionary<string, ItemOption> itemOptionsByPrefab = new Dictionary<string, ItemOption>(StringComparer.OrdinalIgnoreCase);

		private bool isOpen;

		private bool layoutLoaded;

		private bool resizing;

		private Vector2 resizeStartMouse;

		private Rect resizeStartRect;

		private bool resizeWidth;

		private bool resizeHeight;

		private bool layoutDirty;

		private bool splitterDragging;

		private Vector2 splitterDragStartMouse;

		private float splitterDragStartWidth;

		private float saveLayoutAfterRealtime;

		private Rect windowRect;

		private List<EditorFileInfo> files = new List<EditorFileInfo>();

		private EditorFileInfo activeFile;

		private ItemConfigDocument itemDocument;

		private TraderConfigDocument traderDocument;

		private string selectAfterList;

		private string fileSearch = string.Empty;

		private string itemSearch = string.Empty;

		private string statusText = string.Empty;

		private bool statusError;

		private bool requestInProgress;

		private float requestStartedAt;

		private Vector2 fileScroll;

		private Vector2 itemScroll;

		private int itemPage;

		private Vector2 settingsScroll;

		private bool showNewFile;

		private Rect newFileRect = new Rect(0f, 0f, 620f, 520f);

		private Vector2 newFileScroll;

		private EditorConfigKind newFileKind = EditorConfigKind.ItemList;

		private string newFileTrader = "common";

		private TradersExtended.ItemsListType newFileListType = TradersExtended.ItemsListType.Buy;

		private string newFileIdentifier = string.Empty;

		private string newFileExtension = "json";

		private bool showItemPicker;

		private Rect itemPickerRect = new Rect(0f, 0f, 572f, 650f);

		private string itemPickerSearch = string.Empty;

		private string itemPickerTitle = "Select item";

		private Vector2 itemPickerScroll;

		private int itemPickerPage;

		private ItemPickerSortColumn itemPickerSortColumn = ItemPickerSortColumn.Prefab;

		private bool itemPickerSortAscending = true;

		private Action<string> itemPickerCallback;

		private bool itemPickerMultiAdd;

		private bool showGlobalKeyPicker;

		private KeyPickerKind keyPickerKind = KeyPickerKind.Global;

		private string newPickerKey = string.Empty;

		private Rect globalKeyRect = new Rect(0f, 0f, 330f, 620f);

		private string globalKeySearch = string.Empty;

		private Vector2 globalKeyScroll;

		private HashSet<string> globalKeySelection = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private Action<string> globalKeyCallback;

		private bool showConfirm;

		private Rect confirmRect = new Rect(0f, 0f, 360f, 112f);

		private string confirmMessage = string.Empty;

		private Action confirmAction;

		private GUISkin styleSourceSkin;

		private GUIStyle windowStyle;

		private GUIStyle panelStyle;

		private GUIStyle selectedFileStyle;

		private GUIStyle fileStyle;

		private GUIStyle headerStyle;

		private GUIStyle toolbarStyle;

		private GUIStyle rowStyle;

		private GUIStyle itemRowStyle;

		private GUIStyle mutedStyle;

		private GUIStyle rightMutedStyle;

		private GUIStyle errorStyle;

		private GUIStyle titleStyle;

		private GUIStyle smallButtonStyle;

		private GUIStyle centeredMutedStyle;

		private GUIStyle centeredMessageStyle;

		private GUIStyle singleLineMutedStyle;

		private GUIStyle itemPrefabTextFieldStyle;

		private GUIStyle invalidItemIconStyle;

		private GUIStyle fileNameStyle;

		private GUIStyle pickerPrefabStyle;

		private GUIStyle pickerNameStyle;

		private GUIStyle keyNameStyle;

		private GUIStyle keySelectedNameStyle;

		private GUIStyle selectedValueLabelStyle;

		private GUIStyle selectedValueStyle;

		private GUIStyle serverSourceStyle;

		private GUIStyle inlineButtonStyle;

		private GUIStyle splitterStyle;

		private bool stylesInitialized;

		private bool itemOptionsBuilt;

		private float itemPrefabColumnWidth = 150f;

		private bool itemPrefabColumnWidthDirty = true;

		private string lastGuiExceptionSignature = string.Empty;

		private bool focusPopupWindow;

		private readonly HashSet<ItemSortColumn> visibleItemColumns = new HashSet<ItemSortColumn>();

		private string visibleItemColumnsSource = string.Empty;

		private List<TraderOption> temporaryTraderOptions;

		internal static bool IsOpenGlobal => TradersExtended.configEditor != null && TradersExtended.configEditor.IsOpen;

		internal bool IsOpen => isOpen;

		internal static bool IsDrawing { get; private set; }

		internal ConfigEditor()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			ConfigEditorTransport.ResponseReceived += OnTransportResponse;
			ConfigEditorTransport.TransferProgress += OnTransferProgress;
		}

		internal void MarkGameWindowReady()
		{
			scale.MarkGameWindowReady();
		}

		internal void Toggle()
		{
			SetOpen(!isOpen);
		}

		internal void Update()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (isOpen)
			{
				EnsureTargetContext();
			}
			if (TradersExtended.configEditorShortcut != null)
			{
				KeyboardShortcut value = TradersExtended.configEditorShortcut.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					Toggle();
					return;
				}
			}
			if (isOpen && !AnyPopupOpen() && IsControlPressed() && UnityInput.Current.GetKeyDown((KeyCode)115))
			{
				if (activeFile != null && activeFile.Kind != EditorConfigKind.Unsupported && IsDirty() && !requestInProgress)
				{
					SaveActiveFile();
				}
				return;
			}
			if (isOpen && UnityInput.Current.GetKeyDown((KeyCode)27))
			{
				if (showConfirm)
				{
					showConfirm = false;
				}
				else if (showItemPicker)
				{
					CloseItemPicker();
				}
				else if (showGlobalKeyPicker)
				{
					showGlobalKeyPicker = false;
				}
				else if (showNewFile)
				{
					showNewFile = false;
				}
				else
				{
					RequestClose();
				}
			}
			if (requestInProgress && Time.realtimeSinceStartup - requestStartedAt > 15f)
			{
				ConfigEditorTransport.CancelPendingRequest();
				requestInProgress = false;
				selectAfterList = null;
				SetStatus("The configuration request timed out. Check the server connection and mod version.", error: true);
			}
			if (resizing && !UnityInput.Current.GetKey((KeyCode)323))
			{
				ClearResizeState();
				MarkLayoutDirty();
			}
			if (splitterDragging && !UnityInput.Current.GetKey((KeyCode)323))
			{
				splitterDragging = false;
			}
			if (layoutDirty && Time.realtimeSinceStartup >= saveLayoutAfterRealtime)
			{
				SaveLayout();
			}
			cursor.Update(isOpen);
		}

		private bool AnyPopupOpen()
		{
			return showConfirm || showItemPicker || showGlobalKeyPicker || showNewFile;
		}

		private static bool IsControlPressed()
		{
			return UnityInput.Current.GetKey((KeyCode)306) || UnityInput.Current.GetKey((KeyCode)305);
		}

		internal void LateUpdate()
		{
			cursor.Update(isOpen);
		}

		internal void OnGUI()
		{
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_01c4: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Expected O, but got Unknown
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Expected O, but got Unknown
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			if (!isOpen)
			{
				return;
			}
			Matrix4x4 matrix = GUI.matrix;
			GUISkin skin = GUI.skin;
			Color contentColor = GUI.contentColor;
			bool enabled = GUI.enabled;
			IsDrawing = true;
			try
			{
				GUI.matrix = scale.Matrix;
				GUI.skin = theme.Skin;
				GUI.contentColor = theme.TextColor;
				EnsureStyles();
				cursor.Update(active: true);
				ClampWindowToScreen();
				bool flag = showConfirm || showItemPicker || showGlobalKeyPicker || showNewFile;
				bool enabled2 = GUI.enabled;
				GUI.enabled = enabled2 && !flag;
				Rect left = windowRect;
				windowRect = GUI.Window(924617, windowRect, new WindowFunction(DrawWindow), "Traders Extended configuration editor", windowStyle);
				GUI.enabled = enabled2;
				windowRect = ClampRect(windowRect);
				if (RectChanged(left, windowRect))
				{
					MarkLayoutDirty();
				}
				if (showConfirm)
				{
					CenterModal(ref confirmRect);
					confirmRect = GUI.Window(924621, confirmRect, new WindowFunction(DrawConfirmWindow), "Confirm", windowStyle);
					KeepPopupInFront(924621);
				}
				else if (showItemPicker)
				{
					CenterModal(ref itemPickerRect);
					itemPickerRect = GUI.Window(924619, itemPickerRect, new WindowFunction(DrawItemPickerWindow), itemPickerTitle, windowStyle);
					KeepPopupInFront(924619);
				}
				else if (showGlobalKeyPicker)
				{
					CenterModal(ref globalKeyRect);
					globalKeyRect = GUI.Window(924620, globalKeyRect, new WindowFunction(DrawGlobalKeyWindow), (keyPickerKind == KeyPickerKind.Global) ? "Select global keys" : "Select player keys", windowStyle);
					KeepPopupInFront(924620);
				}
				else if (showNewFile)
				{
					CenterModal(ref newFileRect);
					newFileRect = GUI.Window(924618, newFileRect, new WindowFunction(DrawNewFileWindow), "Create configuration", windowStyle);
					KeepPopupInFront(924618);
				}
				lastGuiExceptionSignature = string.Empty;
			}
			catch (Exception ex) when (!(ex is ExitGUIException))
			{
				string a = ex.GetType().FullName + ": " + ex.Message;
				if (!string.Equals(a, lastGuiExceptionSignature, StringComparison.Ordinal))
				{
					lastGuiExceptionSignature = a;
					ManualLogSource logger = TradersExtended.logger;
					if (logger != null)
					{
						logger.LogError((object)$"Configuration editor GUI error: {ex}");
					}
				}
				SetStatus("Editor GUI error: " + ex.Message, error: true);
			}
			finally
			{
				GUI.enabled = enabled;
				GUI.contentColor = contentColor;
				GUI.skin = skin;
				GUI.matrix = matrix;
				IsDrawing = false;
			}
		}

		public void Dispose()
		{
			ConfigEditorTransport.CancelPendingRequest();
			ConfigEditorTransport.ResponseReceived -= OnTransportResponse;
			ConfigEditorTransport.TransferProgress -= OnTransferProgress;
			cursor.Release();
			theme.Shutdown();
		}

		private void SetOpen(bool value)
		{
			if (isOpen == value)
			{
				return;
			}
			if (!value && IsDirty())
			{
				ShowConfirmation("Discard unsaved changes and close the editor?", delegate
				{
					SetOpenImmediate(value: false);
				});
			}
			else
			{
				SetOpenImmediate(value);
			}
		}

		private void SetOpenImmediate(bool value)
		{
			ConfigEditorTransport.CancelPendingRequest();
			requestInProgress = false;
			isOpen = value;
			if (value)
			{
				targetRevision = ConfigEditorTransport.TargetRevision;
				targetChanged = false;
				LoadLayout();
				traderDisplayNames.Clear();
				RefreshFiles();
				BuildItemOptions();
				return;
			}
			SaveLayout();
			activeFile = null;
			itemDocument = null;
			traderDocument = null;
			selectAfterList = null;
			files.Clear();
			showNewFile = false;
			showItemPicker = false;
			showGlobalKeyPicker = false;
			showConfirm = false;
			resizing = false;
			splitterDragging = false;
			itemOptions.Clear();
			itemOptionsByPrefab.Clear();
			itemOptionsBuilt = false;
			itemPrefabColumnWidthDirty = true;
			cursor.Release();
		}

		private void RequestClose()
		{
			SetOpen(value: false);
		}

		private void DrawWindow(int windowId)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			Vector2 mousePosition = current.mousePosition;
			bool flag = TryApplyRealtimeMousePosition(current);
			try
			{
				HandleResizeInput();
				GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
				DrawFileColumn();
				DrawColumnSplitter();
				DrawEditorColumn();
				GUILayout.EndHorizontal();
				if (requestInProgress || !string.IsNullOrWhiteSpace(statusText))
				{
					GUILayout.BeginHorizontal(toolbarStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) });
					GUILayout.Label(statusText ?? string.Empty, statusError ? errorStyle : mutedStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
					if (requestInProgress)
					{
						GUILayout.Label("Working...", mutedStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
					}
					GUILayout.EndHorizontal();
				}
				DrawWindowBorder();
				DrawResizeHandle();
				GUI.DragWindow(new Rect(0f, 0f, Mathf.Max(0f, ((Rect)(ref windowRect)).width - 4f), 22f));
			}
			finally
			{
				if (flag)
				{
					current.mousePosition = mousePosition;
				}
			}
		}

		private bool TryApplyRealtimeMousePosition(Event current)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0050: 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)
			if (current == null || ((int)current.type != 7 && (int)current.type != 8))
			{
				return false;
			}
			Vector2 val = scale.GetLogicalMousePosition() - ((Rect)(ref windowRect)).position;
			if (!IsFinite(val.x) || !IsFinite(val.y))
			{
				return false;
			}
			current.mousePosition = val;
			return true;
		}

		private static bool IsFinite(float value)
		{
			return !float.IsNaN(value) && !float.IsInfinity(value);
		}

		private static float GetHeaderToggleWidth(string text)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Ceil(GUI.skin.label.CalcSize(new GUIContent(text)).x + 22f);
		}

		private void DrawFileColumn()
		{
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(GetLeftPanelWidth()),
				GUILayout.ExpandHeight(true)
			});
			DrawFilePanel();
			GUILayout.EndVertical();
		}

		private void DrawEditorColumn()
		{
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			DrawEditorPanel();
			GUILayout.EndVertical();
		}

		private float GetLeftPanelWidth()
		{
			float num = TradersExtended.configEditorFileListWidth?.Value ?? 382f;
			float num2 = Mathf.Min(800f, Mathf.Max(240f, ((Rect)(ref windowRect)).width * 0.65f));
			return Mathf.Clamp(num, 240f, num2);
		}

		private void DrawColumnSplitter()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Invalid comparison between Unknown and I4
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Invalid comparison between Unknown and I4
			Rect rect = GUILayoutUtility.GetRect(7f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(7f),
				GUILayout.ExpandHeight(true)
			});
			GUI.Box(rect, GUIContent.none, splitterStyle);
			Event current = Event.current;
			if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref rect)).Contains(current.mousePosition))
			{
				splitterDragging = true;
				splitterDragStartMouse = current.mousePosition;
				splitterDragStartWidth = GetLeftPanelWidth();
				current.Use();
			}
			if (splitterDragging && (int)current.type == 3 && current.button == 0)
			{
				float num = Mathf.Min(800f, Mathf.Max(240f, ((Rect)(ref windowRect)).width * 0.65f));
				float value = Mathf.Clamp(splitterDragStartWidth + current.mousePosition.x - splitterDragStartMouse.x, 240f, num);
				if (TradersExtended.configEditorFileListWidth != null)
				{
					TradersExtended.configEditorFileListWidth.Value = value;
				}
				current.Use();
			}
			if (splitterDragging && (int)current.type == 1 && current.button == 0)
			{
				splitterDragging = false;
				current.Use();
			}
		}

		private void DrawFileActions()
		{
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && !requestInProgress;
			if (GUILayout.Button("Refresh", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(62f),
				GUILayout.Height(20f)
			}))
			{
				RefreshFiles();
			}
			if (GUILayout.Button("New", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(42f),
				GUILayout.Height(20f)
			}))
			{
				OpenNewFileWindow();
			}
			GUI.enabled = enabled && activeFile != null && !requestInProgress;
			if (GUILayout.Button("Delete", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(54f),
				GUILayout.Height(20f)
			}))
			{
				DeleteActiveFile();
			}
			GUI.enabled = enabled;
		}

		private void DrawEditorActions()
		{
			bool enabled = GUI.enabled;
			bool flag = activeFile != null && activeFile.Kind != EditorConfigKind.Unsupported && IsDirty() && !requestInProgress && !targetChanged;
			GUI.enabled = enabled && flag;
			GUIStyle val = (flag ? theme.AccentButtonStyle : smallButtonStyle);
			if (GUILayout.Button("Save", val, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(48f),
				GUILayout.Height(20f)
			}))
			{
				SaveActiveFile();
			}
			if (GUILayout.Button("Cancel", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(56f),
				GUILayout.Height(20f)
			}))
			{
				RevertActiveFile();
			}
			GUI.enabled = enabled;
		}

		private void DrawFilePanel()
		{
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(panelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			GUIStyle val = (ConfigEditorTransport.UsesRemoteServer ? serverSourceStyle : singleLineMutedStyle);
			string text = (targetChanged ? "PREVIOUS CONFIGURATION TARGET (READ ONLY)" : (ConfigEditorTransport.UsesRemoteServer ? "SERVER CONFIGURATION DIRECTORY" : "Local configuration directory"));
			GUILayout.Label(text, val, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(20f)
			});
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Search", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(50f),
				GUILayout.Height(20f)
			});
			fileSearch = GUILayout.TextField(fileSearch ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(20f)
			});
			if (GUILayout.Button("×", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(22f),
				GUILayout.Height(20f)
			}))
			{
				fileSearch = string.Empty;
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(4f);
			fileScroll = GUILayout.BeginScrollView(fileScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			List<EditorFileInfo> list = files.Where(FileMatchesSearch).ToList();
			DrawFileGroup("Buy items", list.Where((EditorFileInfo file) => file.Kind == EditorConfigKind.ItemList && file.ListType == TradersExtended.ItemsListType.Buy));
			DrawFileGroup("Sell items", list.Where((EditorFileInfo file) => file.Kind == EditorConfigKind.ItemList && file.ListType == TradersExtended.ItemsListType.Sell));
			DrawFileGroup("Trader Settings", list.Where((EditorFileInfo file) => file.Kind == EditorConfigKind.TraderSettings));
			DrawFileGroup("Other files", list.Where((EditorFileInfo file) => file.Kind == EditorConfigKind.Unsupported));
			if (list.Count == 0)
			{
				GUILayout.Label("No matching files.", mutedStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
			GUILayout.Space(2f);
			GUILayout.BeginHorizontal(toolbarStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) });
			DrawFileActions();
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private void DrawFileGroup(string title, IEnumerable<EditorFileInfo> source)
		{
			List<EditorFileInfo> list = source.OrderBy<EditorFileInfo, string>((EditorFileInfo file) => file.Trader, StringComparer.OrdinalIgnoreCase).ThenBy<EditorFileInfo, string>((EditorFileInfo file) => GetFileListDisplayName(file), StringComparer.OrdinalIgnoreCase).ToList();
			if (list.Count == 0)
			{
				return;
			}
			GUILayout.Label(title, headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(20f)
			});
			foreach (EditorFileInfo item in list)
			{
				DrawFileEntry(item);
			}
			GUILayout.Space(3f);
		}

		private void DrawFileEntry(EditorFileInfo file)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_0128: Expected O, but got Unknown
			GUIStyle val = ((activeFile != null && string.Equals(activeFile.Name, file.Name, StringComparison.OrdinalIgnoreCase)) ? selectedFileStyle : fileStyle);
			string fileListDisplayName = GetFileListDisplayName(file);
			float num = Mathf.Max(80f, GetLeftPanelWidth() - 28f);
			float num2 = Mathf.Max(titleStyle.lineHeight + 2f, fileNameStyle.CalcHeight(new GUIContent(fileListDisplayName), num));
			float num3 = Mathf.Max(30f, num2 + 10f);
			Rect rect = GUILayoutUtility.GetRect(0f, num3, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(num3)
			});
			if (GUI.Button(rect, GUIContent.none, val))
			{
				SelectFile(file);
			}
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 5f, Mathf.Max(0f, ((Rect)(ref rect)).width - 16f), num2);
			GUI.Label(val2, new GUIContent(fileListDisplayName, file.Name), fileNameStyle);
		}

		private string GetFileListDisplayName(EditorFileInfo file)
		{
			if (file == null)
			{
				return string.Empty;
			}
			string text = (string.Equals(file.Trader, "common", StringComparison.OrdinalIgnoreCase) ? "Common" : (file.Trader ?? string.Empty));
			string text2 = Path.GetExtension(file.Name).TrimStart(new char[1] { '.' }).ToLowerInvariant();
			if (file.Kind == EditorConfigKind.ItemList && TradersExtended.TryParseConfigFileName(file.Name, out var _, out var _, out var identifier))
			{
				return string.IsNullOrWhiteSpace(identifier) ? (text + " · " + text2) : (text + " · " + identifier + " · " + text2);
			}
			if (file.Kind == EditorConfigKind.TraderSettings)
			{
				return text + " · " + text2;
			}
			return file.Name;
		}

		private void DrawEditorPanel()
		{
			GUILayout.BeginVertical(panelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			DrawEditorHeader();
			if (activeFile == null)
			{
				GUILayout.FlexibleSpace();
				GUILayout.Label("Select a configuration file or create a new one.", titleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
				GUILayout.FlexibleSpace();
			}
			else if (activeFile.Kind == EditorConfigKind.Unsupported)
			{
				GUILayout.FlexibleSpace();
				GUILayout.Label("The file name does not match a supported Traders Extended configuration pattern.", errorStyle, Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
			}
			else if (itemDocument != null || traderDocument != null)
			{
				bool enabled = GUI.enabled;
				GUI.enabled = enabled && !requestInProgress && !targetChanged;
				try
				{
					if (itemDocument != null)
					{
						DrawItemEditor();
					}
					else
					{
						DrawTraderEditor();
					}
				}
				finally
				{
					GUI.enabled = enabled;
				}
			}
			else
			{
				GUILayout.FlexibleSpace();
				GUILayout.Label(requestInProgress ? "Loading configuration..." : "Configuration is not loaded.", mutedStyle, Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
			}
			GUILayout.EndVertical();
		}

		private void DrawEditorHeader()
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			float num = Mathf.Max(20f, titleStyle.lineHeight + 3f);
			float num2 = Mathf.Max(26f, num + 6f);
			GUILayout.BeginHorizontal(toolbarStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num2) });
			string text = ((activeFile == null) ? "No file selected" : ((itemDocument != null) ? $"{GetTraderDisplayName(activeFile.Trader)} — {activeFile.ListType}" : ((traderDocument != null) ? (GetTraderDisplayName(traderDocument.Trader) + " (" + traderDocument.Trader + ")") : "Configuration")));
			float num3 = Mathf.Ceil(titleStyle.CalcSize(new GUIContent(text)).x * 1.2f + 4f);
			GUILayout.Label(text, titleStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(num3),
				GUILayout.Height(num)
			});
			GUILayout.Space(8f);
			DrawEditorActions();
			GUILayout.Space(8f);
			string text2 = ((activeFile == null) ? string.Empty : activeFile.Name);
			GUILayout.Label(text2, pickerNameStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(false),
				GUILayout.Height(num)
			});
			GUILayout.FlexibleSpace();
			bool flag = Controls.ToggleLayout(theme, TradersExtended.configEditorBlockGameInput?.Value ?? false, new GUIContent("Prevent input", "Block all Valheim gameplay input while the configuration editor is open."), GetHeaderToggleWidth("Prevent input"));
			if (TradersExtended.configEditorBlockGameInput != null && flag != TradersExtended.configEditorBlockGameInput.Value)
			{
				TradersExtended.configEditorBlockGameInput.Value = flag;
			}
			if (GUILayout.Button("Close", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(52f),
				GUILayout.Height(20f)
			}))
			{
				RequestClose();
			}
			GUILayout.EndHorizontal();
		}

		private void DrawItemEditor()
		{
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			bool enabled = GUI.enabled;
			EnsureItemOptions();
			EnsureVisibleItemColumns();
			List<EditorItemRow> list = itemDocument.Rows.Where(ItemMatchesSearch).ToList();
			int num = Math.Max(1, (list.Count + 100 - 1) / 100);
			itemPage = Mathf.Clamp(itemPage, 0, num - 1);
			List<EditorItemRow> list2 = list.Skip(itemPage * 100).Take(100).ToList();
			GUILayout.BeginHorizontal(toolbarStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) });
			if (GUILayout.Button("Add item...", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(88f),
				GUILayout.Height(20f)
			}))
			{
				OpenItemPicker("Add item", delegate(string prefab)
				{
					AddItemRow(prefab);
				}, multiAdd: false);
			}
			GUILayout.Space(2f);
			if (GUILayout.Button("Add items...", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(92f),
				GUILayout.Height(20f)
			}))
			{
				OpenItemPicker("Add items", delegate(string prefab)
				{
					AddItemRow(prefab);
				}, multiAdd: true);
			}
			GUILayout.Space(2f);
			if (GUILayout.Button("Add blank", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(76f),
				GUILayout.Height(20f)
			}))
			{
				itemDocument.Rows.Add(new EditorItemRow(new TradersExtended.TradeableItem()));
				itemDocument.Dirty = true;
			}
			GUILayout.Space(2f);
			if (GUILayout.Button("Select filtered", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(100f),
				GUILayout.Height(20f)
			}))
			{
				foreach (EditorItemRow item in list)
				{
					item.Selected = true;
				}
			}
			GUILayout.Space(2f);
			if (GUILayout.Button("Clear selection", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(100f),
				GUILayout.Height(20f)
			}))
			{
				foreach (EditorItemRow row in itemDocument.Rows)
				{
					row.Selected = false;
				}
			}
			GUILayout.Space(2f);
			int num2 = itemDocument.Rows.Count((EditorItemRow row) => row.Selected);
			GUI.enabled = enabled && num2 > 0;
			if (GUILayout.Button($"Delete selected ({num2})", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(140f),
				GUILayout.Height(20f)
			}))
			{
				itemDocument.Rows.RemoveAll((EditorItemRow row) => row.Selected);
				itemDocument.Dirty = true;
			}
			GUI.enabled = enabled;
			GUILayout.Space(10f);
			GUILayout.Label("Search", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(50f),
				GUILayout.Height(20f)
			});
			string a = GUILayout.TextField(itemSearch ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(150f),
				GUILayout.Height(20f)
			});
			if (!string.Equals(a, itemSearch, StringComparison.Ordinal))
			{
				itemSearch = a;
				itemPage = 0;
			}
			if (GUILayout.Button("×", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(20f),
				GUILayout.Height(20f)
			}))
			{
				itemSearch = string.Empty;
				itemPage = 0;
			}
			GUILayout.FlexibleSpace();
			GUI.enabled = enabled && itemPage > 0;
			if (GUILayout.Button("◀", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(28f),
				GUILayout.Height(20f)
			}))
			{
				itemPage--;
				itemScroll = Vector2.zero;
			}
			GUI.enabled = enabled;
			GUILayout.Label($"Page {itemPage + 1}/{num}", centeredMutedStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(75f),
				GUILayout.Height(20f)
			});
			GUI.enabled = enabled && itemPage + 1 < num;
			if (GUILayout.Button("▶", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(28f),
				GUILayout.Height(20f)
			}))
			{
				itemPage++;
				itemScroll = Vector2.zero;
			}
			GUI.enabled = enabled;
			GUILayout.Label($"Rows: {itemDocument.Rows.Count}; filtered: {list.Count}", centeredMutedStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(180f),
				GUILayout.Height(20f)
			});
			GUILayout.EndHorizontal();
			itemScroll = GUILayout.BeginScrollView(itemScroll, true, true, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			DrawItemHeader();
			EditorItemRow editorItemRow = null;
			ItemRowAction itemRowAction = ItemRowAction.None;
			foreach (EditorItemRow item2 in list2)
			{
				int rowIndex = itemDocument.Rows.IndexOf(item2);
				ItemRowAction itemRowAction2 = DrawItemRow(item2, rowIndex);
				if (itemRowAction2 != ItemRowAction.None)
				{
					editorItemRow = item2;
					itemRowAction = itemRowAction2;
				}
			}
			GUILayout.EndScrollView();
			if (editorItemRow != null)
			{
				int num3 = itemDocument.Rows.IndexOf(editorItemRow);
				if (itemRowAction == ItemRowAction.Delete)
				{
					itemDocument.Rows.Remove(editorItemRow);
				}
				else if (itemRowAction == ItemRowAction.MoveUp && num3 > 0)
				{
					MoveItemRow(num3, num3 - 1);
				}
				else if (itemRowAction == ItemRowAction.MoveDown && num3 >= 0 && num3 + 1 < itemDocument.Rows.Count)
				{
					MoveItemRow(num3, num3 + 1);
				}
				itemDocument.Dirty = true;
			}
			DrawItemSortControls();
			DrawItemColumnVisibilityControls();
		}

		private void AddItemRow(string prefab)
		{
			itemDocument.Rows.Add(new EditorItemRow(new TradersExtended.TradeableItem
			{
				prefab = prefab
			}));
			itemDocument.Dirty = true;
		}

		private void DrawItemHeader()
		{
			float width = GetItemPrefabColumnWidth();
			GUILayout.BeginHorizontal(headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) });
			Header("", 22f);
			ItemColumnGap();
			Header("", 17f);
			ItemColumnGap();
			if (IsItemColumnVisible(ItemSortColumn.Prefab))
			{
				Header("Prefab", width);
				ItemColumnGap();
			}
			Header("", 18f);
			ItemColumnGap();
			Header("", 18f);
			ItemColumnGap();
			Header("", 18f);
			ItemColumnGap();
			if (IsItemColumnVisible(ItemSortColumn.LocalizedName))
			{
				Header("Localized name", 170f);
				ItemColumnGap();
			}
			Header("", 20f);
			ItemColumnGap();
			if (IsItemColumnVisible(ItemSortColumn.Stack))
			{
				Header("Stack", 55f);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.Price))
			{
				Header("Price", 60f);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.Quality))
			{
				Header("Quality", 55f);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.Currency))
			{
				Header("Currency", 140f);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.RequiredGlobalKey))
			{
				Header("Required global key", 155f);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.BlockedGlobalKey))
			{
				Header("Blocked global key", 155f);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.RequiredPlayerKey))
			{
				Header("Required player key", 150f);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.BlockedPlayerKey))
			{
				Header("Blocked player key", 150f);
			}
			GUILayout.EndHorizontal();
		}

		private ItemRowAction DrawItemRow(EditorItemRow row, int rowIndex)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Expected O, but got Unknown
			bool enabled = GUI.enabled;
			ItemRowValidation itemRowValidation = BuildItemRowValidation(row);
			row.ValidationError = itemRowValidation.Combined;
			float width = GetItemPrefabColumnWidth();
			ItemRowAction result = ItemRowAction.None;
			GUILayout.BeginHorizontal(itemRowStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) });
			bool flag = Controls.ToggleLayout(theme, row.Selected, GUIContent.none, 22f, mutedStyle, 0f);
			if (flag != row.Selected)
			{
				row.Selected = flag;
			}
			ItemColumnGap();
			if (!string.IsNullOrEmpty(itemRowValidation.Prefab))
			{
				GUILayout.Label(new GUIContent("!", itemRowValidation.Prefab), invalidItemIconStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(17f),
					GUILayout.Height(17f)
				});
			}
			else
			{
				DrawItemIcon(row.Item.prefab, 17f);
			}
			ItemColumnGap();
			if (IsItemColumnVisible(ItemSortColumn.Prefab))
			{
				string text = DrawValidatedTextField(row.Item.prefab ?? string.Empty, itemPrefabTextFieldStyle, string.Empty, width, 20f);
				if (!string.Equals(text, row.Item.prefab, StringComparison.Ordinal))
				{
					row.Item.prefab = text;
					itemDocument.Dirty = true;
				}
				ItemColumnGap();
			}
			if (DrawQuickActionButton("×", "Delete row"))
			{
				result = ItemRowAction.Delete;
			}
			ItemColumnGap();
			GUI.enabled = enabled && rowIndex > 0;
			if (DrawQuickActionButton("↑", "Move row up"))
			{
				result = ItemRowAction.MoveUp;
			}
			GUI.enabled = enabled;
			ItemColumnGap();
			GUI.enabled = enabled && rowIndex >= 0 && rowIndex + 1 < itemDocument.Rows.Count;
			if (DrawQuickActionButton("↓", "Move row down"))
			{
				result = ItemRowAction.MoveDown;
			}
			GUI.enabled = enabled;
			ItemColumnGap();
			if (IsItemColumnVisible(ItemSortColumn.LocalizedName))
			{
				string itemDisplayName = GetItemDisplayName(row.Item.prefab);
				GUILayout.Label(new GUIContent(itemDisplayName, itemDisplayName), pickerNameStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(170f),
					GUILayout.Height(20f)
				});
				ItemColumnGap();
			}
			if (DrawInlinePickerButton())
			{
				OpenItemPicker("Select item prefab", delegate(string value)
				{
					row.Item.prefab = value;
					itemDocument.Dirty = true;
				}, multiAdd: false);
			}
			ItemColumnGap();
			if (IsItemColumnVisible(ItemSortColumn.Stack))
			{
				DrawIntegerField(ref row.StackText, delegate(int value)
				{
					row.Item.stack = value;
				}, 55f, itemRowValidation.Stack);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.Price))
			{
				DrawIntegerField(ref row.PriceText, delegate(int value)
				{
					row.Item.price = value;
				}, 60f, itemRowValidation.Price);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.Quality))
			{
				DrawIntegerField(ref row.QualityText, delegate(int value)
				{
					row.Item.quality = value;
				}, 55f, itemRowValidation.Quality);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.Currency))
			{
				DrawPrefabField(row.Item.currency, delegate(string value)
				{
					row.Item.currency = value;
				}, 140f, "Select currency item", itemRowValidation.Currency);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.RequiredGlobalKey))
			{
				DrawKeyField(row.Item.requiredGlobalKey, delegate(string value)
				{
					row.Item.requiredGlobalKey = value;
				}, 155f, KeyPickerKind.Global, itemRowValidation.RequiredGlobalKey);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.BlockedGlobalKey))
			{
				DrawKeyField(row.Item.notRequiredGlobalKey, delegate(string value)
				{
					row.Item.notRequiredGlobalKey = value;
				}, 155f, KeyPickerKind.Global, itemRowValidation.BlockedGlobalKey);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.RequiredPlayerKey))
			{
				DrawKeyField(row.Item.requiredPlayerKey, delegate(string value)
				{
					row.Item.requiredPlayerKey = value;
				}, 150f, KeyPickerKind.Player, itemRowValidation.RequiredPlayerKey);
				ItemColumnGap();
			}
			if (IsItemColumnVisible(ItemSortColumn.BlockedPlayerKey))
			{
				DrawKeyField(row.Item.notRequiredPlayerKey, delegate(string value)
				{
					row.Item.notRequiredPlayerKey = value;
				}, 150f, KeyPickerKind.Player, itemRowValidation.BlockedPlayerKey);
			}
			GUILayout.EndHorizontal();
			if (itemRowValidation.HasErrors)
			{
				Rect lastRect = GUILayoutUtility.GetLastRect();
				DrawOutline(lastRect, new Color(0.9f, 0.2f, 0.18f, 1f), 1f);
				GUI.Label(lastRect, new GUIContent(string.Empty, itemRowValidation.Combined), GUIStyle.none);
			}
			return result;
		}

		private void MoveItemRow(int sourceIndex, int destinationIndex)
		{
			if (sourceIndex >= 0 && destinationIndex >= 0 && sourceIndex < itemDocument.Rows.Count && destinationIndex < itemDocument.Rows.Count && sourceIndex != destinationIndex)
			{
				EditorItemRow item = itemDocument.Rows[sourceIndex];
				itemDocument.Rows.RemoveAt(sourceIndex);
				itemDocument.Rows.Insert(destinationIndex, item);
			}
		}

		private void DrawItemSortControls()
		{
			int num = itemDocument.Rows.Count((EditorItemRow row) => row.Selected);
			bool flag = num > 1;
			GUILayout.BeginHorizontal(toolbarStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) });
			GUILayout.Label(flag ? "Sort selected by:" : "Sort by:", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(flag ? 102f : 48f),
				GUILayout.Height(20f)
			});
			DrawItemSortCommand("Prefab", ItemSortColumn.Prefab, 48f, flag);
			DrawItemSortCommand("Name", ItemSortColumn.LocalizedName, 40f, flag);
			DrawItemSortCommand("Stack", ItemSortColumn.Stack, 40f, flag);
			DrawItemSortCommand("Price", ItemSortColumn.Price, 36f, flag);
			DrawItemSortCommand("Quality", ItemSortColumn.Quality, 46f, flag);
			DrawItemSortCommand("Currency", ItemSortColumn.Currency, 58f, flag);
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
		}

		private void DrawItemSortCommand(string label, ItemSortColumn column, float labelWidth, bool selectedOnly)
		{
			GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(labelWidth),
				GUILayout.Height(20f)
			});
			if (GUILayout.Button("↑", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(22f),
				GUILayout.Height(20f)
			}))
			{
				SortItemRows(column, ascending: true, selectedOnly);
			}
			if (GUILayout.Button("↓", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(22f),
				GUILayout.Height(20f)
			}))
			{
				SortItemRows(column, ascending: false, selectedOnly);
			}
			GUILayout.Space(5f);
		}

		private void DrawItemColumnVisibilityControls()
		{
			GUILayout.BeginHorizontal(toolbarStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(29f) });
			GUILayout.Label("Columns:", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(58f),
				GUILayout.Height(20f)
			});
			DrawItemColumnToggle(ItemSortColumn.Prefab, "Prefab", 72f);
			DrawItemColumnToggle(ItemSortColumn.LocalizedName, "Name", 62f);
			DrawItemColumnToggle(ItemSortColumn.Stack, "Stack", 62f);
			DrawItemColumnToggle(ItemSortColumn.Price, "Price", 58f);
			DrawItemColumnToggle(ItemSortColumn.Quality, "Quality", 70f);
			DrawItemColumnToggle(ItemSortColumn.Currency, "Currency", 82f);
			DrawItemColumnToggle(ItemSortColumn.RequiredGlobalKey, "Req global", 96f);
			DrawItemColumnToggle(ItemSortColumn.BlockedGlobalKey, "Block global", 104f);
			DrawItemColumnToggle(ItemSortColumn.RequiredPlayerKey, "Req player", 96f);
			DrawItemColumnToggle(ItemSortColumn.BlockedPlayerKey, "Block player", 104f);
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
		}

		private void DrawItemColumnToggle(ItemSortColumn column, string label, float width)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			bool flag = IsItemColumnVisible(column);
			bool flag2 = Controls.ToggleLayout(theme, flag, new GUIContent(label), width, singleLineMutedStyle, 0f, 22f);
			if (flag2 != flag)
			{
				SetItemColumnVisible(column, flag2);
			}
		}

		private void DrawTraderEditor()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("Enable Override for a field to store a trader-specific value. Disabled fields inherit the synchronized BepInEx configuration.", mutedStyle, Array.Empty<GUILayoutOption>());
			settingsScroll = GUILayout.BeginScrollView(settingsScroll, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			foreach (IGrouping<string, TraderSettingState> item in from state in traderDocument.Settings
				group state by state.Definition.Section)
			{
				GUILayout.Label("— " + item.Key + " —", headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(20f) });
				foreach (TraderSettingState item2 in item)
				{
					DrawTraderSetting(item2);
				}
			}
			GUILayout.EndScrollView();
		}

		private void DrawTraderSetting(TraderSettingState state)
		{
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			bool enabled = GUI.enabled;
			GUILayout.BeginVertical(rowStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			bool flag = Controls.ToggleLayout(theme, state.HasOverride, GUIContent.none, 22f, mutedStyle, 0f);
			if (flag != state.HasOverride)
			{
				state.HasOverride = flag;
				if (flag)
				{
					state.Value = state.Definition.Fallback(traderDocument.Trader);
					state.EditText = TraderConfigSchema.FormatEditText(state.Definition.Type, state.Value);
					state.ValidationError = string.Empty;
					if (state.Definition.Type == TraderSettingType.Vector2)
					{
						Vector2 val = ((state.Value is Vector2 val2) ? val2 : Vector2.zero);
						state.VectorXText = val.x.ToString("0.###", CultureInfo.InvariantCulture);
						state.VectorYText = val.y.ToString("0.###", CultureInfo.InvariantCulture);
					}
				}
				traderDocument.Dirty = true;
			}
			GUILayout.Label(new GUIContent(state.Definition.Name, state.Definition.Description), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(360f) });
			GUI.enabled = enabled && state.HasOverride;
			DrawTraderValue(state);
			GUI.enabled = enabled;
			if (!state.HasOverride)
			{
				GUILayout.Label("Inherited: " + FormatValue(state.Definition.Type, state.Definition.Fallback(traderDocument.Trader)), mutedStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(240f) });
			}
			GUILayout.EndHorizontal();
			if (state.HasOverride && !string.IsNullOrWhiteSpace(state.ValidationError))
			{
				GUILayout.Label(state.ValidationError, errorStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
		}

		private void DrawTraderValue(TraderSettingState state)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			switch (state.Definition.Type)
			{
			case TraderSettingType.Boolean:
			{
				object value = state.Value;
				bool flag = default(bool);
				int num;
				if (value is bool)
				{
					flag = (bool)value;
					num = 1;
				}
				else
				{
					num = 0;
				}
				bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0;
				bool flag3 = Controls.ToggleLayout(theme, flag2, new GUIContent(flag2 ? "Enabled" : "Disabled"), 150f);
				if (flag3 != flag2)
				{
					state.Value = flag3;
					state.ValidationError = string.Empty;
					traderDocument.Dirty = true;
				}
				break;
			}
			case TraderSettingType.Integer:
			{
				string text4 = GUILayout.TextField(state.EditText ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) });
				if (!string.Equals(text4, state.EditText, StringComparison.Ordinal))
				{
					state.EditText = text4;
					traderDocument.Dirty = true;
					if (int.TryParse(text4, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result4))
					{
						state.Value = result4;
						state.ValidationError = string.Empty;
						traderDocument.Dirty = true;
					}
					else
					{
						state.ValidationError = "Enter a valid integer.";
					}
				}
				break;
			}
			case TraderSettingType.Float:
			{
				string text3 = GUILayout.TextField(state.EditText ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) });
				if (!string.Equals(text3, state.EditText, StringComparison.Ordinal))
				{
					state.EditText = text3;
					traderDocument.Dirty = true;
					if (float.TryParse(text3, NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && IsFinite(result3))
					{
						state.Value = result3;
						state.ValidationError = string.Empty;
						traderDocument.Dirty = true;
					}
					else
					{
						state.ValidationError = "Enter a valid number using a dot as the decimal separator.";
					}
				}
				break;
			}
			case TraderSettingType.String:
			{
				string text5 = state.Value?.ToString() ?? string.Empty;
				string text6 = GUILayout.TextField(text5, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.MinWidth(260f),
					GUILayout.ExpandWidth(true)
				});
				if (!string.Equals(text5, text6, StringComparison.Ordinal))
				{
					state.Value = text6;
					state.ValidationError = string.Empty;
					traderDocument.Dirty = true;
				}
				break;
			}
			case TraderSettingType.ItemPrefab:
			{
				string text7 = state.Value?.ToString() ?? string.Empty;
				string text8 = GUILayout.TextField(text7, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(125f),
					GUILayout.Height(20f)
				});
				if (!string.Equals(text7, text8, StringComparison.Ordinal))
				{
					state.Value = text8;
					state.ValidationError = ValidateItemPrefab(text8);
					traderDocument.Dirty = true;
				}
				else
				{
					state.ValidationError = (state.HasOverride ? ValidateItemPrefab(text7) : string.Empty);
				}
				if (DrawInlinePickerButton())
				{
					OpenItemPicker("Select item prefab", delegate(string prefab)
					{
						state.Value = prefab;
						state.EditText = prefab;
						state.ValidationError = string.Empty;
						traderDocument.Dirty = true;
					}, multiAdd: false);
				}
				GUILayout.Label(GetItemDisplayName(state.Value?.ToString()), pickerNameStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(150f),
					GUILayout.Height(20f)
				});
				break;
			}
			case TraderSettingType.Vector2:
			{
				GUILayout.Label("x", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(12f) });
				string text = GUILayout.TextField(state.VectorXText ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(85f) });
				GUILayout.Label("y", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(12f) });
				string text2 = GUILayout.TextField(state.VectorYText ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(85f) });
				if (!string.Equals(text, state.VectorXText, StringComparison.Ordinal) || !string.Equals(text2, state.VectorYText, StringComparison.Ordinal))
				{
					state.VectorXText = text;
					state.VectorYText = text2;
					traderDocument.Dirty = true;
					if (float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(text2, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && IsFinite(result) && IsFinite(result2))
					{
						state.Value = (object)new Vector2(result, result2);
						state.ValidationError = string.Empty;
						traderDocument.Dirty = true;
					}
					else
					{
						state.ValidationError = "Both x and y must be valid numbers using a dot as the decimal separator.";
					}
				}
				break;
			}
			}
		}

		private void DrawNewFileWindow(int windowId)
		{
			//IL_0014: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			bool enabled = GUI.enabled;
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			newFileScroll = GUILayout.BeginScrollView(newFileScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			GUILayout.Label("Configuration type", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Item list", (newFileKind == EditorConfigKind.ItemList) ? theme.AccentButtonStyle : smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				newFileKind = EditorConfigKind.ItemList;
			}
			if (GUILayout.Button("Trader settings", (newFileKind == EditorConfigKind.TraderSettings) ? theme.AccentButtonStyle : smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				newFileKind = EditorConfigKind.TraderSettings;
				if (string.Equals(newFileTrader, "common", StringComparison.OrdinalIgnoreCase))
				{
					newFileTrader = "Haldor";
				}
				if (newFileExtension == "csv")
				{
					newFileExtension = "json";
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(8f);
			GUILayout.Label("Trader prefab", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			newFileTrader = GUILayout.TextField(newFileTrader ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (GUILayout.Button("Select...", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
			{
				OpenTraderPicker();
			}
			GUILayout.EndHorizontal();
			GUILayout.Label(GetTraderDisplayName(newFileTrader), mutedStyle, Array.Empty<GUILayoutOption>());
			if (newFileKind == EditorConfigKind.ItemList)
			{
				GUILayout.Space(8f);
				GUILayout.Label("List type", headerStyle, Array.Empty<GUILayoutOption>());
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				if (GUILayout.Button("Buy", (newFileListType == TradersExtended.ItemsListType.Buy) ? theme.AccentButtonStyle : smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
				{
					newFileListType = TradersExtended.ItemsListType.Buy;
				}
				if (GUILayout.Button("Sell", (newFileListType == TradersExtended.ItemsListType.Sell) ? theme.AccentButtonStyle : smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
				{
					newFileListType = TradersExtended.ItemsListType.Sell;
				}
				GUILayout.EndHorizontal();
				GUILayout.Label("Optional dot-separated identifier", headerStyle, Array.Empty<GUILayoutOption>());
				newFileIdentifier = GUILayout.TextField(newFileIdentifier ?? string.Empty, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(8f);
			GUILayout.Label("File format", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			DrawFormatToggle("json");
			DrawFormatToggle("yaml");
			DrawFormatToggle("yml");
			if (newFileKind == EditorConfigKind.ItemList)
			{
				DrawFormatToggle("csv");
			}
			GUILayout.EndHorizontal();
			string text = BuildNewFileName();
			GUILayout.Space(8f);
			GUILayout.Label("File name", headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label(text, panelStyle, Array.Empty<GUILayoutOption>());
			string text2 = ValidateNewFile(text);
			if (!string.IsNullOrEmpty(text2))
			{
				GUILayout.Label(text2, errorStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
			GUILayout.BeginHorizontal(toolbarStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) });
			GUI.enabled = enabled && string.IsNullOrEmpty(text2) && !requestInProgress;
			if (GUILayout.Button("Create", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				CreateNewFile(text);
			}
			GUI.enabled = enabled;
			if (GUILayout.Button("Cancel", smallButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				showNewFile = false;
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			DrawModalBorder(((Rect)(ref newFileRect)).width, ((Rect)(ref newFileRect)).height);
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref newFileRect)).width, 22f));
		}

		private void DrawItemPickerWindow(int windowId)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0761: Unknown result type (might be due to invalid IL or missing references)
			//IL_0766: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			bool enabled = GUI.enabled;
			bool flag = temporaryTraderOptions != null;
			bool flag2 = false;
			string text = null;
			string value = null;
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(18f) });
			GUILayout.Label("Search", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(49f),
				GUILayout.Height(18f)
			});
			string a = GUILayout.TextField(itemPickerSearch ?? st