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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using Sparroh.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SparrohUILib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SparrohUILib")]
[assembly: AssemblyTitle("SparrohUILib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[BepInPlugin("sparroh.uilibrary", "SparrohUILib", "1.1.1")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class SparrohUILibPlugin : BaseUnityPlugin
{
public const string PluginGUID = "sparroh.uilibrary";
public const string PluginName = "SparrohUILib";
public const string PluginVersion = "1.1.1";
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
UITheme.Initialize();
Logger.LogInfo((object)"SparrohUILib v1.1.1 loaded.");
}
}
namespace Sparroh.UI
{
public static class RichText
{
public static string Colorize(string text, Color color)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return "" + text + " ";
}
public static string Colorize(string text, string hexWithoutHash)
{
return "" + text + " ";
}
public static string Bold(string text)
{
return "" + text + " ";
}
public static string Italic(string text)
{
return "" + text + " ";
}
public static string Size(string text, int percent)
{
return $"{text} ";
}
public static string Labeled(string label, string value, Color valueColor)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return label + ": " + Colorize(value, valueColor);
}
public static string Labeled(string label, string value, Color valueColor, string unit)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(unit))
{
return Labeled(label, value, valueColor);
}
return label + ": " + Colorize(value, valueColor) + " " + unit;
}
public static string Labeled(string label, float value, Color valueColor, string unit = null, string format = "F1")
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return Labeled(label, value.ToString(format), valueColor, unit);
}
public static string Labeled(string label, int value, Color valueColor, string unit = null)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
return Labeled(label, value.ToString(), valueColor, unit);
}
public static string LabeledWithRate(string label, float value, float rate, Color color, string format = "F0", string rateFormat = "F1")
{
//IL_001d: 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)
return label + ": " + Colorize(value.ToString(format), color) + " (" + Colorize(rate.ToString(rateFormat), color) + "/s)";
}
}
public static class UIFactory
{
private static Sprite _whiteSprite;
public static Sprite WhiteSprite
{
get
{
//IL_0032: 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)
if ((Object)(object)_whiteSprite != (Object)null)
{
return _whiteSprite;
}
Texture2D whiteTexture = Texture2D.whiteTexture;
_whiteSprite = Sprite.Create(whiteTexture, new Rect(0f, 0f, (float)((Texture)whiteTexture).width, (float)((Texture)whiteTexture).height), new Vector2(0.5f, 0.5f), 100f);
return _whiteSprite;
}
}
public static GameObject Create(string name, Transform parent = null)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
GameObject val = new GameObject(name);
if ((Object)(object)parent != (Object)null)
{
val.transform.SetParent(parent, false);
}
return val;
}
public static RectTransform CreateRect(string name, Transform parent = null)
{
return Create(name, parent).AddComponent();
}
public static Image CreateImage(string name, Transform parent, Color color, bool raycast = true)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
Image obj = ((Component)CreateRect(name, parent)).gameObject.AddComponent();
((Graphic)obj).color = color;
((Graphic)obj).raycastTarget = raycast;
return obj;
}
public static TextMeshProUGUI CreateTmp(string name, Transform parent, string text = "", float fontSize = -1f, Color? color = null, TextAlignmentOptions alignment = (TextAlignmentOptions)513, bool wrap = false)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI obj = ((Component)CreateRect(name, parent)).gameObject.AddComponent();
float fontSize2 = ((fontSize > 0f) ? fontSize : UITheme.ScaledFontBody);
UITheme.ApplyTextStyle(obj, fontSize2, color, alignment, wrap);
((TMP_Text)obj).text = text ?? string.Empty;
return obj;
}
public static Canvas CreateOverlayCanvas(string name, int sortingOrder)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
GameObject obj = Create(name);
Object.DontDestroyOnLoad((Object)(object)obj);
Canvas val = obj.AddComponent();
val.renderMode = (RenderMode)0;
val.sortingOrder = sortingOrder;
CanvasScaler obj2 = obj.AddComponent();
obj2.uiScaleMode = (ScaleMode)1;
obj2.referenceResolution = new Vector2(1920f, 1080f);
obj2.screenMatchMode = (ScreenMatchMode)0;
obj2.matchWidthOrHeight = 0.5f;
obj2.referencePixelsPerUnit = 100f;
obj.AddComponent();
return val;
}
public static VerticalLayoutGroup AddVerticalLayout(GameObject go, float spacing = -1f, RectOffset padding = null, TextAnchor childAlignment = (TextAnchor)0, bool controlChildHeight = true, bool expandHeight = false, bool controlChildWidth = true, bool expandWidth = true)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
VerticalLayoutGroup val = go.GetComponent();
if ((Object)(object)val == (Object)null)
{
val = go.AddComponent();
}
((HorizontalOrVerticalLayoutGroup)val).spacing = ((spacing >= 0f) ? spacing : UITheme.S(UITheme.SpacingNormal));
((LayoutGroup)val).padding = padding ?? UITheme.ScaledPadding(12, 12, 12, 12);
((LayoutGroup)val).childAlignment = childAlignment;
((HorizontalOrVerticalLayoutGroup)val).childControlHeight = controlChildHeight;
((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = expandHeight;
((HorizontalOrVerticalLayoutGroup)val).childControlWidth = controlChildWidth;
((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = expandWidth;
return val;
}
public static HorizontalLayoutGroup AddHorizontalLayout(GameObject go, float spacing = -1f, RectOffset padding = null, TextAnchor childAlignment = (TextAnchor)3, bool controlChildWidth = true, bool expandWidth = false, bool controlChildHeight = true, bool expandHeight = true)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
HorizontalLayoutGroup val = go.GetComponent();
if ((Object)(object)val == (Object)null)
{
val = go.AddComponent();
}
((HorizontalOrVerticalLayoutGroup)val).spacing = ((spacing >= 0f) ? spacing : UITheme.S(UITheme.SpacingNormal));
((LayoutGroup)val).padding = padding ?? UITheme.ScaledPadding(8, 8, 4, 4);
((LayoutGroup)val).childAlignment = childAlignment;
((HorizontalOrVerticalLayoutGroup)val).childControlWidth = controlChildWidth;
((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = expandWidth;
((HorizontalOrVerticalLayoutGroup)val).childControlHeight = controlChildHeight;
((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = expandHeight;
return val;
}
public static ContentSizeFitter AddContentSizeFitter(GameObject go, FitMode horizontal = (FitMode)0, FitMode vertical = (FitMode)2)
{
//IL_0018: 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)
ContentSizeFitter val = go.GetComponent();
if ((Object)(object)val == (Object)null)
{
val = go.AddComponent();
}
val.horizontalFit = horizontal;
val.verticalFit = vertical;
return val;
}
public static void ApplyWhiteSprite(Image img)
{
if ((Object)(object)img != (Object)null && (Object)(object)img.sprite == (Object)null)
{
img.sprite = WhiteSprite;
}
}
}
public static class UIHelpers
{
public static bool TryGetReticle(out Transform reticle)
{
reticle = null;
try
{
if ((Object)(object)Player.LocalPlayer == (Object)null || (Object)(object)Player.LocalPlayer.PlayerLook == (Object)null || (Object)(object)Player.LocalPlayer.PlayerLook.Reticle == (Object)null)
{
return false;
}
reticle = (Transform)(object)Player.LocalPlayer.PlayerLook.Reticle;
return true;
}
catch
{
return false;
}
}
public static void SetAnchor(RectTransform rt, Vector2 anchorMin, Vector2 anchorMax, Vector2? pivot = null)
{
//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_0024: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rt == (Object)null))
{
rt.anchorMin = anchorMin;
rt.anchorMax = anchorMax;
if (pivot.HasValue)
{
rt.pivot = pivot.Value;
}
}
}
public static void SetPointAnchor(RectTransform rt, float x, float y, Vector2? pivot = null)
{
//IL_000a: 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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(x, y);
SetAnchor(rt, val, val, (Vector2)(((??)pivot) ?? new Vector2(0.5f, 0.5f)));
}
public static void SetFillParent(RectTransform rt, float padding = 0f)
{
//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_0023: 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_0047: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rt == (Object)null))
{
rt.anchorMin = Vector2.zero;
rt.anchorMax = Vector2.one;
rt.offsetMin = new Vector2(padding, padding);
rt.offsetMax = new Vector2(0f - padding, 0f - padding);
rt.pivot = new Vector2(0.5f, 0.5f);
}
}
public static void SetTopStretch(RectTransform rt, float height, float left = 0f, float right = 0f, float top = 0f)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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)
if (!((Object)(object)rt == (Object)null))
{
rt.anchorMin = new Vector2(0f, 1f);
rt.anchorMax = new Vector2(1f, 1f);
rt.pivot = new Vector2(0.5f, 1f);
rt.sizeDelta = new Vector2(0f - (left + right), height);
rt.anchoredPosition = new Vector2((left - right) * 0.5f, 0f - top);
}
}
public static void DestroySafe(Object obj)
{
if (!(obj == (Object)null))
{
if (Application.isPlaying)
{
Object.Destroy(obj);
}
else
{
Object.DestroyImmediate(obj);
}
}
}
public static void DestroyChildren(Transform parent)
{
if (!((Object)(object)parent == (Object)null))
{
for (int num = parent.childCount - 1; num >= 0; num--)
{
DestroySafe((Object)(object)((Component)parent.GetChild(num)).gameObject);
}
}
}
public static Image EnsureImage(GameObject go, Color color, bool raycast = true)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
Image val = go.GetComponent();
if ((Object)(object)val == (Object)null)
{
val = go.AddComponent();
}
((Graphic)val).color = color;
((Graphic)val).raycastTarget = raycast;
return val;
}
public static LayoutElement EnsureLayoutElement(GameObject go, float? preferredWidth = null, float? preferredHeight = null, float? minHeight = null)
{
LayoutElement val = go.GetComponent();
if ((Object)(object)val == (Object)null)
{
val = go.AddComponent();
}
if (preferredWidth.HasValue)
{
val.preferredWidth = preferredWidth.Value;
}
if (preferredHeight.HasValue)
{
val.preferredHeight = preferredHeight.Value;
}
if (minHeight.HasValue)
{
val.minHeight = minHeight.Value;
}
return val;
}
public static bool ScreenToLocal(RectTransform parent, Vector2 screenPoint, out Vector2 localPoint, Camera cam = null)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, screenPoint, cam, ref localPoint);
}
public static Vector2 ScreenPointToNormalizedAnchor(RectTransform parent, Vector2 screenPoint, Camera cam = null)
{
//IL_0001: 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_0022: 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_0038: 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_0085: Unknown result type (might be due to invalid IL or missing references)
if (!ScreenToLocal(parent, screenPoint, out var localPoint, cam))
{
return new Vector2(0.5f, 0.5f);
}
Rect rect = parent.rect;
float num = ((((Rect)(ref rect)).width > 0f) ? ((localPoint.x - ((Rect)(ref rect)).xMin) / ((Rect)(ref rect)).width) : 0.5f);
float num2 = ((((Rect)(ref rect)).height > 0f) ? ((localPoint.y - ((Rect)(ref rect)).yMin) / ((Rect)(ref rect)).height) : 0.5f);
return new Vector2(Mathf.Clamp01(num), Mathf.Clamp01(num2));
}
}
public static class GearActionBar
{
private class Slot
{
public string Id;
public int Order;
public UIButton Button;
public bool WantVisible = true;
public string Label = string.Empty;
public UIButtonStyle Style;
public bool Interactable = true;
public Action OnClick;
}
public const int OrderClearGrid = 10;
public const int OrderSolve = 20;
public const int OrderCancelSolve = 30;
public const int OrderClearSelection = 40;
public const int OrderCopyGrid = 50;
public const int OrderPasteCode = 60;
public const int OrderFilter = 100;
public const int OrderPriority = 110;
public const int OrderScrapMarked = 120;
public const int OrderScrapNonFav = 130;
public const int OrderUndoScrap = 140;
public const int OrderGunStats = 150;
private const float CompactHeightRef = 24f;
private const float CompactFontRef = 12f;
private const float SlotGapRef = 4f;
private static Canvas _canvas;
private static RectTransform _row;
private static readonly Dictionary _slots = new Dictionary(StringComparer.Ordinal);
private static bool _contextVisible;
private static bool _built;
public static void Register(string id, string label, int order, Action onClick, UIButtonStyle style = UIButtonStyle.Default)
{
if (string.IsNullOrEmpty(id))
{
return;
}
EnsureBuilt();
label = label ?? string.Empty;
if (_slots.TryGetValue(id, out var value))
{
bool num = value.Order != order;
bool flag = !string.Equals(value.Label, label, StringComparison.Ordinal);
bool flag2 = value.Style != style;
bool flag3 = (object)value.OnClick != onClick;
value.Order = order;
value.OnClick = onClick;
if (value.Button != null)
{
if (flag)
{
value.Label = label;
value.Button.SetText(label);
value.Button.SetWidth(Mathf.Max(UITheme.S(64f), EstimateWidth(label)));
}
if (flag2)
{
value.Style = style;
value.Button.SetStyle(style);
}
if (flag3)
{
((UnityEventBase)value.Button.Button.onClick).RemoveAllListeners();
if (onClick != null)
{
value.Button.OnClick(onClick);
}
}
}
if (num)
{
RebuildOrder();
}
ApplyVisibility();
}
else
{
float value2 = UITheme.S(24f);
UIButton uIButton = UIButton.Create((Transform)(object)_row, label, onClick, style, null, value2);
if ((Object)(object)uIButton.Label != (Object)null)
{
((TMP_Text)uIButton.Label).fontSize = UITheme.S(12f);
}
uIButton.SetWidth(Mathf.Max(UITheme.S(64f), EstimateWidth(label)));
_slots[id] = new Slot
{
Id = id,
Order = order,
Button = uIButton,
WantVisible = true,
Label = label,
Style = style,
Interactable = true,
OnClick = onClick
};
RebuildOrder();
ApplyVisibility();
}
}
public static void SetText(string id, string text)
{
if (_slots.TryGetValue(id, out var value) && value.Button != null)
{
text = text ?? string.Empty;
if (!string.Equals(value.Label, text, StringComparison.Ordinal))
{
value.Label = text;
value.Button.SetText(text);
value.Button.SetWidth(Mathf.Max(UITheme.S(64f), EstimateWidth(text)));
}
}
}
public static void SetInteractable(string id, bool interactable)
{
if (_slots.TryGetValue(id, out var value) && value.Button != null && value.Interactable != interactable)
{
value.Interactable = interactable;
value.Button.SetInteractable(interactable);
}
}
public static void SetStyle(string id, UIButtonStyle style)
{
if (_slots.TryGetValue(id, out var value) && value.Button != null && value.Style != style)
{
value.Style = style;
value.Button.SetStyle(style);
}
}
public static void SetSlotVisible(string id, bool visible)
{
if (!_slots.TryGetValue(id, out var value))
{
return;
}
if (value.WantVisible == visible)
{
if (value.Button != null)
{
value.Button.SetActive(visible && _contextVisible);
}
return;
}
value.WantVisible = visible;
if (value.Button != null)
{
value.Button.SetActive(visible && _contextVisible);
}
}
public static void SetContextVisible(bool visible)
{
if (_contextVisible == visible && _built)
{
return;
}
_contextVisible = visible;
if (!_built)
{
if (!visible)
{
return;
}
EnsureBuilt();
}
ApplyVisibility();
}
public static bool IsGearMenuOpen()
{
try
{
if ((Object)(object)Menu.Instance == (Object)null || !Menu.Instance.IsOpen || (Object)(object)Menu.Instance.WindowSystem == (Object)null)
{
return false;
}
Window top = Menu.Instance.WindowSystem.GetTop();
return top is GearDetailsWindow || top is OuroGearWindow;
}
catch
{
return false;
}
}
public static void Tick()
{
SetContextVisible(IsGearMenuOpen());
}
public static void Unregister(string id)
{
if (_slots.TryGetValue(id, out var value))
{
if (value.Button != null && (Object)(object)value.Button.GameObject != (Object)null)
{
Object.Destroy((Object)(object)value.Button.GameObject);
}
_slots.Remove(id);
}
}
private static void EnsureBuilt()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: 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)
if (!_built || !((Object)(object)_canvas != (Object)null))
{
UITheme.Initialize();
_canvas = UIFactory.CreateOverlayCanvas("Sparroh_GearActionBar", UITheme.WindowSortingOrder + 8);
RectTransform obj = UIFactory.CreateRect("Bar", ((Component)_canvas).transform);
obj.anchorMin = new Vector2(0f, 1f);
obj.anchorMax = new Vector2(1f, 1f);
obj.pivot = new Vector2(0.5f, 1f);
float num = UITheme.S(36f);
obj.sizeDelta = new Vector2(0f, num);
obj.anchoredPosition = new Vector2(0f, 0f - UITheme.S(6f));
Image obj2 = ((Component)obj).gameObject.AddComponent();
((Graphic)obj2).color = UIColors.WithAlpha(UIColors.PanelBg, 0.55f);
UIFactory.ApplyWhiteSprite(obj2);
((Graphic)obj2).raycastTarget = false;
UIFactory.AddHorizontalLayout(((Component)obj).gameObject, UITheme.S(4f), UITheme.ScaledPadding(8, 8, 4, 4), (TextAnchor)3, controlChildWidth: false, expandWidth: false, controlChildHeight: true, expandHeight: false);
_row = obj;
_built = true;
((Component)_canvas).gameObject.SetActive(false);
}
}
private static void RebuildOrder()
{
if ((Object)(object)_row == (Object)null)
{
return;
}
foreach (Slot item in _slots.Values.OrderBy((Slot x) => x.Order))
{
if (item.Button != null)
{
item.Button.GameObject.transform.SetParent((Transform)(object)_row, false);
item.Button.GameObject.transform.SetAsLastSibling();
}
}
}
private static void ApplyVisibility()
{
if ((Object)(object)_canvas == (Object)null)
{
return;
}
bool flag = _slots.Values.Any((Slot s) => s.WantVisible);
bool flag2 = _contextVisible && flag;
if (((Component)_canvas).gameObject.activeSelf != flag2)
{
((Component)_canvas).gameObject.SetActive(flag2);
}
foreach (Slot value in _slots.Values)
{
if (value.Button != null)
{
value.Button.SetActive(_contextVisible && value.WantVisible);
}
}
}
private static float EstimateWidth(string label)
{
if (string.IsNullOrEmpty(label))
{
return UITheme.S(64f);
}
return UITheme.S(12f + (float)label.Length * 7.2f + 16f);
}
}
public class HudBuilder
{
private struct LineSpec
{
public string Name;
public float FontSize;
public TextAlignmentOptions Alignment;
}
private readonly string _name;
private Transform _parent;
private float _anchorX = 0.5f;
private float _anchorY = 0.5f;
private Vector2 _pivot = new Vector2(0f, 1f);
private Vector2 _size;
private Vector2 _anchoredPosition = Vector2.zero;
private bool _parentToReticle = true;
private readonly List _lines = new List();
private bool _withBackground;
private Color _backgroundColor = UIColors.WithAlpha(UIColors.PanelBg, 0.55f);
private HudBuilder(string name)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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)
_name = name;
_size = new Vector2(UITheme.S(UITheme.HudDefaultWidth), UITheme.S(UITheme.HudLineHeight));
}
public static HudBuilder Create(string name)
{
return new HudBuilder(name);
}
public HudBuilder ParentToReticle(bool enabled = true)
{
_parentToReticle = enabled;
return this;
}
public HudBuilder Parent(Transform parent)
{
_parent = parent;
_parentToReticle = false;
return this;
}
public HudBuilder Anchor(float x, float y)
{
_anchorX = Mathf.Clamp01(x);
_anchorY = Mathf.Clamp01(y);
return this;
}
public HudBuilder Pivot(Vector2 pivot)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_pivot = pivot;
return this;
}
public HudBuilder Size(float width, float height, bool scale = true)
{
//IL_000f: 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_0014: Unknown result type (might be due to invalid IL or missing references)
_size = (Vector2)(scale ? UITheme.ScaledSize(width, height) : new Vector2(width, height));
return this;
}
public HudBuilder AnchoredPosition(Vector2 pos, bool scale = true)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: 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)
_anchoredPosition = (scale ? UITheme.S(pos) : pos);
return this;
}
public HudBuilder WithBackground(Color? color = null)
{
//IL_0013: 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)
_withBackground = true;
if (color.HasValue)
{
_backgroundColor = color.Value;
}
return this;
}
public HudBuilder AddText(string name = "Text", float fontSize = -1f, TextAlignmentOptions alignment = (TextAlignmentOptions)513)
{
//IL_002f: 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)
_lines.Add(new LineSpec
{
Name = name,
FontSize = ((fontSize > 0f) ? fontSize : UITheme.FontHud),
Alignment = alignment
});
return this;
}
public HudBuilder AddLines(int count, float fontSize = -1f, TextAlignmentOptions alignment = (TextAlignmentOptions)513)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < count; i++)
{
AddText($"Line{i}", fontSize, alignment);
}
return this;
}
public HudHandle Build()
{
//IL_00b0: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: 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_0147: 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_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: 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)
Transform reticle = _parent;
if (_parentToReticle && !UIHelpers.TryGetReticle(out reticle))
{
return null;
}
if ((Object)(object)reticle == (Object)null)
{
return null;
}
float scaledHudLineHeight = UITheme.ScaledHudLineHeight;
if (_lines.Count > 1)
{
float num = scaledHudLineHeight * (float)_lines.Count + UITheme.S(4f);
if (_size.y < num)
{
_size.y = num;
}
}
else if (_lines.Count == 0)
{
AddText("Text", -1f, (TextAlignmentOptions)513);
}
RectTransform val = UIFactory.CreateRect(_name, reticle);
UIHelpers.SetPointAnchor(val, _anchorX, _anchorY, _pivot);
val.sizeDelta = _size;
val.anchoredPosition = _anchoredPosition;
if (_withBackground)
{
UIFactory.ApplyWhiteSprite(UIHelpers.EnsureImage(((Component)val).gameObject, _backgroundColor, raycast: false));
}
UIText[] array = new UIText[_lines.Count];
for (int i = 0; i < _lines.Count; i++)
{
LineSpec lineSpec = _lines[i];
float fontSize = UITheme.S(lineSpec.FontSize);
UIText uIText = UIText.Create((Transform)(object)val, lineSpec.Name, "", fontSize, UIColors.TextPrimary, lineSpec.Alignment);
RectTransform rect = uIText.Rect;
rect.anchorMin = new Vector2(0f, 1f);
rect.anchorMax = new Vector2(1f, 1f);
rect.pivot = new Vector2(0.5f, 1f);
rect.sizeDelta = new Vector2(0f, scaledHudLineHeight);
rect.anchoredPosition = new Vector2(0f, (float)(-i) * scaledHudLineHeight);
array[i] = uIText;
}
return new HudHandle(((Component)val).gameObject, val, array);
}
}
public class HudHandle
{
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public UIText[] Lines { get; }
public UIText Primary
{
get
{
if (Lines == null || Lines.Length == 0)
{
return null;
}
return Lines[0];
}
}
public bool IsActive
{
get
{
if ((Object)(object)GameObject != (Object)null)
{
return GameObject.activeSelf;
}
return false;
}
}
public Vector2 Size
{
get
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Rect != (Object)null))
{
return Vector2.zero;
}
return Rect.sizeDelta;
}
}
internal HudHandle(GameObject go, RectTransform rt, UIText[] lines)
{
GameObject = go;
Rect = rt;
Lines = lines;
}
public void SetAnchor(float x, float y)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Rect == (Object)null))
{
UIHelpers.SetPointAnchor(Rect, x, y, Rect.pivot);
}
}
public void SetActive(bool active)
{
if ((Object)(object)GameObject != (Object)null)
{
GameObject.SetActive(active);
}
}
public void Destroy()
{
UIHelpers.DestroySafe((Object)(object)GameObject);
}
}
public sealed class ConfigColor
{
private readonly ConfigEntry _entry;
private readonly Color _fallback;
private Color _cached;
public ConfigEntry Entry => _entry;
public Color Value => _cached;
public string Hex => _entry.Value;
public ConfigColor(ConfigEntry entry, Color fallback)
{
//IL_001d: 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
_entry = entry ?? throw new ArgumentNullException("entry");
_fallback = fallback;
_cached = Parse(_entry.Value);
_entry.SettingChanged += OnSettingChanged;
}
public static ConfigColor Bind(ConfigFile config, string section, string key, Color fallback, string description = null)
{
//IL_0000: 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)
string text = UIColors.ToHex(fallback);
string text2 = description ?? ("Rich-text value color as hex (RRGGBB or #RRGGBB). Default: " + text + ".");
return new ConfigColor(config.Bind(section, key, text, text2), fallback);
}
public void Refresh()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
_cached = Parse(_entry.Value);
}
private void OnSettingChanged(object sender, EventArgs e)
{
Refresh();
}
private Color Parse(string hex)
{
//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)
return UIColors.ParseHex(hex, _fallback);
}
public static implicit operator Color(ConfigColor c)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return (Color)(((??)c?.Value) ?? default(Color));
}
}
public static class UIColors
{
public static readonly Color Sky = new Color(0.45f, 0.85f, 0.95f, 1f);
public static readonly Color Rose = new Color(0.95f, 0.3f, 0.35f, 1f);
public static readonly Color Shamrock = new Color(0.2f, 0.9f, 0.45f, 1f);
public static readonly Color Macaroon = new Color(0.98f, 0.82f, 0.35f, 1f);
public static readonly Color Orchid = new Color(0.85f, 0.4f, 0.9f, 1f);
public static readonly Color Amber = new Color(1f, 0.75f, 0.15f, 1f);
public static readonly Color Electric = new Color(0.3f, 0.65f, 1f, 1f);
public static readonly Color TextPrimary = new Color(0.95f, 0.96f, 0.98f, 1f);
public static readonly Color TextSecondary = new Color(0.7f, 0.74f, 0.8f, 1f);
public static readonly Color TextMuted = new Color(0.5f, 0.54f, 0.6f, 1f);
public static readonly Color PanelBg = new Color(0.08f, 0.1f, 0.14f, 0.94f);
public static readonly Color Surface = new Color(0.12f, 0.15f, 0.2f, 0.96f);
public static readonly Color TitleBar = new Color(0.1f, 0.18f, 0.24f, 1f);
public static readonly Color SectionBar = new Color(0.12f, 0.22f, 0.3f, 1f);
public static readonly Color EntryBg = new Color(0.14f, 0.17f, 0.22f, 0.9f);
public static readonly Color ScrollBg = new Color(0.06f, 0.08f, 0.11f, 0.85f);
public static readonly Color TooltipBg = new Color(0.06f, 0.08f, 0.12f, 0.96f);
public static readonly Color Border = new Color(0.25f, 0.4f, 0.5f, 0.7f);
public static readonly Color BorderAccent = new Color(0.3f, 0.7f, 0.85f, 0.9f);
public static readonly Color Separator = new Color(0.3f, 0.4f, 0.5f, 0.4f);
public static readonly Color ButtonNormal = new Color(0.16f, 0.22f, 0.3f, 1f);
public static readonly Color ButtonHover = new Color(0.26f, 0.38f, 0.5f, 1f);
public static readonly Color ButtonPressed = new Color(0.12f, 0.17f, 0.24f, 1f);
public static readonly Color ButtonPrimary = new Color(0.14f, 0.42f, 0.62f, 1f);
public static readonly Color ButtonPrimaryHover = new Color(0.22f, 0.55f, 0.8f, 1f);
public static readonly Color ButtonPrimaryPressed = new Color(0.1f, 0.32f, 0.48f, 1f);
public static readonly Color ButtonDanger = new Color(0.58f, 0.18f, 0.22f, 1f);
public static readonly Color ButtonDangerHover = new Color(0.78f, 0.28f, 0.32f, 1f);
public static readonly Color ButtonDangerPressed = new Color(0.42f, 0.12f, 0.15f, 1f);
public static readonly Color ButtonActive = new Color(0.16f, 0.48f, 0.4f, 1f);
public static readonly Color ButtonActiveHover = new Color(0.22f, 0.6f, 0.5f, 1f);
public static readonly Color ButtonActivePressed = new Color(0.12f, 0.36f, 0.3f, 1f);
public static readonly Color ToggleOff = new Color(0.25f, 0.28f, 0.32f, 1f);
public static readonly Color ToggleOn = new Color(0.18f, 0.55f, 0.4f, 1f);
public static readonly Color Checkmark = new Color(0.3f, 0.95f, 0.55f, 1f);
public static readonly Color InputBg = new Color(0.1f, 0.13f, 0.18f, 0.95f);
public static readonly Color InputText = new Color(0.92f, 0.94f, 0.96f, 1f);
public static readonly Color SliderTrack = new Color(0.15f, 0.18f, 0.24f, 1f);
public static readonly Color SliderFill = new Color(0.25f, 0.65f, 0.8f, 1f);
public static readonly Color SliderHandle = new Color(0.9f, 0.93f, 0.96f, 1f);
public static readonly Color ProgressTrack = new Color(0.12f, 0.15f, 0.2f, 1f);
public static readonly Color ProgressFill = new Color(0.25f, 0.75f, 0.55f, 1f);
public static readonly Color TabInactive = new Color(0.12f, 0.16f, 0.22f, 1f);
public static readonly Color TabActive = new Color(0.18f, 0.3f, 0.4f, 1f);
public static readonly Color TabHover = new Color(0.16f, 0.24f, 0.32f, 1f);
public static readonly Color Success = Shamrock;
public static readonly Color Warning = Amber;
public static readonly Color Error = Rose;
public static readonly Color Info = Sky;
public static Color GameRed
{
get
{
//IL_0012: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)Global.Instance != (Object)null)
{
return Global.Instance.RedUIColor;
}
}
catch
{
}
return Rose;
}
}
public static Color GameGreen
{
get
{
//IL_0012: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)Global.Instance != (Object)null)
{
return Global.Instance.GreenUIColor;
}
}
catch
{
}
return Shamrock;
}
}
public static string ToHex(Color color)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return ColorUtility.ToHtmlStringRGB(color);
}
public static Color WithAlpha(Color color, float alpha)
{
//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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
return new Color(color.r, color.g, color.b, alpha);
}
public static bool TryParseHex(string hex, out Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
color = default(Color);
if (string.IsNullOrWhiteSpace(hex))
{
return false;
}
string text = hex.Trim();
if (text.StartsWith("#"))
{
text = text.Substring(1);
}
if (text.Length != 6 && text.Length != 8)
{
return false;
}
return ColorUtility.TryParseHtmlString("#" + text, ref color);
}
public static Color ParseHex(string hex, Color fallback)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (!TryParseHex(hex, out var color))
{
return fallback;
}
return color;
}
}
public static class UITheme
{
public const float ReferenceWidth = 1920f;
public const float ReferenceHeight = 1080f;
public static float FontTitle = 24f;
public static float FontHeader = 20f;
public static float FontBody = 16f;
public static float FontHud = 18f;
public static float FontSmall = 13f;
public static float FontTiny = 11f;
public static float PaddingSmall = 6f;
public static float PaddingMedium = 12f;
public static float PaddingLarge = 20f;
public static float SpacingTight = 4f;
public static float SpacingNormal = 8f;
public static float SpacingLoose = 14f;
public static float ButtonHeight = 32f;
public static float InputHeight = 30f;
public static float ToggleSize = 22f;
public static float SliderHeight = 20f;
public static float ProgressHeight = 12f;
public static float TitleBarHeight = 44f;
public static float SeparatorHeight = 2f;
public static float TabHeight = 34f;
public static float BorderWidth = 1.5f;
public static float CornerRadiusHint = 4f;
public static float HudLineHeight = 22f;
public static float HudDefaultWidth = 320f;
public static int WindowSortingOrder = 100;
public static int TooltipSortingOrder = 250;
public static int DialogSortingOrder = 200;
public static float WindowMinWidth = 320f;
public static float WindowMinHeight = 200f;
private static bool _initialized;
private static TMP_FontAsset _cachedFont;
public static float Scale => Mathf.Clamp(((Screen.height > 0) ? ((float)Screen.height) : 1080f) / 1080f, 0.65f, 1.75f);
public static float ScaleX => Mathf.Clamp(((Screen.width > 0) ? ((float)Screen.width) : 1920f) / 1920f, 0.65f, 1.75f);
public static float ScaledFontTitle => S(FontTitle);
public static float ScaledFontHeader => S(FontHeader);
public static float ScaledFontBody => S(FontBody);
public static float ScaledFontHud => S(FontHud);
public static float ScaledFontSmall => S(FontSmall);
public static float ScaledFontTiny => S(FontTiny);
public static float ScaledButtonHeight => S(ButtonHeight);
public static float ScaledInputHeight => S(InputHeight);
public static float ScaledTitleBarHeight => S(TitleBarHeight);
public static float ScaledHudLineHeight => S(HudLineHeight);
public static TMP_FontAsset Font
{
get
{
if ((Object)(object)_cachedFont != (Object)null)
{
return _cachedFont;
}
TryCacheFont();
return _cachedFont;
}
}
public static void Initialize()
{
if (!_initialized)
{
_initialized = true;
TryCacheFont();
}
}
public static float S(float referencePixels)
{
return referencePixels * Scale;
}
public static Vector2 S(Vector2 reference)
{
//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)
return reference * Scale;
}
public static RectOffset ScaledPadding(int left, int right, int top, int bottom)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
float scale = Scale;
return new RectOffset(Mathf.RoundToInt((float)left * scale), Mathf.RoundToInt((float)right * scale), Mathf.RoundToInt((float)top * scale), Mathf.RoundToInt((float)bottom * scale));
}
private static void TryCacheFont()
{
TextMeshProUGUI val = Object.FindObjectOfType();
if ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)null)
{
_cachedFont = ((TMP_Text)val).font;
return;
}
TMP_FontAsset val2 = Resources.Load("Fonts & Materials/LiberationSans SDF");
if ((Object)(object)val2 != (Object)null)
{
_cachedFont = val2;
}
else if ((Object)(object)TMP_Settings.defaultFontAsset != (Object)null)
{
_cachedFont = TMP_Settings.defaultFontAsset;
}
}
public static void ApplyTextStyle(TextMeshProUGUI tmp, float fontSize, Color? color = null, TextAlignmentOptions alignment = (TextAlignmentOptions)513, bool wrap = false)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)tmp == (Object)null))
{
if ((Object)(object)Font != (Object)null)
{
((TMP_Text)tmp).font = Font;
}
((TMP_Text)tmp).fontSize = fontSize;
((Graphic)tmp).color = (Color)(((??)color) ?? UIColors.TextPrimary);
((TMP_Text)tmp).alignment = alignment;
((TMP_Text)tmp).enableWordWrapping = wrap;
((TMP_Text)tmp).richText = true;
((TMP_Text)tmp).overflowMode = (TextOverflowModes)0;
((Graphic)tmp).raycastTarget = false;
}
}
public static Vector2 ScaledSize(float width, float height)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return new Vector2(S(width), S(height));
}
public static Vector2 ClampToScreen(Vector2 size, float maxWidthFraction = 0.92f, float maxHeightFraction = 0.9f)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
float num = (float)Screen.width * maxWidthFraction;
float num2 = (float)Screen.height * maxHeightFraction;
return new Vector2(Mathf.Clamp(size.x, S(WindowMinWidth), num), Mathf.Clamp(size.y, S(WindowMinHeight), num2));
}
}
public enum UIButtonStyle
{
Default,
Primary,
Danger,
Active
}
public class UIButton
{
private Color _normal;
private Color _hover;
private Color _pressed;
private bool _hovered;
private bool _pressedDown;
private UIButtonStyle _style;
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public Button Button { get; }
public Image Background { get; }
public TextMeshProUGUI Label { get; }
public UIButtonStyle Style => _style;
private UIButton(GameObject go, RectTransform rt, Button btn, Image bg, TextMeshProUGUI label)
{
GameObject = go;
Rect = rt;
Button = btn;
Background = bg;
Label = label;
}
public static UIButton Create(Transform parent, string text, Action onClick = null, UIButtonStyle style = UIButtonStyle.Default, string name = null, float? preferredHeight = null)
{
//IL_0024: 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_00a5: 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_00b5: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: 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_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: 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_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Expected O, but got Unknown
GetStyleColors(style, out var normal, out var hover, out var pressed);
Image val = UIFactory.CreateImage(name ?? ("Button_" + text), parent, normal);
UIFactory.ApplyWhiteSprite(val);
RectTransform rectTransform = ((Graphic)val).rectTransform;
float value = preferredHeight ?? UITheme.ScaledButtonHeight;
GameObject gameObject = ((Component)val).gameObject;
float? preferredHeight2 = value;
float? minHeight = value;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight2, minHeight);
Button val2 = ((Component)val).gameObject.AddComponent();
((Selectable)val2).targetGraphic = (Graphic)(object)val;
ColorBlock colors = ((Selectable)val2).colors;
((ColorBlock)(ref colors)).normalColor = Color.white;
((ColorBlock)(ref colors)).highlightedColor = Color.white;
((ColorBlock)(ref colors)).pressedColor = Color.white;
((ColorBlock)(ref colors)).selectedColor = Color.white;
((ColorBlock)(ref colors)).disabledColor = new Color(1f, 1f, 1f, 0.4f);
((ColorBlock)(ref colors)).fadeDuration = 0f;
((Selectable)val2).colors = colors;
((Selectable)val2).transition = (Transition)1;
TextMeshProUGUI val3 = UIFactory.CreateTmp("Label", (Transform)(object)rectTransform, text, UITheme.ScaledFontBody, UIColors.TextPrimary, (TextAlignmentOptions)514);
UIHelpers.SetFillParent(((TMP_Text)val3).rectTransform, UITheme.S(4f));
((Graphic)val3).raycastTarget = false;
UIButton result = new UIButton(((Component)val).gameObject, rectTransform, val2, val, val3)
{
_normal = normal,
_hover = hover,
_pressed = pressed,
_style = style
};
EventTrigger trigger = ((Component)val).gameObject.AddComponent();
AddTrigger(trigger, (EventTriggerType)0, delegate
{
result._hovered = true;
result.ApplyVisualState();
});
AddTrigger(trigger, (EventTriggerType)1, delegate
{
result._hovered = false;
result._pressedDown = false;
result.ApplyVisualState();
});
AddTrigger(trigger, (EventTriggerType)2, delegate
{
result._pressedDown = true;
result.ApplyVisualState();
});
AddTrigger(trigger, (EventTriggerType)3, delegate
{
result._pressedDown = false;
result.ApplyVisualState();
});
if (onClick != null)
{
((UnityEvent)val2.onClick).AddListener(new UnityAction(onClick.Invoke));
}
return result;
}
public UIButton OnClick(Action action)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
if (action != null)
{
((UnityEvent)Button.onClick).AddListener(new UnityAction(action.Invoke));
}
return this;
}
public UIButton SetText(string text)
{
if ((Object)(object)Label != (Object)null)
{
((TMP_Text)Label).text = text ?? string.Empty;
}
return this;
}
public UIButton SetInteractable(bool interactable)
{
if (((Selectable)Button).interactable == interactable)
{
return this;
}
((Selectable)Button).interactable = interactable;
if (!interactable)
{
_hovered = false;
_pressedDown = false;
}
ApplyVisualState();
return this;
}
public UIButton SetStyle(UIButtonStyle style)
{
if (_style == style)
{
return this;
}
_style = style;
GetStyleColors(style, out _normal, out _hover, out _pressed);
ApplyVisualState();
return this;
}
public UIButton SetWidth(float width)
{
UIHelpers.EnsureLayoutElement(GameObject, width);
return this;
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
public void ApplyVisualState()
{
//IL_0031: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Background == (Object)null) && !((Object)(object)Button == (Object)null))
{
if (!((Selectable)Button).interactable)
{
((Graphic)Background).color = UIColors.WithAlpha(_normal, 0.45f);
}
else if (_pressedDown)
{
((Graphic)Background).color = _pressed;
}
else if (_hovered)
{
((Graphic)Background).color = _hover;
}
else
{
((Graphic)Background).color = _normal;
}
}
}
private static void GetStyleColors(UIButtonStyle style, out Color normal, out Color hover, out Color pressed)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_003e: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0066: 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_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_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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: 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_0098: Unknown result type (might be due to invalid IL or missing references)
switch (style)
{
case UIButtonStyle.Primary:
normal = UIColors.ButtonPrimary;
hover = UIColors.ButtonPrimaryHover;
pressed = UIColors.ButtonPrimaryPressed;
break;
case UIButtonStyle.Danger:
normal = UIColors.ButtonDanger;
hover = UIColors.ButtonDangerHover;
pressed = UIColors.ButtonDangerPressed;
break;
case UIButtonStyle.Active:
normal = UIColors.ButtonActive;
hover = UIColors.ButtonActiveHover;
pressed = UIColors.ButtonActivePressed;
break;
default:
normal = UIColors.ButtonNormal;
hover = UIColors.ButtonHover;
pressed = UIColors.ButtonPressed;
break;
}
}
private static void AddTrigger(EventTrigger trigger, EventTriggerType type, UnityAction cb)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_000d: Expected O, but got Unknown
Entry val = new Entry
{
eventID = type
};
((UnityEvent)(object)val.callback).AddListener(cb);
trigger.triggers.Add(val);
}
}
public class UIDragList
{
private class Row
{
public GameObject Go;
public RectTransform Rt;
public UIText Label;
public int Index;
}
private readonly List _rows = new List();
private Action _onReordered;
private int _dragIndex = -1;
private float _rowHeight;
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public RectTransform Content { get; }
private UIDragList(GameObject go, RectTransform rt, RectTransform content)
{
GameObject = go;
Rect = rt;
Content = content;
_rowHeight = UITheme.S(28f);
}
public static UIDragList Create(Transform parent, string name = "DragList")
{
UIScrollView uIScrollView = UIScrollView.Create(parent, name);
return new UIDragList(uIScrollView.GameObject, uIScrollView.Rect, uIScrollView.Content);
}
public UIDragList FillParent(float padding = 0f)
{
UIHelpers.SetFillParent(Rect, padding);
return this;
}
public UIDragList OnReordered(Action action)
{
_onReordered = action;
return this;
}
public void SetItems(IList labels)
{
//IL_004b: 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)
UIHelpers.DestroyChildren((Transform)(object)Content);
_rows.Clear();
_dragIndex = -1;
if (labels == null)
{
return;
}
for (int i = 0; i < labels.Count; i++)
{
GameObject gameObject = ((Component)UIFactory.CreateImage($"Row_{i}", (Transform)(object)Content, UIColors.EntryBg)).gameObject;
UIFactory.ApplyWhiteSprite(gameObject.GetComponent());
float? preferredHeight = _rowHeight;
float? minHeight = _rowHeight;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
UIText uIText = UIText.Create(gameObject.transform, "Label", $"{i + 1}. {labels[i]}", UITheme.ScaledFontBody, UIColors.TextPrimary, (TextAlignmentOptions)513);
UIHelpers.SetFillParent(uIText.Rect, UITheme.S(8f));
((Graphic)uIText.Tmp).raycastTarget = false;
Row row = new Row
{
Go = gameObject,
Rt = gameObject.GetComponent(),
Label = uIText,
Index = i
};
_rows.Add(row);
EventTrigger trigger = gameObject.AddComponent();
Add(trigger, (EventTriggerType)13, delegate
{
BeginDrag(row);
});
Add(trigger, (EventTriggerType)5, delegate(BaseEventData data)
{
OnDrag((PointerEventData)(object)((data is PointerEventData) ? data : null));
});
Add(trigger, (EventTriggerType)14, delegate
{
EndDrag();
});
}
}
public void SetLabels(IList labels)
{
if (labels == null || labels.Count != _rows.Count)
{
SetItems(labels);
return;
}
for (int i = 0; i < _rows.Count; i++)
{
_rows[i].Label.Text = $"{i + 1}. {labels[i]}";
}
}
private void BeginDrag(Row row)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
_dragIndex = _rows.IndexOf(row);
if (_dragIndex >= 0 && _dragIndex < _rows.Count)
{
((Graphic)_rows[_dragIndex].Go.GetComponent()).color = UIColors.ButtonHover;
}
}
private void OnDrag(PointerEventData data)
{
//IL_0022: 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)
Vector2 val = default(Vector2);
if (_dragIndex >= 0 && data != null && !((Object)(object)Content == (Object)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle(Content, data.position, data.pressEventCamera, ref val))
{
int num = Mathf.Clamp(Mathf.FloorToInt((0f - val.y) / _rowHeight), 0, _rows.Count - 1);
if (num != _dragIndex)
{
_rows[_dragIndex].Go.transform.SetSiblingIndex(num);
Row item = _rows[_dragIndex];
_rows.RemoveAt(_dragIndex);
_rows.Insert(num, item);
int dragIndex = _dragIndex;
_dragIndex = num;
Renumber();
_onReordered?.Invoke(dragIndex, num);
}
}
}
private void EndDrag()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
if (_dragIndex >= 0 && _dragIndex < _rows.Count)
{
((Graphic)_rows[_dragIndex].Go.GetComponent()).color = UIColors.EntryBg;
}
_dragIndex = -1;
}
private void Renumber()
{
for (int i = 0; i < _rows.Count; i++)
{
_rows[i].Index = i;
string text = _rows[i].Label.Text;
int num = text.IndexOf('.');
string arg = ((num >= 0 && num + 1 < text.Length) ? text.Substring(num + 1).TrimStart(Array.Empty()) : text);
_rows[i].Label.Text = $"{i + 1}. {arg}";
}
}
private static void Add(EventTrigger trigger, EventTriggerType type, UnityAction cb)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_000d: Expected O, but got Unknown
Entry val = new Entry
{
eventID = type
};
((UnityEvent)(object)val.callback).AddListener(cb);
trigger.triggers.Add(val);
}
}
public class UIDropdown
{
private readonly List _options = new List();
private readonly GameObject _listRoot;
private readonly RectTransform _listContent;
private Action _onChanged;
private bool _open;
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public TextMeshProUGUI Label { get; }
public int SelectedIndex { get; private set; }
public string SelectedValue
{
get
{
if (SelectedIndex < 0 || SelectedIndex >= _options.Count)
{
return null;
}
return _options[SelectedIndex];
}
}
private UIDropdown(GameObject go, RectTransform rt, TextMeshProUGUI label, GameObject listRoot, RectTransform listContent)
{
GameObject = go;
Rect = rt;
Label = label;
_listRoot = listRoot;
_listContent = listContent;
}
public static UIDropdown Create(Transform parent, IList options, int initialIndex = 0, Action onChanged = null, string name = "Dropdown")
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_00d8: 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_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Expected O, but got Unknown
float scaledButtonHeight = UITheme.ScaledButtonHeight;
RectTransform val = UIFactory.CreateRect(name, parent);
GameObject gameObject = ((Component)val).gameObject;
float? preferredHeight = scaledButtonHeight;
float? minHeight = scaledButtonHeight;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
Image val2 = UIFactory.CreateImage("Main", (Transform)(object)val, UIColors.ButtonNormal);
UIFactory.ApplyWhiteSprite(val2);
UIHelpers.SetFillParent(((Graphic)val2).rectTransform);
TextMeshProUGUI val3 = UIFactory.CreateTmp("Label", (Transform)(object)((Graphic)val2).rectTransform, "", UITheme.ScaledFontBody, UIColors.TextPrimary, (TextAlignmentOptions)514);
UIHelpers.SetFillParent(((TMP_Text)val3).rectTransform, UITheme.S(6f));
Image val4 = UIFactory.CreateImage("List", (Transform)(object)val, UIColors.Surface);
UIFactory.ApplyWhiteSprite(val4);
RectTransform rectTransform = ((Graphic)val4).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 0f);
rectTransform.anchorMax = new Vector2(1f, 0f);
rectTransform.pivot = new Vector2(0.5f, 1f);
rectTransform.anchoredPosition = new Vector2(0f, -2f);
UIFactory.AddVerticalLayout(((Component)val4).gameObject, UITheme.S(2f), UITheme.ScaledPadding(4, 4, 4, 4), (TextAnchor)0);
UIDropdown dropdown = new UIDropdown(((Component)val).gameObject, val, val3, ((Component)val4).gameObject, rectTransform)
{
_onChanged = onChanged
};
if (options != null)
{
for (int i = 0; i < options.Count; i++)
{
dropdown._options.Add(options[i]);
}
}
dropdown.RebuildOptions();
dropdown.Select(Mathf.Clamp(initialIndex, 0, Math.Max(0, dropdown._options.Count - 1)), notify: false);
((Component)val4).gameObject.SetActive(false);
Button obj = ((Component)val2).gameObject.AddComponent();
((Selectable)obj).targetGraphic = (Graphic)(object)val2;
((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
{
dropdown.ToggleList();
});
return dropdown;
}
public void SetOptions(IList options, int selectIndex = 0)
{
_options.Clear();
if (options != null)
{
for (int i = 0; i < options.Count; i++)
{
_options.Add(options[i]);
}
}
RebuildOptions();
Select(Mathf.Clamp(selectIndex, 0, Math.Max(0, _options.Count - 1)), notify: false);
}
public void Select(int index, bool notify = true)
{
if (_options.Count == 0)
{
SelectedIndex = -1;
((TMP_Text)Label).text = string.Empty;
return;
}
SelectedIndex = Mathf.Clamp(index, 0, _options.Count - 1);
((TMP_Text)Label).text = _options[SelectedIndex];
CloseList();
if (notify)
{
_onChanged?.Invoke(SelectedIndex, _options[SelectedIndex]);
}
}
public UIDropdown OnChanged(Action action)
{
_onChanged = action;
return this;
}
public void ToggleList()
{
if (_open)
{
CloseList();
}
else
{
OpenList();
}
}
public void OpenList()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
_open = true;
_listRoot.SetActive(true);
float num = UITheme.ScaledButtonHeight * 0.85f * (float)Mathf.Max(1, _options.Count) + UITheme.S(8f);
_listContent.sizeDelta = new Vector2(0f, num);
}
public void CloseList()
{
_open = false;
_listRoot.SetActive(false);
}
private void RebuildOptions()
{
UIHelpers.DestroyChildren((Transform)(object)_listContent);
float value = UITheme.ScaledButtonHeight * 0.85f;
for (int i = 0; i < _options.Count; i++)
{
int index = i;
string text = _options[i];
UIButton.Create((Transform)(object)_listContent, text, delegate
{
Select(index);
}, UIButtonStyle.Default, null, value);
}
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UIInputField
{
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public TMP_InputField Input { get; }
public TextMeshProUGUI TextComponent { get; }
public TextMeshProUGUI Placeholder { get; }
public string Text
{
get
{
return Input.text;
}
set
{
Input.text = value ?? string.Empty;
}
}
private UIInputField(GameObject go, RectTransform rt, TMP_InputField input, TextMeshProUGUI text, TextMeshProUGUI placeholder)
{
GameObject = go;
Rect = rt;
Input = input;
TextComponent = text;
Placeholder = placeholder;
}
public static UIInputField Create(Transform parent, string initial = "", string placeholder = "", Action onChanged = null, string name = "InputField")
{
//IL_0009: 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_00b7: 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_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
float scaledInputHeight = UITheme.ScaledInputHeight;
Image val = UIFactory.CreateImage(name, parent, UIColors.InputBg);
UIFactory.ApplyWhiteSprite(val);
GameObject gameObject = ((Component)val).gameObject;
float? preferredHeight = scaledInputHeight;
float? minHeight = scaledInputHeight;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
RectTransform val2 = UIFactory.CreateRect("TextArea", (Transform)(object)((Graphic)val).rectTransform);
UIHelpers.SetFillParent(val2, UITheme.S(8f));
((Component)val2).gameObject.AddComponent();
TextMeshProUGUI val3 = UIFactory.CreateTmp("Placeholder", (Transform)(object)val2, placeholder, UITheme.ScaledFontBody, UIColors.TextMuted, (TextAlignmentOptions)513);
UIHelpers.SetFillParent(((TMP_Text)val3).rectTransform);
((TMP_Text)val3).fontStyle = (FontStyles)2;
TextMeshProUGUI val4 = UIFactory.CreateTmp("Text", (Transform)(object)val2, initial, UITheme.ScaledFontBody, UIColors.InputText, (TextAlignmentOptions)513);
UIHelpers.SetFillParent(((TMP_Text)val4).rectTransform);
((Graphic)val4).raycastTarget = true;
TMP_InputField val5 = ((Component)val).gameObject.AddComponent();
val5.textViewport = val2;
val5.textComponent = (TMP_Text)(object)val4;
val5.placeholder = (Graphic)(object)val3;
val5.fontAsset = UITheme.Font;
val5.pointSize = UITheme.ScaledFontBody;
val5.text = initial ?? string.Empty;
val5.caretColor = UIColors.Sky;
val5.selectionColor = UIColors.WithAlpha(UIColors.Electric, 0.35f);
((Selectable)val5).targetGraphic = (Graphic)(object)val;
if (onChanged != null)
{
((UnityEvent)(object)val5.onValueChanged).AddListener((UnityAction)onChanged.Invoke);
}
return new UIInputField(((Component)val).gameObject, ((Graphic)val).rectTransform, val5, val4, val3);
}
public UIInputField OnChanged(Action action)
{
if (action != null)
{
((UnityEvent)(object)Input.onValueChanged).AddListener((UnityAction)action.Invoke);
}
return this;
}
public UIInputField OnEndEdit(Action action)
{
if (action != null)
{
((UnityEvent)(object)Input.onEndEdit).AddListener((UnityAction)action.Invoke);
}
return this;
}
public UIInputField SetInteractable(bool interactable)
{
((Selectable)Input).interactable = interactable;
return this;
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UIPanel
{
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public Image Background { get; }
public Image Border { get; private set; }
public Transform Content
{
get
{
if (!((Object)(object)Background != (Object)null))
{
return GameObject.transform;
}
return ((Component)Background).transform;
}
}
private UIPanel(GameObject go, RectTransform rt, Image bg)
{
GameObject = go;
Rect = rt;
Background = bg;
}
public static UIPanel Create(Transform parent, string name = "Panel", Color? background = null, bool withBorder = true)
{
//IL_0005: 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_0085: 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_003b: Unknown result type (might be due to invalid IL or missing references)
if (withBorder)
{
Image val = UIFactory.CreateImage(name, parent, UIColors.Border);
UIFactory.ApplyWhiteSprite(val);
RectTransform rectTransform = ((Graphic)val).rectTransform;
float padding = UITheme.S(UITheme.BorderWidth);
Image val2 = UIFactory.CreateImage("Background", (Transform)(object)rectTransform, (Color)(((??)background) ?? UIColors.PanelBg));
UIFactory.ApplyWhiteSprite(val2);
UIHelpers.SetFillParent(((Graphic)val2).rectTransform, padding);
return new UIPanel(((Component)val).gameObject, rectTransform, val2)
{
Border = val
};
}
Image val3 = UIFactory.CreateImage(name, parent, (Color)(((??)background) ?? UIColors.PanelBg));
UIFactory.ApplyWhiteSprite(val3);
return new UIPanel(((Component)val3).gameObject, ((Graphic)val3).rectTransform, val3);
}
public UIPanel SetSize(Vector2 size)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Rect.sizeDelta = size;
return this;
}
public UIPanel SetSize(float width, float height)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return SetSize(new Vector2(width, height));
}
public UIPanel SetAnchor(Vector2 min, Vector2 max, Vector2? pivot = null)
{
//IL_0006: 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)
UIHelpers.SetAnchor(Rect, min, max, pivot);
return this;
}
public UIPanel SetPointAnchor(float x, float y, Vector2? pivot = null)
{
UIHelpers.SetPointAnchor(Rect, x, y, pivot);
return this;
}
public UIPanel FillParent(float padding = 0f)
{
UIHelpers.SetFillParent(Rect, padding);
return this;
}
public UIPanel WithVerticalLayout(float spacing = -1f, RectOffset padding = null)
{
UIFactory.AddVerticalLayout(((Object)(object)Background != (Object)null) ? ((Component)Background).gameObject : GameObject, spacing, padding, (TextAnchor)0);
return this;
}
public UIPanel WithHorizontalLayout(float spacing = -1f, RectOffset padding = null)
{
UIFactory.AddHorizontalLayout(((Object)(object)Background != (Object)null) ? ((Component)Background).gameObject : GameObject, spacing, padding, (TextAnchor)3);
return this;
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UIProgressBar
{
private float _value;
private float _min;
private float _max;
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public Image Track { get; }
public Image Fill { get; }
public TextMeshProUGUI Label { get; }
public float Value
{
get
{
return _value;
}
set
{
SetValue(value);
}
}
public float Normalized
{
get
{
float num = _max - _min;
if (!(num > 0.0001f))
{
return 0f;
}
return Mathf.Clamp01((_value - _min) / num);
}
}
private UIProgressBar(GameObject go, RectTransform rt, Image track, Image fill, TextMeshProUGUI label, float min, float max, float initial)
{
GameObject = go;
Rect = rt;
Track = track;
Fill = fill;
Label = label;
_min = min;
_max = max;
SetValue(initial);
}
public static UIProgressBar Create(Transform parent, string label = null, float min = 0f, float max = 1f, float initial = 0f, Color? fillColor = null, string name = "ProgressBar")
{
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
float num = UITheme.S(UITheme.ProgressHeight);
float value = (string.IsNullOrEmpty(label) ? (num + UITheme.S(4f)) : (num + UITheme.S(22f)));
RectTransform val = UIFactory.CreateRect(name, parent);
GameObject gameObject = ((Component)val).gameObject;
float? preferredHeight = value;
float? minHeight = value;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
UIFactory.AddVerticalLayout(((Component)val).gameObject, UITheme.S(2f), UITheme.ScaledPadding(2, 2, 2, 2), (TextAnchor)0);
TextMeshProUGUI val2 = null;
if (!string.IsNullOrEmpty(label))
{
val2 = UIFactory.CreateTmp("Label", (Transform)(object)val, label, UITheme.ScaledFontSmall, UIColors.TextSecondary, (TextAlignmentOptions)513);
GameObject gameObject2 = ((Component)val2).gameObject;
minHeight = UITheme.S(16f);
UIHelpers.EnsureLayoutElement(gameObject2, null, minHeight);
}
Image val3 = UIFactory.CreateImage("Track", (Transform)(object)val, UIColors.ProgressTrack, raycast: false);
UIFactory.ApplyWhiteSprite(val3);
GameObject gameObject3 = ((Component)val3).gameObject;
minHeight = num;
preferredHeight = num;
UIHelpers.EnsureLayoutElement(gameObject3, null, minHeight, preferredHeight);
Image val4 = UIFactory.CreateImage("Fill", (Transform)(object)((Graphic)val3).rectTransform, (Color)(((??)fillColor) ?? UIColors.ProgressFill), raycast: false);
UIFactory.ApplyWhiteSprite(val4);
RectTransform rectTransform = ((Graphic)val4).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 0f);
rectTransform.anchorMax = new Vector2(0f, 1f);
rectTransform.pivot = new Vector2(0f, 0.5f);
rectTransform.offsetMin = Vector2.zero;
rectTransform.offsetMax = Vector2.zero;
return new UIProgressBar(((Component)val).gameObject, val, val3, val4, val2, min, max, initial);
}
public UIProgressBar SetValue(float value)
{
//IL_0035: 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_0051: 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)
_value = Mathf.Clamp(value, _min, _max);
float normalized = Normalized;
RectTransform rectTransform = ((Graphic)Fill).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 0f);
rectTransform.anchorMax = new Vector2(normalized, 1f);
rectTransform.offsetMin = Vector2.zero;
rectTransform.offsetMax = Vector2.zero;
return this;
}
public UIProgressBar SetRange(float min, float max)
{
_min = min;
_max = max;
return SetValue(_value);
}
public UIProgressBar SetFillColor(Color color)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((Graphic)Fill).color = color;
return this;
}
public UIProgressBar SetLabel(string text)
{
if ((Object)(object)Label != (Object)null)
{
((TMP_Text)Label).text = text ?? string.Empty;
}
return this;
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UIScrollView
{
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public ScrollRect ScrollRect { get; }
public RectTransform Viewport { get; }
public RectTransform Content { get; }
private UIScrollView(GameObject go, RectTransform rt, ScrollRect sr, RectTransform viewport, RectTransform content)
{
GameObject = go;
Rect = rt;
ScrollRect = sr;
Viewport = viewport;
Content = content;
}
public static UIScrollView Create(Transform parent, string name = "ScrollView", bool vertical = true, bool horizontal = false)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_00a3: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
Image obj = UIFactory.CreateImage(name, parent, UIColors.ScrollBg);
UIFactory.ApplyWhiteSprite(obj);
RectTransform rectTransform = ((Graphic)obj).rectTransform;
Image obj2 = UIFactory.CreateImage("Viewport", (Transform)(object)rectTransform, UIColors.WithAlpha(UIColors.ScrollBg, 0.01f));
UIFactory.ApplyWhiteSprite(obj2);
RectTransform rectTransform2 = ((Graphic)obj2).rectTransform;
UIHelpers.SetFillParent(rectTransform2, UITheme.S(2f));
((Component)obj2).gameObject.AddComponent().showMaskGraphic = false;
RectTransform val = UIFactory.CreateRect("Content", (Transform)(object)rectTransform2);
val.anchorMin = new Vector2(0f, 1f);
val.anchorMax = new Vector2(1f, 1f);
val.pivot = new Vector2(0.5f, 1f);
val.anchoredPosition = Vector2.zero;
val.sizeDelta = new Vector2(0f, 0f);
UIFactory.AddVerticalLayout(((Component)val).gameObject, UITheme.S(UITheme.SpacingNormal), UITheme.ScaledPadding(12, 12, 10, 14), (TextAnchor)0);
UIFactory.AddContentSizeFitter(((Component)val).gameObject, (FitMode)0, (FitMode)2);
ScrollRect val2 = ((Component)obj).gameObject.AddComponent();
val2.viewport = rectTransform2;
val2.content = val;
val2.horizontal = horizontal;
val2.vertical = vertical;
val2.movementType = (MovementType)2;
val2.scrollSensitivity = 30f;
val2.inertia = true;
val2.decelerationRate = 0.15f;
return new UIScrollView(((Component)obj).gameObject, rectTransform, val2, rectTransform2, val);
}
public UIScrollView FillParent(float padding = 0f)
{
UIHelpers.SetFillParent(Rect, padding);
return this;
}
public void ClearContent()
{
UIHelpers.DestroyChildren((Transform)(object)Content);
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UISeparator
{
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public Image Image { get; }
private UISeparator(GameObject go, RectTransform rt, Image img)
{
GameObject = go;
Rect = rt;
Image = img;
}
public static UISeparator Create(Transform parent, string name = "Separator", bool horizontal = true)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
Image val = UIFactory.CreateImage(name, parent, UIColors.Separator, raycast: false);
UIFactory.ApplyWhiteSprite(val);
float value = UITheme.S(UITheme.SeparatorHeight);
if (horizontal)
{
GameObject gameObject = ((Component)val).gameObject;
float? preferredHeight = value;
float? minHeight = value;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
}
else
{
GameObject gameObject2 = ((Component)val).gameObject;
float? preferredWidth = value;
float? minHeight = value;
UIHelpers.EnsureLayoutElement(gameObject2, preferredWidth, null, minHeight);
}
return new UISeparator(((Component)val).gameObject, ((Graphic)val).rectTransform, val);
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UISlider
{
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public Slider Slider { get; }
public TextMeshProUGUI Label { get; }
public TextMeshProUGUI ValueLabel { get; }
public float Value
{
get
{
return Slider.value;
}
set
{
Slider.value = value;
}
}
private UISlider(GameObject go, RectTransform rt, Slider slider, TextMeshProUGUI label, TextMeshProUGUI valueLabel)
{
GameObject = go;
Rect = rt;
Slider = slider;
Label = label;
ValueLabel = valueLabel;
}
public static UISlider Create(Transform parent, string label = null, float min = 0f, float max = 1f, float initial = 0.5f, Action onChanged = null, string name = "Slider", bool wholeNumbers = false, string valueFormat = "F2")
{
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_0387: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: 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_03c4: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: 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_00f2: Expected O, but got Unknown
//IL_0100: 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)
float value = UITheme.S(UITheme.SliderHeight + 16f);
RectTransform val = UIFactory.CreateRect(name, parent);
GameObject gameObject = ((Component)val).gameObject;
float? preferredHeight = value;
float? minHeight = value;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
UIFactory.AddVerticalLayout(((Component)val).gameObject, UITheme.S(2f), UITheme.ScaledPadding(4, 4, 2, 2), (TextAnchor)0);
TextMeshProUGUI val2 = null;
TextMeshProUGUI valueTmp = null;
if (!string.IsNullOrEmpty(label))
{
RectTransform val3 = UIFactory.CreateRect("Header", (Transform)(object)val);
GameObject gameObject2 = ((Component)val3).gameObject;
minHeight = UITheme.S(18f);
UIHelpers.EnsureLayoutElement(gameObject2, null, minHeight);
UIFactory.AddHorizontalLayout(((Component)val3).gameObject, 4f, new RectOffset(0, 0, 0, 0), (TextAnchor)3, controlChildWidth: false);
val2 = UIFactory.CreateTmp("Label", (Transform)(object)val3, label, UITheme.ScaledFontSmall, UIColors.TextSecondary, (TextAlignmentOptions)513);
GameObject gameObject3 = ((Component)val2).gameObject;
minHeight = UITheme.S(18f);
UIHelpers.EnsureLayoutElement(gameObject3, null, minHeight);
((Component)val2).gameObject.GetComponent().flexibleWidth = 1f;
valueTmp = UIFactory.CreateTmp("Value", (Transform)(object)val3, initial.ToString(valueFormat), UITheme.ScaledFontSmall, UIColors.Sky, (TextAlignmentOptions)516);
UIHelpers.EnsureLayoutElement(((Component)valueTmp).gameObject, UITheme.S(60f), UITheme.S(18f));
}
RectTransform val4 = UIFactory.CreateRect("SliderRoot", (Transform)(object)val);
float value2 = UITheme.S(UITheme.SliderHeight);
GameObject gameObject4 = ((Component)val4).gameObject;
minHeight = value2;
preferredHeight = value2;
UIHelpers.EnsureLayoutElement(gameObject4, null, minHeight, preferredHeight);
Image val5 = UIFactory.CreateImage("Track", (Transform)(object)val4, UIColors.SliderTrack);
UIFactory.ApplyWhiteSprite(val5);
UIHelpers.SetFillParent(((Graphic)val5).rectTransform);
RectTransform val6 = UIFactory.CreateRect("Fill Area", (Transform)(object)((Graphic)val5).rectTransform);
UIHelpers.SetFillParent(val6);
Image val7 = UIFactory.CreateImage("Fill", (Transform)(object)val6, UIColors.SliderFill, raycast: false);
UIFactory.ApplyWhiteSprite(val7);
UIHelpers.SetFillParent(((Graphic)val7).rectTransform);
RectTransform val8 = UIFactory.CreateRect("Handle Slide Area", (Transform)(object)((Graphic)val5).rectTransform);
UIHelpers.SetFillParent(val8);
float num = UITheme.S(16f);
Image val9 = UIFactory.CreateImage("Handle", (Transform)(object)val8, UIColors.SliderHandle);
UIFactory.ApplyWhiteSprite(val9);
((Graphic)val9).rectTransform.sizeDelta = new Vector2(num, num);
Slider val10 = ((Component)val4).gameObject.AddComponent();
val10.fillRect = ((Graphic)val7).rectTransform;
val10.handleRect = ((Graphic)val9).rectTransform;
((Selectable)val10).targetGraphic = (Graphic)(object)val9;
val10.direction = (Direction)0;
val10.minValue = min;
val10.maxValue = max;
val10.wholeNumbers = wholeNumbers;
val10.value = initial;
((Graphic)val7).rectTransform.anchorMin = new Vector2(0f, 0f);
((Graphic)val7).rectTransform.anchorMax = new Vector2(0f, 1f);
((Graphic)val7).rectTransform.pivot = new Vector2(0f, 0.5f);
((Graphic)val7).rectTransform.offsetMin = Vector2.zero;
((Graphic)val7).rectTransform.offsetMax = Vector2.zero;
((Graphic)val9).rectTransform.anchorMin = new Vector2(0f, 0.5f);
((Graphic)val9).rectTransform.anchorMax = new Vector2(0f, 0.5f);
((Graphic)val9).rectTransform.pivot = new Vector2(0.5f, 0.5f);
((UnityEvent)(object)val10.onValueChanged).AddListener((UnityAction)delegate(float v)
{
if ((Object)(object)valueTmp != (Object)null)
{
((TMP_Text)valueTmp).text = v.ToString(valueFormat);
}
onChanged?.Invoke(v);
});
return new UISlider(((Component)val).gameObject, val, val10, val2, valueTmp);
}
public UISlider OnChanged(Action action)
{
if (action != null)
{
((UnityEvent)(object)Slider.onValueChanged).AddListener((UnityAction)action.Invoke);
}
return this;
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UITabs
{
private class TabEntry
{
public string Title;
public UIButton Button;
public GameObject Page;
}
private readonly List _tabs = new List();
private Action _onTabChanged;
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public RectTransform TabBar { get; }
public RectTransform PageHost { get; }
public int ActiveIndex { get; private set; } = -1;
private UITabs(GameObject go, RectTransform rt, RectTransform tabBar, RectTransform pageHost)
{
GameObject = go;
Rect = rt;
TabBar = tabBar;
PageHost = pageHost;
}
public static UITabs Create(Transform parent, string name = "Tabs")
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_007e: 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_0111: 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)
RectTransform val = UIFactory.CreateRect(name, parent);
UIHelpers.SetFillParent(val);
UIFactory.AddVerticalLayout(((Component)val).gameObject, UITheme.S(UITheme.SpacingTight), new RectOffset(0, 0, 0, 0), (TextAnchor)0);
float value = UITheme.S(UITheme.TabHeight);
RectTransform val2 = UIFactory.CreateRect("TabBar", (Transform)(object)val);
GameObject gameObject = ((Component)val2).gameObject;
float? preferredHeight = value;
float? minHeight = value;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
UIFactory.ApplyWhiteSprite(UIHelpers.EnsureImage(((Component)val2).gameObject, UIColors.WithAlpha(UIColors.TitleBar, 0.6f), raycast: false));
UIFactory.AddHorizontalLayout(((Component)val2).gameObject, UITheme.S(4f), UITheme.ScaledPadding(6, 6, 4, 0), (TextAnchor)3, controlChildWidth: false);
RectTransform val3 = UIFactory.CreateRect("Pages", (Transform)(object)val);
LayoutElement obj = UIHelpers.EnsureLayoutElement(((Component)val3).gameObject);
obj.flexibleHeight = 1f;
obj.minHeight = UITheme.S(100f);
UIHelpers.EnsureImage(((Component)val3).gameObject, UIColors.WithAlpha(UIColors.PanelBg, 0.5f), raycast: false);
return new UITabs(((Component)val).gameObject, val, val2, val3);
}
public Transform AddTab(string title, bool select = false)
{
float value = UITheme.S(UITheme.TabHeight) - UITheme.S(4f);
int index = _tabs.Count;
RectTransform val = UIFactory.CreateRect("Page_" + title, (Transform)(object)PageHost);
UIHelpers.SetFillParent(val);
((Component)val).gameObject.SetActive(false);
UIButton uIButton = UIButton.Create((Transform)(object)TabBar, title, delegate
{
Select(index);
}, UIButtonStyle.Default, null, value);
uIButton.SetWidth(UITheme.S(100f));
_tabs.Add(new TabEntry
{
Title = title,
Button = uIButton,
Page = ((Component)val).gameObject
});
if (select || ActiveIndex < 0)
{
Select(index, notify: false);
}
return (Transform)(object)val;
}
public void Select(int index, bool notify = true)
{
if (index >= 0 && index < _tabs.Count)
{
ActiveIndex = index;
for (int i = 0; i < _tabs.Count; i++)
{
bool flag = i == index;
_tabs[i].Page.SetActive(flag);
_tabs[i].Button.SetStyle(flag ? UIButtonStyle.Active : UIButtonStyle.Default);
}
if (notify)
{
_onTabChanged?.Invoke(index);
}
}
}
public UITabs OnTabChanged(Action action)
{
_onTabChanged = action;
return this;
}
public GameObject GetPage(int index)
{
if (index < 0 || index >= _tabs.Count)
{
return null;
}
return _tabs[index].Page;
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UIText
{
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public TextMeshProUGUI Tmp { get; }
public string Text
{
get
{
return ((TMP_Text)Tmp).text;
}
set
{
((TMP_Text)Tmp).text = value ?? string.Empty;
}
}
public Color Color
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return ((Graphic)Tmp).color;
}
set
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((Graphic)Tmp).color = value;
}
}
public float FontSize
{
get
{
return ((TMP_Text)Tmp).fontSize;
}
set
{
((TMP_Text)Tmp).fontSize = value;
}
}
private UIText(GameObject go, RectTransform rt, TextMeshProUGUI tmp)
{
GameObject = go;
Rect = rt;
Tmp = tmp;
}
public static UIText Create(Transform parent, string name = "Text", string text = "", float fontSize = -1f, Color? color = null, TextAlignmentOptions alignment = (TextAlignmentOptions)513, bool wrap = false)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI val = UIFactory.CreateTmp(name, parent, text, fontSize, color, alignment, wrap);
return new UIText(((Component)val).gameObject, ((TMP_Text)val).rectTransform, val);
}
public UIText SetText(string text)
{
Text = text;
return this;
}
public UIText SetRich(string label, string value, Color valueColor, string unit = null)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
Text = RichText.Labeled(label, value, valueColor, unit);
return this;
}
public UIText SetRich(string label, float value, Color valueColor, string unit = null, string format = "F1")
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
Text = RichText.Labeled(label, value, valueColor, unit, format);
return this;
}
public UIText SetRich(string label, int value, Color valueColor, string unit = null)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
Text = RichText.Labeled(label, value, valueColor, unit);
return this;
}
public UIText SetRichWithRate(string label, float value, float rate, Color color, string format = "F0", string rateFormat = "F1")
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
Text = RichText.LabeledWithRate(label, value, rate, color, format, rateFormat);
return this;
}
public UIText FillParent(float padding = 0f)
{
UIHelpers.SetFillParent(Rect, padding);
return this;
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UIToggle
{
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public Toggle Toggle { get; }
public TextMeshProUGUI Label { get; }
public Image Box { get; }
public Image Checkmark { get; }
public bool IsOn
{
get
{
return Toggle.isOn;
}
set
{
Toggle.isOn = value;
}
}
private UIToggle(GameObject go, RectTransform rt, Toggle toggle, TextMeshProUGUI label, Image box, Image check)
{
GameObject = go;
Rect = rt;
Toggle = toggle;
Label = label;
Box = box;
Checkmark = check;
}
public static UIToggle Create(Transform parent, string label, bool initial = false, Action onChanged = null, string name = null)
{
//IL_0090: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
float value = UITheme.S(UITheme.ButtonHeight);
float num = UITheme.S(UITheme.ToggleSize);
RectTransform val = UIFactory.CreateRect(name ?? ("Toggle_" + label), parent);
GameObject gameObject = ((Component)val).gameObject;
float? preferredHeight = value;
float? minHeight = value;
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
UIFactory.AddHorizontalLayout(((Component)val).gameObject, UITheme.S(UITheme.SpacingNormal), UITheme.ScaledPadding(4, 8, 2, 2), (TextAnchor)3, controlChildWidth: false);
Image boxImg = UIFactory.CreateImage("Box", (Transform)(object)val, UIColors.ToggleOff);
UIFactory.ApplyWhiteSprite(boxImg);
RectTransform rectTransform = ((Graphic)boxImg).rectTransform;
rectTransform.sizeDelta = new Vector2(num, num);
UIHelpers.EnsureLayoutElement(((Component)boxImg).gameObject, num, num);
Image val2 = UIFactory.CreateImage("Check", (Transform)(object)rectTransform, UIColors.Checkmark, raycast: false);
UIFactory.ApplyWhiteSprite(val2);
UIHelpers.SetFillParent(((Graphic)val2).rectTransform, num * 0.22f);
Toggle val3 = ((Component)val).gameObject.AddComponent();
((Selectable)val3).targetGraphic = (Graphic)(object)boxImg;
val3.graphic = (Graphic)(object)val2;
val3.isOn = initial;
TextMeshProUGUI val4 = UIFactory.CreateTmp("Label", (Transform)(object)val, label, UITheme.ScaledFontBody, UIColors.TextPrimary, (TextAlignmentOptions)513);
((Graphic)val4).raycastTarget = false;
GameObject gameObject2 = ((Component)val4).gameObject;
minHeight = value;
UIHelpers.EnsureLayoutElement(gameObject2, null, minHeight);
((Component)val4).gameObject.GetComponent().flexibleWidth = 1f;
ApplyVisual(initial);
((UnityEvent)(object)val3.onValueChanged).AddListener((UnityAction)delegate(bool v)
{
ApplyVisual(v);
onChanged?.Invoke(v);
});
return new UIToggle(((Component)val).gameObject, val, val3, val4, boxImg, val2);
void ApplyVisual(bool on)
{
//IL_0010: 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)
((Graphic)boxImg).color = (on ? UIColors.ToggleOn : UIColors.ToggleOff);
}
}
public UIToggle OnChanged(Action action)
{
if (action != null)
{
((UnityEvent)(object)Toggle.onValueChanged).AddListener((UnityAction)action.Invoke);
}
return this;
}
public void SetActive(bool active)
{
GameObject.SetActive(active);
}
}
public class UITooltip
{
private static UITooltip _shared;
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public UIText Text { get; }
public Canvas Canvas { get; }
public static UITooltip Shared
{
get
{
if (_shared == null || (Object)(object)_shared.GameObject == (Object)null)
{
_shared = Create();
}
return _shared;
}
}
private UITooltip(GameObject go, RectTransform rt, UIText text, Canvas canvas)
{
GameObject = go;
Rect = rt;
Text = text;
Canvas = canvas;
}
public static UITooltip Create(string name = "SparrohUITooltip")
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
Canvas val = UIFactory.CreateOverlayCanvas(name + "_Canvas", UITheme.TooltipSortingOrder);
UIPanel uIPanel = UIPanel.Create(((Component)val).transform, name, UIColors.TooltipBg);
uIPanel.Rect.pivot = new Vector2(0f, 1f);
uIPanel.SetPointAnchor(0f, 1f, (Vector2?)new Vector2(0f, 1f));
uIPanel.SetSize(UITheme.S(280f), UITheme.S(60f));
UIText uIText = UIText.Create(uIPanel.Content, "TooltipText", "", UITheme.ScaledFontSmall, UIColors.TextPrimary, (TextAlignmentOptions)257, wrap: true);
UIHelpers.SetFillParent(uIText.Rect, UITheme.S(8f));
UITooltip uITooltip = new UITooltip(uIPanel.GameObject, uIPanel.Rect, uIText, val);
uITooltip.Hide();
return uITooltip;
}
public void Show(string message, Vector2 screenPosition)
{
//IL_0048: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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)
if (string.IsNullOrEmpty(message))
{
Hide();
return;
}
Text.Text = message;
GameObject.SetActive(true);
((Component)Canvas).gameObject.SetActive(true);
Transform transform = ((Component)Canvas).transform;
Vector2 val = default(Vector2);
if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((transform is RectTransform) ? transform : null), screenPosition, (Camera)null, ref val))
{
val += new Vector2(UITheme.S(14f), UITheme.S(-14f));
Rect.anchoredPosition = val;
}
float num = UITheme.S(280f);
float num2 = Mathf.Max(UITheme.S(40f), ((TMP_Text)Text.Tmp).preferredHeight + UITheme.S(20f));
Rect.sizeDelta = new Vector2(num, num2);
ClampToScreen();
}
public void ShowAtMouse(string message)
{
//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)
Show(message, Vector2.op_Implicit(Input.mousePosition));
}
public void Hide()
{
if ((Object)(object)GameObject != (Object)null)
{
GameObject.SetActive(false);
}
}
public void Destroy()
{
if ((Object)(object)Canvas != (Object)null)
{
UIHelpers.DestroySafe((Object)(object)((Component)Canvas).gameObject);
}
if (_shared == this)
{
_shared = null;
}
}
public static void Attach(GameObject target, string message)
{
if (!((Object)(object)target == (Object)null))
{
EventTrigger val = target.GetComponent();
if ((Object)(object)val == (Object)null)
{
val = target.AddComponent();
}
TooltipHoverFollower follower = target.GetComponent();
if ((Object)(object)follower == (Object)null)
{
follower = target.AddComponent();
}
follower.Message = message;
Add(val, (EventTriggerType)0, delegate
{
follower.Message = message;
Shared.ShowAtMouse(message);
});
Add(val, (EventTriggerType)1, delegate
{
Shared.Hide();
});
}
}
private void ClampToScreen()
{
//IL_0067: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)Canvas).transform;
if (!((Object)(object)((transform is RectTransform) ? transform : null) == (Object)null))
{
Vector3[] array = (Vector3[])(object)new Vector3[4];
Rect.GetWorldCorners(array);
float x = array[0].x;
float x2 = array[2].x;
float y = array[0].y;
float y2 = array[1].y;
Vector2 anchoredPosition = Rect.anchoredPosition;
if (x2 > (float)Screen.width)
{
anchoredPosition.x -= x2 - (float)Screen.width;
}
if (x < 0f)
{
anchoredPosition.x -= x;
}
if (y < 0f)
{
anchoredPosition.y -= y;
}
if (y2 > (float)Screen.height)
{
anchoredPosition.y -= y2 - (float)Screen.height;
}
Rect.anchoredPosition = anchoredPosition;
}
}
private static void Add(EventTrigger trigger, EventTriggerType type, UnityAction cb)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_000d: Expected O, but got Unknown
Entry val = new Entry
{
eventID = type
};
((UnityEvent)(object)val.callback).AddListener(cb);
trigger.triggers.Add(val);
}
}
public class TooltipHoverFollower : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
public string Message;
private bool _hovering;
public void OnPointerEnter(PointerEventData eventData)
{
_hovering = true;
if (!string.IsNullOrEmpty(Message))
{
UITooltip.Shared.ShowAtMouse(Message);
}
}
public void OnPointerExit(PointerEventData eventData)
{
_hovering = false;
UITooltip.Shared.Hide();
}
private void Update()
{
if (_hovering && !string.IsNullOrEmpty(Message) && (Object)(object)UITooltip.Shared.GameObject != (Object)null && UITooltip.Shared.GameObject.activeSelf)
{
UITooltip.Shared.ShowAtMouse(Message);
}
}
}
public static class UIDialog
{
public static UIWindow Confirm(string title, string message, Action onConfirm, Action onCancel = null, string confirmText = "Confirm", string cancelText = "Cancel")
{
//IL_0024: 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_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Expected O, but got Unknown
UIWindow window = UIWindow.Create("Dialog", (Vector2?)new Vector2(420f, 220f), title, scrollable: false, closeButton: true, (int?)UITheme.DialogSortingOrder);
window.OnClose(delegate
{
onCancel?.Invoke();
});
Transform content = window.Content;
UIFactory.AddVerticalLayout(((Component)content).gameObject, UITheme.S(UITheme.SpacingNormal), UITheme.ScaledPadding(16, 16, 12, 12), (TextAnchor)4);
UIText uIText = UIText.Create(content, "Message", message, UITheme.ScaledFontBody, UIColors.TextSecondary, (TextAlignmentOptions)514, wrap: true);
GameObject gameObject = uIText.GameObject;
float? preferredHeight = UITheme.S(80f);
float? minHeight = UITheme.S(60f);
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
uIText.GameObject.GetComponent().flexibleHeight = 1f;
RectTransform obj = UIFactory.CreateRect("Buttons", content);
GameObject gameObject2 = ((Component)obj).gameObject;
minHeight = UITheme.ScaledButtonHeight + UITheme.S(8f);
UIHelpers.EnsureLayoutElement(gameObject2, null, minHeight);
UIFactory.AddHorizontalLayout(((Component)obj).gameObject, UITheme.S(12f), new RectOffset(0, 0, 0, 0), (TextAnchor)4, controlChildWidth: false);
UIButton.Create((Transform)(object)obj, cancelText, delegate
{
window.Destroy();
onCancel?.Invoke();
}).SetWidth(UITheme.S(120f));
UIButton.Create((Transform)(object)obj, confirmText, delegate
{
window.Destroy();
onConfirm?.Invoke();
}, UIButtonStyle.Primary).SetWidth(UITheme.S(120f));
return window;
}
public static UIWindow Alert(string title, string message, Action onOk = null, string okText = "OK")
{
//IL_001d: 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)
UIWindow window = UIWindow.Create("Alert", (Vector2?)new Vector2(400f, 200f), title, scrollable: false, closeButton: true, (int?)UITheme.DialogSortingOrder);
Transform content = window.Content;
UIFactory.AddVerticalLayout(((Component)content).gameObject, UITheme.S(UITheme.SpacingNormal), UITheme.ScaledPadding(16, 16, 12, 12), (TextAnchor)4);
UIText uIText = UIText.Create(content, "Message", message, UITheme.ScaledFontBody, UIColors.TextSecondary, (TextAlignmentOptions)514, wrap: true);
GameObject gameObject = uIText.GameObject;
float? preferredHeight = UITheme.S(70f);
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight);
uIText.GameObject.GetComponent().flexibleHeight = 1f;
UIButton.Create(content, okText, delegate
{
window.Destroy();
onOk?.Invoke();
}, UIButtonStyle.Primary);
return window;
}
}
public class UIWindow
{
private readonly GameObject _canvasGo;
private Action _onClose;
public GameObject GameObject { get; }
public RectTransform Rect { get; }
public Canvas Canvas { get; }
public Transform Content { get; private set; }
public UIScrollView ScrollView { get; private set; }
public TextMeshProUGUI TitleText { get; }
public bool IsVisible { get; private set; }
private UIWindow(GameObject canvasGo, Canvas canvas, GameObject panelGo, RectTransform panelRt, TextMeshProUGUI titleText)
{
_canvasGo = canvasGo;
Canvas = canvas;
GameObject = panelGo;
Rect = panelRt;
TitleText = titleText;
}
public static UIWindow Create(string name, Vector2? referenceSize = null, string title = null, bool scrollable = false, bool closeButton = true, int? sortingOrder = null)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0036: 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_0041: 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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: 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_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: 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_01c0: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0387: Unknown result type (might be due to invalid IL or missing references)
//IL_0393: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: 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)
//IL_02f9: 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_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
UITheme.Initialize();
Vector2 val = (Vector2)(((??)referenceSize) ?? new Vector2(720f, 520f));
val = UITheme.ScaledSize(val.x, val.y);
val = UITheme.ClampToScreen(val);
Canvas val2 = UIFactory.CreateOverlayCanvas(name + "_Canvas", sortingOrder ?? UITheme.WindowSortingOrder);
GameObject gameObject = ((Component)val2).gameObject;
Image obj = UIFactory.CreateImage("Backdrop", ((Component)val2).transform, UIColors.WithAlpha(Color.black, 0.45f));
UIFactory.ApplyWhiteSprite(obj);
UIHelpers.SetFillParent(((Graphic)obj).rectTransform);
UIPanel uIPanel = UIPanel.Create(((Component)val2).transform, name, UIColors.PanelBg);
RectTransform rect = uIPanel.Rect;
RectTransform rect2 = uIPanel.Rect;
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0.5f, 0.5f);
rect2.anchorMax = val3;
rect.anchorMin = val3;
uIPanel.Rect.pivot = new Vector2(0.5f, 0.5f);
uIPanel.Rect.sizeDelta = val;
uIPanel.Rect.anchoredPosition = Vector2.zero;
float scaledTitleBarHeight = UITheme.ScaledTitleBarHeight;
Image val4 = UIFactory.CreateImage("TitleBar", uIPanel.Content, UIColors.TitleBar);
UIFactory.ApplyWhiteSprite(val4);
UIHelpers.SetTopStretch(((Graphic)val4).rectTransform, scaledTitleBarHeight);
Image obj2 = UIFactory.CreateImage("Accent", (Transform)(object)((Graphic)val4).rectTransform, UIColors.BorderAccent, raycast: false);
UIFactory.ApplyWhiteSprite(obj2);
RectTransform rectTransform = ((Graphic)obj2).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 0f);
rectTransform.anchorMax = new Vector2(1f, 0f);
rectTransform.pivot = new Vector2(0.5f, 0f);
rectTransform.sizeDelta = new Vector2(0f, UITheme.S(2f));
rectTransform.anchoredPosition = Vector2.zero;
TextMeshProUGUI val5 = UIFactory.CreateTmp("Title", (Transform)(object)((Graphic)val4).rectTransform, title ?? name, UITheme.ScaledFontHeader, UIColors.TextPrimary, (TextAlignmentOptions)514);
UIHelpers.SetFillParent(((TMP_Text)val5).rectTransform, UITheme.S(8f));
if (closeButton)
{
((TMP_Text)val5).rectTransform.offsetMax = new Vector2(0f - UITheme.S(40f), 0f - UITheme.S(4f));
}
((Component)val4).gameObject.AddComponent().Target = uIPanel.Rect;
UIWindow window = new UIWindow(gameObject, val2, uIPanel.GameObject, uIPanel.Rect, val5);
if (closeButton)
{
UIButton uIButton = UIButton.Create((Transform)(object)((Graphic)val4).rectTransform, "X", delegate
{
window.Hide();
}, UIButtonStyle.Danger, "CloseButton", UITheme.S(28f));
RectTransform rect3 = uIButton.Rect;
((Vector2)(ref val3))..ctor(1f, 0.5f);
rect3.anchorMax = val3;
rect3.anchorMin = val3;
rect3.pivot = new Vector2(1f, 0.5f);
rect3.sizeDelta = new Vector2(UITheme.S(32f), UITheme.S(28f));
rect3.anchoredPosition = new Vector2(0f - UITheme.S(8f), 0f);
LayoutElement component = uIButton.GameObject.GetComponent();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
}
RectTransform val6 = UIFactory.CreateRect("Body", uIPanel.Content);
val6.anchorMin = Vector2.zero;
val6.anchorMax = Vector2.one;
val6.offsetMin = new Vector2(UITheme.S(10f), UITheme.S(10f));
val6.offsetMax = new Vector2(0f - UITheme.S(10f), 0f - (scaledTitleBarHeight + UITheme.S(8f)));
if (scrollable)
{
UIScrollView uIScrollView = UIScrollView.Create((Transform)(object)val6, "Scroll");
uIScrollView.FillParent();
window.ScrollView = uIScrollView;
window.Content = (Transform)(object)uIScrollView.Content;
}
else
{
window.Content = (Transform)(object)val6;
}
window.IsVisible = true;
return window;
}
public UIWindow WithTitle(string title)
{
if ((Object)(object)TitleText != (Object)null)
{
((TMP_Text)TitleText).text = title ?? string.Empty;
}
return this;
}
public UIWindow OnClose(Action action)
{
_onClose = action;
return this;
}
public void Show()
{
if ((Object)(object)_canvasGo != (Object)null)
{
_canvasGo.SetActive(true);
}
IsVisible = true;
}
public void Hide(bool invokeClose = true)
{
bool isVisible = IsVisible;
if ((Object)(object)_canvasGo != (Object)null)
{
_canvasGo.SetActive(false);
}
IsVisible = false;
if (invokeClose && isVisible)
{
_onClose?.Invoke();
}
}
public void Toggle()
{
if (IsVisible)
{
Hide();
}
else
{
Show();
}
}
public void Destroy()
{
_onClose = null;
UIHelpers.DestroySafe((Object)(object)_canvasGo);
}
public static UIText CreateSectionHeader(Transform parent, string text)
{
//IL_000c: 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)
Image obj = UIFactory.CreateImage("Section_" + text, parent, UIColors.SectionBar, raycast: false);
UIFactory.ApplyWhiteSprite(obj);
GameObject gameObject = ((Component)obj).gameObject;
float? preferredHeight = UITheme.S(32f);
float? minHeight = UITheme.S(32f);
UIHelpers.EnsureLayoutElement(gameObject, null, preferredHeight, minHeight);
UIText uIText = UIText.Create((Transform)(object)((Graphic)obj).rectTransform, "Label", text, UITheme.ScaledFontBody, UIColors.TextPrimary, (TextAlignmentOptions)514);
uIText.FillParent(UITheme.S(4f));
return uIText;
}
}
public class WindowDragHandle : MonoBehaviour, IDragHandler, IEventSystemHandler, IBeginDragHandler
{
public RectTransform Target;
private Vector2 _dragOffset;
public void OnBeginDrag(PointerEventData eventData)
{
//IL_0016: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Target == (Object)null))
{
Vector2 val = default(Vector2);
RectTransformUtility.ScreenPointToLocalPointInRectangle(Target, eventData.position, eventData.pressEventCamera, ref val);
_dragOffset = Target.anchoredPosition - val;
}
}
public void OnDrag(PointerEventData eventData)
{
//IL_0020: 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_003c: 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)
Vector2 val = default(Vector2);
if (!((Object)(object)Target == (Object)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)/*isinst with value type is only supported in some contexts*/, eventData.position, eventData.pressEventCamera, ref val))
{
Target.anchoredPosition = val + _dragOffset;
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SparrohUILib";
public const string PLUGIN_NAME = "SparrohUILib";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}