using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Localization;
using Microsoft.CodeAnalysis;
using SNetwork;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CustomMenuBarButtons")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+98c91c82df9db103cd6976e06882bc79e0a3112b")]
[assembly: AssemblyProduct("CustomMenuBarButtons")]
[assembly: AssemblyTitle("CustomMenuBarButtons")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NativeIntegerAttribute : Attribute
{
public readonly bool[] TransformFlags;
public NativeIntegerAttribute()
{
TransformFlags = new bool[1] { true };
}
public NativeIntegerAttribute(bool[] P_0)
{
TransformFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 CustomMenuBarButtons
{
[BepInPlugin("dev.flaff.gtfo.CustomMenuBarButtons", "CustomMenuBarButtons", "0.1.1")]
internal sealed class EntryPoint : BasePlugin
{
private readonly Harmony _harmony;
public EntryPoint()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
_harmony = new Harmony("dev.flaff.gtfo.CustomMenuBarButtons");
}
public sealed override void Load()
{
_harmony.PatchAll();
}
public sealed override bool Unload()
{
_harmony.UnpatchSelf();
return ((BasePlugin)this).Unload();
}
}
public abstract class MenuBarBuiltInButton : MenuBarButton
{
public sealed class SettingsButton : MenuBarBuiltInButton
{
public sealed override bool ShouldBeVisible => true;
internal SettingsButton(MenuBarHandler handler)
: base(handler, handler.MenuBar.m_settings)
{
}
}
public sealed class LoadoutButton : MenuBarBuiltInButton
{
public sealed override bool ShouldBeVisible => SNet.IsInLobby;
internal LoadoutButton(MenuBarHandler handler)
: base(handler, handler.MenuBar.m_loadout)
{
}
}
public sealed class RundownButton : MenuBarBuiltInButton
{
public sealed override bool ShouldBeVisible
{
get
{
if (!RundownManager.ExpeditionIsStarted)
{
return !ElevatorRide.ElevatorRideInProgress;
}
return false;
}
}
internal RundownButton(MenuBarHandler handler)
: base(handler, handler.MenuBar.m_rundown)
{
}
}
public sealed class ExitLobbyAndExpeditionButton : MenuBarBuiltInButton
{
public sealed override bool ShouldBeVisible => base.MenuBarHandler.MenuBar.ExitLobbyAndExpeditionShouldBeVisible;
internal ExitLobbyAndExpeditionButton(MenuBarHandler handler)
: base(handler, handler.MenuBar.m_exitLobbyAndExpedition)
{
}
}
public sealed class ReturnToLobbyButton : MenuBarBuiltInButton
{
public sealed override bool ShouldBeVisible
{
get
{
if (RundownManager.ExpeditionIsStarted || ElevatorRide.ElevatorRideInProgress)
{
return SNet.IsMaster;
}
return false;
}
}
internal ReturnToLobbyButton(MenuBarHandler handler)
: base(handler, handler.MenuBar.m_returnToLobby)
{
}
}
public sealed class QuitButton : MenuBarBuiltInButton
{
public sealed override bool ShouldBeVisible => true;
internal QuitButton(MenuBarHandler handler)
: base(handler, handler.MenuBar.m_quitGame)
{
}
}
internal MenuBarBuiltInButton(MenuBarHandler handler, CM_MenuBarItem item)
: base(handler, item)
{
}
}
public abstract class MenuBarButton
{
public CM_MenuBarItem Item { get; }
public MenuBarHandler MenuBarHandler { get; }
public abstract bool ShouldBeVisible { get; }
internal MenuBarButton(MenuBarHandler handler, CM_MenuBarItem item)
{
MenuBarHandler = handler;
Item = item;
}
}
public abstract class MenuBarCustomButton : MenuBarButton
{
private MenuBarCustomButton(MenuBarHandler handler, CM_MenuBarItem item)
: base(handler, item)
{
((CM_Item)base.Item).OnBtnPressCallback += Action<int>.op_Implicit((Action<int>)OnButtonClick);
}
protected MenuBarCustomButton(MenuBarHandler handler, CM_MenuBarItem item, string text)
: this(handler, item)
{
((CM_Item)base.Item).SetText(text);
}
protected MenuBarCustomButton(MenuBarHandler handler, CM_MenuBarItem item, uint textId)
: this(handler, item)
{
Text.AddTextSetter(((Il2CppObjectBase)item).Cast<ILocalizedTextSetter>(), textId);
}
protected abstract void OnButtonClick(int id);
}
public sealed class MenuBarHandler
{
private readonly List<MenuBarButton> leftButtons = new List<MenuBarButton>();
private readonly List<MenuBarButton> rightButtons = new List<MenuBarButton>();
public CM_MenuBar MenuBar { get; }
public static event Action<MenuBarHandler>? CreateButtons;
internal MenuBarHandler(CM_MenuBar menuBar)
{
MenuBar = menuBar;
leftButtons.Add(new MenuBarBuiltInButton.SettingsButton(this));
leftButtons.Add(new MenuBarBuiltInButton.RundownButton(this));
leftButtons.Add(new MenuBarBuiltInButton.LoadoutButton(this));
rightButtons.Add(new MenuBarBuiltInButton.QuitButton(this));
rightButtons.Add(new MenuBarBuiltInButton.ExitLobbyAndExpeditionButton(this));
rightButtons.Add(new MenuBarBuiltInButton.ReturnToLobbyButton(this));
}
public T AddLeftButton<T>(Func<MenuBarHandler, CM_MenuBarItem, T> buttonCreator, int insertIndex = int.MaxValue, eCM_MenuPage page = 1) where T : MenuBarCustomButton
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (insertIndex < 0)
{
throw new ArgumentOutOfRangeException("insertIndex");
}
if (buttonCreator == null)
{
throw new ArgumentNullException("buttonCreator");
}
CM_MenuBarItem val = GOUtil.SpawnChildAndGetComp<CM_MenuBarItem>(MenuBar.m_menuBarItemPrefab, ((Component)MenuBar).transform);
((RectTransformComp)val).SetAnchor((GuiAnchor)1, true);
val.Setup(MenuBar.m_root, page);
((RectTransformComp)val).SetVisible(false);
T val2 = buttonCreator(this, val);
if (insertIndex < leftButtons.Count)
{
leftButtons.Insert(insertIndex, val2);
}
else
{
leftButtons.Add(val2);
}
return val2;
}
public T AddRightButton<T>(Func<MenuBarHandler, CM_MenuBarItem, T> buttonCreator, int insertIndex = int.MaxValue, eCM_MenuPage page = 1) where T : MenuBarCustomButton
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (insertIndex < 0)
{
throw new ArgumentOutOfRangeException("insertIndex");
}
if (buttonCreator == null)
{
throw new ArgumentNullException("buttonCreator");
}
CM_MenuBarItem val = GOUtil.SpawnChildAndGetComp<CM_MenuBarItem>(MenuBar.m_menuBarItemPrefab, ((Component)MenuBar).transform);
((RectTransformComp)val).SetAnchor((GuiAnchor)2, true);
val.Setup(MenuBar.m_root, page);
((RectTransformComp)val).SetVisible(false);
T val2 = buttonCreator(this, val);
if (insertIndex < leftButtons.Count)
{
leftButtons.Insert(insertIndex, val2);
}
else
{
leftButtons.Add(val2);
}
return val2;
}
public void RefreshMenuButtons()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
float num = 0f;
foreach (MenuBarButton leftButton in leftButtons)
{
bool shouldBeVisible = leftButton.ShouldBeVisible;
((RectTransformComp)leftButton.Item).SetVisible(shouldBeVisible);
if (shouldBeVisible)
{
leftButton.Item.SetXOffset(num);
num += Mathf.Max(((RectTransformComp)leftButton.Item).GetSize().x, MenuBar.m_buttonLeftSpacing);
}
}
float num2 = 0f;
foreach (MenuBarButton rightButton in rightButtons)
{
bool shouldBeVisible2 = rightButton.ShouldBeVisible;
((RectTransformComp)rightButton.Item).SetVisible(shouldBeVisible2);
if (shouldBeVisible2)
{
Vector2 position = ((RectTransformComp)rightButton.Item).GetPosition();
rightButton.Item.SetXOffset(0f - num2);
((RectTransformComp)rightButton.Item).SetPosition(new Vector2(0f - num2, position.y));
num2 += Mathf.Max(((RectTransformComp)rightButton.Item).GetSize().x, MenuBar.m_buttonRightSpacing);
}
}
((RectTransformComp)MenuBar.m_expIcon).SetPosition(new Vector2(0f - num2 - 280f, 0f));
}
internal void SetVisible(bool visible)
{
((Component)MenuBar).gameObject.SetActive(visible);
if (!visible)
{
MenuBar.m_background.SetActive(false);
foreach (MenuBarButton leftButton in leftButtons)
{
((RectTransformComp)leftButton.Item).SetVisible(false);
}
{
foreach (MenuBarButton rightButton in rightButtons)
{
((RectTransformComp)rightButton.Item).SetVisible(false);
}
return;
}
}
if (!CM_MenuBar.RevealPlayed)
{
CoroutineManager.BlinkIn(MenuBar.m_background, 0f);
float num = 0.5f;
foreach (MenuBarButton leftButton2 in leftButtons)
{
((RectTransformComp)leftButton2.Item).SetVisible(false);
if (leftButton2.ShouldBeVisible)
{
CoroutineManager.BlinkIn((CM_Item)(object)leftButton2.Item, num, (Transform)null);
num += 0.15f;
}
}
foreach (MenuBarButton rightButton2 in rightButtons)
{
((RectTransformComp)rightButton2.Item).SetVisible(false);
if (rightButton2.ShouldBeVisible)
{
CoroutineManager.BlinkIn((CM_Item)(object)rightButton2.Item, num, (Transform)null);
num += 0.15f;
}
}
MenuBar.m_updateMenuTimer = Clock.Time + num + 0.75f;
CM_MenuBar.RevealPlayed = true;
}
else
{
MenuBar.m_background.SetActive(true);
RefreshMenuButtons();
}
}
internal static void AddHandler(CM_MenuBar menuBar)
{
if ((Object)(object)menuBar == (Object)null)
{
return;
}
MenuBarHandlerComponent menuBarHandlerComponent = ((Component)menuBar).gameObject.GetComponent<MenuBarHandlerComponent>();
if ((Object)(object)menuBarHandlerComponent != (Object)null)
{
if (menuBarHandlerComponent.Handler != null)
{
return;
}
}
else
{
menuBarHandlerComponent = ((Component)menuBar).gameObject.AddComponent<MenuBarHandlerComponent>();
}
menuBarHandlerComponent.Handler = new MenuBarHandler(menuBar);
MenuBarHandler.CreateButtons?.Invoke(menuBarHandlerComponent.Handler);
menuBarHandlerComponent.Handler.RefreshMenuButtons();
}
}
internal sealed class MenuBarHandlerComponent : MonoBehaviour
{
[HideFromIl2Cpp]
public MenuBarHandler Handler { get; set; }
public MenuBarHandlerComponent(nint ptr)
: base((IntPtr)ptr)
{
}
static MenuBarHandlerComponent()
{
ClassInjector.RegisterTypeInIl2Cpp<MenuBarHandlerComponent>();
}
}
internal static class PluginInfo
{
public const string NAME = "CustomMenuBarButtons";
public const string GUID = "dev.flaff.gtfo.CustomMenuBarButtons";
public const string VERSION = "0.1.1";
}
}
namespace CustomMenuBarButtons.Patches
{
[HarmonyPatch]
internal static class CM_MenuBarPatches
{
[HarmonyPatch(typeof(CM_MenuBar), "Setup")]
[HarmonyPostfix]
[HarmonyWrapSafe]
public static void Setup(CM_MenuBar __instance)
{
MenuBarHandler.AddHandler(__instance);
}
[HarmonyPatch(typeof(CM_MenuBar), "UpdateMenuOptions")]
[HarmonyPrefix]
[HarmonyWrapSafe]
public static bool UpdateMenuOptions(CM_MenuBar __instance)
{
MenuBarHandlerComponent component = ((Component)__instance).gameObject.GetComponent<MenuBarHandlerComponent>();
if ((Object)(object)component == (Object)null || component.Handler == null)
{
return true;
}
component.Handler.RefreshMenuButtons();
return false;
}
[HarmonyPatch(typeof(CM_MenuBar), "SetVisible")]
[HarmonyPrefix]
[HarmonyWrapSafe]
public static bool UpdateMenuOptions(CM_MenuBar __instance, bool visible)
{
MenuBarHandlerComponent component = ((Component)__instance).gameObject.GetComponent<MenuBarHandlerComponent>();
if ((Object)(object)component == (Object)null || component.Handler == null)
{
return true;
}
component.Handler.SetVisible(visible);
return false;
}
}
}