Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NotModMenu v1.0.0
plugins/NotModMenu.dll
Decompiled a day 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.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using RoR2; using RoR2.UI; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NotModMenu")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NotModMenu")] [assembly: AssemblyTitle("NotModMenu")] [assembly: AssemblyVersion("1.0.0.0")] namespace NotModMenu; internal sealed class MenuButtonInjector : MonoBehaviour { private const string LabelToken = "NOTMODMENU_MODS"; private const string HoverToken = "NOTMODMENU_MODS_DESC"; private MainMenuController lastMainMenu; private GameObject mainMenuButton; private readonly List<PauseScreenController> seenPauseScreens = new List<PauseScreenController>(); private readonly List<GameObject> pauseButtons = new List<GameObject>(); private void Update() { NotModMenuPlugin plugin = NotModMenuPlugin.Instance; MainMenuController mainMenu = MainMenuController.instance; if (Object.op_Implicit((Object)(object)mainMenu) && (Object)(object)mainMenu != (Object)(object)lastMainMenu) { lastMainMenu = mainMenu; Transform root = (Object.op_Implicit((Object)(object)mainMenu.titleMenuScreen) ? ((Component)mainMenu.titleMenuScreen).transform : ((Component)mainMenu).transform); mainMenuButton = AddButton(root, "TITLE_SETTINGS", delegate { plugin.Window.Open((Object)(object)mainMenu); }); } SetActive(mainMenuButton, plugin.ShowInMainMenu.Value); seenPauseScreens.RemoveAll((PauseScreenController val2) => !Object.op_Implicit((Object)(object)val2)); pauseButtons.RemoveAll((GameObject button) => !Object.op_Implicit((Object)(object)button)); List<PauseScreenController> instancesList = PauseScreenController.instancesList; if (instancesList != null) { foreach (PauseScreenController screen in instancesList) { if (Object.op_Implicit((Object)(object)screen) && !seenPauseScreens.Contains(screen)) { seenPauseScreens.Add(screen); GameObject val = AddButton(((Component)screen).transform, "PAUSE_SETTINGS", delegate { plugin.Window.Open((Object)(object)screen); }); if (Object.op_Implicit((Object)(object)val)) { pauseButtons.Add(val); } } } } foreach (GameObject pauseButton in pauseButtons) { SetActive(pauseButton, plugin.ShowInPauseMenu.Value); } Language english = Language.english; if (english == null || (!Object.op_Implicit((Object)(object)mainMenuButton) && pauseButtons.Count <= 0) || english.TokenIsRegistered("NOTMODMENU_MODS")) { return; } RegisterTokens(); RefreshLabel(mainMenuButton); foreach (GameObject pauseButton2 in pauseButtons) { RefreshLabel(pauseButton2); } } private static void RefreshLabel(GameObject button) { if (Object.op_Implicit((Object)(object)button)) { LanguageTextMeshController val = FindLabel(button); if (Object.op_Implicit((Object)(object)val)) { val.token = ""; val.token = "NOTMODMENU_MODS"; } } } private static void SetActive(GameObject go, bool active) { if (Object.op_Implicit((Object)(object)go) && go.activeSelf != active) { go.SetActive(active); } } private static GameObject AddButton(Transform root, string templateToken, Action onClick) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown try { RegisterTokens(); HGButton val = null; HGButton[] componentsInChildren = ((Component)root).GetComponentsInChildren<HGButton>(true); foreach (HGButton val2 in componentsInChildren) { LanguageTextMeshController val3 = FindLabel(((Component)val2).gameObject); if (Object.op_Implicit((Object)(object)val3) && val3.token == templateToken) { val = val2; break; } } if (!Object.op_Implicit((Object)(object)val)) { NotModMenuPlugin.Log.LogWarning((object)("No '" + templateToken + "' button found under " + ((Object)root).name + "; the MODS button was not added there.")); return null; } GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent); ((Object)obj).name = "GenericMenuButton (Mods)"; obj.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1); HGButton component = obj.GetComponent<HGButton>(); ((Button)component).onClick = new ButtonClickedEvent(); ((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate { onClick(); }); ((Selectable)component).interactable = true; component.hoverToken = "NOTMODMENU_MODS_DESC"; LanguageTextMeshController val4 = FindLabel(obj); if (Object.op_Implicit((Object)(object)val4)) { val4.token = "NOTMODMENU_MODS"; } return obj; } catch (Exception arg) { NotModMenuPlugin.Log.LogError((object)$"Failed to add the MODS button: {arg}"); return null; } } private static LanguageTextMeshController FindLabel(GameObject button) { LanguageTextMeshController component = button.GetComponent<LanguageTextMeshController>(); if (!Object.op_Implicit((Object)(object)component)) { return button.GetComponentInChildren<LanguageTextMeshController>(true); } return component; } private static void RegisterTokens() { SetToken("NOTMODMENU_MODS", "Mods"); SetToken("NOTMODMENU_MODS_DESC", "Browse installed mods and change their settings."); } private static void SetToken(string token, string text) { Language english = Language.english; if (english != null) { english.SetStringByToken(token, text); } Language currentLanguage = Language.currentLanguage; if (currentLanguage != null && currentLanguage != Language.english) { currentLanguage.SetStringByToken(token, text); } } } internal sealed class ModEntry { public string Guid; public string Name; public string Version; public string Author; public string Description; public string WebsiteUrl; public string ThunderstoreUrl; public string Folder; public string IconPath; public PluginInfo Plugin; public bool IsBuiltIn; public bool IsLibrary; public int SettingCount; public string SearchText; public Color Tint; public string Initial; public readonly List<ConfigFile> ConfigFiles = new List<ConfigFile>(); public readonly List<string> Requires = new List<string>(); public readonly List<string> RequiredBy = new List<string>(); } [Serializable] internal sealed class ThunderstoreManifest { public string @namespace; public string name; public string version_number; public string website_url; public string description; } internal static class ModCatalog { private static readonly Dictionary<string, Texture2D> icons = new Dictionary<string, Texture2D>(StringComparer.OrdinalIgnoreCase); private static int iconLoadBudget; public static List<ModEntry> Build() { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) List<ModEntry> list = new List<ModEntry> { GameEntry(), BepInExEntry() }; Dictionary<string, ModEntry> dictionary = new Dictionary<string, ModEntry>(StringComparer.OrdinalIgnoreCase); foreach (PluginInfo value2 in Chainloader.PluginInfos.Values) { if (((value2 != null) ? value2.Metadata : null) != null) { try { ModEntry modEntry = FromPlugin(value2); dictionary[modEntry.Guid] = modEntry; list.Add(modEntry); } catch (Exception ex) { NotModMenuPlugin.Log.LogWarning((object)("Skipping " + value2.Metadata.GUID + ": " + ex.Message)); } } } foreach (ModEntry value3 in dictionary.Values) { if (value3.Plugin.Dependencies == null) { continue; } foreach (BepInDependency dependency in value3.Plugin.Dependencies) { if ((dependency.Flags & 1) != 0) { if (dictionary.TryGetValue(dependency.DependencyGUID, out var value)) { value3.Requires.Add(value.Name); value.RequiredBy.Add(value3.Name); value.IsLibrary = true; } else { value3.Requires.Add(dependency.DependencyGUID); } } } } foreach (ModEntry item in list) { item.Requires.Sort(StringComparer.OrdinalIgnoreCase); item.RequiredBy.Sort(StringComparer.OrdinalIgnoreCase); item.SearchText = string.Join(" ", item.Name, item.Guid, item.Author, item.Description).ToLowerInvariant(); item.Initial = ((item.Name.Trim().Length > 0) ? item.Name.Trim().Substring(0, 1).ToUpperInvariant() : "?"); item.Tint = Color.HSVToRGB((float)(StableHash(item.Guid) % 360) / 360f, 0.45f, 0.62f); } return list.OrderByDescending((ModEntry m) => m.IsBuiltIn).ThenBy<ModEntry, string>((ModEntry m) => m.Name, StringComparer.OrdinalIgnoreCase).ToList(); } public static void RefreshSettings(ModEntry mod) { if (mod.Plugin != null) { mod.ConfigFiles.Clear(); CollectConfigFiles(mod, mod.Plugin.Instance); } int num = 0; foreach (ConfigFile configFile in mod.ConfigFiles) { num += configFile.Count; } mod.SettingCount = num; } private static ModEntry FromPlugin(PluginInfo info) { ModEntry modEntry = new ModEntry { Plugin = info, Guid = info.Metadata.GUID, Name = (string.IsNullOrEmpty(info.Metadata.Name) ? info.Metadata.GUID : info.Metadata.Name), Version = info.Metadata.Version?.ToString() }; string text = (modEntry.Folder = (string.IsNullOrEmpty(info.Location) ? null : Path.GetDirectoryName(info.Location))); string text2 = FindPackageDir(text); if (text2 != null) { modEntry.Folder = text2; ReadManifest(modEntry, Path.Combine(text2, "manifest.json"), out var author, out var packageName); string fileName = Path.GetFileName(text2); int num = fileName.IndexOf('-'); if (num > 0 && num < fileName.Length - 1) { if (string.IsNullOrEmpty(author)) { author = fileName.Substring(0, num); } if (string.IsNullOrEmpty(packageName)) { packageName = fileName.Substring(num + 1); } } if (!string.IsNullOrEmpty(author)) { modEntry.Author = author; if (!string.IsNullOrEmpty(packageName)) { modEntry.ThunderstoreUrl = "https://thunderstore.io/c/riskofrain2/p/" + author + "/" + packageName + "/"; } } string text3 = Path.Combine(text2, "icon.png"); if (File.Exists(text3)) { modEntry.IconPath = text3; } } if (modEntry.IconPath == null && text != null) { string text4 = Path.Combine(text, "icon.png"); if (File.Exists(text4)) { modEntry.IconPath = text4; } } CollectConfigFiles(modEntry, info.Instance); return modEntry; } private static ModEntry GameEntry() { string text = null; try { text = RoR2Application.GetBuildId(); } catch { } return new ModEntry { Guid = "RiskOfRain2", Name = "Risk of Rain 2", Version = Application.version, Author = "Hopoo Games, Gearbox", Description = (string.IsNullOrEmpty(text) ? "The game itself." : ("The game itself. Build " + text + ".")), Folder = Paths.GameRootPath, IsBuiltIn = true }; } private static ModEntry BepInExEntry() { ModEntry modEntry = new ModEntry { Guid = "BepInEx", Name = "BepInEx", Version = typeof(Chainloader).Assembly.GetName().Version?.ToString(), Author = "BepInEx team", Description = "The mod loader that runs all the other mods. Its settings live in BepInEx.cfg and apply after a restart.", WebsiteUrl = "https://github.com/BepInEx/BepInEx", Folder = Paths.BepInExRootPath, IsBuiltIn = true }; object? obj = typeof(ConfigFile).GetProperty("CoreConfig", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null, null); ConfigFile val = (ConfigFile)((obj is ConfigFile) ? obj : null); if (val != null) { modEntry.ConfigFiles.Add(val); } return modEntry; } private static string FindPackageDir(string dir) { if (string.IsNullOrEmpty(dir)) { return null; } try { string text = Path.GetFullPath(Paths.PluginPath).TrimEnd('\\', '/'); string text2 = Path.GetFullPath(dir).TrimEnd('\\', '/'); while (text2 != null && text2.Length > text.Length && text2.StartsWith(text, StringComparison.OrdinalIgnoreCase)) { if (File.Exists(Path.Combine(text2, "manifest.json"))) { return text2; } text2 = Path.GetDirectoryName(text2); } } catch (Exception ex) { NotModMenuPlugin.Log.LogDebug((object)("Package lookup failed for " + dir + ": " + ex.Message)); } return null; } private static void ReadManifest(ModEntry mod, string path, out string author, out string packageName) { author = null; packageName = null; try { ThunderstoreManifest thunderstoreManifest = JsonUtility.FromJson<ThunderstoreManifest>(File.ReadAllText(path)); if (thunderstoreManifest != null) { author = thunderstoreManifest.@namespace; packageName = thunderstoreManifest.name; if (!string.IsNullOrEmpty(thunderstoreManifest.description)) { mod.Description = thunderstoreManifest.description; } if (!string.IsNullOrEmpty(thunderstoreManifest.website_url)) { mod.WebsiteUrl = thunderstoreManifest.website_url; } } } catch (Exception ex) { NotModMenuPlugin.Log.LogDebug((object)("Could not read " + path + ": " + ex.Message)); } } private static void CollectConfigFiles(ModEntry mod, BaseUnityPlugin plugin) { if ((Object)(object)plugin == (Object)null) { return; } AddConfig(mod, plugin.Config); Type type = ((object)plugin).GetType(); while (type != null && type != typeof(BaseUnityPlugin)) { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (typeof(ConfigFile).IsAssignableFrom(fieldInfo.FieldType)) { try { object? value = fieldInfo.GetValue(fieldInfo.IsStatic ? null : plugin); AddConfig(mod, (ConfigFile)((value is ConfigFile) ? value : null)); } catch { } } } type = type.BaseType; } } private static void AddConfig(ModEntry mod, ConfigFile file) { if (file != null && !mod.ConfigFiles.Contains(file)) { mod.ConfigFiles.Add(file); } } public static void ResetIconBudget() { iconLoadBudget = 4; } public static Texture2D GetIcon(ModEntry mod) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown if (mod.IconPath == null) { return null; } if (icons.TryGetValue(mod.IconPath, out var value)) { return value; } if (iconLoadBudget <= 0) { return null; } iconLoadBudget--; value = null; try { value = new Texture2D(2, 2, (TextureFormat)4, true) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(value, File.ReadAllBytes(mod.IconPath))) { Object.Destroy((Object)(object)value); value = null; } } catch (Exception ex) { NotModMenuPlugin.Log.LogDebug((object)("Could not load icon " + mod.IconPath + ": " + ex.Message)); value = null; } icons[mod.IconPath] = value; return value; } private static int StableHash(string s) { int num = 23; string text = s ?? ""; foreach (char c in text) { num = num * 31 + c; } return num & 0x7FFFFFFF; } } internal sealed class ModMenuStyles { public static readonly Color Accent = Color32.op_Implicit(new Color32((byte)232, (byte)185, (byte)79, byte.MaxValue)); public static readonly Color AccentHover = Color32.op_Implicit(new Color32((byte)244, (byte)204, (byte)112, byte.MaxValue)); public static readonly Color AccentDown = Color32.op_Implicit(new Color32((byte)201, (byte)155, (byte)55, byte.MaxValue)); public static readonly Color Text = Color32.op_Implicit(new Color32((byte)233, (byte)235, (byte)240, byte.MaxValue)); public static readonly Color Muted = Color32.op_Implicit(new Color32((byte)150, (byte)157, (byte)173, byte.MaxValue)); public static readonly Color Bad = Color32.op_Implicit(new Color32((byte)224, (byte)90, (byte)90, byte.MaxValue)); public readonly GUISkin Skin; public readonly GUIStyle Window; public readonly GUIStyle Panel; public readonly GUIStyle Title; public readonly GUIStyle Subtitle; public readonly GUIStyle ModTitle; public readonly GUIStyle Version; public readonly GUIStyle Body; public readonly GUIStyle Small; public readonly GUIStyle FooterNote; public readonly GUIStyle Placeholder; public readonly GUIStyle SectionTitle; public readonly GUIStyle SectionHeader; public readonly GUIStyle FileHeader; public readonly GUIStyle SettingName; public readonly GUIStyle ListName; public readonly GUIStyle ListMeta; public readonly GUIStyle ListRowSelected; public readonly GUIStyle ListRowHover; public readonly GUIStyle Row; public readonly GUIStyle RowAlt; public readonly GUIStyle ButtonSmall; public readonly GUIStyle ButtonAccent; public readonly GUIStyle ToggleOn; public readonly GUIStyle ToggleOff; public readonly GUIStyle ValueBox; public readonly GUIStyle InvalidField; public readonly GUIStyle Badge; public readonly GUIStyle IconBackground; public readonly GUIStyle Letter; public readonly GUIStyle LetterBig; public readonly GUIStyle Separator; public readonly Texture2D FallbackCursor = ArrowCursor(); public ModMenuStyles() { //IL_0039: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0100: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_0177: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Expected O, but got Unknown //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Expected O, but got Unknown //IL_02c5: Expected O, but got Unknown //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Expected O, but got Unknown //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Expected O, but got Unknown //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Expected O, but got Unknown //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Expected O, but got Unknown //IL_0427: Expected O, but got Unknown //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Expected O, but got Unknown //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Expected O, but got Unknown //IL_0489: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Expected O, but got Unknown //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Expected O, but got Unknown //IL_04f9: Expected O, but got Unknown //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Expected O, but got Unknown //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Expected O, but got Unknown //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Expected O, but got Unknown //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06b0: Expected O, but got Unknown //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Expected O, but got Unknown //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Unknown result type (might be due to invalid IL or missing references) //IL_0747: Unknown result type (might be due to invalid IL or missing references) //IL_0764: Unknown result type (might be due to invalid IL or missing references) //IL_0769: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Expected O, but got Unknown //IL_077d: Expected O, but got Unknown //IL_078d: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_07a8: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Unknown result type (might be due to invalid IL or missing references) //IL_07b2: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Expected O, but got Unknown //IL_07c1: Expected O, but got Unknown //IL_07d1: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_07f1: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Expected O, but got Unknown //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_0807: Unknown result type (might be due to invalid IL or missing references) //IL_0811: Expected O, but got Unknown //IL_0811: Unknown result type (might be due to invalid IL or missing references) //IL_0816: Unknown result type (might be due to invalid IL or missing references) //IL_0820: Expected O, but got Unknown //IL_0825: Expected O, but got Unknown //IL_0835: Unknown result type (might be due to invalid IL or missing references) //IL_0856: Unknown result type (might be due to invalid IL or missing references) //IL_0860: Expected O, but got Unknown //IL_0870: Unknown result type (might be due to invalid IL or missing references) //IL_088c: Unknown result type (might be due to invalid IL or missing references) //IL_0891: Unknown result type (might be due to invalid IL or missing references) //IL_0899: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_08aa: Expected O, but got Unknown //IL_08af: Expected O, but got Unknown //IL_08b1: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08c3: Expected O, but got Unknown //IL_08ca: Unknown result type (might be due to invalid IL or missing references) //IL_08cf: Unknown result type (might be due to invalid IL or missing references) //IL_08d4: Unknown result type (might be due to invalid IL or missing references) //IL_08e9: Unknown result type (might be due to invalid IL or missing references) //IL_08f5: Unknown result type (might be due to invalid IL or missing references) //IL_08ff: Expected O, but got Unknown //IL_090b: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_091f: Unknown result type (might be due to invalid IL or missing references) //IL_092f: Unknown result type (might be due to invalid IL or missing references) //IL_093b: Unknown result type (might be due to invalid IL or missing references) //IL_0945: Expected O, but got Unknown //IL_0951: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_0965: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_0986: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_0999: Expected O, but got Unknown //IL_09b1: Unknown result type (might be due to invalid IL or missing references) //IL_09bd: Unknown result type (might be due to invalid IL or missing references) //IL_09c7: Expected O, but got Unknown //IL_09cc: Unknown result type (might be due to invalid IL or missing references) //IL_09d2: Unknown result type (might be due to invalid IL or missing references) //IL_09fd: Unknown result type (might be due to invalid IL or missing references) //IL_0a0b: Unknown result type (might be due to invalid IL or missing references) //IL_0a31: Unknown result type (might be due to invalid IL or missing references) //IL_0a3b: Expected O, but got Unknown //IL_0a46: Unknown result type (might be due to invalid IL or missing references) //IL_0a50: Expected O, but got Unknown //IL_0a5a: Unknown result type (might be due to invalid IL or missing references) //IL_0a64: Expected O, but got Unknown //IL_0a74: Unknown result type (might be due to invalid IL or missing references) //IL_0a8f: Unknown result type (might be due to invalid IL or missing references) //IL_0a94: Unknown result type (might be due to invalid IL or missing references) //IL_0a9d: Unknown result type (might be due to invalid IL or missing references) //IL_0aa7: Expected O, but got Unknown //IL_0aac: Expected O, but got Unknown //IL_0ab7: Unknown result type (might be due to invalid IL or missing references) //IL_0ad6: Unknown result type (might be due to invalid IL or missing references) //IL_0af9: Unknown result type (might be due to invalid IL or missing references) //IL_0afe: Unknown result type (might be due to invalid IL or missing references) //IL_0b0b: Expected O, but got Unknown //IL_0b0c: Unknown result type (might be due to invalid IL or missing references) //IL_0b11: Unknown result type (might be due to invalid IL or missing references) //IL_0b1c: Unknown result type (might be due to invalid IL or missing references) //IL_0b23: Unknown result type (might be due to invalid IL or missing references) //IL_0b29: Unknown result type (might be due to invalid IL or missing references) //IL_0b33: Expected O, but got Unknown //IL_0b38: Expected O, but got Unknown //IL_0b48: Unknown result type (might be due to invalid IL or missing references) Skin = Object.Instantiate<GUISkin>(GUI.skin); ((Object)Skin).hideFlags = (HideFlags)61; Skin.settings.cursorColor = Accent; Skin.settings.selectionColor = new Color(Accent.r, Accent.g, Accent.b, 0.35f); GUIStyle label = Skin.label; label.fontSize = 15; label.wordWrap = false; label.richText = false; label.padding = new RectOffset(2, 2, 2, 2); SetText(label, Text); GUIStyle button = Skin.button; button.fontSize = 14; button.fontStyle = (FontStyle)1; button.alignment = (TextAnchor)4; button.padding = new RectOffset(14, 14, 8, 8); button.margin = new RectOffset(3, 3, 3, 3); SetBackgrounds(button, 6, Hex(2765122), Hex(3555417), Hex(4608634)); SetText(button, Text); GUIStyle textField = Skin.textField; textField.fontSize = 14; textField.alignment = (TextAnchor)3; textField.padding = new RectOffset(9, 9, 7, 7); textField.margin = new RectOffset(3, 3, 3, 3); textField.clipping = (TextClipping)1; textField.wordWrap = false; Texture2D normal = Rounded(Hex(855829), 6, Hex(2896708)); Texture2D hover = Rounded(Hex(855829), 6, Hex(4542571)); Texture2D val = Rounded(Hex(855829), 6, Accent); SetBackgrounds(textField, 6, normal, hover, val, val); SetText(textField, Text); GUIStyle horizontalSlider = Skin.horizontalSlider; horizontalSlider.normal.background = SliderTrack(); horizontalSlider.hover.background = (horizontalSlider.active.background = (horizontalSlider.focused.background = null)); horizontalSlider.border = new RectOffset(3, 3, 0, 0); horizontalSlider.padding = new RectOffset(0, 0, 0, 0); horizontalSlider.margin = new RectOffset(4, 6, 7, 7); horizontalSlider.overflow = new RectOffset(0, 0, 0, 0); horizontalSlider.fixedHeight = 18f; GUIStyle horizontalSliderThumb = Skin.horizontalSliderThumb; SetBackgrounds(horizontalSliderThumb, 8, Accent, AccentHover, AccentDown); horizontalSliderThumb.border = new RectOffset(0, 0, 0, 0); RectOffset val4 = new RectOffset(0, 0, 0, 0); RectOffset val5 = val4; horizontalSliderThumb.overflow = val4; horizontalSliderThumb.padding = (horizontalSliderThumb.margin = val5); horizontalSliderThumb.fixedWidth = 18f; horizontalSliderThumb.fixedHeight = 18f; GUIStyle verticalScrollbar = Skin.verticalScrollbar; verticalScrollbar.normal.background = Rounded(Hex(1316897), 4); verticalScrollbar.border = new RectOffset(4, 4, 4, 4); verticalScrollbar.padding = new RectOffset(0, 0, 0, 0); verticalScrollbar.margin = new RectOffset(6, 0, 0, 0); verticalScrollbar.fixedWidth = 8f; GUIStyle verticalScrollbarThumb = Skin.verticalScrollbarThumb; SetBackgrounds(verticalScrollbarThumb, 4, Hex(3818070), Hex(5002866), Hex(6056074)); verticalScrollbarThumb.padding = new RectOffset(0, 0, 0, 0); verticalScrollbarThumb.fixedWidth = 8f; GUIStyle[] array = (GUIStyle[])(object)new GUIStyle[2] { Skin.verticalScrollbarUpButton, Skin.verticalScrollbarDownButton }; foreach (GUIStyle val7 in array) { GUIStyleState normal2 = val7.normal; GUIStyleState hover2 = val7.hover; Texture2D val8 = (val7.active.background = null); Texture2D background = (hover2.background = val8); normal2.background = background; val7.fixedHeight = 0f; val7.fixedWidth = 0f; RectOffset val11 = new RectOffset(0, 0, 0, 0); RectOffset margin = val11; val7.padding = val11; val7.margin = margin; } Skin.scrollView.padding = new RectOffset(0, 0, 0, 0); Skin.scrollView.normal.background = null; Window = new GUIStyle { border = new RectOffset(12, 12, 12, 12) }; Window.normal.background = Rounded(new Color(0.063f, 0.075f, 0.102f, 0.97f), 12, Hex(2830914)); Panel = new GUIStyle { border = new RectOffset(10, 10, 10, 10), padding = new RectOffset(12, 12, 12, 12) }; Panel.normal.background = Rounded(Hex(1514276), 10); Title = Derive(label, 30, Accent, (FontStyle)1); Subtitle = Derive(label, 14, Muted, (FontStyle)0); Subtitle.padding = new RectOffset(2, 2, 12, 2); ModTitle = Derive(label, 26, Text, (FontStyle)1); Version = Derive(label, 15, Muted, (FontStyle)0); Version.padding = new RectOffset(4, 2, 12, 2); Body = Derive(label, 15, Text, (FontStyle)0); Body.wordWrap = true; Small = Derive(label, 13, Muted, (FontStyle)0); Small.wordWrap = true; Small.richText = true; FooterNote = Derive(label, 13, Muted, (FontStyle)0); FooterNote.alignment = (TextAnchor)3; Placeholder = Derive(label, 14, new Color(Muted.r, Muted.g, Muted.b, 0.7f), (FontStyle)0); Placeholder.padding = textField.padding; Placeholder.alignment = (TextAnchor)3; SectionTitle = Derive(label, 13, Muted, (FontStyle)1); SectionTitle.padding = new RectOffset(2, 2, 10, 4); SectionHeader = Derive(label, 16, Accent, (FontStyle)1); SectionHeader.margin = new RectOffset(4, 4, 14, 6); SectionHeader.hover.textColor = AccentHover; SectionHeader.active.textColor = AccentDown; FileHeader = Derive(label, 18, Text, (FontStyle)1); FileHeader.margin = new RectOffset(4, 4, 18, 2); SettingName = Derive(label, 15, Text, (FontStyle)1); SettingName.wordWrap = true; ListName = Derive(label, 15, Text, (FontStyle)1); ListName.clipping = (TextClipping)1; ListMeta = Derive(label, 12, Muted, (FontStyle)0); ListMeta.clipping = (TextClipping)1; ListRowSelected = new GUIStyle { border = new RectOffset(8, 8, 8, 8) }; ListRowSelected.normal.background = Rounded(Hex(2634576), 8, Accent); ListRowHover = new GUIStyle { border = new RectOffset(8, 8, 8, 8) }; ListRowHover.normal.background = Rounded(Hex(2172727), 8); Row = new GUIStyle { border = new RectOffset(8, 8, 8, 8), padding = new RectOffset(12, 10, 8, 8), margin = new RectOffset(0, 0, 2, 2) }; Row.normal.background = Rounded(Hex(1777706), 8); RowAlt = new GUIStyle(Row); RowAlt.normal.background = Rounded(Hex(2040881), 8); ButtonSmall = new GUIStyle(button) { fontSize = 13, padding = new RectOffset(10, 10, 6, 6) }; ButtonAccent = new GUIStyle(button) { fontSize = 15 }; SetBackgrounds(ButtonAccent, 6, Accent, AccentHover, AccentDown); SetText(ButtonAccent, Hex(1382173)); ToggleOn = new GUIStyle(button); SetBackgrounds(ToggleOn, 6, Hex(4168291), Hex(4960372), Hex(3507539)); SetText(ToggleOn, Color.white); ToggleOff = new GUIStyle(button); SetBackgrounds(ToggleOff, 6, Hex(3817294), Hex(4672864), Hex(3159103)); SetText(ToggleOff, Muted); ValueBox = new GUIStyle(button) { fontStyle = (FontStyle)0, clipping = (TextClipping)1 }; SetBackgrounds(ValueBox, 6, normal, hover, val); SetText(ValueBox, Text); InvalidField = new GUIStyle(textField); Texture2D val12 = Rounded(Hex(1707536), 6, Bad); SetBackgrounds(InvalidField, 6, val12, val12, val12, val12); SetText(InvalidField, Bad); Badge = Derive(label, 11, Muted, (FontStyle)1); Badge.alignment = (TextAnchor)4; Badge.padding = new RectOffset(7, 7, 3, 3); Badge.margin = new RectOffset(6, 2, 13, 2); Badge.border = new RectOffset(5, 5, 5, 5); Badge.normal.background = Rounded(Hex(3028295), 5); IconBackground = new GUIStyle { border = new RectOffset(9, 9, 9, 9) }; IconBackground.normal.background = Rounded(Color.white, 9); Letter = Derive(label, 18, Color.white, (FontStyle)1); Letter.alignment = (TextAnchor)4; LetterBig = new GUIStyle(Letter) { fontSize = 38 }; Separator = new GUIStyle { fixedHeight = 1f, stretchWidth = true, margin = new RectOffset(0, 0, 12, 4) }; Separator.normal.background = Solid(Hex(2765122)); } private static GUIStyle Derive(GUIStyle baseStyle, int size, Color color, FontStyle fontStyle = (FontStyle)0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_001c: Expected O, but got Unknown GUIStyle val = new GUIStyle(baseStyle) { fontSize = size, fontStyle = fontStyle }; SetText(val, color); return val; } private static void SetText(GUIStyle style, Color color) { //IL_0018: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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_002a: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) GUIStyleState normal = style.normal; GUIStyleState hover = style.hover; GUIStyleState active = style.active; Color val = (style.focused.textColor = color); Color val3 = (active.textColor = val); Color textColor = (hover.textColor = val3); normal.textColor = textColor; GUIStyleState onNormal = style.onNormal; GUIStyleState onHover = style.onHover; GUIStyleState onActive = style.onActive; val = (style.onFocused.textColor = color); val3 = (onActive.textColor = val); textColor = (onHover.textColor = val3); onNormal.textColor = textColor; } private static void SetBackgrounds(GUIStyle style, int radius, Color normal, Color hover, Color active) { //IL_0002: 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_0022: Unknown result type (might be due to invalid IL or missing references) SetBackgrounds(style, radius, Rounded(normal, radius), Rounded(hover, radius), Rounded(active, radius)); } private static void SetBackgrounds(GUIStyle style, int radius, Texture2D normal, Texture2D hover, Texture2D active, Texture2D focused = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown style.border = new RectOffset(radius, radius, radius, radius); style.normal.background = normal; style.hover.background = hover; style.active.background = active; style.focused.background = focused ?? normal; style.onNormal.background = active; style.onHover.background = active; style.onActive.background = active; style.onFocused.background = focused ?? active; } private static Color Hex(int rgb) { //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) return Color32.op_Implicit(new Color32((byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb, byte.MaxValue)); } private static Texture2D NewTexture(int width, int height) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown return new Texture2D(width, height, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; } private static Texture2D Solid(Color color) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Texture2D obj = NewTexture(1, 1); obj.SetPixel(0, 0, color); obj.Apply(); return obj; } private static Texture2D Rounded(Color fill, int radius, Color? outline = null) { //IL_0040: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_0087: 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) int num = radius * 2 + 2; Texture2D val = NewTexture(num, num); Color[] array = (Color[])(object)new Color[num * num]; Vector2 val2 = default(Vector2); Vector2 val3 = default(Vector2); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { ((Vector2)(ref val2))..ctor((float)j + 0.5f, (float)i + 0.5f); ((Vector2)(ref val3))..ctor(Mathf.Clamp(val2.x, (float)radius, (float)(num - radius)), Mathf.Clamp(val2.y, (float)radius, (float)(num - radius))); float num2 = Vector2.Distance(val2, val3); Color val4 = fill; if (outline.HasValue) { val4 = Color.Lerp(outline.Value, fill, Mathf.Clamp01((float)radius - 1f - num2 + 0.5f)); } val4.a *= Mathf.Clamp01((float)radius - num2 + 0.5f); array[i * num + j] = val4; } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D ArrowCursor() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01a9: Unknown result type (might be due to invalid IL or missing references) Vector2[] polygon = (Vector2[])(object)new Vector2[7] { new Vector2(0.5f, 0.5f), new Vector2(0.5f, 21f), new Vector2(5.5f, 16.5f), new Vector2(9f, 24f), new Vector2(12f, 22.5f), new Vector2(8.5f, 15f), new Vector2(15f, 15f) }; bool[,] array = new bool[16, 25]; for (int i = 0; i < 25; i++) { for (int j = 0; j < 16; j++) { array[j, i] = Contains(polygon, new Vector2((float)j + 0.5f, (float)i + 0.5f)); } } Texture2D val = NewTexture(16, 25); ((Texture)val).filterMode = (FilterMode)0; Color[] array2 = (Color[])(object)new Color[400]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.05f, 0.05f, 0.07f, 1f); for (int k = 0; k < 25; k++) { for (int l = 0; l < 16; l++) { Color val3 = Color.clear; if (array[l, k]) { val3 = ((l == 0 || k == 0 || l == 15 || k == 24 || !array[l - 1, k] || !array[l + 1, k] || !array[l, k - 1] || !array[l, k + 1]) ? val2 : Color.white); } array2[(24 - k) * 16 + l] = val3; } } val.SetPixels(array2); val.Apply(); return val; } private static bool Contains(Vector2[] polygon, Vector2 p) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) bool flag = false; int num = 0; int num2 = polygon.Length - 1; while (num < polygon.Length) { if (polygon[num].y > p.y != polygon[num2].y > p.y && p.x < (polygon[num2].x - polygon[num].x) * (p.y - polygon[num].y) / (polygon[num2].y - polygon[num].y) + polygon[num].x) { flag = !flag; } num2 = num++; } return flag; } private static Texture2D SliderTrack() { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = NewTexture(8, 18); Color[] array = (Color[])(object)new Color[144]; Color val2 = Hex(3818070); for (int i = 0; i < 18; i++) { for (int j = 0; j < 8; j++) { array[i * 8 + j] = ((i >= 7 && i <= 10) ? val2 : Color.clear); } } val.SetPixels(array); val.Apply(); return val; } } internal sealed class ModMenuWindow : MonoBehaviour { private sealed class VisibleGroup { public SettingGroup Group; public List<SettingRow> Rows; public bool ShowFileName; } private static readonly KeyCode[] ModifierKeys; private ModMenuStyles styles; private List<ModEntry> mods; private readonly List<ModEntry> visibleMods = new List<ModEntry>(); private int hiddenLibraries; private ModEntry selected; private string selectedConfigPath; private List<SettingGroup> groups = new List<SettingGroup>(); private readonly List<VisibleGroup> visibleGroups = new List<VisibleGroup>(); private int settingCount; private string modSearch = ""; private string settingSearch = ""; private bool onlyWithSettings; private Vector2 listScroll; private Vector2 detailScroll; private ModEntry pendingSelect; private SettingGroup pendingCollapseToggle; private bool modFilterDirty; private bool settingFilterDirty; private const int CollapseThreshold = 60; private readonly HashSet<SettingGroup> collapsed = new HashSet<SettingGroup>(); private bool settingFilterActive; private Object owner; private bool hasOwner; private bool waitingForPauseScreen; private float waitingSince; private bool inputBlocked; private bool pauseWasAllowed; private GameObject overlay; private CanvasGroup ownerGroup; private bool ownerGroupAdded; private bool ownerGroupInteractable; private bool ownerGroupBlocksRaycasts; private readonly List<KeyValuePair<MPEventSystem, bool>> navigationStates = new List<KeyValuePair<MPEventSystem, bool>>(); private static readonly FieldInfo CursorIndicatorField; private Image gameCursor; private bool gameCursorUnusable; private readonly Vector3[] cursorCorners = (Vector3[])(object)new Vector3[4]; private ConfigEntryBase capturingKey; private readonly Dictionary<ConfigEntryBase, string> controlNames = new Dictionary<ConfigEntryBase, string>(); private readonly Dictionary<ConfigEntryBase, string> textBuffers = new Dictionary<ConfigEntryBase, string>(); private readonly HashSet<ConfigEntryBase> invalidText = new HashSet<ConfigEntryBase>(); public bool IsOpen { get; private set; } public void Toggle() { if (IsOpen) { Close(); } else { OpenFromHotkey(); } } public void Open(Object menuOwner) { if (IsOpen) { return; } owner = menuOwner; hasOwner = menuOwner != (Object)null; if (mods == null) { mods = ModCatalog.Build(); } foreach (ModEntry mod in mods) { ModCatalog.RefreshSettings(mod); } modFilterDirty = true; pendingSelect = selected; IsOpen = true; SetGameInputBlocked(blocked: true); } public void Close() { if (IsOpen) { IsOpen = false; capturingKey = null; textBuffers.Clear(); invalidText.Clear(); GUIUtility.keyboardControl = 0; ConfigWriter.Flush(); SetGameInputBlocked(blocked: false); owner = null; hasOwner = false; } } private void OpenFromHotkey() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 MainMenuController instance = MainMenuController.instance; if (Object.op_Implicit((Object)(object)instance)) { Open((Object)(object)instance); return; } PauseScreenController val = FirstPauseScreen(); if (Object.op_Implicit((Object)(object)val)) { Open((Object)(object)val); } else if ((int)Cursor.lockState == 1) { PauseManager.TogglePauseScreen(); waitingForPauseScreen = true; waitingSince = Time.unscaledTime; } else { Open(null); } } private static PauseScreenController FirstPauseScreen() { List<PauseScreenController> instancesList = PauseScreenController.instancesList; if (instancesList == null) { return null; } foreach (PauseScreenController item in instancesList) { if (Object.op_Implicit((Object)(object)item)) { return item; } } return null; } private void Update() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (IsOpen && hasOwner && !Object.op_Implicit(owner)) { Close(); } if (waitingForPauseScreen) { PauseScreenController val = FirstPauseScreen(); if (Object.op_Implicit((Object)(object)val)) { waitingForPauseScreen = false; Open((Object)(object)val); } else if (Time.unscaledTime - waitingSince > 2f) { waitingForPauseScreen = false; } } if (capturingKey == null && IsShortcutDown(NotModMenuPlugin.Instance.OpenKey.Value)) { Toggle(); } } private static bool IsShortcutDown(KeyboardShortcut shortcut) { //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_0029: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0 || !Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } private void OnApplicationQuit() { ConfigWriter.Flush(); } private void OnDestroy() { ConfigWriter.Flush(); SetGameInputBlocked(blocked: false); } private void SetGameInputBlocked(bool blocked) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (blocked == inputBlocked) { return; } inputBlocked = blocked; if (blocked) { pauseWasAllowed = PauseManager.IsAbleToPause; PauseManager.IsAbleToPause = false; overlay = new GameObject("NotModMenuOverlay"); Object.DontDestroyOnLoad((Object)(object)overlay); Canvas obj = overlay.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 30000; overlay.AddComponent<GraphicRaycaster>(); Image obj2 = overlay.AddComponent<Image>(); ((Graphic)obj2).color = new Color(0f, 0f, 0f, 0.6f); ((Graphic)obj2).raycastTarget = true; Object obj3 = owner; Component val = (Component)(object)((obj3 is Component) ? obj3 : null); if (val != null) { ownerGroup = val.GetComponent<CanvasGroup>(); ownerGroupAdded = !Object.op_Implicit((Object)(object)ownerGroup); if (ownerGroupAdded) { ownerGroup = val.gameObject.AddComponent<CanvasGroup>(); } ownerGroupInteractable = ownerGroup.interactable; ownerGroupBlocksRaycasts = ownerGroup.blocksRaycasts; ownerGroup.interactable = false; ownerGroup.blocksRaycasts = false; } navigationStates.Clear(); { foreach (MPEventSystem readOnlyInstances in MPEventSystem.readOnlyInstancesList) { if (Object.op_Implicit((Object)(object)readOnlyInstances)) { navigationStates.Add(new KeyValuePair<MPEventSystem, bool>(readOnlyInstances, ((EventSystem)readOnlyInstances).sendNavigationEvents)); ((EventSystem)readOnlyInstances).sendNavigationEvents = false; } } return; } } PauseManager.IsAbleToPause = pauseWasAllowed; if (Object.op_Implicit((Object)(object)overlay)) { Object.Destroy((Object)(object)overlay); } overlay = null; if (Object.op_Implicit((Object)(object)ownerGroup)) { if (ownerGroupAdded) { Object.Destroy((Object)(object)ownerGroup); } else { ownerGroup.interactable = ownerGroupInteractable; ownerGroup.blocksRaycasts = ownerGroupBlocksRaycasts; } } ownerGroup = null; foreach (KeyValuePair<MPEventSystem, bool> navigationState in navigationStates) { if (Object.op_Implicit((Object)(object)navigationState.Key)) { ((EventSystem)navigationState.Key).sendNavigationEvents = navigationState.Value; } } navigationStates.Clear(); } private void ApplyPendingChanges() { if (modFilterDirty) { modFilterDirty = false; RebuildVisibleMods(); if (selected == null && pendingSelect == null) { pendingSelect = visibleMods.FirstOrDefault((ModEntry m) => !m.IsBuiltIn) ?? visibleMods.FirstOrDefault(); } } if (pendingSelect != null) { ModEntry mod = pendingSelect; pendingSelect = null; Select(mod); } if (pendingCollapseToggle != null) { if (!collapsed.Remove(pendingCollapseToggle)) { collapsed.Add(pendingCollapseToggle); } pendingCollapseToggle = null; } if (settingFilterDirty) { settingFilterDirty = false; RebuildVisibleSettings(); } } private void RebuildVisibleMods() { visibleMods.Clear(); hiddenLibraries = 0; string text = modSearch.Trim().ToLowerInvariant(); bool flag = NotModMenuPlugin.Instance.ShowLibraries.Value || text.Length > 0; foreach (ModEntry mod in mods) { if ((text.Length <= 0 || mod.SearchText.Contains(text)) && (!onlyWithSettings || mod.SettingCount != 0)) { if (mod.IsLibrary && !flag) { hiddenLibraries++; } else { visibleMods.Add(mod); } } } } private void Select(ModEntry mod) { //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 (mod != selected) { ConfigWriter.Flush(); } selected = mod; detailScroll = Vector2.zero; settingSearch = ""; capturingKey = null; textBuffers.Clear(); invalidText.Clear(); GUIUtility.keyboardControl = 0; groups = ((mod != null) ? SettingsModel.Build(mod) : new List<SettingGroup>()); settingCount = groups.Sum((SettingGroup g) => g.Rows.Count); selectedConfigPath = mod?.ConfigFiles.Select((ConfigFile f) => f.ConfigFilePath).FirstOrDefault(File.Exists); collapsed.Clear(); if (settingCount > 60) { foreach (SettingGroup item in groups.Skip(1)) { if (!string.IsNullOrEmpty(item.Section)) { collapsed.Add(item); } } } RebuildVisibleSettings(); } private void RebuildVisibleSettings() { visibleGroups.Clear(); string query = settingSearch.Trim().ToLowerInvariant(); settingFilterActive = query.Length > 0; string text = null; foreach (SettingGroup group in groups) { List<SettingRow> list = ((query.Length == 0) ? group.Rows : group.Rows.Where((SettingRow r) => r.SearchText.Contains(query)).ToList()); if (list.Count != 0) { visibleGroups.Add(new VisibleGroup { Group = group, Rows = list, ShowFileName = (group.FileName != null && group.FileName != text) }); text = group.FileName; } } } private void OnGUI() { //IL_0213: 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: Invalid comparison between Unknown and I4 //IL_0075: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) if (!IsOpen) { return; } if (styles == null) { styles = new ModMenuStyles(); } GUI.skin = styles.Skin; GUI.depth = -1000; if ((int)Event.current.type == 8) { ModCatalog.ResetIconBudget(); ApplyPendingChanges(); } float num = Mathf.Max(0.5f, (float)Screen.height / 1080f * NotModMenuPlugin.Instance.UiScale.Value); Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); try { if (!HandleKeyboard()) { return; } float num2 = (float)Screen.width / num; float num3 = (float)Screen.height / num; float num4 = Mathf.Min(num2 - 60f, 1500f); float num5 = Mathf.Min(num3 - 60f, 900f); Rect val = default(Rect); ((Rect)(ref val))..ctor((num2 - num4) / 2f, (num3 - num5) / 2f, num4, num5); GUI.Box(val, GUIContent.none, styles.Window); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x + 22f, ((Rect)(ref val)).y + 16f, ((Rect)(ref val)).width - 44f, ((Rect)(ref val)).height - 32f); GUILayout.BeginArea(val2); DrawHeader(); GUILayout.Space(8f); float num6 = Mathf.Clamp(((Rect)(ref val2)).width * 0.3f, 290f, 400f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); DrawModList(num6); GUILayout.Space(14f); DrawDetails(((Rect)(ref val2)).width - num6 - 14f); GUILayout.EndHorizontal(); GUILayout.Space(10f); DrawFooter(); GUILayout.EndArea(); } catch (Exception ex) when (!(ex is ExitGUIException)) { NotModMenuPlugin.Log.LogError((object)$"The mod menu hit an error and was closed: {ex}"); Close(); } finally { GUI.matrix = matrix; } if (IsOpen) { DrawCursor(); } } private void DrawCursor() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_006b: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type == 7 && (gameCursorUnusable || !TryDrawGameCursor())) { Vector2 mousePosition = Event.current.mousePosition; Texture2D fallbackCursor = styles.FallbackCursor; float num = Mathf.Max(1f, (float)Screen.height / 1080f); GUI.DrawTexture(new Rect(mousePosition.x, mousePosition.y, (float)((Texture)fallbackCursor).width * num, (float)((Texture)fallbackCursor).height * num), (Texture)(object)fallbackCursor); } } private bool TryDrawGameCursor() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) try { if (!Object.op_Implicit((Object)(object)gameCursor)) { gameCursor = FindGameCursor(); } if (!Object.op_Implicit((Object)(object)gameCursor) || !((Behaviour)gameCursor).isActiveAndEnabled || !Object.op_Implicit((Object)(object)gameCursor.sprite)) { return false; } ((Graphic)gameCursor).rectTransform.GetWorldCorners(cursorCorners); Canvas canvas = ((Graphic)gameCursor).canvas; Camera obj = ((Object.op_Implicit((Object)(object)canvas) && (int)canvas.renderMode != 0) ? canvas.worldCamera : null); Vector2 val = RectTransformUtility.WorldToScreenPoint(obj, cursorCorners[0]); Vector2 val2 = RectTransformUtility.WorldToScreenPoint(obj, cursorCorners[2]); Sprite sprite = gameCursor.sprite; Texture2D texture = sprite.texture; Rect textureRect = sprite.textureRect; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height); Color color = GUI.color; GUI.color = ((Graphic)gameCursor).color; GUI.DrawTextureWithTexCoords(Rect.MinMaxRect(val.x, (float)Screen.height - val2.y, val2.x, (float)Screen.height - val.y), (Texture)(object)texture, val3); GUI.color = color; return true; } catch (Exception ex) { gameCursorUnusable = true; NotModMenuPlugin.Log.LogDebug((object)("Using the fallback cursor: " + ex.Message)); return false; } } private static Image FindGameCursor() { MPEventSystem kbmEventSystem = MPEventSystemManager.kbmEventSystem; if (!Object.op_Implicit((Object)(object)kbmEventSystem) || CursorIndicatorField == null) { return null; } object? value = CursorIndicatorField.GetValue(kbmEventSystem); CursorIndicatorController val = (CursorIndicatorController)((value is CursorIndicatorController) ? value : null); GameObject val2 = (Object.op_Implicit((Object)(object)val) ? val.mouseCursorSet.pointerObject : null); if (!Object.op_Implicit((Object)(object)val2)) { return null; } return val2.GetComponentInChildren<Image>(true); } private bool HandleKeyboard() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if ((int)current.type != 4 || (int)current.keyCode == 0) { return true; } if (capturingKey != null) { if ((int)current.keyCode == 27) { capturingKey = null; } else if (Array.IndexOf(ModifierKeys, current.keyCode) < 0) { ApplyCapturedKey(current.keyCode); } current.Use(); return true; } if ((int)current.keyCode == 27) { current.Use(); if (GUIUtility.keyboardControl != 0) { GUIUtility.keyboardControl = 0; return true; } Close(); return false; } return true; } private void DrawHeader() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("MODS", styles.Title, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); string text = $"{Chainloader.PluginInfos.Count} mods loaded"; if (hiddenLibraries > 0) { text += $" · {hiddenLibraries} libraries hidden"; } GUILayout.Label(text, styles.Subtitle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(40f), GUILayout.Height(36f) })) { Close(); } GUILayout.EndHorizontal(); } private void DrawFooter() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Changes are saved when you close this menu. Some settings only take effect after restarting the game.", styles.FooterNote, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }); GUILayout.FlexibleSpace(); if (GUILayout.Button("Done", styles.ButtonAccent, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(150f), GUILayout.Height(38f) })) { Close(); } GUILayout.EndHorizontal(); } private void DrawModList(float width) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) NotModMenuPlugin instance = NotModMenuPlugin.Instance; GUILayout.BeginVertical(styles.Panel, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(width), GUILayout.ExpandHeight(true) }); string text = SearchField("nmm.modsearch", modSearch, "Search mods..."); if (text != modSearch) { modSearch = text; modFilterDirty = true; } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); bool value = instance.ShowLibraries.Value; if (GUILayout.Button("Libraries", value ? styles.ToggleOn : styles.ToggleOff, Array.Empty<GUILayoutOption>())) { ConfigWriter.Set((ConfigEntryBase)(object)instance.ShowLibraries, !value); modFilterDirty = true; } if (GUILayout.Button("Has settings", onlyWithSettings ? styles.ToggleOn : styles.ToggleOff, Array.Empty<GUILayoutOption>())) { onlyWithSettings = !onlyWithSettings; modFilterDirty = true; } GUILayout.EndHorizontal(); GUILayout.Space(6f); listScroll = GUILayout.BeginScrollView(listScroll, GUIStyle.none, styles.Skin.verticalScrollbar, Array.Empty<GUILayoutOption>()); foreach (ModEntry visibleMod in visibleMods) { DrawModRow(visibleMod); } if (visibleMods.Count == 0) { GUILayout.Label("No mods match.", styles.Small, Array.Empty<GUILayoutOption>()); } GUILayout.EndScrollView(); GUILayout.EndVertical(); } private void DrawModRow(ModEntry mod) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0037: 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) Rect rect = GUILayoutUtility.GetRect(10f, 54f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); Event current = Event.current; if ((int)current.type == 7) { if (mod == selected) { GUI.Box(rect, GUIContent.none, styles.ListRowSelected); } else if (((Rect)(ref rect)).Contains(current.mousePosition)) { GUI.Box(rect, GUIContent.none, styles.ListRowHover); } } Rect rect2 = default(Rect); ((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 8f, 38f, 38f); DrawIcon(rect2, mod, styles.Letter); float num = ((Rect)(ref rect2)).xMax + 10f; float num2 = ((Rect)(ref rect)).xMax - num - 8f; GUI.Label(new Rect(num, ((Rect)(ref rect)).y + 7f, num2, 22f), mod.Name, styles.ListName); GUI.Label(new Rect(num, ((Rect)(ref rect)).y + 29f, num2, 18f), ModMeta(mod), styles.ListMeta); if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) { pendingSelect = mod; } GUILayout.Space(2f); } private static string ModMeta(ModEntry mod) { List<string> list = new List<string>(4); if (!string.IsNullOrEmpty(mod.Version)) { list.Add("v" + mod.Version); } if (!string.IsNullOrEmpty(mod.Author)) { list.Add(mod.Author); } if (mod.SettingCount > 0) { list.Add((mod.SettingCount == 1) ? "1 setting" : (mod.SettingCount + " settings")); } if (mod.IsLibrary) { list.Add("library"); } return string.Join(" · ", list); } private void DrawIcon(Rect rect, ModEntry mod, GUIStyle letterStyle) { //IL_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Texture2D icon = ModCatalog.GetIcon(mod); if ((Object)(object)icon != (Object)null) { GUI.DrawTexture(rect, (Texture)(object)icon, (ScaleMode)2); return; } Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = mod.Tint; GUI.Box(rect, GUIContent.none, styles.IconBackground); GUI.backgroundColor = backgroundColor; GUI.Label(rect, mod.Initial, letterStyle); } private void DrawDetails(float width) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(styles.Panel, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(width), GUILayout.ExpandHeight(true) }); if (selected == null) { GUILayout.Label("Select a mod on the left.", styles.Body, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); return; } detailScroll = GUILayout.BeginScrollView(detailScroll, GUIStyle.none, styles.Skin.verticalScrollbar, Array.Empty<GUILayoutOption>()); float width2 = width - 24f - 18f; DrawModInfo(selected, width2); DrawSettings(width2); GUILayout.EndScrollView(); GUILayout.EndVertical(); } private void DrawModInfo(ModEntry mod, float width) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) float num = width - 88f - 16f; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Rect rect = GUILayoutUtility.GetRect(88f, 88f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(88f), GUILayout.Height(88f) }); DrawIcon(rect, mod, styles.LetterBig); GUILayout.Space(16f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(mod.Name, styles.ModTitle, Array.Empty<GUILayoutOption>()); if (!string.IsNullOrEmpty(mod.Version)) { GUILayout.Label("v" + mod.Version, styles.Version, Array.Empty<GUILayoutOption>()); } if (mod.IsLibrary) { GUILayout.Label("LIBRARY", styles.Badge, Array.Empty<GUILayoutOption>()); } if (mod.IsBuiltIn) { GUILayout.Label("BUILT-IN", styles.Badge, Array.Empty<GUILayoutOption>()); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Label(string.IsNullOrEmpty(mod.Author) ? mod.Guid : ("by " + mod.Author + " · " + mod.Guid), styles.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) }); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (IsWebUrl(mod.WebsiteUrl) && GUILayout.Button("Website", styles.ButtonSmall, Array.Empty<GUILayoutOption>())) { Application.OpenURL(mod.WebsiteUrl); } if (mod.ThunderstoreUrl != null && GUILayout.Button("Thunderstore", styles.ButtonSmall, Array.Empty<GUILayoutOption>())) { Application.OpenURL(mod.ThunderstoreUrl); } if (mod.Folder != null && GUILayout.Button("Open folder", styles.ButtonSmall, Array.Empty<GUILayoutOption>())) { ShowInExplorer(mod.Folder, selectFile: false); } if (selectedConfigPath != null && GUILayout.Button("Config file", styles.ButtonSmall, Array.Empty<GUILayoutOption>())) { ShowInExplorer(selectedConfigPath, selectFile: true); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(mod.Description)) { GUILayout.Space(10f); GUILayout.Label(mod.Description, styles.Body, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); } if (mod.Requires.Count > 0) { GUILayout.Space(6f); GUILayout.Label("<b>Requires:</b> " + string.Join(", ", mod.Requires), styles.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); } if (mod.RequiredBy.Count > 0) { GUILayout.Space(2f); GUILayout.Label("<b>Required by:</b> " + string.Join(", ", mod.RequiredBy), styles.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); } GUILayout.Box(GUIContent.none, styles.Separator, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); } private void DrawSettings(float width) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); GUILayout.Label((settingCount > 0) ? $"SETTINGS ({settingCount})" : "SETTINGS", styles.SectionTitle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (settingCount > 6) { string text = SearchField("nmm.settingsearch", settingSearch, "Filter settings...", 260f); if (text != settingSearch) { settingSearch = text; settingFilterDirty = true; } } GUILayout.EndHorizontal(); if (settingCount == 0) { GUILayout.Label("This mod has no settings.", styles.Body, Array.Empty<GUILayoutOption>()); return; } if (visibleGroups.Count == 0) { GUILayout.Label("No settings match.", styles.Body, Array.Empty<GUILayoutOption>()); return; } float num = Mathf.Clamp(width * 0.4f, 230f, 400f); float labelWidth = width - num - 64f - 22f - 16f; int num2 = 0; foreach (VisibleGroup visibleGroup in visibleGroups) { SettingGroup settingGroup = visibleGroup.Group; if (visibleGroup.ShowFileName) { GUILayout.Label(settingGroup.FileName, styles.FileHeader, Array.Empty<GUILayoutOption>()); } bool flag = !settingFilterActive && collapsed.Contains(settingGroup); if (!string.IsNullOrEmpty(settingGroup.Section) && GUILayout.Button(flag ? $"► {settingGroup.Section} ({visibleGroup.Rows.Count})" : ("▼ " + settingGroup.Section), styles.SectionHeader, Array.Empty<GUILayoutOption>())) { pendingCollapseToggle = settingGroup; } if (flag) { continue; } foreach (SettingRow row in visibleGroup.Rows) { DrawSettingRow(row, labelWidth, num, 64f, num2++ % 2 == 1); } } } private void DrawSettingRow(SettingRow row, float labelWidth, float controlWidth, float resetWidth, bool alternate) { ConfigEntryBase entry = row.Entry; bool enabled = GUI.enabled; GUILayout.BeginHorizontal(alternate ? styles.RowAlt : styles.Row, Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(labelWidth) }); GUILayout.Label(row.Name, styles.SettingName, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(labelWidth) }); if (!string.IsNullOrEmpty(row.Description)) { GUILayout.Label(row.Description, styles.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(labelWidth) }); } GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(controlWidth) }); GUI.enabled = enabled && !row.ReadOnly; DrawControl(entry, controlWidth); GUI.enabled = enabled; GUILayout.EndVertical(); GUILayout.Space(8f); GUI.enabled = enabled && !row.ReadOnly && !ValueUtil.IsDefault(entry); if (GUILayout.Button("Reset", styles.ButtonSmall, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(resetWidth) })) { ConfigWriter.Set(entry, entry.DefaultValue); textBuffers.Remove(entry); invalidText.Remove(entry); if (capturingKey == entry) { capturingKey = null; } GUIUtility.keyboardControl = 0; } GUI.enabled = enabled; GUILayout.EndHorizontal(); } private void DrawControl(ConfigEntryBase entry, float width) { Type settingType = entry.SettingType; ConfigDescription description = entry.Description; AcceptableValueBase acceptable = ((description != null) ? description.AcceptableValues : null); object[] values; double min; double max; if (settingType == typeof(bool)) { object boxedValue = entry.BoxedValue; bool flag = default(bool); int num; if (boxedValue is bool) { flag = (bool)boxedValue; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; if (GUILayout.Button(flag2 ? "ON" : "OFF", flag2 ? styles.ToggleOn : styles.ToggleOff, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) })) { ConfigWriter.Set(entry, !flag2); } } else if (settingType == typeof(KeyboardShortcut) || settingType == typeof(KeyCode)) { DrawKeyControl(entry, width); } else if (ValueUtil.TryGetList(acceptable, out values)) { DrawCycle(entry, values, width); } else if (settingType.IsEnum && !ValueUtil.IsFlags(settingType)) { DrawCycle(entry, ValueUtil.EnumValues(settingType), width); } else if (ValueUtil.IsNumeric(settingType) && ValueUtil.TryGetRange(acceptable, out min, out max)) { DrawSlider(entry, min, max, width); } else if (settingType == typeof(Color)) { DrawColor(entry, width); } else if (settingType == typeof(string) || TomlTypeConverter.CanConvert(settingType)) { DrawTextField(entry, width); } else { GUILayout.Label(ValueUtil.Display(entry.BoxedValue), styles.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); } } private void DrawCycle(ConfigEntryBase entry, object[] options, float width) { int num = options.Length; if (num == 0) { GUILayout.Label(ValueUtil.Display(entry.BoxedValue), styles.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); return; } int num2 = -1; for (int i = 0; i < num; i++) { if (object.Equals(options[i], entry.BoxedValue)) { num2 = i; break; } } GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); if (GUILayout.Button("<", styles.ButtonSmall, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(36f) })) { ConfigWriter.Set(entry, options[(num2 <= 0) ? (num - 1) : (num2 - 1)]); } if (GUILayout.Button(ValueUtil.Display((num2 >= 0) ? options[num2] : entry.BoxedValue), styles.ValueBox, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { ConfigWriter.Set(entry, options[(num2 + 1) % num]); } if (GUILayout.Button(">", styles.ButtonSmall, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(36f) })) { ConfigWriter.Set(entry, options[(num2 + 1) % num]); } GUILayout.EndHorizontal(); } private void DrawSlider(ConfigEntryBase entry, double min, double max, float width) { float num = (float)ValueUtil.ToDouble(entry.BoxedValue); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); float num2 = GUILayout.HorizontalSlider(num, (float)min, (float)max, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width - 82f - 16f) }); if (num2 != num) { object obj = ValueUtil.FromSlider(num2, entry.SettingType, min, max); if (!object.Equals(obj, entry.BoxedValue)) { ConfigWriter.Set(entry, obj); textBuffers.Remove(entry); invalidText.Remove(entry); } } DrawTextField(entry, 82f); GUILayout.EndHorizontal(); } private void DrawColor(ConfigEntryBase entry, float width) { //IL_003e: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); Rect rect = GUILayoutUtility.GetRect(30f, 30f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(30f), GUILayout.Height(30f) }); if ((int)Event.current.type == 7 && entry.BoxedValue is Color val) { Color color = GUI.color; GUI.color = new Color(val.r, val.g, val.b, 1f); GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } GUILayout.Space(6f); DrawTextField(entry, width - 30f - 12f); GUILayout.EndHorizontal(); } private void DrawTextField(ConfigEntryBase entry, float width) { if (!controlNames.TryGetValue(entry, out var value)) { value = "nmm.field." + controlNames.Count; controlNames[entry] = value; } bool flag = GUI.GetNameOfFocusedControl() == value; if (!flag || !textBuffers.TryGetValue(entry, out var value2)) { value2 = ValueUtil.ToText(entry); if (!flag) { textBuffers.Remove(entry); invalidText.Remove(entry); } } GUI.SetNextControlName(value); GUIStyle val = (invalidText.Contains(entry) ? styles.InvalidField : styles.Skin.textField); string text = GUILayout.TextField(value2, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); if (text == value2) { return; } textBuffers[entry] = text; if (ValueUtil.TryParse(entry, text, out var value3)) { invalidText.Remove(entry); if (!object.Equals(value3, entry.BoxedValue)) { ConfigWriter.Set(entry, value3); } } else { invalidText.Add(entry); } } private void DrawKeyControl(ConfigEntryBase entry, float width) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) bool flag = capturingKey == entry; string text = (flag ? "Press a key... (Esc cancels)" : KeyText(entry.BoxedValue)); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); if (GUILayout.Button(text, flag ? styles.ButtonAccent : styles.ValueBox, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { capturingKey = (flag ? null : entry); GUIUtility.keyboardControl = 0; } if (GUILayout.Button("Clear", styles.ButtonSmall, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(62f) })) { ConfigWriter.Set(entry, (entry.SettingType == typeof(KeyCode)) ? ((object)(KeyCode)0) : ((object)KeyboardShortcut.Empty)); capturingKey = null; } GUILayout.EndHorizontal(); } private void ApplyCapturedKey(KeyCode key) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) ConfigEntryBase val = capturingKey; capturingKey = null; if (val.SettingType == typeof(KeyCode)) { ConfigWriter.Set(val, key); return; } KeyCode[] array = ModifierKeys.Where((KeyCode m) => m != key && Input.GetKey(m)).ToArray(); ConfigWriter.Set(val, (object)new KeyboardShortcut(key, array)); } private unsafe static string KeyText(object value) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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 (!(value is KeyboardShortcut val)) { if (value is KeyCode val2) { if ((int)val2 != 0) { return ((object)(*(KeyCode*)(&val2))/*cast due to .constrained prefix*/).ToString(); } return "Not set"; } return ValueUtil.Display(value); } if ((int)((KeyboardShortcut)(ref val)).MainKey != 0) { return ((object)(*(KeyboardShortcut*)(&val))/*cast due to .constrained prefix*/).ToString(); } return "Not set"; } private string SearchField(string name, string text, string placeholder, float width = -1f) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) GUI.SetNextControlName(name); string text2 = ((width > 0f) ? GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }) : GUILayout.TextField(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })); if ((int)Event.current.type == 7 && text2.Length == 0 && GUI.GetNameOfFocusedControl() != name) { GUI.Label(GUILayoutUtility.GetLastRect(), placeholder, styles.Placeholder); } return text2; } private static bool IsWebUrl(string url) { if (!string.IsNullOrEmpty(url) && Uri.TryCreate(url, UriKind.Absolute, out Uri result)) { if (!(result.Scheme == Uri.UriSchemeHttp)) { return result.Scheme == Uri.UriSchemeHttps; } return true; } return false; } private static void ShowInExplorer(string path, bool selectFile) { try { Process.Start("explorer.exe", selectFile ? ("/select,\"" + path + "\"") : ("\"" + path + "\"")); } catch (Exception ex) { NotModMenuPlugin.Log.LogWarning((object)("Could not open " + path + ": " + ex.Message)); } } static ModMenuWindow() { KeyCode[] array = new KeyCode[6]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); ModifierKeys = (KeyCode[])(object)array; CursorIndicatorField = typeof(MPEventSystem).GetField("cursorIndicatorController", BindingFlags.Instance | BindingFlags.NonPublic); } } [BepInPlugin("com.NotTerra.NotModMenu", "NotModMenu", "1.0.0")] public class NotModMenuPlugin : BaseUnityPlugin { public const string PluginGUID = "com.NotTerra.NotModMenu"; public const string PluginName = "NotModMenu"; public const string PluginVersion = "1.0.0"; internal ConfigEntry<KeyboardShortcut> OpenKey; internal ConfigEntry<bool> ShowInMainMenu; internal ConfigEntry<bool> ShowInPauseMenu; internal ConfigEntry<bool> ShowLibraries; internal ConfigEntry<float> UiScale; internal static NotModMenuPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal ModMenuWindow Window { get; private set; } private void Awake() { //IL_002c: 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_00dc: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; OpenKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Open key", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Opens or closes the mod menu. During a run it opens the pause menu first."); ShowInMainMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Main menu button", true, "Show the MODS button in the main menu."); ShowInPauseMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Pause menu button", true, "Show the MODS button in the pause menu."); ShowLibraries = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "Show libraries", false, "List library mods too (mods that other mods require, e.g. R2API modules). Libraries always show up in search results."); UiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Interface", "Scale", 1f, new ConfigDescription("Size of the mod menu.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 1.6f), Array.Empty<object>())); Window = ((Component)this).gameObject.AddComponent<ModMenuWindow>(); ((Component)this).gameObject.AddComponent<MenuButtonInjector>(); } } internal sealed class SettingRow { public ConfigEntryBase Entry; public string Name; public string Description; public bool ReadOnly; public int Order; public string SearchText; } internal sealed class SettingGroup { public string Section; public string FileName; public List<SettingRow> Rows = new List<SettingRow>(); } internal static class SettingsModel { public static List<SettingGroup> Build(ModEntry mod) { List<SettingGroup> list = new List<SettingGroup>(); bool flag = mod.ConfigFiles.Count > 1; foreach (ConfigFile configFile in mod.ConfigFiles) { List<KeyValuePair<ConfigDefinition, ConfigEntryBase>> list2; try { list2 = ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)configFile).ToList(); } catch (Exception ex) { NotModMenuPlugin.Log.LogWarning((object)("Could not read " + configFile.ConfigFilePath + ": " + ex.Message)); continue; } string fileName = (flag ? Path.GetFileName(configFile.ConfigFilePath) : null); Dictionary<string, SettingGroup> dictionary = new Dictionary<string, SettingGroup>(); List<SettingGroup> list3 = new List<SettingGroup>(); foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in list2) { SettingRow settingRow = MakeRow(item.Value); if (settingRow != null) { string text = item.Key.Section ?? ""; if (!dictionary.TryGetValue(text, out var value)) { value = (dictionary[text] = new SettingGroup { Section = text, FileName = fileName }); list3.Add(value); } value.Rows.Add(settingRow); } } foreach (SettingGroup item2 in list3) { item2.Rows = item2.Rows.OrderByDescending((SettingRow r) => r.Order).ToList(); } list.AddRange(list3); } return list; } private static SettingRow MakeRow(ConfigEntryBase entry) { if (entry == null) { return null; } SettingRow obj = new SettingRow { Entry = entry, Name = entry.Definition.Key }; ConfigDescription description = entry.Description; obj.Description = ((description != null) ? description.Description : null); SettingRow settingRow = obj; ConfigDescription description2 = entry.Description; object[] array = ((description2 != null) ? description2.Tags : null); if (array != null) { object[] array2 = array; foreach (object obj2 in array2) { if (obj2 != null && !(obj2.GetType().Name != "ConfigurationManagerAttributes")) { object obj3 = ReadMember(obj2, "Browsable"); if (obj3 is bool && !(bool)obj3) { return null; } if (ReadMember(obj2, "ReadOnly") is bool readOnly) { settingRow.ReadOnly = readOnly; } if (ReadMember(obj2, "DispName") is string { Length: >0 } text) { settingRow.Name = text; } if (ReadMember(obj2, "Order") is int order) { settingRow.Order = order; } } } } settingRow.SearchText = string.Join(" ", settingRow.Name, settingRow.Description, entry.Definition.Section).ToLowerInvariant(); return settingRow; } private static object ReadMember(object target, string name) { Type type = target.GetType(); FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return field.GetValue(target); } PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(property != null) || !property.CanRead) { return null; } return property.GetValue(target, null); } } internal static class ConfigWriter { private static readonly HashSet<ConfigFile> dirty = new HashSet<ConfigFile>(); public static void Set(ConfigEntryBase entry, object value) { ConfigFile configFile = entry.ConfigFile; bool saveOnConfigSet = configFile != null && configFile.SaveOnConfigSet; if (configFile != null) { configFile.SaveOnConfigSet = false; } try { entry.BoxedValue = value; } catch (Exception ex) { NotModMenuPlugin.Log.LogWarning((object)$"Could not change {entry.Definition}: {ex.Message}"); } finally { if (configFile != null) { configFile.SaveOnConfigSet = saveOnConfigSet; dirty.Add(configFile); } } } public static void Flush() { foreach (ConfigFile item in dirty) { try { item.Save(); } catch (Exception ex) { NotModMenuPlugin.Log.LogError((object)("Could not save " + item.ConfigFilePath + ": " + ex.Message)); } } dirty.Clear(); } } internal static class ValueUtil { private static readonly Dictionary<Type, object[]> enumValues = new Dictionary<Type, object[]>(); private static readonly Dictionary<AcceptableValueBase, double[]> ranges = new Dictionary<AcceptableValueBase, double[]>(); private static readonly Dictionary<AcceptableValueBase, object[]> lists = new Dictionary<AcceptableValueBase, object[]>(); public static bool IsNumeric(Type t) { if (!(t == typeof(int)) && !(t == typeof(float)) && !(t == typeof(double)) && !(t == typeof(long)) && !(t == typeof(shor