Decompiled source of BetterUI v0.9.5

BepInEx\plugins\BetterUI\InfernoProtocol.BetterUI.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Game.Data;
using Game.UI;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("InfernoProtocol.BetterUI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.9.5.0")]
[assembly: AssemblyInformationalVersion("0.9.5+477d00f8c6e6102e4d9ad948d3169f90685e9781")]
[assembly: AssemblyProduct("InfernoProtocol.BetterUI")]
[assembly: AssemblyTitle("InfernoProtocol.BetterUI")]
[assembly: AssemblyVersion("0.9.5.0")]
namespace InfernoProtocol.BetterUI;

public sealed class BetterUIController : MonoBehaviour
{
	private readonly CraftingMenuOverhaul _craftingMenu = new CraftingMenuOverhaul();

	private float _nextRefresh;

	private float _retryAt;

	private bool _sessionEnabled = true;

	private bool _craftingOpen;

	private bool _failureReported;

	public BetterUIController(IntPtr pointer)
		: base(pointer)
	{
	}

	private void Update()
	{
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Expected O, but got Unknown
		HandleToggle();
		CraftingTableUI instance = MonoSingleton<CraftingTableUI>.instance;
		if (!_sessionEnabled || !BetterUIPlugin.Enabled.Value || !_craftingOpen || (Object)(object)instance == (Object)null)
		{
			_craftingMenu.SetVisible(visible: false);
			return;
		}
		_craftingMenu.SetVisible(visible: true);
		if (_craftingMenu.HandleInput())
		{
			_nextRefresh = 0f;
		}
		_craftingMenu.RefreshCraftingProgress(instance);
		float unscaledTime = Time.unscaledTime;
		if (unscaledTime < _nextRefresh || unscaledTime < _retryAt)
		{
			return;
		}
		_nextRefresh = unscaledTime + BetterUIPlugin.RefreshSeconds;
		try
		{
			_craftingMenu.Apply(instance);
			_retryAt = 0f;
			_failureReported = false;
		}
		catch (Exception ex)
		{
			_retryAt = unscaledTime + 2f;
			if (!_failureReported)
			{
				_failureReported = true;
				ManualLogSource modLog = BetterUIPlugin.ModLog;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not style the crafting menu; retrying: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				modLog.LogWarning(val);
			}
		}
	}

	private void HandleToggle()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		Keyboard current = Keyboard.current;
		if (current != null && ((ButtonControl)current.f8Key).wasPressedThisFrame)
		{
			_sessionEnabled = !_sessionEnabled;
			if (!_sessionEnabled)
			{
				_craftingMenu.SetVisible(visible: false);
			}
			ManualLogSource modLog = BetterUIPlugin.ModLog;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("BetterUI crafting menu ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_sessionEnabled ? "enabled" : "paused");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" for this session");
			}
			modLog.LogInfo(val);
			_nextRefresh = 0f;
		}
	}

	internal void SetCraftingOpen(bool open)
	{
		_craftingOpen = open;
		_nextRefresh = 0f;
		if (!open)
		{
			_craftingMenu.SetVisible(visible: false);
		}
	}
}
[BepInPlugin("com.holden.infernoprotocol.betterui", "BetterUI", "0.9.5")]
public sealed class BetterUIPlugin : BasePlugin
{
	[HarmonyPatch]
	private static class CraftingVisibilityPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(CraftingTableUI), "Show")]
		private static void AfterShow()
		{
			SetCraftingOpen(open: true);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CraftingTableUI), "Hide")]
		private static void AfterHide()
		{
			SetCraftingOpen(open: false);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CraftingTableUI), "HideRaw")]
		private static void AfterHideRaw()
		{
			SetCraftingOpen(open: false);
		}
	}

	private static BetterUIController _controller;

	private Harmony _harmony;

	internal static ManualLogSource ModLog { get; private set; }

	internal static ConfigEntry<bool> Enabled { get; private set; }

	internal static ConfigEntry<float> RefreshInterval { get; private set; }

	internal static ConfigEntry<int> ColorPalette { get; private set; }

	internal static float RefreshSeconds => Sanitize(RefreshInterval.Value, 0.5f, 0.2f, 5f);

	internal static int PaletteIndex
	{
		get
		{
			if (ColorPalette == null)
			{
				return 0;
			}
			return Mathf.Clamp(ColorPalette.Value, 0, 4);
		}
	}

	public override void Load()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Expected O, but got Unknown
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Expected O, but got Unknown
		ModLog = ((BasePlugin)this).Log;
		Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enables the BetterUI crafting menu. F8 pauses or resumes it for the current session.");
		RefreshInterval = ((BasePlugin)this).Config.Bind<float>("General", "RefreshInterval", 0.5f, new ConfigDescription("Seconds between lightweight crafting-menu state refreshes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 5f), Array.Empty<object>()));
		ColorPalette = ((BasePlugin)this).Config.Bind<int>("Crafting", "ColorPalette", 0, new ConfigDescription("Remembered crafting-terminal palette: 0 green, 1 blue, 2 cyan, 3 violet, 4 amber.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), Array.Empty<object>()));
		_controller = ((BasePlugin)this).AddComponent<BetterUIController>();
		_harmony = new Harmony("com.holden.infernoprotocol.betterui");
		_harmony.PatchAll(typeof(CraftingVisibilityPatches));
		ManualLogSource log = ((BasePlugin)this).Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BetterUI");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.9.5");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded");
		}
		log.LogInfo(val);
	}

	public override bool Unload()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		_harmony = null;
		if ((Object)(object)_controller != (Object)null)
		{
			Object.Destroy((Object)(object)_controller);
			_controller = null;
		}
		return true;
	}

	internal static void SetCraftingOpen(bool open)
	{
		_controller?.SetCraftingOpen(open);
	}

	internal static void CyclePalette()
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		if (ColorPalette != null)
		{
			ColorPalette.Value = (PaletteIndex + 1) % 5;
			string[] array = new string[5] { "green", "blue", "cyan", "violet", "amber" };
			ManualLogSource modLog = ModLog;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("BetterUI crafting palette changed to ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(array[PaletteIndex]);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
			}
			modLog.LogInfo(val);
		}
	}

	private static float Sanitize(float value, float fallback, float minimum, float maximum)
	{
		if (!float.IsNaN(value) && !float.IsInfinity(value))
		{
			return Mathf.Clamp(value, minimum, maximum);
		}
		return fallback;
	}
}
internal enum ButtonVariant
{
	Secondary,
	Primary,
	Danger
}
internal static class BetterUIStyler
{
	internal static Image Surface(RectTransform rect, Color fill, Color border, bool addShadow = true)
	{
		//IL_002f: 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)
		if ((Object)(object)rect == (Object)null)
		{
			return null;
		}
		Image val = ((Component)rect).GetComponent<Image>();
		if ((Object)(object)val == (Object)null)
		{
			val = ((Component)rect).gameObject.AddComponent<Image>();
			((Graphic)val).raycastTarget = false;
		}
		RoundedImage(val, fill);
		Effects((Graphic)(object)val, border, addShadow);
		return val;
	}

