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 ModMenu v1.2.0
BepInEx/plugins/ModMenu.dll
Decompiled 3 days agousing 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.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace ModMenu; internal enum EditorKind { Toggle, Slider, Number, Enum, Flags, Choice, Text } internal class ModEntry { public string Guid; public string Name; public string Version; public string DllPath; public string Package; public bool Loaded; public ConfigFile Config; public object PluginObject; public List<SectionModel> Sections = new List<SectionModel>(); public List<ConfigGroup> Extras = new List<ConfigGroup>(); public bool ExtrasLoaded; public int RelatedFileCount; public IEnumerable<ConfigGroup> Groups { get { if (Sections.Count > 0) { yield return new ConfigGroup { Title = ((Extras.Count <= 0 || Config == null) ? null : Path.GetFileName(Config.ConfigFilePath)), File = Config, Sections = Sections, IsMain = true }; } foreach (ConfigGroup extra in Extras) { yield return extra; } } } public IEnumerable<ConfigEntryBase> AllEntries => Groups.SelectMany((ConfigGroup g) => g.Sections).SelectMany((SectionModel s) => s.Entries); public int SettingCount => Groups.Sum((ConfigGroup g) => g.Sections.Sum((SectionModel s) => s.Entries.Count)); public bool IsFromFile(ConfigEntryBase e) { return Extras.Any((ConfigGroup g) => g.Offline && g.File == e.ConfigFile); } } internal class ConfigGroup { public string Title; public string Path; public ConfigFile File; public bool Offline; public bool IsMain; public List<SectionModel> Sections = new List<SectionModel>(); } internal class SectionModel { public string Name; public List<ConfigEntryBase> Entries = new List<ConfigEntryBase>(); } internal static class ConfigModel { private static readonly Regex PackageFolder = new Regex("^[A-Za-z0-9_]+-[A-Za-z0-9_]+$"); private static readonly Type[] Integers = new Type[8] { typeof(int), typeof(long), typeof(short), typeof(byte), typeof(sbyte), typeof(uint), typeof(ulong), typeof(ushort) }; private static readonly Type[] Floats = new Type[3] { typeof(float), typeof(double), typeof(decimal) }; public static List<ModEntry> DiscoverMods() { List<ModEntry> list = new List<ModEntry>(); foreach (PluginInfo value in Chainloader.PluginInfos.Values) { ModEntry modEntry = new ModEntry(); modEntry.Guid = value.Metadata.GUID; modEntry.Name = value.Metadata.Name; modEntry.Version = value.Metadata.Version.ToString(); modEntry.DllPath = value.Location; modEntry.Loaded = !object.ReferenceEquals(value.Instance, null); ModEntry modEntry2 = modEntry; modEntry2.Package = FindPackage(value.Location); if (!object.ReferenceEquals(value.Instance, null)) { modEntry2.Config = value.Instance.Config; modEntry2.PluginObject = value.Instance; modEntry2.Sections = BuildSections(modEntry2.Config); } list.Add(modEntry2); } return list.OrderBy<ModEntry, string>((ModEntry m) => m.Name, StringComparer.OrdinalIgnoreCase).ToList(); } private static string FindPackage(string dll) { try { string directoryName = Path.GetDirectoryName(dll); string text = Path.GetFullPath(Paths.PluginPath).TrimEnd(Path.DirectorySeparatorChar); while (!string.IsNullOrEmpty(directoryName) && Path.GetFullPath(directoryName).TrimEnd(Path.DirectorySeparatorChar).Length > text.Length) { string fileName = Path.GetFileName(directoryName); if (PackageFolder.IsMatch(fileName) && string.Equals(Path.GetDirectoryName(directoryName), text, StringComparison.OrdinalIgnoreCase)) { return fileName; } directoryName = Path.GetDirectoryName(directoryName); } } catch (Exception) { } return null; } public static List<SectionModel> BuildSections(ConfigFile cfg) { List<SectionModel> list = new List<SectionModel>(); foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> kv in cfg) { SectionModel sectionModel = list.FirstOrDefault((SectionModel x) => x.Name == kv.Key.Section); if (sectionModel == null) { SectionModel sectionModel2 = new SectionModel(); sectionModel2.Name = kv.Key.Section; sectionModel = sectionModel2; list.Add(sectionModel); } sectionModel.Entries.Add(kv.Value); } return list; } public static List<string> FindRelatedFiles(ModEntry m, ICollection<string> owned) { List<string> list = new List<string>(); try { string[] files = Directory.GetFiles(Paths.ConfigPath, "*.cfg", SearchOption.AllDirectories); foreach (string text in files) { string full = Path.GetFullPath(text); if (!owned.Any((string o) => string.Equals(o, full, StringComparison.OrdinalIgnoreCase))) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (fileNameWithoutExtension.IndexOf(m.Guid, StringComparison.OrdinalIgnoreCase) >= 0 || (m.Name.Length >= 4 && fileNameWithoutExtension.IndexOf(m.Name.Replace(" ", string.Empty), StringComparison.OrdinalIgnoreCase) >= 0)) { list.Add(text); } } } } catch (Exception) { } return list; } public static bool IsInteger(Type t) { return Integers.Contains(t); } public static bool IsNumeric(Type t) { return IsInteger(t) || Floats.Contains(t); } public static EditorKind KindOf(ConfigEntryBase e) { Type settingType = e.SettingType; if (settingType == typeof(bool)) { return EditorKind.Toggle; } if (settingType.IsEnum) { return (!settingType.IsDefined(typeof(FlagsAttribute), inherit: false)) ? EditorKind.Enum : EditorKind.Flags; } double min; double max; if (IsNumeric(settingType)) { return TryGetRange(e, out min, out max) ? EditorKind.Slider : EditorKind.Number; } if (ChoicesOf(e) != null) { return EditorKind.Choice; } return EditorKind.Text; } public static bool TryGetRange(ConfigEntryBase e, out double min, out double max) { min = (max = 0.0); AcceptableValueBase val = ((e.Description != null) ? e.Description.AcceptableValues : null); if (val == null || !((object)val).GetType().IsGenericType || ((object)val).GetType().GetGenericTypeDefinition() != typeof(AcceptableValueRange<>)) { return false; } min = Convert.ToDouble(((object)val).GetType().GetProperty("MinValue").GetValue(val, null), CultureInfo.InvariantCulture); max = Convert.ToDouble(((object)val).GetType().GetProperty("MaxValue").GetValue(val, null), CultureInfo.InvariantCulture); return max > min; } public static object[] ChoicesOf(ConfigEntryBase e) { AcceptableValueBase val = ((e.Description != null) ? e.Description.AcceptableValues : null); if (val == null || !((object)val).GetType().IsGenericType || ((object)val).GetType().GetGenericTypeDefinition() != typeof(AcceptableValueList<>)) { return null; } return (((object)val).GetType().GetProperty("AcceptableValues").GetValue(val, null) is Array source) ? source.Cast<object>().ToArray() : null; } public static string Format(ConfigEntryBase e, object value) { if (value == null) { return string.Empty; } Type settingType = e.SettingType; if (settingType == typeof(float)) { return ((float)value).ToString("0.###", CultureInfo.InvariantCulture); } if (settingType == typeof(double)) { return ((double)value).ToString("0.###", CultureInfo.InvariantCulture); } try { return TomlTypeConverter.ConvertToString(value, settingType); } catch (Exception) { return value.ToString(); } } public static string Format(ConfigEntryBase e) { return Format(e, e.BoxedValue); } public static bool TryParse(ConfigEntryBase e, string text, out object value, out string error) { value = null; error = null; Type settingType = e.SettingType; try { if (IsNumeric(settingType)) { if (!double.TryParse((text ?? string.Empty).Trim().Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { error = "Not a number"; return false; } if (IsInteger(settingType) && Math.Abs(result - Math.Round(result)) > 1E-09) { error = "Whole numbers only"; return false; } value = Convert.ChangeType((!IsInteger(settingType)) ? result : Math.Round(result), settingType, CultureInfo.InvariantCulture); } else { value = TomlTypeConverter.ConvertToValue(text ?? string.Empty, settingType); } } catch (Exception) { error = "Invalid value for " + settingType.Name; return false; } AcceptableValueBase val = ((e.Description != null) ? e.Description.AcceptableValues : null); if (val != null && !val.IsValid(value)) { error = ((!TryGetRange(e, out var min, out var max)) ? "Not an allowed value" : ("Must be between " + min.ToString(CultureInfo.InvariantCulture) + " and " + max.ToString(CultureInfo.InvariantCulture))); return false; } return true; } public static bool Apply(ConfigEntryBase e, object value) { try { if (object.Equals(e.BoxedValue, value)) { return false; } e.BoxedValue = value; ConfigFile configFile = e.ConfigFile; if (configFile != null && !configFile.SaveOnConfigSet) { configFile.Save(); } return true; } catch (Exception ex) { ModMenuPlugin.Log.LogError((object)string.Concat("Could not set ", e.Definition, ": ", ex.Message)); return false; } } public static bool IsDefault(ConfigEntryBase e) { return object.Equals(e.BoxedValue, e.DefaultValue); } public static object FromSlider(ConfigEntryBase e, double v) { Type settingType = e.SettingType; if (IsInteger(settingType)) { v = Math.Round(v); } else if (settingType == typeof(float) || settingType == typeof(double)) { v = Math.Round(v, 3); } return Convert.ChangeType(v, settingType, CultureInfo.InvariantCulture); } public static string Pretty(string key) { if (string.IsNullOrEmpty(key)) { return key; } string input = Regex.Replace(key.Replace('_', ' '), "(?<=[a-z0-9])(?=[A-Z])", " ").Trim(); input = Regex.Replace(input, "\\s+", " "); return char.ToUpperInvariant(input[0]) + input.Substring(1); } } internal static class ExtraConfigs { private class Created { public WeakReference File; public Assembly Owner; } [HarmonyPatch] [HarmonyWrapSafe] internal static class ConfigFileCtorPatch { private static IEnumerable<MethodBase> TargetMethods() { return (from c in typeof(ConfigFile).GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where c.GetParameters().Length >= 2 && c.GetParameters()[0].ParameterType == typeof(string) select c).Cast<MethodBase>(); } [HarmonyPostfix] private static void Postfix(ConfigFile __instance) { if (_creatingOurOwn) { return; } Assembly owner = CallingModAssembly(); lock (CreatedFiles) { if (!CreatedFiles.Any((Created c) => object.ReferenceEquals(c.File.Target, __instance))) { CreatedFiles.Add(new Created { File = new WeakReference(__instance), Owner = owner }); } } } } private class RefEq : IEqualityComparer<object> { public new bool Equals(object a, object b) { return object.ReferenceEquals(a, b); } public int GetHashCode(object o) { return RuntimeHelpers.GetHashCode(o); } } private static readonly List<Created> CreatedFiles = new List<Created>(); [ThreadStatic] private static bool _creatingOurOwn; private static readonly Regex Range = new Regex("From\\s+(\\S+)\\s+to\\s+(\\S+)", RegexOptions.IgnoreCase); private static readonly Dictionary<string, Type> KnownTypes = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase) { { "Boolean", typeof(bool) }, { "Int32", typeof(int) }, { "Int64", typeof(long) }, { "Int16", typeof(short) }, { "Byte", typeof(byte) }, { "SByte", typeof(sbyte) }, { "UInt32", typeof(uint) }, { "UInt64", typeof(ulong) }, { "UInt16", typeof(ushort) }, { "Single", typeof(float) }, { "Double", typeof(double) }, { "Decimal", typeof(decimal) }, { "String", typeof(string) }, { "KeyboardShortcut", typeof(KeyboardShortcut) }, { "KeyCode", typeof(KeyCode) }, { "Color", typeof(Color) }, { "Vector2", typeof(Vector2) }, { "Vector3", typeof(Vector3) }, { "Vector4", typeof(Vector4) }, { "Quaternion", typeof(Quaternion) } }; private static Assembly CallingModAssembly() { StackFrame[] frames = new StackTrace(2, fNeedFileInfo: false).GetFrames(); if (frames == null) { return null; } Assembly assembly = typeof(ConfigFile).Assembly; Assembly assembly2 = typeof(ExtraConfigs).Assembly; StackFrame[] array = frames; foreach (StackFrame stackFrame in array) { MethodBase method = stackFrame.GetMethod(); if (!(method == null) && !(method.DeclaringType == null)) { Assembly assembly3 = method.DeclaringType.Assembly; if (!(assembly3 == assembly) && !(assembly3 == assembly2) && !(assembly3 == typeof(Harmony).Assembly) && !(assembly3 == typeof(object).Assembly)) { return assembly3; } } } return null; } public static List<ConfigGroup> Find(ModEntry mod, ICollection<string> claimedPaths) { List<ConfigGroup> list = new List<ConfigGroup>(); HashSet<string> hashSet = new HashSet<string>(claimedPaths, StringComparer.OrdinalIgnoreCase); if (mod.Config != null) { hashSet.Add(Full(mod.Config.ConfigFilePath)); } foreach (ConfigFile item in LiveFilesOf(mod)) { string text = Full(item.ConfigFilePath); if (hashSet.Add(text)) { list.Add(new ConfigGroup { Title = Path.GetFileName(text), Path = text, File = item, Offline = false, Sections = ConfigModel.BuildSections(item) }); } } foreach (string item2 in ConfigModel.FindRelatedFiles(mod, hashSet)) { string text2 = Full(item2); if (hashSet.Add(text2)) { ConfigFile val = LoadFromFile(text2); if (val != null && val.Count != 0) { list.Add(new ConfigGroup { Title = Path.GetFileName(text2), Path = text2, File = val, Offline = true, Sections = ConfigModel.BuildSections(val) }); } } } return list.OrderBy<ConfigGroup, string>((ConfigGroup g) => g.Title, StringComparer.OrdinalIgnoreCase).ToList(); } private static IEnumerable<ConfigFile> LiveFilesOf(ModEntry mod) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) List<ConfigFile> list = new List<ConfigFile>(); Assembly assembly = ((mod.PluginObject == null) ? null : mod.PluginObject.GetType().Assembly); if (assembly == null) { return list; } lock (CreatedFiles) { CreatedFiles.RemoveAll((Created c) => !c.File.IsAlive); foreach (Created createdFile in CreatedFiles) { if (createdFile.Owner == assembly) { list.Add((ConfigFile)createdFile.File.Target); } } } foreach (object item in ReachableObjects(assembly, mod.PluginObject)) { ConfigFile val = (ConfigFile)((item is ConfigFile) ? item : null); if (val == null && item is ConfigEntryBase) { val = ((ConfigEntryBase)item).ConfigFile; } if (val != null && !list.Contains(val)) { list.Add(val); } } return list; } internal static IEnumerable<object> ReachableObjects(Assembly asm, object plugin) { Type[] types; try { types = asm.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types.Where((Type type2) => type2 != null).ToArray(); } List<object> frontier = new List<object>(); if (plugin != null) { frontier.Add(plugin); } Type[] array = types; foreach (Type type in array) { if (type.ContainsGenericParameters) { continue; } FieldInfo[] fields; try { fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } catch { continue; } FieldInfo[] array2 = fields; foreach (FieldInfo fieldInfo in array2) { object value; try { value = fieldInfo.GetValue(null); } catch { continue; } if (value != null) { frontier.Add(value); } } } HashSet<object> seen = new HashSet<object>(new RefEq()); for (int depth = 0; depth < 3; depth++) { if (frontier.Count <= 0) { break; } List<object> next = new List<object>(); foreach (object o in frontier) { if (o == null || !seen.Add(o)) { continue; } yield return o; Type t = o.GetType(); if (t.Assembly != asm || !t.IsClass) { continue; } FieldInfo[] fs; try { fs = t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch { continue; } FieldInfo[] array3 = fs; foreach (FieldInfo fieldInfo2 in array3) { object value2; try { value2 = fieldInfo2.GetValue(o); } catch { continue; } if (value2 != null) { next.Add(value2); } } } frontier = next; } } private static string Full(string p) { return Path.GetFullPath(p); } internal static ConfigFile LoadFromFile(string path) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown try { _creatingOurOwn = true; ConfigFile val; try { val = new ConfigFile(path, false); } finally { _creatingOurOwn = false; } val.SaveOnConfigSet = false; string section = "General"; string type = null; string def = null; string accept = null; string range = null; List<string> list = new List<string>(); string[] array = File.ReadAllLines(path); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length == 0) { continue; } if (text2.StartsWith("[") && text2.EndsWith("]")) { section = text2.Substring(1, text2.Length - 2); Reset(ref type, ref def, ref accept, ref range, list); } else { if (text2.StartsWith("## Settings file was created") || text2.StartsWith("## Plugin GUID")) { continue; } if (text2.StartsWith("##")) { list.Add(text2.Substring(2).Trim()); } else if (text2.StartsWith("# Setting type:")) { type = text2.Substring(15).Trim(); } else if (text2.StartsWith("# Default value:")) { def = text2.Substring(16).Trim(); } else if (text2.StartsWith("# Acceptable values:")) { accept = text2.Substring(20).Trim(); } else if (text2.StartsWith("# Acceptable value range:")) { range = text2.Substring(25).Trim(); } else if (!text2.StartsWith("#")) { int num = text2.IndexOf('='); if (num > 0) { string key = text2.Substring(0, num).Trim(); BindParsed(val, section, key, type, def, accept, range, string.Join("\n", list.ToArray())); Reset(ref type, ref def, ref accept, ref range, list); } } } } return val; } catch (Exception ex) { ModMenuPlugin.Log.LogWarning((object)("Couldn't read " + path + ": " + ex.Message)); return null; } } private static void Reset(ref string type, ref string def, ref string accept, ref string range, List<string> desc) { type = (def = (accept = (range = null))); desc.Clear(); } private static void BindParsed(ConfigFile cfg, string section, string key, string typeName, string def, string accept, string range, string desc) { //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown if (typeName == null || !KnownTypes.TryGetValue(typeName, out var value) || !TomlTypeConverter.CanConvert(value)) { value = typeof(string); } object obj = null; if (def != null) { try { obj = TomlTypeConverter.ConvertToValue(def, value); } catch { value = typeof(string); } } if (value == typeof(string)) { obj = def ?? string.Empty; } if (obj == null) { obj = ((!value.IsValueType) ? null : Activator.CreateInstance(value)); } AcceptableValueBase val = null; if (range != null && ConfigModel.IsNumeric(value)) { Match match = Range.Match(range); if (match.Success && TryNum(match.Groups[1].Value, value, out var v) && TryNum(match.Groups[2].Value, value, out var v2)) { val = (AcceptableValueBase)Activator.CreateInstance(typeof(AcceptableValueRange<>).MakeGenericType(value), v, v2); } } else if (accept != null && value == typeof(string)) { string[] array = (from s in accept.Split(',') select s.Trim() into s where s.Length > 0 select s).ToArray(); if (array.Length > 0 && array.Contains((string)obj)) { val = (AcceptableValueBase)(object)new AcceptableValueList<string>(array); } } MethodInfo methodInfo = typeof(ConfigFile).GetMethods().First((MethodInfo mi) => mi.Name == "Bind" && mi.IsGenericMethodDefinition && mi.GetParameters().Length == 3 && mi.GetParameters()[0].ParameterType == typeof(ConfigDefinition) && mi.GetParameters()[2].ParameterType == typeof(ConfigDescription)).MakeGenericMethod(value); try { methodInfo.Invoke(cfg, new object[3] { (object)new ConfigDefinition(section, key), obj, (object)new ConfigDescription(desc, val, Array.Empty<object>()) }); } catch (Exception ex) { ModMenuPlugin.Log.LogDebug((object)("Skipped " + section + "." + key + ": " + ex.Message)); } } private static bool TryNum(string s, Type t, out object v) { v = null; if (!double.TryParse(s.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return false; } try { v = Convert.ChangeType(result, t, CultureInfo.InvariantCulture); return true; } catch { return false; } } } internal enum ApplyMode { Live, Restart, Unknown } internal static class LiveApply { private static readonly HashSet<string> StartupMethods = new HashSet<string> { ".ctor", ".cctor", "Awake", "Start", "OnEnable" }; private static readonly Dictionary<string, Dictionary<ConfigEntryBase, ApplyMode>> Cache = new Dictionary<string, Dictionary<ConfigEntryBase, ApplyMode>>(); public static ApplyMode Get(ModEntry mod, ConfigEntryBase entry) { if (mod.IsFromFile(entry)) { return ApplyMode.Restart; } if (!Cache.TryGetValue(mod.Guid, out var value) || !value.ContainsKey(entry)) { List<ConfigEntryBase> entries = mod.Groups.Where((ConfigGroup g) => !g.Offline && g.File != null).SelectMany((ConfigGroup g) => g.Sections).SelectMany((SectionModel s) => s.Entries) .ToList(); value = SafeAnalyze(mod.PluginObject, mod.DllPath, entries); Cache[mod.Guid] = value; } ApplyMode value2; return (!value.TryGetValue(entry, out value2)) ? ApplyMode.Unknown : value2; } private static Dictionary<ConfigEntryBase, ApplyMode> SafeAnalyze(object plugin, string dll, List<ConfigEntryBase> entries) { try { return Analyze(plugin, dll, entries); } catch (Exception ex) { ModMenuPlugin.Log.LogDebug((object)("Live-apply analysis failed for " + dll + ": " + ex.Message)); return new Dictionary<ConfigEntryBase, ApplyMode>(); } } internal static Dictionary<ConfigEntryBase, ApplyMode> Analyze(object plugin, string dll, ConfigFile cfg) { return Analyze(plugin, dll, (cfg != null) ? ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)cfg).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> kv) => kv.Value).ToList() : new List<ConfigEntryBase>()); } internal static Dictionary<ConfigEntryBase, ApplyMode> Analyze(object plugin, string dll, List<ConfigEntryBase> entries) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) Dictionary<ConfigEntryBase, ApplyMode> dictionary = new Dictionary<ConfigEntryBase, ApplyMode>(); if (entries == null || entries.Count == 0 || string.IsNullOrEmpty(dll)) { return dictionary; } Dictionary<ConfigEntryBase, List<string>> dictionary2 = new Dictionary<ConfigEntryBase, List<string>>(); Assembly assembly = plugin?.GetType().Assembly; if (assembly != null) { MapFields(assembly, plugin, entries, dictionary2); } Dictionary<string, int[]> dictionary3 = new Dictionary<string, int[]>(); HashSet<string> hashSet = new HashSet<string>(); HashSet<string> hashSet2 = new HashSet<string>(); bool flag = false; ReaderParameters val = new ReaderParameters(); val.ReadSymbols = false; val.InMemory = true; ModuleDefinition val2 = ModuleDefinition.ReadModule(dll, val); try { foreach (TypeDefinition item in AllTypes(val2)) { Enumerator<MethodDefinition> enumerator2 = item.Methods.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodDefinition current2 = enumerator2.Current; if (!current2.HasBody) { continue; } bool flag2 = StartupMethods.Contains(((MemberReference)current2).Name); Collection<Instruction> instructions = current2.Body.Instructions; for (int i = 0; i < instructions.Count; i++) { OpCode opCode = instructions[i].OpCode; if ((opCode == OpCodes.Call || opCode == OpCodes.Callvirt) && instructions[i].Operand is MethodReference) { MethodReference val3 = (MethodReference)instructions[i].Operand; if (((MemberReference)val3).Name == "add_SettingChanged" && ((MemberReference)((MemberReference)val3).DeclaringType).Name == "ConfigFile") { flag = true; } if (((MemberReference)val3).Name == "Bind" && ((MemberReference)((MemberReference)val3).DeclaringType).Name == "ConfigFile" && NextIsValueGet((IList<Instruction>)instructions, i)) { string text = FindKeyString((IList<Instruction>)instructions, i); if (text != null) { ((!flag2) ? hashSet2 : hashSet).Add(text); } } } if (opCode != OpCodes.Ldfld && opCode != OpCodes.Ldsfld) { continue; } object operand = instructions[i].Operand; FieldReference val4 = (FieldReference)((operand is FieldReference) ? operand : null); if (val4 == null) { continue; } string id = FieldId(val4); if (dictionary2.Values.Any((List<string> l) => l.Contains(id))) { if (!dictionary3.TryGetValue(id, out var value)) { value = (dictionary3[id] = new int[3]); } if (NextIsSubscription((IList<Instruction>)instructions, i)) { value[2]++; } else if (NextIsValueGet((IList<Instruction>)instructions, i)) { value[(!flag2) ? 1u : 0u]++; } else if (!flag2) { value[1]++; } } } } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } } finally { ((IDisposable)val2)?.Dispose(); } foreach (ConfigEntryBase entry in entries) { if (flag) { dictionary[entry] = ApplyMode.Live; continue; } int num = 0; int num2 = 0; int num3 = 0; if (dictionary2.TryGetValue(entry, out var value2)) { foreach (string item2 in value2) { if (dictionary3.TryGetValue(item2, out var value3)) { num += value3[0]; num2 += value3[1]; num3 += value3[2]; } } } string key = entry.Definition.Key; if (hashSet2.Contains(key)) { num2++; } if (hashSet.Contains(key)) { num++; } dictionary[entry] = ((num3 <= 0 && num2 <= 0) ? ((num > 0) ? ApplyMode.Restart : ApplyMode.Unknown) : ApplyMode.Live); } return dictionary; } private static void MapFields(Assembly asm, object plugin, List<ConfigEntryBase> entries, Dictionary<ConfigEntryBase, List<string>> map) { HashSet<ConfigEntryBase> entries2 = new HashSet<ConfigEntryBase>(entries); List<object> list = new List<object>(); if (plugin != null) { list.Add(plugin); } Type[] array; try { array = asm.GetTypes(); } catch (ReflectionTypeLoadException ex) { array = ex.Types.Where((Type t) => t != null).ToArray(); } Type[] array2 = array; foreach (Type type in array2) { if (type.ContainsGenericParameters) { continue; } foreach (FieldInfo item in SafeFields(type, BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { object value; try { value = item.GetValue(null); } catch { continue; } Record(value, item, entries2, map); if (value != null && IsHolderCandidate(value.GetType(), asm)) { list.Add(value); } } } HashSet<object> hashSet = new HashSet<object>(); for (int num2 = 0; num2 < list.Count; num2++) { object obj2 = list[num2]; if (obj2 == null || !hashSet.Add(obj2)) { continue; } foreach (FieldInfo item2 in SafeFields(obj2.GetType(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { object value2; try { value2 = item2.GetValue(obj2); } catch { continue; } Record(value2, item2, entries2, map); if (num2 < 64 && value2 != null && obj2 == plugin && IsHolderCandidate(value2.GetType(), asm)) { list.Add(value2); } } } } private static bool IsHolderCandidate(Type t, Assembly asm) { return t.Assembly == asm && t.IsClass && !typeof(ConfigEntryBase).IsAssignableFrom(t); } private static IEnumerable<FieldInfo> SafeFields(Type t, BindingFlags flags) { try { return t.GetFields(flags); } catch { return new FieldInfo[0]; } } private static void Record(object value, FieldInfo f, HashSet<ConfigEntryBase> entries, Dictionary<ConfigEntryBase, List<string>> map) { ConfigEntryBase val = (ConfigEntryBase)((value is ConfigEntryBase) ? value : null); if (val != null && entries.Contains(val)) { if (!map.TryGetValue(val, out var value2)) { value2 = (map[val] = new List<string>()); } string item = f.DeclaringType.FullName.Replace('+', '/') + "::" + f.Name; if (!value2.Contains(item)) { value2.Add(item); } } } private static IEnumerable<TypeDefinition> AllTypes(ModuleDefinition m) { Stack<TypeDefinition> stack = new Stack<TypeDefinition>((IEnumerable<TypeDefinition>)m.Types); while (stack.Count > 0) { TypeDefinition t = stack.Pop(); yield return t; Enumerator<TypeDefinition> enumerator = t.NestedTypes.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; stack.Push(current); } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } } private static string FieldId(FieldReference f) { return ((MemberReference)((MemberReference)f).DeclaringType).FullName + "::" + ((MemberReference)f).Name; } private static bool NextIsValueGet(IList<Instruction> ins, int i) { for (int j = i + 1; j < ins.Count && j <= i + 2; j++) { object operand = ins[j].Operand; MethodReference val = (MethodReference)((operand is MethodReference) ? operand : null); if (val != null && (((MemberReference)val).Name == "get_Value" || ((MemberReference)val).Name == "get_BoxedValue")) { return true; } } return false; } private static bool NextIsSubscription(IList<Instruction> ins, int i) { for (int j = i + 1; j < ins.Count && j <= i + 14; j++) { object operand = ins[j].Operand; MethodReference val = (MethodReference)((operand is MethodReference) ? operand : null); if (val != null) { if (((MemberReference)val).Name == "add_SettingChanged") { return true; } if (((MemberReference)val).Name == "get_Value" || ((MemberReference)val).Name == "get_BoxedValue") { return false; } } } return false; } private static string FindKeyString(IList<Instruction> ins, int bindIndex) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) List<string> list = new List<string>(); int num = bindIndex - 1; while (num >= 0 && num >= bindIndex - 12) { if (ins[num].OpCode == OpCodes.Ldstr) { list.Insert(0, (string)ins[num].Operand); } if (ins[num].OpCode == OpCodes.Call || ins[num].OpCode == OpCodes.Callvirt) { object operand = ins[num].Operand; MethodReference val = (MethodReference)((operand is MethodReference) ? operand : null); if (val != null && ((MemberReference)val).Name == "Bind") { break; } } num--; } return (list.Count < 2) ? null : list[1]; } } internal static class MenuButtonInjector { public enum Placement { RightOfFirst, AboveFirst } private const string ObjectName = "ModMenuButton"; private const float Width = 300f; private const float Gap = 40f; public static void Inject(GameObject panel, Placement placement, GameObject closeWindowWhenHidden) { if ((Object)(object)panel == (Object)null) { ModMenuPlugin.Log.LogWarning((object)"Menu panel not found."); } else { if (panel.GetComponentsInChildren<Transform>(true).Any((Transform t) => ((Object)t).name == "ModMenuButton")) { return; } List<Button> list = (from b in panel.GetComponentsInChildren<Button>(true) where (Object)(object)((Component)b).GetComponentInChildren<TMP_Text>(true) != (Object)null select b).ToList(); if (list.Count == 0) { ModMenuPlugin.Log.LogWarning((object)("No menu buttons to copy in " + ((Object)panel).name + ".")); return; } Transform columnParent = (from b in list group b by ((Component)b).transform.parent).OrderByDescending(Enumerable.Count).First().Key; List<Button> list2 = (from b in list where (Object)(object)((Component)b).transform.parent == (Object)(object)columnParent && ((Component)b).gameObject.activeSelf orderby ((Component)b).transform.position.y descending select b).ToList(); if (list2.Count == 0) { list2 = list; } Button val = list2[0]; GameObject val2 = CreateClone(val); if (placement == Placement.AboveFirst && list2.Count >= 2) { PlaceAbove(val2, val, list2[1]); } else { PlaceBeside(val2, val); } ModMenuWindow.Instance.TrackMenuButton(val2, panel, closeWindowWhenHidden); } } private static GameObject CreateClone(Button template) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, ((Component)template).transform.parent); ((Object)val).name = "ModMenuButton"; EventTrigger[] components = val.GetComponents<EventTrigger>(); foreach (EventTrigger val2 in components) { val2.triggers.RemoveAll((Entry e) => (int)e.eventID == 4 || (int)e.eventID == 15); } Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { ModMenuWindow.Instance.Open(); }); TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true); componentInChildren.text = Relabel(componentInChildren.text); return val; } private static void PlaceAbove(GameObject clone, Button first, Button second) { //IL_0006: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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_002e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)first).transform.position - ((Component)second).transform.position; clone.transform.position = ((Component)first).transform.position + val; ShortenBar(clone, 300f); FinishPlacement(clone); ModMenuPlugin.Log.LogInfo((object)("Added Mods button above '" + Label(first).Trim() + "'. Game menu buttons untouched.")); } private static void FinishPlacement(GameObject clone) { LayoutElement val = clone.GetComponent<LayoutElement>() ?? clone.AddComponent<LayoutElement>(); val.ignoreLayout = true; clone.transform.SetAsLastSibling(); clone.SetActive(true); } private static void PlaceBeside(GameObject clone, Button first) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)clone.transform; RectTransform val2 = Rect(first); float num = float.MaxValue; float num2 = float.MinValue; Vector3[] array = (Vector3[])(object)new Vector3[4]; RectTransform[] componentsInChildren = ((Component)val2).GetComponentsInChildren<RectTransform>(true); foreach (RectTransform val3 in componentsInChildren) { val3.GetWorldCorners(array); num = Mathf.Min(num, array[0].x); num2 = Mathf.Max(num2, array[2].x); } float num3 = ((!((Object)(object)((Transform)val2).parent != (Object)null) || !(((Transform)val2).parent.lossyScale.x > 0f)) ? 1f : ((Transform)val2).parent.lossyScale.x); float num4 = (num2 - num) / num3; val.anchoredPosition = val2.anchoredPosition + new Vector2(num4 + 40f, 0f); ShortenBar(clone, 300f); LayoutElement val4 = clone.GetComponent<LayoutElement>() ?? clone.AddComponent<LayoutElement>(); val4.ignoreLayout = true; clone.transform.SetAsLastSibling(); clone.SetActive(true); ModMenuPlugin.Log.LogInfo((object)("Added Mods button to the right of '" + Label(first).Trim() + "' (bar " + num4.ToString("0") + " -> " + 300f.ToString("0") + "). Game menu buttons untouched.")); } private static void ShortenBar(GameObject clone, float width) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) RectTransform[] componentsInChildren = clone.GetComponentsInChildren<RectTransform>(true); Vector3[] array = (Vector3[])(object)new Vector3[4]; float[] array2 = new float[componentsInChildren.Length]; Vector3[] array3 = (Vector3[])(object)new Vector3[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].GetWorldCorners(array); array2[i] = array[0].x; ref Vector3 reference = ref array3[i]; reference = ((Transform)componentsInChildren[i]).position; } for (int j = 0; j < componentsInChildren.Length; j++) { RectTransform val = componentsInChildren[j]; if (Mathf.Approximately(val.anchorMin.x, val.anchorMax.x)) { Rect rect = val.rect; if (((Rect)(ref rect)).width > width + 1f) { val.SetSizeWithCurrentAnchors((Axis)0, width); ((Transform)val).position = array3[j]; val.GetWorldCorners(array); ((Transform)val).position = ((Transform)val).position + new Vector3(array2[j] - array[0].x, 0f, 0f); } else { ((Transform)val).position = array3[j]; } } } } private static RectTransform Rect(Button b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown return (RectTransform)((Component)b).transform; } private static string Label(Button b) { TMP_Text componentInChildren = ((Component)b).GetComponentInChildren<TMP_Text>(true); return (!((Object)(object)componentInChildren != (Object)null)) ? string.Empty : (componentInChildren.text ?? string.Empty); } internal static string Relabel(string original) { if (string.IsNullOrEmpty(original)) { return "> Mods"; } int i; for (i = 0; i < original.Length && !char.IsLetter(original[i]); i++) { } if (i >= original.Length) { return original + "Mods"; } string text = original.Substring(i).Trim(); string text2 = ((text == text.ToUpperInvariant()) ? "MODS" : ((!(text == text.ToLowerInvariant())) ? "Mods" : "mods")); return original.Substring(0, i) + text2; } } internal class ModMenuWindow : MonoBehaviour { internal static ModMenuWindow Instance; private bool _open; private List<ModEntry> _mods = new List<ModEntry>(); private HashSet<string> _ownedConfigFiles = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private ModEntry _selected; private string _search = string.Empty; private string _settingSearch = string.Empty; private string _searchView = string.Empty; private string _settingSearchView = string.Empty; private HashSet<ConfigEntryBase> _changedView = new HashSet<ConfigEntryBase>(); private ModEntry _selectedView; private HashSet<string> _collapsedView = new HashSet<string>(); private HashSet<ConfigEntryBase> _expandedView = new HashSet<ConfigEntryBase>(); private Dictionary<ConfigEntryBase, string> _errorsView = new Dictionary<ConfigEntryBase, string>(); private Vector2 _listScroll; private Vector2 _detailScroll; private readonly Dictionary<ConfigEntryBase, string> _buffers = new Dictionary<ConfigEntryBase, string>(); private readonly Dictionary<ConfigEntryBase, string> _errors = new Dictionary<ConfigEntryBase, string>(); private readonly HashSet<ConfigEntryBase> _expanded = new HashSet<ConfigEntryBase>(); private readonly HashSet<ConfigEntryBase> _changed = new HashSet<ConfigEntryBase>(); private readonly HashSet<string> _collapsedSections = new HashSet<string>(); private bool _eventSystemWasEnabled; private EventSystem _eventSystem; private CursorLockMode _prevLock; private bool _prevVisible; private const float VW = 1920f; private const float VH = 1080f; private GameObject _menuButton; private GameObject _menuSource; private GameObject _closeWhenHidden; public bool IsOpen => _open; private void Awake() { Instance = this; } public void TrackMenuButton(GameObject button, GameObject source, GameObject closeWindowWhenHidden) { _menuButton = button; _menuSource = source; _closeWhenHidden = closeWindowWhenHidden; } private void Update() { if (_open && (Object)(object)_closeWhenHidden != (Object)null && !_closeWhenHidden.activeInHierarchy) { Close(); } if (!((Object)(object)_menuButton == (Object)null) && !((Object)(object)_menuSource == (Object)null)) { bool flag = _menuSource.activeInHierarchy && !_open; if (_menuButton.activeSelf != flag) { _menuButton.SetActive(flag); } } } public void Open() { //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) if (!_open) { Refresh(); _open = true; _prevLock = Cursor.lockState; _prevVisible = Cursor.visible; _eventSystem = EventSystem.current; _eventSystemWasEnabled = (Object)(object)_eventSystem != (Object)null && ((Behaviour)_eventSystem).enabled; if ((Object)(object)_eventSystem != (Object)null) { ((Behaviour)_eventSystem).enabled = false; } } } public void Close() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (_open) { _open = false; if ((Object)(object)_eventSystem != (Object)null && _eventSystemWasEnabled) { ((Behaviour)_eventSystem).enabled = true; _eventSystem.SetSelectedGameObject((GameObject)null); } _eventSystem = null; Cursor.lockState = _prevLock; Cursor.visible = _prevVisible; } } private void Refresh() { string keep = ((_selected == null) ? null : _selected.Guid); _mods = ConfigModel.DiscoverMods(); _ownedConfigFiles = new HashSet<string>(from m in _mods where m.Config != null select Path.GetFullPath(m.Config.ConfigFilePath), StringComparer.OrdinalIgnoreCase); foreach (ModEntry mod in _mods) { mod.RelatedFileCount = (mod.Loaded ? ConfigModel.FindRelatedFiles(mod, _ownedConfigFiles).Count : 0); } _selected = _mods.FirstOrDefault((ModEntry m) => m.Guid == keep) ?? _mods.FirstOrDefault((ModEntry m) => m.SettingCount > 0) ?? _mods.FirstOrDefault(); _buffers.Clear(); _errors.Clear(); } private void LoadExtras(ModEntry m) { m.ExtrasLoaded = true; if (!m.Loaded) { return; } try { m.Extras = ExtraConfigs.Find(m, _ownedConfigFiles); } catch (Exception ex) { ModMenuPlugin.Log.LogWarning((object)("Couldn't read extra configs of " + m.Name + ": " + ex.Message)); } } private void OnGUI() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Invalid comparison between Unknown and I4 //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Invalid comparison between Unknown and I4 if (!_open) { return; } if ((int)Event.current.type == 8) { _searchView = _search; _settingSearchView = _settingSearch; _changedView = new HashSet<ConfigEntryBase>(_changed); _errorsView = new Dictionary<ConfigEntryBase, string>(_errors); if (_selected != null && !_selected.ExtrasLoaded) { LoadExtras(_selected); } _selectedView = _selected; _collapsedView = new HashSet<string>(_collapsedSections); _expandedView = new HashSet<ConfigEntryBase>(_expanded); } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; Styles.Init(); float num = Mathf.Max(0.5f, (float)Screen.height / 1080f); GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f)); float num2 = (float)Screen.width / num; float num3 = (float)Screen.height / num; GUI.Box(new Rect(0f, 0f, num2, num3), GUIContent.none, Styles.Dim); float num4 = Mathf.Min(1400f, num2 - 80f); float num5 = Mathf.Min(860f, num3 - 80f); Rect val = default(Rect); ((Rect)(ref val))..ctor((num2 - num4) / 2f, (num3 - num5) / 2f, num4, num5); GUI.Box(val, GUIContent.none, Styles.Panel); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).y + 18f, ((Rect)(ref val)).width - 48f, ((Rect)(ref val)).height - 36f)); DrawHeader(); GUILayout.Space(12f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawModList(360f); GUILayout.Space(20f); DrawDetails(); GUILayout.EndHorizontal(); GUILayout.EndArea(); DrawTooltip(num2, num3); if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 27) { Close(); Event.current.Use(); } } private void DrawTooltip(float w, float h) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) string tooltip = GUI.tooltip; if (!string.IsNullOrEmpty(tooltip) && (int)Event.current.type == 7) { GUIContent val = new GUIContent(tooltip); Vector2 val2 = Styles.Tooltip.CalcSize(val); val2.x = Mathf.Min(val2.x, 520f); val2.y = Styles.Tooltip.CalcHeight(val, val2.x); Vector2 mousePosition = Event.current.mousePosition; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(Mathf.Min(mousePosition.x + 16f, w - val2.x - 8f), Mathf.Min(mousePosition.y + 18f, h - val2.y - 8f), val2.x, val2.y); GUI.Label(val3, val, Styles.Tooltip); } } private void DrawHeader() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("MODS", Styles.Title, Array.Empty<GUILayoutOption>()); GUILayout.Label(_mods.Count + " loaded", Styles.Muted, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", Styles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) })) { Refresh(); } GUILayout.Space(8f); if (GUILayout.Button("Close ✕", Styles.Accent, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) })) { Close(); } GUILayout.EndHorizontal(); } private void DrawModList(float width) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Search", Styles.Muted, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) }); _search = GUILayout.TextField(_search, Styles.Field, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.Space(8f); _listScroll = GUILayout.BeginScrollView(_listScroll, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, Styles.ListBg, Array.Empty<GUILayoutOption>()); foreach (ModEntry mod in _mods) { if (_searchView.Length <= 0 || mod.Name.IndexOf(_searchView, StringComparison.OrdinalIgnoreCase) >= 0 || mod.Guid.IndexOf(_searchView, StringComparison.OrdinalIgnoreCase) >= 0) { GUIStyle val = ((mod != _selectedView) ? Styles.ListItem : Styles.ListItemSelected); string text = ((!mod.Loaded) ? "failed" : ((!mod.ExtrasLoaded) ? (((mod.SettingCount > 0) ? (mod.SettingCount + " settings") : ((mod.RelatedFileCount <= 0) ? "no settings" : string.Empty)) + ((mod.RelatedFileCount <= 0) ? string.Empty : (((mod.SettingCount <= 0) ? string.Empty : " + ") + mod.RelatedFileCount + ((mod.RelatedFileCount != 1) ? " files" : " file")))) : ((mod.SettingCount <= 0) ? "no settings" : (mod.SettingCount + " settings")))); if (GUILayout.Button(new GUIContent(mod.Name + "\n<size=13><color=#9a958c>v" + mod.Version + " · " + text + "</color></size>"), val, Array.Empty<GUILayoutOption>())) { _selected = mod; _detailScroll = Vector2.zero; _settingSearch = string.Empty; } } } GUILayout.EndScrollView(); GUILayout.EndVertical(); } private void DrawDetails() { //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); ModEntry selectedView = _selectedView; if (selectedView == null) { GUILayout.Label("No mods loaded.", Styles.Muted, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); return; } GUILayout.Label(selectedView.Name, Styles.Heading, Array.Empty<GUILayoutOption>()); GUILayout.Label("v" + selectedView.Version + " " + selectedView.Guid + ((selectedView.Package == null) ? string.Empty : (" Thunderstore: " + selectedView.Package)), Styles.Muted, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (selectedView.Config != null && File.Exists(selectedView.Config.ConfigFilePath) && GUILayout.Button("Open config file", Styles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { OpenPath(selectedView.Config.ConfigFilePath); } if (!string.IsNullOrEmpty(selectedView.DllPath) && GUILayout.Button("Open mod folder", Styles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { OpenPath(Path.GetDirectoryName(selectedView.DllPath)); } if ((selectedView.Config != null || selectedView.Extras.Count > 0) && GUILayout.Button("Reload from file", Styles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { try { if (selectedView.Config != null) { selectedView.Config.Reload(); } } catch (Exception ex) { ModMenuPlugin.Log.LogError((object)ex.Message); } if (selectedView.Config != null) { selectedView.Sections = ConfigModel.BuildSections(selectedView.Config); } foreach (ConfigGroup item in selectedView.Extras.Where((ConfigGroup x) => !x.Offline)) { try { item.File.Reload(); } catch (Exception) { } item.Sections = ConfigModel.BuildSections(item.File); } LoadExtras(selectedView); _buffers.Clear(); _errors.Clear(); } if (selectedView.SettingCount > 0 && GUILayout.Button("Reset all", Styles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { foreach (ConfigEntryBase item2 in selectedView.AllEntries.ToList()) { SetValue(item2, item2.DefaultValue); } } GUILayout.EndHorizontal(); GUILayout.Space(10f); if (selectedView.SettingCount > 0) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Find setting", Styles.SearchLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }); _settingSearch = GUILayout.TextField(_settingSearch, Styles.Field, Array.Empty<GUILayoutOption>()); if (_settingSearchView.Length > 0) { int num = selectedView.Groups.SelectMany((ConfigGroup g) => g.Sections).Sum((SectionModel sec) => sec.Entries.Count((ConfigEntryBase en) => MatchesSetting(sec, en))); GUILayout.Label(num + " / " + selectedView.SettingCount, Styles.Highlight, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); if (GUILayout.Button("Clear", Styles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) })) { _settingSearch = string.Empty; GUI.FocusControl((string)null); } } GUILayout.EndHorizontal(); GUILayout.Space(8f); } _detailScroll = GUILayout.BeginScrollView(_detailScroll, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, Styles.ListBg, Array.Empty<GUILayoutOption>()); if (!selectedView.Loaded) { GUILayout.Label("This mod failed to load. Check BepInEx/LogOutput.log for the error.", Styles.Error, Array.Empty<GUILayoutOption>()); } else if (selectedView.SettingCount == 0) { GUILayout.Label("This mod has no settings ModMenu can edit.", Styles.Muted, Array.Empty<GUILayoutOption>()); List<string> list = ConfigModel.FindRelatedFiles(selectedView, _ownedConfigFiles); if (list.Count > 0) { GUILayout.Space(8f); GUILayout.Label("It may keep its settings in a separate file:", Styles.Muted, Array.Empty<GUILayoutOption>()); foreach (string item3 in list) { if (GUILayout.Button("Open " + Path.GetFileName(item3), Styles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { OpenPath(item3); } } } } else { bool flag = false; foreach (ConfigGroup group in selectedView.Groups) { List<SectionModel> list2 = group.Sections.Where((SectionModel s) => s.Entries.Any((ConfigEntryBase en) => MatchesSetting(s, en))).ToList(); if (list2.Count == 0) { continue; } if (group.Title != null) { DrawGroupHeader(group); } foreach (SectionModel item4 in list2) { DrawSection(selectedView, group, item4); } flag = true; } if (!flag) { GUILayout.Label("No settings named \"" + _settingSearchView + "\".", Styles.Muted, Array.Empty<GUILayoutOption>()); } } GUILayout.EndScrollView(); GUILayout.EndVertical(); } private void DrawGroupHeader(ConfigGroup g) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown GUILayout.Space(6f); GUILayout.BeginHorizontal(Styles.FileHeaderBar, Array.Empty<GUILayoutOption>()); GUILayout.Label(g.Title, Styles.FileHeader, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (g.Offline) { GUILayout.Label(new GUIContent("read from file · changes apply after restart", "ModMenu couldn't find this file's settings inside the running mod, so it edits the file directly. The mod reads it next time it loads."), Styles.FileTag, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } GUILayout.FlexibleSpace(); string text = ((g.File == null) ? g.Path : g.File.ConfigFilePath); if (!string.IsNullOrEmpty(text) && GUILayout.Button("Open file", Styles.Small, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { OpenPath(text); } GUILayout.EndHorizontal(); } private void DrawSection(ModEntry m, ConfigGroup g, SectionModel s) { string item = m.Guid + "/" + (g.Title ?? string.Empty) + "/" + s.Name; bool flag = _settingSearchView.Length <= 0 && _collapsedView.Contains(item); if (GUILayout.Button(((!flag) ? "▾ " : "▸ ") + s.Name.ToUpperInvariant(), Styles.SectionHeader, Array.Empty<GUILayoutOption>())) { if (_collapsedSections.Contains(item)) { _collapsedSections.Remove(item); } else { _collapsedSections.Add(item); } } if (flag) { return; } foreach (ConfigEntryBase entry in s.Entries) { if (MatchesSetting(s, entry)) { DrawEntry(entry); } } GUILayout.Space(10f); } private void DrawEntry(ConfigEntryBase e) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown EditorKind editorKind = ConfigModel.KindOf(e); bool flag = editorKind == EditorKind.Toggle || editorKind == EditorKind.Flags; GUILayout.BeginVertical(Styles.Row, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(new GUIContent(ConfigModel.Pretty(e.Definition.Key), e.Definition.Key), Styles.Key, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (flag) { GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); } else { GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); } switch (editorKind) { case EditorKind.Toggle: DrawToggle(e); break; case EditorKind.Slider: DrawSlider(e); break; case EditorKind.Enum: DrawEnum(e); break; case EditorKind.Flags: DrawFlags(e); break; case EditorKind.Choice: DrawChoice(e); break; default: DrawTextField(e); break; } GUILayout.EndVertical(); GUILayout.Space(6f); bool enabled = GUI.enabled; GUI.enabled = !ConfigModel.IsDefault(e); if (GUILayout.Button(new GUIContent((Texture)(object)Styles.ResetIcon, "Reset to default: " + ConfigModel.Format(e, e.DefaultValue)), Styles.IconButton, Array.Empty<GUILayoutOption>())) { SetValue(e, e.DefaultValue); } GUI.enabled = enabled; if (_changedView.Contains(e)) { switch (LiveApply.Get(_selectedView, e)) { case ApplyMode.Restart: GUILayout.Label(new GUIContent("Restart needed", "This mod only reads this setting when the game starts."), Styles.NoteRestart, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); break; case ApplyMode.Unknown: GUILayout.Label(new GUIContent("May need restart", "Couldn't tell from the mod's code whether it picks this up while running."), Styles.NoteMaybe, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); break; } } if (flag) { GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); if (_errorsView.TryGetValue(e, out var value)) { GUILayout.Label(value, Styles.Error, Array.Empty<GUILayoutOption>()); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); string text = ((e.Description != null) ? e.Description.Description : null); if (!string.IsNullOrEmpty(text)) { GUILayout.Label(text, Styles.Description, Array.Empty<GUILayoutOption>()); } GUILayout.EndVertical(); } private bool MatchesSetting(SectionModel section, ConfigEntryBase e) { string text = _settingSearchView.Trim(); if (text.Length == 0) { return true; } string key = e.Definition.Key; return key.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0 || ConfigModel.Pretty(key).IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0 || key.Replace(" ", string.Empty).IndexOf(text.Replace(" ", string.Empty), StringComparison.OrdinalIgnoreCase) >= 0 || section.Name.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0; } private void DrawToggle(ConfigEntryBase e) { bool flag = (bool)e.BoxedValue; bool flag2 = GUILayout.Toggle(flag, (!flag) ? "Off" : "On", Styles.Toggle, Array.Empty<GUILayoutOption>()); if (flag2 != flag) { SetValue(e, flag2); } } private void DrawSlider(ConfigEntryBase e) { ConfigModel.TryGetRange(e, out var min, out var max); double num = Convert.ToDouble(e.BoxedValue, CultureInfo.InvariantCulture); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(ConfigModel.Format(e, ConfigModel.FromSlider(e, min)), Styles.Muted, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); float num2 = GUILayout.HorizontalSlider((float)num, (float)min, (float)max, Styles.Slider, Styles.SliderThumb, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(28f) }); GUILayout.Label(ConfigModel.Format(e, ConfigModel.FromSlider(e, max)), Styles.Muted, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (Math.Abs((double)num2 - num) > 1E-06) { SetValue(e, ConfigModel.FromSlider(e, num2)); _buffers.Remove(e); } DrawTextField(e, 110f); GUILayout.EndHorizontal(); } private void DrawEnum(ConfigEntryBase e) { string[] names = Enum.GetNames(e.SettingType); object[] array = Enum.GetValues(e.SettingType).Cast<object>().ToArray(); DrawOptions(e, array.Select((object v, int i) => ConfigModel.Pretty(names[i])).ToArray(), array); } private void DrawChoice(ConfigEntryBase e) { object[] array = ConfigModel.ChoicesOf(e); DrawOptions(e, array.Select((object v) => ConfigModel.Format(e, v)).ToArray(), array); } private void DrawOptions(ConfigEntryBase e, string[] labels, object[] values) { int num = Array.FindIndex(values, (object v) => object.Equals(v, e.BoxedValue)); if (labels.Length <= 5) { int num2 = GUILayout.SelectionGrid(num, labels, labels.Length, Styles.Option, Array.Empty<GUILayoutOption>()); if (num2 != num && num2 >= 0) { SetValue(e, values[num2]); } return; } bool flag = _expandedView.Contains(e); if (GUILayout.Button(((num < 0) ? ConfigModel.Format(e) : labels[num]) + ((!flag) ? " ▾" : " ▴"), Styles.Dropdown, Array.Empty<GUILayoutOption>())) { if (_expanded.Contains(e)) { _expanded.Remove(e); } else { _expanded.Add(e); } } if (flag) { int num3 = GUILayout.SelectionGrid(num, labels, 3, Styles.Option, Array.Empty<GUILayoutOption>()); if (num3 != num && num3 >= 0) { SetValue(e, values[num3]); _expanded.Remove(e); } } } private void DrawFlags(ConfigEntryBase e) { Type settingType = e.SettingType; long num = Convert.ToInt64(e.BoxedValue); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int num2 = 0; foreach (object value in Enum.GetValues(settingType)) { long num3 = Convert.ToInt64(value); if (num3 != 0) { bool flag = (num & num3) == num3; bool flag2 = GUILayout.Toggle(flag, ConfigModel.Pretty(Enum.GetName(settingType, value)), Styles.FlagToggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); if (flag2 != flag) { SetValue(e, Enum.ToObject(settingType, (!flag2) ? (num & ~num3) : (num | num3))); } if (++num2 % 4 == 0) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); } } } GUILayout.EndHorizontal(); } private void DrawTextField(ConfigEntryBase e) { DrawTextField(e, -1f); } private void DrawTextField(ConfigEntryBase e, float width) { if (!_buffers.TryGetValue(e, out var value)) { value = ConfigModel.Format(e); } GUIStyle val = ((!_errors.ContainsKey(e)) ? Styles.Field : Styles.FieldError); string text = ((!(width > 0f)) ? GUILayout.TextField(value, val, Array.Empty<GUILayoutOption>()) : GUILayout.TextField(value, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) })); if (text == value) { return; } _buffers[e] = text; if (ConfigModel.TryParse(e, text, out var value2, out var error)) { _errors.Remove(e); if (ConfigModel.Apply(e, value2)) { _changed.Add(e); } } else { _errors[e] = error; } } private void SetValue(ConfigEntryBase e, object value) { if (ConfigModel.Apply(e, value)) { _changed.Add(e); } _buffers.Remove(e); _errors.Remove(e); } private static void OpenPath(string path) { try { Application.OpenURL("file:///" + path.Replace('\\', '/')); } catch (Exception ex) { ModMenuPlugin.Log.LogError((object)("Could not open " + path + ": " + ex.Message)); } } } [BepInPlugin("modmenu.lethalcompany", "ModMenu", "1.2.0")] public class ModMenuPlugin : BaseUnityPlugin { public const string Guid = "modmenu.lethalcompany"; public const string Name = "ModMenu"; public const string Version = "1.2.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; new Harmony("modmenu.lethalcompany").PatchAll(typeof(ModMenuPlugin).Assembly); GameObject val = new GameObject("ModMenu"); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<ModMenuWindow>(); Log.LogInfo((object)"ModMenu 1.2.0 loaded."); } } [HarmonyPatch(typeof(QuickMenuManager), "Start")] [HarmonyWrapSafe] internal static class QuickMenuStartPatch { [HarmonyPostfix] private static void Postfix(QuickMenuManager __instance) { MenuButtonInjector.Inject(__instance.mainButtonsPanel, MenuButtonInjector.Placement.AboveFirst, __instance.menuContainer); } } [HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")] [HarmonyWrapSafe] internal static class QuickMenuClosePatch { [HarmonyPrefix] private static bool Prefix() { ModMenuWindow instance = ModMenuWindow.Instance; if ((Object)(object)instance == (Object)null || !instance.IsOpen) { return true; } Keyboard current = Keyboard.current; if (current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) { instance.Close(); return false; } return true; } } [HarmonyPatch(typeof(MenuManager), "Start")] [HarmonyWrapSafe] internal static class MenuStartPatch { [HarmonyPostfix] private static void Postfix(MenuManager __instance) { if (!__instance.isInitScene) { MenuButtonInjector.Inject(__instance.menuButtons, MenuButtonInjector.Placement.RightOfFirst, null); } } } internal static class Styles { public static GUIStyle Dim; public static GUIStyle Panel; public static GUIStyle ListBg; public static GUIStyle Title; public static GUIStyle Heading; public static GUIStyle Muted; public static GUIStyle Notice; public static GUIStyle Error; public static GUIStyle Description; public static GUIStyle Key; public static GUIStyle Button; public static GUIStyle Accent; public static GUIStyle Small; public static GUIStyle ListItem; public static GUIStyle ListItemSelected; public static GUIStyle SectionHeader; public static GUIStyle Row; public static GUIStyle Field; public static GUIStyle FieldError; public static GUIStyle Toggle; public static GUIStyle FlagToggle; public static GUIStyle Option; public static GUIStyle Dropdown; public static GUIStyle Slider; public static GUIStyle SliderThumb; public static GUIStyle SearchLabel; public static GUIStyle Highlight; public static GUIStyle IconButton; public static GUIStyle NoteRestart; public static GUIStyle NoteMaybe; public static GUIStyle Tooltip; public static GUIStyle FileHeader; public static GUIStyle FileHeaderBar; public static GUIStyle FileTag; public static Texture2D ResetIcon; private static bool _ready; private static readonly Color Bg = Hex(1118227); private static readonly Color Surface = Hex(1775901); private static readonly Color Surface2 = Hex(2499370); private static readonly Color Line = Hex(3814720); private static readonly Color Text = Hex(15328474); private static readonly Color TextMuted = Hex(10130828); private static readonly Color Orange = Hex(15228970); private static readonly Color OrangeDark = Hex(11027228); private static readonly Color Red = Hex(16739166); public static void Init() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_011f: 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) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Expected O, but got Unknown //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Expected O, but got Unknown //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Expected O, but got Unknown //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Expected O, but got Unknown //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Expected O, but got Unknown //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Expected O, but got Unknown //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Expected O, but got Unknown //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Expected O, but got Unknown //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Expected O, but got Unknown //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Expected O, but got Unknown //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0584: 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_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Expected O, but got Unknown //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Expected O, but got Unknown //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Expected O, but got Unknown //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Expected O, but got Unknown //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Expected O, but got Unknown //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06d5: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Expected O, but got Unknown //IL_0732: Unknown result type (might be due to invalid IL or missing references) //IL_073c: Expected O, but got Unknown //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_0765: Expected O, but got Unknown //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Expected O, but got Unknown //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_07af: Expected O, but got Unknown //IL_07b1: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Unknown result type (might be due to invalid IL or missing references) //IL_0870: Unknown result type (might be due to invalid IL or missing references) //IL_087a: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_08a9: 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_08d9: Unknown result type (might be due to invalid IL or missing references) //IL_08e4: Unknown result type (might be due to invalid IL or missing references) //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_08f0: 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_08fa: Unknown result type (might be due to invalid IL or missing references) //IL_0920: Unknown result type (might be due to invalid IL or missing references) //IL_0925: Unknown result type (might be due to invalid IL or missing references) //IL_094d: Unknown result type (might be due to invalid IL or missing references) //IL_0957: Expected O, but got Unknown //IL_0961: Unknown result type (might be due to invalid IL or missing references) //IL_096b: Expected O, but got Unknown //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_099e: Unknown result type (might be due to invalid IL or missing references) //IL_09a8: Expected O, but got Unknown //IL_09b2: Unknown result type (might be due to invalid IL or missing references) //IL_09bc: Expected O, but got Unknown //IL_09c6: Unknown result type (might be due to invalid IL or missing references) //IL_0a1b: Unknown result type (might be due to invalid IL or missing references) //IL_0a21: Expected O, but got Unknown //IL_0a86: Unknown result type (might be due to invalid IL or missing references) //IL_0a90: Expected O, but got Unknown //IL_0ad0: Unknown result type (might be due to invalid IL or missing references) //IL_0ada: Expected O, but got Unknown //IL_0aed: Unknown result type (might be due to invalid IL or missing references) //IL_0af7: Expected O, but got Unknown //IL_0b0a: Unknown result type (might be due to invalid IL or missing references) //IL_0b11: Expected O, but got Unknown if (!_ready) { _ready = true; Dim = Box(new Color(0f, 0f, 0f, 0.72f)); Panel = Box(Bg); Panel.normal.background = Framed(Bg, Orange); Panel.border = new RectOffset(1, 1, 1, 1); ListBg = Box(Surface); ListBg.padding = new RectOffset(6, 6, 6, 6); Title = Label(34, Orange, (FontStyle)1); Title.margin.right = 14; Heading = Label(26, Text, (FontStyle)1); Muted = Label(15, TextMuted, (FontStyle)0); Muted.alignment = (TextAnchor)3; Notice = Label(15, Orange, (FontStyle)0); Notice.wordWrap = true; Error = Label(14, Red, (FontStyle)0); Description = Label(14, Hex(11775394), (FontStyle)0); Description.wordWrap = true; Description.normal.background = Tex(Hex(1315350)); Description.padding = new RectOffset(12, 12, 8, 9); Description.margin = new RectOffset(0, 0, 8, 2); Key = Label(17, Text, (FontStyle)0); Key.wordWrap = true; Key.alignment = (TextAnchor)3; Key.padding = new RectOffset(0, 12, 6, 6); Button = Btn(Surface2, Hex(3354424), Text, 16); Accent = Btn(OrangeDark, Orange, Text, 16); Small = Btn(Surface2, Hex(3354424), Text, 13); Small.fixedHeight = 26f; ListItem = Btn(Surface, Surface2, Text, 17); ListItem.alignment = (TextAnchor)3; ListItem.richText = true; ListItem.wordWrap = false; ListItem.padding = new RectOffset(14, 10, 8, 8); ListItem.margin = new RectOffset(0, 0, 1, 1); ListItem.fixedHeight = 0f; ListItemSelected = new GUIStyle(ListItem); GUIStyleState normal = ListItemSelected.normal; Texture2D background = Framed(Surface2, Orange, left: true); ListItemSelected.hover.background = background; normal.background = background; GUIStyleState normal2 = ListItemSelected.normal; Color orange = Orange; ListItemSelected.hover.textColor = orange; normal2.textColor = orange; ListItemSelected.border = new RectOffset(3, 0, 0, 0); SectionHeader = Btn(Bg, Bg, Orange, 15); SectionHeader.alignment = (TextAnchor)3; SectionHeader.fontStyle = (FontStyle)1; SectionHeader.padding = new RectOffset(6, 6, 10, 6); SectionHeader.hover.textColor = Text; Row = Box(Surface2); Row.padding = new RectOffset(12, 12, 10, 8); Row.margin = new RectOffset(0, 0, 3, 3); GUIStyle val = new GUIStyle(GUI.skin.textField); val.fontSize = 16; val.padding = new RectOffset(10, 10, 6, 6); val.fixedHeight = 32f; Field = val; GUIStyleState normal3 = Field.normal; background = Framed(Bg, Line); Field.hover.background = background; normal3.background = background; Field.focused.background = Framed(Bg, Orange); GUIStyleState normal4 = Field.normal; orange = Text; Field.focused.textColor = orange; orange = orange; Field.hover.textColor = orange; normal4.textColor = orange; Field.border = new RectOffset(1, 1, 1, 1); FieldError = new GUIStyle(Field); GUIStyleState normal5 = FieldError.normal; background = Framed(Bg, Red); FieldError.focused.background = background; background = background; FieldError.hover.background = background; normal5.background = background; Toggle = Btn(Surface, Hex(3354424), TextMuted, 16); Toggle.alignment = (TextAnchor)4; Toggle.padding = new RectOffset(0, 0, 0, 0); Toggle.fixedHeight = 32f; Toggle.fixedWidth = 84f; GUIStyleState onNormal = Toggle.onNormal; background = Tex(OrangeDark); Toggle.onActive.background = background; background = background; Toggle.onHover.background = background; onNormal.background = background; GUIStyleState onNormal2 = Toggle.onNormal; orange = Text; Toggle.onHover.textColor = orange; onNormal2.textColor = orange; Toggle.hover.textColor = Text; Toggle.imagePosition = (ImagePosition)3; val = new GUIStyle(Toggle); val.alignment = (TextAnchor)3; val.fixedWidth = 0f; val.padding = new RectOffset(12, 14, 0, 0); FlagToggle = val; FlagToggle.margin = new RectOffset(0, 6, 2, 2); ResetIcon = MakeResetIcon(64, Text); IconButton = Btn(Surface, Hex(3814720), Text, 14); IconButton.fixedWidth = 32f; IconButton.fixedHeight = 32f; IconButton.padding = new RectOffset(6, 6, 6, 6); IconButton.imagePosition = (ImagePosition)2; IconButton.alignment = (TextAnchor)4; IconButton.margin = new RectOffset(0, 8, 0, 0); NoteRestart = Label(14, Orange, (FontStyle)1); NoteRestart.alignment = (TextAnchor)3; NoteRestart.fixedHeight = 32f; NoteMaybe = Label(14, TextMuted, (FontStyle)0); NoteMaybe.alignment = (TextAnchor)3; NoteMaybe.fixedHeight = 32f; Tooltip = Label(14, Text, (FontStyle)0); Tooltip.wordWrap = true; Tooltip.normal.background = Framed(Hex(789261), Line); Tooltip.border = new RectOffset(1, 1, 1, 1); Tooltip.padding = new RectOffset(10, 10, 6, 7); FileHeaderBar = Box(Hex(1973025)); FileHeaderBar.padding = new RectOffset(12, 10, 6, 6); FileHeaderBar.margin = new RectOffset(0, 0, 4, 4); FileHeaderBar.normal.background = Framed(Hex(1973025), OrangeDark, left: true); FileHeaderBar.border = new RectOffset(3, 0, 0, 0); FileHeader = Label(18, Text, (FontStyle)1); FileHeader.alignment = (TextAnchor)3; FileHeader.fixedHeight = 28f; FileHeader.margin.right = 14; FileTag = Label(13, TextMuted, (FontStyle)0); FileTag.alignment = (TextAnchor)3; FileTag.fixedHeight = 28f; SearchLabel = Label(15, TextMuted, (FontStyle)0); SearchLabel.alignment = (TextAnchor)3; SearchLabel.fixedHeight = 32f; Highlight = Label(15, Orange, (FontStyle)0); Highlight.alignment = (TextAnchor)3; Highlight.fixedHeight = 32f; Option = Btn(Surface, Hex(3354424), TextMuted, 15); Option.fixedHeight = 32f; GUIStyleState onNormal3 = Option.onNormal; background = Tex(OrangeDark); Option.onHover.background = background; onNormal3.background = background; GUIStyleState onNormal4 = Option.onNormal; orange = Text; Option.onHover.textColor = orange; onNormal4.textColor = orange; Dropdown = Btn(Bg, Surface, Text, 16); Dropdown.alignment = (TextAnchor)3; Dropdown.normal.background = Framed(Bg, Line); Dropdown.fixedHeight = 32f; Dropdown.border = new RectOffset(1, 1, 1, 1); Slider = new GUIStyle(GUI.skin.horizontalSlider); Slider.normal.background = Tex(Line); Slider.fixedHeight = 6f; Slider.margin = new RectOffset(8, 8, 13, 13); SliderThumb = new GUIStyle(GUI.skin.horizontalSliderThumb); GUIStyleState normal6 = SliderThumb.normal; background = Tex(Orange); SliderThumb.active.background = background; background = background; SliderThumb.hover.background = background; normal6.background = background; SliderThumb.fixedWidth = 16f; SliderThumb.fixedHeight = 22f; RectOffset val2 = new RectOffset(0, 0, 2, 2); GUIStyle[] array = (GUIStyle[])(object)new GUIStyle[5] { Toggle, Field, FieldError, Option, Dropdown }; foreach (GUIStyle val3 in array) { val3.margin = new RectOffset(val3.margin.left, val3.margin.right, val2.top, val2.bottom); } FlagToggle.margin = new RectOffset(FlagToggle.margin.left, FlagToggle.margin.right, val2.top, val2.bottom); IconButton.margin = new RectOffset(0, 8, val2.top, val2.bottom); GUIStyle noteRestart = NoteRestart; RectOffset margin = new RectOffset(0, 8, val2.top, val2.bottom); NoteMaybe.margin = margin; noteRestart.margin = margin; } } internal static Texture2D MakeResetIcon(int n, Color color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(n, n, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Texture2D val2 = val; Color[] array = (Color[])(object)new Color[n * n]; float num = (float)(n - 1) / 2f; float num2 = (float)n * 0.4f; float num3 = (float)n * 0.27f; float num4 = 0.34906584f; float num5 = (num2 + num3) / 2f; float num6 = (num2 - num3) * 1.15f; Vector2 a = default(Vector2); ((Vector2)(ref a))..ctor(num + num5 * Mathf.Cos(num4 + 0.62f), num + num5 * Mathf.Sin(num4 + 0.62f)); Vector2 b = default(Vector2); ((Vector2)(ref b))..ctor(num + (num5 + num6) * Mathf.Cos(num4), num + (num5 + num6) * Mathf.Sin(num4)); Vector2 c = default(Vector2); ((Vector2)(ref c))..ctor(num + (num5 - num6) * Mathf.Cos(num4), num + (num5 - num6) * Mathf.Sin(num4)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int num7 = 0; for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { float num8 = (float)j + ((float)l + 0.5f) / 4f - 0.5f; float num9 = (float)i + ((float)k + 0.5f) / 4f - 0.5f; float num10 = num8 - num; float num11 = num9 - num; float num12 = Mathf.Sqrt(num10 * num10 + num11 * num11); float num13 = Mathf.Atan2(num11, num10) * 57.29578f; if (num13 < 0f) { num13 += 360f; } if ((num12 >= num3 && num12 <= num2 && (!(num13 > 20f) || !(num13 < 80f))) || InTri(new Vector2(num8, num9), a, b, c)) { num7++; } } } Color val3 = color; val3.a = (float)num7 / 16f; array[i * n + j] = val3; } } val2.SetPixels(array); val2.Apply(); return val2; } private static bool InTri(Vector2 p, Vector2 a, Vector2 b, Vector2 c) { float num = (p.x - b.x) * (a.y - b.y) - (a.x - b.x) * (p.y - b.y); float num2 = (p.x - c.x) * (b.y - c.y) - (b.x - c.x) * (p.y - c.y); float num3 = (p.x - a.x) * (c.y - a.y) - (c.x - a.x) * (p.y - a.y); bool flag = num < 0f || num2 < 0f || num3 < 0f; bool flag2 = num > 0f || num2 > 0f || num3 > 0f; return !flag || !flag2; } private static GUIStyle Box(Color c) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: 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_0030: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.box); val.normal.background = Tex(c); val.border = new RectOffset(0, 0, 0, 0); return val; } private static GUIStyle Label(int size, Color c, FontStyle f = (FontStyle)0) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label); val.fontSize = size; val.fontStyle = f; val.richText = true; GUIStyle val2 = val; val2.normal.textColor = c; return val2; } private static GUIStyle Btn(Color bg, Color hover, Color text, int size) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.button); val.fontSize = size; val.padding = new RectOffset(14, 14, 6, 6); val.fixedHeight = 34f; GUIStyle val2 = val; val2.normal.background = Tex(bg); val2.hover.background = Tex(hover); val2.active.background = Tex(Orange); val2.focused.background = Tex(bg); GUIStyleState normal = val2.normal; val2.focused.textColor = text; normal.textColor = text; val2.hover.textColor = Text; val2.active.textColor = Color.white; val2.border = new RectOffset(0, 0, 0, 0); return val2; } private static Texture2D Tex(Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1); ((Object)val).hideFlags = (HideFlags)61; Texture2D val2 = val; val2.SetPixel(0, 0, c); val2.Apply(); return val2; } private static Texture2D Framed(Color fill, Color edge, bool left = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0062: 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) Texture2D val = new Texture2D(8, 8); ((Object)val).hideFlags = (HideFlags)61; ((Texture)val).filterMode = (FilterMode)0; Texture2D val2 = val; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { bool flag = ((!left) ? (i == 0 || j == 0 || i == 7 || j == 7) : (i < 3)); val2.SetPixel(i, j, (!flag) ? fill : edge); } } val2.Apply(); return val2; } private static Color Hex(int rgb) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f, 1f); } }