Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of KydlCore v1.0.0
KydlCore/KydlCore.dll
Decompiled 19 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using KydlCore.Bootstrap; using KydlCore.Common; using KydlCore.Configuration; using KydlCore.Core; using KydlCore.Features.Hub.Contracts; using KydlCore.Features.Hub.Domain; using KydlCore.Features.Hub.Infrastructure; using KydlCore.Features.Items.Contracts; using KydlCore.Features.Items.Domain; using KydlCore.Features.Items.Infrastructure; using KydlCore.Integrations.Jotunn; using KydlCore.Presentation.Hub; using KydlCore.Presentation.Hub.Pages; using KydlCore.Presentation.Hub.Registration; using KydlCore.Ui; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.TextCore.Text; using UnityEngine.UIElements; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] [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 KydlCore.Testing { internal static class InGameTests { private static string Startup_ConfigBound() { //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) if (ModSettings.HubKey == null) { return "FAIL: ModSettings.Bind did not run (HubKey is null)"; } return "PASS: config bound (no EnableAll: KydlCore is always on), hub key " + ((object)ModSettings.HubKey.Value/*cast due to .constrained prefix*/).ToString() + ", debug log " + ((ModSettings.DebugLog != null && ModSettings.DebugLog.Value) ? "on" : "off"); } private static string Startup_FontsLoaded() { return CheckFonts(); } private static string World_FontsLoaded() { return CheckFonts(); } private static string CheckFonts() { HashSet<string> hashSet = new HashSet<string>(); List<string> list = new List<string>(); int num = 0; Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val in array) { if (!((Object)(object)val == (Object)null)) { num++; hashSet.Add(((Object)val).name); if (((Object)val).name.IndexOf("Noto", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val).name.IndexOf("Norse", StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(((Object)val).name + (val.dynamic ? " (dynamic)" : " (static)")); } } } string text = num + " Font objects loaded; NotoSansSC-Regular " + Has(hashSet, "NotoSansSC-Regular") + ", NotoSansSC-Thin " + Has(hashSet, "NotoSansSC-Thin") + ", Norse " + Has(hashSet, "Norse") + ", Norsebold " + Has(hashSet, "Norsebold") + ", NotoEmoji-Regular " + Has(hashSet, "NotoEmoji-Regular") + "; Noto / Norse fonts by name: " + ((list.Count == 0) ? "none" : string.Join(", ", list.ToArray())); ModLog.Verbose("InGameTests: " + text); if (!hashSet.Contains("NotoSansSC-Regular")) { return "FAIL: NotoSansSC-Regular is not a loaded Font: " + text; } return "PASS: " + text; } private static string Has(HashSet<string> names, string name) { if (!names.Contains(name)) { return "NO"; } return "yes"; } private static string Startup_KC01_OneUiRoot() { return CheckUiRoot(); } private static string CheckUiRoot() { int num = 0; UIDocument[] array = Object.FindObjectsByType<UIDocument>((FindObjectsSortMode)0); foreach (UIDocument val in array) { if ((Object)(object)val != (Object)null && ((Object)((Component)val).gameObject).name == "Kydl_UI_Root") { num++; } } ModLog.Verbose("InGameTests: KC-01 " + num + " Kydl_UI_Root UIDocument(s)"); if (num > 1) { return "FAIL: " + num + " Kydl_UI_Root UIDocuments, expected at most 1"; } return "PASS: " + num + " Kydl_UI_Root UIDocument(s)"; } private static string World_KC02_HubRowOne() { int modCount = KyHub.Model.ModCount; if (modCount == 0) { return "SKIP: the hub was not opened yet (its mod list is read when it opens): press F6 once, then PageDown"; } int num = 0; foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (value != null && value.Metadata != null && HubModel.IsHubGuid(value.Metadata.GUID)) { num++; } } ModLog.Check("KC-02 row-1 tabs", modCount, num, 0.0, "mods"); if (modCount != num) { return "FAIL: " + modCount + " mod(s) in row 1, " + num + " loaded com.kydldev.* plugin(s)"; } return "PASS: " + modCount + " mod(s) in row 1 = " + num + " loaded com.kydldev.* plugin(s)"; } private static string World_KC03_HubTabs() { HubModel model = KyHub.Model; if (model.ModCount == 0) { return "SKIP: the hub was not opened yet: press F6 once, then PageDown"; } string[] array = model.ModGuids(); foreach (string text in array) { if (model.TabIds(text).Length == 0) { return "FAIL: " + text + " has no tab in row 2"; } } List<string> list = new List<string>(model.TabIds("com.kydldev.KydlCore")); bool flag = list.Contains("ky-items"); bool flag2 = KyItems.All.Count > 0; ModLog.Verbose("InGameTests: KC-03 KydlCore tabs " + string.Join(", ", list.ToArray()) + ", registry " + KyItems.All.Count); if (!list.Contains("settings")) { return "FAIL: KydlCore has no 'settings' tab (" + string.Join(", ", list.ToArray()) + ")"; } if (flag != flag2) { return "FAIL: ky-items tab " + (flag ? "shown" : "missing") + " but the registry has " + KyItems.All.Count + " entr" + ((KyItems.All.Count == 1) ? "y" : "ies"); } return "PASS: all " + model.ModCount + " mod(s) have a tab; KydlCore tabs " + string.Join(", ", list.ToArray()); } private static string World_KC04_KyItemsCount() { HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (CustomItem item in ModRegistry.GetItems()) { if (item != null && (Object)(object)item.ItemPrefab != (Object)null && ((CustomEntity)item).SourceMod != null && KyItems.IsUserGuid(((CustomEntity)item).SourceMod.GUID)) { hashSet.Add(((Object)item.ItemPrefab).name); } } foreach (CustomPiece piece in ModRegistry.GetPieces()) { if (piece != null && (Object)(object)piece.PiecePrefab != (Object)null && ((CustomEntity)piece).SourceMod != null && KyItems.IsUserGuid(((CustomEntity)piece).SourceMod.GUID)) { hashSet.Add(((Object)piece.PiecePrefab).name); } } int count = KyItems.All.Count; ModLog.Check("KC-04 KY-Items entries (at least the Jotunn ones)", count, hashSet.Count, 0.0, "prefabs"); if (!KyItems.Ready) { return "FAIL: the registry is not Ready 5 s after the world loaded"; } foreach (string item2 in hashSet) { if (KyItems.Find(item2) == null) { return "FAIL: '" + item2 + "' is registered by Jotunn for a com.kydldev.* mod but is not in the registry"; } } return "PASS: " + count + " entr" + ((count == 1) ? "y" : "ies") + " (" + hashSet.Count + " from Jotunn); " + CountNoIcon() + " without an icon"; } private static string World_KC05_KyUiWindow() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown if (KyUi.Root == null) { return "SKIP: the UI root does not exist yet (open the hub once with F6, then PageDown)"; } bool anyOpen = KyUi.AnyOpen; int closed = 0; if (KyUi.Open("com.kydldev.kydlcore.test", "kc05", new VisualElement(), delegate { closed++; }) == null) { return "FAIL: KyUi.Open returned null"; } bool flag = KyUi.IsOpen("com.kydldev.kydlcore.test", "kc05") && KyUi.AnyOpen; KyWindow kyWindow = KyUi.Open("com.kydldev.kydlcore.test", "kc05", new VisualElement(), delegate { closed++; }); bool flag2 = closed == 1 && KyUi.IsOpen("com.kydldev.kydlcore.test", "kc05"); bool flag3 = KyUi.Open("com.kydldev.kydlcore.test", " ", new VisualElement()) == null; kyWindow.Close(); kyWindow.Close(); bool flag4 = !KyUi.IsOpen("com.kydldev.kydlcore.test", "kc05") && closed == 2 && KyUi.AnyOpen == anyOpen; ModLog.Check("KC-05 KyUi window", closed, 2.0, 0.0, "onClosed calls"); if (flag && flag2 && flag3 && flag4) { return "PASS: window opened, replaced by the same id, closed once; onClosed ran 2 times, any-open back to " + anyOpen; } return "FAIL: openAfter " + flag + ", replaced " + flag2 + ", blankIdRefused " + flag3 + ", closedClean " + flag4 + " (onClosed " + closed + ")"; } private static string CountNoIcon() { int num = 0; foreach (KyEntry item in KyItems.All) { if ((Object)(object)item.Icon == (Object)null) { num++; } } return num.ToString(); } private static string World_PlayerPresent() { //IL_0050: 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) Player localPlayer = Player.m_localPlayer; ModLog.Verbose("InGameTests: World_PlayerPresent player " + (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetPlayerName() : "null")); if (!((Object)(object)localPlayer != (Object)null)) { return "FAIL: no local player 5 s after the world loaded"; } string playerName = localPlayer.GetPlayerName(); Vector3 position = ((Component)localPlayer).transform.position; return "PASS: " + playerName + " at " + ((Vector3)(ref position)).ToString("F1"); } } } namespace KydlCore.Testing.TestHooks { internal static class TestHooks { [TestHook("kc.arena")] private static string Arena() { return TestArena.MovePlayer(); } [TestHook("kc.selftest")] private static string SelfTest() { return TestLabSupport.RunInGameTests(typeof(InGameTests)); } [TestHook("kc.hubOpen")] private static bool HubOpen(string mod = null, string tab = null) { KyHub.Open(string.IsNullOrEmpty(mod) ? null : mod, string.IsNullOrEmpty(tab) ? null : tab); return KyHub.IsOpen; } [TestHook("kc.hubIsOpen")] private static bool HubIsOpen() { return KyHub.IsOpen; } [TestHook("kc.hubClose")] private static bool HubClose() { KyHub.Close(); return KyHub.IsOpen; } [TestHook("kc.hubMods")] private static string HubMods() { return string.Join(",", KyHub.Model.ModGuids().ToArray()); } [TestHook("kc.hubTabCount")] private static int HubTabCount(string mod) { return KyHub.Model.TabIds(mod).Length; } [TestHook("kc.hubTabs")] private static string HubTabs(string mod) { return string.Join(",", KyHub.Model.TabIds(mod)); } [TestHook("kc.itemsCount")] private static int ItemsCount(string mod = null) { if (!string.IsNullOrEmpty(mod)) { return KyItems.ByMod(mod).Count(); } return KyItems.All.Count; } [TestHook("kc.itemsReady")] private static bool ItemsReady() { return KyItems.Ready; } [TestHook("kc.itemsContribute")] private static string ItemsContribute(string id, string prefab, string owner) { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefab) : null); if ((Object)(object)val == (Object)null && (Object)(object)ObjectDB.instance != (Object)null) { val = ObjectDB.instance.GetItemPrefab(prefab); } return KyItems.Contribute(new KyContribution { Id = id, ModGuid = owner, Prefab = val, Kind = KyKind.Item }).ToString(); } [TestHook("kc.itemsById")] private static string ItemsById(string id) { KyEntry kyEntry = KyItems.FindById(id); if (kyEntry == null) { return ""; } return kyEntry.Prefab; } [TestHook("kc.itemsWithdraw")] private static bool ItemsWithdraw(string id) { return KyItems.Withdraw(id); } } } namespace KydlCore.Ui { public sealed class UiColorPicker { private static readonly string[] Palette = new string[14] { "#FFFFFF", "#000000", "#E8D5A9", "#FFB85C", "#C0392B", "#E67E22", "#F1C40F", "#2ECC71", "#1ABC9C", "#00FFFF", "#3498DB", "#9B59B6", "#FF33FF", "#7F8C8D" }; public readonly VisualElement Root; private readonly VisualElement _preview; private readonly UiSlider _r; private readonly UiSlider _g; private readonly UiSlider _b; private readonly UiSlider _bright; private readonly TextField _hex; private readonly Action<string> _changed; private Color _c; private float _h; private float _s; public string Hex => "#" + ColorUtility.ToHtmlStringRGB(_c); public Color Color => _c; public UiColorPicker(string hex, Action<string> changed, bool brightness) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0073: 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_0088: Expected O, but got Unknown //IL_0098: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) _changed = changed; if (!ColorUtility.TryParseHtmlString(hex ?? "#FFFFFF", ref _c)) { _c = Color.white; } _c.a = 1f; float num = default(float); Color.RGBToHSV(_c, ref _h, ref _s, ref num); Root = new VisualElement(); Root.style.flexShrink = StyleFloat.op_Implicit(0f); _preview = new VisualElement(); _preview.style.height = StyleLength.op_Implicit(26f); UiKit.Radius(_preview, 4f); UiKit.Borders(_preview, 1f, UiKit.Border); Root.Add(_preview); VisualElement val = new VisualElement(); val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); val.style.flexWrap = StyleEnum<Wrap>.op_Implicit((Wrap)1); val.style.flexShrink = StyleFloat.op_Implicit(0f); val.style.marginTop = StyleLength.op_Implicit(8f); val.style.marginBottom = StyleLength.op_Implicit(4f); string[] palette = Palette; Color pc = default(Color); foreach (string p in palette) { ColorUtility.TryParseHtmlString(p, ref pc); VisualElement sw = new VisualElement(); sw.style.width = StyleLength.op_Implicit(28f); sw.style.height = StyleLength.op_Implicit(28f); sw.style.marginRight = StyleLength.op_Implicit(6f); sw.style.marginTop = StyleLength.op_Implicit(4f); sw.style.backgroundColor = StyleColor.op_Implicit(pc); UiKit.Radius(sw, 4f); UiKit.Borders(sw, 1f, UiKit.Border); ((CallbackEventHandler)sw).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) UiKit.Borders(sw, 2f, UiKit.Gold); }, (TrickleDown)0); ((CallbackEventHandler)sw).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) UiKit.Borders(sw, 1f, UiKit.Border); }, (TrickleDown)0); ((CallbackEventHandler)sw).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0) { UiLog.Verbose("UiColorPicker: swatch " + p); SetColor(pc, updateHex: true, notify: true); } }, (TrickleDown)0); val.Add(sw); } Root.Add(val); _r = new UiSlider(0f, 255f, _c.r * 255f, "0", delegate(float x) { _c.r = x / 255f; FromRgb(); }); _g = new UiSlider(0f, 255f, _c.g * 255f, "0", delegate(float x) { _c.g = x / 255f; FromRgb(); }); _b = new UiSlider(0f, 255f, _c.b * 255f, "0", delegate(float x) { _c.b = x / 255f; FromRgb(); }); Root.Add(UiControls.Row("Red", _r.Root)); Root.Add(UiControls.Row("Green", _g.Root)); Root.Add(UiControls.Row("Blue", _b.Root)); if (brightness) { _bright = new UiSlider(0f, 100f, num * 100f, "0", OnBrightness, new float[5] { 0f, 0.25f, 0.5f, 0.75f, 1f }); Root.Add(UiControls.Row("Brightness", _bright.Root)); } _hex = UiControls.TextField(Hex, 7, OnHexTyped); ((VisualElement)_hex).style.width = StyleLength.op_Implicit(130f); ((VisualElement)_hex).style.flexGrow = StyleFloat.op_Implicit(0f); VisualElement val2 = UiControls.Row("Hex", (VisualElement)(object)_hex); ((VisualElement)_hex).style.flexGrow = StyleFloat.op_Implicit(0f); Root.Add(val2); Show(all: true); } private void OnBrightness(float percent) { //IL_001a: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(percent / 100f); Color c = Color.HSVToRGB(_h, _s, num); c.a = 1f; _c = c; UiLog.Verbose("UiColorPicker: brightness " + percent.ToString("0") + "% -> " + Hex); Show(all: false, fromBrightness: true); _changed?.Invoke(Hex); } private void FromRgb() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) float h = default(float); float num = default(float); float num2 = default(float); Color.RGBToHSV(_c, ref h, ref num, ref num2); if (num2 > 0.001f && num > 0.001f) { _h = h; _s = num; } else if (num2 > 0.001f) { _s = num; } Show(all: false); _changed?.Invoke(Hex); } private void OnHexTyped(string text) { //IL_0041: 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_006b: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); if (text != null && text.TrimStart(new char[1] { '#' }).Length == 6 && ColorUtility.TryParseHtmlString(text.StartsWith("#") ? text : ("#" + text), ref val) && !(ColorUtility.ToHtmlStringRGB(val) == ColorUtility.ToHtmlStringRGB(_c))) { UiLog.Verbose("UiColorPicker: hex typed " + text); SetColor(val, updateHex: false, notify: true); } } private void Show(bool all, bool fromBrightness = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) _preview.style.backgroundColor = StyleColor.op_Implicit(_c); if (all || fromBrightness) { _r.SetValueWithoutNotify(_c.r * 255f); _g.SetValueWithoutNotify(_c.g * 255f); _b.SetValueWithoutNotify(_c.b * 255f); } if (_bright != null && !fromBrightness) { float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(_c, ref num, ref num2, ref num3); _bright.SetValueWithoutNotify(num3 * 100f); } ((BaseField<string>)(object)_hex).SetValueWithoutNotify(Hex); } private void SetColor(Color c, bool updateHex, bool notify) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) c.a = 1f; _c = c; float h = default(float); float num = default(float); float num2 = default(float); Color.RGBToHSV(_c, ref h, ref num, ref num2); if (num2 > 0.001f && num > 0.001f) { _h = h; _s = num; } else if (num2 > 0.001f) { _s = num; } Show(all: true); if (!updateHex) { ((BaseField<string>)(object)_hex).SetValueWithoutNotify(((BaseField<string>)(object)_hex).value); } if (notify) { _changed?.Invoke(Hex); } } public bool Set(Color c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) SetColor(c, updateHex: true, notify: false); return ColorUtility.ToHtmlStringRGB(_c) == ColorUtility.ToHtmlStringRGB(new Color(c.r, c.g, c.b, 1f)); } } public static class UiControls { private const float PressDim = 0.35f; private const long PressFeedbackMs = 120L; private const float ItemHeight = 40f; private const float ListMax = 400f; private static readonly string[] Palette = new string[14] { "#FFFFFF", "#000000", "#E8D5A9", "#FFB85C", "#C0392B", "#E67E22", "#F1C40F", "#2ECC71", "#1ABC9C", "#00FFFF", "#3498DB", "#9B59B6", "#FF33FF", "#7F8C8D" }; public static Button Button(string text, Action onClick, bool primary = false) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0096: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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) Button b = new Button(UiLog.Wrap(delegate { UiLog.Verbose("Ui: button '" + text + "' pressed"); onClick?.Invoke(); })) { text = text }; Color bg = (primary ? UiKit.GoldDim : UiKit.PanelLight); Color hot = (primary ? UiKit.Gold : UiKit.PanelHover); ((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(bg); ((VisualElement)b).style.color = StyleColor.op_Implicit(primary ? UiKit.OnDark : UiKit.Text); ((VisualElement)b).style.fontSize = StyleLength.op_Implicit(21f); UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border); UiKit.Radius((VisualElement)(object)b, 4f); UiKit.Pad((VisualElement)(object)b, 6f, 14f); ((VisualElement)b).style.flexShrink = StyleFloat.op_Implicit(0f); ((VisualElement)b).style.marginLeft = StyleLength.op_Implicit(3f); ((VisualElement)b).style.marginRight = StyleLength.op_Implicit(3f); ((VisualElement)b).style.marginTop = StyleLength.op_Implicit(3f); ((VisualElement)b).style.marginBottom = StyleLength.op_Implicit(3f); UiKit.Fade((VisualElement)(object)b, "background-color"); bool hovered = false; bool pressed = false; Action show = delegate { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0064: 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) ((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(pressed ? Color.Lerp(hot, Color.black, 0.35f) : (hovered ? hot : bg)); UiKit.Borders((VisualElement)(object)b, 1f, hovered ? UiKit.TabColor : UiKit.Border); }; ((CallbackEventHandler)b).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate { hovered = true; show(); }, (TrickleDown)0); ((CallbackEventHandler)b).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate { hovered = false; pressed = false; show(); }, (TrickleDown)0); ((CallbackEventHandler)b).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate { pressed = true; show(); UiLog.Verbose("Ui: button '" + text + "' down, dimmed " + 35f.ToString("0") + "% for at least " + 120L + " ms"); }, (TrickleDown)0); ((CallbackEventHandler)b).RegisterCallback<PointerUpEvent>((EventCallback<PointerUpEvent>)delegate { ((VisualElement)b).schedule.Execute((Action)delegate { pressed = false; show(); }).StartingIn(120L); }, (TrickleDown)0); return b; } public static Button Field(string text, Action onClick) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0080: 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_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_011e: Unknown result type (might be due to invalid IL or missing references) Button b = new Button(UiLog.Wrap(delegate { UiLog.Verbose("Ui: field '" + text + "' opened"); onClick?.Invoke(); })) { text = text }; ((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(UiKit.Track); ((VisualElement)b).style.color = StyleColor.op_Implicit(UiKit.ValueColor); ((VisualElement)b).style.fontSize = StyleLength.op_Implicit(22f); UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border); UiKit.Radius((VisualElement)(object)b, 4f); UiKit.Pad((VisualElement)(object)b, 5f, 10f); ((VisualElement)b).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3); ((VisualElement)b).style.flexShrink = StyleFloat.op_Implicit(0f); ((VisualElement)b).style.marginLeft = StyleLength.op_Implicit(0f); ((VisualElement)b).style.marginRight = StyleLength.op_Implicit(0f); UiKit.Fade((VisualElement)(object)b, "border-top-color", "border-bottom-color", "border-left-color", "border-right-color"); ((CallbackEventHandler)b).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Gold); }, (TrickleDown)0); ((CallbackEventHandler)b).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border); }, (TrickleDown)0); return b; } public static VisualElement Heading(string text) { //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_0010: 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_0025: 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_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0083: 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) //IL_00ad: 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_00bf: Expected O, but got Unknown VisualElement val = new VisualElement(); val.style.flexShrink = StyleFloat.op_Implicit(0f); val.style.marginTop = StyleLength.op_Implicit(16f); val.style.marginBottom = StyleLength.op_Implicit(6f); Label val2 = UiKit.Label(text, 24f, UiKit.TabColor, title: true); ((VisualElement)val2).style.letterSpacing = StyleLength.op_Implicit(1.5f); val.Add((VisualElement)(object)val2); VisualElement val3 = new VisualElement(); val3.style.height = StyleLength.op_Implicit(1f); val3.style.backgroundColor = StyleColor.op_Implicit(UiKit.Border); val3.style.marginTop = StyleLength.op_Implicit(4f); val.Add(val3); return val; } public static Label Note(string text) { //IL_0006: 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_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_0057: Unknown result type (might be due to invalid IL or missing references) Label obj = UiKit.Label(text, 18f, UiKit.TextDim); ((VisualElement)obj).style.whiteSpace = StyleEnum<WhiteSpace>.op_Implicit((WhiteSpace)0); ((VisualElement)obj).style.flexShrink = StyleFloat.op_Implicit(0f); ((VisualElement)obj).style.marginTop = StyleLength.op_Implicit(2f); ((VisualElement)obj).style.marginBottom = StyleLength.op_Implicit(2f); return obj; } public static VisualElement Row(string label, VisualElement control) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown VisualElement val = new VisualElement(); val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2); val.style.flexShrink = StyleFloat.op_Implicit(0f); val.style.marginTop = StyleLength.op_Implicit(4f); val.style.marginBottom = StyleLength.op_Implicit(4f); Label val2 = UiKit.Label(label, 24f, UiKit.NameColor); ((VisualElement)val2).style.width = StyleLength.op_Implicit(170f); ((VisualElement)val2).style.flexShrink = StyleFloat.op_Implicit(0f); val.Add((VisualElement)(object)val2); control.style.flexGrow = StyleFloat.op_Implicit(1f); control.style.flexShrink = StyleFloat.op_Implicit(1f); val.Add(control); return val; } public static VisualElement Line(params VisualElement[] items) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_000d: 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_002f: 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) VisualElement val = new VisualElement(); val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); val.style.flexWrap = StyleEnum<Wrap>.op_Implicit((Wrap)1); val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2); val.style.flexShrink = StyleFloat.op_Implicit(0f); foreach (VisualElement val2 in items) { val.Add(val2); } return val; } public static TextField TextField(string value, int maxLength, Action<string> changed) { //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_0033: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_003a: 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_004f: 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_0064: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00bf: Expected O, but got Unknown changed = UiLog.Wrap(changed); TextField val = new TextField(); ((BaseField<string>)val).value = value ?? ""; ((TextInputBaseField<string>)val).maxLength = maxLength; ((VisualElement)val).style.marginLeft = StyleLength.op_Implicit(0f); ((VisualElement)val).style.marginRight = StyleLength.op_Implicit(0f); ((VisualElement)val).style.marginTop = StyleLength.op_Implicit(0f); ((VisualElement)val).style.marginBottom = StyleLength.op_Implicit(0f); ((VisualElement)val).style.flexShrink = StyleFloat.op_Implicit(0f); StyleInput(val, 22); INotifyValueChangedExtensions.RegisterValueChangedCallback<string>((INotifyValueChanged<string>)val, (EventCallback<ChangeEvent<string>>)delegate(ChangeEvent<string> e) { changed?.Invoke(e.newValue); }); return val; } private static void StyleInput(TextField f, int size) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_005e: 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_00ae: Unknown result type (might be due to invalid IL or missing references) VisualElement input = (VisualElement)(((object)UQueryExtensions.Q((VisualElement)(object)f, (string)null, TextField.inputUssClassName)) ?? ((object)f)); input.style.backgroundColor = StyleColor.op_Implicit(UiKit.Track); input.style.color = StyleColor.op_Implicit(UiKit.ValueColor); input.style.fontSize = StyleLength.op_Implicit((float)size); UiKit.Borders(input, 1f, UiKit.Border); UiKit.Radius(input, 4f); UiKit.Pad(input, 5f, 8f); input.style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3); ((CallbackEventHandler)f).RegisterCallback<FocusInEvent>((EventCallback<FocusInEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) UiKit.Borders(input, 1f, UiKit.Gold); }, (TrickleDown)0); ((CallbackEventHandler)f).RegisterCallback<FocusOutEvent>((EventCallback<FocusOutEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) UiKit.Borders(input, 1f, UiKit.Border); }, (TrickleDown)0); } private static EventCallback<T> Owned<T>(EventCallback<T> handler) where T : EventBase<T>, new() { string owner = UiLog.Owner; return delegate(T e) { UiLog.Within(owner, delegate { handler.Invoke(e); return true; }); }; } public static VisualElement Toggle(string text, bool on, Action<bool> changed) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00fc: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) changed = UiLog.Wrap(changed); bool state = on; VisualElement row = new VisualElement(); row.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); row.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2); row.style.flexShrink = StyleFloat.op_Implicit(0f); UiKit.Pad(row, 5f, 8f); UiKit.Radius(row, 4f); row.style.marginRight = StyleLength.op_Implicit(6f); UiKit.Fade(row, "background-color"); VisualElement sw = new VisualElement(); sw.pickingMode = (PickingMode)1; sw.style.width = StyleLength.op_Implicit(44f); sw.style.height = StyleLength.op_Implicit(22f); sw.style.flexShrink = StyleFloat.op_Implicit(0f); sw.style.marginRight = StyleLength.op_Implicit(8f); UiKit.Radius(sw, 11f); UiKit.Borders(sw, 1f, UiKit.Border); UiKit.Fade(sw, "background-color"); VisualElement knob = new VisualElement(); knob.pickingMode = (PickingMode)1; knob.style.position = StyleEnum<Position>.op_Implicit((Position)1); knob.style.top = StyleLength.op_Implicit(2f); knob.style.width = StyleLength.op_Implicit(16f); knob.style.height = StyleLength.op_Implicit(16f); UiKit.Radius(knob, 8f); UiKit.Fade(knob, "left", "background-color"); sw.Add(knob); row.Add(sw); row.Add((VisualElement)(object)UiKit.Label(text, 24f, UiKit.NameColor)); ((CallbackEventHandler)row).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) row.style.backgroundColor = StyleColor.op_Implicit(UiKit.PanelLight); }, (TrickleDown)0); ((CallbackEventHandler)row).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) row.style.backgroundColor = StyleColor.op_Implicit(Color.clear); }, (TrickleDown)0); ((CallbackEventHandler)row).RegisterCallback<PointerDownEvent>(Owned<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e) { if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0) { state = !state; Show(); UiLog.Verbose("Ui: switch '" + text + "' " + (state ? "on" : "off")); changed?.Invoke(state); } }), (TrickleDown)0); Show(); return row; void Show() { //IL_001a: 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_001f: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) sw.style.backgroundColor = StyleColor.op_Implicit(state ? UiKit.GoldDim : UiKit.Track); knob.style.left = StyleLength.op_Implicit((float)(state ? 24 : 2)); knob.style.backgroundColor = StyleColor.op_Implicit(state ? UiKit.Gold : UiKit.TextDim); } } public static VisualElement Slider(float min, float max, float value, string format, Action<float> changed) { //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_0040: 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_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) //IL_0066: 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_007b: 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_0090: Expected O, but got Unknown //IL_00a0: 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_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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown //IL_0306: Expected O, but got Unknown //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_037e: 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_03af: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Expected O, but got Unknown changed = UiLog.Wrap(changed); VisualElement val = new VisualElement(); val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2); val.style.flexShrink = StyleFloat.op_Implicit(0f); val.style.minHeight = StyleLength.op_Implicit(34f); VisualElement hit = new VisualElement(); hit.style.flexGrow = StyleFloat.op_Implicit(1f); hit.style.height = StyleLength.op_Implicit(24f); hit.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)1); hit.style.marginRight = StyleLength.op_Implicit(10f); VisualElement val2 = new VisualElement(); val2.pickingMode = (PickingMode)1; val2.style.height = StyleLength.op_Implicit(6f); UiKit.Radius(val2, 3f); val2.style.backgroundColor = StyleColor.op_Implicit(UiKit.Track); UiKit.Borders(val2, 1f, UiKit.Border); hit.Add(val2); VisualElement fill = new VisualElement(); fill.pickingMode = (PickingMode)1; fill.style.position = StyleEnum<Position>.op_Implicit((Position)1); fill.style.left = StyleLength.op_Implicit(0f); fill.style.top = StyleLength.op_Implicit(0f); fill.style.bottom = StyleLength.op_Implicit(0f); fill.style.backgroundColor = StyleColor.op_Implicit(UiKit.GoldDim); UiKit.Radius(fill, 3f); val2.Add(fill); VisualElement handle = new VisualElement(); handle.pickingMode = (PickingMode)1; handle.style.position = StyleEnum<Position>.op_Implicit((Position)1); handle.style.top = StyleLength.op_Implicit(4f); handle.style.width = StyleLength.op_Implicit(16f); handle.style.height = StyleLength.op_Implicit(16f); handle.style.marginLeft = StyleLength.op_Implicit(-8f); UiKit.Radius(handle, 8f); handle.style.backgroundColor = StyleColor.op_Implicit(UiKit.Gold); UiKit.Borders(handle, 1f, UiKit.OnDark); hit.Add(handle); val.Add(hit); TextField val3 = new TextField(); ((TextInputBaseField<string>)val3).maxLength = 8; TextField input = val3; ((VisualElement)input).style.width = StyleLength.op_Implicit(80f); ((VisualElement)input).style.flexShrink = StyleFloat.op_Implicit(0f); ((VisualElement)input).style.marginLeft = StyleLength.op_Implicit(0f); ((VisualElement)input).style.marginRight = StyleLength.op_Implicit(0f); ((VisualElement)input).style.marginTop = StyleLength.op_Implicit(0f); ((VisualElement)input).style.marginBottom = StyleLength.op_Implicit(0f); StyleInput(input, 19); val.Add((VisualElement)(object)input); float v = Mathf.Clamp(value, min, max); bool editing = false; ((CallbackEventHandler)hit).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) PointerCaptureHelper.CapturePointer((IEventHandler)(object)hit, ((PointerEventBase<PointerDownEvent>)(object)e).pointerId); FromX(((PointerEventBase<PointerDownEvent>)(object)e).localPosition.x); ((EventBase)e).StopPropagation(); }, (TrickleDown)0); ((CallbackEventHandler)hit).RegisterCallback<PointerMoveEvent>((EventCallback<PointerMoveEvent>)delegate(PointerMoveEvent e) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (PointerCaptureHelper.HasPointerCapture((IEventHandler)(object)hit, ((PointerEventBase<PointerMoveEvent>)(object)e).pointerId)) { FromX(((PointerEventBase<PointerMoveEvent>)(object)e).localPosition.x); } }, (TrickleDown)0); ((CallbackEventHandler)hit).RegisterCallback<PointerUpEvent>(Owned<PointerUpEvent>((EventCallback<PointerUpEvent>)delegate(PointerUpEvent e) { if (PointerCaptureHelper.HasPointerCapture((IEventHandler)(object)hit, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId)) { PointerCaptureHelper.ReleasePointer((IEventHandler)(object)hit, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId); UiLog.Verbose("Ui: slider set to " + v.ToString(format)); } }), (TrickleDown)0); ((CallbackEventHandler)input).RegisterCallback<FocusInEvent>((EventCallback<FocusInEvent>)delegate { editing = true; }, (TrickleDown)0); ((CallbackEventHandler)input).RegisterCallback<FocusOutEvent>(Owned<FocusOutEvent>((EventCallback<FocusOutEvent>)delegate { editing = false; Commit(); }), (TrickleDown)0); ((CallbackEventHandler)input).RegisterCallback<KeyDownEvent>(Owned<KeyDownEvent>((EventCallback<KeyDownEvent>)delegate(KeyDownEvent e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if ((int)((KeyboardEventBase<KeyDownEvent>)(object)e).keyCode == 13 || (int)((KeyboardEventBase<KeyDownEvent>)(object)e).keyCode == 271) { ((EventBase)e).StopPropagation(); editing = false; Commit(); ((Focusable)input).Blur(); } }), (TrickleDown)0); Show(); return val; void Commit() { if (float.TryParse((((BaseField<string>)(object)input).value ?? "").Trim().Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { Set(result, "typed"); UiLog.Verbose("Ui: slider typed " + v.ToString(format)); } else { UiLog.Verbose("Ui: slider input '" + ((BaseField<string>)(object)input).value + "' is not a number, kept " + v.ToString(format)); Show(); } } void FromX(float x) { float width = hit.resolvedStyle.width; if (width > 1f) { Set(Mathf.Lerp(min, max, Mathf.Clamp01(x / width)), "drag"); } } void Set(float nv, string how) { v = Mathf.Clamp(nv, min, max); Show(); changed?.Invoke(v); } void Show() { //IL_003f: 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_0060: 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) float num = ((max > min) ? Mathf.InverseLerp(min, max, v) : 0f); fill.style.width = StyleLength.op_Implicit(Length.Percent(num * 100f)); handle.style.left = StyleLength.op_Implicit(Length.Percent(num * 100f)); if (!editing) { ((BaseField<string>)(object)input).SetValueWithoutNotify(v.ToString(format)); } } } public static Button Dropdown(IList<string> options, string current, Func<string, string> label, Action<string> chosen) { chosen = UiLog.Wrap(chosen); Button b = null; string cur = current; VisualElement openList = null; b = Field(label(current) + " ▾", delegate { //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_002d: Expected O, but got Unknown //IL_0039: 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_006d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00df: Expected O, but got Unknown //IL_00e5: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) VisualElement root = UiKit.Root; if (root != null) { VisualElement shade = new VisualElement { name = "kydl-dropdown" }; shade.style.position = StyleEnum<Position>.op_Implicit((Position)1); shade.style.left = StyleLength.op_Implicit(0f); shade.style.top = StyleLength.op_Implicit(0f); shade.style.right = StyleLength.op_Implicit(0f); shade.style.bottom = StyleLength.op_Implicit(0f); shade.style.backgroundColor = StyleColor.op_Implicit(new Color(0f, 0f, 0f, 0.35f)); VisualElement val = new VisualElement(); Rect worldBound = ((VisualElement)b).worldBound; float num = Mathf.Min(400f, (float)options.Count * 40f + 12f); float num2 = ((Rect)(ref worldBound)).yMax + num; Rect layout = root.layout; float num3 = ((num2 > ((Rect)(ref layout)).height) ? Mathf.Max(0f, ((Rect)(ref worldBound)).yMin - num) : (((Rect)(ref worldBound)).yMax + 2f)); val.style.position = StyleEnum<Position>.op_Implicit((Position)1); val.style.left = StyleLength.op_Implicit(((Rect)(ref worldBound)).xMin); val.style.top = StyleLength.op_Implicit(num3); val.style.width = StyleLength.op_Implicit(Mathf.Max(((Rect)(ref worldBound)).width, 260f)); val.style.height = StyleLength.op_Implicit(num); val.style.backgroundColor = StyleColor.op_Implicit(new Color(UiKit.Panel.r, UiKit.Panel.g, UiKit.Panel.b, 1f)); UiKit.Borders(val, 1f, UiKit.Gold); UiKit.Radius(val, 6f); UiKit.Pad(val, 4f, 4f); UiScroll uiScroll = new UiScroll("drop-down"); val.Add(uiScroll.Root); foreach (string option in options) { string opt = option; Label item = UiKit.Label(label(opt), 22f, (opt == cur) ? UiKit.ValueColor : UiKit.Text); ((VisualElement)item).pickingMode = (PickingMode)0; ((VisualElement)item).style.height = StyleLength.op_Implicit(36f); ((VisualElement)item).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3); ((VisualElement)item).style.flexShrink = StyleFloat.op_Implicit(0f); UiKit.Pad((VisualElement)(object)item, 0f, 10f); UiKit.Radius((VisualElement)(object)item, 4f); UiKit.Fade((VisualElement)(object)item, "background-color"); ((CallbackEventHandler)item).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((VisualElement)item).style.backgroundColor = StyleColor.op_Implicit(UiKit.PanelHover); }, (TrickleDown)0); ((CallbackEventHandler)item).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((VisualElement)item).style.backgroundColor = StyleColor.op_Implicit(Color.clear); }, (TrickleDown)0); ((CallbackEventHandler)item).RegisterCallback<PointerDownEvent>(Owned<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e) { if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0) { cur = opt; ((TextElement)b).text = label(opt) + " ▾"; shade.RemoveFromHierarchy(); UiLog.Verbose("Ui: drop-down chose '" + opt + "'"); chosen?.Invoke(opt); } }), (TrickleDown)0); uiScroll.Content.Add((VisualElement)(object)item); } ((CallbackEventHandler)shade).RegisterCallback<PointerDownEvent>(Owned<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e) { if ((object)((EventBase)e).target == shade) { shade.RemoveFromHierarchy(); UiLog.Verbose("Ui: drop-down closed without a choice"); } }), (TrickleDown)0); shade.Add(val); root.Add(shade); openList = shade; int num4 = options.IndexOf(cur); if (num4 > 3) { uiScroll.ScrollTo((float)(num4 - 3) * 40f); } UiLog.Verbose("Ui: drop-down opened with " + options.Count + " option(s), current '" + cur + "'"); } }); ((CallbackEventHandler)b).RegisterCallback<DetachFromPanelEvent>(Owned<DetachFromPanelEvent>((EventCallback<DetachFromPanelEvent>)delegate { VisualElement val = openList; openList = null; if (val != null && val.parent != null) { val.RemoveFromHierarchy(); UiLog.Verbose("Ui: drop-down closed because its field left the panel"); } }), (TrickleDown)0); return b; } public static VisualElement ColorPicker(string hex, Action<string> changed, out Action<string> set) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0076: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00be: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_013a: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) changed = UiLog.Wrap(changed); VisualElement val = new VisualElement(); val.style.flexShrink = StyleFloat.op_Implicit(0f); Color c = default(Color); if (!ColorUtility.TryParseHtmlString(hex ?? "#FFFFFF", ref c)) { c = Color.white; } VisualElement preview = new VisualElement(); preview.style.height = StyleLength.op_Implicit(26f); UiKit.Radius(preview, 4f); UiKit.Borders(preview, 1f, UiKit.Border); val.Add(preview); VisualElement val2 = new VisualElement(); val2.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); val2.style.flexWrap = StyleEnum<Wrap>.op_Implicit((Wrap)1); val2.style.flexShrink = StyleFloat.op_Implicit(0f); val2.style.marginTop = StyleLength.op_Implicit(8f); val2.style.marginBottom = StyleLength.op_Implicit(4f); val.Add(val2); VisualElement sliders = new VisualElement(); sliders.style.flexShrink = StyleFloat.op_Implicit(0f); val.Add(sliders); TextField field = null; string[] palette = Palette; Color pc = default(Color); foreach (string obj in palette) { ColorUtility.TryParseHtmlString(obj, ref pc); VisualElement s = new VisualElement(); s.style.width = StyleLength.op_Implicit(28f); s.style.height = StyleLength.op_Implicit(28f); s.style.marginRight = StyleLength.op_Implicit(6f); s.style.marginTop = StyleLength.op_Implicit(4f); s.style.backgroundColor = StyleColor.op_Implicit(pc); UiKit.Radius(s, 4f); UiKit.Borders(s, 1f, UiKit.Border); ((CallbackEventHandler)s).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) UiKit.Borders(s, 2f, UiKit.Gold); }, (TrickleDown)0); ((CallbackEventHandler)s).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) UiKit.Borders(s, 1f, UiKit.Border); }, (TrickleDown)0); ((CallbackEventHandler)s).RegisterCallback<PointerDownEvent>(Owned<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate { //IL_0007: 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) c = pc; RebuildSliders(); Apply(fromField: false); }), (TrickleDown)0); val2.Add(s); } field = TextField("#" + ColorUtility.ToHtmlStringRGB(c), 7, delegate(string v) { //IL_003e: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Color val4 = default(Color); if (v.TrimStart(new char[1] { '#' }).Length == 6 && ColorUtility.TryParseHtmlString(v.StartsWith("#") ? v : ("#" + v), ref val4)) { if (ColorUtility.ToHtmlStringRGB(val4) == ColorUtility.ToHtmlStringRGB(c)) { UiLog.Verbose("Ui: colour hex " + v + " = current colour, sliders kept"); } else { c = val4; RebuildSliders(); Apply(fromField: true); UiLog.Verbose("Ui: colour typed " + v + ", sliders set"); } } }); ((VisualElement)field).style.width = StyleLength.op_Implicit(130f); ((VisualElement)field).style.flexGrow = StyleFloat.op_Implicit(0f); VisualElement val3 = Row("Hex", (VisualElement)(object)field); ((VisualElement)field).style.flexGrow = StyleFloat.op_Implicit(0f); val.Add(val3); RebuildSliders(); preview.style.backgroundColor = StyleColor.op_Implicit(c); set = delegate(string h) { //IL_000b: 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_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) Color val4 = default(Color); if (ColorUtility.TryParseHtmlString(h, ref val4)) { c = val4; RebuildSliders(); ((BaseField<string>)(object)field).SetValueWithoutNotify(h); preview.style.backgroundColor = StyleColor.op_Implicit(c); } }; return val; void Apply(bool fromField) { //IL_0006: 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) string text = "#" + ColorUtility.ToHtmlStringRGB(c); preview.style.backgroundColor = StyleColor.op_Implicit(c); if (!fromField && field != null) { ((BaseField<string>)(object)field).SetValueWithoutNotify(text); } changed?.Invoke(text); } void RebuildSliders() { sliders.Clear(); sliders.Add(Row("Red", Slider(0f, 255f, c.r * 255f, "0", delegate(float v) { c.r = v / 255f; Apply(fromField: false); }))); sliders.Add(Row("Green", Slider(0f, 255f, c.g * 255f, "0", delegate(float v) { c.g = v / 255f; Apply(fromField: false); }))); sliders.Add(Row("Blue", Slider(0f, 255f, c.b * 255f, "0", delegate(float v) { c.b = v / 255f; Apply(fromField: false); }))); } } } public static class UiKit { public static readonly Color Panel = new Color(0.075f, 0.058f, 0.043f, 0.96f); public static readonly Color PanelLight = new Color(0.125f, 0.098f, 0.072f, 0.96f); public static readonly Color PanelHover = new Color(0.19f, 0.145f, 0.098f, 0.96f); public static readonly Color Border = new Color(0.45f, 0.33f, 0.17f, 0.95f); public static readonly Color Gold = new Color(0.85490197f, 0.64705884f, 0.1254902f, 1f); public static readonly Color GoldDim = new Color(0.6156863f, 7f / 15f, 0.09019608f, 1f); public static readonly Color Text = new Color(0.92f, 0.87f, 0.77f, 1f); public static readonly Color TextDim = new Color(0.7f, 0.64f, 0.55f, 1f); public static readonly Color Track = new Color(0.03f, 0.025f, 0.02f, 1f); public static readonly Color OnDark = new Color(0.1f, 0.07f, 0.03f, 1f); public static readonly Color NameColor = new Color(84f / 85f, 49f / 51f, 79f / 85f, 1f); public static readonly Color ValueColor = Gold; public static readonly Color TabColor = new Color(73f / 85f, 11f / 85f, 11f / 85f, 1f); internal const int TitleSize = 34; public const int SectionSize = 24; public const int FontSize = 22; public const int ButtonSize = 21; public const int SmallSize = 18; public const int NameSize = 24; private const float WindowHeight = 80f; private const float WindowTop = 10f; public static string Owner = typeof(UiKit).Assembly.GetName().Name; private static UIDocument _doc; private static Font _bodyFont; private static Font _titleFont; private static FontAsset _bodyAsset; private static FontAsset _titleAsset; private const string TextFontName = "NotoSansSC-Regular"; public static PanelSettings Settings { get; private set; } public static VisualElement Root { get { if ((Object)(object)_doc == (Object)null) { Create(); } if (!((Object)(object)_doc != (Object)null)) { return null; } return _doc.rootVisualElement; } } internal static void Reset() { if ((Object)(object)_doc != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)_doc).gameObject); } _doc = null; } private static void Create() { //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) //IL_0065: Expected O, but got Unknown //IL_0099: 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) //IL_00d8: 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_0111: 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_012a: Unknown result type (might be due to invalid IL or missing references) try { PanelSettings val = ScriptableObject.CreateInstance<PanelSettings>(); ((Object)val).name = "Kydl_PanelSettings"; val.scaleMode = (PanelScaleMode)2; val.referenceResolution = new Vector2Int(1920, 1080); val.screenMatchMode = (PanelScreenMatchMode)0; val.match = 1f; val.sortingOrder = 500f; Settings = val; GameObject val2 = new GameObject("Kydl_UI_" + Owner); if (Application.isPlaying) { Object.DontDestroyOnLoad((Object)(object)val2); } _doc = val2.AddComponent<UIDocument>(); _doc.panelSettings = val; VisualElement rootVisualElement = _doc.rootVisualElement; rootVisualElement.style.position = StyleEnum<Position>.op_Implicit((Position)1); rootVisualElement.style.left = StyleLength.op_Implicit(0f); rootVisualElement.style.top = StyleLength.op_Implicit(0f); rootVisualElement.style.right = StyleLength.op_Implicit(0f); rootVisualElement.style.bottom = StyleLength.op_Implicit(0f); rootVisualElement.pickingMode = (PickingMode)1; string text = LoadFonts(); Font(rootVisualElement, title: false); rootVisualElement.style.color = StyleColor.op_Implicit(Text); rootVisualElement.style.fontSize = StyleLength.op_Implicit(22f); UiLog.Verbose("UiKit: UI Toolkit panel made (scale with screen " + Screen.width + "x" + Screen.height + " from 1920x1080, " + text + ")"); } catch (Exception ex) { UiLog.Error("UiKit: UI Toolkit could not be started - the menus of this mod are not available: " + ex); _doc = null; } } private static string LoadFonts() { Font emoji = null; Font val = null; Font val2 = null; _bodyFont = null; Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val3 in array) { if ((Object)(object)val3 == (Object)null) { continue; } switch (((Object)val3).name) { case "NotoSansSC-Regular": _bodyFont = val3; continue; case "NotoEmoji-Regular": emoji = val3; continue; case "Norse": val = val3; continue; } if ((Object)(object)val2 == (Object)null) { val2 = val3; } } if ((Object)(object)_bodyFont == (Object)null) { _bodyFont = (((Object)(object)val != (Object)null) ? val : val2); UiLog.Warn("UiKit: font 'NotoSansSC-Regular' is not loaded; using " + (((Object)(object)_bodyFont != (Object)null) ? ("'" + ((Object)_bodyFont).name + "'") : "no font (engine default)")); } _titleFont = _bodyFont; return MakeAssets(emoji); } private static string MakeAssets(Font emoji) { if ((Object)(object)emoji == (Object)null) { emoji = Font.CreateDynamicFontFromOSFont(new string[3] { "Segoe UI Emoji", "Segoe UI Symbol", "Noto Emoji" }, 32); } FontAsset val = MakeAsset(emoji, null); _bodyAsset = MakeAsset(_bodyFont, val); _titleAsset = (((Object)(object)_titleFont == (Object)(object)_bodyFont) ? _bodyAsset : MakeAsset(_titleFont, val)); return "text font " + Describe(_bodyFont, _bodyAsset) + ", title font " + Describe(_titleFont, _titleAsset) + ", emoji font " + Describe(emoji, val); } private static string Describe(Font f, FontAsset a) { if (!((Object)(object)f == (Object)null)) { return "'" + ((Object)f).name + "'" + (((Object)(object)a != (Object)null) ? " (font asset made)" : " (legacy font, no emoji fallback)"); } return "MISSING"; } private static FontAsset MakeAsset(Font f, FontAsset fallback) { if ((Object)(object)f == (Object)null) { return null; } try { FontAsset val = FontAsset.CreateFontAsset(f); if ((Object)(object)val == (Object)null) { UiLog.Warn("UiKit: font asset from '" + ((Object)f).name + "' could not be made"); return null; } ((Object)val).name = "Kydl_" + ((Object)f).name; if ((Object)(object)fallback != (Object)null) { if (val.fallbackFontAssetTable == null) { val.fallbackFontAssetTable = new List<FontAsset>(); } val.fallbackFontAssetTable.Add(fallback); } return val; } catch (Exception ex) { UiLog.Warn("UiKit: font asset from '" + ((Object)f).name + "' failed: " + ex.Message); return null; } } internal static void Font(VisualElement e, bool title) { //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_0050: Unknown result type (might be due to invalid IL or missing references) FontAsset val = (title ? _titleAsset : _bodyAsset); Font val2 = (title ? _titleFont : _bodyFont); if ((Object)(object)val != (Object)null) { e.style.unityFontDefinition = StyleFontDefinition.op_Implicit(FontDefinition.FromSDFFont(val)); } else if ((Object)(object)val2 != (Object)null) { e.style.unityFont = StyleFont.op_Implicit(val2); } } public static void Radius(VisualElement e, float r) { //IL_0007: 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_0029: 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) e.style.borderTopLeftRadius = StyleLength.op_Implicit(r); e.style.borderTopRightRadius = StyleLength.op_Implicit(r); e.style.borderBottomLeftRadius = StyleLength.op_Implicit(r); e.style.borderBottomRightRadius = StyleLength.op_Implicit(r); } public static void Borders(VisualElement e, float w, Color c) { //IL_0007: 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_0029: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007d: 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) e.style.borderTopWidth = StyleFloat.op_Implicit(w); e.style.borderRightWidth = StyleFloat.op_Implicit(w); e.style.borderBottomWidth = StyleFloat.op_Implicit(w); e.style.borderLeftWidth = StyleFloat.op_Implicit(w); e.style.borderTopColor = StyleColor.op_Implicit(c); e.style.borderRightColor = StyleColor.op_Implicit(c); e.style.borderBottomColor = StyleColor.op_Implicit(c); e.style.borderLeftColor = StyleColor.op_Implicit(c); } public static void Pad(VisualElement e, float v, float h) { //IL_0007: 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_0029: 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) e.style.paddingTop = StyleLength.op_Implicit(v); e.style.paddingBottom = StyleLength.op_Implicit(v); e.style.paddingLeft = StyleLength.op_Implicit(h); e.style.paddingRight = StyleLength.op_Implicit(h); } public static void Fade(VisualElement e, params string[] props) { //IL_0012: 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_0053: Unknown result type (might be due to invalid IL or missing references) List<StylePropertyName> list = new List<StylePropertyName>(); foreach (string text in props) { list.Add(new StylePropertyName(text)); } e.style.transitionProperty = StyleList<StylePropertyName>.op_Implicit(list); e.style.transitionDuration = StyleList<TimeValue>.op_Implicit(new List<TimeValue> { new TimeValue(0.12f, (TimeUnit)0) }); } public static Label Label(string text, float size, Color color, bool title = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0015: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Label val = new Label(text); ((VisualElement)val).pickingMode = (PickingMode)1; ((VisualElement)val).style.fontSize = StyleLength.op_Implicit(size); ((VisualElement)val).style.color = StyleColor.op_Implicit(color); if (title) { Font((VisualElement)(object)val, title: true); } return val; } public static VisualElement Window(string title, string footer, Action onClose, out UiScroll body) { //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_0011: Expected O, but got Unknown //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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown //IL_01a0: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) VisualElement val = new VisualElement { name = "kydl-window" }; val.style.position = StyleEnum<Position>.op_Implicit((Position)1); val.style.width = StyleLength.op_Implicit(760f); val.style.maxWidth = StyleLength.op_Implicit(Length.Percent(60f)); val.style.height = StyleLength.op_Implicit(Length.Percent(80f)); val.style.right = StyleLength.op_Implicit(Length.Percent(5f)); val.style.left = StyleLength.op_Implicit((StyleKeyword)2); val.style.top = StyleLength.op_Implicit(Length.Percent(10f)); UiLog.Verbose("UiKit: window '" + title + "' opened 5% from the right edge, " + 10f.ToString("0") + "% from the top, " + 80f.ToString("0") + "% of the screen high"); val.style.backgroundColor = StyleColor.op_Implicit(Panel); Radius(val, 8f); Borders(val, 2f, Border); val.style.borderTopColor = StyleColor.op_Implicit(Gold); val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)0); val.pickingMode = (PickingMode)0; ((CallbackEventHandler)val).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e) { ((EventBase)e).StopPropagation(); }, (TrickleDown)0); VisualElement val2 = new VisualElement(); val2.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); val2.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)3); val2.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2); val2.style.flexShrink = StyleFloat.op_Implicit(0f); Pad(val2, 12f, 18f); val2.style.borderBottomWidth = StyleFloat.op_Implicit(1f); val2.style.borderBottomColor = StyleColor.op_Implicit(Border); Label val3 = Label(title, 34f, TabColor, title: true); ((VisualElement)val3).style.letterSpacing = StyleLength.op_Implicit(2f); val2.Add((VisualElement)(object)val3); val2.Add((VisualElement)(object)UiControls.Button("X", onClose)); val.Add(val2); Drag(val2, val); body = new UiScroll(title); Pad(body.Content, 14f, 18f); val.Add(body.Root); Label val4 = Label(footer ?? "", 18f, TextDim); ((VisualElement)val4).style.alignSelf = StyleEnum<Align>.op_Implicit((Align)2); ((VisualElement)val4).style.marginTop = StyleLength.op_Implicit(4f); ((VisualElement)val4).style.marginBottom = StyleLength.op_Implicit(8f); ((VisualElement)val4).style.flexShrink = StyleFloat.op_Implicit(0f); val.Add((VisualElement)(object)val4); return val; } private static void Drag(VisualElement handle, VisualElement target) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) bool dragging = false; Vector2 start = Vector2.zero; Vector2 origin = Vector2.zero; ((CallbackEventHandler)handle).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0055: 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_006b: Unknown result type (might be due to invalid IL or missing references) if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0 && !(((EventBase)e).target is Button)) { dragging = true; start = Vector2.op_Implicit(((PointerEventBase<PointerDownEvent>)(object)e).position); Rect layout = target.layout; float x = ((Rect)(ref layout)).x; layout = target.layout; origin = new Vector2(x, ((Rect)(ref layout)).y); target.style.right = StyleLength.op_Implicit((StyleKeyword)2); PointerCaptureHelper.CapturePointer((IEventHandler)(object)handle, ((PointerEventBase<PointerDownEvent>)(object)e).pointerId); } }, (TrickleDown)0); ((CallbackEventHandler)handle).RegisterCallback<PointerMoveEvent>((EventCallback<PointerMoveEvent>)delegate(PointerMoveEvent e) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_0020: 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) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (dragging) { Vector2 val = origin + Vector2.op_Implicit(((PointerEventBase<PointerMoveEvent>)(object)e).position) - start; VisualElement parent = target.parent; float num = ((parent != null) ? (parent.resolvedStyle.width - 80f) : 2000f); float num2 = ((parent != null) ? (parent.resolvedStyle.height - 40f) : 2000f); target.style.left = StyleLength.op_Implicit(Mathf.Clamp(val.x, 0f - target.resolvedStyle.width + 80f, num)); target.style.top = StyleLength.op_Implicit(Mathf.Clamp(val.y, 0f, num2)); } }, (TrickleDown)0); ((CallbackEventHandler)handle).RegisterCallback<PointerUpEvent>((EventCallback<PointerUpEvent>)delegate(PointerUpEvent e) { if (dragging) { dragging = false; PointerCaptureHelper.ReleasePointer((IEventHandler)(object)handle, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId); UiLog.Verbose("UiKit: window moved to " + target.resolvedStyle.left.ToString("0") + ", " + target.resolvedStyle.top.ToString("0")); } }, (TrickleDown)0); } } public static class UiLog { public static Action<string> VerboseSink = delegate(string s) { Debug.Log((object)("[Kydl UI] " + s)); }; public static Action<string> WarnSink = delegate(string s) { Debug.LogWarning((object)("[Kydl UI] " + s)); }; public static Action<string> ErrorSink = delegate(string s) { Debug.LogError((object)("[Kydl UI] " + s)); }; public static string Owner; public static void Verbose(string s) { VerboseSink?.Invoke(s); } public static void Warn(string s) { WarnSink?.Invoke(s); } public static void Error(string s) { ErrorSink?.Invoke(s); } public static T Within<T>(string owner, Func<T> work) { if (work == null) { return default(T); } string owner2 = Owner; Owner = owner; try { return work(); } finally { Owner = owner2; } } public static Action Wrap(Action action) { if (action == null) { return null; } string owner = Owner; return delegate { Within(owner, delegate { action(); return true; }); }; } public static Action<T> Wrap<T>(Action<T> action) { if (action == null) { return null; } string owner = Owner; return delegate(T value) { Within(owner, delegate { action(value); return true; }); }; } } public sealed class UiScroll { private const float BarWidth = 8f; private const float WheelStep = 60f; private const float MinThumb = 28f; public readonly VisualElement Root; public readonly VisualElement Content; private readonly VisualElement _viewport; private readonly VisualElement _bar; private readonly VisualElement _thumb; private readonly string _name; private float _offset; private float ContentH { get { //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 layout = Content.layout; return ((Rect)(ref layout)).height; } } private float ViewH { get { //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 layout = _viewport.layout; return ((Rect)(ref layout)).height; } } private float Max { get { float num = ContentH - ViewH; if (!(num > 0f) || float.IsNaN(num)) { return 0f; } return num; } } public UiScroll(string name) { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0099: Expected O, but got Unknown //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_00d9: 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: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_028c: 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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) _name = name; Root = new VisualElement { name = "kydl-scroll", userData = this }; Root.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); Root.style.flexGrow = StyleFloat.op_Implicit(1f); Root.style.flexShrink = StyleFloat.op_Implicit(1f); Root.style.minHeight = StyleLength.op_Implicit(40f); _viewport = new VisualElement(); _viewport.style.flexGrow = StyleFloat.op_Implicit(1f);