Merge remote-tracking branch 'ClearHudNotifications/main'

Merged ClearHudNotifications
This commit is contained in:
NotAKidoS 2023-04-16 06:42:31 -05:00
commit 8a130550bd
8 changed files with 195 additions and 1 deletions

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="cohtml.Net">
<HintPath>..\..\..\_ManagedLibs\cohtml.Net.dll</HintPath>
</Reference>
<Reference Include="Cohtml.Runtime">
<HintPath>..\..\..\_ManagedLibs\Cohtml.Runtime.dll</HintPath>
</Reference>
<Reference Include="MelonLoader">
<HintPath>C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\MelonLoader.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
</ItemGroup>
<Target Name="Deploy" AfterTargets="Build">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" />
<Message Text="Copied $(TargetPath) to C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" Importance="high" />
</Target>
</Project>

View file

@ -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

View file

@ -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;
}
}

View file

@ -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);
}
}
}

View file

@ -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";
}

View file

@ -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"
}

View file

@ -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

View file

@ -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.
---