Decompiled source of ModdingAPI v2.0.3
MioModdingApi.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using MioGame; using MioGame.GlobalFunctions.core; using MioGame.GlobalFunctions.game; using MioModLoader; using NativeMod; using On.MioGame; using On.MioGame.GlobalFunctions.game; using On.MioGame.GlobalFunctions.platform.win32; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] [assembly: AssemblyCompany("MioModdingApi")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d6d880c061b252ec70cf5c953174ea19f1890f88")] [assembly: AssemblyProduct("MioModdingApi")] [assembly: AssemblyTitle("MioModdingApi")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace MioModdingApi; internal static class ApiOptions { [CompilerGenerated] private static class <>O { public static orig_update <0>__Metagame_update_Suffix; } private static ToggleOption? debugMode; private static bool startupApplied; internal static void Register(MioModdingApi api) { debugMode = ModMenu.RegisterMod((Mod)(object)api, "Modding API", "Core API for modifying MIO.").RegisterToggle("debug_mode", "Start in debug mode", defaultValue: false, "Turns on the game's debug mode automatically, without the d-pad input. Turning it off takes effect the next time the game starts."); debugMode.Changed += delegate(bool enabled) { if (enabled) { EnableDebug(); } }; } internal unsafe static void ApplyHooks() { //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_001b: Expected O, but got Unknown object obj = <>O.<0>__Metagame_update_Suffix; if (obj == null) { orig_update val = Metagame_update_Suffix; <>O.<0>__Metagame_update_Suffix = val; obj = (object)val; } update.Suffix += (orig_update)obj; } private unsafe static void Metagame_update_Suffix(Metagame* self) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (startupApplied || (int)((Metagame)self).state < 3) { return; } startupApplied = true; try { ToggleOption? toggleOption = debugMode; if (toggleOption != null && toggleOption.Value) { EnableDebug(); } } catch (Exception value) { ModMenu.Log($"enabling debug mode failed: {value}"); } } private static void EnableDebug() { ref Metagame metagame = ref Globals.metagame; if (!metagame.debug_enabled) { if (!metagame.debug_allowed) { metagame.debug_allowed = true; ModMenu.Log("debug mode wasn't allowed on this install (no debug key); allowing it"); } metagame.enable_debug(); ModMenu.Log($"debug mode turned on (debug_enabled={metagame.debug_enabled})"); } } } public static class GinPatching { public class GinPatch { public unsafe Gin_read* targetRead; public uint targetIndex; public uint size; public unsafe GinPatch(Gin_read* targetRead, uint targetIndex, uint size) { this.targetRead = targetRead; this.targetIndex = targetIndex; this.size = size; } } [CompilerGenerated] private static class <>O { public static hook_read_section_data_1 <0>__Read_section_data_1_Hook; } public static Dictionary<string, Dictionary<int, GinPatch>> patches = new Dictionary<string, Dictionary<int, GinPatch>>(); public static bool PatchedGins; public static event Action? PatchGins; public unsafe static void ApplyHooks() { //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_001b: Expected O, but got Unknown object obj = <>O.<0>__Read_section_data_1_Hook; if (obj == null) { hook_read_section_data_1 val = Read_section_data_1_Hook; <>O.<0>__Read_section_data_1_Hook = val; obj = (object)val; } read_section_data_1.Hook += (hook_read_section_data_1)obj; } public unsafe static void AddGinPatch(string file, string patch) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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_004b: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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) TempString tempString = new TempString(patch); try { TempString tempString2 = new TempString(file); try { Gin_read val = Gin_read.from_file(&tempString.MioString); Gin_read val2 = Gin_read.from_file(&tempString2.MioString); ((Gin_read)(ref val)).read_header(true); ((Gin_read)(ref val2)).read_header(true); Gin_read* ptr = (Gin_read*)NativeMemory.Alloc((nuint)Unsafe.SizeOf<Gin_read>()); Unsafe.Write(ptr, val); string key = StringAllocator.FromMioString(val2.path); Dictionary<int, GinPatch> valueOrDefault = patches.GetValueOrDefault(key, new Dictionary<int, GinPatch>()); for (uint num = 0u; num < val.header.section_count; num++) { Gin_section_header data = (Gin_section_header)(*val.sections.data.data); uint num2 = 0u; for (int i = 0; i < 64 && global::<PrivateImplementationDetails>.InlineArrayAsSpan<InlineArray_unsigned_char_64, byte>(ref data.name, 64)[i] != 0; i++) { num2++; } String val3 = new String { data = new Ptr { data = (byte*)(&data.name) }, size = num2 }; int key2 = ((Gin_read)(ref val2)).find_section(&val3); GinPatch value = new GinPatch(ptr, num, data.size); valueOrDefault.TryAdd(key2, value); } if (!patches.TryAdd(key, valueOrDefault)) { patches[key] = valueOrDefault; } } finally { ((IDisposable)tempString2/*cast due to .constrained prefix*/).Dispose(); } } finally { ((IDisposable)tempString/*cast due to .constrained prefix*/).Dispose(); } } public static void PatchAllGins() { GinPatching.PatchGins?.Invoke(); } private unsafe static void Read_section_data_1_Hook(orig_read_section_data_1 orig, Gin_read* self, uint section_index, byte* mem, uint size) { //IL_0013: 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_004e: Invalid comparison between Unknown and I4 //IL_0080: 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_0088: Invalid comparison between Unknown and I4 //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (!PatchedGins) { PatchAllGins(); PatchedGins = true; } string key = StringAllocator.FromMioString(((Gin_read)self).path); if (!patches.TryGetValue(key, out Dictionary<int, GinPatch> value) || !value.ContainsKey((int)section_index)) { orig.Invoke(self, section_index, mem, size); return; } if ((int)((Gin_read_batcher)(&((Gin_read)self).batcher)).status == 2) { ref Gin_read_batcher reference = ref ((Gin_read)self).batcher; uint next_subsection = reference.next_subsection; uint next_subsection2; if ((((Ordered_gin_read)(reference.ordered_reads.data.data + reference.next_idx * Unsafe.SizeOf<Ordered_gin_read>())).flags & 1) <= 0 || next_subsection > 1) { reference.next_idx++; next_subsection2 = 0u; } else { next_subsection2 = next_subsection + 1; } reference.next_subsection = next_subsection2; Unsafe.Write(&((Gin_read)self).batcher, reference); } GinPatch ginPatch = value[(int)section_index]; orig.Invoke(ginPatch.targetRead, ginPatch.targetIndex, mem, ginPatch.size); } } public static class Localization { [CompilerGenerated] private static class <>O { public static hook_try_translate <0>__Try_translate_Hook; public static hook_translate_1 <1>__Translate_lang_Hook; public static hook_translate_2 <2>__Translate_Hook; } public static readonly Dictionary<string, Dictionary<string, nint>> Strings = new Dictionary<string, Dictionary<string, nint>>(); private static readonly string[] LanguageNames = Enum.GetNames(typeof(Language)); private static readonly string English = Enum.GetName(typeof(Language), (object)(Language)1); private const string MissingId = "\u0001MIO_MODDING_API_MISSING_LOCA_ID"; private const string Blank = " "; private unsafe static String* AsFallback(String* value) { if (((String)value).size != 0) { return value; } return StringAllocator.GetMioString(" "); } public static void LoadLanguageFile(string path) { foreach (KeyValuePair<string, JsonNode> item in JsonNode.Parse(File.ReadAllText(path)) as JsonObject) { foreach (KeyValuePair<string, JsonNode> item2 in item.Value as JsonObject) { AddString(item.Key, item2.Key, (string?)item2.Value); } } } public static void AddString(string id, string text, Language language = (Language)1u) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) AddString(Enum.GetName<Language>(language) ?? English, id, text); } private unsafe static void AddString(string languageName, string id, string text) { bool exists; ref Dictionary<string, nint> valueRefOrAddDefault = ref CollectionsMarshal.GetValueRefOrAddDefault(Strings, languageName, out exists); if (valueRefOrAddDefault == null) { valueRefOrAddDefault = new Dictionary<string, nint>(); } valueRefOrAddDefault[id] = (nint)StringAllocator.GetMioString(text); } public unsafe static void ApplyHooks() { //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_001b: Expected O, but got Unknown //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_003b: Expected O, but got Unknown //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) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__Try_translate_Hook; if (obj == null) { hook_try_translate val = Try_translate_Hook; <>O.<0>__Try_translate_Hook = val; obj = (object)val; } try_translate.Hook += (hook_try_translate)obj; object obj2 = <>O.<1>__Translate_lang_Hook; if (obj2 == null) { hook_translate_1 val2 = Translate_lang_Hook; <>O.<1>__Translate_lang_Hook = val2; obj2 = (object)val2; } translate_1.Hook += (hook_translate_1)obj2; object obj3 = <>O.<2>__Translate_Hook; if (obj3 == null) { hook_translate_2 val3 = Translate_Hook; <>O.<2>__Translate_Hook = val3; obj3 = (object)val3; } translate_2.Hook += (hook_translate_2)obj3; } private static string LanguageName(uint language) { if (language >= (uint)LanguageNames.Length) { return English; } return LanguageNames[language]; } private unsafe static String* FindOverride(String* id, string languageName) { if (Strings.Count == 0 || id == null) { return null; } string text = StringAllocator.FromMioString(id); if (text == null) { return null; } if (Strings.TryGetValue(languageName, out Dictionary<string, nint> value) && value.TryGetValue(text, out var value2)) { return (String*)value2; } if (Strings.TryGetValue(English, out value) && value.TryGetValue(text, out value2)) { return (String*)value2; } return null; } private unsafe static String* Try_translate_Hook(orig_try_translate orig, Loca* self, String* id) { String* ptr = FindOverride(id, LanguageName(((Loca)self).current_txt_lang)); if (ptr == null) { return orig.Invoke(self, id); } return ptr; } private unsafe static void Translate_lang_Hook(orig_translate_1 orig, Loca* self, String* retBuffer, String* id, Language lang, String* _default) { //IL_0001: 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_0029: Unknown result type (might be due to invalid IL or missing references) String* ptr = FindOverride(id, Enum.GetName<Language>(lang) ?? English); if (ptr != null) { orig.Invoke(self, retBuffer, StringAllocator.GetMioString("\u0001MIO_MODDING_API_MISSING_LOCA_ID"), lang, AsFallback(ptr)); } else { orig.Invoke(self, retBuffer, id, lang, _default); } } private unsafe static void Translate_Hook(orig_translate_2 orig, Loca* self, String* retBuffer, String* id, String* _default) { String* ptr = FindOverride(id, LanguageName(((Loca)self).current_txt_lang)); if (ptr != null) { orig.Invoke(self, retBuffer, StringAllocator.GetMioString("\u0001MIO_MODDING_API_MISSING_LOCA_ID"), AsFallback(ptr)); } else { orig.Invoke(self, retBuffer, id, _default); } } } public class MioModdingApi : Mod { [CompilerGenerated] private static class <>O { public static prefix_main <0>__Main_Prefix; } private const uint PAGE_EXECUTE_READWRITE = 64u; internal static MioModdingApi? Instance { get; private set; } public unsafe override void Initialize() { //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) //IL_005b: Expected O, but got Unknown Instance = this; NativeModule.MemoryAddress = (ulong)ModLoader.MioMemoryAddress; ((Mod)this).LogMessage("Loaded Mio Modding Api"); PatchChecksum(); GinPatching.ApplyHooks(); Trinkets.ApplyHooks(); Localization.ApplyHooks(); ModMenu.ApplyHooks(); ApiOptions.ApplyHooks(); ApiOptions.Register(this); object obj = <>O.<0>__Main_Prefix; if (obj == null) { prefix_main val = Main_Prefix; <>O.<0>__Main_Prefix = val; obj = (object)val; } main.Prefix += (prefix_main)obj; } private unsafe static void Main_Prefix(int argc, sbyte** argv, sbyte** envp) { ModLoader.logOverride = delegate(string message) { TempString tempString = new TempString(message + "\n"); try { win32_io.write_console(&tempString.MioString, false, true); } finally { ((IDisposable)tempString/*cast due to .constrained prefix*/).Dispose(); } }; } [DllImport("kernel32.dll", SetLastError = true)] private static extern bool VirtualProtect(nint lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect); private unsafe void PatchChecksum() { nint lpAddress = IntPtr.Add(new IntPtr(ModLoader.MioMemoryAddress), 202360); ReadOnlySpan<byte> readOnlySpan = new byte[5] { 57, 192, 144, 144, 144 }; uint length = (uint)readOnlySpan.Length; if (VirtualProtect(lpAddress, length, 64u, out var lpflOldProtect)) { byte* ptr = (byte*)((IntPtr)lpAddress).ToPointer(); for (int i = 0; i < readOnlySpan.Length; i++) { ptr[i] = readOnlySpan[i]; } VirtualProtect(lpAddress, length, lpflOldProtect, out var _); } else { string lastPInvokeErrorMessage = Marshal.GetLastPInvokeErrorMessage(); ((Mod)this).LogMessage("Failed to change memory protection for gin patching: - " + lastPInvokeErrorMessage); } } } public static class StringExtensions { public unsafe static bool Equals(this String str, String* other) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return Util.MioStringToString(str) == Util.MioStringToString(*other); } public unsafe static bool Equals(this string? str, String* other) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (str == null) { if (other != null) { return ((Ptr)(&((String)other).data)).data == null; } return true; } return str == Util.MioStringToString(*other); } } public static class ModMenu { private static readonly List<ModMenuPage> pages = new List<ModMenuPage>(); internal const string KeyPrefix = "MIO_MODDING_API.MOD_MENU."; public static IReadOnlyList<ModMenuPage> Pages => pages; public static ModMenuPage RegisterMod(Mod mod, string? displayName = null, string? description = null) { ArgumentNullException.ThrowIfNull(mod, "mod"); return RegisterMod(mod.Id, displayName ?? mod.Name, description); } public static ModMenuPage RegisterMod(string modId, string displayName, string? description = null) { ArgumentException.ThrowIfNullOrWhiteSpace(modId, "modId"); ArgumentException.ThrowIfNullOrWhiteSpace(displayName, "displayName"); if (TryGetPage(modId, out ModMenuPage page)) { return page; } ModMenuPage modMenuPage = new ModMenuPage(modId, displayName, description); pages.Add(modMenuPage); return modMenuPage; } public static bool TryGetPage(string modId, [NotNullWhen(true)] out ModMenuPage? page) { page = pages.FirstOrDefault((ModMenuPage p) => p.ModId == modId); return page != null; } public static T? GetOption<T>(string modId, string optionId) where T : ModMenuOption { if (!TryGetPage(modId, out ModMenuPage page)) { return null; } return page.GetOption<T>(optionId); } public static void ApplyHooks() { ModMenuUi.ApplyHooks(); } internal static ModMenuPage[] VisiblePages() { return pages.Where((ModMenuPage p) => p.Options.Count > 0).ToArray(); } internal static void PollValues() { foreach (ModMenuPage page in pages) { foreach (ModMenuOption option in page.Options) { option.PollNative(); } } } internal static void Log(string message) { MioModdingApi? instance = MioModdingApi.Instance; if (instance != null) { ((Mod)instance).LogMessage("[ModMenu] " + message); } } } public sealed class ModMenuPage { private readonly List<ModMenuOption> options = new List<ModMenuOption>(); public string ModId { get; } public string DisplayName { get; } public string? Description { get; } public IReadOnlyList<ModMenuOption> Options => options; internal string TitleKey { get; } internal string DescriptionKey { get; } internal ModMenuPage(string modId, string displayName, string? description) { ModId = modId; DisplayName = displayName; Description = description; TitleKey = "MIO_MODDING_API.MOD_MENU." + modId + ".TITLE"; Localization.AddString(TitleKey, displayName, (Language)1); DescriptionKey = ""; if (!string.IsNullOrEmpty(description)) { DescriptionKey = "MIO_MODDING_API.MOD_MENU." + modId + ".DESCRIPTION"; Localization.AddString(DescriptionKey, description, (Language)1); } } public ToggleOption RegisterToggle(string id, string title, bool defaultValue = false, string? description = null) { return Add(new ToggleOption(this, id, title, description, defaultValue)); } public ChoiceOption RegisterChoice(string id, string title, IReadOnlyList<string> choices, int defaultIndex = 0, string? description = null) { return Add(new ChoiceOption(this, id, title, description, choices, defaultIndex)); } public NumberOption RegisterNumber(string id, string title, int min, int max, int step = 1, int? defaultValue = null, string? description = null, string format = "{0}") { return Add(new NumberOption(this, id, title, description, min, max, step, defaultValue ?? min, format)); } public ButtonOption RegisterButton(string id, string title, Action? onPressed = null, string? description = null) { return Add(new ButtonOption(this, id, title, description, onPressed)); } public KeybindOption RegisterKeybind(string id, string title, Key defaultKey = (Key)0, Gamepad_button defaultButton = (Gamepad_button)0, Mouse_button defaultMouseButton = (Mouse_button)0, string? description = null, bool keyboard = true, bool controller = true) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return Add(new KeybindOption(this, id, title, description, defaultKey, defaultMouseButton, defaultButton, keyboard, controller)); } public void ResetToDefaults() { foreach (ModMenuOption option in options) { option.ResetToDefault(); } } public T? GetOption<T>(string id) where T : ModMenuOption { return options.FirstOrDefault((ModMenuOption o) => o.Id == id) as T; } private T Add<T>(T option) where T : ModMenuOption { if (options.Any((ModMenuOption o) => o.Id == option.Id)) { throw new ArgumentException($"Mod '{ModId}' already has an option with id '{option.Id}'.", "id"); } options.Add(option); if (option.HasValue) { ModMenuConfig.ApplySaved(option); } return option; } } internal static class ModMenuConfig { private const string FileName = "mod-menu.json"; private static JsonObject? root; private static bool dirty; private static string? FilePath { get { MioModdingApi instance = MioModdingApi.Instance; if (instance != null) { return Path.Combine(((Mod)instance).GetModConfigPath(), "mod-menu.json"); } return null; } } private static JsonObject Root { get { if (root != null) { return root; } root = Load() ?? new JsonObject(); return root; } } private static JsonObject? Load() { string filePath = FilePath; if (filePath == null || !File.Exists(filePath)) { return null; } try { return JsonNode.Parse(File.ReadAllText(filePath)) as JsonObject; } catch (Exception ex) { ModMenu.Log("could not read " + filePath + ", using defaults: " + ex.Message); try { File.Copy(filePath, filePath + ".broken", overwrite: true); } catch { } return null; } } internal static void ApplySaved(ModMenuOption option) { if (Root[option.Page.ModId] is JsonObject jsonObject) { JsonNode jsonNode = jsonObject[option.Id]; if (jsonNode != null) { option.FromJson(jsonNode); } } } internal static void Changed(ModMenuOption option, bool saveNow) { if (option.HasValue) { JsonObject jsonObject = Root[option.Page.ModId] as JsonObject; if (jsonObject == null) { jsonObject = new JsonObject(); Root[option.Page.ModId] = jsonObject; } jsonObject[option.Id] = option.ToJson(); dirty = true; if (saveNow) { SaveIfDirty(); } } } internal static void SaveIfDirty() { if (!dirty) { return; } dirty = false; string filePath = FilePath; if (filePath == null) { return; } try { Directory.CreateDirectory(Path.GetDirectoryName(filePath)); string text = filePath + ".tmp"; File.WriteAllText(text, Root.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); File.Move(text, filePath, overwrite: true); } catch (Exception ex) { ModMenu.Log("could not save " + filePath + ": " + ex.Message); } } } public sealed class KeybindOption : ModMenuOption { internal unsafe readonly Binding* Binding; private Binding known; public const Key ClearKey = (Key)339; private const string ClearHint = "While rebinding, press Delete to clear."; private const string ControllerClearHint = "While rebinding, press Delete on the keyboard to clear."; public Key DefaultKey { get; } public Mouse_button DefaultMouseButton { get; } public Gamepad_button DefaultButton { get; } public bool HasKeyboard { get; } public bool HasController { get; } internal string KeyboardDescription { get; } internal string ControllerDescription { get; } internal string KeyboardDescriptionKey { get; } internal string ControllerDescriptionKey { get; } public unsafe Key Key { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Binding)Binding).key_primary; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Set(value, (Mouse_button)(((int)value == 0) ? ((int)((Binding)Binding).mouse_btn) : 0), ((Binding)Binding).gamepad_button); } } public unsafe Mouse_button MouseButton { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Binding)Binding).mouse_btn; } set { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Set((Key)(((int)value == 0) ? ((int)((Binding)Binding).key_primary) : 0), value, ((Binding)Binding).gamepad_button); } } public unsafe Gamepad_button Button { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Binding)Binding).gamepad_button; } set { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Set(((Binding)Binding).key_primary, ((Binding)Binding).mouse_btn, value); } } public bool IsDown => Any((Input_btn b) => b.down); public bool WasPressed => Any((Input_btn b) => b.pressed); public bool WasReleased => Any((Input_btn b) => b.released); internal override ModMenuRowKind RowKind => ModMenuRowKind.Keybind; internal override string[] ValueKeys => Array.Empty<string>(); internal override int DefaultIndex => 0; public event Action<KeybindOption>? Changed; internal unsafe KeybindOption(ModMenuPage page, string id, string title, string? description, Key defaultKey, Mouse_button defaultMouse, Gamepad_button defaultButton, bool keyboard, bool controller) : base(page, id, title, description) { //IL_0023: 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_0053: 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_0062: 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_0071: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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) if (!keyboard && !controller) { throw new ArgumentException("A keybind needs a keyboard row, a controller row, or both.", "keyboard"); } if ((int)defaultKey != 0 && (int)defaultMouse != 0) { throw new ArgumentException("A keybind's default is a key or a mouse button, not both.", "defaultMouse"); } HasKeyboard = keyboard; HasController = controller; DefaultKey = (Key)(keyboard ? ((int)defaultKey) : 0); DefaultMouseButton = (Mouse_button)(keyboard ? ((int)defaultMouse) : 0); DefaultButton = (Gamepad_button)(controller ? ((int)defaultButton) : 0); KeyboardDescription = RowDescription("(Keyboard)", description, "While rebinding, press Delete to clear."); KeyboardDescriptionKey = base.TitleKey + ".KEYBOARD_DESCRIPTION"; Localization.AddString(KeyboardDescriptionKey, KeyboardDescription, (Language)1); ControllerDescription = RowDescription("(Controller)", description, "While rebinding, press Delete on the keyboard to clear."); ControllerDescriptionKey = base.TitleKey + ".CONTROLLER_DESCRIPTION"; Localization.AddString(ControllerDescriptionKey, ControllerDescription, (Language)1); Binding = (Binding*)NativeMemory.AllocZeroed((nuint)Unsafe.SizeOf<Binding>()); Write(DefaultKey, DefaultMouseButton, DefaultButton); known = *Binding; } private static string RowDescription(string device, string? description, string hint) { if (!string.IsNullOrEmpty(description)) { return $"{device} {description}\n{hint}"; } return device + " " + hint; } private unsafe bool Any(Func<Input_btn, bool> test) { //IL_0011: 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_0017: 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) //IL_0066: 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: Invalid comparison between Unknown and I4 //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected I4, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Invalid comparison between Unknown and I4 //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected I4, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected I4, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) ref Game game = ref Globals.input.game; Key key_primary = ((Binding)Binding).key_primary; if ((int)key_primary != 0 && (int)key_primary < 512 && test(global::<PrivateImplementationDetails>.InlineArrayAsSpan<InlineArray_Input_btn_512, Input_btn>(ref game.kb.keys.keys.data, 512)[(int)key_primary])) { return true; } Mouse_button mouse_btn = ((Binding)Binding).mouse_btn; if ((int)mouse_btn != 0 && (int)mouse_btn < 6 && test(global::<PrivateImplementationDetails>.InlineArrayAsSpan<InlineArray_Input_btn_6, Input_btn>(ref game.mouse.buttons.data, 6)[(int)mouse_btn])) { return true; } Gamepad_button gamepad_button = ((Binding)Binding).gamepad_button; if ((int)gamepad_button != 0 && (int)gamepad_button < 22 && test(global::<PrivateImplementationDetails>.InlineArrayAsSpan<InlineArray_Input_btn_22, Input_btn>(ref game.pad.buttons.data, 22)[(int)gamepad_button])) { return true; } return false; } private unsafe void Write(Key key, Mouse_button mouse, Gamepad_button button) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_003f: 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) Unsafe.Write(&((Binding)Binding).key_primary, (Key)(HasKeyboard ? ((int)key) : 0)); Unsafe.Write(&((Binding)Binding).mouse_btn, (Mouse_button)(HasKeyboard ? ((int)mouse) : 0)); Unsafe.Write(&((Binding)Binding).gamepad_button, (Gamepad_button)(HasController ? ((int)button) : 0)); Unsafe.Write(&((Binding)Binding).key_secondary, (Key)0); } private unsafe void Set(Key key, Mouse_button mouse, Gamepad_button button, bool save = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) Write(key, mouse, button); if (!SameAs(known)) { known = *Binding; NotifyChanged(); if (save) { ModMenuConfig.Changed(this, saveNow: true); } } } private unsafe bool SameAs(Binding other) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_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_0032: Unknown result type (might be due to invalid IL or missing references) if (((Binding)Binding).key_primary == other.key_primary && ((Binding)Binding).mouse_btn == other.mouse_btn) { return ((Binding)Binding).gamepad_button == other.gamepad_button; } return false; } internal unsafe override void PollNative() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!SameAs(known)) { known = *Binding; NotifyChanged(); ModMenuConfig.Changed(this, saveNow: false); } } public override void ResetToDefault() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Set(DefaultKey, DefaultMouseButton, DefaultButton); } public void Clear() { Set((Key)0, (Mouse_button)0, (Gamepad_button)0); } internal unsafe void ApplyKeyboardMouse(Key key, Mouse_button mouse) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_001c: 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_0033: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if ((int)key == 339) { Write((Key)0, (Mouse_button)0, ((Binding)Binding).gamepad_button); } else if ((int)key != 0) { Write(key, (Mouse_button)0, ((Binding)Binding).gamepad_button); } else if ((int)mouse != 0) { Write((Key)0, mouse, ((Binding)Binding).gamepad_button); } } internal unsafe void ApplyButton(Gamepad_button button) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if ((int)button != 0) { Unsafe.Write(&((Binding)Binding).gamepad_button, button); } } internal unsafe void ClearButton() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Unsafe.Write(&((Binding)Binding).gamepad_button, (Gamepad_button)0); } private protected override void RaiseChanged() { this.Changed?.Invoke(this); } internal unsafe override JsonNode ToJson() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) return new JsonObject { ["key"] = Enum.GetName<Key>(((Binding)Binding).key_primary) ?? "Key_dummy", ["mouse"] = Enum.GetName<Mouse_button>(((Binding)Binding).mouse_btn) ?? "Mouse_none", ["button"] = Enum.GetName<Gamepad_button>(((Binding)Binding).gamepad_button) ?? "Btn_none" }; } internal unsafe override void FromJson(JsonNode node) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_005e: 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: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (node is JsonObject jsonObject) { Key val = Parse<Key>(jsonObject["key"], ((Binding)Binding).key_primary); Mouse_button mouse = Parse<Mouse_button>(jsonObject["mouse"], ((Binding)Binding).mouse_btn); Gamepad_button button = Parse<Gamepad_button>(jsonObject["button"], ((Binding)Binding).gamepad_button); if ((int)val != 0) { mouse = (Mouse_button)0; } Set(val, mouse, button, save: false); } } private static T Parse<T>(JsonNode? node, T fallback) where T : struct, Enum { if (!(node is JsonValue jsonValue) || !jsonValue.TryGetValue<string>(out string value) || !Enum.TryParse<T>(value, out var result)) { return fallback; } return result; } } internal enum ModMenuRowKind { Choice, Button, Keybind } public abstract class ModMenuOption { internal unsafe readonly int* Cell; private int knownIndex; internal bool RowNeedsSync; public ModMenuPage Page { get; } public string Id { get; } public string Title { get; } public string? Description { get; } internal string TitleKey { get; } internal string DescriptionKey { get; } internal abstract string[] ValueKeys { get; } internal virtual bool IsToggle => false; internal virtual bool HasValue => true; internal virtual ModMenuRowKind RowKind => ModMenuRowKind.Choice; internal abstract int DefaultIndex { get; } internal int Index => ReadIndex(); private protected unsafe ModMenuOption(ModMenuPage page, string id, string title, string? description) { ArgumentException.ThrowIfNullOrWhiteSpace(id, "id"); ArgumentException.ThrowIfNullOrWhiteSpace(title, "title"); Page = page; Id = id; Title = title; Description = description; Cell = (int*)NativeMemory.AllocZeroed(4u); string text = "MIO_MODDING_API.MOD_MENU." + page.ModId + "." + id; TitleKey = text + ".TITLE"; Localization.AddString(TitleKey, title, (Language)1); DescriptionKey = ""; if (!string.IsNullOrEmpty(description)) { DescriptionKey = text + ".DESCRIPTION"; Localization.AddString(DescriptionKey, description, (Language)1); } } private protected void InitIndex() { WriteIndex(DefaultIndex); knownIndex = DefaultIndex; } private unsafe int ReadIndex() { if (!HasValue) { return 0; } return Math.Clamp(IsToggle ? (*(byte*)Cell) : (*Cell), 0, ValueKeys.Length - 1); } private unsafe void WriteIndex(int index) { if (IsToggle) { *Cell = 0; *(bool*)Cell = index != 0; } else { *Cell = index; } } private protected void SetIndex(int index, bool save) { index = Math.Clamp(index, 0, ValueKeys.Length - 1); if (index != knownIndex || ReadIndex() != index) { WriteIndex(index); knownIndex = index; RowNeedsSync = true; NotifyChanged(); if (save) { ModMenuConfig.Changed(this, saveNow: true); } } } internal virtual void PollNative() { if (HasValue) { int num = ReadIndex(); if (num != knownIndex) { knownIndex = num; NotifyChanged(); ModMenuConfig.Changed(this, saveNow: false); } } } private protected void NotifyChanged() { try { RaiseChanged(); } catch (Exception value) { ModMenu.Log($"a Changed handler for {Page.ModId}/{Id} threw: {value}"); } } public virtual void ResetToDefault() { if (HasValue) { SetIndex(DefaultIndex, save: true); } } private protected abstract void RaiseChanged(); internal abstract JsonNode ToJson(); internal abstract void FromJson(JsonNode node); private protected string ValueKey(int index) { return "MIO_MODDING_API.MOD_MENU." + Page.ModId + "." + Id + ".VALUE." + index; } } public sealed class ToggleOption : ModMenuOption { private static readonly string[] YesNoKeys = new string[2] { "UI_MENU_SETTINGS_BOOL_NO", "UI_MENU_SETTINGS_BOOL_YES" }; public bool DefaultValue { get; } public bool Value { get { return base.Index != 0; } set { SetIndex(value ? 1 : 0, save: true); } } internal override string[] ValueKeys => YesNoKeys; internal override bool IsToggle => true; internal override int DefaultIndex => DefaultValue ? 1 : 0; public event Action<bool>? Changed; internal ToggleOption(ModMenuPage page, string id, string title, string? description, bool defaultValue) : base(page, id, title, description) { DefaultValue = defaultValue; InitIndex(); } private protected override void RaiseChanged() { this.Changed?.Invoke(Value); } internal override JsonNode ToJson() { return JsonValue.Create(Value); } internal override void FromJson(JsonNode node) { if (node is JsonValue jsonValue && jsonValue.TryGetValue<bool>(out var value)) { SetIndex(value ? 1 : 0, save: false); } } } public sealed class ChoiceOption : ModMenuOption { private readonly string[] choices; private readonly string[] valueKeys; private readonly int defaultIndex; public IReadOnlyList<string> Choices => choices; public int SelectedIndex { get { return base.Index; } set { SetIndex(value, save: true); } } public string Value { get { return choices[base.Index]; } set { int num = Array.IndexOf(choices, value); if (num < 0) { throw new ArgumentException("'" + value + "' is not one of the choices.", "value"); } SetIndex(num, save: true); } } internal override string[] ValueKeys => valueKeys; internal override int DefaultIndex => defaultIndex; public event Action<int>? Changed; internal ChoiceOption(ModMenuPage page, string id, string title, string? description, IReadOnlyList<string> choices, int defaultIndex) : base(page, id, title, description) { ArgumentNullException.ThrowIfNull(choices, "choices"); if (choices.Count == 0) { throw new ArgumentException("A choice option needs at least one choice.", "choices"); } if (defaultIndex < 0 || defaultIndex >= choices.Count) { throw new ArgumentOutOfRangeException("defaultIndex"); } this.choices = choices.ToArray(); this.defaultIndex = defaultIndex; valueKeys = new string[this.choices.Length]; for (int i = 0; i < this.choices.Length; i++) { valueKeys[i] = ValueKey(i); Localization.AddString(valueKeys[i], this.choices[i], (Language)1); } InitIndex(); } private protected override void RaiseChanged() { this.Changed?.Invoke(base.Index); } internal override JsonNode ToJson() { return JsonValue.Create(Value); } internal override void FromJson(JsonNode node) { if (node is JsonValue jsonValue && jsonValue.TryGetValue<string>(out string value)) { int num = Array.IndexOf(choices, value); if (num >= 0) { SetIndex(num, save: false); } } } } public sealed class NumberOption : ModMenuOption { private const int MaxValueCount = 1000; private readonly string[] valueKeys; private readonly int defaultIndex; public int Min { get; } public int Max { get; } public int Step { get; } public int DefaultValue { get; } public int Value { get { return FromIndex(base.Index); } set { SetIndex(ToIndex(value), save: true); } } internal override string[] ValueKeys => valueKeys; internal override int DefaultIndex => defaultIndex; public event Action<int>? Changed; internal NumberOption(ModMenuPage page, string id, string title, string? description, int min, int max, int step, int defaultValue, string format) : base(page, id, title, description) { if (step <= 0) { throw new ArgumentOutOfRangeException("step", "Step must be positive."); } if (max < min) { throw new ArgumentException("Max must be at least min.", "max"); } long num = ((long)max - (long)min) / step + 1; if (num > 1000) { throw new ArgumentException($"Too many values ({num}); Settings can show at most {1000}. Use a larger step.", "step"); } Min = min; Max = min + (int)(num - 1) * step; Step = step; defaultIndex = ToIndex(defaultValue); DefaultValue = FromIndex(defaultIndex); valueKeys = new string[num]; for (int i = 0; i < num; i++) { valueKeys[i] = ValueKey(i); Localization.AddString(valueKeys[i], string.Format(CultureInfo.InvariantCulture, format, FromIndex(i)), (Language)1); } InitIndex(); } private int FromIndex(int index) { return Min + index * Step; } private int ToIndex(int value) { return (int)Math.Clamp((long)Math.Round(((double)value - (double)Min) / (double)Step), 0L, ((long)Max - (long)Min) / Step); } private protected override void RaiseChanged() { this.Changed?.Invoke(Value); } internal override JsonNode ToJson() { return JsonValue.Create(Value); } internal override void FromJson(JsonNode node) { if (node is JsonValue jsonValue && jsonValue.TryGetValue<int>(out var value)) { SetIndex(ToIndex(value), save: false); } } } public sealed class ButtonOption : ModMenuOption { internal override bool HasValue => false; internal override ModMenuRowKind RowKind => ModMenuRowKind.Button; internal override string[] ValueKeys => Array.Empty<string>(); internal override int DefaultIndex => 0; public event Action? Pressed; internal ButtonOption(ModMenuPage page, string id, string title, string? description, Action? onPressed) : base(page, id, title, description) { if (onPressed != null) { Pressed += onPressed; } } internal void Press() { try { this.Pressed?.Invoke(); } catch (Exception value) { ModMenu.Log($"button {base.Page.ModId}/{base.Id} threw: {value}"); } } private protected override void RaiseChanged() { } internal override JsonNode ToJson() { return JsonValue.Create(0); } internal override void FromJson(JsonNode node) { } } internal static class ModMenuUi { private enum Screen { Closed, ModList, ModPage } private readonly record struct View(uint Start, uint Count); private sealed class Menu { public ModMenuPage[] Pages = Array.Empty<ModMenuPage>(); public TNode_Ui_interactive_node ModsRow; public TNode_Ui_interactive_node Tab; public bool Previewing; public float PreviewFade; public bool Built; public uint VanillaCount; public uint TotalCount; public View ModList; public View[] ModPages = Array.Empty<View>(); public ModMenuOption[][] PageRows = Array.Empty<ModMenuOption[]>(); public string?[][] PageRowDescriptions = Array.Empty<string[]>(); public Screen Screen; public int OpenPage = -1; public int LastPageOpened = int.MinValue; public int HoveredBeforeUpdate = -1; public Array_Ui_settings__Widget VanillaHeader; public readonly List<nint> HiddenVanilla = new List<nint>(); public View? Lingering; public float? VanillaBottomPad; public bool ResetPending; } private readonly struct BindingGuard : IDisposable { private readonly List<(nint binding, Binding value)> saved; public unsafe BindingGuard(Ui_settings* self, Widget* rebound) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) saved = new List<(nint, Binding)>(); Save(((Page)((byte*)Pages(self) + (nint)3 * (nint)Unsafe.SizeOf<Page>())).widget_list, ((Widget)rebound).p_key_binding); Save(((Page)Host(self)).widget_list, ((Widget)rebound).p_key_binding); } private unsafe void Save(Array_Ui_settings__Widget list, Binding* skip) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Widget* ptr = Rows(list); for (uint num = 0u; num < list.count; num++) { Binding* p_key_binding = ((Widget)((byte*)ptr + num * Unsafe.SizeOf<Widget>())).p_key_binding; if (p_key_binding != null && p_key_binding != skip) { saved.Add(((nint)p_key_binding, *p_key_binding)); } } } public unsafe void Dispose() { //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_0023: 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) foreach (var item3 in saved) { nint item = item3.binding; Binding item2 = item3.value; Unsafe.Write((void*)item, item2); } } } [CompilerGenerated] private static class <>O { public static hook_instantiate_tree <0>__Instantiate_tree_Hook; public static orig_set_text_1 <1>__Set_text_Prefix; public static orig_init_page <2>__Init_page_Suffix; public static prefix_OperatorInvoke <3>__Add_choice_Prefix; public static orig_pre_sim_update <4>__Pre_sim_update_Prefix; public static orig_pre_sim_update <5>__Pre_sim_update_Suffix; public static hook_open_confirm_window <6>__Open_confirm_window_Hook; public static hook_apply_new_keyboard_mouse_binding <7>__Apply_new_keyboard_mouse_binding_Hook; public static hook_apply_new_button_binding <8>__Apply_new_button_binding_Hook; } private const string ModsTabKey = "MIO_MODDING_API.MOD_MENU.MODS_TAB"; private const string GameTabTitleId = "UI_MENU_SETTINGS_GAME_TITLE"; private const float ContentsFade = 0.3f; private static bool capturing; private static readonly List<(Prefab_ref prefab, nint world, nint node)> instantiated = new List<(Prefab_ref, nint, nint)>(); private static nint gameTabLabel; private const int GamePage = 0; private const int ControllerPage = 4; private const int HostPage = 6; private const int PageCount = 7; private const int OpenModTarget = 0; private const string ModsRowKey = "MIO_MODDING_API.MOD_MENU.MODS"; private static Vec_float_3 basePos = new Vec_float_3 { x = 95f, y = -36f, z = 0f }; private static Vec_float_3 increment = new Vec_float_3 { x = 0f, y = -60f, z = 0f }; private static readonly Dictionary<nint, Menu> menus = new Dictionary<nint, Menu>(); private static bool addingOwnRows; private const uint LineNameHash = 3296830565u; private const float LineHeightPerFontSize = 1.4f; private const float DescriptionGap = 30f; private const float CharWidthPerFontSize = 0.5f; private static readonly Dictionary<nint, KeybindOption> keybinds = new Dictionary<nint, KeybindOption>(); private const Rt_flags HoverFlags = (Rt_flags)7; private unsafe static void ApplyTabHooks() { //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_002b: Expected O, but got Unknown //IL_0040: 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_004b: Expected O, but got Unknown Localization.AddString("MIO_MODDING_API.MOD_MENU.MODS_TAB", "Mods", (Language)1); object obj = <>O.<0>__Instantiate_tree_Hook; if (obj == null) { hook_instantiate_tree val = Instantiate_tree_Hook; <>O.<0>__Instantiate_tree_Hook = val; obj = (object)val; } instantiate_tree.Hook += (hook_instantiate_tree)obj; object obj2 = <>O.<1>__Set_text_Prefix; if (obj2 == null) { orig_set_text_1 val2 = Set_text_Prefix; <>O.<1>__Set_text_Prefix = val2; obj2 = (object)val2; } set_text_1.Prefix += (orig_set_text_1)obj2; } private static void BeginTabCapture() { capturing = true; instantiated.Clear(); gameTabLabel = 0; } private unsafe static Node2* Instantiate_tree_Hook(orig_instantiate_tree orig, World* self, Prefab_ref* path, Node2* parent, Zone* zone) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) Node2* ptr = orig.Invoke(self, path, parent, zone); if (capturing && path != null) { instantiated.Add((*path, (nint)self, (nint)ptr)); } return ptr; } private unsafe static void Set_text_Prefix(Node2* node, String text) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (capturing && gameTabLabel == 0 && StringAllocator.FromMioString(text) == "UI_MENU_SETTINGS_GAME_TITLE") { gameTabLabel = (nint)node; } } private unsafe static void EndTabCapture(Ui_settings* self) { if (!capturing) { return; } capturing = false; try { if (menus.TryGetValue((nint)self, out Menu value) && value.Built) { BuildTab(self, value); } } catch (Exception value2) { ModMenu.Log($"creating the Mods tab failed, keeping the Game page row: {value2}"); } finally { instantiated.Clear(); gameTabLabel = 0; } } private unsafe static void BuildTab(Ui_settings* self, Menu menu) { //IL_00ac: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_0190: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_01ee: 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_0203: 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_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: 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_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) Page* ptr = Pages(self); Node2* gameTab = ((TNode_Ui_interactive_node)(&((Page)ptr).cat_choice)).n; Node2* n = ((TNode_Ui_interactive_node)(&((Page)((byte*)ptr + (nint)5 * (nint)Unsafe.SizeOf<Page>())).cat_choice)).n; Node2* n2 = ((TNode_Ui_interactive_node)(&((Page)((byte*)ptr + (nint)4 * (nint)Unsafe.SizeOf<Page>())).cat_choice)).n; if (gameTab == null || n == null || n2 == null || ((Node2)gameTab).parent == null) { ModMenu.Log("Settings tabs not found; keeping the Game page row"); return; } int num = instantiated.FindIndex(((Prefab_ref prefab, nint world, nint node) e) => e.node == (nint)gameTab); if (num < 0) { ModMenu.Log("didn't see the Settings tabs being made; keeping the Game page row"); return; } Prefab_ref item = instantiated[num].prefab; World* item2 = (World*)instantiated[num].world; Node2* ptr2 = ((World)item2).instantiate_tree(&item, ((Node2)gameTab).parent, (Zone*)null); if (ptr2 == null) { ModMenu.Log("instantiating the Mods tab failed; keeping the Game page row"); return; } Node2* ptr3 = ((gameTabLabel != 0) ? FindDescendant(ptr2, ((Symstring)(&((Node2)gameTabLabel).name)).hash, 3) : null); if (ptr3 != null) { ui[ptr3] = *StringAllocator.GetMioString("MIO_MODDING_API.MOD_MENU.MODS_TAB"); } else { ModMenu.Log("couldn't find the tab's label node; the Mods tab may show no text"); } Vec_float_3 translation = ((Aff)(&((Node2)n)._transform)).translation; Vec_float_3 translation2 = ((Aff)(&((Node2)n2)._transform)).translation; SetTranslation(item2, ptr2, new Vec_float_3 { x = translation.x + (translation.x - translation2.x), y = translation.y + (translation.y - translation2.y), z = translation.z + (translation.z - translation2.z) }); TNode_Ui_interactive_node val = new TNode_Ui_interactive_node { n = ptr2 }; TNode_Ui_interactive_node on_up = new TNode_Ui_interactive_node { n = n }; TNode_Ui_interactive_node on_down = new TNode_Ui_interactive_node { n = gameTab }; if (((TNode_Ui_interactive_node)(ref val)).d == null || ((TNode_Ui_interactive_node)(ref on_up)).d == null || ((TNode_Ui_interactive_node)(ref on_down)).d == null) { common.toggle_node(ptr2, false); ModMenu.Log("the new tab isn't an interactive node; keeping the Game page row"); return; } Unsafe.Write(&((Ui_interactive_node)((TNode_Ui_interactive_node)(ref on_up)).d).on_down, val); Unsafe.Write(&((Ui_interactive_node)((TNode_Ui_interactive_node)(ref val)).d).on_up, on_up); Unsafe.Write(&((Ui_interactive_node)((TNode_Ui_interactive_node)(ref val)).d).on_down, on_down); Unsafe.Write(&((Ui_interactive_node)((TNode_Ui_interactive_node)(ref on_down)).d).on_up, val); ((Ui_interactive_node)((TNode_Ui_interactive_node)(ref val)).d).rt_flags &= (Rt_flags)(-8); menu.Tab = val; RemoveModsRow(self, menu); } private unsafe static void SetTranslation(World* world, Node2* node, Vec_float_3 translation) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Unsafe.Write(&((Aff)(&((Node2)node)._transform)).translation, translation); ((Node2)node).flags |= (Flags)32768; if ((((Node2)node).flags & 0x200000) == 0) { ((Array_Node2_Ptr)(&((World)world).dirty_nodes)).push(node); ((Node2)node).flags |= (Flags)2097152; } } private unsafe static Node2* FindDescendant(Node2* node, uint nameHash, int depth) { if (node == null || depth < 0) { return null; } Node2** data = (Node2**)((Ptr)(&((Array_Node2_Ptr)(&((Node2)node).children)).data)).data; for (uint num = 0u; num < ((Array_Node2_Ptr)(&((Node2)node).children)).count; num++) { if (data[num] != null) { if (((Symstring)(&((Node2)data[num]).name)).hash == nameHash) { return data[num]; } Node2* ptr = FindDescendant(data[num], nameHash, depth - 1); if (ptr != null) { return ptr; } } } return null; } private unsafe static void RemoveModsRow(Ui_settings* self, Menu menu) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) Page* ptr = Pages(self); uint count = ((Array_Ui_settings__Widget)(&((Page)ptr).widget_list)).count; if (count != 0 && menu.ModsRow.n != null) { Widget* ptr2 = Rows(((Page)ptr).widget_list); if (((TNode_Ui_interactive_node)(&((Widget)((byte*)ptr2 + (count - 1) * Unsafe.SizeOf<Widget>())).node)).n == menu.ModsRow.n) { common.toggle_node(menu.ModsRow.n, false); ((Array_Ui_settings__Widget)(&((Page)ptr).widget_list)).count = count - 1; LinkRows(ptr2, count - 1); FixDividers(ptr2, count - 1); menu.ModsRow = default(TNode_Ui_interactive_node); } } } private unsafe static void UpdateTabLevel(Ui_settings* self, Menu menu, float dt) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Invalid comparison between Unknown and I4 //IL_0128: Unknown result type (might be due to invalid IL or missing references) Ui_interactive_node* d = ((TNode_Ui_interactive_node)(ref menu.Tab)).d; if (d == null || ((Confirm_window)(&((Ui_settings)self).confirm_window)).window_open) { return; } if ((((Ui_interactive_node)d).rt_flags & 4) != 0) { ((Game)(ref Globals.audio.game)).play_sfx_ui((Sfx_ui)10); } if ((((Ui_interactive_node)d).rt_flags & 1) <= 0) { if (menu.Previewing) { menu.Previewing = false; Close(self, menu); } return; } if (menu.Screen == Screen.Closed) { Show(self, menu, Screen.ModList, -1, 0); } Ui_group_node* d2 = ((TNode_Ui_group_node)(&((Page)Host(self)).contents)).d; if (d2 != null) { Ui_element* ptr = ((Ui_group_node)d2).as_ui_element(); if (!menu.Previewing) { menu.PreviewFade = (((int)((Ui_element)ptr).status == 1) ? 0f : ((Ui_element)ptr).fade); } DrivePreviewFade(ptr, menu, dt); } menu.Previewing = true; if (ConfirmPressed()) { ((Game)(ref Globals.input.game)).reset((Action)18, false); ((Game)(ref Globals.audio.game)).play_sfx_ui((Sfx_ui)11); menu.Previewing = false; GoTo(self, menu, 6); ((Ui_settings)self).page_choice_first_sfx_passed = false; Widget* ptr2 = Rows(((Page)Host(self)).widget_list); if (((Array_Ui_settings__Widget)(&((Page)Host(self)).widget_list)).count != 0) { SetHover(((Widget)ptr2).node); SetDescription(Host(self), menu.Pages[0].Description); } } } private unsafe static void DrivePreviewFade(Ui_element* element, Menu menu, float dt) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) menu.PreviewFade = Math.Min(1f, menu.PreviewFade + dt / 0.3f); ((Ui_element)element).fade = menu.PreviewFade; ((Ui_element)element).fade_per_sec = 0f; Unsafe.Write(&((Ui_element)element).status, (Status)((!(menu.PreviewFade >= 1f)) ? 2 : 0)); } private unsafe static void ReturnToTab(Ui_settings* self, Menu menu) { //IL_0016: 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_0096: 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) Page* ptr = Pages(self); for (int i = 0; i < 6; i++) { ClearHover(Rows(((Page)((byte*)ptr + (nint)i * (nint)Unsafe.SizeOf<Page>())).widget_list), ((Array_Ui_settings__Widget)(&((Page)((byte*)ptr + (nint)i * (nint)Unsafe.SizeOf<Page>())).widget_list)).count); if (((TNode_Ui_interactive_node)(&((Page)((byte*)ptr + (nint)i * (nint)Unsafe.SizeOf<Page>())).cat_choice)).n != null) { ClearHover(((Page)((byte*)ptr + (nint)i * (nint)Unsafe.SizeOf<Page>())).cat_choice); } } ClearHover(Rows(((Page)Host(self)).widget_list), ((Array_Ui_settings__Widget)(&((Page)Host(self)).widget_list)).count); SetHover(menu.Tab); menu.Previewing = true; } private unsafe static void ClearHover(TNode_Ui_interactive_node node) { Ui_interactive_node* d = ((TNode_Ui_interactive_node)(ref node)).d; if (d != null) { ((Ui_interactive_node)d).rt_flags &= (Rt_flags)(-8); } } private static bool ConfirmPressed() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected I4, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected I4, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected I4, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected I4, but got Unknown ref Game game = ref Globals.input.game; Binding val = global::<PrivateImplementationDetails>.InlineArrayElementRef<InlineArray_Input_state_Binding_37, Binding>(ref game.bindings.data, 18); if ((int)val.key_primary != 0 && global::<PrivateImplementationDetails>.InlineArrayAsSpan<InlineArray_Input_btn_512, Input_btn>(ref game.kb.keys.keys.data, 512)[(int)val.key_primary].pressed) { return true; } if ((int)val.mouse_btn != 0 && global::<PrivateImplementationDetails>.InlineArrayAsSpan<InlineArray_Input_btn_6, Input_btn>(ref game.mouse.buttons.data, 6)[(int)val.mouse_btn].pressed) { return true; } if ((int)val.key_secondary != 0 && global::<PrivateImplementationDetails>.InlineArrayAsSpan<InlineArray_Input_btn_512, Input_btn>(ref game.kb.keys.keys.data, 512)[(int)val.key_secondary].pressed) { return true; } if ((int)val.gamepad_button != 0 && global::<PrivateImplementationDetails>.InlineArrayAsSpan<InlineArray_Input_btn_22, Input_btn>(ref game.pad.buttons.data, 22)[(int)val.gamepad_button].pressed) { return true; } return false; } internal unsafe static void ApplyHooks() { //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_002b: Expected O, but got Unknown //IL_0040: 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_004b: Expected O, but got Unknown //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) //IL_006b: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00c5: 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_00d0: 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_00f0: Expected O, but got Unknown Localization.AddString("MIO_MODDING_API.MOD_MENU.MODS", "Mods", (Language)1); object obj = <>O.<2>__Init_page_Suffix; if (obj == null) { orig_init_page val = Init_page_Suffix; <>O.<2>__Init_page_Suffix = val; obj = (object)val; } init_page.Suffix += (orig_init_page)obj; object obj2 = <>O.<3>__Add_choice_Prefix; if (obj2 == null) { prefix_OperatorInvoke val2 = Add_choice_Prefix; <>O.<3>__Add_choice_Prefix = val2; obj2 = (object)val2; } OperatorInvoke.Prefix += (prefix_OperatorInvoke)obj2; object obj3 = <>O.<4>__Pre_sim_update_Prefix; if (obj3 == null) { orig_pre_sim_update val3 = Pre_sim_update_Prefix; <>O.<4>__Pre_sim_update_Prefix = val3; obj3 = (object)val3; } pre_sim_update.Prefix += (orig_pre_sim_update)obj3; object obj4 = <>O.<5>__Pre_sim_update_Suffix; if (obj4 == null) { orig_pre_sim_update val4 = Pre_sim_update_Suffix; <>O.<5>__Pre_sim_update_Suffix = val4; obj4 = (object)val4; } pre_sim_update.Suffix += (orig_pre_sim_update)obj4; object obj5 = <>O.<6>__Open_confirm_window_Hook; if (obj5 == null) { hook_open_confirm_window val5 = Open_confirm_window_Hook; <>O.<6>__Open_confirm_window_Hook = val5; obj5 = (object)val5; } open_confirm_window.Hook += (hook_open_confirm_window)obj5; ApplyTabHooks(); object obj6 = <>O.<7>__Apply_new_keyboard_mouse_binding_Hook; if (obj6 == null) { hook_apply_new_keyboard_mouse_binding val6 = Apply_new_keyboard_mouse_binding_Hook; <>O.<7>__Apply_new_keyboard_mouse_binding_Hook = val6; obj6 = (object)val6; } apply_new_keyboard_mouse_binding.Hook += (hook_apply_new_keyboard_mouse_binding)obj6; object obj7 = <>O.<8>__Apply_new_button_binding_Hook; if (obj7 == null) { hook_apply_new_button_binding val7 = Apply_new_button_binding_Hook; <>O.<8>__Apply_new_button_binding_Hook = val7; obj7 = (object)val7; } apply_new_button_binding.Hook += (hook_apply_new_button_binding)obj7; } private unsafe static void Add_choice_Prefix(Ui_settings__init_page___lambda_5* closure, String* name, Array_String* values, String* description) { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!addingOwnRows) { if (((Ui_settings__init_page___lambda_5)closure).base_pos != null) { basePos = *((Ui_settings__init_page___lambda_5)closure).base_pos; } if (((Ui_settings__init_page___lambda_5)closure).increment != null) { increment = *((Ui_settings__init_page___lambda_5)closure).increment; } } } private unsafe static void Init_page_Suffix(Ui_settings* self, Page* page, Cat c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 try { addingOwnRows = true; if ((int)c == 0) { BuildModsRow(self, page); } else if ((int)c == 6) { BuildScreens(self, page); } } catch (Exception value) { ModMenu.Log($"building Settings rows failed: {value}"); } finally { addingOwnRows = false; } } private unsafe static void BuildModsRow(Ui_settings* self, Page* page) { //IL_0037: 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_0042: 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) Menu menu = new Menu { Pages = ModMenu.VisiblePages() }; menus[(nint)self] = menu; if (menu.Pages.Length != 0) { Widget* ptr = AddGoto(page, "MIO_MODDING_API.MOD_MENU.MODS", 6, 0u); menu.ModsRow = ((Widget)ptr).node; LinkRows(Rows(((Page)page).widget_list), ((Array_Ui_settings__Widget)(&((Page)page).widget_list)).count); FixDividers(Rows(((Page)page).widget_list), ((Array_Ui_settings__Widget)(&((Page)page).widget_list)).count); } } private unsafe static void BuildScreens(Ui_settings* self, Page* host) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) if (!menus.TryGetValue((nint)self, out Menu value) || value.Pages.Length == 0) { return; } Array_String* ptr = FindYesNoValues(self); if (ptr == null) { ModMenu.Log("no vanilla Yes/No row to build from; Mods menu disabled"); return; } uint count = ((Array_Ui_settings__Widget)(&((Page)host).widget_list)).count; uint count2 = ((Array_Ui_settings__Widget)(&((Page)host).widget_list)).count; ModMenuPage[] pages = value.Pages; foreach (ModMenuPage modMenuPage in pages) { Unsafe.Write(&((Widget)AddGoto(host, modMenuPage.TitleKey, 0, count2)).description, *StringAllocator.GetMioString(modMenuPage.DescriptionKey)); } View view = new View(count2, ((Array_Ui_settings__Widget)(&((Page)host).widget_list)).count - count2); View[] array = new View[value.Pages.Length]; ModMenuOption[][] array2 = new ModMenuOption[value.Pages.Length][]; string[][] array3 = new string[value.Pages.Length][]; for (int j = 0; j < value.Pages.Length; j++) { uint count3 = ((Array_Ui_settings__Widget)(&((Page)host).widget_list)).count; List<ModMenuOption> list = new List<ModMenuOption>(); List<string> list2 = new List<string>(); foreach (ModMenuOption option in value.Pages[j].Options) { switch (option.RowKind) { case ModMenuRowKind.Button: Unsafe.Write(&((Widget)AddGoto(host, option.TitleKey, 0, count3)).description, *StringAllocator.GetMioString(option.DescriptionKey)); list.Add(option); list2.Add(option.Description); break; case ModMenuRowKind.Keybind: { KeybindOption keybindOption = (KeybindOption)option; if (keybindOption.HasKeyboard) { Unsafe.Write(&((Widget)AddKeyBinding(host, keybindOption.TitleKey, keybindOption.Binding, count3)).description, *StringAllocator.GetMioString(keybindOption.KeyboardDescriptionKey)); list.Add(option); list2.Add(keybindOption.KeyboardDescription); } if (keybindOption.HasController) { Unsafe.Write(&((Widget)AddButtonBinding(host, keybindOption.TitleKey, keybindOption.Binding, count3)).description, *StringAllocator.GetMioString(keybindOption.ControllerDescriptionKey)); list.Add(option); list2.Add(keybindOption.ControllerDescription); } keybinds[(nint)keybindOption.Binding] = keybindOption; break; } default: { Widget* ptr2 = AddChoice(host, ptr, option.TitleKey, option.ValueKeys, option.DescriptionKey, count3); if (option.IsToggle) { ((Widget)ptr2).p_bool = (bool*)option.Cell; } else { ((Widget)ptr2).p_choice = option.Cell; } ((Widget)ptr2).current_choice = option.Index; list.Add(option); list2.Add(option.Description); break; } } } array[j] = new View(count3, ((Array_Ui_settings__Widget)(&((Page)host).widget_list)).count - count3); array2[j] = list.ToArray(); array3[j] = list2.ToArray(); } value.VanillaCount = count; value.TotalCount = ((Array_Ui_settings__Widget)(&((Page)host).widget_list)).count; value.ModList = view; value.ModPages = array; value.PageRows = array2; value.PageRowDescriptions = array3; Widget* ptr3 = Rows(((Page)host).widget_list); foreach (View item in array.Prepend(view)) { LinkRows((Widget*)((byte*)ptr3 + item.Start * Unsafe.SizeOf<Widget>()), item.Count); FixDividers((Widget*)((byte*)ptr3 + item.Start * Unsafe.SizeOf<Widget>()), item.Count); } SetVisible((Widget*)((byte*)ptr3 + count * Unsafe.SizeOf<Widget>()), value.TotalCount - count, visible: false); ((Array_Ui_settings__Widget)(&((Page)host).widget_list)).count = count; value.Built = true; } private unsafe static Array_String* FindYesNoValues(Ui_settings* self) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Page* ptr = (Page*)(&((Ui_settings)self).pages); for (int i = 0; i < 6; i++) { Widget* ptr2 = Rows(((Page)((byte*)ptr + (nint)i * (nint)Unsafe.SizeOf<Page>())).widget_list); for (uint num = 0u; num < ((Array_Ui_settings__Widget)(&((Page)((byte*)ptr + (nint)i * (nint)Unsafe.SizeOf<Page>())).widget_list)).count; num++) { if ((int)((Widget)((byte*)ptr2 + num * Unsafe.SizeOf<Widget>())).kind == 0 && ((Widget)((byte*)ptr2 + num * Unsafe.SizeOf<Widget>())).p_bool != null && ((Array_String)(&((Widget)((byte*)ptr2 + num * Unsafe.SizeOf<Widget>())).choices)).count == 2) { return &((Widget)((byte*)ptr2 + num * Unsafe.SizeOf<Widget>())).choices; } } } return null; } private unsafe static Widget* AddChoice(Page* page, Array_String* seed, string nameKey, string[] valueKeys, string descriptionKey, uint screenStart) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) Page* ptr = page; Vec_float_3 val = ScreenBase(screenStart); Vec_float_3 val2 = increment; Ui_settings__init_page___lambda_5 val3 = new Ui_settings__init_page___lambda_5 { page = &ptr, base_pos = &val, increment = &val2 }; Widget* ptr2 = ((Ui_settings__init_page___lambda_5)(ref val3)).OperatorInvoke(StringAllocator.GetMioString(nameKey), seed, StringAllocator.GetMioString(descriptionKey)); if (((Array_String)(&((Widget)ptr2).choices)).count != (uint)valueKeys.Length) { ((Array_String)(&((Widget)ptr2).choices)).resize((uint)valueKeys.Length); } String* data = (String*)((Ptr)(&((Array_String)(&((Widget)ptr2).choices)).data)).data; for (int i = 0; i < valueKeys.Length; i++) { Unsafe.Write((byte*)data + (nint)i * (nint)Unsafe.SizeOf<String>(), *StringAllocator.GetMioString(valueKeys[i])); } return ptr2; } private unsafe static Widget* AddKeyBinding(Page* page, string nameKey, Binding* binding, uint screenStart) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0011: 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_0037: Unknown result type (might be due to invalid IL or missing references) Page* ptr = page; Vec_float_3 val = ScreenBase(screenStart); Vec_float_3 val2 = increment; Ui_settings__init_page___lambda_4 val3 = new Ui_settings__init_page___lambda_4 { page = &ptr, base_pos = &val, increment = &val2 }; return ((Ui_settings__init_page___lambda_4)(ref val3)).OperatorInvoke(StringAllocator.GetMioString(nameKey), binding); } private unsafe static Widget* AddButtonBinding(Page* page, string nameKey, Binding* binding, uint screenStart) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0011: 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_0037: Unknown result type (might be due to invalid IL or missing references) Page* ptr = page; Vec_float_3 val = ScreenBase(screenStart); Vec_float_3 val2 = increment; Ui_settings__init_page___lambda_3 val3 = new Ui_settings__init_page___lambda_3 { page = &ptr, base_pos = &val, increment = &val2 }; return ((Ui_settings__init_page___lambda_3)(ref val3)).OperatorInvoke(StringAllocator.GetMioString(nameKey), binding); } private unsafe static Widget* AddGoto(Page* page, string nameKey, int targetPage, uint screenStart) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0011: 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_0037: Unknown result type (might be due to invalid IL or missing references) Page* ptr = page; Vec_float_3 val = ScreenBase(screenStart); Vec_float_3 val2 = increment; Ui_settings__init_page___lambda_2 val3 = new Ui_settings__init_page___lambda_2 { page = &ptr, base_pos = &val, increment = &val2 }; return ((Ui_settings__init_page___lambda_2)(ref val3)).OperatorInvoke(StringAllocator.GetMioString(nameKey), targetPage); } private static Vec_float_3 ScreenBase(uint rowsBefore) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) return new Vec_float_3 { x = basePos.x - increment.x * (float)rowsBefore, y = basePos.y - increment.y * (float)rowsBefore, z = basePos.z - increment.z * (float)rowsBefore }; } private unsafe static void Pre_sim_update_Prefix(Ui_settings* self, Node2* n, float dt) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!((Ui_settings)self).initialized) { BeginTabCapture(); } if (menus.TryGetValue((nint)self, out Menu value) && value.Screen != Screen.Closed) { value.HoveredBeforeUpdate = HoveredIndex(((Page)Host(self)).widget_list); if (value.Screen == Screen.ModPage) { ClearListeningControllerRow(self); } } } private unsafe static void Pre_sim_update_Suffix(Ui_settings* self, Node2* n, float dt) { try { ModMenu.PollValues(); EndTabCapture(self); if (menus.TryGetValue((nint)self, out Menu value) && value.Built) { FinishReset(self, value); Navigate(self, value, dt); if (value.Screen == Screen.ModPage) { SyncChangedRows(self, value); } } if (((Ui_settings)self).widget_opened < 0) { ModMenuConfig.SaveIfDirty(); } } catch (Exception value2) { ModMenu.Log($"Settings update failed: {value2}"); } } private unsafe static void Navigate(Ui_settings* self, Menu menu, float dt) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) int lastPageOpened = menu.LastPageOpened; int num = (menu.LastPageOpened = ((Ui_settings)self).page_opened); if (menu.Tab.n != null && num < 0 && !((Ui_settings)self).exit) { UpdateTabLevel(self, menu, dt); return; } switch (menu.Screen) { case Screen.Closed: if (lastPageOpened == 0 && num == 6) { Show(self, menu, Screen.ModList, -1, 0); } else if (num == 6 && lastPageOpened != 6 && menu.Lingering.HasValue) { RestoreVanilla(self, menu); } break; case Screen.ModList: if (((Ui_settings)self).exit || num < 0) { Close(self, menu); break; } switch (num) { case 4: if (menu.Tab.n != null) { GoTo(self, menu, -1); ReturnToTab(self, menu); } else { Close(self, menu); GoTo(self, menu, 0); SetHover(menu.ModsRow); } return; case 0: if (lastPageOpened == 6) { int hoveredBeforeUpdate2 = menu.HoveredBeforeUpdate; if (hoveredBeforeUpdate2 >= 0 && hoveredBeforeUpdate2 < menu.Pages.Length) { Show(self, menu, Screen.ModPage, hoveredBeforeUpdate2, 0); GoTo(self, menu, 6); } else { Close(self, menu); } return; } break; } if (num != 6) { Close(self, menu); } break; case Screen.ModPage: if (((Ui_settings)self).exit || num < 0) { Close(self, menu); break; } switch (num) { case 4: Show(self, menu, Screen.ModList, -1, menu.OpenPage); GoTo(self, menu, 6); break; case 0: if (lastPageOpened == 6) { GoTo(self, menu, 6); int hoveredBeforeUpdate = menu.HoveredBeforeUpdate; ModMenuOption[] array = menu.PageRows[menu.OpenPage]; Refocus(self, menu, Math.Max(hoveredBeforeUpdate, 0)); if (hoveredBeforeUpdate >= 0 && hoveredBeforeUpdate < array.Length && array[hoveredBeforeUpdate] is ButtonOption buttonOption) { buttonOption.Press(); } break; } goto default; default: if (num != 6) { Close(self, menu); } break; } break; } } private unsafe static void GoTo(Ui_settings* self, Menu menu, int page) { ((Ui_settings)self).page_opened = page; menu.LastPageOpened = page; } private unsafe static void Show(Ui_settings* self, Menu menu, Screen screen, int page, int hover) { //IL_0126: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) Page* ptr = Host(self); if (menu.Screen == Screen.Closed) { View? lingering = menu.Lingering; if (lingering.HasValue) { View valueOrDefault = lingering.GetValueOrDefault(); SetVisible((Widget*)((byte*)Rows(menu.VanillaHeader) + valueOrDefault.Start * Unsafe.SizeOf<Widget>()), valueOrDefault.Count, visible: false); menu.Lingering = null; goto IL_0141; } } if (menu.Screen == Screen.Closed) { menu.HiddenVanilla.Clear(); Widget* ptr2 = Rows(((Page)ptr).widget_list); for (uint num = 0u; num < ((Array_Ui_settings__Widget)(&((Page)ptr).widget_list)).count; num++) { HideIfShown(((TNode_Ui_interactive_node)(&((Widget)((byte*)ptr2 + num * Unsafe.SizeOf<Widget>())).node)).n, menu); } HideIfShown(((TNode_Ui_group_node)(&((Controller_view)(&((Page)ptr).controller)).root)).n, menu); HideIfShown(((TNode_Ui_group_node)(&((Controller_view)(&((Page)ptr).controller_xb)).root)).n, menu); HideIfShown(((TNode_Ui_group_node)(&((Controller_view)(&((Page)ptr).controller_ps4)).root)).n, menu); HideIfShown(((TNode_Ui_group_node)(&((Controller_view)(&((Page)ptr).controller_ps5)).root)).n, menu); menu.VanillaHeader = ((Page)ptr).widget_list; } else { SetVisible(Rows(((Page)ptr).widget_list), ((Array_Ui_settings__Widget)(&((Page)ptr).widget_list)).count, visible: false); } goto IL_0141; IL_0141: View view = ((screen == Screen.ModList) ? menu.ModList : menu.ModPages[page]); Unsafe.Write(&((Page)ptr).widget_list, Header(menu, view)); Widget* ptr3 = Rows(((Page)ptr).widget_list); SetVisible(ptr3, view.Count, visible: true); FixDividers(ptr3, view.Count); if (screen == Screen.ModPage) { SyncRows(ptr3, menu.PageRows[page]); } FitAboveDescription(ptr, menu, screen, page); ClearHover(Rows(menu.VanillaHeader), menu.TotalCount); for (int i = 0; i < 6; i++) { ClearHover(Rows(((Page)((byte*)Pages(self) + (nint)i * (nint)Unsafe.SizeOf<Page>())).widget_list), ((Array_Ui_settings__Widget)(&((Page)((byte*)Pages(self) + (nint)i * (nint)Unsafe.SizeOf<Page>())).widget_list)).count); } if (view.Count != 0) { hover = Math.Clamp(hover, 0, (int)(view.Count - 1)); SetHover(((Widget)((byte*)ptr3 + (nint)hover * (nint)Unsafe.SizeOf<Widget>())).node); string text = ((screen == Screen.ModList) ? menu.Pages[hover].Description : menu.PageRowDescriptions[page][hover]); SetDescription(ptr, text); } menu.Screen = screen; menu.OpenPage = page; } private unsafe static void Refocus(Ui_settings* self, Menu menu, int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) Page* ptr = Host(self); Widget* ptr2 = Rows(((Page)ptr).widget_list); uint count = ((Array_Ui_settings__Widget)(&((Page)ptr).widget_list)).count; if (count != 0) { index = Math.Clamp(index, 0, (int)(count - 1)); ClearHover(Rows(menu.VanillaHeader), menu.TotalCount); for (int i = 0; i < 6; i++) { ClearHover(Rows(((Page)((byte*)Pages(self) + (nint)i * (nint)Unsafe.SizeOf<Page>())).widget_list), ((Array_Ui_settings__Widget)(&((Page)((byte*)Pages(self) + (nint)i * (nint)Unsafe.SizeOf<Page>())).widget_list)).count); } SetHover(((Widget)((byte*)ptr2 + (nint)index * (nint)Unsafe.SizeOf<Widget>())).node); if (menu.Screen == Screen.ModPage) { SetDescription(ptr, menu.PageRowDescriptions[menu.OpenPage][index]); } } } private unsafe static void Close(Ui_settings* self, Menu menu) { //IL_0012: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (menu.Screen != Screen.Closed) { Page* ptr = Host(self); menu.Lingering = new View((uint)((nint)((byte*)Rows(((Page)ptr).widget_list) - (nuint)Rows(menu.VanillaHeader)) / (nint)Unsafe.SizeOf<Widget>()), ((Array_Ui_settings__Widget)(&((Page)ptr).widget_list)).count); Unsafe.Write(&((Page)ptr).widget_list, menu.VanillaHeader); ClearHover((Widget*)((byte*)Rows(menu.VanillaHeader) + menu.VanillaCount * Unsafe.SizeOf<Widget>()), menu.TotalCount - menu.VanillaCount); menu.Screen = Screen.Closed; menu.OpenPage = -1; ModMenuConfig.SaveIfDirty(); } } private unsafe static void RestoreVanilla(Ui_settings* self, Menu menu) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) View? lingering = menu.Lingering; if (lingering.HasValue) { View valueOrDefault = lingering.GetValueOrDefault(); SetVisible((Widget*)((byte*)Rows(menu.VanillaHeader) + valueOrDefault.Start * Unsafe.SizeOf<Widget>()), valueOrDefault.Count, visible: false); menu.Lingering = null; } foreach (nint item in menu.HiddenVanilla) { common.toggle_node((Node2*)item, true); } menu.HiddenVanilla.Clear(); Ui_scroll_rect* d = ((TNode_Ui_scroll_rect)(&((Page)Host(self)).scroll)).d; float? vanillaBottomPad = menu.VanillaBottomPad; if (vanillaBottomPad.HasValue) { float valueOrDefault2 = vanillaBottomPad.GetValueOrDefault(); if (d != null) { ((Vec_float_4)(&((Ui_scroll_rect)d).pad)).w = valueOrDefault2; } } menu.VanillaBottomPad = null; } private unsafe static Array_Ui_settings__Widget Header(Menu menu, View view) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) return new Array_Ui_settings__Widget { count = view.Count, capacity = view.Count, data = { data = (byte*)Rows(menu.VanillaHeader) + view.Start * Unsafe.SizeOf<Widget>() } }; } private unsafe static void SyncRows(Widget* rows, ModMenuOption[] rowOptions) { for (int i = 0; i < rowOptions.Length; i++) { ModMenuOption modMenuOption = rowOptions[i]; if (modMenuOption.RowKind == ModMenuRowKind.Choice) { ((Widget)((byte*)rows + (nint)i * (nint)Unsafe.SizeOf<Widget>())).current_choice = modMenuOption.Index; modMenuOption.RowNeedsSync = false; } } } private unsafe static void SyncChangedRows(Ui_settings* self, Menu menu) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) ModMenuOption[] array = menu.PageRows[menu.OpenPage]; Widget* ptr = Rows(((Page)Host(self)).widget_list); for (int i = 0; i < array.Length; i++) { ModMenuOption modMenuOption = array[i]; if (modMenuOption.RowKind == ModMenuRowKind.Choice && modMenuOption.RowNeedsSync) { ((Widget)((byte*)ptr + (nint)i * (nint)Unsafe.SizeOf<Widget>())).current_choice = modMenuOption.Index; modMenuOption.RowNeedsSync = false; } } } private unsafe static Page* Pages(Ui_settings* self) { return (Page*)(&((Ui_settings)self).pages); } private unsafe static Page* Host(Ui_settings* self) { return (Page*)((byte*)Pages(self) + (nint)6 * (nint)Unsafe.SizeOf<Page>()); } private unsafe static Widget* Rows(Array_Ui_settings__Widget list) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return (Widget*)list.data.data; } private unsafe static void LinkRows(Widget* rows, uint count) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (count == 0) { return; } for (uint num = 0u; num < count; num++) { Ui_interactive_node* d = ((TNode_Ui_interactive_node)(&((Widget)((byte*)rows + num * Unsafe.SizeOf<Widget>())).node)).d; if (d != null) { Unsafe.W