using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using HarmonyLib; using Il2Cpp; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using MelonLoader; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Caleb Orchard")] [assembly: AssemblyConfiguration("Retail - Debug")] [assembly: AssemblyDescription("A reusable menu injection library for Baby Steps MelonLoader mods.")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+11a490c829d6b67512aa6da54556de709c4ef3c3")] [assembly: AssemblyProduct("BabyStepsMenuLib")] [assembly: AssemblyTitle("BabyStepsMenuLib")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/caleborchard/BabyStepsMenuLib")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BabyStepsMenuLib { public static class MenuInjectionLibrary { public sealed class RuntimeTabMenu { private readonly string[] _tabNames; private readonly List[] _pageSelectables; private int _setTabFrame = -1; private Selectable[] _fixedItems; public RectTransform Root { get; internal set; } public RectTransform Header { get; internal set; } public Button[] Tabs { get; internal set; } public RectTransform[] Pages { get; internal set; } public int ActiveTab { get; private set; } public int TabCount { get { Button[] tabs = Tabs; return (tabs != null) ? tabs.Length : 0; } } internal MenuItemList ManagedItemList { get; set; } internal Color NativeHighlightedColor { get; set; } = TabHighlighted; internal void SetFixedMenuItems(params Selectable[] items) { _fixedItems = items; } internal RuntimeTabMenu(string[] tabNames) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) _tabNames = tabNames; _pageSelectables = new List[tabNames.Length]; for (int i = 0; i < tabNames.Length; i++) { _pageSelectables[i] = new List(); } } public RectTransform GetPage(int index) { return (Pages != null && index >= 0 && index < Pages.Length) ? Pages[index] : null; } public void UpdateTabName(int index, string name) { if (_tabNames != null && index >= 0 && index < _tabNames.Length) { _tabNames[index] = name; } } public void OnShown() { SetActiveTab(ActiveTab); } internal void RegisterPageSelectable(int page, Selectable s) { if (!((Object)(object)s == (Object)null) && _pageSelectables != null && page >= 0 && page < _pageSelectables.Length) { _pageSelectables[page].Add(s); } } public void SetActiveTab(int index) { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) if (Tabs == null || Pages == null || index < 0 || index >= TabCount) { return; } int frameCount = Time.frameCount; if (frameCount == _setTabFrame) { return; } _setTabFrame = frameCount; ActiveTab = index; List[] pageSelectables = _pageSelectables; List list = ((pageSelectables != null) ? pageSelectables[index] : null); for (int i = 0; i < TabCount; i++) { bool flag = i == index; if ((Object)(object)Pages[i] != (Object)null) { CanvasGroup component = ((Component)Pages[i]).GetComponent(); if ((Object)(object)component != (Object)null) { component.alpha = (flag ? 1f : 0f); component.interactable = flag; component.blocksRaycasts = flag; } if (flag) { Il2CppArrayBase componentsInChildren = ((Component)Pages[i]).GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)null) { componentsInChildren[j].ForceMeshUpdate(false, false); } } } } if (!((Object)(object)Tabs[i] != (Object)null)) { continue; } Color val = (flag ? TabSelected : TabUnselected); Image component2 = ((Component)Tabs[i]).GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Graphic)component2).color = Color.white; ((Graphic)component2).CrossFadeColor(val, 0f, true, true); } TMP_Text componentInChildren = ((Component)Tabs[i]).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { if (_tabNames != null && i < _tabNames.Length) { componentInChildren.text = _tabNames[i]; } ((Graphic)componentInChildren).color = TabText; componentInChildren.ForceMeshUpdate(false, false); } ColorBlock colors = ((Selectable)Tabs[i]).colors; ((ColorBlock)(ref colors)).normalColor = val; ((ColorBlock)(ref colors)).selectedColor = NativeHighlightedColor; ((ColorBlock)(ref colors)).highlightedColor = NativeHighlightedColor; ((ColorBlock)(ref colors)).pressedColor = NativeHighlightedColor; ((ColorBlock)(ref colors)).disabledColor = val; ((ColorBlock)(ref colors)).colorMultiplier = 1f; ((Selectable)Tabs[i]).colors = colors; } int num = list?.Count ?? 0; Selectable[] fixedItems = _fixedItems; int num2 = ((fixedItems != null) ? fixedItems.Length : 0); List list2 = new List(num + num2); for (int k = 0; k < num; k++) { if ((Object)(object)list[k] != (Object)null) { list2.Add(list[k]); } } for (int l = 0; l < num2; l++) { if ((Object)(object)_fixedItems[l] != (Object)null) { list2.Add(_fixedItems[l]); } } if ((Object)(object)ManagedItemList != (Object)null) { GameObject[] array = (GameObject[])(object)new GameObject[list2.Count]; for (int m = 0; m < list2.Count; m++) { array[m] = ((Component)list2[m]).gameObject; } ManagedItemList.items = Il2CppReferenceArray.op_Implicit(array); } for (int n = 0; n < list2.Count; n++) { Selectable val2 = list2[n]; Navigation navigation = val2.navigation; navigation.mode = (Mode)4; navigation.selectOnUp = ((n > 0) ? list2[n - 1] : null); navigation.selectOnDown = ((n < list2.Count - 1) ? list2[n + 1] : null); navigation.selectOnLeft = null; navigation.selectOnRight = null; val2.navigation = navigation; } } } public sealed class TabBuilder { internal TabBuilder() { } public TMP_Text AddLabel(string text) { return MenuInjectionLibrary.AddLabel(text, (RectTransform)null); } public Button AddButton(string text, UnityAction onClick) { return MenuInjectionLibrary.AddButton(text, onClick, (RectTransform)null); } public Toggle AddToggle(string text, bool initial, UnityAction onChange) { return MenuInjectionLibrary.AddToggle(text, initial, onChange, (RectTransform)null); } public Slider AddSlider(string text, float min, float max, float value, UnityAction onChange, bool wholeNumbers = false) { return MenuInjectionLibrary.AddSlider(text, min, max, value, onChange, wholeNumbers, (RectTransform)null); } public Button AddInputField(string placeholder = "", UnityAction onChange = null, string initialValue = null) { return MenuInjectionLibrary.AddInputField(placeholder, onChange, initialValue, (RectTransform)null); } public Image AddImage(Color color, float height = 52f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return MenuInjectionLibrary.AddImage(color, height, (RectTransform)null); } } public sealed class MenuBuilder { internal readonly string _mainButtonLabel; internal readonly List<(string name, Action configure)> _tabs = new List<(string, Action)>(); internal readonly List<(string label, UnityAction action)> _fixed = new List<(string, UnityAction)>(); internal float _sideMargin; internal float _topMargin; internal MenuBuilder(string mainButtonLabel) { _mainButtonLabel = mainButtonLabel; } public MenuBuilder AddTab(string name, Action configure) { _tabs.Add((name, configure)); return this; } public MenuBuilder AddFixedButton(string label, UnityAction action = null) { _fixed.Add((label, action)); return this; } public MenuBuilder WithMargin(float sideMargin, float topMargin) { _sideMargin = sideMargin; _topMargin = topMargin; return this; } public InjectedMenu Build() { InjectedMenu injectedMenu = new InjectedMenu(this); if (!_registeredMenus.Contains(injectedMenu)) { _registeredMenus.Add(injectedMenu); } return injectedMenu; } } public sealed class InputFieldInfo { public string Value = ""; public TMP_Text DisplayText; public UnityAction OnChanged; public string Placeholder = ""; public RectTransform Viewport; public Color ActiveColor = Color.white; public Color PlaceholderColor = new Color(1f, 1f, 1f, 0.45f); public Button OwnerButton; public Image CursorImage; } public sealed class InjectedMenu { private readonly string _mainButtonLabel; private readonly List<(string name, Action configure)> _tabDescs; private readonly List<(string label, UnityAction action)> _fixedDescs; private Menu _activeMenu; private RuntimeTabMenu _tabMenu; private bool _contentBuilt; private bool _hasAttemptedInitialDump; private GameObject _mainButtonObj; private Button _mainButton; private Transform _mainMenuRoot; private CanvasGroup _mainMenuCG; private MenuItemList _mainMenuItemList; private GameObject _submenuObj; private CanvasGroup _submenuCG; private MenuItemList _submenuItemList; private readonly List