Decompiled source of SFK UILib v1.0.0

SFKUILib.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using SuperFantasyKingdom.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("AWSSDK.CognitoIdentity")]
[assembly: IgnoresAccessChecksTo("AWSSDK.CognitoSync")]
[assembly: IgnoresAccessChecksTo("AWSSDK.Core")]
[assembly: IgnoresAccessChecksTo("AWSSDK.Kinesis")]
[assembly: IgnoresAccessChecksTo("AWSSDK.SecurityToken")]
[assembly: IgnoresAccessChecksTo("com.games-farm.platforms.wingdk.public.runtime")]
[assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")]
[assembly: IgnoresAccessChecksTo("FMODUnity")]
[assembly: IgnoresAccessChecksTo("FMODUnityResonance")]
[assembly: IgnoresAccessChecksTo("GalaxyCSharp")]
[assembly: IgnoresAccessChecksTo("GamesFarm.Platforms.WinGDK.Private.Core")]
[assembly: IgnoresAccessChecksTo("GamesFarm.Platforms.WinGDK.Private.Runtime")]
[assembly: IgnoresAccessChecksTo("I18N.CJK")]
[assembly: IgnoresAccessChecksTo("I18N")]
[assembly: IgnoresAccessChecksTo("I18N.MidEast")]
[assembly: IgnoresAccessChecksTo("I18N.Other")]
[assembly: IgnoresAccessChecksTo("I18N.Rare")]
[assembly: IgnoresAccessChecksTo("I18N.West")]
[assembly: IgnoresAccessChecksTo("Mono.Security")]
[assembly: IgnoresAccessChecksTo("netstandard")]
[assembly: IgnoresAccessChecksTo("Newtonsoft.Json")]
[assembly: IgnoresAccessChecksTo("PrimeTween.Runtime")]
[assembly: IgnoresAccessChecksTo("Textus.SerializeReferenceUI")]
[assembly: IgnoresAccessChecksTo("UniTask.Addressables")]
[assembly: IgnoresAccessChecksTo("UniTask")]
[assembly: IgnoresAccessChecksTo("UniTask.DOTween")]
[assembly: IgnoresAccessChecksTo("UniTask.Linq")]
[assembly: IgnoresAccessChecksTo("UniTask.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Animation.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Common.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.IK.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.PixelPerfect")]
[assembly: IgnoresAccessChecksTo("Unity.2D.SpriteShape.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.2D.Tilemap.Extras")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.001")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Microsoft.GDK")]
[assembly: IgnoresAccessChecksTo("Unity.Microsoft.GDK.Tools")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipeline.Universal.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Shaders")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AccessibilityModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AndroidJNIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AnimationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClothModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterInputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ClusterRendererModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CoreModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CrashReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DirectorModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: IgnoresAccessChecksTo("UnityEngine.DSPGraphModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GameCenterModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.GridModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.HotReloadModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ImageConversionModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.IMGUIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputLegacyModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.InputModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.JSONSerializeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.LocalizationModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ParticleSystemModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PerformanceReportingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.Physics2DModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ProfilerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ScreenCaptureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SharedInternalsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteMaskModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpriteShapeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.StreamingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubstanceModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SubsystemsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TerrainPhysicsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreFontEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreTextEngineModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TextRenderingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TilemapModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.TLSModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsNativeModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UIModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UmbraModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UNETModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsCommonModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityConnectModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityCurlModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityTestProtocolModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAssetBundleModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAudioModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestTextureModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestWWWModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VehiclesModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VFXModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VideoModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VirtualTexturingModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.VRModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.WindModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XRModule")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("SFKUILib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+449f6072038b69d81e4e061a141efe64a6f0661d")]
[assembly: AssemblyProduct("UI framework for SFK")]
[assembly: AssemblyTitle("SFKUILib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SFKUILib
{
	public interface IUIContainer
	{
		RectTransform Rect { get; }

		void SetSize(Vector2 size);

		void SetPosition(Vector2 position);

		void SetParent(Transform transform);

		void Hide();

		void Show();
	}
	public enum OverlayBackgroundMode
	{
		None,
		Fullscreen,
		PanelFixed
	}
	public class UIButton : UIObject
	{
		public Image Background;

		public TextMeshProUGUI Label;

		public Button Button;

		public UIClickable Clickable;

		public static Vector2 STANDARD_SIZE = new Vector2(250f, 42f);

		public UIButton onClick(UnityAction action)
		{
			Button button = Button;
			if (button != null)
			{
				((UnityEvent)button.onClick).AddListener(action);
			}
			return this;
		}

		public static UIButton Create(string text, Transform parent, Vector2 size, Vector2 pos, Color? bgColor = null, bool rounded = false, bool enableShake = false)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_016c: 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)
			UIButton uIButton = new UIButton();
			uIButton.GameObject = new GameObject("UIButton_" + text);
			uIButton.Rect = uIButton.GameObject.AddComponent<RectTransform>();
			uIButton.SetParent(parent);
			uIButton.SetSize(size);
			uIButton.SetPosition(pos);
			uIButton.Background = uIButton.GameObject.AddComponent<Image>();
			((Graphic)uIButton.Background).color = (Color)(((??)bgColor) ?? new Color(0f, 0f, 0f, 0.6f));
			if (rounded)
			{
				Sprite roundedSprite = Util.GetRoundedSprite();
				if ((Object)(object)roundedSprite != (Object)null)
				{
					uIButton.Background.sprite = roundedSprite;
					uIButton.Background.type = (Type)1;
				}
			}
			uIButton.Button = uIButton.GameObject.AddComponent<Button>();
			uIButton.Button.onClick = new ButtonClickedEvent();
			if (enableShake)
			{
				uIButton.Clickable = uIButton.GameObject.AddComponent<UIClickable>();
				uIButton.Clickable.buttonThatMustBeEnabledAndInteractable = (Selectable)(object)uIButton.Button;
			}
			UIText uIText = UIText.Create(text, (Transform)(object)uIButton.Rect, Vector2.zero, 20, (TextAlignmentOptions)257, Color.white);
			uIButton.Label = uIText.Label;
			RectTransform rect = uIText.Rect;
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.offsetMin = Vector2.zero;
			rect.offsetMax = Vector2.zero;
			return uIButton;
		}
	}
	public class UICloseButton : UIButton
	{
		public static Vector2 DEFAULT_SIZE = new Vector2(26f, 26f);

		public static UICloseButton Create(Transform parent, Sprite closeSprite, Vector2? size = null, Vector2? offsetFromTopRight = null, Color? tint = null, bool enableShake = true)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_004d: 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_0052: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_0115: 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_014a: Expected O, but got Unknown
			UICloseButton uICloseButton = new UICloseButton();
			uICloseButton.GameObject = new GameObject("Close");
			uICloseButton.Rect = uICloseButton.GameObject.AddComponent<RectTransform>();
			uICloseButton.SetParent(parent);
			RectTransform rect = uICloseButton.Rect;
			Vector2 sizeDelta = (Vector2)(((??)size) ?? DEFAULT_SIZE);
			Vector2 anchoredPosition = (Vector2)(((??)offsetFromTopRight) ?? new Vector2(-10f, -10f));
			rect.anchorMin = new Vector2(1f, 1f);
			rect.anchorMax = new Vector2(1f, 1f);
			rect.pivot = new Vector2(1f, 1f);
			rect.sizeDelta = sizeDelta;
			rect.anchoredPosition = anchoredPosition;
			uICloseButton.Background = uICloseButton.GameObject.AddComponent<Image>();
			uICloseButton.Background.sprite = closeSprite;
			uICloseButton.Background.type = (Type)0;
			uICloseButton.Background.preserveAspect = true;
			((Graphic)uICloseButton.Background).color = (Color)(((??)tint) ?? Color.white);
			uICloseButton.Button = uICloseButton.GameObject.AddComponent<Button>();
			uICloseButton.Button.onClick = new ButtonClickedEvent();
			if (enableShake)
			{
				uICloseButton.Clickable = uICloseButton.GameObject.AddComponent<UIClickable>();
				uICloseButton.Clickable.buttonThatMustBeEnabledAndInteractable = (Selectable)(object)uICloseButton.Button;
			}
			return uICloseButton;
		}
	}
	public class UIHorizontalLayout
	{
		private readonly IUIContainer container;

		private readonly float spacing;

		private readonly float padding;

		private readonly List<UIObject> children = new List<UIObject>();

		private float currentX;

		private UIHorizontalLayout(IUIContainer container, float spacing, float padding)
		{
			this.container = container;
			this.spacing = spacing;
			this.padding = padding;
			currentX = padding;
		}

		public static UIHorizontalLayout Create(Transform parentCanvas, Vector2 anchoredPos)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0041: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			UIObject uIObject = new UIObject();
			uIObject.GameObject = new GameObject("Horizontal");
			uIObject.Rect = uIObject.GameObject.AddComponent<RectTransform>();
			uIObject.SetParent(parentCanvas);
			uIObject.Rect.anchorMin = new Vector2(0.5f, 0.5f);
			uIObject.Rect.anchorMax = new Vector2(0.5f, 0.5f);
			uIObject.SetPosition(anchoredPos);
			return AttachTo(uIObject);
		}

		public static UIHorizontalLayout AttachTo(IUIContainer container, float spacing = 8f, float padding = 10f)
		{
			return new UIHorizontalLayout(container, spacing, padding);
		}

		public void Add(UIObject obj)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			obj.SetParent((Transform)(object)container.Rect);
			RectTransform rect = obj.Rect;
			float num = 0f;
			TextMeshProUGUI component = obj.GameObject.GetComponent<TextMeshProUGUI>();
			if ((Object)(object)component != (Object)null)
			{
				((TMP_Text)component).ForceMeshUpdate(false, false);
				num = ((TMP_Text)component).preferredWidth;
			}
			else
			{
				LayoutElement component2 = obj.GameObject.GetComponent<LayoutElement>();
				if ((Object)(object)component2 != (Object)null)
				{
					if (component2.preferredWidth > 0f)
					{
						num = component2.preferredWidth;
					}
					else if (component2.minWidth > 0f)
					{
						num = component2.minWidth;
					}
				}
			}
			if (num <= 0f)
			{
				num = rect.sizeDelta.x;
			}
			float num2 = num * 0.15f;
			obj.Rect.anchorMin = new Vector2(0f, 0.5f);
			obj.Rect.anchorMax = new Vector2(0f, 0.5f);
			obj.Rect.pivot = new Vector2(0f, 0.5f);
			obj.SetPosition(new Vector2(currentX, 0f));
			currentX += num + num2;
			children.Add(obj);
		}
	}
	public class UIMenu : UIObject
	{
		public Image Background;

		public static UIMenu Create(Vector2 size, Vector2 pos, Transform parent, Color? bgColor = null)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			UIMenu uIMenu = new UIMenu();
			uIMenu.GameObject = new GameObject("UIMenu");
			uIMenu.Rect = uIMenu.GameObject.AddComponent<RectTransform>();
			uIMenu.SetParent(parent);
			uIMenu.SetSize(size);
			uIMenu.SetPosition(pos);
			uIMenu.Background = uIMenu.GameObject.AddComponent<Image>();
			((Graphic)uIMenu.Background).color = (Color)(((??)bgColor) ?? new Color(0f, 0f, 0f, 0f));
			((Component)uIMenu.Background).transform.SetAsFirstSibling();
			return uIMenu;
		}

		public UIVerticalLayout AddVerticalLayout(float spacing = 8f, float padding = 10f)
		{
			return UIVerticalLayout.AttachTo(this, spacing, padding);
		}

		public UIHorizontalLayout AddHorizontalLayout(float spacing = 8f, float padding = 10f)
		{
			return UIHorizontalLayout.AttachTo(this, spacing, padding);
		}
	}
	public class UIObject : IUIContainer
	{
		public GameObject GameObject;

		public RectTransform Rect { get; set; }

		public bool Active
		{
			get
			{
				return GameObject.activeSelf;
			}
			set
			{
				GameObject.SetActive(value);
			}
		}

		public void SetParent(Transform parent)
		{
			if ((Object)(object)parent != (Object)null)
			{
				((Transform)Rect).SetParent(parent);
			}
		}

		public void SetSize(Vector2 size)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Rect.sizeDelta = size;
		}

		public void SetPosition(Vector2 anchoredPos)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Rect.anchoredPosition = anchoredPos;
		}

		public void Hide()
		{
			GameObject.SetActive(false);
		}

		public void Show()
		{
			GameObject.SetActive(true);
		}
	}
	public class UIOverlay
	{
		public UIObject Root { get; private set; }

		public UIVerticalLayout Menu { get; private set; }

		public Image FullscreenBackground { get; private set; }

		public Image PanelBackground { get; private set; }

		public UICloseButton CloseButton { get; private set; }

		private UIOverlay()
		{
		}

		public void Hide()
		{
			Root.Active = false;
		}

		public void Show()
		{
			Root.Active = true;
		}

		public void Destroy()
		{
			Object.Destroy((Object)(object)Root.GameObject);
		}

		public static UIOverlay Create(string name, Vector2 menuPos, Transform canvasOverride = null, float spacing = 5f, float padding = 5f, OverlayBackgroundMode bgMode = OverlayBackgroundMode.None, Color? bgColor = null, Vector2? panelSize = null, bool bgBlocksRaycasts = true)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00d3: 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_00f5: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: 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_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Expected O, but got Unknown
			UIOverlay overlay = new UIOverlay();
			Transform val = canvasOverride;
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = GameObject.Find("Canvas");
				if ((Object)(object)val2 == (Object)null)
				{
					Canvas obj = Object.FindObjectOfType<Canvas>();
					val2 = ((obj != null) ? ((Component)obj).gameObject : null);
				}
				val = val2.transform;
			}
			overlay.Root = new UIObject();
			overlay.Root.GameObject = new GameObject(name);
			overlay.Root.Rect = overlay.Root.GameObject.AddComponent<RectTransform>();
			overlay.Root.SetParent(val);
			RectTransform rect = overlay.Root.Rect;
			rect.anchorMin = new Vector2(0f, 0f);
			rect.anchorMax = new Vector2(1f, 1f);
			rect.offsetMin = Vector2.zero;
			rect.offsetMax = Vector2.zero;
			if (bgMode == OverlayBackgroundMode.Fullscreen)
			{
				overlay.FullscreenBackground = CreateBackgroundImage("FullscreenBG", (Transform)(object)overlay.Root.Rect, bgColor, stretchFullscreen: true);
				if (bgBlocksRaycasts)
				{
					((Graphic)overlay.FullscreenBackground).raycastTarget = true;
				}
			}
			overlay.Menu = UIVerticalLayout.Create((Transform)(object)overlay.Root.Rect, Vector2.zero, spacing, padding);
			if (bgMode == OverlayBackgroundMode.PanelFixed)
			{
				Vector2 val3 = (Vector2)(((??)panelSize) ?? new Vector2(520f, 420f));
				overlay.PanelBackground = CreateBackgroundImage("PanelBG", (Transform)(object)overlay.Root.Rect, bgColor, stretchFullscreen: false);
				RectTransform rectTransform = ((Graphic)overlay.PanelBackground).rectTransform;
				rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
				rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
				rectTransform.pivot = new Vector2(0.5f, 0.5f);
				rectTransform.sizeDelta = val3;
				rectTransform.anchoredPosition = menuPos;
				((Transform)rectTransform).SetAsFirstSibling();
				((Transform)overlay.Menu.container.Rect).SetParent((Transform)(object)rectTransform, false);
				RectTransform rect2 = overlay.Menu.container.Rect;
				rect2.anchorMin = new Vector2(0f, 1f);
				rect2.anchorMax = new Vector2(0f, 1f);
				rect2.pivot = new Vector2(0f, 1f);
				rect2.anchoredPosition = new Vector2(padding, 0f - padding);
				rect2.sizeDelta = new Vector2(val3.x, 0f);
			}
			Sprite closeSprite = Util.GetCloseSprite();
			if ((Object)(object)closeSprite != (Object)null)
			{
				Transform parent = (Transform)(object)((bgMode == OverlayBackgroundMode.PanelFixed && (Object)(object)overlay.PanelBackground != (Object)null) ? ((Graphic)overlay.PanelBackground).rectTransform : overlay.Root.Rect);
				Vector2 value = default(Vector2);
				((Vector2)(ref value))..ctor(-8f, -8f);
				UIOverlay uIOverlay = overlay;
				Vector2? offsetFromTopRight = value;
				uIOverlay.CloseButton = UICloseButton.Create(parent, closeSprite, null, offsetFromTopRight);
				overlay.CloseButton.onClick((UnityAction)delegate
				{
					overlay.Hide();
				});
			}
			return overlay;
		}

		private static Image CreateBackgroundImage(string goName, Transform parent, Color? color, bool stretchFullscreen)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(goName, new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).SetParent(parent, false);
			if (stretchFullscreen)
			{
				component.anchorMin = new Vector2(0f, 0f);
				component.anchorMax = new Vector2(1f, 1f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			Image component2 = val.GetComponent<Image>();
			component2.sprite = null;
			component2.type = (Type)0;
			((Graphic)component2).color = (Color)(((??)color) ?? new Color(0f, 0f, 0f, 0.6f));
			((Graphic)component2).raycastTarget = false;
			return component2;
		}

		public UIOverlay AddHeader(string text, int size = 32, Color? color = null)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			UIText obj = UIText.Create(text, (Transform)(object)Menu.container.Rect, Vector2.zero, size, (TextAlignmentOptions)257, color);
			Menu.Add(obj);
			return this;
		}

		public UIOverlay AddText(string text, int size = 18, Color? color = null, bool wrap = false)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			UIText obj = UIText.Create(text, (Transform)(object)Menu.container.Rect, Vector2.zero, size, (TextAlignmentOptions)513, color, wrap);
			Menu.Add(obj);
			return this;
		}

		public UIOverlay AddButton(string label, UnityAction onClick, Vector2? size = null)
		{
			//IL_0026: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			UIButton uIButton = UIButton.Create(label, (Transform)(object)Menu.container.Rect, (Vector2)(((??)size) ?? UIButton.STANDARD_SIZE), Vector2.zero, null, rounded: false, enableShake: true);
			uIButton.onClick(onClick);
			Menu.Add(uIButton);
			return this;
		}
	}
	public class UISection
	{
		public UIObject Root { get; private set; }

		public UIVerticalLayout Layout { get; private set; }

		private UISection()
		{
		}

		public static UISection Create(Transform parent, string name = "Section", float spacing = 2f, float padding = 0f)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			UISection uISection = new UISection();
			uISection.Root = new UIObject();
			uISection.Root.GameObject = new GameObject(name);
			uISection.Root.Rect = uISection.Root.GameObject.AddComponent<RectTransform>();
			uISection.Root.SetParent(parent);
			uISection.Layout = UIVerticalLayout.AttachTo(uISection.Root, spacing, padding);
			return uISection;
		}
	}
	public class UIText : UIObject
	{
		public TextMeshProUGUI Label;

		public static UIText Create(string text, Transform parent, Vector2 pos, int size = 24, TextAlignmentOptions alignment = 257, Color? color = null, bool wrap = false)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0043: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f->IL012f: Incompatible stack types: O vs I4
			//IL_0124->IL012f: Incompatible stack types: I4 vs O
			//IL_0124->IL012f: Incompatible stack types: O vs I4
			UIText uIText = new UIText();
			uIText.GameObject = new GameObject("UIText");
			uIText.Rect = uIText.GameObject.AddComponent<RectTransform>();
			uIText.SetParent(parent);
			RectTransform rect = uIText.Rect;
			rect.anchorMin = new Vector2(0f, 1f);
			rect.anchorMax = new Vector2(1f, 1f);
			rect.pivot = new Vector2(0f, 1f);
			rect.sizeDelta = new Vector2(0f, 0f);
			uIText.SetPosition(pos);
			uIText.Label = uIText.GameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)uIText.Label).text = text;
			((TMP_Text)uIText.Label).font = Util.GetFont();
			((TMP_Text)uIText.Label).fontSize = size;
			((Graphic)uIText.Label).color = (Color)(((??)color) ?? Color.white);
			((TMP_Text)uIText.Label).alignment = alignment;
			((TMP_Text)uIText.Label).enableWordWrapping = wrap;
			object obj = uIText.Label;
			int num;
			if (wrap)
			{
				obj = ((TMP_Text)uIText.Label).overflowMode;
				num = (int)obj;
			}
			else
			{
				num = 0;
				obj = num;
				num = (int)obj;
			}
			((TMP_Text)num).overflowMode = (TextOverflowModes)obj;
			return uIText;
		}
	}
	public class UIVerticalLayout
	{
		public readonly IUIContainer container;

		private readonly float spacing;

		private readonly float padding;

		private readonly List<UIObject> children = new List<UIObject>();

		private float currentY;

		private UIVerticalLayout(IUIContainer container, float spacing, float padding)
		{
			this.container = container;
			this.spacing = spacing;
			this.padding = padding;
			currentY = 0f - padding;
		}

		public static UIVerticalLayout Create(Transform parentCanvas, Vector2 anchoredPos, float childSpacing = 2f, float childPadding = 4f)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0041: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			UIObject uIObject = new UIObject();
			uIObject.GameObject = new GameObject("VerticalLayout");
			uIObject.Rect = uIObject.GameObject.AddComponent<RectTransform>();
			uIObject.SetParent(parentCanvas);
			uIObject.Rect.anchorMin = new Vector2(0.5f, 0.5f);
			uIObject.Rect.anchorMax = new Vector2(0.5f, 0.5f);
			uIObject.SetPosition(anchoredPos);
			return AttachTo(uIObject, childSpacing, childPadding);
		}

		public static UIVerticalLayout AttachTo(IUIContainer container, float spacing = 8f, float padding = 10f)
		{
			return new UIVerticalLayout(container, spacing, padding);
		}

		public void Add(UIObject obj)
		{
			//IL_0025: 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_0051: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			obj.SetParent((Transform)(object)container.Rect);
			RectTransform rect = obj.Rect;
			rect.anchorMin = new Vector2(0f, 1f);
			rect.anchorMax = new Vector2(0f, 1f);
			rect.pivot = new Vector2(0f, 1f);
			float num = 0f;
			TextMeshProUGUI component = obj.GameObject.GetComponent<TextMeshProUGUI>();
			if ((Object)(object)component != (Object)null)
			{
				((TMP_Text)component).ForceMeshUpdate(false, false);
				num = ((TMP_Text)component).preferredHeight;
			}
			else
			{
				LayoutElement component2 = obj.GameObject.GetComponent<LayoutElement>();
				if ((Object)(object)component2 != (Object)null)
				{
					if (component2.preferredHeight > 0f)
					{
						num = component2.preferredHeight;
					}
					else if (component2.minHeight > 0f)
					{
						num = component2.minHeight;
					}
				}
			}
			if (num <= 0f)
			{
				num = rect.sizeDelta.y;
			}
			float num2 = spacing + num * 0.15f;
			obj.SetPosition(new Vector2(padding, currentY));
			currentY -= num + num2;
			children.Add(obj);
		}
	}
	public static class Util
	{
		private static TMP_FontAsset cachedFont;

		private static Sprite cachedRounded;

		private static Sprite _closeSpriteCached;

		private static GameObject _closePrefabCached;

		public static TMP_FontAsset GetFont()
		{
			if ((Object)(object)cachedFont != (Object)null)
			{
				return cachedFont;
			}
			cachedFont = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == "Compass 9"));
			if ((Object)(object)cachedFont != (Object)null)
			{
				return cachedFont;
			}
			TextMeshProUGUI val = Object.FindObjectOfType<TextMeshProUGUI>();
			if ((Object)(object)val != (Object)null)
			{
				cachedFont = ((TMP_Text)val).font;
				return cachedFont;
			}
			cachedFont = Resources.Load<TMP_FontAsset>("DefaultFont");
			if ((Object)(object)cachedFont == (Object)null)
			{
				Debug.LogWarning((object)"[UIFramework] Could not find Compass 9 or any TMP font!");
			}
			return cachedFont;
		}

		public static Sprite GetRoundedSprite()
		{
			if ((Object)(object)cachedRounded != (Object)null)
			{
				return cachedRounded;
			}
			cachedRounded = Resources.Load<Sprite>("UI_27");
			return cachedRounded;
		}

		public static Sprite GetCloseSprite()
		{
			if ((Object)(object)_closeSpriteCached != (Object)null)
			{
				return _closeSpriteCached;
			}
			GameObject val = ((IEnumerable<GameObject>)Object.FindObjectsOfType<GameObject>(true)).FirstOrDefault((Func<GameObject, bool>)((GameObject g) => ((Object)g).name == "Close" && (Object)(object)g.GetComponent<Image>() != (Object)null));
			if ((Object)(object)val != (Object)null)
			{
				_closeSpriteCached = val.GetComponent<Image>().sprite;
				return _closeSpriteCached;
			}
			return null;
		}

		public static GameObject GetClosePrefab()
		{
			if ((Object)(object)_closePrefabCached != (Object)null)
			{
				return _closePrefabCached;
			}
			GameObject val = ((IEnumerable<GameObject>)Object.FindObjectsOfType<GameObject>(true)).FirstOrDefault((Func<GameObject, bool>)((GameObject g) => ((Object)g).name == "Close" && (Object)(object)g.GetComponent<Button>() != (Object)null));
			if ((Object)(object)val != (Object)null)
			{
				_closePrefabCached = val;
				return _closePrefabCached;
			}
			return null;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}