	internal static void RoundedImage(Image image, Color color)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)image == (Object)null))
		{
			image.sprite = BetterUITheme.RoundedSprite;
			image.type = (Type)1;
			((Graphic)image).color = color;
		}
	}

	internal static void Tint(Image image, Color color)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)image != (Object)null)
		{
			((Graphic)image).color = color;
		}
	}

	internal static void Effects(Graphic target, Color border, bool addShadow)
	{
		//IL_0027: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)target == (Object)null)
		{
			return;
		}
		Outline val = ((Component)target).GetComponent<Outline>();
		if ((Object)(object)val == (Object)null)
		{
			val = ((Component)target).gameObject.AddComponent<Outline>();
		}
		((Shadow)val).effectColor = border;
		((Shadow)val).effectDistance = new Vector2(1.25f, -1.25f);
		((Shadow)val).useGraphicAlpha = true;
		Shadow val2 = null;
		Il2CppArrayBase<Shadow> components = ((Component)target).GetComponents<Shadow>();
		for (int i = 0; i < components.Length; i++)
		{
			Shadow val3 = components[i];
			if ((Object)(object)val3 != (Object)null && (Object)(object)((Il2CppObjectBase)val3).TryCast<Outline>() == (Object)null)
			{
				val2 = val3;
				break;
			}
		}
		if (!addShadow)
		{
			if ((Object)(object)val2 != (Object)null && ColorsMatch(val2.effectColor, BetterUITheme.Shadow))
			{
				((Behaviour)val2).enabled = false;
			}
			return;
		}
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = ((Component)target).gameObject.AddComponent<Shadow>();
		}
		((Behaviour)val2).enabled = true;
		val2.effectColor = BetterUITheme.Shadow;
		val2.effectDistance = new Vector2(0f, -4f);
		val2.useGraphicAlpha = true;
	}

	private static bool ColorsMatch(Color left, Color right)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		if (Mathf.Abs(left.r - right.r) < 0.002f && Mathf.Abs(left.g - right.g) < 0.002f && Mathf.Abs(left.b - right.b) < 0.002f)
		{
			return Mathf.Abs(left.a - right.a) < 0.002f;
		}
		return false;
	}

	internal static void Text(TMP_Text text, float size, Color color, FontStyles style, bool preserveSize = false)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)text == (Object)null))
		{
			text.enableAutoSizing = false;
			if (!preserveSize)
			{
				text.fontSize = size;
			}
			((Graphic)text).color = color;
			text.fontStyle = style;
			((Graphic)text).raycastTarget = false;
		}
	}

	internal static void Heading(TMP_Text text, float size)
	{
		//IL_0002: 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)
		Text(text, size, BetterUITheme.Text, (FontStyles)1);
		if (!((Object)(object)text == (Object)null))
		{
			text.characterSpacing = 2.2f;
			text.outlineWidth = 0.12f;
			text.outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)190);
		}
	}

	internal static void Button(MazeButton button, ButtonVariant variant)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: 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_004d: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: 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_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)button == (Object)null)
		{
			return;
		}
		Color val = default(Color);
		Color slotHover = default(Color);
		Color border;
		Color val2;
		switch (variant)
		{
		case ButtonVariant.Primary:
			((Color)(ref val))..ctor(BetterUITheme.Primary.r, BetterUITheme.Primary.g, BetterUITheme.Primary.b, 0.18f);
			((Color)(ref slotHover))..ctor(BetterUITheme.PrimaryHover.r, BetterUITheme.PrimaryHover.g, BetterUITheme.PrimaryHover.b, 0.34f);
			border = BetterUITheme.Primary;
			val2 = BetterUITheme.PrimaryHover;
			break;
		case ButtonVariant.Danger:
			val = BetterUITheme.DangerSoft;
			((Color)(ref slotHover))..ctor(BetterUITheme.Danger.r, BetterUITheme.Danger.g, BetterUITheme.Danger.b, 0.34f);
			border = BetterUITheme.Danger;
			val2 = BetterUITheme.Text;
			break;
		default:
			val = BetterUITheme.PanelSoft;
			slotHover = BetterUITheme.SlotHover;
			border = BetterUITheme.Border;
			val2 = BetterUITheme.TextMuted;
			break;
		}
		button.backgroundColor = val;
		button.hoverColor = slotHover;
		button.textColor = val2;
		button.hoverTextColor = BetterUITheme.Text;
		Graphic backgroundImage = button.backgroundImage;
		Image val3 = (((Object)(object)backgroundImage != (Object)null) ? ((Il2CppObjectBase)backgroundImage).TryCast<Image>() : null);
		if ((Object)(object)val3 != (Object)null)
		{
			RoundedImage(val3, val);
			Effects((Graphic)(object)val3, border, addShadow: false);
			Outline component = ((Component)val3).GetComponent<Outline>();
			if ((Object)(object)component != (Object)null)
			{
				((Shadow)component).effectDistance = new Vector2(0.65f, -0.65f);
			}
		}
		if ((Object)(object)button.buttonText != (Object)null)
		{
			Text((TMP_Text)(object)button.buttonText, Mathf.Max(15f, ((TMP_Text)button.buttonText).fontSize), val2, (FontStyles)1);
			((TMP_Text)button.buttonText).characterSpacing = 0.8f;
		}
		LayoutElement val4 = ((Component)button).GetComponent<LayoutElement>();
		if ((Object)(object)val4 == (Object)null)
		{
			val4 = ((Component)button).gameObject.AddComponent<LayoutElement>();
		}
		val4.minHeight = 42f;
		button.UpdateVisualState(true);
	}

	internal static void ToggleButton(MazeButton button, bool active)
	{
		//IL_0014: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)button == (Object)null)
		{
			return;
		}
		Color val = (active ? BetterUITheme.AccentSoft : BetterUITheme.PanelSoft);
		Color hoverColor = (active ? BetterUITheme.CraftingSelectedHover : BetterUITheme.SlotHover);
		Color border = (active ? BetterUITheme.Accent : BetterUITheme.BorderSoft);
		Color val2 = (active ? BetterUITheme.Text : BetterUITheme.TextMuted);
		button.backgroundColor = val;
		button.hoverColor = hoverColor;
		button.textColor = val2;
		button.hoverTextColor = BetterUITheme.Text;
		Graphic backgroundImage = button.backgroundImage;
		Image val3 = (((Object)(object)backgroundImage != (Object)null) ? ((Il2CppObjectBase)backgroundImage).TryCast<Image>() : null);
		if ((Object)(object)val3 != (Object)null)
		{
			RoundedImage(val3, val);
			Effects((Graphic)(object)val3, border, addShadow: false);
			Outline component = ((Component)val3).GetComponent<Outline>();
			if ((Object)(object)component != (Object)null)
			{
				((Shadow)component).effectDistance = new Vector2(0.65f, -0.65f);
			}
		}
		if ((Object)(object)button.buttonText != (Object)null)
		{
			Text((TMP_Text)(object)button.buttonText, 14f, val2, (FontStyles)1);
			((TMP_Text)button.buttonText).characterSpacing = 0.5f;
		}
	}

	internal static void InputField(TMP_InputField input)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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)
		if (!((Object)(object)input == (Object)null))
		{
			Image component = ((Component)input).GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				RoundedImage(component, BetterUITheme.PanelElevated);
				Effects((Graphic)(object)component, BetterUITheme.Border, addShadow: false);
			}
			Text(input.textComponent, 16f, BetterUITheme.Text, (FontStyles)0);
			Text(((Object)(object)input.placeholder != (Object)null) ? ((Il2CppObjectBase)input.placeholder).TryCast<TMP_Text>() : null, 16f, BetterUITheme.TextDim, (FontStyles)2);
			input.selectionColor = BetterUITheme.AccentSoft;
			input.caretColor = BetterUITheme.Accent;
			input.caretWidth = 2;
		}
	}

	internal static void Scrollbars(Transform root)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)root == (Object)null)
		{
			return;
		}
		Il2CppArrayBase<Scrollbar> componentsInChildren = ((Component)root).GetComponentsInChildren<Scrollbar>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Scrollbar val = componentsInChildren[i];
			if (!((Object)(object)val == (Object)null))
			{
				Image component = ((Component)val).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					RoundedImage(component, new Color(BetterUITheme.PanelSoft.r, BetterUITheme.PanelSoft.g, BetterUITheme.PanelSoft.b, 0.62f));
				}
				Image val2 = (((Object)(object)val.handleRect != (Object)null) ? ((Component)val.handleRect).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					RoundedImage(val2, BetterUITheme.Accent);
					Effects((Graphic)(object)val2, new Color(1f, 1f, 1f, 0.24f), addShadow: false);
				}
				ColorBlock colors = ((Selectable)val).colors;
				((ColorBlock)(ref colors)).normalColor = BetterUITheme.TextMuted;
				((ColorBlock)(ref colors)).highlightedColor = BetterUITheme.Text;
				((ColorBlock)(ref colors)).pressedColor = BetterUITheme.Accent;
				((ColorBlock)(ref colors)).disabledColor = BetterUITheme.TextDim;
				((ColorBlock)(ref colors)).fadeDuration = 0.08f;
				((Selectable)val).colors = colors;
			}
		}
	}

	internal static ButtonVariant ClassifyButton(MazeButton button)
	{
		string text = (((Object)(object)button != (Object)null && (Object)(object)button.buttonText != (Object)null) ? ((TMP_Text)button.buttonText).text.ToUpperInvariant() : string.Empty);
		if (text.Contains("CLOSE") || text.Contains("DROP") || text.Contains("REMOVE") || text.Contains("DELETE"))
		{
			return ButtonVariant.Danger;
		}
		if (text.Contains("CRAFT") || text.Contains("PACK") || text.Contains("CONFIRM") || text.Contains("APPLY") || text.Contains("PLACE"))
		{
			return ButtonVariant.Primary;
		}
		return ButtonVariant.Secondary;
	}
}
internal static class BetterUITheme
{
	private sealed class Palette
	{
		internal Color Scrim;

		internal Color Panel;

		internal Color PanelElevated;

		internal Color PanelSoft;

		internal Color CraftingCanvas;

		internal Color CraftingWell;

		internal Color CraftingReady;

		internal Color CraftingSelected;

		internal Color CraftingSelectedHover;

		internal Color Slot;

		internal Color SlotHover;

		internal Color SlotSelected;

		internal Color Border;

		internal Color BorderSoft;

		internal Color CardBorder;

		internal Color Accent;

		internal Color AccentSoft;

		internal Color Primary;

		internal Color PrimaryHover;

		internal Color PrimarySoft;

		internal Color Success;

		internal Color SuccessSoft;

		internal Color Text;

		internal Color TextMuted;

		internal Color TextUnavailable;

		internal Color TextDim;

		internal Color Shadow;
	}

	internal const int PaletteCount = 5;

	internal static readonly Color Danger = Hex("FFB45C", 1f);

