using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using CosmeticMenu; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Bonelab; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Pool; using Il2CppTMPro; using LabFusion.Marrow; using LabFusion.Marrow.Pool; using LabFusion.Marrow.Proxies; using LabFusion.Menu; using MelonLoader; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(CosmeticMenuMod), "CosmeticMenu", "1.0.0", "CosmeticMenuAuthor", null)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace CosmeticMenu; public static class CatalogPanel { internal static GameObject CachedCatalogClone; internal static bool IsActive; internal static GameObject ProfilePanel; internal static MenuPage ProfilePage; internal static bool IsCatalogUiInitialized; internal static bool AreButtonsPopulated; private const float CloseButtonSize = 45f; private const float CloseButtonOffset = 35f; private const int ToolbarLeftPadding = 85; private const int ToolbarRightPadding = 30; private static GameObject _overlayRoot; private static bool _spawning; private static void SetCachedCatalog(GameObject catalog) { CachedCatalogClone = catalog; IsCatalogUiInitialized = false; AreButtonsPopulated = false; IsActive = false; } public static void Toggle(GameObject menuRoot) { if (IsActive) { Hide(); } else { Show(menuRoot); } } private static void Show(GameObject menuRoot) { if ((Object)(object)CachedCatalogClone != (Object)null) { ShowCached(menuRoot); return; } BitMart val = Object.FindObjectOfType(); if ((Object)(object)val != (Object)null && (Object)(object)val.BitMartElement != (Object)null) { Transform val2 = ((Component)val.BitMartElement).transform.Find("panel_BitCatalog"); if ((Object)(object)val2 != (Object)null) { SetCachedCatalog(Object.Instantiate(((Component)val2).gameObject)); CachedCatalogClone.SetActive(true); ShowCached(menuRoot); return; } } SpawnTemporaryBitMart(menuRoot); } private static void SpawnTemporaryBitMart(GameObject menuRoot) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (_spawning) { return; } _spawning = true; MelonLogger.Msg("[CosmeticMenu] No BitMart in scene, spawning temporary one to get catalog..."); ShowLoadingOverlay(menuRoot); try { Spawnable obj = LocalAssetSpawner.CreateSpawnable(FusionSpawnableReferences.BitMartReference); LocalAssetSpawner.Register(obj); LocalAssetSpawner.Spawn(obj, new Vector3(0f, -10000f, 0f), Quaternion.identity, (Action)OnTemporaryBitMartSpawned); } catch (Exception value) { MelonLogger.Error($"[CosmeticMenu] Failed to spawn temporary BitMart: {value}"); _spawning = false; ClearOverlay(); } } private static void OnTemporaryBitMartSpawned(Poolee poolee) { try { GameObject val = ((poolee != null) ? ((Component)poolee).gameObject : null); if ((Object)(object)val == (Object)null) { MelonLogger.Warning("[CosmeticMenu] Temporary BitMart spawn returned null."); _spawning = false; return; } BitMart component = val.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.BitMartElement == (Object)null) { MelonLogger.Warning("[CosmeticMenu] Temporary BitMart has no elements."); Object.Destroy((Object)(object)val); _spawning = false; return; } Transform val2 = ((Component)component.BitMartElement).transform.Find("panel_BitCatalog"); if ((Object)(object)val2 == (Object)null) { MelonLogger.Warning("[CosmeticMenu] Temporary BitMart has no catalog panel."); Object.Destroy((Object)(object)val); _spawning = false; return; } SetCachedCatalog(Object.Instantiate(((Component)val2).gameObject)); CachedCatalogClone.SetActive(true); Object.Destroy((Object)(object)val); MelonLogger.Msg("[CosmeticMenu] Catalog cloned from temporary BitMart."); GameObject menuGameObject = MenuCreator.MenuGameObject; if ((Object)(object)menuGameObject != (Object)null) { ClearOverlay(); ShowCached(menuGameObject); } _spawning = false; } catch (Exception value) { MelonLogger.Error($"[CosmeticMenu] Error cloning catalog from temp BitMart: {value}"); _spawning = false; } } private static void ShowCached(GameObject menuRoot) { if (!((Object)(object)CachedCatalogClone == (Object)null)) { ClearOverlay(); if ((Object)(object)CachedCatalogClone.transform.parent != (Object)(object)menuRoot.transform) { CachedCatalogClone.transform.SetParent(menuRoot.transform, false); UiHelpers.StretchFull(CachedCatalogClone.GetComponent()); } if (!AreButtonsPopulated) { UiHelpers.RemoveButtonHoverClicks(CachedCatalogClone); MenuButtonHelper.PopulateButtons(CachedCatalogClone); AreButtonsPopulated = true; } BitCatalogElement component = CachedCatalogClone.GetComponent(); if ((Object)(object)component != (Object)null) { SetupCatalogUI(component); } MenuPage component2 = CachedCatalogClone.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.ShowPage(); } if ((Object)(object)ProfilePanel != (Object)null) { ProfilePanel.SetActive(false); } IsActive = true; MelonLogger.Msg("[CosmeticMenu] Cosmetics catalog shown (Inventory tab)."); } } private static void SetupCatalogUI(BitCatalogElement catalogElement) { if (!IsCatalogUiInitialized) { if ((Object)(object)catalogElement.ShopElement != (Object)null) { ((Component)catalogElement.ShopElement).gameObject.SetActive(false); } MenuPage browserPage = catalogElement.BrowserPage; Transform obj = ((browserPage != null) ? ((Component)browserPage).transform.Find("group_Toolbars") : null); Transform val = ((obj != null) ? obj.Find("layout_Tabs") : null); HorizontalLayoutGroup layoutTabsHlg = ((val != null) ? ((Component)val).GetComponent() : null); if ((Object)(object)catalogElement.CatalogCloseElement != (Object)null && (Object)(object)val != (Object)null) { SetupCloseButton(catalogElement.CatalogCloseElement, val, layoutTabsHlg); } if ((Object)(object)catalogElement.InventoryElement != (Object)null) { SetupInventoryLabel(catalogElement.InventoryElement, val); } if ((Object)(object)val != (Object)null) { SetupToolbarButtons(catalogElement, val); } if ((Object)(object)catalogElement.CatalogBitCountText != (Object)null && (Object)(object)catalogElement.CatalogUnequipAllElement != (Object)null) { SetupBitCount(catalogElement); } IsCatalogUiInitialized = true; } FunctionElement inventoryElement = catalogElement.InventoryElement; if (inventoryElement != null) { inventoryElement.Press(); } } private static void SetupCloseButton(FunctionElement closeElement, Transform layoutTabs, HorizontalLayoutGroup layoutTabsHlg) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown ((Component)closeElement).transform.SetParent(layoutTabs, false); ((Component)closeElement).transform.SetAsFirstSibling(); LayoutElement component = ((Component)closeElement).GetComponent(); if ((Object)(object)component != (Object)null) { component.ignoreLayout = true; component.minWidth = 45f; component.preferredWidth = 45f; component.minHeight = 45f; component.preferredHeight = 45f; component.flexibleWidth = 0f; component.flexibleHeight = 0f; } RectTransform component2 = ((Component)closeElement).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.anchorMin = new Vector2(0f, 0.5f); component2.anchorMax = new Vector2(0f, 0.5f); component2.pivot = new Vector2(0f, 0.5f); component2.sizeDelta = new Vector2(45f, 45f); component2.anchoredPosition = new Vector2(35f, 0f); } Transform val = ((Component)closeElement).transform.Find("Collider"); if ((Object)(object)val != (Object)null) { UiHelpers.StretchFull(((Component)val).GetComponent()); } if ((Object)(object)layoutTabsHlg != (Object)null) { ((LayoutGroup)layoutTabsHlg).padding = new RectOffset(85, 30, 0, 0); } closeElement.OnPressed = null; closeElement.OnPressed = (Action)Delegate.Combine(closeElement.OnPressed, new Action(Hide)); Button component3 = ((Component)closeElement).GetComponent