using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("MenuLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0")]
[assembly: AssemblyProduct("MenuLib")]
[assembly: AssemblyTitle("MenuLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MenuLib
{
public class MenuEntry
{
public string Id { get; set; }
public string Name { get; set; }
public List<MenuEntry> Children { get; private set; } = new List<MenuEntry>();
public List<MenuOption> Options { get; private set; } = new List<MenuOption>();
public MenuEntry(string id, string name)
{
Id = id;
Name = name;
}
public MenuEntry Register(MenuEntry submenu)
{
Children.Add(submenu);
return this;
}
public MenuEntry Register(MenuOption option)
{
Options.Add(option);
return this;
}
}
public class MenuOption
{
public string Id { get; set; }
public string Name { get; set; }
public List<string> Options { get; set; } = new List<string>();
public Action<string>? OnChange { get; set; }
public MenuOption(string id, string name, List<string> options, Action<string>? onChange = null)
{
Id = id;
Name = name;
Options = options;
OnChange = onChange;
}
}
public static class MenuLib
{
public static List<MenuEntry> MainMenus { get; } = new List<MenuEntry>();
public static void Register(MenuEntry menu)
{
MainMenus.Add(menu);
}
}
[BepInPlugin("MenuLib", "MenuLib", "0.2.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <WaitForMenuLoop>d__2 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private GameObject <optionController>5__2;
private GameObject <navRoot>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForMenuLoop>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<optionController>5__2 = null;
<navRoot>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<optionController>5__2 = null;
goto IL_0052;
case 1:
<>1__state = -1;
goto IL_0052;
case 2:
{
<>1__state = -1;
goto IL_00aa;
}
IL_0052:
if ((Object)(object)<optionController>5__2 == (Object)null)
{
<optionController>5__2 = GameObject.Find("[UI MANAGER]/[UI Layer] - PAUSE/OptionsMenuController(Clone)/");
<>2__current = null;
<>1__state = 1;
return true;
}
goto IL_00bf;
IL_00bf:
if (<optionController>5__2 != null)
{
Logger.LogInfo((object)"Found menu objects, cloning OptionPrefab...");
<navRoot>5__3 = GameObject.Find("[UI MANAGER]/[UI Layer] - PAUSE/OptionsMenuController(Clone)/Visuals/SettingsMenu/Navigation");
goto IL_00aa;
}
goto IL_0052;
IL_00aa:
if ((Object)(object)<navRoot>5__3 != (Object)null)
{
<navRoot>5__3 = GameObject.Find("[UI MANAGER]/[UI Layer] - PAUSE/OptionsMenuController(Clone)/Visuals/SettingsMenu/Navigation");
<>2__current = null;
<>1__state = 2;
return true;
}
<navRoot>5__3 = null;
goto IL_00bf;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal static ManualLogSource Logger;
private void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin loaded!");
new Harmony("com.cosita3cz.MenuLib").PatchAll();
}
private IEnumerator WaitForMenuLoop()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForMenuLoop>d__2(0);
}
private void CloneOptionPrefab(string id, string text, bool active, GameObject navRoot)
{
GameObject val = GameObject.Find("[UI MANAGER]/[UI Layer] - PAUSE/OptionsMenuController(Clone)/Visuals/Prefabs/OptionPrefab");
if ((Object)(object)val == (Object)null || (Object)(object)navRoot == (Object)null)
{
Logger.LogError((object)"Couldn't locate required objects.");
return;
}
GameObject obj = Object.Instantiate<GameObject>(val, navRoot.transform);
((Object)obj).name = id;
obj.SetActive(active);
Component val2 = ((IEnumerable<Component>)obj.GetComponentsInChildren<Component>(true)).FirstOrDefault((Func<Component, bool>)((Component c) => ((object)c).GetType().FullName == "TMPro.TextMeshProUGUI"));
if ((Object)(object)val2 != (Object)null)
{
((object)val2).GetType().GetProperty("text")?.SetValue(val2, text, null);
}
Logger.LogInfo((object)"OptionPrefab cloned");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MenuLib";
public const string PLUGIN_NAME = "MenuLib";
public const string PLUGIN_VERSION = "0.2.0";
}
}