Decompiled source of cfgMenu v1.0.0
cfgmenu.dll
Decompiled 7 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Microsoft.CodeAnalysis; using Rewired; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using cfgMenu.Api; using cfgMenu.Configuration; using cfgMenu.Localization; using cfgMenu.Runtime; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Go Go Gadget Justice CFG Menu")] [assembly: AssemblyDescription("Edit CFG files live in game")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } internal static class EnumHelper { public static T OrValue<T>(bool useFallback, T value, int fallback) where T : struct, Enum { return useFallback ? ((T)Enum.ToObject(typeof(T), fallback)) : value; } } namespace cfgMenu { [BepInPlugin("gogogadgetjustice.BigWalk.cfgmenu", "cfgmenu", "1.0.0")] public class cfgMenu : BasePlugin { private Harmony _harmony; internal static ManualLogSource Logger { get; private set; } public override void Load() { //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown Logger = ((BasePlugin)this).Log; ModSettingsRegistry.RefreshRequested += RefreshMenus; bool flag = false; try { Logger.LogInfo((object)"============================================="); ManualLogSource logger = Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("cfgMenu"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(I18n.Text("plugin.initializing")); } logger.LogInfo(val); ManualLogSource logger2 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(I18n.Text("plugin.author_prefix")); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("gogogadgetjustice of /r/bigwalkmodding(https://reddit.com/r/bigwalkmodding/)"); } logger2.LogInfo(val); ClassInjector.RegisterTypeInIl2Cpp<ModSettingsInput>(); _harmony = new Harmony("gogogadgetjustice.BigWalk.cfgMenu"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ManualLogSource logger3 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("cfgMenu"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(I18n.Text("plugin.initialized")); } logger3.LogInfo(val); Logger.LogInfo((object)"============================================="); } catch (Exception ex) { ManualLogSource logger4 = Logger; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to initialize cfg settings menu: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } logger4.LogError(val2); } } private static void RefreshMenus() { cfgMenuController.RefreshLocalizedText(); } } public static class PluginInfo { public const string PLUGIN_GUID = "gogogadgetjustice.BigWalk.cfgMenu"; public const string PLUGIN_NAME = "cfgMenu"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace cfgMenu.Api { public sealed class ModSettingsEntryTag { public int? Order { get; set; } public double? SliderStep { get; set; } } public sealed class ModSettingsModOptions { public string Name { get; set; } public Func<string> LocalizedName { get; set; } public string Description { get; set; } public string Author { get; set; } public string Version { get; set; } public int? NexusModsId { get; set; } public string ThunderstoreTeam { get; set; } public string ThunderstoreModName { get; set; } } public sealed class ModSettingsRegistration { public string PluginGuid { get; } public string Name { get; private set; } public Func<string> LocalizedName { get; private set; } public string Description { get; private set; } public string Author { get; private set; } public string Version { get; private set; } public int? NexusModsId { get; private set; } public string ThunderstoreTeam { get; private set; } public string ThunderstoreModName { get; private set; } internal ModSettingsRegistration(string pluginGuid, ModSettingsModOptions options) { PluginGuid = pluginGuid ?? throw new ArgumentNullException("pluginGuid"); if (options != null && options.NexusModsId.HasValue) { ModSettingsRegistry.GetNexusModsUrl(options.NexusModsId.Value); } bool flag = !string.IsNullOrWhiteSpace(options?.ThunderstoreTeam); bool flag2 = !string.IsNullOrWhiteSpace(options?.ThunderstoreModName); if (flag != flag2) { throw new ArgumentException("Thunderstore team and mod name must be provided together.", "options"); } if (flag) { ModSettingsRegistry.GetThunderstoreUrl(options.ThunderstoreTeam, options.ThunderstoreModName); } Name = options?.Name; LocalizedName = options?.LocalizedName; Description = options?.Description; Author = options?.Author; Version = options?.Version; NexusModsId = options?.NexusModsId; ThunderstoreTeam = (flag ? options.ThunderstoreTeam.Trim() : null); ThunderstoreModName = (flag2 ? options.ThunderstoreModName.Trim() : null); } public string GetName() { if (LocalizedName != null) { try { string text = LocalizedName(); if (!string.IsNullOrWhiteSpace(text) && !string.Equals(text, "mod.name", StringComparison.Ordinal)) { return text; } } catch (Exception ex) { ManualLogSource logger = cfgMenu.Logger; if (logger != null) { logger.LogError((object)("Localized mod name callback failed for " + PluginGuid + ": " + ex)); } } } return GetText("mod.name", Name); } public string GetDescription() { return GetText("mod.description", Description); } private string GetText(string key, string fallback) { return fallback; } } public static class ModSettingsRegistry { public const string NexusModsGameUrl = "https://www.nexusmods.com/games/bigwalk"; public const string ThunderstoreGameUrl = "https://thunderstore.io/c/big-walk/"; private const string NexusModsModUrlPrefix = "https://www.nexusmods.com/bigwalk/mods/"; private const string ThunderstoreModUrlPrefix = "https://thunderstore.io/c/big-walk/p/"; private static readonly object Sync = new object(); private static readonly Dictionary<string, ModSettingsRegistration> Registrations = new Dictionary<string, ModSettingsRegistration>(StringComparer.OrdinalIgnoreCase); internal static event Action RefreshRequested; public static ModSettingsRegistration Register(string pluginGuid, ModSettingsModOptions options = null) { if (string.IsNullOrWhiteSpace(pluginGuid)) { throw new ArgumentException("Plugin GUID cannot be empty.", "pluginGuid"); } ModSettingsRegistration modSettingsRegistration = new ModSettingsRegistration(pluginGuid, options); lock (Sync) { Registrations[pluginGuid] = modSettingsRegistration; } RequestRefresh(); return modSettingsRegistration; } public static bool Unregister(string pluginGuid) { bool flag; lock (Sync) { flag = !string.IsNullOrWhiteSpace(pluginGuid) && Registrations.Remove(pluginGuid); } if (flag) { RequestRefresh(); } return flag; } public static string GetNexusModsUrl(int nexusModsId) { if (nexusModsId <= 0) { throw new ArgumentOutOfRangeException("nexusModsId", nexusModsId, "Nexus Mods ID must be a positive integer."); } return "https://www.nexusmods.com/bigwalk/mods/" + nexusModsId.ToString(CultureInfo.InvariantCulture); } public static string GetThunderstoreUrl(string team, string modName) { ValidateThunderstoreName(team, "team"); ValidateThunderstoreName(modName, "modName"); return "https://thunderstore.io/c/big-walk/p/" + team.Trim() + "/" + modName.Trim() + "/"; } internal static bool TryGet(string pluginGuid, out ModSettingsRegistration registration) { registration = null; lock (Sync) { return !string.IsNullOrWhiteSpace(pluginGuid) && Registrations.TryGetValue(pluginGuid, out registration); } } internal static void RequestRefresh() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown Action refreshRequested = ModSettingsRegistry.RefreshRequested; if (refreshRequested == null) { return; } Delegate[] invocationList = refreshRequested.GetInvocationList(); bool flag = false; Delegate[] array = invocationList; foreach (Delegate obj in array) { try { ((Action)obj)(); } catch (Exception ex) { ManualLogSource logger = cfgMenu.Logger; if (logger != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("cfg settings refresh callback failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); } } } } private static void ValidateThunderstoreName(string value, string paramName) { if (string.IsNullOrWhiteSpace(value)) { throw new ArgumentException("Thunderstore team and mod names cannot be empty.", paramName); } string text = value.Trim(); string text2 = text; foreach (char c in text2) { if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '_') { throw new ArgumentException("Thunderstore team and mod names may only contain ASCII letters, numbers, and underscores.", paramName); } } } } public sealed class ModSettingsSectionTag { public string Section { get; set; } public int? Order { get; set; } } public static class ModSettingsTags { public static ModSettingsEntryTag Entry(int? order = null, double? sliderStep = null) { return new ModSettingsEntryTag { Order = order, SliderStep = sliderStep }; } public static ModSettingsSectionTag Section(string section, int? order = null) { return new ModSettingsSectionTag { Section = section, Order = order }; } } } namespace cfgMenu.Configuration { internal static class ConfigValues { public static bool TrySetValue(ConfigEntryBase entry, object value) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown try { entry.BoxedValue = value; entry.ConfigFile.Save(); return true; } catch (Exception ex) { ManualLogSource logger = cfgMenu.Logger; bool flag = false; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to save setting "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ConfigDefinition>(entry.Definition); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); return false; } } public static bool TrySetSerializedValue(ConfigEntryBase entry, string value) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown try { entry.SetSerializedValue(value); entry.ConfigFile.Save(); return true; } catch (Exception ex) { ManualLogSource logger = cfgMenu.Logger; bool flag = false; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to save setting "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ConfigDefinition>(entry.Definition); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); return false; } } public static bool TryReset(ConfigFile config) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown bool saveOnConfigSet = config.SaveOnConfigSet; try { config.SaveOnConfigSet = false; foreach (ConfigEntryBase value in config.Values) { value.BoxedValue = value.DefaultValue; } config.Save(); return true; } catch (Exception ex) { ManualLogSource logger = cfgMenu.Logger; bool flag = false; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to restore default settings: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); return false; } finally { config.SaveOnConfigSet = saveOnConfigSet; } } public static string FormatValue(object value) { if (value == null) { return string.Empty; } if (value is IFormattable formattable) { return formattable.ToString(null, CultureInfo.InvariantCulture) ?? string.Empty; } return value.ToString() ?? string.Empty; } public static object ConvertSliderValue(float sliderValue, double min, double max, double step, float stepCount, Type targetType) { double value = ((sliderValue >= stepCount) ? max : (min + step * Math.Round(sliderValue))); value = SnapSliderValue(value, min, max, step); if (targetType == typeof(float)) { return (float)value; } if (targetType == typeof(double)) { return value; } if (targetType == typeof(decimal)) { return (decimal)value; } if (targetType == typeof(byte)) { return (byte)Math.Round(value); } if (targetType == typeof(sbyte)) { return (sbyte)Math.Round(value); } if (targetType == typeof(short)) { return (short)Math.Round(value); } if (targetType == typeof(ushort)) { return (ushort)Math.Round(value); } if (targetType == typeof(int)) { return (int)Math.Round(value); } if (targetType == typeof(uint)) { return (uint)Math.Round(value); } if (targetType == typeof(long)) { return (long)Math.Round(value); } if (targetType == typeof(ulong)) { return (ulong)Math.Round(value); } return value; } public static double GetSliderStep(Type type, double min, double max, double? configuredStep) { return Math.Min((configuredStep.HasValue && double.IsFinite(configuredStep.Value) && configuredStep.Value > 0.0) ? configuredStep.Value : (IsIntegralType(type) ? 1.0 : 0.1), max - min); } public static float GetSliderStepCount(double min, double max, double step) { double num = (max - min) / step; double num2 = Math.Round(num); double val = ((Math.Abs(num - num2) < 1E-06) ? num2 : Math.Ceiling(num)); return (float)Math.Max(1.0, Math.Min(3.4028234663852886E+38, val)); } public static float GetSliderStepIndex(object value, double min, double max, double step, float stepCount) { double num = Convert.ToDouble(value, CultureInfo.InvariantCulture); if (num >= max) { return stepCount; } double val = Math.Round((num - min) / step); return (float)Math.Max(0.0, Math.Min(stepCount, val)); } public static bool IsSliderType(Type type) { if (!(type == typeof(byte)) && !(type == typeof(sbyte)) && !(type == typeof(short)) && !(type == typeof(ushort)) && !(type == typeof(int)) && !(type == typeof(uint)) && !(type == typeof(long)) && !(type == typeof(ulong)) && !(type == typeof(float)) && !(type == typeof(double))) { return type == typeof(decimal); } return true; } public static bool IsIntegralType(Type type) { if (!(type == typeof(byte)) && !(type == typeof(sbyte)) && !(type == typeof(short)) && !(type == typeof(ushort)) && !(type == typeof(int)) && !(type == typeof(uint)) && !(type == typeof(long))) { return type == typeof(ulong); } return true; } private static double SnapSliderValue(double value, double min, double max, double step) { if (value <= min) { return min; } if (value >= max) { return max; } value = min + Math.Round((value - min) / step) * step; return Math.Max(min, Math.Min(max, value)); } public static bool TryGetAcceptableValues(AcceptableValueBase acceptable, out IReadOnlyList<object> values) { values = Array.Empty<object>(); if (acceptable == null) { return false; } if (!(((object)acceptable).GetType().GetProperty("AcceptableValues")?.GetValue(acceptable) is IEnumerable source)) { return false; } values = source.Cast<object>().ToList(); return values.Count > 0; } public static bool TryGetNumericRange(AcceptableValueBase acceptable, out double min, out double max) { min = 0.0; max = 1.0; if (acceptable == null) { return false; } Type type = ((object)acceptable).GetType(); PropertyInfo property = type.GetProperty("MinValue"); PropertyInfo property2 = type.GetProperty("MaxValue"); if (property == null || property2 == null) { return false; } try { min = Convert.ToDouble(property.GetValue(acceptable), CultureInfo.InvariantCulture); max = Convert.ToDouble(property2.GetValue(acceptable), CultureInfo.InvariantCulture); return double.IsFinite(min) && double.IsFinite(max) && min < max; } catch { return false; } } } public sealed class ModConfig { public PluginInfo Info; public ConfigFile ConfigFile; public ModSettingsRegistration Registration; } public static class ModConfigs { public static IReadOnlyList<ModConfig> Load() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown List<ModConfig> list = new List<ModConfig>(); if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance)?.Plugins == null) { return list; } foreach (PluginInfo item in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values.Where((PluginInfo info) => ((info != null) ? info.Metadata : null) != null).OrderBy<PluginInfo, string>((PluginInfo info) => info.Metadata.Name, StringComparer.OrdinalIgnoreCase).ToList()) { if (!string.Equals(item.Metadata.GUID, "gogogadgetjustice.BigWalk.CFGMenu", StringComparison.OrdinalIgnoreCase)) { object instance = item.Instance; BasePlugin val = (BasePlugin)((instance is BasePlugin) ? instance : null); if (val != null && val.Config != null && val.Config.Values.Count != 0) { list.Add(new ModConfig { Info = item, ConfigFile = val.Config, Registration = (ModSettingsRegistry.TryGet(item.Metadata.GUID, out var registration) ? registration : null) }); } } } return list; } } internal static class ModSettingsOrder { private const int DefaultOrder = 1000; internal static int GetSectionOrder(ModConfig mod, string section) { int? num = null; object obj; if (mod == null) { obj = null; } else { ConfigFile configFile = mod.ConfigFile; obj = ((configFile != null) ? configFile.Values.ToArray() : null); } if (obj == null) { obj = Array.Empty<ConfigEntryBase>(); } ConfigEntryBase[] array = (ConfigEntryBase[])obj; ConfigEntryBase[] array2 = array; foreach (ConfigEntryBase val in array2) { if (!string.Equals(val.Definition.Section, section, StringComparison.Ordinal)) { continue; } ConfigDescription description = val.Description; object[] array3 = ((description != null) ? description.Tags : null) ?? Array.Empty<object>(); object[] array4 = array3; foreach (object obj2 in array4) { int order; if (obj2 is ModSettingsSectionTag modSettingsSectionTag) { if (string.Equals(modSettingsSectionTag.Section, section, StringComparison.Ordinal) && modSettingsSectionTag.Order.HasValue) { num = modSettingsSectionTag.Order.Value; } } else if (string.Equals(ReadString(obj2, "Section"), section, StringComparison.Ordinal) && TryReadOrder(obj2, out order)) { num = order; } } } return num ?? 1000; } internal static int GetEntryOrder(ModConfig mod, ConfigEntryBase entry) { int? num = null; ConfigDescription description = entry.Description; object[] array = ((description != null) ? description.Tags : null) ?? Array.Empty<object>(); object[] array2 = array; foreach (object obj in array2) { int order2; if (obj is ModSettingsEntryTag { Order: var order } modSettingsEntryTag) { if (order.HasValue) { num = modSettingsEntryTag.Order.Value; } } else if (ReadString(obj, "Section") == null && TryReadOrder(obj, out order2)) { num = order2; } } return num ?? 1000; } internal static double? GetSliderStep(ConfigEntryBase entry) { double? result = null; ConfigDescription description = entry.Description; object[] array = ((description != null) ? description.Tags : null) ?? Array.Empty<object>(); object[] array2 = array; foreach (object obj in array2) { double result2; if (obj is ModSettingsEntryTag { SliderStep: var sliderStep } modSettingsEntryTag) { if (sliderStep.HasValue) { result = modSettingsEntryTag.SliderStep.Value; } } else if (TryReadDouble(obj, "SliderStep", out result2)) { result = result2; } } return result; } private static bool TryReadOrder(object value, out int order) { order = 0; object obj = ReadProperty(value, "Order"); if (obj == null) { return false; } try { order = Convert.ToInt32(obj, CultureInfo.InvariantCulture); return true; } catch { return false; } } private static bool TryReadDouble(object value, string propertyName, out double result) { result = 0.0; object obj = ReadProperty(value, propertyName); if (obj == null) { return false; } try { result = Convert.ToDouble(obj, CultureInfo.InvariantCulture); return true; } catch { return false; } } private static string ReadString(object value, string propertyName) { return ReadProperty(value, propertyName) as string; } private static object ReadProperty(object value, string propertyName) { return value?.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public)?.GetValue(value, null); } } } namespace cfgMenu.Localization { public static class I18n { private static readonly Dictionary<string, string> English = new Dictionary<string, string> { ["plugin.initializing"] = "is initializing...", ["plugin.author_prefix"] = "Author: ", ["plugin.initialized"] = "initialized.", ["value.on"] = "On", ["value.off"] = "Off", ["menu.press_key"] = "Press a key...", ["menu.mod_settings_main"] = "Go Go Gadget Config Menu", ["menu.mod_settings_pause"] = "Go Go Gadget Config Menu", ["menu.back"] = "Back", ["menu.previous"] = "Previous", ["menu.next"] = "Next", ["menu.no_configurable_mods"] = "No configurable mods found", ["menu.version"] = "Version {0}", ["menu.author"] = "by {0}", ["menu.open_nexus_page"] = "Nexus Mods page", ["menu.open_thunderstore_page"] = "Thunderstore page" }; public static string Text(string key, params object[] args) { if (!English.TryGetValue(key, out var value)) { return key; } if (args == null || args.Length == 0) { return value; } try { return string.Format(value, args); } catch (FormatException) { return value; } } } } namespace cfgMenu.Patches { [HarmonyPatch(typeof(SettingsMenu), "SettingBackEvent")] public static class SettingsMenuPatch { [HarmonyPrefix] public static bool Prefix(SettingsMenu __instance) { return !cfgMenuController.HandleSettingsBack(__instance); } } [HarmonyPatch(typeof(TitleMenu))] public static class TitleMenuPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPostfix(TitleMenu __instance) { cfgMenuController.TryCreate(__instance); } [HarmonyPatch("OnEnable")] [HarmonyPostfix] public static void OnEnablePostfix(TitleMenu __instance) { cfgMenuController.TryCreate(__instance); } } [HarmonyPatch(typeof(WorldMenuManager))] public static class WorldMenuManagerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void AwakePostfix(WorldMenuManager __instance) { cfgMenuController.TryCreate(__instance); } [HarmonyPatch("CloseMenu")] [HarmonyPrefix] public static bool CloseMenuPrefix() { return !cfgMenuController.HandleWorldMenuClose(); } } } namespace cfgMenu.Runtime { internal sealed class ConfigRows { private readonly Transform _content; private readonly GameObject _heading; private readonly GameObject _binary; private readonly GameObject _array; private readonly GameObject _slider; private readonly GameObject _button; private readonly GameObject _keybind; private readonly KeybindCapture _capture; private readonly ConfigTextEditor _textEditor = new ConfigTextEditor(); private readonly List<GameObject> _rows = new List<GameObject>(); private readonly List<List<Selectable>> _rowSelectables = new List<List<Selectable>>(); private string _pluginGuid; private Selectable _category; private Selectable _back; private GameObject _lastSelected; public bool IsEditingText => _textEditor.IsEditing; private Selectable FirstSelectable { get { if (_rowSelectables.Count <= 0) { return null; } return _rowSelectables[0][0]; } } private Selectable LastSelectable { get { if (_rowSelectables.Count <= 0) { return null; } return _rowSelectables[_rowSelectables.Count - 1][0]; } } public ConfigRows(Transform content, GameObject heading, GameObject binary, GameObject array, GameObject slider, GameObject button, GameObject keybind, KeybindCapture capture) { _content = content; _heading = heading; _binary = binary; _array = array; _slider = slider; _button = button; _keybind = keybind; _capture = capture; } public void Build(ModConfig mod) { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown Clear(); _lastSelected = null; if (mod == null) { _pluginGuid = null; return; } string gUID = mod.Info.Metadata.GUID; if (!string.Equals(gUID, _pluginGuid, StringComparison.OrdinalIgnoreCase)) { _pluginGuid = gUID; } ConfigEntryBase[] array = mod.ConfigFile.Values.OrderBy((ConfigEntryBase entry) => ModSettingsOrder.GetSectionOrder(mod, entry.Definition.Section)).ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Section, StringComparer.OrdinalIgnoreCase).ThenBy((ConfigEntryBase entry) => ModSettingsOrder.GetEntryOrder(mod, entry)) .ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Key, StringComparer.OrdinalIgnoreCase) .ToArray(); string text = null; int contentSize = 0; ConfigEntryBase[] array2 = array; foreach (ConfigEntryBase val in array2) { if (!string.Equals(text, val.Definition.Section, StringComparison.OrdinalIgnoreCase)) { text = val.Definition.Section; CreateHeading(text, contentSize++); } Create(val, contentSize++); } CreateReset(mod, contentSize++); WireRows(); SetContentSize(contentSize); if ((Object)_category != (Object)null || (Object)_back != (Object)null) { ConnectNavigation(_category, _back); } } public void Refresh(ModConfig mod) { Build(mod); } public void EnsureSelectionVisible() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0029: 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_003e: Expected O, but got Unknown //IL_003e: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_009f: Expected O, but got Unknown EventSystem current = EventSystem.current; GameObject val = (((Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null); if ((Object)val == (Object)null || (Object)val == (Object)_lastSelected) { return; } _lastSelected = val; for (int i = 0; i < _rowSelectables.Count; i++) { List<Selectable> list = _rowSelectables[i]; for (int j = 0; j < list.Count; j++) { if ((Object)list[j] != (Object)null && (Object)((Component)list[j]).gameObject == (Object)val) { ScrollToRow(i); return; } } } } public bool Update() { return _textEditor.Update(); } public void CommitText() { _textEditor.Commit(); } public bool CancelText() { return _textEditor.Cancel(); } public void Scroll(float delta) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Approximately(delta, 0f)) { return; } ScrollRect componentInParent = ((Component)_content).GetComponentInParent<ScrollRect>(); RectTransform component = ((Component)_content).GetComponent<RectTransform>(); RectTransform val = (((Object)(object)componentInParent != (Object)null) ? componentInParent.viewport : null); if (!((Object)componentInParent == (Object)null) && !((Object)component == (Object)null) && !((Object)val == (Object)null) && RectTransformUtility.RectangleContainsScreenPoint(val, new Vector2(Input.mousePosition.x, Input.mousePosition.y), (Camera)null)) { Rect rect = component.rect; float height = ((Rect)(ref rect)).height; rect = val.rect; float num = Mathf.Max(0f, height - ((Rect)(ref rect)).height); if (!(num <= 0f)) { Vector2 anchoredPosition = component.anchoredPosition; anchoredPosition.y = Mathf.Clamp(anchoredPosition.y - delta * 80f, 0f, num); component.anchoredPosition = anchoredPosition; } } } private void Clear() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown _textEditor.Commit(); for (int i = 0; i < _rows.Count; i++) { if ((Object)_rows[i] != (Object)null) { _rows[i].SetActive(false); Object.Destroy((Object)_rows[i]); } } _rows.Clear(); _rowSelectables.Clear(); } private void Create(ConfigEntryBase entry, int index) { Type settingType = entry.SettingType; ConfigDescription description = entry.Description; AcceptableValueBase acceptable = ((description != null) ? description.AcceptableValues : null); IReadOnlyList<object> values; double min; double max; if (settingType == typeof(bool)) { CreateBool(entry, index); } else if (settingType == typeof(KeyCode)) { CreateKeybind(entry, index); } else if (settingType.IsEnum || ConfigValues.TryGetAcceptableValues(acceptable, out values)) { CreateArray(entry, index); } else if (ConfigValues.TryGetNumericRange(acceptable, out min, out max) && ConfigValues.IsSliderType(settingType)) { CreateSlider(entry, index, min, max); } else { CreateInput(entry, index); } } private void CreateBool(ConfigEntryBase entry, int index) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown GameObject val = New(_binary, index); Button left = ((Component)NativeUi.Require(val.transform, "GameObject/LeftOption")).GetComponent<Button>(); Button right = ((Component)NativeUi.Require(val.transform, "GameObject/RightOption")).GetComponent<Button>(); if ((Object)left == (Object)null || (Object)right == (Object)null) { Object.Destroy((Object)val); return; } Action refresh = delegate { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown bool flag = (bool)entry.BoxedValue; TMP_Text componentInChildren = ((Component)left).GetComponentInChildren<TMP_Text>(true); TMP_Text componentInChildren2 = ((Component)right).GetComponentInChildren<TMP_Text>(true); if ((Object)componentInChildren != (Object)null) { componentInChildren.fontStyle = (FontStyles)((!flag) ? 4 : 0); } if ((Object)componentInChildren2 != (Object)null) { componentInChildren2.fontStyle = (FontStyles)(flag ? 4 : 0); } }; Bind(left, delegate { Set(entry, false); refresh(); }); Bind(right, delegate { Set(entry, true); refresh(); }); SetTitle(val, entry); SetButtonText(left, I18n("value.off")); SetButtonText(right, I18n("value.on")); refresh(); AddSelectables((Selectable)left, (Selectable)right); } private void CreateArray(ConfigEntryBase entry, int index) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown GameObject val = New(_array, index); Button component = ((Component)NativeUi.Require(val.transform, "LeftButton")).GetComponent<Button>(); Button component2 = ((Component)NativeUi.Require(val.transform, "RightButton")).GetComponent<Button>(); TMP_Text value = ((Component)NativeUi.Require(val.transform, "Variable")).GetComponentInChildren<TMP_Text>(true); Button component3 = ((Component)NativeUi.Require(val.transform, "Variable")).GetComponent<Button>(); List<object> values = GetValues(entry); if ((Object)component == (Object)null || (Object)component2 == (Object)null || (Object)value == (Object)null || values.Count == 0) { Object.Destroy((Object)val); return; } int selected = FindValue(values, entry.BoxedValue); Action<int> change = delegate(int valueIndex) { selected = (selected + valueIndex + values.Count) % values.Count; if (!ConfigValues.TrySetValue(entry, values[selected])) { selected = FindValue(values, entry.BoxedValue); } NativeUi.SetText(value, GetValueText(entry, values[selected])); }; Bind(component, delegate { change(-1); }); Bind(component2, delegate { change(1); }); if ((Object)component3 != (Object)null) { ((Selectable)component3).interactable = false; } SetTitle(val, entry); NativeUi.SetText(value, GetValueText(entry, values[selected])); AddSelectables((Selectable)component, (Selectable)component2); } private void CreateSlider(ConfigEntryBase entry, int index, double min, double max) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown GameObject val = New(_slider, index); Slider component = ((Component)NativeUi.Require(val.transform, "Slider")).GetComponent<Slider>(); Transform val2 = val.transform.Find("VariableDisplay"); TMP_Text val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<TMP_Text>() : null); if ((Object)component == (Object)null) { Object.Destroy((Object)val); return; } component.onValueChanged = new SliderEvent(); double sliderStep = ConfigValues.GetSliderStep(entry.SettingType, min, max, ModSettingsOrder.GetSliderStep(entry)); float sliderStepCount = ConfigValues.GetSliderStepCount(min, max, sliderStep); component.minValue = 0f; component.maxValue = sliderStepCount; component.wholeNumbers = true; component.SetValueWithoutNotify(ConfigValues.GetSliderStepIndex(entry.BoxedValue, min, max, sliderStep, sliderStepCount)); BindSlider(component, val3, entry, min, max, sliderStep, sliderStepCount); SetTitle(val, entry); NativeUi.SetText(val3, ConfigValues.FormatValue(entry.BoxedValue)); AddSelectables((Selectable)component); } private void CreateKeybind(ConfigEntryBase entry, int index) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown GameObject val = New(_keybind, index); Transform val2 = val.transform.Find("LobbyButton_Underline"); Button button = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Button>() : null); Button val3 = button; TMP_Text val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponentInChildren<TMP_Text>(true) : null); Transform val5 = val.transform.Find("statusLabel"); TMP_Text status = (((Object)(object)val5 != (Object)null) ? ((Component)val5).GetComponent<TMP_Text>() : null); if ((Object)val2 == (Object)null || (Object)button == (Object)null || (Object)val4 == (Object)null || (Object)status == (Object)null) { Object.Destroy((Object)val); return; } string text = SplitName(entry.Definition.Key); Bind(button, delegate { _capture.Begin(entry, button, status); }); NativeUi.SetText(val4, text); NativeUi.SetText(status, KeybindCapture.Format(entry.BoxedValue, status)); AddSelectables((Selectable)button); } private void CreateReset(ModConfig mod, int index) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown GameObject val = New(_button, index); Transform val2 = val.transform.Find("LobbyButton_Underline"); Button val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Button>() : null); if ((Object)val3 == (Object)null) { Object.Destroy((Object)val); return; } Bind(val3, delegate { _capture.Cancel(); _textEditor.Commit(); if (ConfigValues.TryReset(mod.ConfigFile)) { Build(mod); Selectable lastSelectable = LastSelectable; NativeUi.Select(((Object)(object)lastSelectable != (Object)null) ? ((Component)lastSelectable).gameObject : null); } }); AddSelectables((Selectable)val3); } private void CreateInput(ConfigEntryBase entry, int index) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown GameObject val = New(_array, index, active: false); Transform val2 = val.transform.Find("LeftButton"); Transform val3 = val.transform.Find("RightButton"); Transform val4 = val.transform.Find("Variable"); Button val5 = (((Object)(object)val4 != (Object)null) ? ((Component)val4).GetComponent<Button>() : null); TMP_Text val6 = (((Object)(object)val4 != (Object)null) ? ((Component)val4).GetComponentInChildren<TMP_Text>(true) : null); if ((Object)val4 == (Object)null || (Object)val5 == (Object)null || (Object)val6 == (Object)null) { Object.Destroy((Object)val); return; } if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(false); } SetTitle(val, entry); Button val7 = _textEditor.Create(entry, val5, val6); if ((Object)val7 == (Object)null) { Object.Destroy((Object)val); return; } val.SetActive(true); NativeUi.SetText(val6, entry.GetSerializedValue() ?? string.Empty); AddSelectables((Selectable)val7); } private void CreateHeading(string text, int index) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown GameObject val = New(_heading, index); Transform val2 = val.transform.Find("LeftButton"); Transform val3 = val.transform.Find("RightButton"); Transform val4 = val.transform.Find("Variable"); if ((Object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } if ((Object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(false); } if ((Object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(false); } TMP_Text val5 = NativeUi.SetRowTitle(val, SplitName(text)); if ((Object)val5 != (Object)null) { val5.fontStyle = (FontStyles)1; val5.enableAutoSizing = false; val5.fontSize = Mathf.Max(32f, val5.fontSize * 1.5f); } } private GameObject New(GameObject source, int index, bool active = true) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00b6: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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) GameObject val = Object.Instantiate<GameObject>(source, _content); ((Object)val).name = "go go gadget cfg menu" + index.ToString(CultureInfo.InvariantCulture); NativeUi.DisableNativeScripts(val); if (active) { val.SetActive(true); } RectTransform component = val.GetComponent<RectTransform>(); if ((Object)component != (Object)null) { RectTransform component2 = _button.GetComponent<RectTransform>(); Rect rect; float width; if ((Object)(object)component2 == (Object)null) { rect = component.rect; width = ((Rect)(ref rect)).width; } else { rect = component2.rect; width = ((Rect)(ref rect)).width; } if ((Object)source == (Object)_keybind) { component.sizeDelta = new Vector2(component.sizeDelta.x, 130f); } float num = width * 0.5f; float num2 = component.pivot.x - 0.5f; rect = component.rect; float num3 = num + num2 * ((Rect)(ref rect)).width; float num4 = -65f - (float)index * 130f; float num5 = component.pivot.y - 0.5f; rect = component.rect; float num6 = num4 + num5 * ((Rect)(ref rect)).height; component.anchoredPosition = new Vector2(num3, num6); } _rows.Add(val); return val; } private void SetContentSize(int rowCount) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown RectTransform component = ((Component)_content).GetComponent<RectTransform>(); if (!((Object)component == (Object)null)) { component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(0f, (float)rowCount * 130f); ScrollRect componentInParent = ((Component)_content).GetComponentInParent<ScrollRect>(); if ((Object)componentInParent != (Object)null) { componentInParent.verticalNormalizedPosition = 1f; } } } private void ScrollToRow(int selectableRow) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00c2: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_0102: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) ScrollRect componentInParent = ((Component)_content).GetComponentInParent<ScrollRect>(); RectTransform component = ((Component)_content).GetComponent<RectTransform>(); RectTransform val = (((Object)(object)componentInParent != (Object)null) ? componentInParent.viewport : null); if ((Object)componentInParent == (Object)null || (Object)component == (Object)null || (Object)val == (Object)null) { return; } Selectable val2 = _rowSelectables[selectableRow][0]; Transform val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).transform : null); while ((Object)val3 != (Object)null && (Object)val3.parent != (Object)_content) { val3 = val3.parent; } RectTransform val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<RectTransform>() : null); if (!((Object)val4 == (Object)null)) { float num = 0f - val4.anchoredPosition.y; Rect rect = val4.rect; float num2 = num - ((Rect)(ref rect)).height * 0.5f; rect = val4.rect; float num3 = num2 + ((Rect)(ref rect)).height; float num4 = component.anchoredPosition.y; rect = val.rect; float height = ((Rect)(ref rect)).height; if (num2 < num4) { num4 = num2; } else if (num3 > num4 + height) { num4 = num3 - height; } rect = component.rect; float num5 = Mathf.Max(0f, ((Rect)(ref rect)).height - height); component.anchoredPosition = new Vector2(component.anchoredPosition.x, Mathf.Clamp(num4, 0f, num5)); } } private static List<object> GetValues(ConfigEntryBase entry) { if (entry.SettingType.IsEnum) { return Enum.GetValues(entry.SettingType).Cast<object>().ToList(); } ConfigDescription description = entry.Description; if (!ConfigValues.TryGetAcceptableValues((description != null) ? description.AcceptableValues : null, out var values)) { return new List<object>(); } return values.ToList(); } private static int FindValue(IReadOnlyList<object> values, object current) { for (int i = 0; i < values.Count; i++) { if (object.Equals(values[i], current)) { return i; } } return 0; } private void Set(ConfigEntryBase entry, object value) { ConfigValues.TrySetValue(entry, value); } public void ConnectNavigation(Selectable category, Selectable back) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown _category = category; _back = back; Selectable firstSelectable = FirstSelectable; Selectable lastSelectable = LastSelectable; if ((Object)category != (Object)null) { Navigation navigation = category.navigation; NativeUi.SetNavigation(category, navigation.selectOnUp, navigation.selectOnDown, navigation.selectOnLeft, firstSelectable); } for (int i = 0; i < _rowSelectables.Count; i++) { List<Selectable> list = _rowSelectables[i]; Selectable up = ((i > 0) ? _rowSelectables[i - 1][0] : category); Selectable down = ((i + 1 < _rowSelectables.Count) ? _rowSelectables[i + 1][0] : back); for (int j = 0; j < list.Count; j++) { NativeUi.SetNavigation(list[j], up, down, (j > 0) ? list[j - 1] : category, (j + 1 < list.Count) ? list[j + 1] : null); } } if ((Object)back != (Object)null) { Navigation navigation2 = back.navigation; NativeUi.SetNavigation(back, lastSelectable, navigation2.selectOnDown, lastSelectable, navigation2.selectOnRight); } } private void AddSelectables(params Selectable[] selectables) { _rowSelectables.Add(selectables.Where((Selectable selectable) => (Object)selectable != (Object)null).ToList()); } private void WireRows() { for (int num = _rowSelectables.Count - 1; num >= 0; num--) { if (_rowSelectables[num].Count == 0) { _rowSelectables.RemoveAt(num); } } } private void Bind(Button button, Action action) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action)); } private void BindSlider(Slider slider, TMP_Text value, ConfigEntryBase entry, double min, double max, double step, float stepCount) { ((UnityEvent<float>)(object)slider.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<float>>((Delegate)(Action<float>)delegate(float raw) { object value2 = ConfigValues.ConvertSliderValue(raw, min, max, step, stepCount, entry.SettingType); ConfigValues.TrySetValue(entry, value2); slider.SetValueWithoutNotify(ConfigValues.GetSliderStepIndex(entry.BoxedValue, min, max, step, stepCount)); NativeUi.SetText(value, ConfigValues.FormatValue(entry.BoxedValue)); })); } private static void SetButtonText(Button button, string text) { NativeUi.SetText(((Object)(object)button != (Object)null) ? ((Component)button).gameObject : null, text); } private static void SetTitle(GameObject row, ConfigEntryBase entry) { NativeUi.SetRowTitle(row, SplitName(entry.Definition.Key)); } private static string GetValueText(ConfigEntryBase entry, object value) { return ConfigValues.FormatValue(value); } private static string SplitName(string text) { if (string.IsNullOrWhiteSpace(text)) { return text; } return Regex.Replace(text.Replace('_', ' ').Replace('-', ' '), "(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])", " "); } private static string I18n(string key, params object[] args) { return global::cfgMenu.Localization.I18n.Text(key, args); } } internal sealed class ConfigTextEditor { private sealed class Binding { public ConfigEntryBase Entry; public Button Button; public TMP_Text Display; public GameObject InputObject; public TMP_InputField Field; } private Binding _active; private string _original; private bool _restoring; private bool _dragStartedInside; private bool _dragMovedOutside; private int _dragGraceFrames; public bool IsEditing => _active != null; public Button Create(ConfigEntryBase entry, Button button, TMP_Text text) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown if (entry == null || (Object)button == (Object)null || (Object)text == (Object)null) { return null; } CanvasGroup component = ((Component)button).GetComponent<CanvasGroup>(); if ((Object)component != (Object)null) { component.interactable = true; component.blocksRaycasts = true; } ((Selectable)button).interactable = true; ((Graphic)text).raycastTarget = true; if ((Object)((Selectable)button).targetGraphic != (Object)null) { ((Selectable)button).targetGraphic.raycastTarget = true; } RectTransform component2 = ((Component)button).GetComponent<RectTransform>(); if ((Object)component2 != (Object)null) { component2.sizeDelta = new Vector2(760f, component2.sizeDelta.y); } TMP_InputField field; GameObject val = CreateInputObject(((Component)button).gameObject, text, out field); if ((Object)val == (Object)null || (Object)field == (Object)null) { return null; } field.SetTextWithoutNotify(entry.GetSerializedValue() ?? string.Empty); ((Selectable)field).interactable = false; val.SetActive(false); Binding binding = new Binding { Entry = entry, Button = button, Display = text, InputObject = val, Field = field }; button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate { Begin(binding); })); field.onValueChanged = new OnChangeEvent(); ((UnityEvent<string>)(object)field.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)(Action<string>)delegate(string value) { Change(binding, value); })); field.onEndEdit = new SubmitEvent(); ((UnityEvent<string>)(object)field.onEndEdit).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)(Action<string>)delegate(string value) { End(binding, value); })); return button; } private static GameObject CreateInputObject(GameObject parent, TMP_Text display, out TMP_InputField field) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown field = null; if ((Object)parent == (Object)null || (Object)display == (Object)null) { return null; } GameObject val = new GameObject("Text Input", new Il2CppReferenceArray<Type>((Type[])(object)new Type[3] { Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<RectTransform>.NativeClassPtr)), Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<Image>.NativeClassPtr)), Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<TMP_InputField>.NativeClassPtr)) })); val.transform.SetParent(parent.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; ((Transform)component).localScale = Vector3.one; Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = new Color(1f, 1f, 1f, 0f); ((Graphic)component2).raycastTarget = true; RectTransform val2 = CreateViewport(val.transform); if ((Object)val2 == (Object)null) { Object.Destroy((Object)val); return null; } GameObject val3 = Object.Instantiate<GameObject>(((Component)display).gameObject, (Transform)val2); if ((Object)val3 == (Object)null) { Object.Destroy((Object)val); return null; } LocalizedText component3 = val3.GetComponent<LocalizedText>(); if ((Object)component3 != (Object)null) { Object.DestroyImmediate((Object)component3); } TMP_Text val4 = val3.GetComponent<TMP_Text>(); if ((Object)val4 == (Object)null) { val4 = val3.GetComponentInChildren<TMP_Text>(true); } RectTransform val5 = (((Object)(object)val4 != (Object)null) ? ((Component)val4).GetComponent<RectTransform>() : null); if ((Object)val4 == (Object)null || (Object)val5 == (Object)null) { Object.Destroy((Object)val); return null; } ((Object)val3).name = "Text Input Value"; val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = Vector2.zero; val5.offsetMax = Vector2.zero; val4.enableWordWrapping = false; val4.overflowMode = (TextOverflowModes)0; ((Graphic)val4).raycastTarget = false; field = val.GetComponent<TMP_InputField>(); ((Selectable)field).targetGraphic = (Graphic)component2; field.textViewport = val2; field.textComponent = val4; field.contentType = (ContentType)0; field.lineType = (LineType)0; field.characterLimit = 0; field.readOnly = false; field.richText = false; field.shouldActivateOnSelect = false; field.shouldHideMobileInput = true; field.shouldHideSoftKeyboard = true; field.onFocusSelectAll = false; field.restoreOriginalTextOnEscape = true; return val; } private static RectTransform CreateViewport(Transform root) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if ((Object)root == (Object)null) { return null; } GameObject val = new GameObject("Text Viewport", new Il2CppReferenceArray<Type>((Type[])(object)new Type[2] { Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<RectTransform>.NativeClassPtr)), Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<RectMask2D>.NativeClassPtr)) })); val.transform.SetParent(root, false); RectTransform component = val.GetComponent<RectTransform>(); if ((Object)component == (Object)null) { Object.Destroy((Object)val); return null; } component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = new Vector2(10f, 0f); component.offsetMax = new Vector2(-10f, 0f); ((Transform)component).localScale = Vector3.one; return component; } public bool Update() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (_active == null) { return false; } if (Input.GetKeyDown((KeyCode)27)) { Cancel(); return true; } if (Input.GetMouseButtonDown(0)) { GameObject inputObject = _active.InputObject; RectTransform val = (((Object)(object)inputObject != (Object)null) ? inputObject.GetComponent<RectTransform>() : null); _dragStartedInside = (Object)val != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(val, new Vector2(Input.mousePosition.x, Input.mousePosition.y), (Camera)null); _dragMovedOutside = false; _dragGraceFrames = 0; } else if (_dragStartedInside && Input.GetMouseButton(0)) { GameObject inputObject2 = _active.InputObject; RectTransform val2 = (((Object)(object)inputObject2 != (Object)null) ? inputObject2.GetComponent<RectTransform>() : null); if ((Object)val2 != (Object)null && !RectTransformUtility.RectangleContainsScreenPoint(val2, new Vector2(Input.mousePosition.x, Input.mousePosition.y), (Camera)null)) { _dragMovedOutside = true; } } if (Input.GetMouseButtonUp(0) && _dragStartedInside && _dragMovedOutside) { _dragGraceFrames = 2; } else if (!Input.GetMouseButton(0) && _dragGraceFrames > 0) { _dragGraceFrames--; } return false; } public void Commit() { if (_active != null) { Binding active = _active; _active = null; _original = null; _dragStartedInside = false; _dragMovedOutside = false; _dragGraceFrames = 0; TMP_InputField field = active.Field; Save(active, ((Object)(object)field != (Object)null) ? field.text : null); TMP_InputField field2 = active.Field; if ((Object)(object)field2 != (Object)null) { field2.DeactivateInputField(false); } SetEditing(active, editing: false); } } public bool Cancel() { if (_active == null) { return false; } Binding active = _active; string text = _original ?? string.Empty; _active = null; _original = null; _dragStartedInside = false; _dragMovedOutside = false; _dragGraceFrames = 0; _restoring = true; TMP_InputField field = active.Field; if ((Object)(object)field != (Object)null) { field.SetTextWithoutNotify(text); } Save(active, text); TMP_InputField field2 = active.Field; if ((Object)(object)field2 != (Object)null) { field2.DeactivateInputField(false); } SetEditing(active, editing: false); _restoring = false; return true; } private void Begin(Binding binding) { if (binding != null && _active != binding) { Commit(); _active = binding; _original = binding.Entry.GetSerializedValue() ?? string.Empty; _dragStartedInside = false; _dragMovedOutside = false; _dragGraceFrames = 0; binding.Field.SetTextWithoutNotify(_original); SetEditing(binding, editing: true); NativeUi.Select(((Component)binding.Field).gameObject); binding.Field.ActivateInputField(); binding.Field.MoveTextEnd(false); } } private void Change(Binding binding, string value) { if (!_restoring) { Save(binding, value); NativeUi.SetText(binding.Display, value); } } private void End(Binding binding, string value) { if (_restoring) { return; } TMP_InputField field = binding.Field; if ((Object)(object)field != (Object)null && field.wasCanceled) { Cancel(); return; } Save(binding, value); NativeUi.SetText(binding.Display, value); bool flag = Input.GetKey((KeyCode)13) || Input.GetKey((KeyCode)271); bool flag2 = Input.GetMouseButtonDown(0) && !IsPointerInside(binding); bool flag3 = _active == binding && _dragStartedInside && (Input.GetMouseButton(0) || Input.GetMouseButtonUp(0)) && !Input.GetMouseButtonDown(0); if (_active == binding && !flag && !flag2 && (flag3 || _dragMovedOutside || _dragGraceFrames > 0)) { _dragMovedOutside = false; _dragGraceFrames = 2; NativeUi.Select(((Component)binding.Field).gameObject); binding.Field.ActivateInputField(); return; } if (_active == binding) { _active = null; _original = null; _dragStartedInside = false; _dragMovedOutside = false; _dragGraceFrames = 0; } SetEditing(binding, editing: false); } private static bool IsPointerInside(Binding binding) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) object obj; if (binding == null) { obj = null; } else { GameObject inputObject = binding.InputObject; obj = (((Object)(object)inputObject != (Object)null) ? inputObject.GetComponent<RectTransform>() : null); } RectTransform val = (RectTransform)obj; if ((Object)val != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(val, new Vector2(Input.mousePosition.x, Input.mousePosition.y), (Camera)null); } return false; } private static void SetEditing(Binding binding, bool editing) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown if ((Object)(binding?.Button) != (Object)null) { ((Selectable)binding.Button).interactable = !editing; } if ((Object)(binding?.Display) != (Object)null) { ((Component)binding.Display).gameObject.SetActive(!editing); } if ((Object)(binding?.InputObject) != (Object)null) { binding.InputObject.SetActive(editing); } if ((Object)(binding?.Field) != (Object)null) { ((Selectable)binding.Field).interactable = editing; } } private static void Save(Binding binding, string value) { if (binding != null && binding.Entry != null) { ConfigValues.TrySetSerializedValue(binding.Entry, value ?? string.Empty); } } } internal sealed class KeybindCapture { private ConfigEntryBase _entry; private TMP_Text _text; public bool IsActive => _entry != null; public void Begin(ConfigEntryBase entry, Button button, TMP_Text text) { _entry = entry; _text = text; NativeUi.SetText(_text, I18nText("menu.press_key")); NativeUi.Select(((Object)(object)button != (Object)null) ? ((Component)button).gameObject : null); } public void Capture() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (_entry == null) { return; } if (Input.GetKeyDown((KeyCode)27)) { Cancel(); return; } Array values = Enum.GetValues(typeof(KeyCode)); for (int i = 0; i < values.Length; i++) { KeyCode val = (KeyCode)values.GetValue(i); if ((int)val != 0 && Input.GetKeyDown(val)) { Finish(val); break; } } } public void Cancel() { if (_entry != null) { NativeUi.SetText(_text, Format(_entry.BoxedValue, _text)); Clear(); } } public void Clear() { _entry = null; _text = null; } public static string Format(object value, TMP_Text text = null) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!(value is KeyCode key) || 1 == 0) { return ConfigValues.FormatValue(value); } return FormatKey(key, text); } private void Finish(KeyCode key) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!ConfigValues.TrySetValue(_entry, key)) { key = (KeyCode)_entry.BoxedValue; } NativeUi.SetText(_text, Format(key, _text)); Clear(); } private static string FormatKey(KeyCode key, TMP_Text text) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) try { DevSettings currentSettings = DevSettings.currentSettings; ControllerGlyphSet val = (((Object)(object)currentSettings != (Object)null) ? currentSettings.controllerGlyphSet : null); if ((Object)val != (Object)null) { GlyphText glyph = GetGlyph(val, key); if (glyph != null && !string.IsNullOrWhiteSpace(glyph.glyphString)) { LocalizedText val2 = (((Object)(object)text != (Object)null) ? ((Component)text).GetComponent<LocalizedText>() : null); MaterialType val3 = EnumHelper.OrValue<MaterialType>((Object)(object)val2 == (Object)null, (MaterialType)(((Object)(object)val2 != (Object)null) ? ((int)val2.materialType) : 0), 1); return val.WrapInTags(glyph, val3); } } } catch { } return GetFallbackText(key); } private static GlyphText GetGlyph(ControllerGlyphSet glyphs, KeyCode key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected I4, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_005b: Unknown result type (might be due to invalid IL or missing references) switch (key - 323) { case 0: return glyphs.GetMouseGlyphForElementName("Button 0"); case 1: return glyphs.GetMouseGlyphForElementName("Button 1"); case 2: return glyphs.GetMouseGlyphForElementName("Button 2"); default: if ((int)key > 319) { return null; } return glyphs.GetKeyboardGlyphForKeyCode((KeyboardKeyCode)key); } } private static string GetFallbackText(KeyCode key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected I4, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected I4, but got Unknown if ((int)key <= 271) { if ((int)key == 13 || (int)key == 271) { return "Enter"; } } else { switch (key - 303) { default: switch (key - 323) { case 0: return "Mouse 1"; case 1: return "Mouse 2"; case 2: return "Mouse 3"; } break; case 2: case 3: return "Ctrl"; case 0: case 1: return "Shift"; case 4: case 5: case 10: return "Alt"; case 6: case 7: case 8: case 9: break; } } string text = ((object)key).ToString(); if (!text.StartsWith("Alpha", StringComparison.Ordinal)) { return text; } return text.Substring("Alpha".Length); } private static string I18nText(string key) { return I18n.Text(key); } } internal sealed class ModSettingsInput : MonoBehaviour { public ModSettingsInput(IntPtr pointer) : base(pointer) { } private void Update() { cfgMenuController.Update(); } } public static class cfgMenuController { private static TitleMenu _titleMenu; private static GameObject _titleButton; private static ModSettingsPanel _mainPanel; private static WorldMenuManager _worldMenu; private static GameObject _hostButton; private static GameObject _clientButton; private static ModSettingsPanel _pausePanel; private static GameObject _pauseRoot; private static int _handledPauseBackFrame = -1; private static int _handledTextBackFrame = -1; private static int _lastUpdateFrame = -1; public static void TryCreate(TitleMenu menu) { //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0037: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown try { if (!((Object)menu == (Object)null) && (!((Object)_titleButton != (Object)null) || !((Object)_titleMenu == (Object)menu))) { ResetMainMenu(); Transform val = ((Component)menu).transform.Find("StartButtons"); if ((Object)val == (Object)null && (Object)((Component)menu).transform.parent != (Object)null) { val = ((Component)menu).transform.parent.Find("TitleMenu/StartButtons"); } if ((Object)val == (Object)null) { throw new InvalidOperationException("Main menu StartButtons was not found."); } Transform val2 = NativeUi.Require(val, "SettingsButton"); MainMenuManager instance = MainMenuManager.instance; SettingsMenu val3 = (((Object)(object)instance != (Object)null) ? instance.settingsMenu : null); if (!((Object)val3 == (Object)null)) { _titleMenu = menu; _mainPanel = ModSettingsPanel.Create(val3, ((Component)val3).transform.parent, CloseMainMenu); AttachInput(((Component)menu).gameObject); AttachInput(((Component)val3).gameObject); _titleButton = CreateEntry(((Component)val2).gameObject, val, OpenMainMenu); ((Object)_titleButton).name = "ModSettingsButton"; LayoutMainButtons(val); RefreshLocalizedText(); } } } catch (Exception ex) { ManualLogSource logger = cfgMenu.Logger; bool flag = false; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(51, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Failed to create the main menu cfg settings entry: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex); } logger.LogError(val4); ResetMainMenu(); } } public static void TryCreate(WorldMenuManager menu) { //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0043: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown try { if ((Object)menu == (Object)null || (_pausePanel != null && (Object)_worldMenu == (Object)menu)) { return; } ResetPauseMenu(); SettingsMenu settingsMenu = menu.settingsMenu; if (!((Object)settingsMenu == (Object)null) && !((Object)menu.pauseMenuHost == (Object)null) && !((Object)menu.pauseMenuClient == (Object)null)) { Transform val = NativeUi.Require(((Component)menu.pauseMenuHost).transform, "LayoutContainer/Settings"); Transform val2 = NativeUi.Require(((Component)menu.pauseMenuClient).transform, "LayoutContainer/Settings"); _worldMenu = menu; _pausePanel = ModSettingsPanel.Create(settingsMenu, ((Component)settingsMenu).transform.parent, ClosePauseMenu, pauseMenu: true); AttachInput(((Component)menu).gameObject); AttachInput(((Component)settingsMenu).gameObject); _hostButton = CreateEntry(((Component)val).gameObject, val.parent, delegate { OpenPauseMenu(menu.pauseMenuHost); }); _clientButton = CreateEntry(((Component)val2).gameObject, val2.parent, delegate { OpenPauseMenu(menu.pauseMenuClient); }); ((Object)_hostButton).name = "ModSettings"; ((Object)_clientButton).name = "ModSettings"; LayoutPauseButtons(val.parent); LayoutPauseButtons(val2.parent); RefreshLocalizedText(); } } catch (Exception ex) { ManualLogSource logger = cfgMenu.Logger; bool flag = false; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(52, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to create the pause menu cfg settings entry: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex); } logger.LogError(val3); ResetPauseMenu(); } } public static void Update() { if (_lastUpdateFrame == Time.frameCount) { return; } _lastUpdateFrame = Time.frameCount; ModSettingsPanel mainPanel = _mainPanel; ModSettingsPanel modSettingsPanel = ((mainPanel != null && mainPanel.IsOpen) ? _mainPanel : _pausePanel); if (modSettingsPanel == null || !modSettingsPanel.IsOpen) { return; } if (modSettingsPanel.Update()) { _handledTextBackFrame = Time.frameCount; if (modSettingsPanel == _pausePanel) { _handledPauseBackFrame = Time.frameCount; } } else { if (_handledTextBackFrame == Time.frameCount) { return; } if (modSettingsPanel.IsCapturingKeybind) { modSettingsPanel.CaptureInput(); if (modSettingsPanel == _pausePanel && Input.GetKeyDown((KeyCode)27)) { _handledPauseBackFrame = Time.frameCount; } } else if (modSettingsPanel == _mainPanel && Input.GetKeyDown((KeyCode)27)) { CloseMainMenu(); } else if (modSettingsPanel == _pausePanel && Input.GetKeyDown((KeyCode)27) && _handledPauseBackFrame != Time.frameCount) { _handledPauseBackFrame = Time.frameCount; ClosePauseMenu(); } } } public static bool HandleSettingsBack(SettingsMenu menu) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown if ((Object)menu == (Object)null) { return false; } if (_handledTextBackFrame == Time.frameCount) { return true; } ModSettingsPanel mainPanel = _mainPanel; if (mainPanel != null && mainPanel.IsOpen) { if (_mainPanel.CancelTextEdit()) { _handledTextBackFrame = Time.frameCount; return true; } CloseMainMenu(); return true; } ModSettingsPanel pausePanel = _pausePanel; if (pausePanel != null && pausePanel.IsOpen) { if (_pausePanel.CancelTextEdit()) { _handledTextBackFrame = Time.frameCount; _handledPauseBackFrame = Time.frameCount; return true; } ClosePauseMenu(); return true; } return false; } public static void RefreshLocalizedText() { if (_mainPanel != null && !_mainPanel.IsAlive) { _mainPanel = null; _titleMenu = null; _titleButton = null; } if (_pausePanel != null && !_pausePanel.IsAlive) { _pausePanel = null; _worldMenu = null; _hostButton = null; _clientButton = null; _pauseRoot = null; } NativeUi.SetText(_titleButton, I18n.Text("menu.mod_settings_main")); NativeUi.SetText(_hostButton, I18n.Text("menu.mod_settings_pause")); NativeUi.SetText(_clientButton, I18n.Text("menu.mod_settings_pause")); _mainPanel?.RefreshLocalizedText(); _pausePanel?.RefreshLocalizedText(); } private static void AttachInput(GameObject root) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if ((Object)root != (Object)null && (Object)root.GetComponent<ModSettingsInput>() == (Object)null) { root.AddComponent<ModSettingsInput>(); } } private static GameObject CreateEntry(GameObject source, Transform parent, Action open) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(source, parent); NativeUi.ResetManagedButtons(val); Button component = val.GetComponent<Button>(); if ((Object)component == (Object)null) { Object.Destroy((Object)val); throw new InvalidOperationException("Native settings entry is missing Button."); } component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)open)); val.transform.SetSiblingIndex(source.transform.GetSiblingIndex() + 1); return val; } private static void OpenMainMenu() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (_mainPanel != null && !((Object)_titleMenu == (Object)null)) { ((Component)_titleMenu).gameObject.SetActive(false); _mainPanel.Show(); } } private static void CloseMainMenu() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (_mainPanel != null && !((Object)_titleMenu == (Object)null)) { _mainPanel.Hide(); ((Component)_titleMenu).gameObject.SetActive(true); NativeUi.Select(_titleButton); } } private static void OpenPauseMenu(PauseMenu menu) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown if (_pausePanel != null && !((Object)menu == (Object)null)) { _pauseRoot = ((Component)menu).gameObject; _pauseRoot.SetActive(false); _pausePanel.Show(); } } private static void ClosePauseMenu() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_0091: Expected O, but got Unknown if (_pausePanel == null) { return; } _pausePanel.Hide(); if ((Object)_pauseRoot != (Object)null) { _pauseRoot.SetActive(true); GameObject pauseRoot = _pauseRoot; WorldMenuManager worldMenu = _worldMenu; object obj; if ((Object)(object)worldMenu == (Object)null) { obj = null; } else { PauseMenu pauseMenuHost = worldMenu.pauseMenuHost; obj = (((Object)(object)pauseMenuHost != (Object)null) ? ((Component)pauseMenuHost).gameObject : null); } NativeUi.Select(((Object)pauseRoot == (Object)obj) ? _hostButton : _clientButton); } } private static void LayoutMainButtons(Transform parent) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_0246: Expected O, but got Unknown //IL_0246: Expected O, but got Unknown List<RectTransform> list = new List<RectTransform>(); for (int i = 0; i < parent.childCount; i++) { RectTransform component = ((Component)parent.GetChild(i)).GetComponent<RectTransform>(); Button component2 = ((Component)parent.GetChild(i)).GetComponent<Button>(); if ((Object)component != (Object)null && (Object)component2 != (Object)null && ((Component)parent.GetChild(i)).gameObject.activeSelf) { list.Add(component); } } list.Sort((RectTransform left, RectTransform right) => right.anchoredPosition.y.CompareTo(left.anchoredPosition.y)); if (list.Count >= 2) { VerticalLayoutGroup component3 = ((Component)parent).GetComponent<VerticalLayoutGroup>(); if ((Object)component3 != (Object)null) { ((Behaviour)component3).enabled = false; } float num = 352f / (float)(list.Count - 1); float num2 = Mathf.Abs(list[0].anchoredPosition.y - list[1].anchoredPosition.y); float num3 = ((num2 > 0f) ? Mathf.Min(1f, num / num2) : 1f); RectTransform component4 = ((Component)parent).GetComponent<RectTransform>(); if ((Object)component4 != (Object)null) { component4.sizeDelta = new Vector2(component4.sizeDelta.x, Mathf.Max(component4.sizeDelta.y, Mathf.Abs(-352f) + 80f)); } for (int num4 = 0; num4 < list.Count; num4++) { list[num4].anchoredPosition = new Vector2(list[num4].anchoredPosition.x, -55.15f - num * (float)num4); ((Transform)list[num4]).localScale = new Vector3(num3, num3, num3); Button component5 = ((Component)list[num4]).GetComponent<Button>(); Button val = ((num4 > 0) ? ((Component)list[num4 - 1]).GetComponent<Button>() : null); Button val2 = ((num4 + 1 < list.Count) ? ((Component)list[num4 + 1]).GetComponent<Button>() : null); NativeUi.SetNavigation((Selectable)component5, (Selectable)val, (Selectable)val2, null, null); } } } private static void LayoutPauseButtons(Transform parent) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might b