From 8c780bb72bc060df1a474eb72f4b723d7d3ca2cc Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Thu, 13 Apr 2023 19:15:28 -0500 Subject: [PATCH] init --- .../ClearHudNotifications.csproj | 44 +++++++++++++++++++ .../ClearHudNotifications.sln | 25 +++++++++++ ClearHudNotifications/HarmonyPatches.cs | 26 +++++++++++ ClearHudNotifications/Main.cs | 40 +++++++++++++++++ .../Properties/AssemblyInfo.cs | 31 +++++++++++++ ClearHudNotifications/format.json | 23 ++++++++++ 6 files changed, 189 insertions(+) create mode 100644 ClearHudNotifications/ClearHudNotifications.csproj create mode 100644 ClearHudNotifications/ClearHudNotifications.sln create mode 100644 ClearHudNotifications/HarmonyPatches.cs create mode 100644 ClearHudNotifications/Main.cs create mode 100644 ClearHudNotifications/Properties/AssemblyInfo.cs create mode 100644 ClearHudNotifications/format.json 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..2dc725f --- /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.ClearHudNoficiations.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)) + { + ClearHudNoficiations.ClearHudNotifications(); + 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..795ea00 --- /dev/null +++ b/ClearHudNotifications/Main.cs @@ -0,0 +1,40 @@ +using ABI_RC.Core.UI; +using MelonLoader; +using UnityEngine; + +namespace NAK.Melons.ClearHudNoficiations; + +public class ClearHudNoficiations : MelonMod +{ + public override void OnInitializeMelon() + { + ApplyPatches(typeof(HarmonyPatches.CohtmlHudPatches)); + } + + public override void OnUpdate() + { + if (Input.GetKeyDown(KeyCode.F4)) + { + ClearHudNotifications(); + } + } + + public static void ClearHudNotifications() + { + // 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..03b55ed --- /dev/null +++ b/ClearHudNotifications/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +using NAK.Melons.ClearHudNoficiations.Properties; +using MelonLoader; +using System.Reflection; + + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.Melons.ClearHudNoficiations))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.Melons.ClearHudNoficiations))] + +[assembly: MelonInfo( + typeof(NAK.Melons.ClearHudNoficiations.ClearHudNoficiations), + nameof(NAK.Melons.ClearHudNoficiations), + 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.ClearHudNoficiations.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