Decompiled source of ModSettingsMenu v1.1.1
BepInEx/plugins/ModSettingsMenu.dll
Decompiled 2 days 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.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BigWalkLocalizationAPI.Api; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using ModSettingsMenu.Api; using ModSettingsMenu.Configuration; using ModSettingsMenu.Localization; using ModSettingsMenu.Runtime; using Rewired; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ModSettingsMenu")] [assembly: AssemblyDescription("Mod Settings Menu for Big Walk 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("3ac874ec-c025-43fb-a507-b958bf6bc5a7")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("1.1.1.0")] namespace ModSettingsMenu { [BepInPlugin("IceBoxStudio.BigWalk.ModSettingsMenu", "ModSettingsMenu", "1.1.1")] [BepInDependency("IceBoxStudio.BigWalk.LocalizationAPI", ">=1.1.0")] 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<ModSettingsInput>(); _harmony = new Harmony("IceBoxStudio.BigWalk.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(); } } public static class PluginInfo { public const string PLUGIN_GUID = "IceBoxStudio.BigWalk.ModSettingsMenu"; public const string PLUGIN_NAME = "ModSettingsMenu"; public const string PLUGIN_VERSION = "1.1.1"; } } namespace ModSettingsMenu.Runtime { internal sealed class ConfigRows { private readonly Transform _content; private readonly GameObject _heading; private readonly GameObject _binary; private readonly GameObject _array; private readonly GameObject _slider; private readonly GameObject _button; private readonly GameObject _keybind; private readonly KeybindCapture _capture; private readonly ConfigTextEditor _textEditor = new ConfigTextEditor(); private readonly List<GameObject> _rows = new List<GameObject>(); private readonly List<List<Selectable>> _rowSelectables = new List<List<Selectable>>(); private string _pluginGuid; private Selectable _category; private Selectable _back; private GameObject _lastSelected; public bool IsEditingText => _textEditor.IsEditing; private Selectable FirstSelectable { get { if (_rowSelectables.Count <= 0) { return null; } return _rowSelectables[0][0]; } } private Selectable LastSelectable { get { if (_rowSelectables.Count <= 0) { return null; } return _rowSelectables[_rowSelectables.Count - 1][0]; } } public ConfigRows(Transform content, GameObject heading, GameObject binary, GameObject array, GameObject slider, GameObject button, GameObject keybind, KeybindCapture capture) { _content = content; _heading = heading; _binary = binary; _array = array; _slider = slider; _button = button; _keybind = keybind; _capture = capture; } public void Build(ModConfig mod) { Clear(); _lastSelected = null; if (mod == null) { _pluginGuid = null; return; } string gUID = mod.Info.Metadata.GUID; if (!string.Equals(gUID, _pluginGuid, StringComparison.OrdinalIgnoreCase)) { _pluginGuid = gUID; } ConfigEntryBase[] array = mod.ConfigFile.Values.OrderBy((ConfigEntryBase entry) => ModSettingsOrder.GetSectionOrder(mod, entry.Definition.Section)).ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Section, StringComparer.OrdinalIgnoreCase).ThenBy((ConfigEntryBase entry) => ModSettingsOrder.GetEntryOrder(mod, entry)) .ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Key, StringComparer.OrdinalIgnoreCase) .ToArray(); string text = null; int contentSize = 0; foreach (ConfigEntryBase val in array) { if (!string.Equals(text, val.Definition.Section, StringComparison.OrdinalIgnoreCase)) { text = val.Definition.Section; CreateHeading(LocalizationApi.GetConfigSection(text, mod.ConfigFile), contentSize++); } Create(val, contentSize++); } CreateReset(mod, contentSize++); WireRows(); SetContentSize(contentSize); if ((Object)(object)_category != (Object)null || (Object)(object)_back != (Object)null) { ConnectNavigation(_category, _back); } } public void Refresh(ModConfig mod) { Build(mod); } public void EnsureSelectionVisible() { EventSystem current = EventSystem.current; GameObject val = ((current != null) ? current.currentSelectedGameObject : null); if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)_lastSelected) { return; } _lastSelected = val; for (int i = 0; i < _rowSelectables.Count; i++) { List<Selectable> list = _rowSelectables[i]; for (int j = 0; j < list.Count; j++) { if ((Object)(object)list[j] != (Object)null && (Object)(object)((Component)list[j]).gameObject == (Object)(object)val) { ScrollToRow(i); return; } } } } public bool Update() { return _textEditor.Update(); } public void CommitText() { _textEditor.Commit(); } public bool CancelText() { return _textEditor.Cancel(); } public void Scroll(float delta) { //IL_004e: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00cb: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Approximately(delta, 0f)) { return; } ScrollRect componentInParent = ((Component)_content).GetComponentInParent<ScrollRect>(); RectTransform component = ((Component)_content).GetComponent<RectTransform>(); RectTransform val = ((componentInParent != null) ? componentInParent.viewport : null); if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)component == (Object)null) && !((Object)(object)val == (Object)null) && RectTransformUtility.RectangleContainsScreenPoint(val, new Vector2(Input.mousePosition.x, Input.mousePosition.y), (Camera)null)) { Rect rect = component.rect; float height = ((Rect)(ref rect)).height; rect = val.rect; float num = Mathf.Max(0f, height - ((Rect)(ref rect)).height); if (!(num <= 0f)) { Vector2 anchoredPosition = component.anchoredPosition; anchoredPosition.y = Mathf.Clamp(anchoredPosition.y - delta * 80f, 0f, num); component.anchoredPosition = anchoredPosition; } } } private void Clear() { _textEditor.Commit(); for (int i = 0; i < _rows.Count; i++) { if ((Object)(object)_rows[i] != (Object)null) { _rows[i].SetActive(false); Object.Destroy((Object)(object)_rows[i]); } } _rows.Clear(); _rowSelectables.Clear(); } private void Create(ConfigEntryBase entry, int index) { Type settingType = entry.SettingType; ConfigDescription description = entry.Description; AcceptableValueBase acceptable = ((description != null) ? description.AcceptableValues : null); IReadOnlyList<object> values; double min; double max; if (settingType == typeof(bool)) { CreateBool(entry, index); } else if (settingType == typeof(KeyCode)) { CreateKeybind(entry, index); } else if (settingType.IsEnum || ConfigValues.TryGetAcceptableValues(acceptable, out values)) { CreateArray(entry, index); } else if (ConfigValues.TryGetNumericRange(acceptable, out min, out max) && ConfigValues.IsSliderType(settingType)) { CreateSlider(entry, index, min, max); } else { CreateInput(entry, index); } } private void CreateBool(ConfigEntryBase entry, int index) { GameObject val = New(_binary, index); Button left = ((Component)NativeUi.Require(val.transform, "GameObject/LeftOption")).GetComponent<Button>(); Button right = ((Component)NativeUi.Require(val.transform, "GameObject/RightOption")).GetComponent<Button>(); if ((Object)(object)left == (Object)null || (Object)(object)right == (Object)null) { Object.Destroy((Object)(object)val); return; } Action refresh = delegate { bool flag = (bool)entry.BoxedValue; TMP_Text componentInChildren = ((Component)left).GetComponentInChildren<TMP_Text>(true); TMP_Text componentInChildren2 = ((Component)right).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.fontStyle = (FontStyles)((!flag) ? 4 : 0); } if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.fontStyle = (FontStyles)(flag ? 4 : 0); } }; Bind(left, delegate { Set(entry, false); refresh(); }); Bind(right, delegate { Set(entry, true); refresh(); }); SetTitle(val, entry); SetButtonText(left, I18n("value.off")); SetButtonText(right, I18n("value.on")); refresh(); AddSelectables((Selectable)left, (Selectable)right); } private void CreateArray(ConfigEntryBase entry, int index) { GameObject val = New(_array, index); Button component = ((Component)NativeUi.Require(val.transform, "LeftButton")).GetComponent<Button>(); Button component2 = ((Component)NativeUi.Require(val.transform, "RightButton")).GetComponent<Button>(); TMP_Text value = ((Component)NativeUi.Require(val.transform, "Variable")).GetComponentInChildren<TMP_Text>(true); Button component3 = ((Component)NativeUi.Require(val.transform, "Variable")).GetComponent<Button>(); List<object> values = GetValues(entry); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)value == (Object)null || values.Count == 0) { Object.Destroy((Object)(object)val); return; } int selected = FindValue(values, entry.BoxedValue); Action<int> change = delegate(int valueIndex) { selected = (selected + valueIndex + values.Count) % values.Count; if (!ConfigValues.TrySetValue(entry, values[selected])) { selected = FindValue(values, entry.BoxedValue); } NativeUi.SetText(value, GetValueText(entry, values[selected])); }; Bind(component, delegate { change(-1); }); Bind(component2, delegate { change(1); }); if ((Object)(object)component3 != (Object)null) { ((Selectable)component3).interactable = false; } SetTitle(val, entry); NativeUi.SetText(value, GetValueText(entry, values[selected])); AddSelectables((Selectable)component, (Selectable)component2); } private void CreateSlider(ConfigEntryBase entry, int index, double min, double max) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown GameObject val = New(_slider, index); Slider component = ((Component)NativeUi.Require(val.transform, "Slider")).GetComponent<Slider>(); Transform obj = val.transform.Find("VariableDisplay"); TMP_Text val2 = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); return; } component.onValueChanged = new SliderEvent(); double sliderStep = ConfigValues.GetSliderStep(entry.SettingType, min, max, ModSettingsOrder.GetSliderStep(entry)); float sliderStepCount = ConfigValues.GetSliderStepCount(min, max, sliderStep); component.minValue = 0f; component.maxValue = sliderStepCount; component.wholeNumbers = true; component.SetValueWithoutNotify(ConfigValues.GetSliderStepIndex(entry.BoxedValue, min, max, sliderStep, sliderStepCount)); BindSlider(component, val2, entry, min, max, sliderStep, sliderStepCount); SetTitle(val, entry); NativeUi.SetText(val2, ConfigValues.FormatValue(entry.BoxedValue)); AddSelectables((Selectable)component); } private void CreateKeybind(ConfigEntryBase entry, int index) { GameObject val = New(_keybind, index); Transform val2 = val.transform.Find("LobbyButton_Underline"); Button button = ((val2 != null) ? ((Component)val2).GetComponent<Button>() : null); Button obj = button; TMP_Text val3 = ((obj != null) ? ((Component)obj).GetComponentInChildren<TMP_Text>(true) : null); Transform obj2 = val.transform.Find("statusLabel"); TMP_Text status = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)button == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)status == (Object)null) { Object.Destroy((Object)(object)val); return; } string text = SplitName(LocalizationApi.GetConfigDisplayName(entry)); Bind(button, delegate { _capture.Begin(entry, button, status); }); NativeUi.SetText(val3, text); NativeUi.SetText(status, KeybindCapture.Format(entry.BoxedValue, status)); AddSelectables((Selectable)button); } private void CreateReset(ModConfig mod, int index) { GameObject val = New(_button, index); Transform obj = val.transform.Find("LobbyButton_Underline"); Button val2 = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null); if ((Object)(object)val2 == (Object)null) { Object.Destroy((Object)(object)val); return; } Bind(val2, delegate { _capture.Cancel(); _textEditor.Commit(); if (ConfigValues.TryReset(mod.ConfigFile)) { Build(mod); Selectable lastSelectable = LastSelectable; NativeUi.Select((lastSelectable != null) ? ((Component)lastSelectable).gameObject : null); } }); AddSelectables((Selectable)val2); } private void CreateInput(ConfigEntryBase entry, int index) { GameObject val = New(_array, index, active: false); Transform val2 = val.transform.Find("LeftButton"); Transform val3 = val.transform.Find("RightButton"); Transform obj = val.transform.Find("Variable"); Button val4 = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null); TMP_Text val5 = ((obj != null) ? ((Component)obj).GetComponentInChildren<TMP_Text>(true) : null); if ((Object)(object)obj == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) { Object.Destroy((Object)(object)val); return; } if (val2 != null) { ((Component)val2).gameObject.SetActive(false); } if (val3 != null) { ((Component)val3).gameObject.SetActive(false); } SetTitle(val, entry); Button val6 = _textEditor.Create(entry, val4, val5); if ((Object)(object)val6 == (Object)null) { Object.Destroy((Object)(object)val); return; } val.SetActive(true); NativeUi.SetText(val5, entry.GetSerializedValue() ?? string.Empty); AddSelectables((Selectable)val6); } private void CreateHeading(string text, int index) { GameObject obj = New(_heading, index); Transform val = obj.transform.Find("LeftButton"); Transform val2 = obj.transform.Find("RightButton"); Transform val3 = obj.transform.Find("Variable"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(false); } TMP_Text val4 = NativeUi.SetRowTitle(obj, SplitName(text)); if ((Object)(object)val4 != (Object)null) { val4.fontStyle = (FontStyles)1; val4.enableAutoSizing = false; val4.fontSize = Mathf.Max(32f, val4.fontSize * 1.5f); } } private GameObject New(GameObject source, int index, bool active = true) { //IL_006c: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(source, _content); ((Object)val).name = "Mod Setting " + index.ToString(CultureInfo.InvariantCulture); NativeUi.DisableNativeScripts(val); if (active) { val.SetActive(true); } RectTransform component = val.GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { RectTransform component2 = _button.GetComponent<RectTransform>(); Rect rect; float width; if (component2 == null) { rect = component.rect; width = ((Rect)(ref rect)).width; } else { rect = component2.rect; width = ((Rect)(ref rect)).width; } if ((Object)(object)source == (Object)(object)_keybind) { component.sizeDelta = new Vector2(component.sizeDelta.x, 130f); } float num = width * 0.5f; float num2 = component.pivot.x - 0.5f; rect = component.rect; float num3 = num + num2 * ((Rect)(ref rect)).width; float num4 = -65f - (float)index * 130f; float num5 = component.pivot.y - 0.5f; rect = component.rect; float num6 = num4 + num5 * ((Rect)(ref rect)).height; component.anchoredPosition = new Vector2(num3, num6); } _rows.Add(val); return val; } private void SetContentSize(int rowCount) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) RectTransform component = ((Component)_content).GetComponent<RectTransform>(); if (!((Object)(object)component == (Object)null)) { component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(0f, (float)rowCount * 130f); ScrollRect componentInParent = ((Component)_content).GetComponentInParent<ScrollRect>(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.verticalNormalizedPosition = 1f; } } } private void ScrollToRow(int selectableRow) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) ScrollRect componentInParent = ((Component)_content).GetComponentInParent<ScrollRect>(); RectTransform component = ((Component)_content).GetComponent<RectTransform>(); RectTransform val = ((componentInParent != null) ? componentInParent.viewport : null); if ((Object)(object)componentInParent == (Object)null || (Object)(object)component == (Object)null || (Object)(object)val == (Object)null) { return; } Selectable obj = _rowSelectables[selectableRow][0]; Transform val2 = ((obj != null) ? ((Component)obj).transform : null); while ((Object)(object)val2 != (Object)null && (Object)(object)val2.parent != (Object)(object)_content) { val2 = val2.parent; } RectTransform val3 = ((val2 != null) ? ((Component)val2).GetComponent<RectTransform>() : null); if (!((Object)(object)val3 == (Object)null)) { float num = 0f - val3.anchoredPosition.y; Rect rect = val3.rect; float num2 = num - ((Rect)(ref rect)).height * 0.5f; rect = val3.rect; float num3 = num2 + ((Rect)(ref rect)).height; float num4 = component.anchoredPosition.y; rect = val.rect; float height = ((Rect)(ref rect)).height; if (num2 < num4) { num4 = num2; } else if (num3 > num4 + height) { num4 = num3 - height; } rect = component.rect; float num5 = Mathf.Max(0f, ((Rect)(ref rect)).height - height); component.anchoredPosition = new Vector2(component.anchoredPosition.x, Mathf.Clamp(num4, 0f, num5)); } } private static List<object> GetValues(ConfigEntryBase entry) { if (entry.SettingType.IsEnum) { return Enum.GetValues(entry.SettingType).Cast<object>().ToList(); } ConfigDescription description = entry.Description; if (!ConfigValues.TryGetAcceptableValues((description != null) ? description.AcceptableValues : null, out var values)) { return new List<object>(); } return values.ToList(); } private static int FindValue(IReadOnlyList<object> values, object current) { for (int i = 0; i < values.Count; i++) { if (object.Equals(values[i], current)) { return i; } } return 0; } private void Set(ConfigEntryBase entry, object value) { ConfigValues.TrySetValue(entry, value); } public void ConnectNavigation(Selectable category, Selectable back) { _category = category; _back = back; Selectable firstSelectable = FirstSelectable; Selectable lastSelectable = LastSelectable; if ((Object)(object)category != (Object)null) { Navigation navigation = category.navigation; NativeUi.SetNavigation(category, navigation.selectOnUp, navigation.selectOnDown, navigation.selectOnLeft, firstSelectable); } for (int i = 0; i < _rowSelectables.Count; i++) { List<Selectable> list = _rowSelectables[i]; Selectable up = ((i > 0) ? _rowSelectables[i - 1][0] : category); Selectable down = ((i + 1 < _rowSelectables.Count) ? _rowSelectables[i + 1][0] : back); for (int j = 0; j < list.Count; j++) { NativeUi.SetNavigation(list[j], up, down, (j > 0) ? list[j - 1] : category, (j + 1 < list.Count) ? list[j + 1] : null); } } if ((Object)(object)back != (Object)null) { Navigation navigation2 = back.navigation; NativeUi.SetNavigation(back, lastSelectable, navigation2.selectOnDown, lastSelectable, navigation2.selectOnRight); } } private void AddSelectables(params Selectable[] selectables) { _rowSelectables.Add(selectables.Where((Selectable selectable) => (Object)(object)selectable != (Object)null).ToList()); } private void WireRows() { for (int num = _rowSelectables.Count - 1; num >= 0; num--) { if (_rowSelectables[num].Count == 0) { _rowSelectables.RemoveAt(num); } } } private void Bind(Button button, Action action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action)); } private void BindSlider(Slider slider, TMP_Text value, ConfigEntryBase entry, double min, double max, double step, float stepCount) { ((UnityEvent<float>)(object)slider.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<float>>((Delegate)(Action<float>)delegate(float raw) { object value2 = ConfigValues.ConvertSliderValue(raw, min, max, step, stepCount, entry.SettingType); ConfigValues.TrySetValue(entry, value2); slider.SetValueWithoutNotify(ConfigValues.GetSliderStepIndex(entry.BoxedValue, min, max, step, stepCount)); NativeUi.SetText(value, ConfigValues.FormatValue(entry.BoxedValue)); })); } private static void SetButtonText(Button button, string text) { NativeUi.SetText((button != null) ? ((Component)button).gameObject : null, text); } private static void SetTitle(GameObject row, ConfigEntryBase entry) { NativeUi.SetRowTitle(row, SplitName(LocalizationApi.GetConfigDisplayName(entry))); } private static string GetValueText(ConfigEntryBase entry, object value) { string result = default(string); if (!LocalizationApi.TryGetConfigDisplayValue(entry, value, ref result)) { return ConfigValues.FormatValue(value); } return result; } private static string SplitName(string text) { if (string.IsNullOrWhiteSpace(text)) { return text; } return Regex.Replace(text.Replace('_', ' ').Replace('-', ' '), "(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])", " "); } private static string I18n(string key, params object[] args) { return global::ModSettingsMenu.Localization.I18n.Text(key, args); } } internal sealed class ConfigTextEditor { private sealed class Binding { public ConfigEntryBase Entry; public Button Button; public TMP_Text Display; public GameObject InputObject; public TMP_InputField Field; } private Binding _active; private string _original; private bool _restoring; private bool _dragStartedInside; private bool _dragMovedOutside; private int _dragGraceFrames; public bool IsEditing => _active != null; public Button Create(ConfigEntryBase entry, Button button, TMP_Text text) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown if (entry == null || (Object)(object)button == (Object)null || (Object)(object)text == (Object)null) { return null; } CanvasGroup component = ((Component)button).GetComponent<CanvasGroup>(); if ((Object)(object)component != (Object)null) { component.interactable = true; component.blocksRaycasts = true; } ((Selectable)button).interactable = true; ((Graphic)text).raycastTarget = true; if ((Object)(object)((Selectable)button).targetGraphic != (Object)null) { ((Selectable)button).targetGraphic.raycastTarget = true; } RectTransform component2 = ((Component)button).GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { component2.sizeDelta = new Vector2(760f, component2.sizeDelta.y); } TMP_InputField field; GameObject val = CreateInputObject(((Component)button).gameObject, text, out field); if ((Object)(object)val == (Object)null || (Object)(object)field == (Object)null) { return null; } field.SetTextWithoutNotify(entry.GetSerializedValue() ?? string.Empty); ((Selectable)field).interactable = false; val.SetActive(false); Binding binding = new Binding { Entry = entry, Button = button, Display = text, InputObject = val, Field = field }; button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate { Begin(binding); })); field.onValueChanged = new OnChangeEvent(); ((UnityEvent<string>)(object)field.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)(Action<string>)delegate(string value) { Change(binding, value); })); field.onEndEdit = new SubmitEvent(); ((UnityEvent<string>)(object)field.onEndEdit).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)(Action<string>)delegate(string value) { End(binding, value); })); return button; } private static GameObject CreateInputObject(GameObject parent, TMP_Text display, out TMP_InputField field) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_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_01aa: Unknown result type (might be due to invalid IL or missing references) field = null; if ((Object)(object)parent == (Object)null || (Object)(object)display == (Object)null) { return null; } GameObject val = new GameObject("Text Input", new Il2CppReferenceArray<Type>((Type[])(object)new Type[3] { Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<RectTransform>.NativeClassPtr)), Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<Image>.NativeClassPtr)), Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<TMP_InputField>.NativeClassPtr)) })); val.transform.SetParent(parent.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; ((Transform)component).localScale = Vector3.one; Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = new Color(1f, 1f, 1f, 0f); ((Graphic)component2).raycastTarget = true; RectTransform val2 = CreateViewport(val.transform); if ((Object)(object)val2 == (Object)null) { Object.Destroy((Object)(object)val); return null; } GameObject val3 = Object.Instantiate<GameObject>(((Component)display).gameObject, (Transform)(object)val2); if ((Object)(object)val3 == (Object)null) { Object.Destroy((Object)(object)val); return null; } LocalizedText component3 = val3.GetComponent<LocalizedText>(); if ((Object)(object)component3 != (Object)null) { Object.DestroyImmediate((Object)(object)component3); } TMP_Text val4 = val3.GetComponent<TMP_Text>(); if ((Object)(object)val4 == (Object)null) { val4 = val3.GetComponentInChildren<TMP_Text>(true); } RectTransform val5 = ((val4 != null) ? ((Component)val4).GetComponent<RectTransform>() : null); if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) { Object.Destroy((Object)(object)val); return null; } ((Object)val3).name = "Text Input Value"; val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = Vector2.zero; val5.offsetMax = Vector2.zero; val4.enableWordWrapping = false; val4.overflowMode = (TextOverflowModes)0; ((Graphic)val4).raycastTarget = false; field = val.GetComponent<TMP_InputField>(); ((Selectable)field).targetGraphic = (Graphic)(object)component2; field.textViewport = val2; field.textComponent = val4; field.contentType = (ContentType)0; field.lineType = (LineType)0; field.characterLimit = 0; field.readOnly = false; field.richText = false; field.shouldActivateOnSelect = false; field.shouldHideMobileInput = true; field.shouldHideSoftKeyboard = true; field.onFocusSelectAll = false; field.restoreOriginalTextOnEscape = true; return val; } private static RectTransform CreateViewport(Transform root) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) if ((Object)(object)root == (Object)null) { return null; } GameObject val = new GameObject("Text Viewport", new Il2CppReferenceArray<Type>((Type[])(object)new Type[2] { Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<RectTransform>.NativeClassPtr)), Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<RectMask2D>.NativeClassPtr)) })); val.transform.SetParent(root, false); RectTransform component = val.GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); return null; } component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = new Vector2(10f, 0f); component.offsetMax = new Vector2(-10f, 0f); ((Transform)component).localScale = Vector3.one; return component; } public bool Update() { //IL_0047: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00c4: Unknown result type (might be due to invalid IL or missing references) if (_active == null) { return false; } if (Input.GetKeyDown((KeyCode)27)) { Cancel(); return true; } if (Input.GetMouseButtonDown(0)) { GameObject inputObject = _active.InputObject; RectTransform val = ((inputObject != null) ? inputObject.GetComponent<RectTransform>() : null); _dragStartedInside = (Object)(object)val != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(val, new Vector2(Input.mousePosition.x, Input.mousePosition.y), (Camera)null); _dragMovedOutside = false; _dragGraceFrames = 0; } else if (_dragStartedInside && Input.GetMouseButton(0)) { GameObject inputObject2 = _active.InputObject; RectTransform val2 = ((inputObject2 != null) ? inputObject2.GetComponent<RectTransform>() : null); if ((Object)(object)val2 != (Object)null && !RectTransformUtility.RectangleContainsScreenPoint(val2, new Vector2(Input.mousePosition.x, Input.mousePosition.y), (Camera)null)) { _dragMovedOutside = true; } } if (Input.GetMouseButtonUp(0) && _dragStartedInside && _dragMovedOutside) { _dragGraceFrames = 2; } else if (!Input.GetMouseButton(0) && _dragGraceFrames > 0) { _dragGraceFrames--; } return false; } public void Commit() { if (_active != null) { Binding active = _active; _active = null; _original = null; _dragStartedInside = false; _dragMovedOutside = false; _dragGraceFrames = 0; TMP_InputField field = active.Field; Save(active, (field != null) ? field.text : null); TMP_InputField field2 = active.Field; if (field2 != null) { field2.DeactivateInputField(false); } SetEditing(active, editing: false); } } public bool Cancel() { if (_active == null) { return false; } Binding active = _active; string text = _original ?? string.Empty; _active = null; _original = null; _dragStartedInside = false; _dragMovedOutside = false; _dragGraceFrames = 0; _restoring = true; TMP_InputField field = active.Field; if (field != null) { field.SetTextWithoutNotify(text); } Save(active, text); TMP_InputField field2 = active.Field; if (field2 != null) { field2.DeactivateInputField(false); } SetEditing(active, editing: false); _restoring = false; return true; } private void Begin(Binding binding) { if (binding != null && _active != binding) { Commit(); _active = binding; _original = binding.Entry.GetSerializedValue() ?? string.Empty; _dragStartedInside = false; _dragMovedOutside = false; _dragGraceFrames = 0; binding.Field.SetTextWithoutNotify(_original); SetEditing(binding, editing: true); NativeUi.Select(((Component)binding.Field).gameObject); binding.Field.ActivateInputField(); binding.Field.MoveTextEnd(false); } } private void Change(Binding binding, string value) { if (!_restoring) { Save(binding, value); NativeUi.SetText(binding.Display, value); } } private void End(Binding binding, string value) { if (_restoring) { return; } TMP_InputField field = binding.Field; if (field != null && field.wasCanceled) { Cancel(); return; } Save(binding, value); NativeUi.SetText(binding.Display, value); bool flag = Input.GetKey((KeyCode)13) || Input.GetKey((KeyCode)271); bool flag2 = Input.GetMouseButtonDown(0) && !IsPointerInside(binding); bool flag3 = _active == binding && _dragStartedInside && (Input.GetMouseButton(0) || Input.GetMouseButtonUp(0)) && !Input.GetMouseButtonDown(0); if (_active == binding && !flag && !flag2 && (flag3 || _dragMovedOutside || _dragGraceFrames > 0)) { _dragMovedOutside = false; _dragGraceFrames = 2; NativeUi.Select(((Component)binding.Field).gameObject); binding.Field.ActivateInputField(); return; } if (_active == binding) { _active = null; _original = null; _dragStartedInside = false; _dragMovedOutside = false; _dragGraceFrames = 0; } SetEditing(binding, editing: false); } private static bool IsPointerInside(Binding binding) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) object obj; if (binding == null) { obj = null; } else { GameObject inputObject = binding.InputObject; obj = ((inputObject != null) ? inputObject.GetComponent<RectTransform>() : null); } RectTransform val = (RectTransform)obj; if ((Object)(object)val != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(val, new Vector2(Input.mousePosition.x, Input.mousePosition.y), (Camera)null); } return false; } private static void SetEditing(Binding binding, bool editing) { if ((Object)(object)binding?.Button != (Object)null) { ((Selectable)binding.Button).interactable = !editing; } if ((Object)(object)binding?.Display != (Object)null) { ((Component)binding.Display).gameObject.SetActive(!editing); } if ((Object)(object)binding?.InputObject != (Object)null) { binding.InputObject.SetActive(editing); } if ((Object)(object)binding?.Field != (Object)null) { ((Selectable)binding.Field).interactable = editing; } } private static void Save(Binding binding, string value) { if (binding != null && binding.Entry != null) { ConfigValues.TrySetSerializedValue(binding.Entry, value ?? string.Empty); } } } internal sealed class KeybindCapture { private ConfigEntryBase _entry; private TMP_Text _text; public bool IsActive => _entry != null; public void Begin(ConfigEntryBase entry, Button button, TMP_Text text) { _entry = entry; _text = text; NativeUi.SetText(_text, I18nText("menu.press_key")); NativeUi.Select((button != null) ? ((Component)button).gameObject : null); } public void Capture() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (_entry == null) { return; } if (Input.GetKeyDown((KeyCode)27)) { Cancel(); return; } Array values = Enum.GetValues(typeof(KeyCode)); for (int i = 0; i < values.Length; i++) { KeyCode val = (KeyCode)values.GetValue(i); if ((int)val != 0 && Input.GetKeyDown(val)) { Finish(val); break; } } } public void Cancel() { if (_entry != null) { NativeUi.SetText(_text, Format(_entry.BoxedValue, _text)); Clear(); } } public void Clear() { _entry = null; _text = null; } public static string Format(object value, TMP_Text text = null) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!(value is KeyCode key)) { return ConfigValues.FormatValue(value); } return FormatKey(key, text); } private void Finish(KeyCode key) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!ConfigValues.TrySetValue(_entry, key)) { key = (KeyCode)_entry.BoxedValue; } NativeUi.SetText(_text, Format(key, _text)); Clear(); } private static string FormatKey(KeyCode key, TMP_Text text) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) try { DevSettings currentSettings = DevSettings.currentSettings; ControllerGlyphSet val = ((currentSettings != null) ? currentSettings.controllerGlyphSet : null); if ((Object)(object)val != (Object)null) { GlyphText glyph = GetGlyph(val, key); if (glyph != null && !string.IsNullOrWhiteSpace(glyph.glyphString)) { LocalizedText obj = ((text != null) ? ((Component)text).GetComponent<LocalizedText>() : null); MaterialType val2 = (MaterialType)((obj == null) ? 1 : ((int)obj.materialType)); return val.WrapInTags(glyph, val2); } } } catch { } return GetFallbackText(key); } private static GlyphText GetGlyph(ControllerGlyphSet glyphs, KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) switch (key - 323) { case 0: return glyphs.GetMouseGlyphForElementName("Button 0"); case 1: return glyphs.GetMouseGlyphForElementName("Button 1"); case 2: return glyphs.GetMouseGlyphForElementName("Button 2"); default: if ((int)key > 319) { return null; } return glyphs.GetKeyboardGlyphForKeyCode((KeyboardKeyCode)key); } } private unsafe static string GetFallbackText(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected I4, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected I4, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if ((int)key <= 271) { if ((int)key == 13 || (int)key == 271) { return "Enter"; } } else { switch (key - 303) { default: switch (key - 323) { case 0: return "Mouse 1"; case 1: return "Mouse 2"; case 2: return "Mouse 3"; } break; case 2: case 3: return "Ctrl"; case 0: case 1: return "Shift"; case 4: case 5: case 10: return "Alt"; case 6: case 7: case 8: case 9: break; } } string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); if (!text.StartsWith("Alpha", StringComparison.Ordinal)) { return text; } return text.Substring("Alpha".Length); } private static string I18nText(string key) { return I18n.Text(key); } } internal sealed class ModSettingsInput : MonoBehaviour { public ModSettingsInput(IntPtr pointer) : base(pointer) { } private void Update() { ModSettingsMenuController.Update(); } } public static class ModSettingsMenuController { private static TitleMenu _titleMenu; private static GameObject _titleButton; private static ModSettingsPanel _mainPanel; private static WorldMenuManager _worldMenu; private static GameObject _hostButton; private static GameObject _clientButton; private static ModSettingsPanel _pausePanel; private static GameObject _pauseRoot; private static int _handledPauseBackFrame = -1; private static int _handledTextBackFrame = -1; private static int _lastUpdateFrame = -1; private static string _lastLanguage; public static void TryCreate(TitleMenu menu) { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown try { if (!((Object)(object)menu == (Object)null) && (!((Object)(object)_titleButton != (Object)null) || !((Object)(object)_titleMenu == (Object)(object)menu))) { ResetMainMenu(); Transform val = ((Component)menu).transform.Find("StartButtons"); if ((Object)(object)val == (Object)null && (Object)(object)((Component)menu).transform.parent != (Object)null) { val = ((Component)menu).transform.parent.Find("TitleMenu/StartButtons"); } if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("Main menu StartButtons was not found."); } Transform val2 = NativeUi.Require(val, "SettingsButton"); MainMenuManager instance = MainMenuManager.instance; SettingsMenu val3 = ((instance != null) ? instance.settingsMenu : null); if (!((Object)(object)val3 == (Object)null)) { _titleMenu = menu; _mainPanel = ModSettingsPanel.Create(val3, ((Component)val3).transform.parent, CloseMainMenu); AttachInput(((Component)menu).gameObject); AttachInput(((Component)val3).gameObject); _titleButton = CreateEntry(((Component)val2).gameObject, val, OpenMainMenu); ((Object)_titleButton).name = "ModSettingsButton"; LayoutMainButtons(val); RefreshLocalizedText(); } } } catch (Exception ex) { ManualLogSource logger = ModSettingsMenu.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(51, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Failed to create the main menu mod settings entry: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex); } logger.LogError(val4); ResetMainMenu(); } } public static void TryCreate(WorldMenuManager menu) { //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown try { if ((Object)(object)menu == (Object)null || (_pausePanel != null && (Object)(object)_worldMenu == (Object)(object)menu)) { return; } ResetPauseMenu(); SettingsMenu settingsMenu = menu.settingsMenu; if (!((Object)(object)settingsMenu == (Object)null) && !((Object)(object)menu.pauseMenuHost == (Object)null) && !((Object)(object)menu.pauseMenuClient == (Object)null)) { Transform val = NativeUi.Require(((Component)menu.pauseMenuHost).transform, "LayoutContainer/Settings"); Transform val2 = NativeUi.Require(((Component)menu.pauseMenuClient).transform, "LayoutContainer/Settings"); _worldMenu = menu; _pausePanel = ModSettingsPanel.Create(settingsMenu, ((Component)settingsMenu).transform.parent, ClosePauseMenu); AttachInput(((Component)menu).gameObject); AttachInput(((Component)settingsMenu).gameObject); _hostButton = CreateEntry(((Component)val).gameObject, val.parent, delegate { OpenPauseMenu(menu.pauseMenuHost); }); _clientButton = CreateEntry(((Component)val2).gameObject, val2.parent, delegate { OpenPauseMenu(menu.pauseMenuClient); }); ((Object)_hostButton).name = "ModSettings"; ((Object)_clientButton).name = "ModSettings"; LayoutPauseButtons(val.parent); LayoutPauseButtons(val2.parent); RefreshLocalizedText(); } } catch (Exception ex) { ManualLogSource logger = ModSettingsMenu.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(52, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to create the pause menu mod settings entry: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex); } logger.LogError(val3); ResetPauseMenu(); } } public static void Update() { if (_lastUpdateFrame == Time.frameCount) { return; } _lastUpdateFrame = Time.frameCount; if (!string.Equals(LocalizationApi.CurrentLanguage, _lastLanguage, StringComparison.OrdinalIgnoreCase)) { RefreshLocalizedText(); } ModSettingsPanel mainPanel = _mainPanel; ModSettingsPanel modSettingsPanel = ((mainPanel != null && mainPanel.IsOpen) ? _mainPanel : _pausePanel); if (modSettingsPanel == null || !modSettingsPanel.IsOpen) { return; } if (modSettingsPanel.Update()) { _handledTextBackFrame = Time.frameCount; if (modSettingsPanel == _pausePanel) { _handledPauseBackFrame = Time.frameCount; } } else { if (_handledTextBackFrame == Time.frameCount) { return; } if (modSettingsPanel.IsCapturingKeybind) { modSettingsPanel.CaptureInput(); if (modSettingsPanel == _pausePanel && Input.GetKeyDown((KeyCode)27)) { _handledPauseBackFrame = Time.frameCount; } } else if (modSettingsPanel == _mainPanel && Input.GetKeyDown((KeyCode)27)) { CloseMainMenu(); } else if (modSettingsPanel == _pausePanel && Input.GetKeyDown((KeyCode)27) && _handledPauseBackFrame != Time.frameCount) { _handledPauseBackFrame = Time.frameCount; ClosePauseMenu(); } } } public static bool HandleSettingsBack(SettingsMenu menu) { if ((Object)(object)menu == (Object)null) { return false; } if (_handledTextBackFrame == Time.frameCount) { return true; } ModSettingsPanel mainPanel = _mainPanel; if (mainPanel != null && mainPanel.IsOpen) { if (_mainPanel.CancelTextEdit()) { _handledTextBackFrame = Time.frameCount; return true; } CloseMainMenu(); return true; } ModSettingsPanel pausePanel = _pausePanel; if (pausePanel != null && pausePanel.IsOpen) { if (_pausePanel.CancelTextEdit()) { _handledTextBackFrame = Time.frameCount; _handledPauseBackFrame = Time.frameCount; return true; } ClosePauseMenu(); return true; } return false; } public static void RefreshLocalizedText() { if (_mainPanel != null && !_mainPanel.IsAlive) { _mainPanel = null; _titleMenu = null; _titleButton = null; } if (_pausePanel != null && !_pausePanel.IsAlive) { _pausePanel = null; _worldMenu = null; _hostButton = null; _clientButton = null; _pauseRoot = null; } NativeUi.SetText(_titleButton, I18n.Text("menu.mod_settings")); NativeUi.SetText(_hostButton, I18n.Text("menu.mod_settings")); NativeUi.SetText(_clientButton, I18n.Text("menu.mod_settings")); _mainPanel?.RefreshLocalizedText(); _pausePanel?.RefreshLocalizedText(); _lastLanguage = LocalizationApi.CurrentLanguage; } private static void AttachInput(GameObject root) { if ((Object)(object)root != (Object)null && (Object)(object)root.GetComponent<ModSettingsInput>() == (Object)null) { root.AddComponent<ModSettingsInput>(); } } private static GameObject CreateEntry(GameObject source, Transform parent, Action open) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(source, parent); NativeUi.ResetManagedButtons(val); Button component = val.GetComponent<Button>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Native settings entry is missing Button."); } component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)open)); val.transform.SetSiblingIndex(source.transform.GetSiblingIndex() + 1); return val; } private static void OpenMainMenu() { if (_mainPanel != null && !((Object)(object)_titleMenu == (Object)null)) { ((Component)_titleMenu).gameObject.SetActive(false); _mainPanel.Show(); } } private static void CloseMainMenu() { if (_mainPanel != null && !((Object)(object)_titleMenu == (Object)null)) { _mainPanel.Hide(); ((Component)_titleMenu).gameObject.SetActive(true); NativeUi.Select(_titleButton); } } private static void OpenPauseMenu(PauseMenu menu) { if (_pausePanel != null && !((Object)(object)menu == (Object)null)) { _pauseRoot = ((Component)menu).gameObject; _pauseRoot.SetActive(false); _pausePanel.Show(); } } private static void ClosePauseMenu() { if (_pausePanel == null) { return; } _pausePanel.Hide(); if ((Object)(object)_pauseRoot != (Object)null) { _pauseRoot.SetActive(true); GameObject pauseRoot = _pauseRoot; WorldMenuManager worldMenu = _worldMenu; object obj; if (worldMenu == null) { obj = null; } else { PauseMenu pauseMenuHost = worldMenu.pauseMenuHost; obj = ((pauseMenuHost != null) ? ((Component)pauseMenuHost).gameObject : null); } NativeUi.Select(((Object)(object)pauseRoot == (Object)obj) ? _hostButton : _clientButton); } } private static void LayoutMainButtons(Transform parent) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) List<RectTransform> list = new List<RectTransform>(); for (int i = 0; i < parent.childCount; i++) { RectTransform component = ((Component)parent.GetChild(i)).GetComponent<RectTransform>(); Button component2 = ((Component)parent.GetChild(i)).GetComponent<Button>(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null && ((Component)parent.GetChild(i)).gameObject.activeSelf) { list.Add(component); } } list.Sort((RectTransform left, RectTransform right) => right.anchoredPosition.y.CompareTo(left.anchoredPosition.y)); if (list.Count >= 2) { VerticalLayoutGroup component3 = ((Component)parent).GetComponent<VerticalLayoutGroup>(); if ((Object)(object)component3 != (Object)null) { ((Behaviour)component3).enabled = false; } float num = 352f / (float)(list.Count - 1); float num2 = Mathf.Abs(list[0].anchoredPosition.y - list[1].anchoredPosition.y); float num3 = ((num2 > 0f) ? Mathf.Min(1f, num / num2) : 1f); RectTransform component4 = ((Component)parent).GetComponent<RectTransform>(); if ((Object)(object)component4 != (Object)null) { component4.sizeDelta = new Vector2(component4.sizeDelta.x, Mathf.Max(component4.sizeDelta.y, Mathf.Abs(-352f) + 80f)); } for (int num4 = 0; num4 < list.Count; num4++) { list[num4].anchoredPosition = new Vector2(list[num4].anchoredPosition.x, -55.15f - num * (float)num4); ((Transform)list[num4]).localScale = new Vector3(num3, num3, num3); Button component5 = ((Component)list[num4]).GetComponent<Button>(); Button up = ((num4 > 0) ? ((Component)list[num4 - 1]).GetComponent<Button>() : null); Button down = ((num4 + 1 < list.Count) ? ((Component)list[num4 + 1]).GetComponent<Button>() : null); NativeUi.SetNavigation((Selectable)(object)component5, (Selectable)(object)up, (Selectable)(object)down, null, null); } } } private static void LayoutPauseButtons(Transform parent) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) List<RectTransform> list = new List<RectTransform>(); for (int i = 0; i < parent.childCount; i++) { RectTransform component = ((Component)parent.GetChild(i)).GetComponent<RectTransform>(); Button component2 = ((Component)parent.GetChild(i)).GetComponent<Button>(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null && ((Component)component2).gameObject.activeSelf) { list.Add(component); } } if (list.Count >= 2) { VerticalLayoutGroup component3 = ((Component)parent).GetComponent<VerticalLayoutGroup>(); if ((Object)(object)component3 != (Object)null) { ((Behaviour)component3).enabled = false; } float num = 228f / (float)(list.Count - 1); float num2 = Mathf.Min(1f, num / 76f); for (int j = 0; j < list.Count; j++) { list[j].anchoredPosition = new Vector2(list[j].anchoredPosition.x, -38f - num * (float)j); ((Transform)list[j]).localScale = new Vector3(num2, num2, num2); Button component4 = ((Component)list[j]).GetComponent<Button>(); Button up = ((j > 0) ? ((Component)list[j - 1]).GetComponent<Button>() : null); Button down = ((j + 1 < list.Count) ? ((Component)list[j + 1]).GetComponent<Button>() : null); NativeUi.SetNavigation((Selectable)(object)component4, (Selectable)(object)up, (Selectable)(object)down, null, null); } LayoutRebuilder.ForceRebuildLayoutImmediate(((Component)parent).GetComponent<RectTransform>()); } } public static bool HandleWorldMenuClose() { if (_handledPauseBackFrame == Time.frameCount) { return true; } ModSettingsPanel pausePanel = _pausePanel; if (pausePanel == null || !pausePanel.IsOpen) { return false; } _handledPauseBackFrame = Time.frameCount; if (_pausePanel.CancelTextEdit()) { _handledTextBackFrame = Time.frameCount; return true; } if (_pausePanel.IsCapturingKeybind) { _pausePanel.CaptureInput(); } else { ClosePauseMenu(); } return true; } private static void ResetMainMenu() { _titleMenu = null; _titleButton = null; _mainPanel = null; _lastLanguage = null; _handledTextBackFrame = -1; } private static void ResetPauseMenu() { _worldMenu = null; _hostButton = null; _clientButton = null; _pausePanel = null; _pauseRoot = null; _handledPauseBackFrame = -1; _handledTextBackFrame = -1; _lastLanguage = null; } } internal sealed class ModSettingsPanel { private sealed class CategoryItem { public string Text { get; } public Action Action { get; } public string Guid { get; } public CategoryItem(string text, Action action, string guid = null) { Text = text; Action = action; Guid = guid; } } private const int CategoryCapacity = 9; private readonly GameObject _panel; private readonly GameObject _backObject; private readonly TMP_Text _title; private readonly TMP_Text _version; private readonly TMP_Text _author; private readonly TMP_Text _description; private readonly GameObject _nexusObject; private readonly GameObject _thunderstoreObject; private readonly List<Button> _categories; private readonly ConfigRows _rows; private readonly KeybindCapture _capture; private readonly string[] _categoryGuids = new string[9]; private IReadOnlyList<ModConfig> _mods = Array.Empty<ModConfig>(); private string _selectedGuid; private int _page; public bool IsOpen { get { if ((Object)(object)_panel != (Object)null) { return _panel.activeSelf; } return false; } } public bool IsAlive => (Object)(object)_panel != (Object)null; public bool IsCapturingKeybind => _capture.IsActive; public bool IsEditingText => _rows.IsEditingText; private ModSettingsPanel(GameObject panel, GameObject backObject, TMP_Text title, TMP_Text version, TMP_Text author, TMP_Text description, GameObject nexusObject, GameObject thunderstoreObject, List<Button> categories, ConfigRows rows, KeybindCapture capture) { _panel = panel; _backObject = backObject; _title = title; _version = version; _author = author; _description = description; _nexusObject = nexusObject; _thunderstoreObject = thunderstoreObject; _categories = categories; _rows = rows; _capture = capture; } public static ModSettingsPanel Create(SettingsMenu source, Transform parent, Action close) { //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null || (Object)(object)parent == (Object)null || close == null) { throw new ArgumentNullException(); } GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, parent); ((Object)val).name = "ModSettingsMenu"; val.SetActive(false); DisableNativeBehaviour(val); Transform root = NativeUi.Require(val.transform, "SettingsMenuContents"); Transform val2 = NativeUi.Require(root, "Right"); Transform val3 = NativeUi.Require(root, "Left"); Transform val4 = NativeUi.Require(root, "Centre"); GameObject gameObject = ((Component)NativeUi.Require(val4, "General")).gameObject; GameObject gameObject2 = ((Component)NativeUi.Require(val4, "Audio")).gameObject; for (int i = 0; i < val4.childCount; i++) { GameObject gameObject3 = ((Component)val4.GetChild(i)).gameObject; gameObject3.SetActive((Object)(object)gameObject3 == (Object)(object)gameObject); } gameObject.SetActive(true); GameObject gameObject4 = ((Component)NativeUi.Require(gameObject.transform, "SettingsRow_Array Language")).gameObject; GameObject gameObject5 = ((Component)NativeUi.Require(gameObject.transform, "SettingsRow_Binary Hud")).gameObject; GameObject gameObject6 = ((Component)NativeUi.Require(gameObject.transform, "SettingsRow_Button Reset")).gameObject; GameObject gameObject7 = ((Component)NativeUi.Require(gameObject2.transform, "SettingsRow_Slider Volume")).gameObject; RebindMenu component = ((Component)NativeUi.Require(val.transform, "RebindMenu Keyboard")).GetComponent<RebindMenu>(); GameObject val5 = ((component != null) ? component.rowPrefab : null); if ((Object)(object)val5 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Native keyboard rebind row prefab is missing."); } for (int j = 0; j < gameObject.transform.childCount; j++) { ((Component)gameObject.transform.GetChild(j)).gameObject.SetActive(false); } VerticalLayoutGroup component2 = gameObject.GetComponent<VerticalLayoutGroup>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } GameObject val6 = Object.Instantiate<GameObject>(gameObject4, gameObject.transform); ((Object)val6).name = "SettingsRow_Section"; val6.SetActive(false); NativeUi.DisableNativeScripts(val6); NativeUi.ResetManagedButtons(val6); Transform obj = val6.transform.Find("LeftButton"); Transform val7 = val6.transform.Find("RightButton"); Transform val8 = val6.transform.Find("Variable"); if (obj != null) { ((Component)obj).gameObject.SetActive(false); } if (val7 != null) { ((Component)val7).gameObject.SetActive(false); } if (val8 != null) { ((Component)val8).gameObject.SetActive(false); } GameObject val9 = new GameObject("ModSettingsContent", new Il2CppReferenceArray<Type>((Type[])(object)new Type[1] { Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<RectTransform>.NativeClassPtr)) })); val9.transform.SetParent(gameObject.transform, false); RectTransform component3 = val9.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(1f, 1f); component3.pivot = new Vector2(0.5f, 1f); component3.sizeDelta = new Vector2(0f, 0f); ScrollRect obj2 = gameObject.AddComponent<ScrollRect>(); if ((Object)(object)gameObject.GetComponent<RectMask2D>() == (Object)null) { gameObject.AddComponent<RectMask2D>(); } obj2.viewport = gameObject.GetComponent<RectTransform>(); obj2.content = component3; obj2.horizontal = false; obj2.vertical = true; obj2.movementType = (MovementType)2; obj2.scrollSensitivity = 50f; GameObject gameObject8 = ((Component)NativeUi.Require(val2, "BackButton")).gameObject; Button component4 = gameObject8.GetComponent<Button>(); if ((Object)(object)component4 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Native back button is missing Button."); } Bind(component4, close); NativeUi.SetText(gameObject8, I18n.Text("menu.back")); ((Component)NativeUi.Require(val2, "WarningCircle")).gameObject.SetActive(false); TMP_Text component5 = ((Component)NativeUi.Require(val2, "Title")).GetComponent<TMP_Text>(); TMP_Text component6 = ((Component)NativeUi.Require(val2, "Title/VersionDisplay")).GetComponent<TMP_Text>(); TMP_Text author = CreateAuthor(component6); TMP_Text val10 = CreateDescription(val2, component5); ((Component)val10).gameObject.SetActive(false); GameObject nexusObject = CreateLinkButton(val2, gameObject8, 190f); GameObject thunderstoreObject = CreateLinkButton(val2, gameObject8, 100f); List<Transform> list = new List<Transform>(); for (int k = 0; k < val3.childCount; k++) { Transform child = val3.GetChild(k); Transform obj3 = child.Find("LobbyButton"); if ((Object)(object)((obj3 != null) ? ((Component)obj3).GetComponent<Button>() : null) != (Object)null) { list.Add(child); } } if (list.Count == 0) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Native settings menu has no category button templates."); } List<Button> list2 = new List<Button>(); for (int l = 0; l < 9; l++) { Transform val11 = list[l % list.Count]; GameObject val12 = ((l < list.Count) ? ((Component)val11).gameObject : Object.Instantiate<GameObject>(((Component)val11).gameObject, val3)); if (l >= list.Count) { ((Object)val12).name = "Category Mod " + (l + 1); NativeUi.DisableAll<SettingsCatagory>(val12); NativeUi.ResetManagedButtons(val12); } Button val13 = val12.GetComponent<Button>(); if ((Object)(object)val13 == (Object)null) { val13 = val12.GetComponentInChildren<Button>(true); } if ((Object)(object)val13 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException($"Native category {l} is missing Button."); } Bind(val13, delegate { }); list2.Add(val13); } Transform val14 = NativeUi.Require(val3, "Spacer"); for (int num = 0; num < list2.Count; num++) { Transform val15 = ((Component)list2[num]).transform; while ((Object)(object)val15.parent != (Object)(object)val3 && (Object)(object)val15.parent != (Object)null) { val15 = val15.parent; } val15.SetSiblingIndex(val14.GetSiblingIndex() + 1 + num); } ((Component)NativeUi.Require(val3, "divider")).gameObject.SetActive(true); KeybindCapture capture = new KeybindCapture(); ConfigRows rows = new ConfigRows((Transform)(object)component3, val6, gameObject5, gameObject4, gameObject7, gameObject6, val5, capture); ModSettingsPanel modSettingsPanel = new ModSettingsPanel(val, gameObject8, component5, component6, author, val10, nexusObject, thunderstoreObject, list2, rows, capture); val.AddComponent<ModSettingsInput>(); modSettingsPanel.RefreshLocalizedText(); return modSettingsPanel; } public void Prepare() { if (!((Object)(object)_panel == (Object)null)) { _capture.Cancel(); _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); _page = 0; } BuildCategories(); BuildRows(); } } public void Show() { if (!((Object)(object)_panel == (Object)null)) { _panel.SetActive(true); RefreshLocalizedText(); Button obj = SelectedCategory(); NativeUi.Select(((obj != null) ? ((Component)obj).gameObject : null) ?? _backObject); } } public void Hide() { if (!((Object)(object)_panel == (Object)null)) { _capture.Cancel(); _rows.CommitText(); _panel.SetActive(false); } } public void CaptureInput() { if (!((Object)(object)_panel == (Object)null)) { _capture.Capture(); } } public bool Update() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_panel == (Object)null) { return false; } if (_rows.Update()) { return true; } _rows.Scroll(Input.mouseScrollDelta.y); _rows.EnsureSelectionVisible(); return false; } public bool CancelTextEdit() { if ((Object)(object)_panel == (Object)null) { return false; } return _rows.CancelText(); } public void RefreshLocalizedText() { if (!((Object)(object)_panel == (Object)null)) { NativeUi.SetText(_title, I18n.Text("menu.mod_settings")); NativeUi.SetText(_backObject, I18n.Text("menu.back")); Prepare(); } } private void BuildCategories() { for (int i = 0; i < _categories.Count; i++) { ((Component)_categories[i]).gameObject.SetActive(false); _categoryGuids[i] = null; } if (_mods.Count == 0) { NativeUi.SetText(_title, I18n.Text("menu.no_configurable_mods")); NativeUi.SetText(_version, string.Empty); NativeUi.SetText(_author, string.Empty); ((Component)_author).gameObject.SetActive(false); NativeUi.SetText(_description, string.Empty); ((Component)_description).gameObject.SetActive(false); _nexusObject.SetActive(false); _thunderstoreObject.SetActive(false); SetNavigation(new List<Button>()); return; } int pageCount = GetPageCount(_mods.Count); _page = Mathf.Clamp(_page, 0, pageCount - 1); List<CategoryItem> pageItems = GetPageItems(); List<Button> list = new List<Button>(); for (int j = 0; j < pageItems.Count; j++) { CategoryItem categoryItem = pageItems[j]; Button val = _categories[j]; _categoryGuids[j] = categoryItem.Guid; Bind(val, categoryItem.Action); NativeUi.SetText(((Component)val).gameObject, categoryItem.Text); ((Component)val).gameObject.SetActive(true); list.Add(val); } SetNavigation(list); } private void BuildRows() { ModConfig modConfig = SelectedMod(); _rows.Build(modConfig); if (modConfig != null) { string name = GetName(modConfig); string text = modConfig.Registration?.Author; string text2 = modConfig.Registration?.Version; if (string.IsNullOrWhiteSpace(text2)) { text2 = ((object)modConfig.Info.Metadata.Version).ToString(); } NativeUi.SetText(_title, name); NativeUi.SetText(_version, I18n.Text("menu.version", text2)); bool flag = !string.IsNullOrWhiteSpace(text); ((Component)_author).gameObject.SetActive(flag); NativeUi.SetText(_author, flag ? I18n.Text("menu.author", text) : string.Empty); string text3 = modConfig.Registration?.GetDescription(); NativeUi.SetText(_description, text3); ((Component)_description).gameObject.SetActive(!string.IsNullOrWhiteSpace(text3)); GameObject nexusObject = _nexusObject; bool visible = modConfig.Registration?.NexusModsId.HasValue ?? false; string text4 = I18n.Text("menu.open_nexus_page"); ModSettingsRegistration registration = modConfig.Registration; ConfigureLink(nexusObject, visible, text4, (registration != null && registration.NexusModsId.HasValue) ? ModSettingsRegistry.GetNexusModsUrl(modConfig.Registration.NexusModsId.Value) : null); bool flag2 = !string.IsNullOrWhiteSpace(modConfig.Registration?.ThunderstoreTeam); ConfigureLink(_thunderstoreObject, flag2, I18n.Text("menu.open_thunderstore_page"), flag2 ? ModSettingsRegistry.GetThunderstoreUrl(modConfig.Registration.ThunderstoreTeam, modConfig.Registration.ThunderstoreModName) : null); Selectable back = (Selectable)(object)(_nexusObject.activeSelf ? _nexusObject.GetComponent<Button>() : (_thunderstoreObject.activeSelf ? _thunderstoreObject.GetComponent<Button>() : _backObject.GetComponent<Button>())); _rows.ConnectNavigation((Selectable)(object)SelectedCategory(), back); WireInfoNavigation(); } } private List<CategoryItem> GetPageItems() { List<CategoryItem> list = new List<CategoryItem>(); bool flag = _page > 0; int pageCount = GetPageCount(_mods.Count); bool flag2 = _page + 1 < pageCount; int firstModIndex = GetFirstModIndex(_page); int num = 9 - (flag ? 1 : 0) - (flag2 ? 1 : 0); if (flag) { list.Add(new CategoryItem(I18n.Text("menu.previous"), PreviousPage)); } for (int i = firstModIndex; i < _mods.Count && i < firstModIndex + num; i++) { ModConfig modConfig = _mods[i]; string guid = modConfig.Info.Metadata.GUID; list.Add(new CategoryItem(GetName(modConfig), delegate { SelectMod(guid); }, guid)); } if (flag2) { list.Add(new CategoryItem(I18n.Text("menu.next"), NextPage)); } return list; } private void SelectMod(string guid) { _selectedGuid = guid; BuildRows(); Button obj = SelectedCategory(); NativeUi.Select((obj != null) ? ((Component)obj).gameObject : null); } private void PreviousPage() { _page--; SelectFirstModOnPage(); BuildCategories(); BuildRows(); NativeUi.Select(((Component)_categories[0]).gameObject); } private void NextPage() { _page++; SelectFirstModOnPage(); BuildCategories(); BuildRows(); NativeUi.Select(((Component)_categories[0]).gameObject); } private void SelectFirstModOnPage() { int firstModIndex = GetFirstModIndex(_page); if (firstModIndex >= 0 && firstModIndex < _mods.Count) { _selectedGuid = _mods[firstModIndex].Info.Metadata.GUID; } } private ModConfig SelectedMod() { return _mods.FirstOrDefault((ModConfig mod) => string.Equals(mod.Info.Metadata.GUID, _selectedGuid, StringComparison.OrdinalIgnoreCase)); } private Button SelectedCategory() { for (int i = 0; i < _categories.Count; i++) { if (((Component)_categories[i]).gameObject.activeSelf && string.Equals(_categoryGuids[i], _selectedGuid, StringComparison.OrdinalIgnoreCase)) { return _categories[i]; } } return ((IEnumerable<Button>)_categories).FirstOrDefault((Func<Button, bool>)((Button button) => ((Component)button).gameObject.activeSelf)); } private void SetNavigation(IReadOnlyList<Button> visible) { for (int i = 0; i < visible.Count; i++) { NativeUi.SetNavigation((Selectable)(object)visible[i], (Selectable)(object)((i > 0) ? visible[i - 1] : null), (Selectable)(object)((i + 1 < visible.Count) ? visible[i + 1] : _backObject.GetComponent<Button>()), null, null); } Button component = _backObject.GetComponent<Button>(); Navigation navigation = ((Selectable)component).navigation; NativeUi.SetNavigation((Selectable)(object)component, (Selectable)(object)visible.LastOrDefault(), null, navigation.selectOnLeft, navigation.selectOnRight); } private static void DisableNativeBehaviour(GameObject panel) { NativeUi.DisableAll<SettingsMenu>(panel); NativeUi.DisableAll<SettingsRow>(panel); NativeUi.DisableAll<SettingsCatagory>(panel); NativeUi.DisableAll<BackNavigationHelper>(panel); NativeUi.DisableAll<MenuScreenBack>(panel); NativeUi.DisableAll<SettingItemIdentifier>(panel); NativeUi.DisableAll<SliderSounds>(panel); NativeUi.DisableAll<NmouseSliderHandler>(panel); NativeUi.ResetManagedButtons(panel); } private static int GetPageCount(int count) { if (count <= 9) { return 1; } int num = 8; int num2 = 7; if (count <= num * 2) { return 2; } return 2 + Mathf.CeilToInt((float)(count - num * 2) / (float)num2); } private static int GetFirstModIndex(int page) { if (page != 0) { return 8 + (page - 1) * 7; } return 0; } private static string GetName(ModConfig mod) { if (mod == null) { return string.Empty; } string text = mod.Registration?.GetName(); if (string.IsNullOrWhiteSpace(text)) { text = mod.Info.Metadata.Name; } return Regex.Replace(text.Replace('_', ' ').Replace('-', ' '), "(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])", " "); } private static void Bind(Button button, Action action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action)); } private static TMP_Text CreateDescription(Transform right, TMP_Text source) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, right); ((Object)val).name = "Mod Description"; Transform val2 = val.transform.Find("VersionDisplay"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } TMP_Text component = val.GetComponent<TMP_Text>(); RectTransform component2 = val.GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Native title cannot provide a description label."); } component2.anchorMin = new Vector2(1f, 1f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(1f, 1f); component2.anchoredPosition = new Vector2(-80f, -230f); component2.sizeDelta = new Vector2(420f, 360f); component.alignment = (TextAlignmentOptions)260; component.enableWordWrapping = true; component.enableAutoSizing = true; component.fontSizeMin = 18f; component.fontSizeMax = Mathf.Min(32f, source.fontSize); return component; } private static TMP_Text CreateAuthor(TMP_Text source) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, source.transform.parent); ((Object)val).name = "AuthorDisplay"; TMP_Text component = val.GetComponent<TMP_Text>(); RectTransform component2 = ((Component)source).GetComponent<RectTransform>(); RectTransform component3 = val.GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Native version label cannot provide an author label."); } component3.anchoredPosition = component2.anchoredPosition + new Vector2(0f, -52f); ((Component)component).gameObject.SetActive(false); return component; } private static GameObject CreateLinkButton(Transform right, GameObject source, float y) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(source, right); 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("Native back button cannot provide a link button."); } component.anchoredPosition = new Vector2(-80f, y); component.sizeDelta = new Vector2(380f, 75f); val.SetActive(false); return val; } private static void ConfigureLink(GameObject linkObject, bool visible, string text, string url) { linkObject.SetActive(visible); if (visible) { Bind(linkObject.GetComponent<Button>(), delegate { Application.OpenURL(url); }); NativeUi.SetText(linkObject, text); } } private void WireInfoNavigation() { Button val = (_nexusObject.activeSelf ? _nexusObject.GetComponent<Button>() : null); Button val2 = (_thunderstoreObject.activeSelf ? _thunderstoreObject.GetComponent<Button>() : null); Button component = _backObject.GetComponent<Button>(); if ((Object)(object)val != (Object)null) { NativeUi.SetNavigation((Selectable)(object)val, null, (Selectable)(object)(val2 ?? component), null, null); } if ((Object)(object)val2 != (Object)null) { NativeUi.SetNavigation((Selectable)(object)val2, (Selectable)(object)val, (Selectable)(object)component, null, null); } NativeUi.SetNavigation((Selectable)(object)component, (Selectable)(object)(val2 ?? val), null, null, null); } } internal static class NativeUi { public static TMP_Text SetText(GameObject root, string text) { if ((Object)(object)root == (Object)null) { return null; } TMP_Text componentInChildren = root.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { LocalizedText component = ((Component)componentInChildren).GetComponent<LocalizedText>(); if ((Object)(object)component != (Object)null) { string text2 = text ?? string.Empty; component.Change(text2, (DisplayType)1); componentInChildren.text = text2; } else { componentInChildren.text = text ?? string.Empty; } } return componentInChildren; } public static TMP_Text SetRowTitle(GameObject row, string text) { Transform obj = ((row != null) ? row.transform.Find("Title") : null); TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null) ?? ((row != null) ? row.GetComponentInChildren<TMP_Text>(true) : null); if ((Object)(object)val != (Object)null) { LocalizedText component = ((Component)val).GetComponent<LocalizedText>(); if ((Object)(object)component != (Object)null) { string text2 = text ?? string.Empty; component.Change(text2, (DisplayType)1); val.text = text2; } else { val.text = text ?? string.Empty; } } return val; } public static void SetText(TMP_Text label, string text) { if ((Object)(object)label != (Object)null) { LocalizedText component = ((Component)label).GetComponent<LocalizedText>(); if ((Object)(object)component != (Object)null) { string text2 = text ?? string.Empty; component.Change(text2, (DisplayType)1); label.text = text2; } else { label.text = text ?? string.Empty; } } } public static void Select(GameObject target) { if ((Object)(object)target != (Object)null && (Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject(target); } } public static Transform Require(Transform root, string path) { Transform obj = ((root != null) ? root.Find(path) : null); if ((Object)(object)obj == (Object)null) { throw new InvalidOperationException("Resource path not found: " + path); } return obj; } public static void Disable<T>(GameObject root) where T : Behaviour { if (!((Object)(object)root == (Object)null)) { T component = root.GetComponent<T>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } } } public static void DisableAll<T>(GameObject root) where T : Behaviour { if (!((Object)(object)root == (Object)null)) { T[] array = Il2CppArrayBase<T>.op_Implicit(root.GetComponentsInChildren<T>(true)); for (int i = 0; i < array.Length; i++) { ((Behaviour)array[i]).enabled = false; } } } public static void DisableNativeScripts(GameObject root) { NativeUi.DisableAll<SettingsRow>(root); NativeUi.DisableAll<SettingsMenu>(root); NativeUi.DisableAll<BackNavigationHelper>(root); NativeUi.DisableAll<MenuScreenBack>(root); NativeUi.DisableAll<SettingItemIdentifier>(root); NativeUi.DisableAll<SliderSounds>(root); NativeUi.DisableAll<NmouseSliderHandler>(root); NativeUi.DisableAll<RebindRow>(root); ResetManagedButtons(root); } public static void ResetManagedButtons(GameObject root) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (!((Object)(object)root == (Object)null)) { ManagedButton[] array = Il2CppArrayBase<ManagedButton>.op_Implicit(root.GetComponentsInChildren<ManagedButton>(true)); for (int i = 0; i < array.Length; i++) { array[i].onLeft = new UnityEvent(); array[i].onRight = new UnityEvent(); } } } public static void SetNavigation(Selectable selectable, Selectable up, Selectable down, Selectable left, Selectable right) { if (TryGetGameObject(selectable, out var _)) { up = (IsAlive(up) ? up : null); down = (IsAlive(down) ? down : null); left = (IsAlive(left) ? left : null); right = (IsAlive(right) ? right : null); Navigation navigation = selectable.navigation; navigation.mode = (Mode)4; navigation.selectOnUp = up; navigation.selectOnDown = down; navigation.selectOnLeft = left; navigation.selectOnRight = right; selectable.navigation = navigation; ManagedButton component = ((Component)selectable).GetComponent<ManagedButton>(); if ((Object)(object)component != (Object)null) { component.SetNavagitationTargets(GetGameObject(up), GetGameObject(down), GetGameObject(left), GetGameObject(right)); } } } private static bool IsAlive(Selectable selectable) { GameObject gameObject; return TryGetGameObject(selectable, out gameObject); } private static GameObject GetGameObject(Selectable selectable) { if (!TryGetGameObject(selectable, out var gameObject)) { return null; } return gameObject; } private static bool TryGetGameObject(Selectable selectable, out GameObject gameObject) { gameObject = null; if ((Object)(object)selectable == (Object)null) { return false; } try { gameObject = ((Component)selectable).gameObject; return (Object)(object)gameObject != (Object)null; } catch { return false; } } public static List<GameObject> Children(Transform root) { List<GameObject> list = new List<GameObject>(); if ((Object)(object)root == (Object)null) { return list; } for (int i = 0; i < root.childCount; i++) { list.Add(((Component)root.GetChild(i)).gameObject); } return list; } } } namespace ModSettingsMenu.Patches { [HarmonyPatch(typeof(SettingsMenu), "SettingBackEvent")] public static class SettingsMenuPatch { [HarmonyPrefix] public static bool Prefix(SettingsMenu __instance) { return !ModSettingsMenuController.HandleSettingsBack(__instance); } } [HarmonyPatch(typeof(TitleMenu))] public static class TitleMenuPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPostfix(TitleMenu __instance) { ModSettingsMenuController.TryCreate(__instance); } [HarmonyPatch("OnEnable")] [HarmonyPostfix] public static void OnEnablePostfix(TitleMenu __instance) { ModSettingsMenuController.TryCreate(__instance); } } [HarmonyPatch(typeof(WorldMenuManager))] public static class WorldMenuManagerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void AwakePostfix(WorldMenuManager __instance) { ModSettingsMenuController.TryCreate(__instance); } [HarmonyPatch("CloseMenu")] [HarmonyPrefix] public static bool CloseMenuPrefix() { return !ModSettingsMenuController.HandleWorldMenuClose(); } } } namespace ModSettingsMenu.Localization { public static class I18n { private const string FileName = "ModSettingsMenu.Localization.json"; private static ModLocalizer _localizer; public static ModLocalizer L => _localizer ?? (_localizer = CreateLocalizer()); public static string Text(string key, params object[] args) { return L.GetLocalizedText(key, args); } private static ModLocalizer CreateLocalizer() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ModLocalizer obj = LocalizationApi.For("IceBoxStudio.BigWalk.ModSettingsMenu"); obj.RegisterJson(Path.Combine(directoryName, "ModSettingsMenu.Localization.json")); return obj; } } } namespace ModSettingsMenu.Configuration { internal static class ConfigValues { public static bool TrySetValue(ConfigEntryBase entry, object value) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown try { entry.BoxedValue = value; entry.ConfigFile.Save(); return true; } catch (Exception ex) { ManualLogSource logger = ModSettingsMenu.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to save setting "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ConfigDefinition>(entry.Definition); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); return false; } } public static bool TrySetSerializedValue(ConfigEntryBase entry, string value) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown try { entry.SetSerializedValue(value); entry.ConfigFile.Save(); return true; } catch (Exception ex) { ManualLogSource logger = ModSettingsMenu.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to save setting "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ConfigDefinition>(entry.Definition); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); return false; } } public static bool TryReset(ConfigFile config) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown bool saveOnConfigSet = config.SaveOnConfigSet; try { config.SaveOnConfigSet = false; foreach (ConfigEntryBase value in config.Values) { value.BoxedValue = value.DefaultValue; } config.Save(); return true; } catch (Exception ex) { ManualLogSource logger = ModSettingsMenu.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to restore default settings: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); return false; } finally { config.SaveOnConfigSet = saveOnConfigSet; } } public static string FormatValue(object value) { if (value == null) { return string.Empty; } if (value is IFormattable formattable) { return formattable.ToString(null, CultureInfo.InvariantCulture) ?? string.Empty; } return value.ToString() ?? string.Empty; } public static object ConvertSliderValue(float sliderValue, double min, double max, double step, float stepCount, Type targetType) { double value = ((sliderValue >= stepCount) ? max : (min + step * Math.Round(sliderValue))); value = SnapSliderValue(value, min, max, step); if (targetType == typeof(float)) { return (float)value; } if (targetType == typeof(double)) { return value; } if (targetType == typeof(decimal)) { return (decimal)value; } if (targetType == typeof(