Decompiled source of LBoL InGameMuseum v0.1.0

LBoL_InGameMuseum.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LBoL.Presentation;
using LBoL.Presentation.UI;
using LBoL.Presentation.UI.Panels;
using UnityEngine;
using UnityEngine.EventSystems;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LBoL_Encyclopedia")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LBoL_Encyclopedia")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dfe4ba63-d15d-4726-b7c0-6718d88b5b9d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LBoL_InGameMuseum;

[BepInProcess("LBoL.exe")]
[BepInPlugin("marrollar.lbol.ingamemuseum", "LBoL InGameMuseum", "0.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class InGameMuseumPlugin : BaseUnityPlugin
{
	private const string mod_guid = "marrollar.lbol.ingamemuseum";

	private const string mod_name = "LBoL InGameMuseum";

	private const string mod_version = "0.1.0";

	private static readonly Harmony harmony = new Harmony("marrollar.lbol.ingamemuseum");

	internal static ManualLogSource log;

	public static ConfigEntry<KeyboardShortcut> ShowMuseumKey;

	private void Awake()
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		log = ((BaseUnityPlugin)this).Logger;
		log.LogInfo((object)"InGameMuseum plugin awake");
		if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
		{
			WatermarkWrapper.ActivateWatermark();
		}
		ShowMuseumKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "ShowMuseumKey", new KeyboardShortcut((KeyCode)112, Array.Empty<KeyCode>()), new ConfigDescription("Shows Museum", (AcceptableValueBase)null, Array.Empty<object>()));
		harmony.PatchAll();
	}

	private void OnDestroy()
	{
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	private void Update()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)UiManager.Instance != (Object)null)
		{
			KeyboardShortcut value = ShowMuseumKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				MuseumPanelPatches.ShowMuseumPanel();
			}
		}
	}
}
[HarmonyPatch(typeof(SystemBoard))]
internal class DeckButtonPatches
{
	private class ShowMuseumListener : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
	{
		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)eventData.button == 1)
			{
				InGameMuseumPlugin.log.LogDebug((object)"Deck right clicked");
				MuseumPanelPatches.ShowMuseumPanel();
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch("Awake")]
	public static void Patch_AddRightClickDeck(SystemBoard __instance)
	{
		GameObject gameObject = ((Component)__instance.deckButton).gameObject;
		if ((Object)(object)gameObject.GetComponent<ShowMuseumListener>() == (Object)null)
		{
			InGameMuseumPlugin.log.LogDebug((object)"Adding right click only listener to SystemBoard's Deck button");
			gameObject.AddComponent<ShowMuseumListener>();
		}
	}
}
[HarmonyPatch(typeof(GameMaster))]
internal class MuseumPanelPatches
{
	internal static void ShowMuseumPanel()
	{
		try
		{
			if (((UiBase)UiManager.GetPanel<MuseumPanel>()).IsVisible)
			{
				InGameMuseumPlugin.log.LogDebug((object)"MuseumPanel toggle off");
				UiManager.Hide<MuseumPanel>(true);
			}
			else
			{
				InGameMuseumPlugin.log.LogDebug((object)"MuseumPanel toggle on");
				UiManager.Show<MuseumPanel>();
			}
		}
		catch (InvalidOperationException ex)
		{
			InGameMuseumPlugin.log.LogError((object)ex);
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch("CoSetupGameRun")]
	private static void Patch_RetainMuseumPanel()
	{
		if (GameMaster.MainMenuUiList.Contains(typeof(MuseumPanel)))
		{
			InGameMuseumPlugin.log.LogDebug((object)"MuseumPanel removed before unload due to game start");
			GameMaster.MainMenuUiList.Remove(typeof(MuseumPanel));
			InGameMuseumPlugin.log.LogDebug((object)"MuseumPanel parentage moved to TopmostLayer");
			GameObject val = GameObject.Find("UICamera/Canvas/Root/NormalLayer/MuseumPanel");
			GameObject val2 = GameObject.Find("UICamera/Canvas/Root/TopmostLayer");
			val.transform.SetParent(val2.transform, false);
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch("CoLeaveGameRun")]
	private static void Patch_RemoveMuseumPanel()
	{
		try
		{
			InGameMuseumPlugin.log.LogDebug((object)"MuseumPanel unloaded successfully");
			UiManager.UnloadPanel<MuseumPanel>();
		}
		catch (InvalidOperationException)
		{
			InGameMuseumPlugin.log.LogDebug((object)"MuseumPanel not found during unload attempt");
		}
	}
}
internal class WatermarkWrapper
{
	[MethodImpl(MethodImplOptions.NoInlining)]
	internal static void ActivateWatermark()
	{
		API.ActivateWatermark();
	}
}