using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("FishNet.Runtime")]
[assembly: AssemblyCompany("SpongeMods")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Shared UI toolkit for Sponge mods.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a149c533da6d929b7267867242f5011f9c2152dc")]
[assembly: AssemblyProduct("SpongeMods.UILib")]
[assembly: AssemblyTitle("SpongeMods.UILib")]
[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;
}
}
}
namespace SpongeMods.UILib
{
public sealed class Column
{
private readonly RectTransform _host;
private float _cursor;
public float Spacing = 8f;
public float Padding = 10f;
public float Inset = 12f;
public float Height => Mathf.Max(0f, _cursor - Spacing) + Padding;
public Column(RectTransform host)
{
_host = host;
_cursor = Padding;
}
public float Add(RectTransform child, float height)
{
//IL_0018: 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_0042: 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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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)
((Transform)child).SetParent((Transform)(object)_host, false);
child.anchorMin = new Vector2(0f, 1f);
child.anchorMax = new Vector2(1f, 1f);
child.pivot = new Vector2(0.5f, 1f);
child.offsetMin = new Vector2(Inset, 0f);
child.offsetMax = new Vector2(0f - Inset, 0f);
child.anchoredPosition = new Vector2(0f, 0f - _cursor);
child.sizeDelta = new Vector2(child.sizeDelta.x, height);
float cursor = _cursor;
_cursor += height + Spacing;
return cursor;
}
public void Gap(float height)
{
_cursor += height;
}
public void Rewind()
{
_cursor = Padding;
}
}
public enum Anchor
{
TopLeft,
TopCentre,
TopRight,
MiddleLeft,
Centre,
MiddleRight,
BottomLeft,
BottomCentre,
BottomRight
}
public readonly struct Placement
{
public readonly Anchor Anchor;
public readonly float X;
public readonly float Y;
public Placement(Anchor anchor, float x, float y)
{
Anchor = anchor;
X = x;
Y = y;
}
public Vector2 Normalised()
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
float num;
switch (Anchor)
{
case Anchor.TopLeft:
case Anchor.MiddleLeft:
case Anchor.BottomLeft:
num = 0f;
break;
case Anchor.TopRight:
case Anchor.MiddleRight:
case Anchor.BottomRight:
num = 1f;
break;
default:
num = 0.5f;
break;
}
float num2 = num;
switch (Anchor)
{
case Anchor.BottomLeft:
case Anchor.BottomCentre:
case Anchor.BottomRight:
num = 0f;
break;
case Anchor.TopLeft:
case Anchor.TopCentre:
case Anchor.TopRight:
num = 1f;
break;
default:
num = 0.5f;
break;
}
float num3 = num;
return new Vector2(num2, num3);
}
public void ApplyTo(RectTransform rect)
{
//IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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_0059: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = (rect.pivot = (rect.anchorMax = (rect.anchorMin = Normalised())));
float num = ((val.x > 0.5f) ? (0f - X) : X);
float num2 = ((val.y > 0.5f) ? (0f - Y) : Y);
rect.anchoredPosition = new Vector2(num, num2);
}
}
public static class Stage
{
private const string HostName = "SpongeMods.UILib.Root";
private static Canvas _canvas;
private static Sprite _pixel;
private const int Layer = 200;
private static readonly Dictionary<int, Sprite> _rounded = new Dictionary<int, Sprite>();
public static Canvas Root
{
get
{
//IL_0018: 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_0023: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_canvas != (Object)null)
{
return _canvas;
}
GameObject val = new GameObject("SpongeMods.UILib.Root");
Object.DontDestroyOnLoad((Object)val);
_canvas = val.AddComponent<Canvas>();
_canvas.renderMode = (RenderMode)0;
_canvas.sortingOrder = 200;
CanvasScaler obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
obj.matchWidthOrHeight = 1f;
return _canvas;
}
}
public static Sprite Pixel
{
get
{
//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_0023: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_0057: 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_0070: Expected O, but got Unknown
if ((Object)(object)_pixel != (Object)null)
{
return _pixel;
}
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false)
{
wrapMode = (TextureWrapMode)1,
filterMode = (FilterMode)1
};
val.SetPixel(0, 0, Color.white);
val.Apply();
Object.DontDestroyOnLoad((Object)val);
_pixel = Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f));
Object.DontDestroyOnLoad((Object)(object)_pixel);
return _pixel;
}
}
public static Sprite Rounded(int radius)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_0138: 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_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
radius = Mathf.Clamp(radius, 2, 64);
if (_rounded.TryGetValue(radius, out var value) && (Object)(object)value != (Object)null)
{
return value;
}
int num = radius * 2 + 2;
Texture2D val = new Texture2D(num, num, (TextureFormat)4, false)
{
wrapMode = (TextureWrapMode)1,
filterMode = (FilterMode)1
};
Color[] array = (Color[])(object)new Color[num * num];
float num2 = radius;
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num3 = Mathf.Max(0f, Mathf.Max(num2 - ((float)j + 0.5f), (float)j + 0.5f - ((float)num - num2)));
float num4 = Mathf.Max(0f, Mathf.Max(num2 - ((float)i + 0.5f), (float)i + 0.5f - ((float)num - num2)));
float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) - num2;
float num6 = Mathf.Clamp01(0.5f - num5);
array[i * num + j] = new Color(1f, 1f, 1f, num6);
}
}
val.SetPixels(array);
val.Apply();
Object.DontDestroyOnLoad((Object)(object)val);
Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)radius, (float)radius, (float)radius, (float)radius));
Object.DontDestroyOnLoad((Object)(object)val2);
_rounded[radius] = val2;
return val2;
}
public static Image Fill(string name, RectTransform parent, Color colour, int radius = 10)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
Image obj = ((Component)NewRect(name, parent)).gameObject.AddComponent<Image>();
obj.sprite = Rounded(radius);
obj.type = (Type)1;
obj.pixelsPerUnitMultiplier = 1f;
((Graphic)obj).color = colour;
((Graphic)obj).raycastTarget = false;
return obj;
}
public static void Spread(RectTransform rect, float bleed = 0f)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
rect.anchorMin = Vector2.zero;
rect.anchorMax = Vector2.one;
rect.offsetMin = new Vector2(bleed, bleed);
rect.offsetMax = new Vector2(0f - bleed, 0f - bleed);
}
public static RectTransform NewRect(string name, RectTransform parent = null)
{
//IL_0014: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform;
((Transform)val).SetParent((Transform)(((Object)(object)parent != (Object)null) ? ((object)parent) : ((object)((Component)Root).transform)), false);
return val;
}
}
public static class Focus
{
private static object _holder;
private static Action _onLost;
public static bool Held => _holder != null;
private static bool GameScreenOpen
{
get
{
if (!PauseManager.IsPaused && !PlayerThinking.IsThinking)
{
return MainMenuManager.IsInMenu;
}
return true;
}
}
public static bool Available
{
get
{
if ((Object)(object)Player.LocalPlayer != (Object)null)
{
return !GameScreenOpen;
}
return false;
}
}
public static bool HeldBy(object who)
{
if (who != null)
{
return _holder == who;
}
return false;
}
public static bool Claim(object who, Action onLost = null)
{
if (who == null)
{
return false;
}
if (Held)
{
return HeldBy(who);
}
if (!Available)
{
return false;
}
_holder = who;
_onLost = onLost;
SyncCursor();
return true;
}
public static void Release(object who)
{
if (HeldBy(who))
{
Drop(tell: false);
}
}
internal static void Step()
{
if (Held && (GameScreenOpen || (Object)(object)Player.LocalPlayer == (Object)null))
{
Drop(tell: true);
}
}
private static void Drop(bool tell)
{
Action onLost = _onLost;
_holder = null;
_onLost = null;
SyncCursor();
if (tell)
{
onLost?.Invoke();
}
}
private static void SyncCursor()
{
if ((Object)(object)Player.LocalPlayer != (Object)null)
{
PlayerCamera.ToggleMouse(Held);
}
}
}
internal static class GameHooks
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal static class SuspendWhileOpen
{
private static void Postfix(Player __instance, ref bool __result)
{
if (!__result && Focus.Held && __instance == Player.LocalPlayer)
{
__result = true;
}
}
}
[HarmonyPatch(typeof(PlayerCamera), "ToggleMouse")]
internal static class HoldCursorFree
{
private static void Prefix(ref bool unlock)
{
if (Focus.Held)
{
unlock = true;
}
}
}
}
public static class Pointer
{
private static int _spent = -1;
public static Vector2 Position => Vector2.op_Implicit(Input.mousePosition);
public static bool Pressed
{
get
{
if (Input.GetMouseButtonDown(0))
{
return _spent != Time.frameCount;
}
return false;
}
}
public static bool Down => Input.GetMouseButton(0);
public static bool Released => Input.GetMouseButtonUp(0);
public static float Wheel => Input.mouseScrollDelta.y;
public static void Spend()
{
_spent = Time.frameCount;
}
public static bool Over(RectTransform rect)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rect != (Object)null && ((Component)rect).gameObject.activeInHierarchy)
{
return RectTransformUtility.RectangleContainsScreenPoint(rect, Position, (Camera)null);
}
return false;
}
}
public static class Typing
{
private static object _target;
private static readonly StringBuilder _buffer = new StringBuilder();
private static Action<string> _commit;
private static Action _cancel;
public const int Limit = 64;
public static bool Active => _target != null;
public static string Text => _buffer.ToString();
public static bool ActiveOn(object who)
{
if (who != null)
{
return _target == who;
}
return false;
}
public static void Begin(object who, string initial, Action<string> commit, Action cancel = null)
{
if (who != null)
{
if (Active && !ActiveOn(who))
{
Stop(keep: false);
}
_target = who;
_commit = commit;
_cancel = cancel;
_buffer.Length = 0;
if (!string.IsNullOrEmpty(initial))
{
_buffer.Append(initial, 0, Mathf.Min(initial.Length, 64));
}
}
}
public static void Abandon(object who)
{
if (ActiveOn(who))
{
Stop(keep: false);
}
}
public static bool Step(object who)
{
if (!ActiveOn(who))
{
return false;
}
if (Input.GetKeyDown((KeyCode)27))
{
Stop(keep: false);
return true;
}
if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
{
Stop(keep: true);
return true;
}
bool result = false;
string inputString = Input.inputString;
foreach (char c in inputString)
{
if (c == '\b')
{
if (_buffer.Length > 0)
{
_buffer.Length--;
result = true;
}
}
else if (c >= ' ' && _buffer.Length < 64)
{
_buffer.Append(c);
result = true;
}
}
return result;
}
private static void Stop(bool keep)
{
Action<string> commit = _commit;
Action cancel = _cancel;
string obj = _buffer.ToString();
_target = null;
_commit = null;
_cancel = null;
_buffer.Length = 0;
try
{
if (keep)
{
commit?.Invoke(obj);
}
else
{
cancel?.Invoke();
}
}
catch (Exception ex)
{
UILibPlugin.Log.LogError((object)("A text field rejected its own value: " + ex.Message));
}
}
}
[BepInPlugin("SpongeMods.UILib", "Sponge's UI Library", "1.0.0")]
public sealed class UILibPlugin : BaseUnityPlugin
{
public const string Id = "SpongeMods.UILib";
public const string Version = "1.0.0";
internal static ManualLogSource Log { get; private set; }
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
try
{
new Harmony("SpongeMods.UILib").PatchAll();
}
catch (Exception ex)
{
Log.LogError((object)("Could not install the input patches; Sponge menus will not take the mouse: " + ex.Message));
}
Log.LogInfo((object)"UI library ready.");
}
private void Update()
{
Focus.Step();
}
}
public sealed class Palette
{
public Color Surface = new Color(0.043f, 0.086f, 0.126f, 0.92f);
public Color Accent = new Color(1f, 0.729f, 0.259f, 1f);
public Color Alert = new Color(1f, 0.361f, 0.322f, 1f);
public Color Ink = new Color(0.949f, 0.961f, 0.976f, 1f);
public Color Rim = new Color(0.31f, 0.545f, 0.639f, 0.85f);
public static readonly Palette Default = new Palette();
public int PanelRadius = 14;
public int BarRadius = 9;
public int ControlRadius = 8;
public Color Well => Fade(Shade(Surface, -0.03f), Mathf.Min(1f, Surface.a + 0.06f));
public Color Face => Fade(Shade(Surface, 0.09f), 1f);
public Color FaceLit => Fade(Shade(Surface, 0.17f), 1f);
public Color FaceHeld => Fade(Shade(Surface, -0.04f), 1f);
public Color Muted => Fade(Ink, 0.34f);
public static Color Gloss => new Color(1f, 1f, 1f, 0.16f);
public static Color Shade(Color source, float amount)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
float num = default(float);
float num2 = default(float);
float num3 = default(float);
Color.RGBToHSV(source, ref num, ref num2, ref num3);
Color result = Color.HSVToRGB(num, num2, Mathf.Clamp01(num3 + amount));
result.a = source.a;
return result;
}
public static Color Fade(Color source, float alpha)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
source.a = Mathf.Clamp01(alpha);
return source;
}
public Color ForFraction(float fraction)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
float num = 1f - Mathf.Clamp01(fraction);
return Color.Lerp(Accent, Alert, num * num);
}
public Color FaceFor(bool interactive, bool hovered, bool pressed)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
if (!interactive)
{
return Fade(Shade(Surface, 0.03f), 0.7f);
}
if (pressed)
{
return FaceHeld;
}
if (!hovered)
{
return Face;
}
return FaceLit;
}
}
public sealed class Button : Control
{
private readonly Image _rim;
private readonly Image _face;
private readonly Image _sheen;
private readonly Label _label;
public Action Action;
public Color Wash = new Color(0f, 0f, 0f, 0f);
public Color Ink = new Color(0f, 0f, 0f, 0f);
public string Text
{
get
{
return _label.Text;
}
set
{
_label.Text = value;
}
}
public float Measure()
{
return _label.Measure();
}
public Button(string text, RectTransform parent, Palette palette, float textSize = 17f, TextAnchor align = (TextAnchor)4)
: base(palette)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
base.Rect = Stage.NewRect("Button", parent);
_rim = Stage.Fill("Rim", base.Rect, Theme.Rim, Theme.ControlRadius + 2);
Stage.Spread(((Graphic)_rim).rectTransform, -1.5f);
_face = Stage.Fill("Face", base.Rect, Theme.Face, Theme.ControlRadius);
Stage.Spread(((Graphic)_face).rectTransform);
_sheen = Stage.Fill("Sheen", base.Rect, Palette.Gloss, Theme.ControlRadius);
RectTransform rectTransform = ((Graphic)_sheen).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 0.5f);
rectTransform.anchorMax = new Vector2(1f, 1f);
rectTransform.offsetMin = new Vector2(2f, 0f);
rectTransform.offsetMax = new Vector2(-2f, -2f);
_label = new Label("Text", base.Rect, textSize, Theme.Ink)
{
Alignment = align
};
Stage.Spread(_label.Rect);
_label.Rect.offsetMin = new Vector2(10f, 0f);
_label.Rect.offsetMax = new Vector2(-10f, 0f);
_label.Text = text;
Repaint();
}
protected override void Clicked()
{
if (Action == null)
{
return;
}
try
{
Action();
}
catch (Exception ex)
{
UILibPlugin.Log.LogError((object)("'" + Text + "' failed: " + ex.Message));
}
}
protected override void Repaint()
{
//IL_0018: 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_004e: 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_0032: 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_0047: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
Color val = Theme.FaceFor(Interactive, base.Hovered, base.Pressing);
if (Wash.a > 0f)
{
val = Color.Lerp(val, Wash, Wash.a);
}
((Graphic)_face).color = val;
((Graphic)_rim).color = ((!Interactive) ? Palette.Fade(Theme.Rim, 0.3f) : (base.Hovered ? Theme.Accent : Theme.Rim));
_label.Colour = ((!Interactive) ? Theme.Muted : ((Ink.a > 0f) ? Ink : Theme.Ink));
((Behaviour)_sheen).enabled = Interactive && !base.Pressing;
}
}
public sealed class Chooser : Control
{
private const float Gap = 4f;
private const int MostSegments = 4;
private const float ArrowWidth = 30f;
private readonly RectTransform _row;
private readonly RectTransform _strip;
private readonly Label _label;
private readonly List<Button> _segments = new List<Button>();
private readonly List<string> _options = new List<string>();
private readonly Label _reading;
private int _index;
public Action<int> Changed;
public override RectTransform Body => _row;
public int Index
{
get
{
return _index;
}
set
{
int num = ((_options.Count != 0) ? Mathf.Clamp(value, 0, _options.Count - 1) : 0);
if (_index != num)
{
_index = num;
Repaint();
}
}
}
public string Text
{
get
{
return _label.Text;
}
set
{
_label.Text = value;
}
}
public Chooser(string text, IReadOnlyList<string> options, RectTransform parent, Palette palette, float labelWidth = 0.44f, float textSize = 16f)
: base(palette)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: 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_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
_row = Stage.NewRect("Chooser", parent);
base.Rect = _row;
_label = new Label("Text", _row, textSize + 1f, Theme.Ink)
{
Alignment = (TextAnchor)3
};
_label.Rect.anchorMin = Vector2.zero;
_label.Rect.anchorMax = new Vector2(Mathf.Clamp01(labelWidth), 1f);
_label.Rect.offsetMin = Vector2.zero;
_label.Rect.offsetMax = new Vector2(-10f, 0f);
_label.Text = text;
_strip = Stage.NewRect("Strip", _row);
_strip.anchorMin = new Vector2(Mathf.Clamp01(labelWidth), 0f);
_strip.anchorMax = Vector2.one;
_strip.offsetMin = Vector2.zero;
_strip.offsetMax = Vector2.zero;
int num = options?.Count ?? 0;
for (int i = 0; i < num; i++)
{
_options.Add(options[i]);
}
if (num > 4)
{
_reading = new Label("Reading", _strip, textSize, Theme.Ink)
{
Alignment = (TextAnchor)4
};
Stage.Spread(_reading.Rect);
_reading.Rect.offsetMin = new Vector2(34f, 0f);
_reading.Rect.offsetMax = new Vector2(-34f, 0f);
_segments.Add(Arrow("◀", 0f, -1, textSize));
_segments.Add(Arrow("▶", 1f, 1, textSize));
}
else
{
for (int j = 0; j < num; j++)
{
int chosen = j;
Button button = new Button(_options[j], _strip, Theme, textSize, (TextAnchor)4)
{
Action = delegate
{
Pick(chosen);
}
};
float num2 = (float)j / (float)num;
float num3 = (float)(j + 1) / (float)num;
button.Rect.anchorMin = new Vector2(num2, 0f);
button.Rect.anchorMax = new Vector2(num3, 1f);
button.Rect.offsetMin = new Vector2((j == 0) ? 0f : 2f, 0f);
button.Rect.offsetMax = new Vector2((j == num - 1) ? 0f : (-2f), 0f);
_segments.Add(button);
}
}
Repaint();
}
private Button Arrow(string glyph, float side, int step, float textSize)
{
//IL_0047: 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_0073: 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_009d: Unknown result type (might be due to invalid IL or missing references)
Button obj = new Button(glyph, _strip, Theme, textSize, (TextAnchor)4)
{
Action = delegate
{
Pick(Wrapped(_index + step));
}
};
obj.Rect.anchorMin = new Vector2(side, 0f);
obj.Rect.anchorMax = new Vector2(side, 1f);
obj.Rect.pivot = new Vector2(side, 0.5f);
obj.Rect.sizeDelta = new Vector2(30f, 0f);
obj.Rect.anchoredPosition = Vector2.zero;
return obj;
}
private int Wrapped(int index)
{
if (_options.Count != 0)
{
return (index % _options.Count + _options.Count) % _options.Count;
}
return 0;
}
public override void Step()
{
for (int i = 0; i < _segments.Count; i++)
{
_segments[i].Step();
}
}
private void Pick(int index)
{
if (_index == index)
{
return;
}
_index = index;
Repaint();
try
{
Changed?.Invoke(_index);
}
catch (Exception ex)
{
UILibPlugin.Log.LogError((object)("'" + _label.Text + "' failed: " + ex.Message));
}
}
protected override void Repaint()
{
//IL_00fa: 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_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: 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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: 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)
if (_reading != null)
{
_reading.Text = ((_index >= 0 && _index < _options.Count) ? _options[_index] : string.Empty);
_reading.Colour = (Interactive ? Theme.Ink : Theme.Muted);
for (int i = 0; i < _segments.Count; i++)
{
_segments[i].Interactive = Interactive;
_segments[i].Refresh();
}
}
else
{
for (int j = 0; j < _segments.Count; j++)
{
Button button = _segments[j];
bool flag = j == _index;
button.Wash = (Color)(flag ? Theme.Accent : new Color(0f, 0f, 0f, 0f));
button.Ink = (Color)(flag ? Palette.Shade(Theme.Surface, -0.02f) : new Color(0f, 0f, 0f, 0f));
button.Interactive = Interactive;
button.Refresh();
}
}
_label.Colour = (Interactive ? Theme.Ink : Theme.Muted);
}
}
public abstract class Control
{
protected readonly Palette Theme;
public bool Interactive = true;
public RectTransform Rect { get; protected set; }
public virtual RectTransform Body => Rect;
public bool Hovered { get; private set; }
public bool Pressing { get; private set; }
protected Control(Palette palette)
{
Theme = palette ?? Palette.Default;
}
public virtual void Step()
{
bool flag = Interactive && Pointer.Over(Rect);
if (flag != Hovered)
{
Hovered = flag;
Repaint();
}
if (flag && Pointer.Pressed)
{
Pointer.Spend();
Pressing = true;
Repaint();
Grabbed();
}
if (!Pressing)
{
return;
}
Dragged();
if (Pointer.Released)
{
Pressing = false;
Repaint();
if (flag)
{
Clicked();
}
}
else if (!Pointer.Down)
{
Pressing = false;
Repaint();
}
}
protected virtual void Grabbed()
{
}
protected virtual void Dragged()
{
}
protected virtual void Clicked()
{
}
protected abstract void Repaint();
public virtual void Animate()
{
}
public virtual void Refresh()
{
Repaint();
}
public virtual void Cancel()
{
}
public void Visible(bool visible)
{
if (!((Object)(object)Body == (Object)null) && ((Component)Body).gameObject.activeSelf != visible)
{
((Component)Body).gameObject.SetActive(visible);
if (!visible)
{
Hovered = false;
Pressing = false;
}
}
}
}
public sealed class Label
{
private readonly Text _text;
private readonly Outline _outline;
public RectTransform Rect { get; }
public string Text
{
get
{
return _text.text;
}
set
{
if (_text.text != value)
{
_text.text = value;
}
}
}
public Color Colour
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return ((Graphic)_text).color;
}
set
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
if (((Graphic)_text).color != value)
{
((Graphic)_text).color = value;
}
}
}
public TextAnchor Alignment
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return _text.alignment;
}
set
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
_text.alignment = value;
}
}
public float Size
{
get
{
return _text.fontSize;
}
set
{
_text.fontSize = Mathf.RoundToInt(value);
}
}
public bool Wrap
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
return (int)_text.horizontalOverflow == 0;
}
set
{
_text.horizontalOverflow = (HorizontalWrapMode)(!value);
}
}
public Label(string name, RectTransform parent, float size, Color colour, bool outlined = true)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
Rect = Stage.NewRect(name, parent);
_text = ((Component)Rect).gameObject.AddComponent<Text>();
_text.font = Font.CreateDynamicFontFromOSFont("Arial", Mathf.RoundToInt(size));
_text.fontSize = Mathf.RoundToInt(size);
((Graphic)_text).color = colour;
_text.alignment = (TextAnchor)3;
_text.horizontalOverflow = (HorizontalWrapMode)1;
_text.verticalOverflow = (VerticalWrapMode)1;
((Graphic)_text).raycastTarget = false;
if (outlined)
{
_outline = ((Component)Rect).gameObject.AddComponent<Outline>();
((Shadow)_outline).effectColor = new Color(0f, 0f, 0f, 0.85f);
((Shadow)_outline).effectDistance = new Vector2(1.2f, -1.2f);
}
}
public float MeasureHeight()
{
return _text.preferredHeight;
}
public float Measure()
{
return _text.preferredWidth;
}
public void Visible(bool visible)
{
if ((Object)(object)Rect != (Object)null && ((Component)Rect).gameObject.activeSelf != visible)
{
((Component)Rect).gameObject.SetActive(visible);
}
}
}
public sealed class Menu
{
private readonly Panel _panel;
private readonly Label _title;
private readonly Label _header;
private readonly Label _footer;
private readonly List<Label> _rows = new List<Label>();
private readonly Palette _palette;
private readonly List<string> _items = new List<string>();
private int _cursor;
private int _window;
public string Pointer = "▶ ";
public bool Selectable = true;
public RectTransform Rect => _panel.Rect;
public int Height => _rows.Count;
public int Cursor
{
get
{
if (_items.Count != 0)
{
return Mathf.Clamp(_cursor, 0, _items.Count - 1);
}
return -1;
}
}
public int Count => _items.Count;
public string Title
{
set
{
_title.Text = value;
}
}
public string Header
{
set
{
_header.Text = value;
}
}
public string Footer
{
set
{
_footer.Text = value;
}
}
public bool Overflows => _items.Count > _rows.Count;
public Menu(string name, float width, int rows, Palette palette, float titleSize = 25f, float rowSize = 17f)
{
//IL_0073: 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_00ba: 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_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
_palette = palette ?? Palette.Default;
_panel = new Panel(name, null, width, _palette)
{
Padding = 18f,
Spacing = 5f
};
_title = NewLine(titleSize, _palette.Ink);
_panel.Add(_title.Rect, titleSize * 1.3f);
_header = NewLine(rowSize * 0.88f, Palette.Fade(_palette.Ink, 0.6f));
_panel.Add(_header.Rect, rowSize * 1.3f);
for (int i = 0; i < rows; i++)
{
Label label = NewLine(rowSize, _palette.Ink);
_rows.Add(label);
_panel.Add(label.Rect, rowSize * 1.3f);
}
_footer = NewLine(rowSize * 0.88f, Palette.Fade(_palette.Ink, 0.65f));
_panel.Add(_footer.Rect, rowSize * 2.4f);
_panel.Visible(visible: false);
}
private Label NewLine(float size, Color colour)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
return new Label("Line", _panel.Rect, size, colour)
{
Alignment = (TextAnchor)3
};
}
public void PlaceAt(Placement placement)
{
placement.ApplyTo(_panel.Rect);
}
public void Visible(bool visible)
{
_panel.Visible(visible);
}
public void SetItems(IEnumerable<string> items)
{
_items.Clear();
if (items != null)
{
_items.AddRange(items);
}
_cursor = ((_items.Count != 0) ? Mathf.Clamp(_cursor, 0, _items.Count - 1) : 0);
Reveal();
}
public void Move(int by)
{
if (_items.Count != 0)
{
_cursor = (_cursor + by + _items.Count) % _items.Count;
Reveal();
}
}
public void Scroll(int by)
{
_window = Mathf.Clamp(_window + by, 0, Mathf.Max(0, _items.Count - _rows.Count));
}
public void Rewind()
{
_cursor = 0;
_window = 0;
}
private void Reveal()
{
int num = Mathf.Max(0, _items.Count - _rows.Count);
if (!Selectable)
{
_window = Mathf.Clamp(_window, 0, num);
return;
}
if (_cursor < _window)
{
_window = _cursor;
}
else if (_cursor >= _window + _rows.Count)
{
_window = _cursor - _rows.Count + 1;
}
_window = Mathf.Clamp(_window, 0, num);
}
public void Draw()
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < _rows.Count; i++)
{
int num = _window + i;
Label label = _rows[i];
if (num >= _items.Count)
{
label.Text = string.Empty;
continue;
}
bool flag = Selectable && num == _cursor;
label.Text = (flag ? Pointer : new string(' ', Pointer.Length)) + _items[num];
label.Colour = (flag ? _palette.Accent : _palette.Ink);
}
}
}
public enum Readout
{
None,
Current,
Fraction,
Percent
}
public sealed class Meter
{
private readonly RectTransform _root;
private readonly Image _rim;
private readonly Image _backdrop;
private readonly Image _gloss;
private readonly Image _trail;
private readonly Image _fill;
private readonly Label _caption;
private readonly Label _value;
private readonly Palette _palette;
private float _target;
private float _shown;
private float _trailAt;
private float _current;
private float _maximum;
public float FillSpeed = 6f;
public float TrailSpeed = 1.6f;
public Readout Style = Readout.Fraction;
public RectTransform Rect => _root;
public Meter(string name, RectTransform parent, float width, float height, Palette palette)
{
//IL_004a: 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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
_palette = palette ?? Palette.Default;
_root = Stage.NewRect(name, parent);
_root.sizeDelta = new Vector2(width, height);
int num = Mathf.Clamp(Mathf.RoundToInt(height * 0.5f), 3, _palette.BarRadius);
_rim = Stage.Fill("Rim", _root, _palette.Rim, num + 2);
Stretch(((Graphic)_rim).rectTransform, -1.5f);
_backdrop = Stage.Fill("Well", _root, _palette.Well, num);
Stretch(((Graphic)_backdrop).rectTransform, 0f);
_trail = Stage.Fill("Trail", _root, Palette.Fade(_palette.Alert, 0.45f), num);
Edge(((Graphic)_trail).rectTransform, height);
_fill = Stage.Fill("Fill", _root, _palette.Accent, num);
Edge(((Graphic)_fill).rectTransform, height);
_gloss = Stage.Fill("Gloss", _root, Palette.Gloss, num);
RectTransform rectTransform = ((Graphic)_gloss).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 0.52f);
rectTransform.anchorMax = new Vector2(0f, 1f);
rectTransform.pivot = new Vector2(0f, 1f);
rectTransform.offsetMin = new Vector2(2.5f, 0f);
rectTransform.offsetMax = new Vector2(-2.5f, -2f);
_caption = new Label("Caption", _root, Mathf.Max(11f, height * 0.62f), _palette.Ink)
{
Alignment = (TextAnchor)6
};
_caption.Rect.anchorMin = new Vector2(0f, 1f);
_caption.Rect.anchorMax = new Vector2(0f, 1f);
_caption.Rect.pivot = new Vector2(0f, 0f);
_caption.Rect.anchoredPosition = new Vector2(2f, 2f);
_caption.Rect.sizeDelta = new Vector2(width, height);
_value = new Label("Value", _root, Mathf.Max(11f, height * 0.66f), _palette.Ink)
{
Alignment = (TextAnchor)8
};
_value.Rect.anchorMin = new Vector2(1f, 1f);
_value.Rect.anchorMax = new Vector2(1f, 1f);
_value.Rect.pivot = new Vector2(1f, 0f);
_value.Rect.anchoredPosition = new Vector2(-2f, 2f);
_value.Rect.sizeDelta = new Vector2(width, height);
}
public void Caption(string text)
{
_caption.Text = text;
}
public void Visible(bool visible)
{
if ((Object)(object)_root != (Object)null && ((Component)_root).gameObject.activeSelf != visible)
{
((Component)_root).gameObject.SetActive(visible);
}
}
public void Set(float current, float maximum)
{
_current = current;
_maximum = Mathf.Max(1f, maximum);
_target = Mathf.Clamp01(_current / _maximum);
}
public void Jump()
{
_shown = _target;
_trailAt = _target;
}
public void Step(float deltaTime)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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)
_shown = Mathf.MoveTowards(_shown, _target, FillSpeed * deltaTime);
_trailAt = ((_trailAt < _shown) ? _shown : Mathf.MoveTowards(_trailAt, _shown, TrailSpeed * deltaTime));
((Graphic)_fill).rectTransform.anchorMax = new Vector2(_shown, 1f);
((Graphic)_trail).rectTransform.anchorMax = new Vector2(_trailAt, 1f);
((Graphic)_gloss).rectTransform.anchorMax = new Vector2(_shown, 1f);
((Graphic)_fill).color = _palette.ForFraction(_shown);
((Behaviour)_gloss).enabled = _shown > 0.02f;
_value.Text = Write();
}
private string Write()
{
CultureInfo invariantCulture = CultureInfo.InvariantCulture;
return Style switch
{
Readout.None => string.Empty,
Readout.Current => Round(_current).ToString(invariantCulture),
Readout.Percent => Mathf.RoundToInt(_target * 100f).ToString(invariantCulture) + "%",
_ => Round(_current).ToString(invariantCulture) + " / " + Round(_maximum).ToString(invariantCulture),
};
}
private static int Round(float value)
{
return Mathf.Max(0, Mathf.RoundToInt(value));
}
private static void Stretch(RectTransform rect, float bleed)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
rect.anchorMin = Vector2.zero;
rect.anchorMax = Vector2.one;
rect.offsetMin = new Vector2(bleed, bleed);
rect.offsetMax = new Vector2(0f - bleed, 0f - bleed);
}
private static void Edge(RectTransform rect, float height)
{
//IL_000b: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
rect.anchorMin = new Vector2(0f, 0f);
rect.anchorMax = new Vector2(0f, 1f);
rect.pivot = new Vector2(0f, 0.5f);
rect.offsetMin = new Vector2(1f, 1f);
rect.offsetMax = new Vector2(-1f, -1f);
}
}
public sealed class Panel
{
private readonly Image _rim;
private readonly Image _card;
private readonly Image _sheen;
private float _cursor;
public float Spacing = 4f;
public float Padding = 6f;
public float Edge = 2f;
public RectTransform Rect { get; }
public Panel(string name, RectTransform parent, float width, Palette palette = null)
{
//IL_004c: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: 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_0182: Unknown result type (might be due to invalid IL or missing references)
Palette palette2 = palette ?? Palette.Default;
Rect = Stage.NewRect(name, parent);
Rect.sizeDelta = new Vector2(width, 0f);
_rim = Stage.Fill("Rim", Rect, palette2.Rim, palette2.PanelRadius + 2);
Stage.Spread(((Graphic)_rim).rectTransform, 0f - Edge);
_card = Stage.Fill("Card", Rect, palette2.Surface, palette2.PanelRadius);
Stage.Spread(((Graphic)_card).rectTransform);
_sheen = Stage.Fill("Sheen", Rect, Palette.Fade(Palette.Shade(palette2.Surface, 0.1f), 0.5f), palette2.PanelRadius);
RectTransform rectTransform = ((Graphic)_sheen).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 1f);
rectTransform.anchorMax = new Vector2(1f, 1f);
rectTransform.pivot = new Vector2(0.5f, 1f);
rectTransform.offsetMin = new Vector2(1f, 0f);
rectTransform.offsetMax = new Vector2(-1f, -1f);
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, 18f);
_cursor = Padding;
}
public void Add(RectTransform child, float height)
{
//IL_0018: 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_0042: 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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_00c8: 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)
((Transform)child).SetParent((Transform)(object)Rect, false);
child.anchorMin = new Vector2(0f, 1f);
child.anchorMax = new Vector2(1f, 1f);
child.pivot = new Vector2(0.5f, 1f);
child.offsetMin = new Vector2(Padding, 0f);
child.offsetMax = new Vector2(0f - Padding, 0f);
child.anchoredPosition = new Vector2(0f, 0f - _cursor);
child.sizeDelta = new Vector2(child.sizeDelta.x, height);
_cursor += height + Spacing;
Rect.sizeDelta = new Vector2(Rect.sizeDelta.x, _cursor - Spacing + Padding);
}
public void Rewind()
{
//IL_0018: 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)
_cursor = Padding;
Rect.sizeDelta = new Vector2(Rect.sizeDelta.x, 0f);
}
public void Tint(Color colour)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((Graphic)_card).color = colour;
}
public void Visible(bool visible)
{
if ((Object)(object)Rect != (Object)null && ((Component)Rect).gameObject.activeSelf != visible)
{
((Component)Rect).gameObject.SetActive(visible);
}
}
}
public sealed class ScrollBar : Control
{
private readonly Image _well;
private readonly Image _thumb;
private readonly bool _vertical;
private float _range;
private float _shown = 1f;
private float _at;
public Action<float> Moved;
public float At
{
get
{
return _at;
}
set
{
float num = Mathf.Clamp(value, 0f, _range);
if (!Mathf.Approximately(_at, num))
{
_at = num;
Place();
}
}
}
public bool Needed => _range > 0.5f;
public ScrollBar(RectTransform parent, Palette palette, bool vertical, float thickness = 8f)
: base(palette)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
_vertical = vertical;
base.Rect = Stage.NewRect("ScrollBar", parent);
int radius = Mathf.Max(2, Mathf.RoundToInt(thickness / 2f));
_well = Stage.Fill("Well", base.Rect, Palette.Fade(Theme.Well, 0.55f), radius);
Stage.Spread(((Graphic)_well).rectTransform);
_thumb = Stage.Fill("Thumb", base.Rect, Palette.Fade(Theme.Rim, 0.9f), radius);
RectTransform rectTransform = ((Graphic)_thumb).rectTransform;
if (vertical)
{
rectTransform.anchorMin = new Vector2(0f, 1f);
rectTransform.anchorMax = new Vector2(1f, 1f);
rectTransform.pivot = new Vector2(0.5f, 1f);
}
else
{
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;
rectTransform.anchoredPosition = Vector2.zero;
Repaint();
}
public void Measure(float content, float viewport)
{
_range = Mathf.Max(0f, content - viewport);
_shown = ((content <= 0f) ? 1f : Mathf.Clamp01(viewport / content));
_at = Mathf.Clamp(_at, 0f, _range);
Visible(Needed);
Place();
}
protected override void Grabbed()
{
Follow();
}
protected override void Dragged()
{
Follow();
}
private void Follow()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = default(Vector2);
if (!Needed || !RectTransformUtility.ScreenPointToLocalPointInRectangle(base.Rect, Pointer.Position, (Camera)null, ref val))
{
return;
}
Rect rect;
float num;
if (!_vertical)
{
rect = base.Rect.rect;
num = ((Rect)(ref rect)).width;
}
else
{
rect = base.Rect.rect;
num = ((Rect)(ref rect)).height;
}
float num2 = num;
float num3 = ThumbLength(num2);
float num4 = num2 - num3;
if (num4 <= 0f)
{
return;
}
float num5;
if (!_vertical)
{
float x = val.x;
rect = base.Rect.rect;
num5 = (x - ((Rect)(ref rect)).xMin - num3 / 2f) / num4;
}
else
{
rect = base.Rect.rect;
num5 = (((Rect)(ref rect)).yMax - val.y - num3 / 2f) / num4;
}
float num6 = Mathf.Clamp01(num5) * _range;
if (Mathf.Approximately(_at, num6))
{
return;
}
_at = num6;
Place();
try
{
Moved?.Invoke(_at);
}
catch (Exception ex)
{
UILibPlugin.Log.LogError((object)("A scroll bar's owner failed: " + ex.Message));
}
}
private float ThumbLength(float length)
{
return Mathf.Max(24f, length * _shown);
}
private void Place()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
Rect rect;
float num;
if (!_vertical)
{
rect = base.Rect.rect;
num = ((Rect)(ref rect)).width;
}
else
{
rect = base.Rect.rect;
num = ((Rect)(ref rect)).height;
}
float num2 = num;
if (!(num2 <= 0f))
{
float num3 = ThumbLength(num2);
float num4 = Mathf.Max(0f, num2 - num3);
float num5 = ((_range <= 0f) ? 0f : Mathf.Clamp01(_at / _range));
RectTransform rectTransform = ((Graphic)_thumb).rectTransform;
if (_vertical)
{
rectTransform.sizeDelta = new Vector2(0f, num3);
rectTransform.anchoredPosition = new Vector2(0f, (0f - num4) * num5);
}
else
{
rectTransform.sizeDelta = new Vector2(num3, 0f);
rectTransform.anchoredPosition = new Vector2(num4 * num5, 0f);
}
}
}
public void Settle()
{
Place();
}
protected override void Repaint()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0026: Unknown result type (might be due to invalid IL or missing references)
((Graphic)_thumb).color = (base.Pressing ? Theme.Accent : (base.Hovered ? Palette.Shade(Theme.Rim, 0.15f) : Palette.Fade(Theme.Rim, 0.9f)));
}
}
public sealed class ScrollBox
{
private const float Notch = 56f;
private readonly RectTransform _view;
private readonly ScrollBar _bar;
private float _offset;
private float _content;
public const float BarStrip = 14f;
public RectTransform Rect { get; }
public RectTransform Content { get; }
public float Offset => _offset;
public ScrollBox(string name, RectTransform parent, Palette palette)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
Palette palette2 = palette ?? Palette.Default;
Rect = Stage.NewRect(name, parent);
_view = Stage.NewRect("View", Rect);
_view.anchorMin = Vector2.zero;
_view.anchorMax = Vector2.one;
_view.offsetMin = Vector2.zero;
_view.offsetMax = new Vector2(-14f, 0f);
((Component)_view).gameObject.AddComponent<RectMask2D>();
Content = Stage.NewRect("Content", _view);
Content.anchorMin = new Vector2(0f, 1f);
Content.anchorMax = new Vector2(1f, 1f);
Content.pivot = new Vector2(0.5f, 1f);
Content.offsetMin = new Vector2(0f, 0f);
Content.offsetMax = new Vector2(0f, 0f);
Content.anchoredPosition = Vector2.zero;
_bar = new ScrollBar(Rect, palette2, vertical: true);
_bar.Rect.anchorMin = new Vector2(1f, 0f);
_bar.Rect.anchorMax = new Vector2(1f, 1f);
_bar.Rect.pivot = new Vector2(1f, 0.5f);
_bar.Rect.sizeDelta = new Vector2(8f, -4f);
_bar.Rect.anchoredPosition = Vector2.zero;
_bar.Moved = To;
}
public void Measure(float contentHeight)
{
//IL_001d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
_content = Mathf.Max(0f, contentHeight);
Content.sizeDelta = new Vector2(Content.sizeDelta.x, _content);
ScrollBar bar = _bar;
float content = _content;
Rect rect = Rect.rect;
bar.Measure(content, ((Rect)(ref rect)).height);
float offset = _offset;
float content2 = _content;
rect = Rect.rect;
To(Mathf.Min(offset, Mathf.Max(0f, content2 - ((Rect)(ref rect)).height)));
}
public void To(float offset)
{
//IL_0018: 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_0041: 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)
float content = _content;
Rect rect = Rect.rect;
_offset = Mathf.Clamp(offset, 0f, Mathf.Max(0f, content - ((Rect)(ref rect)).height));
Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _offset);
_bar.At = _offset;
}
public void Reveal(float top, float height)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Rect rect = Rect.rect;
float height2 = ((Rect)(ref rect)).height;
if (top < _offset)
{
To(top);
}
else if (top + height > _offset + height2)
{
To(top + height - height2);
}
}
public void Step()
{
_bar.Step();
float wheel = Pointer.Wheel;
if (!Mathf.Approximately(wheel, 0f) && Pointer.Over(Rect))
{
To(_offset - wheel * 56f);
}
}
public void Settle()
{
_bar.Settle();
Measure(_content);
}
public void Visible(bool visible)
{
if ((Object)(object)Rect != (Object)null && ((Component)Rect).gameObject.activeSelf != visible)
{
((Component)Rect).gameObject.SetActive(visible);
}
}
}
public sealed class Slider : Control
{
private const float Knob = 20f;
private const float FieldWidth = 78f;
private readonly RectTransform _row;
private readonly Label _label;
private readonly TextBox _field;
private readonly Image _well;
private readonly Image _fill;
private readonly Image _handle;
private readonly float _min;
private readonly float _max;
private readonly bool _whole;
private float _value;
public Action<float> Changed;
public override RectTransform Body => _row;
public float Value
{
get
{
return _value;
}
set
{
float num = Tidy(value);
if (!Mathf.Approximately(_value, num))
{
_value = num;
Show();
}
}
}
private string Written
{
get
{
if (!_whole)
{
return _value.ToString("0.##", CultureInfo.InvariantCulture);
}
return Mathf.RoundToInt(_value).ToString(CultureInfo.InvariantCulture);
}
}
public string Text
{
get
{
return _label.Text;
}
set
{
_label.Text = value;
}
}
public Slider(string text, RectTransform parent, Palette palette, float min, float max, bool whole = false, float labelWidth = 0.44f, float textSize = 17f)
: base(palette)
{
//IL_0051: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: 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_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0404: Unknown result type (might be due to invalid IL or missing references)
_min = min;
_max = Mathf.Max(max, min + 0.0001f);
_whole = whole;
_row = Stage.NewRect("Slider", parent);
_label = new Label("Text", _row, textSize, Theme.Ink)
{
Alignment = (TextAnchor)3
};
_label.Rect.anchorMin = new Vector2(0f, 0f);
_label.Rect.anchorMax = new Vector2(Mathf.Clamp01(labelWidth), 1f);
_label.Rect.offsetMin = Vector2.zero;
_label.Rect.offsetMax = new Vector2(-10f, 0f);
_label.Text = text;
base.Rect = Stage.NewRect("Track", _row);
base.Rect.anchorMin = new Vector2(Mathf.Clamp01(labelWidth), 0.5f);
base.Rect.anchorMax = new Vector2(1f, 0.5f);
base.Rect.pivot = new Vector2(0.5f, 0.5f);
base.Rect.offsetMin = new Vector2(0f, -10f);
base.Rect.offsetMax = new Vector2(-90f, 10f);
int radius = Mathf.RoundToInt(10f);
_well = Stage.Fill("Well", base.Rect, Theme.Well, radius);
Stage.Spread(((Graphic)_well).rectTransform);
((Graphic)_well).rectTransform.offsetMin = new Vector2(0f, 6f);
((Graphic)_well).rectTransform.offsetMax = new Vector2(0f, -6f);
_fill = Stage.Fill("Fill", base.Rect, Theme.Accent, radius);
((Graphic)_fill).rectTransform.anchorMin = new Vector2(0f, 0f);
((Graphic)_fill).rectTransform.anchorMax = new Vector2(0f, 1f);
((Graphic)_fill).rectTransform.pivot = new Vector2(0f, 0.5f);
((Graphic)_fill).rectTransform.offsetMin = new Vector2(0f, 6f);
((Graphic)_fill).rectTransform.offsetMax = new Vector2(0f, -6f);
_handle = Stage.Fill("Handle", base.Rect, Theme.Ink, radius);
((Graphic)_handle).rectTransform.anchorMin = new Vector2(0f, 0.5f);
((Graphic)_handle).rectTransform.anchorMax = new Vector2(0f, 0.5f);
((Graphic)_handle).rectTransform.pivot = new Vector2(0.5f, 0.5f);
((Graphic)_handle).rectTransform.sizeDelta = new Vector2(20f, 20f);
_field = new TextBox(_row, Theme, textSize - 1f, (TextAnchor)4);
_field.Rect.anchorMin = new Vector2(1f, 0.5f);
_field.Rect.anchorMax = new Vector2(1f, 0.5f);
_field.Rect.pivot = new Vector2(1f, 0.5f);
_field.Rect.sizeDelta = new Vector2(78f, 26f);
_field.Rect.anchoredPosition = Vector2.zero;
_field.Committed = Typed;
_value = Tidy(min);
Repaint();
Show();
}
public override void Step()
{
_field.Step();
base.Step();
}
public override void Animate()
{
_field.Animate();
}
public override void Cancel()
{
_field.Cancel();
}
protected override void Grabbed()
{
TrackPointer();
}
protected override void Dragged()
{
TrackPointer();
}
private void TrackPointer()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = default(Vector2);
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(base.Rect, Pointer.Position, (Camera)null, ref val))
{
return;
}
Rect rect = base.Rect.rect;
float num = ((Rect)(ref rect)).width - 20f;
if (!(num <= 0f))
{
float x = val.x;
rect = base.Rect.rect;
float num2 = Mathf.Clamp01((x - ((Rect)(ref rect)).xMin - 10f) / num);
float num3 = Tidy(Mathf.Lerp(_min, _max, num2));
if (!Mathf.Approximately(_value, num3))
{
_value = num3;
Show();
Announce();
}
}
}
private string Typed(string text)
{
if (!float.TryParse(text.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
{
return Written;
}
float num = Tidy(result);
if (!Mathf.Approximately(_value, num))
{
_value = num;
Show();
Announce();
}
return Written;
}
private void Announce()
{
try
{
Changed?.Invoke(_value);
}
catch (Exception ex)
{
UILibPlugin.Log.LogError((object)("'" + _label.Text + "' failed: " + ex.Message));
}
}
private float Tidy(float raw)
{
float num = Mathf.Clamp(raw, _min, _max);
if (!_whole)
{
return num;
}
return Mathf.Round(num);
}
private void Show()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0080: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.InverseLerp(_min, _max, _value);
Rect rect = base.Rect.rect;
float num2 = Mathf.Max(0f, ((Rect)(ref rect)).width - 20f);
((Graphic)_handle).rectTransform.anchoredPosition = new Vector2(10f + num2 * num, 0f);
RectTransform rectTransform = ((Graphic)_fill).rectTransform;
rectTransform.sizeDelta = new Vector2(10f + num2 * num, rectTransform.sizeDelta.y);
if (!_field.Editing)
{
_field.Value = Written;
}
}
public void Settle()
{
Show();
}
protected override void Repaint()
{
//IL_0014: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
((Graphic)_fill).color = ((!Interactive) ? Palette.Fade(Theme.Accent, 0.35f) : ((base.Hovered || base.Pressing) ? Palette.Shade(Theme.Accent, 0.08f) : Theme.Accent));
((Graphic)_handle).color = (Interactive ? Theme.Ink : Theme.Muted);
_label.Colour = (Interactive ? Theme.Ink : Theme.Muted);
_field.Interactive = Interactive;
_field.Refresh();
}
}
public sealed class Switch : Control
{
private const float PillWidth = 52f;
private const float PillHeight = 26f;
private readonly Image _track;
private readonly Image _knob;
private readonly Label _label;
private readonly RectTransform _pill;
private float _slide;
private bool _on;
public Action<bool> Changed;
public bool On
{
get
{
return _on;
}
set
{
if (_on != value)
{
_on = value;
Repaint();
}
}
}
public string Text
{
get
{
return _label.Text;
}
set
{
_label.Text = value;
}
}
public Switch(string text, RectTransform parent, Palette palette, float textSize = 17f)
: base(palette)
{
//IL_002c: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
base.Rect = Stage.NewRect("Switch", parent);
_label = new Label("Text", base.Rect, textSize, Theme.Ink)
{
Alignment = (TextAnchor)3
};
Stage.Spread(_label.Rect);
_label.Rect.offsetMax = new Vector2(-66f, 0f);
_label.Text = text;
_pill = Stage.NewRect("Pill", base.Rect);
_pill.anchorMin = new Vector2(1f, 0.5f);
_pill.anchorMax = new Vector2(1f, 0.5f);
_pill.pivot = new Vector2(1f, 0.5f);
_pill.sizeDelta = new Vector2(52f, 26f);
_pill.anchoredPosition = Vector2.zero;
int radius = Mathf.RoundToInt(13f);
_track = Stage.Fill("Track", _pill, Theme.Well, radius);
Stage.Spread(((Graphic)_track).rectTransform);
_knob = Stage.Fill("Knob", _pill, Theme.Ink, radius);
((Graphic)_knob).rectTransform.anchorMin = new Vector2(0f, 0.5f);
((Graphic)_knob).rectTransform.anchorMax = new Vector2(0f, 0.5f);
((Graphic)_knob).rectTransform.pivot = new Vector2(0.5f, 0.5f);
((Graphic)_knob).rectTransform.sizeDelta = new Vector2(20f, 20f);
_slide = 0f;
Repaint();
Place();
}
protected override void Clicked()
{
_on = !_on;
Repaint();
try
{
Changed?.Invoke(_on);
}
catch (Exception ex)
{
UILibPlugin.Log.LogError((object)("'" + _label.Text + "' failed: " + ex.Message));
}
}
public override void Animate()
{
float num = (_on ? 1f : 0f);
if (!Mathf.Approximately(_slide, num))
{
_slide = Mathf.MoveTowards(_slide, num, Time.unscaledDeltaTime * 7f);
Place();
}
}
private void Place()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
float num = 26f;
((Graphic)_knob).rectTransform.anchoredPosition = new Vector2(13f + num * _slide, 0f);
}
protected override void Repaint()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_0096: Unknown result type (might be due to invalid IL or missing references)
Color val = (_on ? Theme.Accent : Theme.Well);
if (!Interactive)
{
val = Palette.Fade(val, 0.35f);
}
else if (base.Hovered)
{
val = Palette.Shade(val, 0.06f);
}
((Graphic)_track).color = val;
((Graphic)_knob).color = (Interactive ? Theme.Ink : Theme.Muted);
_label.Colour = (Interactive ? Theme.Ink : Theme.Muted);
}
}
public sealed class TabRail
{
public const float TabHeight = 34f;
private const float BarHeight = 10f;
private const float ArrowWidth = 26f;
private const float Gap = 5f;
private const float MinTabWidth = 84f;
private const float Lift = 3f;
private readonly Palette _theme;
private readonly RectTransform _view;
private readonly RectTransform _strip;
private readonly ScrollBar _bar;
private readonly Button _left;
private readonly Button _right;
private readonly List<Button> _tabs = new List<Button>();
private readonly List<float> _starts = new List<float>();
private readonly List<float> _widths = new List<float>();
private float _span;
private float _offset;
private int _active;
public Action<int> Changed;
public RectTransform Rect { get; }
public static float Height => 44f;
public int Count => _tabs.Count;
public int Active
{
get
{
return _active;
}
set
{
Pick(value, tell: false);
}
}
public TabRail(RectTransform parent, Palette palette)
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
_theme = palette ?? Palette.Default;
Rect = Stage.NewRect("TabRail", parent);
_left = Arrow("◀", 0f, -1);
_right = Arrow("▶", 1f, 1);
_view = Stage.NewRect("View", Rect);
_view.anchorMin = new Vector2(0f, 1f);
_view.anchorMax = new Vector2(1f, 1f);
_view.pivot = new Vector2(0.5f, 1f);
_view.offsetMin = new Vector2(31f, 0f);
_view.offsetMax = new Vector2(-31f, 0f);
_view.sizeDelta = new Vector2(_view.sizeDelta.x, 34f);
((Component)_view).gameObject.AddComponent<RectMask2D>();
_strip = Stage.NewRect("Strip", _view);
_strip.anchorMin = new Vector2(0f, 0f);
_strip.anchorMax = new Vector2(0f, 1f);
_strip.pivot = new Vector2(0f, 0.5f);
_strip.offsetMin = Vector2.zero;
_strip.offsetMax = Vector2.zero;
_strip.anchoredPosition = Vector2.zero;
_bar = new ScrollBar(Rect, _theme, vertical: false, 6f);
_bar.Rect.anchorMin = new Vector2(0f, 1f);
_bar.Rect.anchorMax = new Vector2(1f, 1f);
_bar.Rect.pivot = new Vector2(0.5f, 1f);
_bar.Rect.offsetMin = new Vector2(31f, 0f);
_bar.Rect.offsetMax = new Vector2(-31f, 0f);
_bar.Rect.sizeDelta = new Vector2(_bar.Rect.sizeDelta.x, 6f);
_bar.Rect.anchoredPosition = new Vector2(0f, -36f);
_bar.Moved = Slide;
}
private Button Arrow(string glyph, float side, int step)
{
//IL_004a: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
Button obj = new Button(glyph, Rect, _theme, 16f, (TextAnchor)4)
{
Action = delegate
{
Pick(_active + step, tell: true);
}
};
obj.Rect.anchorMin = new Vector2(side, 1f);
obj.Rect.anchorMax = new Vector2(side, 1f);
obj.Rect.pivot = new Vector2(side, 1f);
obj.Rect.sizeDelta = new Vector2(26f, 34f);
obj.Rect.anchoredPosition = Vector2.zero;
return obj;
}
public int Add(string title)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
int index = _tabs.Count;
Button button = new Button(title, _strip, _theme, 16f, (TextAnchor)4)
{
Action = delegate
{
Pick(index, tell: true);
}
};
button.Rect.anchorMin = new Vector2(0f, 0f);
button.Rect.anchorMax = new Vector2(0f, 1f);
button.Rect.pivot = new Vector2(0f, 0.5f);
_tabs.Add(button);
return index;
}
public void Settle()
{
//IL_005c: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
_starts.Clear();
_widths.Clear();
float num = 0f;
for (int i = 0; i < _tabs.Count; i++)
{
float num2 = Mathf.Max(84f, _tabs[i].Measure() + 26f);
_tabs[i].Rect.sizeDelta = new Vector2(num2, 0f);
_tabs[i].Rect.anchoredPosition = new Vector2(num, 0f);
_starts.Add(num);
_widths.Add(num2);
num += num2 + 5f;
}
_span = Mathf.Max(0f, num - 5f);
_strip.sizeDelta = new Vector2(_span, 0f);
ScrollBar bar = _bar;
float span = _span;
Rect rect = _view.rect;
bar.Measure(span, ((Rect)(ref rect)).width);
_bar.Settle();
Slide(_offset);
Repaint();
Reveal();
}
private void Pick(int index, bool tell)
{
if (_tabs.Count == 0)
{
return;
}
int num = (index % _tabs.Count + _tabs.Count) % _tabs.Count;
bool num2 = num != _active;
_active = num;
Repaint();
Reveal();
if (!num2 || !tell)
{
return;
}
try
{
Changed?.Invoke(_active);
}
catch (Exception ex)
{
UILibPlugin.Log.LogError((object)("Changing tab failed: " + ex.Message));
}
}
public void Step(int by)
{
Pick(_active + by, tell: true);
}
public void Poll()
{
_left.Step();
_right.Step();
_bar.Step();
for (int i = 0; i < _tabs.Count; i++)
{
_tabs[i].Step();
}
float wheel = Pointer.Wheel;
if (!Mathf.Approximately(wheel, 0f) && Pointer.Over(_view))
{
Slide(_offset - wheel * 60f);
}
}
private void Slide(float offset)
{
//IL_0018: 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_0047: Unknown result type (might be due to invalid IL or missing references)
float span = _span;
Rect rect = _view.rect;
_offset = Mathf.Clamp(offset, 0f, Mathf.Max(0f, span - ((Rect)(ref rect)).width));
_strip.anchoredPosition = new Vector2(0f - _offset, 0f);
_bar.At = _offset;
}
private void Reveal()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
if (_active >= 0 && _active < _starts.Count)
{
float num = _starts[_active];
float num2 = num + _widths[_active];
Rect rect = _view.rect;
float width = ((Rect)(ref rect)).width;
if (num < _offset)
{
Slide(num);
}
else if (num2 > _offset + width)
{
Slide(num2 - width);
}
}
}
private void Repaint()
{
//IL_0043: 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_0048: 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_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < _tabs.Count; i++)
{
Button button = _tabs[i];
bool flag = i == _active;
button.Wash = (Color)(flag ? _theme.Accent : new Color(0f, 0f, 0f, 0f));
button.Ink = (Color)(flag ? Palette.Shade(_theme.Surface, -0.02f) : new Color(0f, 0f, 0f, 0f));
button.Rect.anchoredPosition = new Vector2(button.Rect.anchoredPosition.x, flag ? 3f : 0f);
button.Refresh();
}
}
public void Visible(bool visible)
{
if ((Object)(object)Rect != (Object)null && ((Component)Rect).gameObject.activeSelf != visible)
{
((Component)Rect).gameObject.SetActive(visible);
}
}
}
public sealed class TextBox : Control
{
private readonly Image _rim;
private readonly Image _face;
private readonly Label _text;
private string _value = string.Empty;
private float _blink;
private bool _caret = true;
public Func<string, string> Committed;
public string Placeholder = string.Empty;
public bool Editing => Typing.ActiveOn(this);
public string Value
{
get
{
return _value;
}
set
{
_value = value ?? string.Empty;
if (!Editing)
{
Redraw();
}
}
}
public TextBox(RectTransform parent, Palette palette, float textSize = 16f, TextAnchor align = (TextAnchor)3)
: base(palette)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
base.Rect = Stage.NewRect("Field", parent);
_rim = Stage.Fill("Rim", base.Rect, Theme.Rim, Theme.ControlRadius + 2);
Stage.Spread(((Graphic)_rim).rectTransform, -1.5f);
_face = Stage.Fill("Face", base.Rect, Theme.Well, Theme.ControlRadius);
Stage.Spread(((Graphic)_face).rectTransform);
_text = new Label("Text", base.Rect, textSize, Theme.Ink)
{
Alignment = align
};
Stage.Spread(_text.Rect);
_text.Rect.offsetMin = new Vector2(9f, 0f);
_text.Rect.offsetMax = new Vector2(-9f, 0f);
Repaint();
Redraw();
}
protected override void Clicked()
{
if (!Editing)
{
Typing.Begin(this, _value, Keep, Drop);
_blink = 0f;
_caret = true;
Repaint();
Redraw();
}
}
public override void Animate()
{
if (Editing)
{
bool flag = Typing.Step(this);
_blink += Time.unscaledDeltaTime;
if (_blink >= 0.45f)
{
_blink = 0f;
_caret = !_caret;
flag = true;
}
if (flag && Editing)
{
Redraw();
}
}
}
public override void Cancel()
{
Typing.Abandon(this);
}
private void Keep(string typed)
{
_value = ((Committed != null) ? (Committed(typed) ?? _value) : typed);
Repaint();
Redraw();
}
private void Drop()
{
Repaint();
Redraw();
}
private void Redraw()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
if (Editing)
{
_text.Text = Typing.Text + (_caret ? "▌" : " ");
_text.Colour = Theme.Ink;
}
else
{
bool flag = string.IsNullOrEmpty(_value);
_text.Text = (flag ? Placeholder : _value);
_text.Colour = ((flag || !Interactive) ? Theme.Muted : Theme.Ink);
}
}
protected override void Repaint()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
((Graphic)_face).color = (Editing ? Palette.Shade(Theme.Well, 0.05f) : Theme.FaceFor(Interactive, base.Hovered, base.Pressing));
((Graphic)_rim).color = (Editing ? Theme.Accent : ((Interactive && base.Hovered) ? Palette.Shade(Theme.Rim, 0.12f) : Theme.Rim));
}
public override void Refresh()
{
Repaint();
Redraw();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}