diff --git a/ClearHudNotifications/ClearHudNotifications.csproj b/ClearHudNotifications/ClearHudNotifications.csproj new file mode 100644 index 0000000..6dc7b11 --- /dev/null +++ b/ClearHudNotifications/ClearHudNotifications.csproj @@ -0,0 +1,44 @@ + + + + + net472 + enable + latest + false + True + + + + + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\0Harmony.dll + + + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\Assembly-CSharp.dll + + + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\Assembly-CSharp-firstpass.dll + + + ..\..\..\_ManagedLibs\cohtml.Net.dll + + + ..\..\..\_ManagedLibs\Cohtml.Runtime.dll + + + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\MelonLoader.dll + + + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\UnityEngine.CoreModule.dll + + + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\UnityEngine.InputLegacyModule.dll + + + + + + + + + diff --git a/ClearHudNotifications/ClearHudNotifications.sln b/ClearHudNotifications/ClearHudNotifications.sln new file mode 100644 index 0000000..5ae6fd6 --- /dev/null +++ b/ClearHudNotifications/ClearHudNotifications.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32630.192 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClearHudNotifications", "ClearHudNotifications.csproj", "{753B581A-1D5F-413C-93D8-ADE3193E825C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {753B581A-1D5F-413C-93D8-ADE3193E825C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {753B581A-1D5F-413C-93D8-ADE3193E825C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {753B581A-1D5F-413C-93D8-ADE3193E825C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {753B581A-1D5F-413C-93D8-ADE3193E825C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B69DA489-5322-4E63-9795-EEA831017CC8} + EndGlobalSection +EndGlobal diff --git a/ClearHudNotifications/HarmonyPatches.cs b/ClearHudNotifications/HarmonyPatches.cs new file mode 100644 index 0000000..7086c46 --- /dev/null +++ b/ClearHudNotifications/HarmonyPatches.cs @@ -0,0 +1,26 @@ +using ABI_RC.Core.Savior; +using ABI_RC.Core.UI; +using cohtml; +using HarmonyLib; + +namespace NAK.Melons.ClearHudNotifications.HarmonyPatches; + +internal static class CohtmlHudPatches +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(CohtmlHud), nameof(CohtmlHud.ViewDropText), new Type[] { typeof(string), typeof(string), typeof(string) })] + private static bool Prefix_CohtmlHud_ViewDropText(string cat, string headline, string small, ref CohtmlHud __instance) + { + if (!headline.Contains(MetaPort.Instance.username)) return true; // we only want our username notification + + if (small == "A user has joined your Instance." && !MetaPort.Instance.settings.GetSettingsBool("HUDCustomizationPlayerJoins", false)) + { + ClearHudNotifications.ClearNotifications(); + return false; + } + + // clears buffer + if (__instance._isReady) __instance.hudView.View.TriggerEvent("DisplayHudMessageImmediately", cat, headline, small, 3); + return false; + } +} \ No newline at end of file diff --git a/ClearHudNotifications/Main.cs b/ClearHudNotifications/Main.cs new file mode 100644 index 0000000..6fceae9 --- /dev/null +++ b/ClearHudNotifications/Main.cs @@ -0,0 +1,40 @@ +using ABI_RC.Core.UI; +using MelonLoader; +using UnityEngine; + +namespace NAK.Melons.ClearHudNotifications; + +public class ClearHudNotifications : MelonMod +{ + public override void OnInitializeMelon() + { + ApplyPatches(typeof(HarmonyPatches.CohtmlHudPatches)); + } + + public override void OnUpdate() + { + if (Input.GetKeyDown(KeyCode.F4)) + { + ClearNotifications(); + } + } + + public static void ClearNotifications() + { + // sending an immediate notification clears buffer + CohtmlHud.Instance?.ViewDropTextImmediate("(Local) Client", "Notifications Cleared!", "Cleared Hud Notifications!"); + } + + void ApplyPatches(Type type) + { + try + { + HarmonyInstance.PatchAll(type); + } + catch (Exception e) + { + LoggerInstance.Msg($"Failed while patching {type.Name}!"); + LoggerInstance.Error(e); + } + } +} \ No newline at end of file diff --git a/ClearHudNotifications/Properties/AssemblyInfo.cs b/ClearHudNotifications/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e754ce5 --- /dev/null +++ b/ClearHudNotifications/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using NAK.Melons.ClearHudNotifications.Properties; +using MelonLoader; +using System.Reflection; + + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.Melons.ClearHudNotifications))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.Melons.ClearHudNotifications))] + +[assembly: MelonInfo( + typeof(NAK.Melons.ClearHudNotifications.ClearHudNotifications), + nameof(NAK.Melons.ClearHudNotifications), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidOnSteam/UndoPropButton" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] +[assembly: HarmonyDontPatchAll] + +namespace NAK.Melons.ClearHudNotifications.Properties; +internal static class AssemblyInfoParams +{ + public const string Version = "1.0.0"; + public const string Author = "NotAKidoS"; +} \ No newline at end of file diff --git a/ClearHudNotifications/format.json b/ClearHudNotifications/format.json new file mode 100644 index 0000000..3bd0267 --- /dev/null +++ b/ClearHudNotifications/format.json @@ -0,0 +1,23 @@ +{ + "_id": -1, + "name": "ClearHudNotifications", + "modversion": "1.0.0", + "gameversion": "2022r170", + "loaderversion": "0.5.7", + "modtype": "Mod", + "author": "NotAKidoS", + "description": "Clears queued hud notifications when joining a new online instance. Can also press F4 to manually clear notifications.", + "searchtags": [ + "hud", + "queue", + "notifications", + "clear" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidOnSteam/ClearHudNotifications/releases/download/v1.0.0/ClearHudNotifications.dll", + "sourcelink": "https://github.com/NotAKidOnSteam/ClearHudNotifications/", + "changelog": "- Initial Release", + "embedcolor": "#6495ED" +} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 262b1ec..4480281 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 NotAKidoS +Copyright (c) 2023 NotAKidoS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 0682c56..02dae3e 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ Uses modified version of Popcron.Gizmos: https://github.com/popcron/gizmos ![ChilloutVR_vQAWKRkt73](https://user-images.githubusercontent.com/37721153/190173732-368dec7a-d56e-47a0-bc38-3c7f38caa0bc.png) +# ClearHudNotifications + +Simple mod to clear hud notifications when joining an online instance. Can also manually clear notifications by pressing F4. + +There is no native method to clear notifications, so I force an immediate notification to clear the buffer. ---