	internal static readonly Color DangerSoft = Hex("FFB45C", 0.18f);

	internal static readonly Color CountBackground = Hex("010302", 0.94f);

	private static readonly Texture2D[] CategoryIcons = (Texture2D[])(object)new Texture2D[5];

	private static int _cachedPaletteIndex = -1;

	private static Palette _current;

	private static Sprite _roundedSprite;

	private static Texture2D _scanlineTexture;

	private static Texture2D _colorWheelTexture;

	internal static Color Scrim => Current.Scrim;

	internal static Color Panel => Current.Panel;

	internal static Color PanelElevated => Current.PanelElevated;

	internal static Color PanelSoft => Current.PanelSoft;

	internal static Color CraftingCanvas => Current.CraftingCanvas;

	internal static Color CraftingWell => Current.CraftingWell;

	internal static Color CraftingReady => Current.CraftingReady;

	internal static Color CraftingSelected => Current.CraftingSelected;

	internal static Color CraftingSelectedHover => Current.CraftingSelectedHover;

	internal static Color Slot => Current.Slot;

	internal static Color SlotHover => Current.SlotHover;

	internal static Color SlotSelected => Current.SlotSelected;

	internal static Color Border => Current.Border;

	internal static Color BorderSoft => Current.BorderSoft;

	internal static Color CardBorder => Current.CardBorder;

	internal static Color Accent => Current.Accent;

	internal static Color AccentSoft => Current.AccentSoft;

	internal static Color Primary => Current.Primary;

	internal static Color PrimaryHover => Current.PrimaryHover;

	internal static Color PrimarySoft => Current.PrimarySoft;

	internal static Color Success => Current.Success;

	internal static Color SuccessSoft => Current.SuccessSoft;

	internal static Color Text => Current.Text;

	internal static Color TextMuted => Current.TextMuted;

	internal static Color TextUnavailable => Current.TextUnavailable;

	internal static Color TextDim => Current.TextDim;

	internal static Color Shadow => Current.Shadow;

	private static Palette Current
	{
		get
		{
			int paletteIndex = BetterUIPlugin.PaletteIndex;
			if (_current == null || _cachedPaletteIndex != paletteIndex)
			{
				_cachedPaletteIndex = paletteIndex;
				_current = BuildPalette(paletteIndex);
			}
			return _current;
		}
	}

	internal static Texture2D ScanlineTexture
	{
		get
		{
			if ((Object)(object)_scanlineTexture == (Object)null)
			{
				_scanlineTexture = CreateScanlineTexture();
			}
			return _scanlineTexture;
		}
	}

	internal static Texture2D ColorWheelTexture
	{
		get
		{
			if ((Object)(object)_colorWheelTexture == (Object)null)
			{
				_colorWheelTexture = CreateColorWheelTexture();
			}
			return _colorWheelTexture;
		}
	}

	internal static Sprite RoundedSprite
	{
		get
		{
			if ((Object)(object)_roundedSprite == (Object)null)
			{
				_roundedSprite = CreateRoundedSprite();
			}
			return _roundedSprite;
		}
	}

	internal static Texture2D GetCategoryIconTexture(string label)
	{
		string text = label?.ToUpperInvariant() ?? string.Empty;
		int num = ((!text.Contains("WEAPON") && !text.Contains("COMBAT")) ? ((text.Contains("MED") || text.Contains("HEALTH")) ? 1 : ((text.Contains("TOOL") || text.Contains("FOOD")) ? 2 : (text.Contains("CLOTH") ? 3 : 4))) : 0);
		if ((Object)(object)CategoryIcons[num] == (Object)null)
		{
			CategoryIcons[num] = CreateCategoryIcon(num);
		}
		return CategoryIcons[num];
	}

	private static Palette BuildPalette(int index)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: 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_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: 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_0201: 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_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		float shift = Mathf.Clamp(index, 0, 4) switch
		{
			1 => 0.25f, 
			2 => 0.13f, 
			3 => 0.43f, 
			4 => -0.23f, 
			_ => 0f, 
		};
		return new Palette
		{
			Scrim = ShiftedHex("020704", 0.72f, shift),
			Panel = ShiftedHex("040C07", 0.88f, shift),
			PanelElevated = ShiftedHex("08140C", 0.9f, shift),
			PanelSoft = ShiftedHex("0C2113", 0.86f, shift),
			CraftingCanvas = ShiftedHex("020805", 0.8f, shift),
			CraftingWell = ShiftedHex("010403", 0.84f, shift),
			CraftingReady = ShiftedHex("07190C", 0.9f, shift),
			CraftingSelected = ShiftedHex("103A1C", 1f, shift),
			CraftingSelectedHover = ShiftedHex("165326", 1f, shift),
			Slot = ShiftedHex("07130B", 0.99f, shift),
			SlotHover = ShiftedHex("102B18", 1f, shift),
			SlotSelected = ShiftedHex("174923", 1f, shift),
			Border = ShiftedHex("2D6B3B", 0.9f, shift),
			BorderSoft = ShiftedHex("1C4327", 0.76f, shift),
			CardBorder = ShiftedHex("16331E", 0.68f, shift),
			Accent = ShiftedHex("6DFF83", 1f, shift),
			AccentSoft = ShiftedHex("6DFF83", 0.2f, shift),
			Primary = ShiftedHex("B8FF78", 1f, shift),
			PrimaryHover = ShiftedHex("DFFF9D", 1f, shift),
			PrimarySoft = ShiftedHex("B8FF78", 0.15f, shift),
			Success = ShiftedHex("66E97A", 1f, shift),
			SuccessSoft = ShiftedHex("66E97A", 0.18f, shift),
			Text = ShiftedHex("D9FFD7", 1f, shift),
			TextMuted = ShiftedHex("8FBC91", 1f, shift),
			TextUnavailable = ShiftedHex("688B6C", 1f, shift),
			TextDim = ShiftedHex("4F7556", 1f, shift),
			Shadow = ShiftedHex("000D03", 0.66f, shift)
		};
	}

	private static Color ShiftedHex(string hex, float alpha, float shift)
	{
		//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_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: 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)
		Color val = Hex(hex, alpha);
		if (Mathf.Abs(shift) < 0.001f)
		{
			return val;
		}
		float num = default(float);
		float num2 = default(float);
		float num3 = default(float);
		Color.RGBToHSV(val, ref num, ref num2, ref num3);
		Color result = Color.HSVToRGB(Mathf.Repeat(num + shift, 1f), num2, num3);
		result.a = alpha;
		return result;
	}

	private static Sprite CreateRoundedSprite()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_0121: 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_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
		{
			name = "BetterUI_RoundedSurface",
			filterMode = (FilterMode)1,
			wrapMode = (TextureWrapMode)1,
			hideFlags = (HideFlags)61
		};
		Color32[] array = (Color32[])(object)new Color32[4096];
		for (int i = 0; i < 64; i++)
		{
			for (int j = 0; j < 64; j++)
			{
				float num = Mathf.Clamp((float)j + 0.5f, 13f, 51f);
				float num2 = Mathf.Clamp((float)i + 0.5f, 13f, 51f);
				float num3 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num2));
				byte b = (byte)Mathf.RoundToInt(Mathf.Clamp01(13.75f - num3) * 255f);
				array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
			}
		}
		val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
		val.Apply(false, true);
		Object.DontDestroyOnLoad((Object)(object)val);
		Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(16f, 16f, 16f, 16f));
		((Object)obj).name = "BetterUI_RoundedSurfaceSprite";
		((Object)obj).hideFlags = (HideFlags)61;
		Object.DontDestroyOnLoad((Object)(object)obj);
		return obj;
	}

	private static Texture2D CreateScanlineTexture()
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(2, 4, (TextureFormat)4, false)
		{
			name = "BetterUI_TerminalScanlines",
			filterMode = (FilterMode)0,
			wrapMode = (TextureWrapMode)0,
			hideFlags = (HideFlags)61
		};
		Color32 val2 = default(Color32);
		((Color32)(ref val2))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0);
		Color32 val3 = default(Color32);
		((Color32)(ref val3))..ctor((byte)0, (byte)0, (byte)0, byte.MaxValue);
		val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit((Color32[])(object)new Color32[8] { val2, val2, val2, val2, val3, val3, val2, val2 }));
		val.Apply(false, true);
		Object.DontDestroyOnLoad((Object)(object)val);
		return val;
	}

	private static Texture2D CreateColorWheelTexture()
	{
		//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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = NewIconTexture("BetterUI_ColorWheel", 32);
		Color32[] array = (Color32[])(object)new Color32[1024];
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(15.5f, 15.5f);
		for (int i = 0; i < 32; i++)
		{
			for (int j = 0; j < 32; j++)
			{
				Vector2 val3 = new Vector2((float)j, (float)i) - val2;
				float magnitude = ((Vector2)(ref val3)).magnitude;
				if (magnitude < 7f || magnitude > 14.5f)
				{
					array[i * 32 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0);
					continue;
				}
				float num = Mathf.Repeat(Mathf.Atan2(val3.y, val3.x) / ((float)Math.PI * 2f), 1f);
				array[i * 32 + j] = Color32.op_Implicit(Color.HSVToRGB(num, 0.86f, 1f));
			}
		}
		val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
		val.Apply(false, true);
		Object.DontDestroyOnLoad((Object)(object)val);
		return val;
	}

	private static Texture2D CreateCategoryIcon(int iconIndex)
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = NewIconTexture($"BetterUI_CategoryIcon_{iconIndex}", 32);
		Color32[] array = (Color32[])(object)new Color32[1024];
		Color32 color = default(Color32);
		((Color32)(ref color))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
		switch (iconIndex)
		{
		case 0:
			DrawLine(array, 32, 7, 6, 25, 25, 2, color);
			DrawLine(array, 32, 25, 6, 7, 25, 2, color);
			break;
		case 1:
			FillRect(array, 32, 13, 5, 19, 27, color);
			FillRect(array, 32, 5, 13, 27, 19, color);
			break;
		case 2:
			DrawLine(array, 32, 9, 25, 21, 11, 3, color);
			FillRect(array, 32, 15, 6, 27, 12, color);
			break;
		case 3:
			FillRect(array, 32, 10, 10, 22, 27, color);
			FillRect(array, 32, 5, 10, 12, 17, color);
			FillRect(array, 32, 20, 10, 27, 17, color);
			FillRect(array, 32, 13, 7, 19, 12, new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0));
			break;
		default:
			FillRect(array, 32, 6, 6, 13, 13, color);
			FillRect(array, 32, 19, 6, 26, 13, color);
			FillRect(array, 32, 6, 19, 13, 26, color);
			FillRect(array, 32, 19, 19, 26, 26, color);
			break;
		}
		val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
		val.Apply(false, true);
		Object.DontDestroyOnLoad((Object)(object)val);
		return val;
	}

	private static Texture2D NewIconTexture(string name, int size)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		return new Texture2D(size, size, (TextureFormat)4, false)
		{
			name = name,
			filterMode = (FilterMode)1,
			wrapMode = (TextureWrapMode)1,
			hideFlags = (HideFlags)61
		};
	}

	private static void FillRect(Color32[] pixels, int size, int left, int bottom, int right, int top, Color32 color)
	{
		//IL_001a: 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)
		for (int i = Mathf.Max(0, bottom); i < Mathf.Min(size, top); i++)
		{
			for (int j = Mathf.Max(0, left); j < Mathf.Min(size, right); j++)
			{
				pixels[i * size + j] = color;
			}
		}
	}

	private static void DrawLine(Color32[] pixels, int size, int startX, int startY, int endX, int endY, int thickness, Color32 color)
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		int num = Mathf.Max(Mathf.Abs(endX - startX), Mathf.Abs(endY - startY));
		for (int i = 0; i <= num; i++)
		{
			float num2 = ((num > 0) ? ((float)i / (float)num) : 0f);
			int num3 = Mathf.RoundToInt(Mathf.Lerp((float)startX, (float)endX, num2));
			int num4 = Mathf.RoundToInt(Mathf.Lerp((float)startY, (float)endY, num2));
			FillRect(pixels, size, num3 - thickness, num4 - thickness, num3 + thickness + 1, num4 + thickness + 1, color);
		}
	}

	private static Color Hex(string hex, float alpha)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		Color result = default(Color);
		ColorUtility.TryParseHtmlString("#" + hex, ref result);
		result.a = alpha;
		return result;
	}
}
internal sealed class CraftingMenuBuilder
{
	private int _builtForRootId;

