Decompiled source of ModSettingsMenu v1.1.0
BepInEx/plugins/ModSettingsMenu/ModSettingsMenu.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; 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; using Il2CppInterop.Runtime.InteropTypes.Arrays; using ModSettingsMenu.Api; using ModSettingsMenu.Configuration; using ModSettingsMenu.Localization; using ModSettingsMenu.Runtime; using ShiftAtMidnightLocalizationAPI.Api; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ModSettingsMenu")] [assembly: AssemblyDescription("Mod Settings Menu mod for Shift At Midnight by Ice Box Studio")] [assembly: AssemblyCompany("Ice Box Studio")] [assembly: AssemblyProduct("ModSettingsMenu")] [assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")] [assembly: ComVisible(false)] [assembly: Guid("6d512f55-e9ee-445c-9fb4-93ed6c1ef50a")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("1.1.0.0")] namespace ModSettingsMenu { [BepInPlugin("IceBoxStudio.ShiftAtMidnight.ModSettingsMenu", "ModSettingsMenu", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ModSettingsMenu : BasePlugin { private Harmony _harmony; internal static ManualLogSource Logger { get; private set; } public override void Load() { //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown Logger = ((BasePlugin)this).Log; LocalizationApi.LanguageChanged += OnLanguageChanged; ModSettingsRegistry.RefreshRequested += RefreshMenus; bool flag = default(bool); try { Logger.LogInfo((object)"============================================="); ManualLogSource logger = Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ModSettingsMenu"); ((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("Ice Box Studio(https://steamcommunity.com/id/ibox666/)"); } logger2.LogInfo(val); ClassInjector.RegisterTypeInIl2Cpp<PauseMenuInput>(); _harmony = new Harmony("IceBoxStudio.ShiftAtMidnight.ModSettingsMenu"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ManualLogSource logger3 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ModSettingsMenu"); ((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 Mod Settings Menu: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } logger4.LogError(val2); } } private static void OnLanguageChanged(string _) { RefreshMenus(); } private static void RefreshMenus() { ModSettingsMenuController.RefreshLocalizedText(); PauseModSettingsController.RefreshLocalizedText(); } } public static class PluginInfo { public const string PLUGIN_GUID = "IceBoxStudio.ShiftAtMidnight.ModSettingsMenu"; public const string PLUGIN_NAME = "ModSettingsMenu"; public const string PLUGIN_VERSION = "1.1.0"; } } namespace ModSettingsMenu.Runtime { internal sealed class ConfigRows { private readonly Transform _content; private readonly GameObject _slider; private readonly GameObject _toggle; private readonly GameObject _dropdown; private readonly GameObject _input; private readonly GameObject _keybind; private readonly KeybindCapture _keybindCapture; private readonly DescriptionLayout _description; private readonly ModInfoRow _modInfo; private readonly List<GameObject> _createdRows = new List<GameObject>(); public ConfigRows(Transform content, GameObject slider, GameObject toggle, GameObject dropdown, GameObject input, GameObject keybind, KeybindCapture keybindCapture, DescriptionLayout description, ModInfoRow modInfo) { _content = content; _slider = slider; _toggle = toggle; _dropdown = dropdown; _input = input; _keybind = keybind; _keybindCapture = keybindCapture; _description = description; _modInfo = modInfo; } public void Build(ModConfig mod) { ClearRows(); if (mod == null) { CreateHeading(I18n.Text("menu.no_configurable_mods")); } else { AddModInfo(mod); foreach (ConfigEntryBase item in mod.ConfigFile.Values.OrderBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Section, StringComparer.OrdinalIgnoreCase).ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Key, StringComparer.OrdinalIgnoreCase).ToList()) { CreateEntryRow(item); } } LayoutRebuild(); } private void ClearRows() { foreach (GameObject createdRow in _createdRows) { if ((Object)(object)createdRow != (Object)null) { createdRow.SetActive(false); Object.Destroy((Object)(object)createdRow); } } _createdRows.Clear(); } private void CreateHeading(string text) { GameObject val = NewRow(_slider, "Mod Settings Heading"); string[] array = new string[2] { "Slider", "Value" }; foreach (string text2 in array) { Transform val2 = val.transform.Find(text2); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } } NativeUi.SetRowTitle(val, text); CompleteRow(val); } private void CreateEntryRow(ConfigEntryBase entry) { Type settingType = entry.SettingType; ConfigDescription description = entry.Description; AcceptableValueBase acceptable = ((description != null) ? description.AcceptableValues : null); IReadOnlyList<object> values; float min; float max; if (settingType == typeof(bool)) { CreateBoolRow(entry); } else if (settingType == typeof(KeyCode)) { CreateKeybindRow(entry); } else if (settingType.IsEnum) { CreateDropdownRow(entry, Enum.GetValues(settingType).Cast<object>().ToList()); } else if (ConfigValues.TryGetAcceptableValues(acceptable, out values)) { CreateDropdownRow(entry, values); } else if (ConfigValues.TryGetNumericRange(acceptable, out min, out max) && ConfigValues.IsSliderType(settingType)) { CreateSliderRow(entry, min, max); } else { CreateInputRow(entry); } } private void CreateBoolRow(ConfigEntryBase entry) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown GameObject val = NewRow(_toggle, GetRowName(entry)); Toggle toggle = val.GetComponentInChildren<Toggle>(true); if ((Object)(object)toggle == (Object)null) { Object.Destroy((Object)(object)val); CreateInputRow(entry); return; } toggle.onValueChanged = new ToggleEvent(); toggle.SetIsOnWithoutNotify((bool)entry.BoxedValue); ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<bool>>((Delegate)(Action<bool>)delegate(bool value) { if (!ConfigValues.TrySetValue(entry, value)) { toggle.SetIsOnWithoutNotify((bool)entry.BoxedValue); } })); NativeUi.SetRowTitle(val, entry.Definition.Key); _description.Apply(val, entry, 6f); NativeUi.CenterControl(((Component)toggle).GetComponent<RectTransform>()); CompleteRow(val); } private void CreateKeybindRow(ConfigEntryBase entry) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown GameObject val = NewRow(_keybind, GetRowName(entry)); Button button = val.GetComponentInChildren<Button>(true); Button obj = button; TMP_Text buttonText = ((obj != null) ? ((Component)obj).GetComponentInChildren<TMP_Text>(true) : null); if ((Object)(object)button == (Object)null || (Object)(object)buttonText == (Object)null) { Object.Destroy((Object)(object)val); CreateInputRow(entry); return; } button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate { _keybindCapture.Begin(entry, button, buttonText); })); NativeUi.CopyFont(NativeUi.SetRowTitle(val, entry.Definition.Key), buttonText); NativeUi.SetLocalizedText(buttonText, KeybindCapture.FormatKeyCode(entry.BoxedValue)); _description.Apply(val, entry, 6f); NativeUi.CenterControl(((Component)button).GetComponent<RectTransform>()); CompleteRow(val); } private void CreateSliderRow(ConfigEntryBase entry, float min, float max) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown GameObject val = NewRow(_slider, GetRowName(entry)); Slider slider = val.GetComponentInChildren<Slider>(true); if ((Object)(object)slider == (Object)null) { Object.Destroy((Object)(object)val); CreateInputRow(entry); return; } slider.onValueChanged = new SliderEvent(); slider.minValue = min; slider.maxValue = max; slider.wholeNumbers = ConfigValues.IsIntegralType(entry.SettingType); slider.SetValueWithoutNotify(Convert.ToSingle(entry.BoxedValue, CultureInfo.InvariantCulture)); Transform obj = val.transform.Find("Value"); TMP_Text valueText = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null); ((UnityEvent<float>)(object)slider.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<float>>((Delegate)(Action<float>)delegate(float value) { object value2 = ConfigValues.ConvertSliderValue(value, entry.SettingType); if (!ConfigValues.TrySetValue(entry, value2)) { slider.SetValueWithoutNotify(Convert.ToSingle(entry.BoxedValue, CultureInfo.InvariantCulture)); } if ((Object)(object)valueText != (Object)null) { valueText.text = ConfigValues.FormatValue(entry.BoxedValue); } })); NativeUi.CopyFont(NativeUi.SetRowTitle(val, entry.Definition.Key), valueText); if ((Object)(object)valueText != (Object)null) { valueText.text = ConfigValues.FormatValue(entry.BoxedValue); } _description.Apply(val, entry); CompleteRow(val); } private void CreateDropdownRow(ConfigEntryBase entry, IReadOnlyList<object> values) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown GameObject val = NewRow(_dropdown, GetRowName(entry)); TMP_Dropdown dropdown = val.GetComponentInChildren<TMP_Dropdown>(true); if ((Object)(object)dropdown == (Object)null || values.Count == 0) { Object.Destroy((Object)(object)val); CreateInputRow(entry); return; } dropdown.ClearOptions(); foreach (object value in values) { dropdown.options.Add(new OptionData(ConfigValues.FormatValue(value))); } var anon = values.Select((object value, int index) => new { value, index }).FirstOrDefault(item => object.Equals(item.value, entry.BoxedValue)); dropdown.onValueChanged = new DropdownEvent(); dropdown.SetValueWithoutNotify(anon?.index ?? 0); dropdown.RefreshShownValue(); ((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<int>>((Delegate)(Action<int>)delegate(int index) { if (index >= 0 && index < values.Count && !ConfigValues.TrySetValue(entry, values[index])) { int valueWithoutNotify = values.Select((object value, int valueIndex) => new { value, valueIndex }).FirstOrDefault(item => object.Equals(item.value, entry.BoxedValue))?.valueIndex ?? 0; dropdown.SetValueWithoutNotify(valueWithoutNotify); dropdown.RefreshShownValue(); } })); TMP_Text source = NativeUi.SetRowTitle(val, entry.Definition.Key); NativeUi.CopyFont(source, dropdown.captionText); NativeUi.CopyFont(source, dropdown.itemText); _description.Apply(val, entry); CompleteRow(val); } private void CreateInputRow(ConfigEntryBase entry) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown GameObject val = NewRow(_input, GetRowName(entry)); TMP_InputField input = val.GetComponentInChildren<TMP_InputField>(true); if ((Object)(object)input == (Object)null) { Object.Destroy((Object)(object)val); return; } input.onEndEdit = new SubmitEvent(); input.SetTextWithoutNotify(entry.GetSerializedValue()); ((UnityEvent<string>)(object)input.onEndEdit).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)(Action<string>)delegate(string value) { if (!ConfigValues.TrySetSerializedValue(entry, value)) { input.SetTextWithoutNotify(entry.GetSerializedValue()); } })); TMP_Text source = NativeUi.SetRowTitle(val, entry.Definition.Key); NativeUi.CopyFont(source, input.textComponent); Graphic placeholder = input.placeholder; NativeUi.CopyFont(source, (placeholder != null) ? ((Il2CppObjectBase)placeholder).TryCast<TMP_Text>() : null); _description.Apply(val, entry); CompleteRow(val); } private void AddModInfo(ModConfig mod) { GameObject val = _modInfo.Create(mod); if ((Object)(object)val != (Object)null) { CompleteRow(val); } } private void CompleteRow(GameObject row) { row.SetActive(true); _createdRows.Add(row); } private GameObject NewRow(GameObject source, string name) { GameObject val = Object.Instantiate<GameObject>(source, _content); ((Object)val).name = name; val.SetActive(false); MatchRow(val); NativeUi.DisableRowComponents(val); return val; } private void MatchRow(GameObject row) { //IL_0028: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) RectTransform component = _slider.GetComponent<RectTransform>(); RectTransform component2 = row.GetComponent<RectTransform>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null)) { component2.anchorMin = component.anchorMin; component2.anchorMax = component.anchorMax; component2.pivot = component.pivot; component2.sizeDelta = component.sizeDelta; component2.anchoredPosition = component.anchoredPosition; ((Transform)component2).localScale = ((Transform)component).localScale; ((Transform)component2).localRotation = ((Transform)component).localRotation; } } private void LayoutRebuild() { LayoutRebuilder.ForceRebuildLayoutImmediate(((Component)_content).GetComponent<RectTransform>()); Transform parent = _content.parent; object obj; if (parent == null) { obj = null; } else { Transform parent2 = parent.parent; obj = ((parent2 != null) ? ((Component)parent2).GetComponent<ScrollRect>() : null); } ScrollRect val = (ScrollRect)obj; if ((Object)(object)val != (Object)null) { val.verticalNormalizedPosition = 1f; } } private static string GetRowName(ConfigEntryBase entry) { return "Mod Setting - " + entry.Definition.Key; } } internal sealed class DescriptionLayout { private readonly GameObject _slider; private readonly GameObject _dropdown; private readonly GameObject _description; private readonly TMP_Text _descriptionFont; public DescriptionLayout(GameObject slider, GameObject dropdown, GameObject description, TMP_Text descriptionFont) { _slider = slider; _dropdown = dropdown; _description = description; _descriptionFont = descriptionFont; } public void Apply(GameObject row, ConfigEntryBase entry, float additionalControlGap = 0f) { //IL_00e9: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) string configDescription = LocalizationApi.GetConfigDescription(entry); if (string.IsNullOrWhiteSpace(configDescription)) { return; } RectTransform component = row.GetComponent<RectTransform>(); RectTransform component2 = _slider.GetComponent<RectTransform>(); RectTransform component3 = _description.GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null) { return; } Transform titleTransform; List<RectTransform> activeControls = GetActiveControls(row, out titleTransform); if ((Object)(object)titleTransform != (Object)null) { ((Component)titleTransform).gameObject.SetActive(false); } GameObject val = Object.Instantiate<GameObject>(_description, row.transform); ((Object)val).name = "Description"; val.SetActive(false); RectTransform component4 = val.GetComponent<RectTransform>(); TMP_Text component5 = val.GetComponent<TMP_Text>(); if ((Object)(object)component4 == (Object)null || (Object)(object)component5 == (Object)null) { Object.Destroy((Object)(object)val); return; } component5.enableAutoSizing = false; component5.fontSize = _descriptionFont.fontSize; NativeUi.SetLocalizedText(component5, configDescription.Trim()); float x = component3.sizeDelta.x; float y = component5.GetPreferredValues(component5.text, x, 0f).y; float num = Mathf.Max(_descriptionFont.fontSize, y); Transform obj = _dropdown.transform.Find("Title"); RectTransform val2 = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null); Transform obj2 = _dropdown.transform.Find("Dropdown"); RectTransform val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<RectTransform>() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || activeControls.Count == 0) { Object.Destroy((Object)(object)val); return; } float num2 = Mathf.Abs(GetRectTop(val3) - GetRectBottom(val2)); float num3 = GetRectTop(val2) - GetRectBottom(val3); float num4 = Mathf.Max(0f, component2.sizeDelta.y - num3); float num5 = ((IEnumerable<RectTransform>)activeControls).Max((Func<RectTransform, float>)GetRectTop); float num6 = ((IEnumerable<RectTransform>)activeControls).Min((Func<RectTransform, float>)GetRectBottom); float num7 = num5 + num2 + additionalControlGap; float num8 = num7 + num; float num9 = (num8 + num6) * 0.5f; float num10 = num8 - num6; foreach (RectTransform item in activeControls) { item.anchoredPosition = new Vector2(item.anchoredPosition.x, item.anchoredPosition.y - num9); } component.sizeDelta = new Vector2(component.sizeDelta.x, Mathf.Max(component2.sizeDelta.y, num10 + num4)); component4.anchorMin = component3.anchorMin; component4.anchorMax = component3.anchorMax; component4.pivot = component3.pivot; component4.sizeDelta = new Vector2(x, num); component4.anchoredPosition = new Vector2(0f, num7 + num * 0.5f - num9); ((Transform)component4).localScale = ((Transform)component3).localScale; ((Transform)component4).localRotation = ((Transform)component3).localRotation; val.SetActive(true); } private static List<RectTransform> GetActiveControls(GameObject row, out Transform titleTransform) { List<RectTransform> list = new List<RectTransform>(); titleTransform = row.transform.Find("Title") ?? row.transform.Find("Title (1)"); for (int i = 0; i < row.transform.childCount; i++) { Transform child = row.transform.GetChild(i); if (!((Object)(object)child == (Object)(object)titleTransform) && !string.Equals(((Object)child).name, "EditingBar", StringComparison.Ordinal) && ((Component)child).gameObject.activeSelf) { RectTransform component = ((Component)child).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { list.Add(component); } } } return list; } private static float GetRectTop(RectTransform rectTransform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float y = rectTransform.anchoredPosition.y; Rect rect = rectTransform.rect; return y + ((Rect)(ref rect)).height * Mathf.Abs(((Transform)rectTransform).localScale.y) * 0.5f; } private static float GetRectBottom(RectTransform rectTransform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float y = rectTransform.anchoredPosition.y; Rect rect = rectTransform.rect; return y - ((Rect)(ref rect)).height * Mathf.Abs(((Transform)rectTransform).localScale.y) * 0.5f; } } internal sealed class KeybindCapture { private ConfigEntryBase _entry; private TMP_Text _buttonText; public bool IsActive => _entry != null; public void Begin(ConfigEntryBase entry, Button button, TMP_Text buttonText) { _entry = entry; _buttonText = buttonText; NativeUi.SetLocalizedText(buttonText, string.Empty); NativeUi.SelectObject(((Component)button).gameObject); } public void CaptureInput() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current == null) { return; } if (((ButtonControl)current.escapeKey).wasPressedThisFrame) { Finish(save: false, (KeyCode)0); return; } foreach (Key value in Enum.GetValues(typeof(Key))) { if ((int)value != 0) { KeyControl val2; try { val2 = current[value]; } catch { continue; } if (val2 != null && ((ButtonControl)val2).wasPressedThisFrame && TryConvertKeyCode(value, out var keyCode)) { Finish(save: true, keyCode); break; } } } } public void Clear() { _entry = null; _buttonText = null; } public void Cancel() { if (IsActive) { Finish(save: false, (KeyCode)0); } } public unsafe static string FormatKeyCode(object value) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!(value is KeyCode val)) { return ConfigValues.FormatValue(value); } return ((object)(*(KeyCode*)(&val))/*cast due to .constrained prefix*/).ToString(); } private void Finish(bool save, KeyCode keyCode) { //IL_0052: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (save && _entry != null && !ConfigValues.TrySetValue(_entry, keyCode)) { keyCode = (KeyCode)_entry.BoxedValue; } else if (_entry != null) { keyCode = (KeyCode)_entry.BoxedValue; } NativeUi.SetLocalizedText(_buttonText, FormatKeyCode(keyCode)); Clear(); } private unsafe static bool TryConvertKeyCode(Key key, out KeyCode keyCode) { string text = ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Digit", StringComparison.Ordinal)) { text = "Alpha" + text.Substring("Digit".Length); } else if (text.StartsWith("Numpad", StringComparison.Ordinal)) { text = "Keypad" + text.Substring("Numpad".Length); } else if (string.Equals(text, "Enter", StringComparison.Ordinal)) { text = "Return"; } else if (string.Equals(text, "Backquote", StringComparison.Ordinal)) { text = "BackQuote"; } return Enum.TryParse<KeyCode>(text, ignoreCase: true, out keyCode); } } internal sealed class ModInfoRow { private sealed class MetadataPart { public string Text { get; } public string Name { get; } public string Url { get; } public MetadataPart(string text, string name = null, string url = null) { Text = text; Name = name; Url = url; } } private sealed class ModLink { public string Name { get; } public string Url { get; } public int Start { get; } public int Length { get; } public ModLink(string name, string url, int start, int length) { Name = name; Url = url; Start = start; Length = length; } } private readonly Transform _content; private readonly GameObject _slider; private readonly GameObject _divider; private readonly GameObject _linkButton; private readonly GameObject _description; private readonly TMP_Text _descriptionFont; public ModInfoRow(Transform content, GameObject slider, GameObject divider, GameObject linkButton, GameObject description, TMP_Text descriptionFont) { _content = content; _slider = slider; _divider = divider; _linkButton = linkButton; _description = description; _descriptionFont = descriptionFont; } public GameObject Create(ModConfig mod) { ModSettingsRegistration registration = mod.Registration; if (registration == null) { return null; } List<ModLink> links; string text = BuildPluginInfoText(registration, out links); if (string.IsNullOrWhiteSpace(text)) { return null; } return CreateInfoTextRow(text, links); } private GameObject CreateInfoTextRow(string text, IReadOnlyList<ModLink> links) { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_022d: 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_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) GameObject val = NewRow("Mod Settings Information"); string[] array = new string[4] { "Title", "Title (1)", "Slider", "Value" }; foreach (string text2 in array) { Transform val2 = val.transform.Find(text2); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } } RectTransform component = val.GetComponent<RectTransform>(); RectTransform component2 = _slider.GetComponent<RectTransform>(); RectTransform component3 = _description.GetComponent<RectTransform>(); GameObject val3 = Object.Instantiate<GameObject>(_divider, val.transform); ((Object)val3).name = "Information Divider"; val3.SetActive(false); RectTransform component4 = val3.GetComponent<RectTransform>(); RectTransform component5 = _divider.GetComponent<RectTransform>(); Transform parent = _divider.transform.parent; RectTransform val4 = ((parent != null) ? ((Component)parent).GetComponent<RectTransform>() : null); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null || (Object)(object)component4 == (Object)null || (Object)(object)component5 == (Object)null || (Object)(object)val4 == (Object)null) { Object.Destroy((Object)(object)val); return null; } float x = component3.sizeDelta.x; RectTransform infoRect; TMP_Text infoText; float infoHeight; GameObject val5 = CreateInfoText(val, text, x, out infoRect, out infoText, out infoHeight); if (!string.IsNullOrWhiteSpace(text) && (Object)(object)val5 == (Object)null) { Object.Destroy((Object)(object)val); return null; } float num = val4.sizeDelta.y * (component5.anchorMax.y - component5.anchorMin.y); float num2 = infoHeight + num + 12f + 6f; component.sizeDelta = new Vector2(component2.sizeDelta.x, num2); float contentTop = num2 * 0.5f - 6f; if ((Object)(object)infoRect != (Object)null) { SetInfoRect(infoRect, component3, x, infoHeight, contentTop); } if (val5 != null) { val5.SetActive(true); } if ((Object)(object)infoText != (Object)null && links.Count > 0) { val.SetActive(true); try { LayoutRebuilder.ForceRebuildLayoutImmediate(component); Canvas.ForceUpdateCanvases(); CreateLinkButtons(val, infoRect, infoText, links); } finally { val.SetActive(false); } } component4.anchorMin = component3.anchorMin; component4.anchorMax = component3.anchorMax; component4.pivot = component3.pivot; component4.sizeDelta = new Vector2(val4.sizeDelta.x, num); component4.anchoredPosition = new Vector2(0f, 0f - num2 * 0.5f + 6f + num * 0.5f); ((Transform)component4).localScale = ((Transform)component5).localScale; ((Transform)component4).localRotation = ((Transform)component5).localRotation; val3.SetActive(true); return val; } private GameObject CreateInfoText(GameObject row, string text, float infoWidth, out RectTransform infoRect, out TMP_Text infoText, out float infoHeight) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) infoRect = null; infoText = null; infoHeight = 0f; if (string.IsNullOrWhiteSpace(text)) { return null; } GameObject val = Object.Instantiate<GameObject>(_description, row.transform); ((Object)val).name = "Information Text"; val.SetActive(false); infoRect = val.GetComponent<RectTransform>(); infoText = val.GetComponent<TMP_Text>(); if ((Object)(object)infoRect == (Object)null || (Object)(object)infoText == (Object)null) { Object.Destroy((Object)(object)val); return null; } infoText.enableAutoSizing = false; infoText.enableWordWrapping = true; infoText.richText = true; infoText.alignment = (TextAlignmentOptions)257; infoText.fontSize = _descriptionFont.fontSize; NativeUi.SetLocalizedText(infoText, text.Trim()); infoHeight = Mathf.Max(_descriptionFont.fontSize, infoText.GetPreferredValues(infoText.text, infoWidth, 0f).y); return val; } private void CreateLinkButtons(GameObject row, RectTransform infoRect, TMP_Text infoText, IReadOnlyList<ModLink> links) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)infoRect == (Object)null || (Object)(object)infoText == (Object)null) { return; } infoText.ForceMeshUpdate(true, true); for (int i = 0; i < links.Count; i++) { ModLink link = links[i]; List<Rect> linkBounds = GetLinkBounds(infoText, link); for (int j = 0; j < linkBounds.Count; j++) { CreateLinkButton(row, infoRect, infoText, link, linkBounds[j], j); } } } private void CreateLinkButton(GameObject row, RectTransform infoRect, TMP_Text infoText, ModLink link, Rect bounds, int segment) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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) GameObject val = Object.Instantiate<GameObject>(_linkButton, row.transform); ((Object)val).name = link.Name + " Link " + segment; val.SetActive(false); NativeUi.DisableRowComponents(val); RectTransform component = val.GetComponent<RectTransform>(); Button component2 = val.GetComponent<Button>(); TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true); Image component3 = val.GetComponent<Image>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)componentInChildren == (Object)null || (Object)(object)component3 == (Object)null) { Object.Destroy((Object)(object)val); return; } component2.onClick = new ButtonClickedEvent(); ((UnityEvent)component2.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate { Application.OpenURL(link.Url); })); ((Behaviour)component2).enabled = true; ((Selectable)component2).interactable = true; ((Selectable)component2).transition = (Transition)0; ((Selectable)component2).targetGraphic = (Graphic)(object)component3; ((Graphic)component3).color = new Color(((Graphic)component3).color.r, ((Graphic)component3).color.g, ((Graphic)component3).color.b, 0f); ((Graphic)component3).raycastTarget = true; NativeUi.SetLocalizedText(componentInChildren, string.Empty); ((Graphic)componentInChildren).raycastTarget = false; component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = ((Rect)(ref bounds)).size + new Vector2(4f, 4f); ((Transform)component).localScale = ((Transform)infoRect).localScale; ((Transform)component).localRotation = ((Transform)infoRect).localRotation; ((Transform)component).localPosition = row.transform.InverseTransformPoint(((Transform)infoRect).TransformPoint(new Vector3(((Rect)(ref bounds)).center.x, ((Rect)(ref bounds)).center.y, 0f))); ConfigureLinkHover(val, infoText, link); val.SetActive(true); } private static void SetInfoRect(RectTransform infoRect, RectTransform sourceRect, float width, float height, float contentTop) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) infoRect.anchorMin = sourceRect.anchorMin; infoRect.anchorMax = sourceRect.anchorMax; infoRect.pivot = sourceRect.pivot; infoRect.sizeDelta = new Vector2(width, height); infoRect.anchoredPosition = new Vector2(0f, contentTop - height * 0.5f); ((Transform)infoRect).localScale = ((Transform)sourceRect).localScale; ((Transform)infoRect).localRotation = ((Transform)sourceRect).localRotation; } private static List<Rect> GetLinkBounds(TMP_Text text, ModLink link) { //IL_0145: 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_00ef: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) List<Rect> list = new List<Rect>(); TMP_TextInfo textInfo = text.textInfo; int num = Math.Min(link.Start + link.Length, textInfo.characterCount); int num2 = -1; float num3 = 0f; float num4 = 0f; float num5 = 0f; float num6 = 0f; for (int i = link.Start; i < num; i++) { TMP_CharacterInfo val = ((Il2CppArrayBase<TMP_CharacterInfo>)(object)textInfo.characterInfo)[i]; if (val == null || !val.isVisible) { continue; } if (num2 != val.lineNumber) { if (num2 >= 0) { list.Add(Rect.MinMaxRect(num3, num4, num5, num6)); } num2 = val.lineNumber; num3 = val.bottomLeft.x; num4 = val.bottomLeft.y; num5 = val.topRight.x; num6 = val.topRight.y; } else { num3 = Mathf.Min(num3, val.bottomLeft.x); num4 = Mathf.Min(num4, val.bottomLeft.y); num5 = Mathf.Max(num5, val.topRight.x); num6 = Mathf.Max(num6, val.topRight.y); } } if (num2 >= 0) { list.Add(Rect.MinMaxRect(num3, num4, num5, num6)); } return list; } private static void ConfigureLinkHover(GameObject buttonObject, TMP_Text infoText, ModLink link) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown if (!((Object)(object)buttonObject == (Object)null) && !((Object)(object)infoText == (Object)null) && link.Start >= 0 && link.Start + link.Length <= infoText.text.Length) { string normalText = infoText.text; string hoverText = normalText.Substring(0, link.Start) + "<u>" + normalText.Substring(link.Start, link.Length) + "</u>" + normalText.Substring(link.Start + link.Length); EventTrigger obj = buttonObject.GetComponent<EventTrigger>() ?? buttonObject.AddComponent<EventTrigger>(); obj.triggers.Clear(); Entry val = new Entry { eventID = (EventTriggerType)0 }; ((UnityEvent<BaseEventData>)(object)val.callback).AddListener(DelegateSupport.ConvertDelegate<UnityAction<BaseEventData>>((Delegate)(Action<BaseEventData>)delegate { infoText.text = hoverText; })); obj.triggers.Add(val); Entry val2 = new Entry { eventID = (EventTriggerType)1 }; ((UnityEvent<BaseEventData>)(object)val2.callback).AddListener(DelegateSupport.ConvertDelegate<UnityAction<BaseEventData>>((Delegate)(Action<BaseEventData>)delegate { infoText.text = normalText; })); obj.triggers.Add(val2); } } private static string BuildPluginInfoText(ModSettingsRegistration registration, out List<ModLink> links) { List<MetadataPart> list = new List<MetadataPart>(); bool hasValue = registration.NexusModsId.HasValue; bool flag = !string.IsNullOrWhiteSpace(registration.ThunderstoreTeam); bool flag2 = hasValue && flag; if (!string.IsNullOrWhiteSpace(registration.Version)) { list.Add(new MetadataPart("V" + registration.Version.Trim())); } if (!string.IsNullOrWhiteSpace(registration.Author)) { list.Add(new MetadataPart(registration.Author.Trim())); } if (hasValue) { list.Add(new MetadataPart(flag2 ? "Nexus" : I18n.Text("menu.open_nexus_page"), "Nexus Mods", ModSettingsRegistry.GetNexusModsUrl(registration.NexusModsId.Value))); } if (flag) { list.Add(new MetadataPart(flag2 ? "Thunderstore" : I18n.Text("menu.open_thunderstore_page"), "Thunderstore", ModSettingsRegistry.GetThunderstoreUrl(registration.ThunderstoreTeam, registration.ThunderstoreModName))); } links = new List<ModLink>(); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { if (i > 0) { stringBuilder.Append(" · "); } MetadataPart metadataPart = list[i]; int length = stringBuilder.Length; stringBuilder.Append(metadataPart.Text); if (!string.IsNullOrWhiteSpace(metadataPart.Url)) { links.Add(new ModLink(metadataPart.Name, metadataPart.Url, length, metadataPart.Text.Length)); } } if (!string.IsNullOrWhiteSpace(registration.Description)) { if (stringBuilder.Length > 0) { stringBuilder.Append("\n\n"); } stringBuilder.Append(registration.Description.Trim()); } return stringBuilder.ToString(); } private GameObject NewRow(string name) { GameObject val = Object.Instantiate<GameObject>(_slider, _content); ((Object)val).name = name; val.SetActive(false); MatchRow(val); NativeUi.DisableRowComponents(val); return val; } private void MatchRow(GameObject row) { //IL_0028: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) RectTransform component = _slider.GetComponent<RectTransform>(); RectTransform component2 = row.GetComponent<RectTransform>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null)) { component2.anchorMin = component.anchorMin; component2.anchorMax = component.anchorMax; component2.pivot = component.pivot; component2.sizeDelta = component.sizeDelta; component2.anchoredPosition = component.anchoredPosition; ((Transform)component2).localScale = ((Transform)component).localScale; ((Transform)component2).localRotation = ((Transform)component).localRotation; } } } public static class ModSettingsMenuController { private const string MainMenuButtonPath = "Main Menu/Settings Button"; private const string QuitButtonPath = "Main Menu/Quit BTN"; private const string SettingsPanelName = "Settings"; private static Transform _mainMenuRoot; private static GameObject _mainMenuObject; private static GameObject _modSettingsButton; private static ModSettingsPanel _settingsPanel; public static void TryCreate(MainMenu mainMenu) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown try { if ((Object)(object)mainMenu == (Object)null || (Object)(object)mainMenu.mainMenu == (Object)null) { return; } GameObject mainMenu2 = mainMenu.mainMenu; if (!((Object)(object)_modSettingsButton != (Object)null) || !((Object)(object)_mainMenuObject == (Object)(object)mainMenu2)) { ResetReferences(); Transform transform = mainMenu2.transform; Transform source = NativeUi.RequireTransform(transform, "Main Menu/Settings Button"); Transform quitButton = NativeUi.RequireTransform(transform, "Main Menu/Quit BTN"); Transform parent = transform.parent; if ((Object)(object)parent == (Object)null) { throw new InvalidOperationException("Canvas parent is missing."); } Transform source2 = NativeUi.RequireTransform(parent, "Settings"); _mainMenuRoot = transform; _mainMenuObject = mainMenu2; _settingsPanel = ModSettingsPanel.Create(source2, parent, CloseSettings); _modSettingsButton = CreateMainMenuButton(source, quitButton); } } catch (Exception ex) { ManualLogSource logger = ModSettingsMenu.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to create the mod settings menu: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); ResetReferences(); } } public static void CheckBackInput() { if (_settingsPanel == null || !_settingsPanel.IsOpen) { return; } if (_settingsPanel.IsCapturingKeybind) { _settingsPanel.CaptureKeybindInput(); return; } _settingsPanel.ScrollModList(); Keyboard current = Keyboard.current; Gamepad current2 = Gamepad.current; if ((current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) || (current2 != null && current2.buttonEast.wasPressedThisFrame)) { CloseSettings(); } } public static void RefreshLocalizedText() { if ((Object)(object)_modSettingsButton != (Object)null) { NativeUi.SetText(_modSettingsButton, I18n.Text("menu.mod_settings")); } _settingsPanel?.RefreshLocalizedText(); } private static GameObject CreateMainMenuButton(Transform source, Transform quitButton) { //IL_00a0: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_010c: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, source.parent); ((Object)val).name = "Mod Settings Button"; Transform val2 = NativeUi.RequireTransform(source.parent, "PlayButtonHolder"); Transform obj = NativeUi.RequireTransform(source.parent, "Credits Button"); RectTransform component = ((Component)val2).GetComponent<RectTransform>(); RectTransform component2 = ((Component)obj).GetComponent<RectTransform>(); RectTransform component3 = ((Component)source).GetComponent<RectTransform>(); RectTransform component4 = ((Component)quitButton).GetComponent<RectTransform>(); RectTransform component5 = val.GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null || (Object)(object)component4 == (Object)null || (Object)(object)component5 == (Object)null) { throw new InvalidOperationException("Main menu buttons or PlayButtonHolder are missing RectTransform."); } float num = component3.anchoredPosition.y - component4.anchoredPosition.y; float num2 = (component.anchoredPosition.y - component4.anchoredPosition.y) / 4f; if (num <= 0f || num2 <= 0f) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Main menu button spacing is invalid."); } float num3 = num2 / num; Vector3 val3 = ((Transform)component3).localScale * num3; float y = component.anchoredPosition.y; ((Transform)component).localScale = val3; SetButtonLayout(component2, val3, y - num2); SetButtonLayout(component3, val3, y - num2 * 2f); SetButtonLayout(component5, val3, y - num2 * 3f); SetButtonLayout(component4, val3, y - num2 * 4f); val.transform.SetSiblingIndex(quitButton.GetSiblingIndex()); Button component6 = val.GetComponent<Button>(); if ((Object)(object)component6 == (Object)null) { throw new InvalidOperationException("Cloned main menu button is missing Button."); } component6.onClick = new ButtonClickedEvent(); ((UnityEvent)component6.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)new Action(OpenSettings))); NativeUi.SetText(val, I18n.Text("menu.mod_settings")); Button component7 = ((Component)source).GetComponent<Button>(); if ((Object)(object)component7 != (Object)null) { Navigation navigation = ((Selectable)component7).navigation; navigation.selectOnDown = (Selectable)(object)component6; ((Selectable)component7).navigation = navigation; } Navigation navigation2 = ((Selectable)component6).navigation; navigation2.selectOnUp = (Selectable)(object)component7; navigation2.selectOnDown = (Selectable)(object)((Component)quitButton).GetComponent<Button>(); ((Selectable)component6).navigation = navigation2; Button component8 = ((Component)quitButton).GetComponent<Button>(); if ((Object)(object)component8 != (Object)null) { Navigation navigation3 = ((Selectable)component8).navigation; navigation3.selectOnUp = (Selectable)(object)component6; ((Selectable)component8).navigation = navigation3; } return val; } private static void OpenSettings() { if (_settingsPanel != null && !((Object)(object)_mainMenuRoot == (Object)null)) { _settingsPanel.Prepare(); ((Component)_mainMenuRoot).gameObject.SetActive(false); _settingsPanel.Show(); } } private static void CloseSettings() { if (_settingsPanel != null && !((Object)(object)_mainMenuRoot == (Object)null)) { _settingsPanel.Hide(); ((Component)_mainMenuRoot).gameObject.SetActive(true); NativeUi.SelectObject(_modSettingsButton); } } private static void SetButtonLayout(RectTransform rectTransform, Vector3 scale, float anchoredY) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, anchoredY); ((Transform)rectTransform).localScale = scale; } private static void ResetReferences() { _mainMenuRoot = null; _mainMenuObject = null; _modSettingsButton = null; _settingsPanel = null; } } internal sealed class ModSettingsPanel { private const string InputRowPath = "CreateLobbySettings/Lobby Name"; private const string DescriptionTextPath = "NetworkErrorPopup/DescriptionText (TMP)"; private const string PauseBackButtonName = "Mod Settings Back Button"; private static readonly string[] PluginButtonSlotPaths = new string[4] { "Audio Button", "KeyboardControls Button", "GamepadControlsButton", "Video Button" }; private readonly GameObject _panel; private readonly TMP_Text _title; private readonly GameObject _backButtonObject; private readonly GameObject _buttonTemplate; private readonly Transform _buttonParent; private readonly ScrollRect _modScroll; private readonly float _modButtonStep; private readonly ConfigRows _rows; private readonly KeybindCapture _keybindCapture; private readonly List<GameObject> _modButtons = new List<GameObject>(); private IReadOnlyList<ModConfig> _mods = Array.Empty<ModConfig>(); private string _selectedGuid; public bool IsOpen { get { if ((Object)(object)_panel != (Object)null) { return _panel.activeSelf; } return false; } } public bool IsCapturingKeybind => _keybindCapture.IsActive; private ModSettingsPanel(GameObject panel, TMP_Text title, GameObject backButtonObject, GameObject buttonTemplate, Transform buttonParent, ScrollRect modScroll, float modButtonStep, ConfigRows rows, KeybindCapture keybindCapture) { _panel = panel; _title = title; _backButtonObject = backButtonObject; _buttonTemplate = buttonTemplate; _buttonParent = buttonParent; _modScroll = modScroll; _modButtonStep = modButtonStep; _rows = rows; _keybindCapture = keybindCapture; } public static ModSettingsPanel Create(Transform source, Transform canvas, Action closeSettings) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, canvas); ((Object)val).name = "Mod Settings"; val.SetActive(false); NativeUi.DisableComponent<ControlsMenuSwitcher>(val); NativeUi.DisableComponent<SettingsBackButtonNavigation>(val); NativeUi.DisableComponent<PauseMenu>(val); NativeUi.DisableComponent<SelectObjectOnDisable>(val); for (int i = 0; i < val.transform.childCount; i++) { ((Component)val.transform.GetChild(i)).gameObject.SetActive(false); } Transform val2 = NativeUi.RequireTransform(val.transform, "BG"); GameObject gameObject = ((Component)NativeUi.RequireTransform(val.transform, "Back to menu Button")).gameObject; Transform val3 = NativeUi.RequireTransform(val.transform, "Audio Menu"); ((Component)val2).gameObject.SetActive(true); gameObject.SetActive(true); ((Component)val3).gameObject.SetActive(true); Button component = gameObject.GetComponent<Button>(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("Mod settings back button is missing Button."); } component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)closeSettings)); List<RectTransform> list = new List<RectTransform>(); string[] pluginButtonSlotPaths = PluginButtonSlotPaths; foreach (string text in pluginButtonSlotPaths) { Transform obj = NativeUi.RequireTransform(val.transform, text); RectTransform component2 = ((Component)obj).GetComponent<RectTransform>(); if ((Object)(object)component2 == (Object)null) { throw new InvalidOperationException("Mod button slot " + text + " is missing RectTransform."); } list.Add(component2); ((Component)obj).gameObject.SetActive(false); } GameObject gameObject2 = ((Component)NativeUi.RequireTransform(val.transform, PluginButtonSlotPaths[0])).gameObject; Transform obj2 = val3.Find("TITLE (1)"); TMP_Text val4 = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null); NativeUi.SetLocalizedText(val4, I18n.Text("menu.mod_settings")); NativeUi.DisableComponent<SelectObjectOnDisable>(((Component)val3).gameObject); NativeUi.DisableComponent<ScrollRectControllerFocus>(((Component)val3).gameObject); Transform val5 = NativeUi.RequireTransform(val3, "Scroll View (1)"); GameObject gameObject3 = ((Component)NativeUi.RequireTransform(NativeUi.RequireTransform(val5, "Viewport/Content"), "Music Bar")).gameObject; GameObject gameObject4 = ((Component)NativeUi.RequireTransform(gameObject3.transform, "Slider/Background")).gameObject; GameObject gameObject5 = ((Component)NativeUi.RequireTransform(val.transform, "Video Menu/Scroll View/Viewport/Content/Display Mode (1)")).gameObject; TMP_Text component3 = ((Component)NativeUi.RequireTransform(gameObject5.transform, "Dropdown/Label")).GetComponent<TMP_Text>(); if ((Object)(object)component3 == (Object)null) { throw new InvalidOperationException("Config description font template is missing TextMeshProUGUI."); } GameObject gameObject6 = ((Component)NativeUi.RequireTransform(val.transform, "Video Menu/Scroll View/Viewport/Content/Arachnophobia Mode")).gameObject; GameObject gameObject7 = ((Component)NativeUi.RequireTransform(canvas, "CreateLobbySettings/Lobby Name")).gameObject; GameObject gameObject8 = ((Component)NativeUi.RequireTransform(val.transform, "Controls Menu/Scroll View/Viewport/Content/MoveForward")).gameObject; GameObject gameObject9 = ((Component)NativeUi.RequireTransform(gameObject8.transform, "Button")).gameObject; GameObject gameObject10 = ((Component)NativeUi.RequireTransform(canvas, "NetworkErrorPopup/DescriptionText (TMP)")).gameObject; return CreatePanel(val, val4, gameObject, gameObject2, list, val5, gameObject3, gameObject4, gameObject6, gameObject5, gameObject7, gameObject8, gameObject9, gameObject10, component3); } public static ModSettingsPanel Create(PauseMenu pauseMenu, Action closeSettings) { if ((Object)(object)pauseMenu == (Object)null) { throw new ArgumentNullException("pauseMenu"); } if (closeSettings == null) { throw new ArgumentNullException("closeSettings"); } Transform transform = ((Component)pauseMenu).transform; Transform val = transform.Find("Button Vertical Layout Group") ?? transform; List<RectTransform> list = new List<RectTransform>(); string[] pluginButtonSlotPaths = PluginButtonSlotPaths; foreach (string text in pluginButtonSlotPaths) { Transform val2 = val.Find(text); if (!((Object)(object)val2 == (Object)null)) { RectTransform component = ((Component)val2).GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("Pause menu button slot " + text + " is missing RectTransform."); } list.Add(component); } } if (list.Count < 2) { throw new InvalidOperationException("Pause menu does not expose enough settings button slots."); } GameObject val3 = Object.Instantiate<GameObject>(((Component)NativeUi.RequireTransform(transform, "Audio Menu")).gameObject, transform); ((Object)val3).name = "Mod Settings"; val3.SetActive(false); NativeUi.DisableComponent<BackButtonPressed>(val3); NativeUi.DisableComponent<SelectObjectOnDisable>(val3); NativeUi.DisableComponent<ScrollRectControllerFocus>(val3); TMP_Text component2 = ((Component)NativeUi.RequireTransform(val3.transform, "TITLE")).GetComponent<TMP_Text>(); NativeUi.SetLocalizedText(component2, I18n.Text("menu.mod_settings")); Transform val4 = NativeUi.RequireTransform(val3.transform, "Scroll View"); GameObject gameObject = ((Component)NativeUi.RequireTransform(NativeUi.RequireTransform(val4, "Viewport/Content"), "Music Bar")).gameObject; GameObject gameObject2 = ((Component)NativeUi.RequireTransform(gameObject.transform, "Slider/Background")).gameObject; GameObject gameObject3 = ((Component)NativeUi.RequireTransform(transform, "Video Menu/Scroll View/Viewport/Content/Display Mode")).gameObject; TMP_Text component3 = ((Component)NativeUi.RequireTransform(gameObject3.transform, "Dropdown/Label")).GetComponent<TMP_Text>(); if ((Object)(object)component3 == (Object)null) { Object.Destroy((Object)(object)val3); throw new InvalidOperationException("Pause menu config description font template is missing TextMeshProUGUI."); } GameObject gameObject4 = ((Component)NativeUi.RequireTransform(transform, "Video Menu/Scroll View/Viewport/Content/Arachnophobia Mode")).gameObject; GameObject gameObject5 = ((Component)NativeUi.RequireTransform(transform, "Controls Menu/Scroll View/Viewport/Content/MoveForward")).gameObject; GameObject gameObject6 = ((Component)NativeUi.RequireTransform(gameObject5.transform, "Button")).gameObject; GameObject gameObject7 = ((Component)NativeUi.RequireTransform(transform, "RestoreDefaultAudioSettings/Text (TMP) (1)")).gameObject; GameObject inputTemplate = CreatePauseInputTemplate(gameObject5, val3.transform); GameObject gameObject8 = ((Component)NativeUi.RequireTransform(val, "Audio Button")).gameObject; GameObject val5 = CreatePauseBackButton(((Component)NativeUi.RequireTransform(val, "Quit Button")).gameObject, val3.transform, closeSettings); ModSettingsPanel result = CreatePanel(val3, component2, val5, gameObject8, list, val4, gameObject, gameObject2, gameObject4, gameObject3, inputTemplate, gameObject5, gameObject6, gameObject7, component3); val5.transform.SetAsLastSibling(); return result; } private static ModSettingsPanel CreatePanel(GameObject panel, TMP_Text title, GameObject backButtonObject, GameObject buttonSource, IReadOnlyList<RectTransform> buttonSlots, Transform scrollView, GameObject sliderTemplate, GameObject dividerTemplate, GameObject toggleTemplate, GameObject dropdownTemplate, GameObject inputTemplate, GameObject keybindTemplate, GameObject linkButtonTemplate, GameObject descriptionTemplate, TMP_Text descriptionFontTemplate) { NativeUi.DisableComponent<ScrollRectControllerSupport>(((Component)scrollView).gameObject); NativeUi.DisableComponent<ConsoleUINavigation>(((Component)scrollView).gameObject); NativeUi.DisableComponent<ScrollRectFollowSelection>(((Component)scrollView).gameObject); Transform val = NativeUi.RequireTransform(scrollView, "Viewport/Content"); NativeUi.DisableComponent<PerPlayerVolumeUI>(((Component)val).gameObject); Transform content; float buttonStep; float buttonWidth; ScrollRect modScroll = CreateModList(panel.transform, scrollView, buttonSlots, out content, out buttonStep, out buttonWidth); GameObject buttonTemplate = CreateButtonTemplate(panel.transform, buttonSource, buttonWidth); for (int i = 0; i < val.childCount; i++) { ((Component)val.GetChild(i)).gameObject.SetActive(false); } KeybindCapture keybindCapture = new KeybindCapture(); DescriptionLayout description = new DescriptionLayout(sliderTemplate, dropdownTemplate, descriptionTemplate, descriptionFontTemplate); ModInfoRow modInfo = new ModInfoRow(val, sliderTemplate, dividerTemplate, linkButtonTemplate, descriptionTemplate, descriptionFontTemplate); ConfigRows rows = new ConfigRows(val, sliderTemplate, toggleTemplate, dropdownTemplate, inputTemplate, keybindTemplate, keybindCapture, description, modInfo); return new ModSettingsPanel(panel, title, backButtonObject, buttonTemplate, content, modScroll, buttonStep, rows, keybindCapture); } private static GameObject CreatePauseInputTemplate(GameObject keybindTemplate, Transform parent) { GameObject val = Object.Instantiate<GameObject>(keybindTemplate, parent); ((Object)val).name = "Mod Settings Input Template"; val.SetActive(false); NativeUi.DisableRowComponents(val); GameObject gameObject = ((Component)NativeUi.RequireTransform(val.transform, "Button")).gameObject; Button component = gameObject.GetComponent<Button>(); Image component2 = gameObject.GetComponent<Image>(); TMP_Text componentInChildren = gameObject.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)componentInChildren == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Pause menu keybind template cannot provide a text input field."); } Object.DestroyImmediate((Object)(object)component); TMP_InputField obj = gameObject.AddComponent<TMP_InputField>(); if ((Object)(object)obj == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Failed to add TMP_InputField to the pause menu input template."); } ((Selectable)obj).targetGraphic = (Graphic)(object)component2; obj.textViewport = componentInChildren.rectTransform; obj.textComponent = componentInChildren; obj.lineType = (LineType)0; obj.richText = false; componentInChildren.enableWordWrapping = false; ((Graphic)componentInChildren).raycastTarget = false; return val; } private static GameObject CreatePauseBackButton(GameObject source, Transform parent, Action closeSettings) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(source, parent); ((Object)val).name = "Mod Settings Back Button"; RectTransform component = source.GetComponent<RectTransform>(); RectTransform component2 = val.GetComponent<RectTransform>(); Button component3 = val.GetComponent<Button>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Pause menu back button template is missing RectTransform or Button."); } Vector3 lossyScale = parent.lossyScale; Vector3 lossyScale2 = ((Transform)component).lossyScale; component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.pivot = component.pivot; component2.sizeDelta = component.sizeDelta; ((Transform)component2).localScale = new Vector3(lossyScale2.x / lossyScale.x, lossyScale2.y / lossyScale.y, lossyScale2.z / lossyScale.z); ((Transform)component2).localRotation = Quaternion.Inverse(parent.rotation) * ((Transform)component).rotation; ((Transform)component2).position = ((Transform)component).position; component3.onClick = new ButtonClickedEvent(); ((UnityEvent)component3.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)closeSettings)); NativeUi.SetText(val, I18n.Text("menu.back")); val.SetActive(true); return val; } private static GameObject CreateButtonTemplate(Transform panel, GameObject source, float width) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(source, panel); ((Object)val).name = "Mod Selection Template"; val.SetActive(false); RectTransform component = source.GetComponent<RectTransform>(); RectTransform component2 = val.GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Mod selection button template is missing RectTransform."); } Vector3 lossyScale = panel.lossyScale; Vector3 lossyScale2 = ((Transform)component).lossyScale; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(lossyScale2.x / lossyScale.x, lossyScale2.y / lossyScale.y, lossyScale2.z / lossyScale.z); component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.pivot = component.pivot; component2.sizeDelta = new Vector2(width / Mathf.Abs(val2.x), component.sizeDelta.y); component2.anchoredPosition = Vector2.zero; ((Transform)component2).localScale = val2; ((Transform)component2).localRotation = Quaternion.Inverse(panel.rotation) * ((Transform)component).rotation; return val; } public void Prepare() { _keybindCapture.Cancel(); BuildModButtons(); BuildRows(); } public void Show() { _panel.SetActive(true); NativeUi.SelectObject(_modButtons.FirstOrDefault() ?? _backButtonObject); } public void Hide() { _keybindCapture.Cancel(); _panel.SetActive(false); } public void Destroy() { _keybindCapture.Cancel(); if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)_panel); } } public void CancelKeybind() { _keybindCapture.Cancel(); } public void CaptureKeybindInput() { _keybindCapture.CaptureInput(); } public void ScrollModList() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; RectTransform viewport = _modScroll.viewport; RectTransform content = _modScroll.content; if (current == null || (Object)(object)viewport == (Object)null || (Object)(object)content == (Object)null) { return; } Vector2 val = ((InputControl<Vector2>)(object)current.scroll).ReadValue(); if (!Mathf.Approximately(val.y, 0f) && RectTransformUtility.RectangleContainsScreenPoint(viewport, ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(), (Camera)null)) { Rect rect = content.rect; float height = ((Rect)(ref rect)).height; rect = viewport.rect; float num = height - ((Rect)(ref rect)).height; if (!(num <= 0f)) { _modScroll.StopMovement(); _modScroll.verticalNormalizedPosition = Mathf.Clamp01(_modScroll.verticalNormalizedPosition + Mathf.Sign(val.y) * (_modButtonStep / num)); } } } public void RefreshLocalizedText() { NativeUi.SetLocalizedText(_title, I18n.Text("menu.mod_settings")); if ((Object)(object)_backButtonObject != (Object)null && ((Object)_backButtonObject).name == "Mod Settings Back Button") { NativeUi.SetText(_backButtonObject, I18n.Text("menu.back")); } if (IsOpen) { Prepare(); } } private void BuildModButtons() { //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown foreach (GameObject modButton in _modButtons) { if ((Object)(object)modButton != (Object)null) { modButton.SetActive(false); Object.Destroy((Object)(object)modButton); } } _modButtons.Clear(); _mods = ModConfigs.Load(); if (!_mods.Any((ModConfig mod) => string.Equals(mod.Info.Metadata.GUID, _selectedGuid, StringComparison.OrdinalIgnoreCase))) { ModConfig? modConfig = _mods.FirstOrDefault(); _selectedGuid = ((modConfig != null) ? modConfig.Info.Metadata.GUID : null); } for (int num = 0; num < _mods.Count; num++) { ModConfig modConfig2 = _mods[num]; GameObject val = Object.Instantiate<GameObject>(_buttonTemplate, _buttonParent); ((Object)val).name = "Mod Settings - " + modConfig2.Info.Metadata.GUID; val.SetActive(false); RectTransform component = val.GetComponent<RectTransform>(); Button component2 = val.GetComponent<Button>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Cloned mod selection button is missing RectTransform or Button."); } NativeUi.DisableComponent<RemoveOnConsole>(val); string guid = modConfig2.Info.Metadata.GUID; component2.onClick = new ButtonClickedEvent(); ((UnityEvent)component2.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate { SelectMod(guid); })); NativeUi.SetText(val, GetModName(modConfig2)); val.SetActive(true); _modButtons.Add(val); } Button val2 = (((Object)(object)_backButtonObject != (Object)null && ((Object)_backButtonObject).name == "Mod Settings Back Button") ? _backButtonObject.GetComponent<Button>() : null); for (int num2 = 0; num2 < _modButtons.Count; num2++) { Button component3 = _modButtons[num2].GetComponent<Button>(); Navigation navigation = ((Selectable)component3).navigation; navigation.mode = (Mode)4; navigation.selectOnUp = (Selectable)(object)((num2 > 0) ? _modButtons[num2 - 1].GetComponent<Button>() : null); navigation.selectOnDown = (Selectable)(object)((num2 + 1 < _modButtons.Count) ? _modButtons[num2 + 1].GetComponent<Button>() : val2); ((Selectable)component3).navigation = navigation; } if ((Object)(object)val2 != (Object)null) { Navigation navigation2 = ((Selectable)val2).navigation; navigation2.mode = (Mode)4; GameObject? obj = _modButtons.LastOrDefault(); navigation2.selectOnUp = (Selectable)(object)((obj != null) ? obj.GetComponent<Button>() : null); navigation2.selectOnDown = null; ((Selectable)val2).navigation = navigation2; } LayoutRebuilder.ForceRebuildLayoutImmediate(((Component)_buttonParent).GetComponent<RectTransform>()); _modScroll.StopMovement(); if (_mods.Count <= PluginButtonSlotPaths.Length) { _modScroll.verticalNormalizedPosition = 1f; } } private void BuildRows() { ModConfig mod = _mods.FirstOrDefault((ModConfig item) => string.Equals(item.Info.Metadata.GUID, _selectedGuid, StringComparison.OrdinalIgnoreCase)); _rows.Build(mod); } private void SelectMod(string guid) { _selectedGuid = guid; BuildRows(); } private static string GetModName(ModConfig mod) { string text = mod.Registration?.Name; if (string.IsNullOrWhiteSpace(text)) { text = mod.Info.Metadata.Name; } return SplitName(text); } private static string SplitName(string name) { if (string.IsNullOrWhiteSpace(name)) { return string.Empty; } return Regex.Replace(name.Replace('_', ' ').Replace('-', ' '), "(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])", " "); } private static ScrollRect CreateModList(Transform panel, Transform source, IReadOnlyList<RectTransform> slots, out Transform content, out float buttonStep, out float buttonWidth) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, panel); ((Object)val).name = "Mod List"; val.SetActive(false); NativeUi.DisableComponent<ScrollRectControllerSupport>(val); NativeUi.DisableComponent<ConsoleUINavigation>(val); RectTransform component = val.GetComponent<RectTransform>(); Transform val2 = NativeUi.RequireTransform(val.transform, "Viewport"); RectTransform component2 = ((Component)val2).GetComponent<RectTransform>(); content = NativeUi.RequireTransform(val2, "Content"); RectTransform component3 = ((Component)content).GetComponent<RectTransform>(); VerticalLayoutGroup component4 = ((Component)content).GetComponent<VerticalLayoutGroup>(); ContentSizeFitter component5 = ((Component)content).GetComponent<ContentSizeFitter>(); ScrollRect component6 = val.GetComponent<ScrollRect>(); RectTransform component7 = ((Component)source).GetComponent<RectTransform>(); object obj; if (component6 == null) { obj = null; } else { Scrollbar verticalScrollbar = component6.verticalScrollbar; obj = ((verticalScrollbar != null) ? ((Component)verticalScrollbar).GetComponent<RectTransform>() : null); } RectTransform val3 = (RectTransform)obj; if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null || (Object)(object)component4 == (Object)null || (Object)(object)component5 == (Object)null || (Object)(object)component6 == (Object)null || (Object)(object)component7 == (Object)null || (Object)(object)val3 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Native mod list scroll template is missing required components."); } RectTransform val4 = slots[0]; RectTransform val5 = slots[slots.Count - 1]; Rect rect = val4.rect; float x = ((Rect)(ref rect)).center.x; rect = val4.rect; float y = panel.InverseTransformPoint(((Transform)val4).TransformPoint(new Vector3(x, ((Rect)(ref rect)).yMax, 0f))).y; rect = val5.rect; float x2 = ((Rect)(ref rect)).center.x; rect = val5.rect; float y2 = panel.InverseTransformPoint(((Transform)val5).TransformPoint(new Vector3(x2, ((Rect)(ref rect)).yMin, 0f))).y; rect = val4.rect; float x3 = ((Rect)(ref rect)).center.x; rect = val4.rect; float y3 = panel.InverseTransformPoint(((Transform)val4).TransformPoint(new Vector3(x3, ((Rect)(ref rect)).yMin, 0f))).y; float num = y - y3; float num2 = Mathf.Abs(component2.sizeDelta.x); rect = val4.rect; float x4 = panel.InverseTransformPoint(((Transform)val4).TransformPoint(new Vector3(((Rect)(ref rect)).xMin, 0f, 0f))).x; rect = val4.rect; float num3 = panel.InverseTransformPoint(((Transform)val4).TransformPoint(new Vector3(((Rect)(ref rect)).xMax, 0f, 0f))).x - x4; rect = component7.rect; float x5 = panel.InverseTransformPoint(source.TransformPoint(new Vector3(((Rect)(ref rect)).xMin, 0f, 0f))).x; rect = val3.rect; float x6 = panel.InverseTransformPoint(((Transform)val3).TransformPoint(new Vector3(((Rect)(ref rect)).xMax, 0f, 0f))).x; rect = val3.rect; float num4 = Mathf.Abs(x6 - panel.InverseTransformPoint(((Transform)val3).TransformPoint(new Vector3(((Rect)(ref rect)).xMin, 0f, 0f))).x); float num5 = x5 - x4 - num4; float num6 = num3 + num + num2; float num7 = Mathf.Min(num5, num6); buttonWidth = num7 - num2; if (buttonWidth <= num3) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Native settings panel does not have enough space for a wider mod list."); } component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = new Vector2(x4 + num7 * 0.5f, (y + y2) * 0.5f); component.sizeDelta = new Vector2(num7, y - y2); ((Transform)component).localScale = Vector3.one; ((Transform)component).localRotation = Quaternion.identity; component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(1f, 1f); component3.pivot = new Vector2(0.5f, 1f); component3.anchoredPosition = Vector2.zero; component3.sizeDelta = Vector2.zero; float num8 = (y - y2 - num * (float)slots.Count) / (float)(slots.Count - 1); buttonStep = num + num8; ((LayoutGroup)component4).padding = new RectOffset(0, 0, 0, 0); ((LayoutGroup)component4).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)component4).spacing = num8; ((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component4).childScaleWidth = false; ((HorizontalOrVerticalLayoutGroup)component4).childScaleHeight = true; component5.horizontalFit = (FitMode)0; component5.verticalFit = (FitMode)2; component6.content = component3; component6.viewport = component2; component6.horizontal = false; component6.vertical = true; component6.verticalScrollbarVisibility = (ScrollbarVisibility)2; component6.verticalNormalizedPosition = 1f; ScrollRectFollowSelection component8 = val.GetComponent<ScrollRectFollowSelection>(); if ((Object)(object)component8 != (Object)null) { component8.scrollRect = component6; ((Behaviour)component8).enabled = true; } NativeUi.DisableComponent<PerPlayerVolumeUI>(((Component)content).gameObject); for (int i = 0; i < content.childCount; i++) { ((Component)content.GetChild(i)).gameObject.SetActive(false); } val.SetActive(true); return component6; } } internal static class NativeUi { public static void DisableRowComponents(GameObject row) { UseLanguageFontsOnly(row); NativeUi.DisableComponent<RemoveOnConsole>(row); NativeUi.DisableComponent<RemoveIfNotController>(row); NativeUi.DisableComponent<ControllerButtonPrompt>(row); NativeUi.DisableComponent<ChangeTextToKeybind>(row); for (int i = 0; i < row.transform.childCount; i++) { GameObject gameObject = ((Component)row.transform.GetChild(i)).gameObject; if (((Object)gameObject).name.StartsWith("CONTROLLER BUTTON PROMPT", StringComparison.Ordinal)) { gameObject.SetActive(false); } } } public static void UseLanguageFontsOnly(GameObject root) { Il2CppArrayBase<LanguageText> componentsInChildren = root.GetComponentsInChildren<LanguageText>(true); for (int i = 0; i < componentsInChildren.Length; i++) { LanguageText obj = componentsInChildren[i]; ((Behaviour)obj).enabled = false; obj.fontOnly = true; obj.OnEnable(); obj.SetText(); } } public static void SetLocalizedText(TMP_Text label, string text) { if (!((Object)(object)label == (Object)null)) { UseLanguageFontsOnly(((Component)label).gameObject); label.text = text; } } public static void SetText(GameObject root, string text) { UseLanguageFontsOnly(root); TMP_Text componentInChildren = root.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = text; } } public static TMP_Text SetRowTitle(GameObject row, string text) { Transform val = row.transform.Find("Title") ?? row.transform.Find("Title (1)"); if ((Object)(object)val == (Object)null) { SetText(row, text); return row.GetComponentInChildren<TMP_Text>(true); } TMP_Text component = ((Component)val).GetComponent<TMP_Text>(); SetLocalizedText(component, text); return component; } public static void CopyFont(TMP_Text source, TMP_Text target) { if ((Object)(object)source != (Object)null && (Object)(object)source.font != (Object)null && (Object)(object)target != (Object)null) { target.font = source.font; } } public static void CenterControl(RectTransform controlRect) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)controlRect != (Object)null) { controlRect.anchoredPosition = new Vector2(0f, controlRect.anchoredPosition.y); } } public static void SelectObject(GameObject target) { if ((Object)(object)target != (Object)null && (Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject(target); } } public static Transform RequireTransform(Transform root, string path) { Transform obj = root.Find(path); if ((Object)(object)obj == (Object)null) { throw new InvalidOperationException("Resource path not found: " + GetTransformPath(root) + "/" + path); } return obj; } public static void DisableComponent<T>(GameObject root) where T : Behaviour { T component = root.GetComponent<T>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } } private static string GetTransformPath(Transform transform) { List<string> list = new List<string>(); Transform val = transform; while ((Object)(object)val != (Object)null) { list.Add(((Object)val).name); val = val.parent; } list.Reverse(); return string.Join("/", list); } } internal sealed class PauseMenuInput : MonoBehaviour { public PauseMenuInput(IntPtr pointer) : base(pointer) { } private void Update() { PauseModSettingsController.Update(((Component)this).GetComponent<PauseMenu>()); } private void OnDestroy() { PauseMenu component = ((Component)this).GetComponent<PauseMenu>(); if ((Object)(object)component != (Object)null) { PauseModSettingsController.Remove(((Object)component).GetInstanceID()); } } } internal static class PauseModSettingsController { private sealed class PauseState { private readonly bool _usesOptionRoot; private readonly List<GameObject> _hiddenOptions = new List<GameObject>(); private readonly List<bool> _activeStates = new List<bool>(); private bool _optionRootActive; private bool _hasOptionRootState; public PauseMenu Menu { get; } public Transform OptionRoot { get; } public GameObject Button { get; } public ModSettingsPanel Panel { get; } public float Top { get; } public float Span { get; } public float NativeStep { get; } public Vector3 NativeScale { get; } public int VisibleButtonCount { get; set; } = -1; public PauseState(PauseMenu menu, Transform optionRoot, GameObject button, ModSettingsPanel panel) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) Menu = menu; OptionRoot = optionRoot; Button = button; Panel = panel; _usesOptionRoot = (Object)(object)optionRoot != (Object)(object)((Component)menu).transform; RectTransform component = ((Component)NativeUi.RequireTransform(optionRoot, "Resume Button")).GetComponent<RectTransform>(); RectTransform component2 = ((Component)NativeUi.RequireTransform(optionRoot, "Audio Button")).GetComponent<RectTransform>(); RectTransform component3 = ((Component)NativeUi.RequireTransform(optionRoot, "Quit Button")).GetComponent<RectTransform>(); RectTransform component4 = button.GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null || (Object)(object)component4 == (Object)null) { throw new InvalidOperationException("Pause menu buttons are missing RectTransform."); } Top = component.anchoredPosition.y; Span = Mathf.Abs(Top - component3.anchoredPosition.y); NativeStep = Mathf.Abs(component.anchoredPosition.y - component2.anchoredPosition.y); NativeScale = ((Transform)component4).localScale; } public void HideOptions() { if (_usesOptionRoot) { _optionRootActive = ((Component)OptionRoot).gameObject.activeSelf; _hasOptionRootState = true; ((Component)OptionRoot).gameObject.SetActive(false); return; } _hiddenOptions.Clear(); _activeStates.Clear(); for (int i = 0; i < ButtonNames.Length; i++) { Transform val = OptionRoot.Find(ButtonNames[i]); if (!((Object)(object)val == (Object)null)) { GameObject gameObject = ((Component)val).gameObject; _hiddenOptions.Add(gameObject); _activeStates.Add(gameObject.activeSelf); gameObject.SetActive(false); } } } public void RestoreOptions() { if (_usesOptionRoot) { if (_hasOptionRootState) { ((Component)OptionRoot).gameObject.SetActive(_optionRootActive); _hasOptionRootState = false; } Visi