Decompiled source of MenuModList v1.0.0

MenuModList.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MenuModList;

[BepInPlugin("com.parallel53.menumodlist", "MenuModList", "1.0.0")]
public class MenuModListPlugin : BaseUnityPlugin
{
	private const float ReferenceHeight = 1080f;

	private const float PanelWidth = 260f;

	private const float Margin = 20f;

	private const int FontSize = 14;

	private const string GameFont = "AveriaSerifLibre-Bold";

	private string text;

	private int lineCount;

	private GUIStyle style;

	private bool logged;

	private void OnGUI()
	{
		//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_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_0092: Expected O, but got Unknown
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		FejdStartup instance = FejdStartup.instance;
		if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_mainMenu == (Object)null) && instance.m_mainMenu.activeInHierarchy)
		{
			if (text == null)
			{
				BuildText();
			}
			if (style == null)
			{
				style = new GUIStyle(GUI.skin.box)
				{
					alignment = (TextAnchor)0,
					font = FindGameFont(),
					fontSize = 14,
					richText = true,
					wordWrap = false,
					padding = new RectOffset(12, 12, 10, 10)
				};
				style.normal.textColor = Color.white;
			}
			float num = (float)Screen.height / 1080f;
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			float num2 = style.lineHeight * (float)lineCount + (float)style.padding.vertical;
			GUI.Box(new Rect((float)Screen.width / num - 260f - 20f, 20f, 260f, num2), text, style);
			if (!logged)
			{
				logged = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Showing mod list on main menu:\n" + text));
			}
		}
	}

	private Font FindGameFont()
	{
		Font[] source = Resources.FindObjectsOfTypeAll<Font>();
		Font val = ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name == "AveriaSerifLibre-Bold"));
		((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)(object)val != (Object)null) ? ("Using font " + ((Object)val).name + " (dynamic: " + val.dynamic + ")") : ("No AveriaSerifLibre-Bold font. Loaded: " + string.Join(", ", source.Select((Font f) => ((Object)f).name).ToArray()))));
		return val;
	}

	private void BuildText()
	{
		string[] array = (from p in Chainloader.PluginInfos.Values
			select p.Metadata.Name + " <color=#ffcc66>" + p.Metadata.Version?.ToString() + "</color>" into line
			orderby line
			select line).ToArray();
		string text = "<b>Mods loaded: " + array.Length + "</b>\nBepInEx " + typeof(BaseUnityPlugin).Assembly.GetName().Version;
		this.text = text + "\n" + string.Join("\n", array);
		lineCount = array.Length + 2;
	}
}