	internal GameObject ReplacementRoot { get; private set; }

	internal void Build(CraftingTableUI crafting)
	{
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)crafting == (Object)null || _builtForRootId == ((Object)crafting).GetInstanceID())
		{
			return;
		}
		Transform transform = ((Component)crafting).transform;
		Canvas componentInParent = ((Component)crafting).GetComponentInParent<Canvas>();
		Canvas val = (((Object)(object)componentInParent != (Object)null) ? componentInParent.rootCanvas : null);
		Transform parent = (((Object)(object)val != (Object)null) ? ((Component)val).transform : (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).transform : transform));
		List<Transform> list = new List<Transform>();
		for (int i = 0; i < transform.childCount; i++)
		{
			list.Add(transform.GetChild(i));
		}
		RectTransform root = CreateSurface("BetterUI_CraftingMenu", parent, BetterUITheme.CraftingCanvas);
		root.anchorMin = new Vector2(0.035f, 0.055f);
		root.anchorMax = new Vector2(0.965f, 0.945f);
		root.offsetMin = Vector2.zero;
		root.offsetMax = Vector2.zero;
		((Transform)root).SetAsLastSibling();
		ReplacementRoot = ((Component)root).gameObject;
		BetterUIStyler.Effects((Graphic)(object)((Component)root).GetComponent<Image>(), BetterUITheme.Accent, addShadow: true);
		RectTransform header = CreateSurface("BetterUI_Header", (Transform)(object)root, BetterUITheme.Panel);
		AnchorTop(header, 84f, 0f, 0f);
		HorizontalLayoutGroup obj = ((Component)header).gameObject.AddComponent<HorizontalLayoutGroup>();
		((LayoutGroup)obj).padding = Padding(20, 20, 12, 12);
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 12f;
		((LayoutGroup)obj).childAlignment = (TextAnchor)4;
		((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		RectTransform val2 = CreateRect("BetterUI_Body", (Transform)(object)root);
		val2.anchorMin = Vector2.zero;
		val2.anchorMax = Vector2.one;
		val2.offsetMin = new Vector2(14f, 64f);
		val2.offsetMax = new Vector2(-14f, -98f);
		RectTransform categoriesPanel = CreateSurface("BetterUI_Categories", (Transform)(object)val2, BetterUITheme.PanelElevated);
		categoriesPanel.anchorMin = Vector2.zero;
		categoriesPanel.anchorMax = new Vector2(0.18f, 1f);
		categoriesPanel.offsetMin = Vector2.zero;
		categoriesPanel.offsetMax = Vector2.zero;
		RectTransform browserPanel = CreateSurface("BetterUI_RecipeBrowser", (Transform)(object)val2, BetterUITheme.Panel);
		browserPanel.anchorMin = new Vector2(0.192f, 0f);
		browserPanel.anchorMax = new Vector2(0.585f, 1f);
		browserPanel.offsetMin = Vector2.zero;
		browserPanel.offsetMax = Vector2.zero;
		RectTransform detailsPanel = CreateSurface("BetterUI_Details", (Transform)(object)val2, BetterUITheme.PanelElevated);
		detailsPanel.anchorMin = new Vector2(0.597f, 0f);
		detailsPanel.anchorMax = Vector2.one;
		detailsPanel.offsetMin = Vector2.zero;
		detailsPanel.offsetMax = Vector2.zero;
		BuildSection("header", delegate
		{
			BuildHeader(crafting, header);
		});
		BuildSection("classification rail", delegate
		{
			BuildCategories(crafting, categoriesPanel);
		});
		BuildSection("schematic index", delegate
		{
			BuildBrowser(crafting, browserPanel);
		});
		BuildSection("inspection workspace", delegate
		{
			BuildDetails(crafting, detailsPanel);
		});
		BuildSection("command footer", delegate
		{
			BuildFooter(crafting, root);
		});
		int instanceID = ((Object)transform).GetInstanceID();
		for (int num = 0; num < list.Count; num++)
		{
			Transform val3 = list[num];
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3.parent != (Object)null && ((Object)val3.parent).GetInstanceID() == instanceID)
			{
				((Component)val3).gameObject.SetActive(false);
			}
		}
		((Component)root).gameObject.SetActive(true);
		_builtForRootId = ((Object)crafting).GetInstanceID();
		BetterUIPlugin.ModLog.LogInfo((object)"Built replacement terminal-workbench crafting hierarchy.");
	}

	private static void BuildCategories(CraftingTableUI crafting, RectTransform categoriesPanel)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		VerticalLayoutGroup obj = ((Component)categoriesPanel).gameObject.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj).padding = Padding(12, 12, 16, 12);
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
		((LayoutGroup)obj).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		TextMeshProUGUI obj2 = CreateLabel("BetterUI_CategoriesHeading", (Transform)(object)categoriesPanel, crafting._titleTMP);
		((TMP_Text)obj2).text = "CLASSIFICATION";
		((TMP_Text)obj2).fontSize = 13f;
		((TMP_Text)obj2).fontStyle = (FontStyles)1;
		((Graphic)obj2).color = BetterUITheme.TextMuted;
		((TMP_Text)obj2).characterSpacing = 1.6f;
		((TMP_Text)obj2).alignment = (TextAlignmentOptions)4097;
		SetLayout(((Component)obj2).gameObject, 0f, 0f, 1f, 26f, 26f, 0f);
		List<MazeButton> list = new List<MazeButton> { crafting.filterMiscButton, crafting.filterCombatButton, crafting.filterFoodButton, crafting.filterHealthyButton, crafting.filterClothingButton };
		list.Sort(CompareFilterButtons);
		for (int i = 0; i < list.Count; i++)
		{
			MazeButton val = list[i];
			if (!((Object)(object)val == (Object)null))
			{
				MoveToLayout(((Component)val).transform, (Transform)(object)categoriesPanel, 0f, 0f, 1f);
				SetLayout(((Component)val).gameObject, 0f, 0f, 1f, 48f, 48f, 0f);
				if ((Object)(object)val.buttonText != (Object)null)
				{
					((TMP_Text)val.buttonText).alignment = (TextAlignmentOptions)4097;
					((TMP_Text)val.buttonText).margin = new Vector4(42f, 0f, 8f, 0f);
				}
			}
		}
		TextMeshProUGUI obj3 = CreateLabel("BetterUI_FilterStatus", (Transform)(object)categoriesPanel, crafting._titleTMP);
		((TMP_Text)obj3).text = "// LIVE INDEX\n// LOCAL CACHE";
		((TMP_Text)obj3).fontSize = 11f;
		((TMP_Text)obj3).fontStyle = (FontStyles)0;
		((Graphic)obj3).color = BetterUITheme.TextDim;
		((TMP_Text)obj3).characterSpacing = 1.2f;
		((TMP_Text)obj3).alignment = (TextAlignmentOptions)1025;
		SetLayout(((Component)obj3).gameObject, 0f, 0f, 1f, 48f, 0f, 1f);
	}

	private static void BuildBrowser(CraftingTableUI crafting, RectTransform browserPanel)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: 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_01d2: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = CreateSurface("BetterUI_RecipeHeader", (Transform)(object)browserPanel, BetterUITheme.PanelElevated);
		AnchorTop(val, 94f, 8f, 8f);
		TextMeshProUGUI obj = CreateLabel("BetterUI_RecipeHeading", (Transform)(object)val, crafting._titleTMP);
		((TMP_Text)obj).text = "SCHEMATIC INDEX";
		((TMP_Text)obj).fontSize = 13f;
		((TMP_Text)obj).fontStyle = (FontStyles)1;
		((Graphic)obj).color = BetterUITheme.TextMuted;
		((TMP_Text)obj).characterSpacing = 1.5f;
		((TMP_Text)obj).alignment = (TextAlignmentOptions)4097;
		RectTransform component = ((Component)obj).GetComponent<RectTransform>();
		if ((Object)(object)component != (Object)null)
		{
			component.anchorMin = new Vector2(0f, 0.5f);
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(12f, 0f);
			component.offsetMax = new Vector2(-12f, 0f);
		}
		if ((Object)(object)crafting._searchInputField != (Object)null)
		{
			RectTransform component2 = ((Component)crafting._searchInputField).GetComponent<RectTransform>();
			if ((Object)(object)component2 != (Object)null)
			{
				((Transform)component2).SetParent((Transform)(object)val, false);
				NormalizeRect(component2);
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = new Vector2(1f, 0.5f);
				component2.offsetMin = new Vector2(10f, 8f);
				component2.offsetMax = new Vector2(-10f, -4f);
				LayoutElement component3 = ((Component)component2).GetComponent<LayoutElement>();
				if ((Object)(object)component3 != (Object)null)
				{
					component3.ignoreLayout = true;
				}
			}
		}
		RectTransform val2 = CreateSurface("BetterUI_RecipeScroll", (Transform)(object)browserPanel, BetterUITheme.CraftingWell);
		val2.anchorMin = Vector2.zero;
		val2.anchorMax = Vector2.one;
		val2.offsetMin = new Vector2(8f, 8f);
		val2.offsetMax = new Vector2(-8f, -102f);
		RectTransform val3 = CreateSurface("Viewport", (Transform)(object)val2, BetterUITheme.CraftingWell);
		val3.anchorMin = Vector2.zero;
		val3.anchorMax = Vector2.one;
		val3.offsetMin = new Vector2(8f, 8f);
		val3.offsetMax = new Vector2(-22f, -8f);
		((Graphic)((Component)val3).GetComponent<Image>()).raycastTarget = true;
		((Component)val3).gameObject.AddComponent<Mask>().showMaskGraphic = true;
		Transform craftingRecipesContainer = CraftingTableUI.craftingRecipesContainer;
		RectTransform val4 = (((Object)(object)craftingRecipesContainer != (Object)null) ? ((Component)craftingRecipesContainer).GetComponent<RectTransform>() : null);
		if ((Object)(object)val4 != (Object)null)
		{
			((Transform)val4).SetParent((Transform)(object)val3, false);
			NormalizeRect(val4);
			val4.anchorMin = new Vector2(0f, 1f);
			val4.anchorMax = new Vector2(1f, 1f);
			val4.pivot = new Vector2(0.5f, 1f);
			val4.anchoredPosition = Vector2.zero;
			val4.sizeDelta = new Vector2(0f, val4.sizeDelta.y);
		}
		Scrollbar verticalScrollbar = CreateScrollbar(val2);
		ScrollRect obj2 = ((Component)val2).gameObject.AddComponent<ScrollRect>();
		obj2.content = val4;
		obj2.viewport = val3;
		obj2.horizontal = false;
		obj2.vertical = true;
		obj2.movementType = (MovementType)2;
		obj2.inertia = true;
		obj2.decelerationRate = 0.12f;
		obj2.scrollSensitivity = 34f;
		obj2.verticalScrollbar = verticalScrollbar;
		obj2.verticalScrollbarVisibility = (ScrollbarVisibility)2;
		obj2.verticalScrollbarSpacing = 4f;
	}

	private static void BuildHeader(CraftingTableUI crafting, RectTransform header)
	{
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)crafting._titleTMP != (Object)null)
		{
			((TMP_Text)crafting._titleTMP).text = "WORKBENCH // FABRICATION";
			((TMP_Text)crafting._titleTMP).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)crafting._titleTMP).margin = Vector4.zero;
			MoveToLayout(((TMP_Text)crafting._titleTMP).transform, (Transform)(object)header, 220f, 420f, 1f);
		}
		SetLayout(((Component)CreateRect("BetterUI_HeaderSpacer", (Transform)(object)header)).gameObject, 0f, 0f, 1f, 1f, 1f, 0f);
		TextMeshProUGUI obj = CreateLabel("BetterUI_StationStatus", (Transform)(object)header, crafting._titleTMP);
		((TMP_Text)obj).text = "STN-04  //  ONLINE\nLOCAL FABRICATION NETWORK";
		((TMP_Text)obj).fontSize = 11f;
		((TMP_Text)obj).fontStyle = (FontStyles)1;
		((Graphic)obj).color = BetterUITheme.Accent;
		((TMP_Text)obj).characterSpacing = 1.4f;
		((TMP_Text)obj).alignment = (TextAlignmentOptions)4100;
		SetLayout(((Component)obj).gameObject, 150f, 220f, 0f, 48f, 48f, 0f);
	}

	private static void BuildFooter(CraftingTableUI crafting, RectTransform root)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = CreateSurface("BetterUI_CommandFooter", (Transform)(object)root, BetterUITheme.Panel);
		val.anchorMin = Vector2.zero;
		val.anchorMax = new Vector2(1f, 0f);
		val.pivot = new Vector2(0.5f, 0f);
		val.offsetMin = Vector2.zero;
		val.offsetMax = new Vector2(0f, 52f);
		HorizontalLayoutGroup obj = ((Component)val).gameObject.AddComponent<HorizontalLayoutGroup>();
		((LayoutGroup)obj).padding = Padding(18, 18, 7, 7);
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 10f;
		((LayoutGroup)obj).childAlignment = (TextAnchor)4;
		((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		AddFooterPrompt((Transform)(object)val, crafting._titleTMP, "[ LMB ]  SELECT", 150f);
		AddFooterPrompt((Transform)(object)val, crafting._titleTMP, "[ WHEEL ]  SCROLL", 165f);
		SetLayout(((Component)CreateRect("BetterUI_FooterSpacer", (Transform)(object)val)).gameObject, 0f, 0f, 1f, 1f, 1f, 0f);
		BuildThemeButton(val);
		if ((Object)(object)crafting._hideUncraftableButton != (Object)null)
		{
			MoveToLayout(((Component)crafting._hideUncraftableButton).transform, (Transform)(object)val, 42f, 46f, 0f);
		}
		MazeButton val2 = FindButton(((Component)crafting).transform, "CLOSE");
		if ((Object)(object)val2 != (Object)null)
		{
			if ((Object)(object)val2.buttonText != (Object)null)
			{
				((TMP_Text)val2.buttonText).text = "[ ESC ]  EXIT";
			}
			MoveToLayout(((Component)val2).transform, (Transform)(object)val, 138f, 154f, 0f);
			StyleFlatButton(val2, BetterUITheme.PanelSoft, BetterUITheme.Border, BetterUITheme.TextMuted);
		}
	}

	private static void BuildThemeButton(RectTransform footer)
	{
		//IL_0006: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = CreateSurface("BetterUI_ThemeButton", (Transform)(object)footer, BetterUITheme.PanelSoft);
		SetLayout(((Component)val).gameObject, 42f, 46f, 0f, 38f, 38f, 0f);
		Image component = ((Component)val).GetComponent<Image>();
		((Graphic)component).raycastTarget = true;
		BetterUIStyler.Effects((Graphic)(object)component, BetterUITheme.Border, addShadow: false);
		GameObject val2 = new GameObject("BetterUI_ColorWheelIcon", (Type[])(object)new Type[4]
		{
			Il2CppType.Of<RectTransform>(),
			Il2CppType.Of<CanvasRenderer>(),
			Il2CppType.Of<RawImage>(),
			Il2CppType.Of<LayoutElement>()
		});
		val2.transform.SetParent((Transform)(object)val, false);
		RectTransform component2 = val2.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0.5f, 0.5f);
		component2.anchorMax = new Vector2(0.5f, 0.5f);
		component2.pivot = new Vector2(0.5f, 0.5f);
		component2.anchoredPosition = Vector2.zero;
		component2.sizeDelta = new Vector2(26f, 26f);
		val2.GetComponent<LayoutElement>().ignoreLayout = true;
		RawImage component3 = val2.GetComponent<RawImage>();
		component3.texture = (Texture)(object)BetterUITheme.ColorWheelTexture;
		((Graphic)component3).color = Color.white;
		((Graphic)component3).raycastTarget = false;
	}

	private static void AddFooterPrompt(Transform footer, TextMeshProUGUI template, string value, float width)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI obj = CreateLabel("BetterUI_CommandPrompt", footer, template);
		((TMP_Text)obj).text = value;
		((TMP_Text)obj).fontSize = 12f;
		((TMP_Text)obj).fontStyle = (FontStyles)1;
		((Graphic)obj).color = BetterUITheme.TextMuted;
		((TMP_Text)obj).characterSpacing = 1f;
		((TMP_Text)obj).alignment = (TextAlignmentOptions)4097;
		SetLayout(((Component)obj).gameObject, width * 0.55f, width, 0f, 32f, 32f, 0f);
	}

	private static void BuildDetails(CraftingTableUI crafting, RectTransform detailsPanel)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = CreateSurface("BetterUI_DetailsHeader", (Transform)(object)detailsPanel, BetterUITheme.CraftingWell);
		AnchorTop(val, 50f, 8f, 8f);
		TextMeshProUGUI obj = CreateLabel("BetterUI_DetailsHeading", (Transform)(object)val, crafting._titleTMP);
		((TMP_Text)obj).text = "ITEM INSPECTION // COMPONENT ANALYSIS";
		((TMP_Text)obj).fontSize = 15f;
		((TMP_Text)obj).fontStyle = (FontStyles)1;
		((Graphic)obj).color = BetterUITheme.TextMuted;
		((TMP_Text)obj).characterSpacing = 1.8f;
		((TMP_Text)obj).alignment = (TextAlignmentOptions)4097;
		((TMP_Text)obj).enableWordWrapping = false;
		((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
		RectTransform component = ((Component)obj).GetComponent<RectTransform>();
		if ((Object)(object)component != (Object)null)
		{
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(12f, 0f);
			component.offsetMax = new Vector2(-12f, 0f);
		}
		SelectedCraftingRecipeUI selectedRecipeUI = crafting._selectedRecipeUI;
		if ((Object)(object)selectedRecipeUI != (Object)null)
		{
			RectTransform component2 = ((Component)selectedRecipeUI).GetComponent<RectTransform>();
			if ((Object)(object)component2 != (Object)null)
			{
				((Transform)component2).SetParent((Transform)(object)detailsPanel, false);
				NormalizeRect(component2);
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.offsetMin = new Vector2(10f, 10f);
				component2.offsetMax = new Vector2(-10f, -58f);
				((Component)component2).gameObject.SetActive(true);
				HideLegacyDetailsHeading(selectedRecipeUI);
				ConfigureEmptyState(crafting, selectedRecipeUI);
				BuildSelectedContent(crafting, selectedRecipeUI);
			}
		}
	}

	private static void ConfigureEmptyState(CraftingTableUI crafting, SelectedCraftingRecipeUI selected)
	{
		//IL_0025: 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_003b: 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_00f1: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)selected.didntSelectRecipeParent == (Object)null)
		{
			return;
		}
		RectTransform component = selected.didntSelectRecipeParent.GetComponent<RectTransform>();
		if ((Object)(object)component != (Object)null)
		{
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
		}
		Il2CppArrayBase<TextMeshProUGUI> componentsInChildren = selected.didntSelectRecipeParent.GetComponentsInChildren<TextMeshProUGUI>(true);
		if (componentsInChildren.Length > 0)
		{
			((TMP_Text)componentsInChildren[0]).text = "SELECT A SCHEMATIC";
			((TMP_Text)componentsInChildren[0]).fontSize = 16f;
			((TMP_Text)componentsInChildren[0]).fontStyle = (FontStyles)1;
			((Graphic)componentsInChildren[0]).color = BetterUITheme.TextMuted;
			((TMP_Text)componentsInChildren[0]).alignment = (TextAlignmentOptions)514;
			return;
		}
		TextMeshProUGUI obj = CreateLabel("BetterUI_SelectRecipePrompt", selected.didntSelectRecipeParent.transform, crafting._titleTMP);
		((TMP_Text)obj).text = "SELECT A SCHEMATIC";
		((TMP_Text)obj).fontSize = 16f;
		((TMP_Text)obj).fontStyle = (FontStyles)1;
		((Graphic)obj).color = BetterUITheme.TextMuted;
		((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
		RectTransform component2 = ((Component)obj).GetComponent<RectTransform>();
		if ((Object)(object)component2 != (Object)null)
		{
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
		}
	}

	private static void BuildSelectedContent(CraftingTableUI crafting, SelectedCraftingRecipeUI selected)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: 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_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)selected.approvedParent == (Object)null)
		{
			return;
		}
		Transform transform = selected.approvedParent.transform;
		RectTransform val = (((Object)(object)transform != (Object)null) ? ((Component)transform).GetComponent<RectTransform>() : null);
		if ((Object)(object)val != (Object)null)
		{
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			val.offsetMin = Vector2.zero;
			val.offsetMax = Vector2.zero;
		}
		List<Transform> list = new List<Transform>();
		for (int i = 0; i < transform.childCount; i++)
		{
			list.Add(transform.GetChild(i));
		}
		RectTransform val2 = CreateSurface("BetterUI_DetailsScroll", transform, BetterUITheme.PanelElevated);
		val2.anchorMin = Vector2.zero;
		val2.anchorMax = Vector2.one;
		val2.offsetMin = Vector2.zero;
		val2.offsetMax = Vector2.zero;
		RectTransform val3 = CreateSurface("Viewport", (Transform)(object)val2, BetterUITheme.PanelElevated);
		val3.anchorMin = Vector2.zero;
		val3.anchorMax = Vector2.one;
		val3.offsetMin = new Vector2(0f, 4f);
		val3.offsetMax = new Vector2(-18f, -4f);
		((Component)val3).gameObject.AddComponent<Mask>().showMaskGraphic = true;
		RectTransform val4 = CreateSurface("BetterUI_DetailsContent", (Transform)(object)val3, BetterUITheme.PanelElevated);
		val4.anchorMin = new Vector2(0f, 1f);
		val4.anchorMax = new Vector2(1f, 1f);
		val4.pivot = new Vector2(0.5f, 1f);
		val4.anchoredPosition = Vector2.zero;
		val4.sizeDelta = Vector2.zero;
		VerticalLayoutGroup obj = ((Component)val4).gameObject.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj).padding = Padding(14, 14, 14, 14);
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
		((LayoutGroup)obj).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		ContentSizeFitter obj2 = ((Component)val4).gameObject.AddComponent<ContentSizeFitter>();
		obj2.horizontalFit = (FitMode)0;
		obj2.verticalFit = (FitMode)2;
		RectTransform val5 = CreateSurface("BetterUI_OutputSummary", (Transform)(object)val4, BetterUITheme.CraftingWell);
		SetLayout(((Component)val5).gameObject, 0f, 0f, 1f, 132f, 132f, 0f);
		HorizontalLayoutGroup obj3 = ((Component)val5).gameObject.AddComponent<HorizontalLayoutGroup>();
		((LayoutGroup)obj3).padding = Padding(16, 16, 12, 12);
		((HorizontalOrVerticalLayoutGroup)obj3).spacing = 18f;
		((LayoutGroup)obj3).childAlignment = (TextAnchor)3;
		((HorizontalOrVerticalLayoutGroup)obj3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj3).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false;
		MoveToLayout(((Object)(object)selected._outputItemContainer != (Object)null) ? ((Component)selected._outputItemContainer).transform : null, (Transform)(object)val5, 104f, 104f, 0f);
		MoveToLayout(((Object)(object)selected._outputItemNameTMP != (Object)null) ? ((TMP_Text)selected._outputItemNameTMP).transform : null, (Transform)(object)val5, 160f, 240f, 1f);
		if ((Object)(object)selected._sliderContainer != (Object)null)
		{
			MoveToLayout(selected._sliderContainer.transform, (Transform)(object)val4, 0f, 0f, 1f);
			SetLayout(selected._sliderContainer, 0f, 0f, 1f, 34f, 38f, 0f);
		}
		RectTransform val6 = CreateRect("BetterUI_RequirementsSection", (Transform)(object)val4);
		VerticalLayoutGroup obj4 = ((Component)val6).gameObject.AddComponent<VerticalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj4).spacing = 8f;
		((LayoutGroup)obj4).childAlignment = (TextAnchor)0;
		((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
		ContentSizeFitter obj5 = ((Component)val6).gameObject.AddComponent<ContentSizeFitter>();
		obj5.horizontalFit = (FitMode)0;
		obj5.verticalFit = (FitMode)2;
		TextMeshProUGUI obj6 = CreateLabel("BetterUI_MaterialsHeading", (Transform)(object)val6, crafting._titleTMP);
		((TMP_Text)obj6).text = "REQUIRED COMPONENTS  //  CURRENT BATCH";
		((TMP_Text)obj6).fontSize = 15f;
		((TMP_Text)obj6).fontStyle = (FontStyles)1;
		((Graphic)obj6).color = BetterUITheme.TextMuted;
		((TMP_Text)obj6).characterSpacing = 1.2f;
		((TMP_Text)obj6).alignment = (TextAlignmentOptions)4097;
		SetLayout(((Component)obj6).gameObject, 0f, 0f, 1f, 24f, 26f, 0f);
		if ((Object)(object)selected._requiredItemsContainer != (Object)null)
		{
			selected._requiredItemsContainer.SetParent((Transform)(object)val6, false);
			SetLayout(((Component)selected._requiredItemsContainer).gameObject, 0f, 0f, 1f, 80f, 80f, 0f);
		}
		RectTransform val7 = CreateRect("BetterUI_RequirementsStatus", (Transform)(object)val6);
		SetLayout(((Component)val7).gameObject, 0f, 0f, 1f, 0f, 52f, 0f);
		VerticalLayoutGroup obj7 = ((Component)val7).gameObject.AddComponent<VerticalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj7).spacing = 5f;
		((LayoutGroup)obj7).childAlignment = (TextAnchor)3;
		((HorizontalOrVerticalLayoutGroup)obj7).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj7).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)obj7).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj7).childForceExpandHeight = false;
		MoveToLayout(((Object)(object)selected._needCraftingTableTmp != (Object)null) ? ((TMP_Text)selected._needCraftingTableTmp).transform : null, (Transform)(object)val7, 0f, 0f, 1f);
		MoveToLayout(((Object)(object)selected._needBlueprintTmp != (Object)null) ? ((TMP_Text)selected._needBlueprintTmp).transform : null, (Transform)(object)val7, 0f, 0f, 1f);
		if ((Object)(object)selected._needCraftingTableTmp != (Object)null)
		{
			SetLayout(((Component)selected._needCraftingTableTmp).gameObject, 0f, 0f, 1f, 20f, 22f, 0f);
		}
		if ((Object)(object)selected._needBlueprintTmp != (Object)null)
		{
			SetLayout(((Component)selected._needBlueprintTmp).gameObject, 0f, 0f, 1f, 20f, 22f, 0f);
		}
		BuildFabricationState(crafting, val4);
		if ((Object)(object)selected._craftButton != (Object)null)
		{
			MoveToLayout(((Component)selected._craftButton).transform, (Transform)(object)val4, 0f, 0f, 1f);
			if ((Object)(object)selected._craftButton.buttonText != (Object)null)
			{
				((TMP_Text)selected._craftButton.buttonText).text = "[ E ]  FABRICATE";
			}
			SetLayout(((Component)selected._craftButton).gameObject, 0f, 0f, 1f, 56f, 58f, 0f);
		}
		Scrollbar verticalScrollbar = CreateScrollbar(val2);
		ScrollRect obj8 = ((Component)val2).gameObject.AddComponent<ScrollRect>();
		obj8.content = val4;
		obj8.viewport = val3;
		obj8.horizontal = false;
		obj8.vertical = true;
		obj8.movementType = (MovementType)2;
		obj8.inertia = true;
		obj8.decelerationRate = 0.12f;
		obj8.scrollSensitivity = 30f;
		obj8.verticalScrollbar = verticalScrollbar;
		obj8.verticalScrollbarVisibility = (ScrollbarVisibility)1;
		int instanceID = ((Object)transform).GetInstanceID();
		for (int j = 0; j < list.Count; j++)
		{
			Transform val8 = list[j];
			if ((Object)(object)val8 != (Object)null && (Object)(object)val8.parent != (Object)null && ((Object)val8.parent).GetInstanceID() == instanceID)
			{
				((Component)val8).gameObject.SetActive(false);
			}
		}
	}

	private static void BuildFabricationState(CraftingTableUI crafting, RectTransform content)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_035a: Unknown result type (might be due to invalid IL or missing references)
		//IL_036f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_0393: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0418: Unknown result type (might be due to invalid IL or missing references)
		//IL_042d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = CreateSurface("BetterUI_FabricationSection", (Transform)(object)content, BetterUITheme.CraftingWell);
		SetLayout(((Component)val).gameObject, 0f, 0f, 1f, 174f, 174f, 0f);
		((Component)val).GetComponent<LayoutElement>().ignoreLayout = true;
		CanvasGroup obj = ((Component)val).gameObject.AddComponent<CanvasGroup>();
		obj.alpha = 0f;
		obj.interactable = false;
		obj.blocksRaycasts = false;
		TextMeshProUGUI obj2 = CreateLabel("BetterUI_FabricationHeading", (Transform)(object)val, crafting._titleTMP);
		((TMP_Text)obj2).text = "FABRICATION IN PROGRESS";
		((TMP_Text)obj2).fontSize = 14f;
		((TMP_Text)obj2).fontStyle = (FontStyles)1;
		((Graphic)obj2).color = BetterUITheme.TextMuted;
		((TMP_Text)obj2).characterSpacing = 1.4f;
		((TMP_Text)obj2).alignment = (TextAlignmentOptions)4097;
		RectTransform component = ((Component)obj2).GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.offsetMin = new Vector2(16f, -42f);
		component.offsetMax = new Vector2(-16f, -12f);
		RectTransform val2 = CreateSurface("BetterUI_FabricationIconFrame", (Transform)(object)val, BetterUITheme.PanelSoft);
		val2.anchorMin = new Vector2(0f, 0f);
		val2.anchorMax = new Vector2(0f, 0f);
		val2.pivot = new Vector2(0f, 0f);
		val2.anchoredPosition = new Vector2(16f, 18f);
		val2.sizeDelta = new Vector2(96f, 96f);
		Image obj3 = CreateArtwork("BetterUI_FabricationIconBase", (Transform)(object)val2);
		((Graphic)obj3).color = new Color(1f, 1f, 1f, 0.2f);
		Stretch(((Graphic)obj3).rectTransform, 8f);
		Image obj4 = CreateArtwork("BetterUI_FabricationIconFill", (Transform)(object)val2);
		obj4.type = (Type)3;
		obj4.fillMethod = (FillMethod)1;
		obj4.fillOrigin = 0;
		obj4.fillAmount = 0f;
		Stretch(((Graphic)obj4).rectTransform, 8f);
		TextMeshProUGUI obj5 = CreateLabel("BetterUI_FabricationItemName", (Transform)(object)val, crafting._titleTMP);
		((TMP_Text)obj5).text = "FABRICATING ITEM";
		((TMP_Text)obj5).fontSize = 20f;
		((TMP_Text)obj5).fontStyle = (FontStyles)1;
		((Graphic)obj5).color = BetterUITheme.Text;
		((TMP_Text)obj5).alignment = (TextAlignmentOptions)1025;
		((TMP_Text)obj5).enableWordWrapping = false;
		((TMP_Text)obj5).overflowMode = (TextOverflowModes)1;
		RectTransform component2 = ((Component)obj5).GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 0f);
		component2.anchorMax = new Vector2(1f, 0f);
		component2.pivot = new Vector2(0f, 0f);
		component2.offsetMin = new Vector2(132f, 72f);
		component2.offsetMax = new Vector2(-18f, 106f);
		TextMeshProUGUI obj6 = CreateLabel("BetterUI_FabricationPercent", (Transform)(object)val, crafting._titleTMP);
		((TMP_Text)obj6).text = "FABRICATING // 0%";
		((TMP_Text)obj6).fontSize = 13f;
		((TMP_Text)obj6).fontStyle = (FontStyles)1;
		((Graphic)obj6).color = BetterUITheme.Accent;
		((TMP_Text)obj6).characterSpacing = 1f;
		((TMP_Text)obj6).alignment = (TextAlignmentOptions)4097;
		RectTransform component3 = ((Component)obj6).GetComponent<RectTransform>();
		component3.anchorMin = new Vector2(0f, 0f);
		component3.anchorMax = new Vector2(1f, 0f);
		component3.pivot = new Vector2(0f, 0f);
		component3.offsetMin = new Vector2(132f, 43f);
		component3.offsetMax = new Vector2(-18f, 69f);
		RectTransform val3 = CreateSurface("BetterUI_FabricationTrack", (Transform)(object)val, BetterUITheme.PanelSoft);
		val3.anchorMin = new Vector2(0f, 0f);
		val3.anchorMax = new Vector2(1f, 0f);
		val3.pivot = new Vector2(0.5f, 0f);
		val3.offsetMin = new Vector2(132f, 22f);
		val3.offsetMax = new Vector2(-18f, 34f);
		RectTransform obj7 = CreateSurface("BetterUI_FabricationBarFill", (Transform)(object)val3, BetterUITheme.Accent);
		obj7.anchorMin = Vector2.zero;
		obj7.anchorMax = new Vector2(0f, 1f);
		obj7.pivot = new Vector2(0f, 0.5f);
		obj7.offsetMin = Vector2.zero;
		obj7.offsetMax = Vector2.zero;
		CraftingProgressUI craftingProgressUI = crafting._craftingProgressUI;
		if ((Object)(object)craftingProgressUI != (Object)null)
		{
			RectTransform component4 = ((Component)craftingProgressUI).GetComponent<RectTransform>();
			if ((Object)(object)component4 != (Object)null)
			{
				((Transform)component4).SetParent((Transform)(object)val, false);
				NormalizeRect(component4);
				component4.anchorMin = Vector2.zero;
				component4.anchorMax = Vector2.one;
				component4.offsetMin = Vector2.zero;
				component4.offsetMax = Vector2.zero;
				((Transform)component4).SetAsFirstSibling();
			}
			CanvasGroup val4 = ((Component)craftingProgressUI).GetComponent<CanvasGroup>();
			if ((Object)(object)val4 == (Object)null)
			{
				val4 = ((Component)craftingProgressUI).gameObject.AddComponent<CanvasGroup>();
			}
			val4.alpha = 0f;
			val4.interactable = false;
			val4.blocksRaycasts = false;
		}
	}

	private static Image CreateArtwork(string name, Transform parent)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, (Type[])(object)new Type[3]
		{
			Il2CppType.Of<RectTransform>(),
			Il2CppType.Of<CanvasRenderer>(),
			Il2CppType.Of<Image>()
		});
		val.transform.SetParent(parent, false);
		Image component = val.GetComponent<Image>();
		((Graphic)component).material = null;
		component.sprite = null;
		component.type = (Type)0;
		((Graphic)component).color = Color.white;
		component.preserveAspect = true;
		((Graphic)component).raycastTarget = false;
		return component;
	}

	private static void Stretch(RectTransform rect, float inset)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		rect.anchorMin = Vector2.zero;
		rect.anchorMax = Vector2.one;
		rect.offsetMin = new Vector2(inset, inset);
		rect.offsetMax = new Vector2(0f - inset, 0f - inset);
	}

	private static Scrollbar CreateScrollbar(RectTransform parent)
	{
		//IL_0006: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = CreateSurface("BetterUI_Scrollbar", (Transform)(object)parent, BetterUITheme.PanelSoft);
		val.anchorMin = new Vector2(1f, 0f);
		val.anchorMax = Vector2.one;
		val.pivot = new Vector2(1f, 0.5f);
		val.offsetMin = new Vector2(-14f, 8f);
		val.offsetMax = new Vector2(-4f, -8f);
		((Graphic)((Component)val).GetComponent<Image>()).raycastTarget = true;
		RectTransform val2 = CreateSurface("Handle", (Transform)(object)val, BetterUITheme.Accent);
		val2.anchorMin = Vector2.zero;
		val2.anchorMax = Vector2.one;
		val2.offsetMin = Vector2.zero;
		val2.offsetMax = Vector2.zero;
		((Graphic)((Component)val2).GetComponent<Image>()).raycastTarget = true;
		Scrollbar obj = ((Component)val).gameObject.AddComponent<Scrollbar>();
		obj.handleRect = val2;
		((Selectable)obj).targetGraphic = (Graphic)(object)((Component)val2).GetComponent<Image>();
		obj.direction = (Direction)2;
		obj.size = 0.2f;
		return obj;
	}

	private static void HideLegacyDetailsHeading(SelectedCraftingRecipeUI selected)
	{
		Il2CppArrayBase<TextMeshProUGUI> componentsInChildren = ((Component)selected).GetComponentsInChildren<TextMeshProUGUI>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			TextMeshProUGUI val = componentsInChildren[i];
			if ((Object)(object)val != (Object)null && string.Equals(((TMP_Text)val).text?.Trim(), "Details", StringComparison.OrdinalIgnoreCase))
			{
				((Component)val).gameObject.SetActive(false);
			}
		}
	}

	private static MazeButton FindButton(Transform root, string label)
	{
		Il2CppArrayBase<MazeButton> componentsInChildren = ((Component)root).GetComponentsInChildren<MazeButton>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			MazeButton val = componentsInChildren[i];
			if (string.Equals((((Object)(object)val != (Object)null && (Object)(object)val.buttonText != (Object)null) ? ((TMP_Text)val.buttonText).text : string.Empty)?.Trim(), label, StringComparison.OrdinalIgnoreCase))
			{
				return val;
			}
		}
		return null;
	}

	private static int CompareFilterButtons(MazeButton left, MazeButton right)
	{
		return FilterRank(left).CompareTo(FilterRank(right));
	}

	private static int FilterRank(MazeButton button)
	{
		string text = (((Object)(object)button != (Object)null && (Object)(object)button.buttonText != (Object)null) ? ((TMP_Text)button.buttonText).text.ToUpperInvariant() : string.Empty);
		if (text.Contains("WEAPON") || text.Contains("COMBAT"))
		{
			return 0;
		}
		if (text.Contains("MED"))
		{
			return 1;
		}
		if (text.Contains("TOOL"))
		{
			return 2;
		}
		if (text.Contains("CLOTH"))
		{
			return 3;
		}
		if (text.Contains("MISC"))
		{
			return 4;
		}
		return 5;
	}

	private static void MoveToLayout(Transform item, Transform parent, float minimumWidth, float preferredWidth, float flexibleWidth)
	{
		if (!((Object)(object)item == (Object)null))
		{
			item.SetParent(parent, false);
			RectTransform component = ((Component)item).GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				NormalizeRect(component);
			}
			LayoutElement val = ((Component)item).GetComponent<LayoutElement>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)item).gameObject.AddComponent<LayoutElement>();
			}
			val.minWidth = minimumWidth;
			val.preferredWidth = preferredWidth;
			val.flexibleWidth = flexibleWidth;
			val.minHeight = 42f;
			val.preferredHeight = 46f;
			val.flexibleHeight = 0f;
		}
	}

	private static void SetLayout(GameObject target, float minimumWidth, float preferredWidth, float flexibleWidth, float minimumHeight, float preferredHeight, float flexibleHeight)
	{
		LayoutElement val = target.GetComponent<LayoutElement>();
		if ((Object)(object)val == (Object)null)
		{
			val = target.AddComponent<LayoutElement>();
		}
		val.minWidth = minimumWidth;
		val.preferredWidth = preferredWidth;
		val.flexibleWidth = flexibleWidth;
		val.minHeight = minimumHeight;
		val.preferredHeight = preferredHeight;
		val.flexibleHeight = flexibleHeight;
	}

	private static RectTransform CreateRect(string name, Transform parent)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, (Type[])(object)new Type[1] { Il2CppType.Of<RectTransform>() });
		val.transform.SetParent(parent, false);
		return val.GetComponent<RectTransform>();
	}

	private static RectTransform CreateSurface(string name, Transform parent, Color color)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, (Type[])(object)new Type[3]
		{
			Il2CppType.Of<RectTransform>(),
			Il2CppType.Of<CanvasRenderer>(),
			Il2CppType.Of<Image>()
		});
		val.transform.SetParent(parent, false);
		Image component = val.GetComponent<Image>();
		((Graphic)component).material = null;
		component.sprite = null;
		component.type = (Type)0;
		((Graphic)component).color = color;
		((Graphic)component).raycastTarget = false;
		BetterUIStyler.Effects((Graphic)(object)component, BetterUITheme.BorderSoft, addShadow: false);
		Outline component2 = ((Component)component).GetComponent<Outline>();
		if ((Object)(object)component2 != (Object)null)
		{
			((Shadow)component2).effectDistance = new Vector2(1f, -1f);
		}
		return val.GetComponent<RectTransform>();
	}

	private static void StyleFlatButton(MazeButton button, Color fill, Color border, Color text)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Un