Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NoBackgroundHover v1.0.1
NoBackgroundHover.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using NoBackgroundHover.Patches; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("NoBackgroundHover")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("toejune")] [assembly: AssemblyProduct("NoBackgroundHover")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("563263f8-d8ed-4f62-9416-c31df24326f5")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace NoBackgroundHover { [BepInPlugin("toejune.NoBackgroundHover", "NoBackgroundHover", "1.0")] public class NoBackgroundHoverBase : BaseUnityPlugin { private const string modGUID = "toejune.NoBackgroundHover"; private const string modName = "NoBackgroundHover"; private const string modVersion = "1.0"; private readonly Harmony harmony = new Harmony("toejune.NoBackgroundHover"); private static NoBackgroundHoverBase Instance; internal static ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("toejune.NoBackgroundHover"); mls.LogInfo((object)"NoBackgroundHover started."); harmony.PatchAll(typeof(NoBackgroundHoverBase)); harmony.PatchAll(typeof(NoBackgroundHover.Patches.NoBackgroundHover)); harmony.PatchAll(typeof(NoBackgroundHover_Stub)); } } } namespace NoBackgroundHover.Patches { [HarmonyPatch(typeof(MenuHolder))] internal class NoBackgroundHover { private static bool _focused = false; private static bool _lastFocused = true; private static bool _menuButtonsInitialized = false; private static bool _menuElementsHoverInitialized = false; [DllImport("user32.dll")] private static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll")] private static extern IntPtr GetActiveWindow(); private static bool IsGameFocused() { return GetForegroundWindow() == GetActiveWindow(); } [HarmonyPatch(typeof(MenuHolder), "Start")] [HarmonyPostfix] public static void Start(MenuHolder __instance) { HandleFocus(ref __instance); } [HarmonyPatch(typeof(MenuHolder), "Update")] [HarmonyPrefix] public static void Update_Prefix(MenuHolder __instance) { HandleFocus(ref __instance); } private static void HandleFocus(ref MenuHolder instance, bool forceUpdate = false) { if (!_menuButtonsInitialized) { _menuButtonsInitialized = Initialize<MenuButton, NoBackgroundHover_Stub>(ref instance, zeroCheck: true); } if (!_menuElementsHoverInitialized) { _menuElementsHoverInitialized = Initialize<MenuElementHover, NoBackgroundHover_Stub>(ref instance, zeroCheck: false); } if (!_menuButtonsInitialized || !_menuElementsHoverInitialized) { return; } _focused = IsGameFocused(); if (_focused != _lastFocused || forceUpdate) { MenuElementHover[] componentsInChildren = ((Component)instance).GetComponentsInChildren<MenuElementHover>(); foreach (MenuElementHover val in componentsInChildren) { ((Behaviour)val).enabled = _focused; } MenuButton[] componentsInChildren2 = ((Component)instance).GetComponentsInChildren<MenuButton>(); foreach (MenuButton val2 in componentsInChildren2) { ((Behaviour)val2).enabled = _focused; } _lastFocused = _focused; } } private static bool Initialize<TFind, TTarget>(ref MenuHolder instance, bool zeroCheck = true) where TFind : Component { int num = 0; int num2 = ((Component)instance).GetComponentsInChildren<TFind>().Length; TFind[] componentsInChildren = ((Component)instance).GetComponentsInChildren<TFind>(); foreach (TFind val in componentsInChildren) { GameObject gameObject = ((Component)val).gameObject; NoBackgroundHover_Stub noBackgroundHover_Stub = gameObject.GetComponent<NoBackgroundHover_Stub>(); if (!Object.op_Implicit((Object)(object)noBackgroundHover_Stub)) { noBackgroundHover_Stub = gameObject.AddComponent<NoBackgroundHover_Stub>(); } if (noBackgroundHover_Stub.IsInitialized()) { num++; } } return num == num2 && ((zeroCheck && num2 != 0) || !zeroCheck); } } [HarmonyPatch(typeof(MenuButton))] internal class NoBackgroundHover_Stub : MonoBehaviour { private static bool _initialized; [DllImport("user32.dll")] private static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll")] private static extern IntPtr GetActiveWindow(); private static bool IsGameFocused() { return GetForegroundWindow() == GetActiveWindow(); } public bool IsInitialized() { return _initialized; } [HarmonyPatch(typeof(MenuButton), "Awake")] [HarmonyPostfix] public static void Awake_Postfix(MenuButton __instance) { ((Behaviour)__instance).enabled = IsGameFocused(); _initialized = true; } } }