mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
rename mod & add settings
This commit is contained in:
parent
ef3efc001d
commit
28347e45a4
8 changed files with 39 additions and 20 deletions
34
FuckMetrics/FuckMetrics.cs
Normal file
34
FuckMetrics/FuckMetrics.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.IO;
|
||||
|
||||
namespace NAK.Melons.FuckMetrics
|
||||
{
|
||||
public static class FuckMetrics
|
||||
{
|
||||
public static void ToggleMetrics(bool disable)
|
||||
{
|
||||
var job = SchedulerSystem.Instance.activeJobs.FirstOrDefault(pair => pair.Job.Method.Name == "UpdateMetrics").Job;
|
||||
if (!disable && job == null)
|
||||
{
|
||||
SchedulerSystem.AddJob(new SchedulerSystem.Job(ViewManager.Instance.UpdateMetrics), 0f, 0.5f, -1);
|
||||
}
|
||||
else if (disable && job != null)
|
||||
{
|
||||
SchedulerSystem.RemoveJob(job);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ToggleCoreUpdates(bool disable)
|
||||
{
|
||||
var job = SchedulerSystem.Instance.activeJobs.FirstOrDefault(pair => pair.Job.Method.Name == "SendCoreUpdate").Job;
|
||||
if (!disable && job == null)
|
||||
{
|
||||
SchedulerSystem.AddJob(new SchedulerSystem.Job(CVR_MenuManager.Instance.SendCoreUpdate), 0f, 0.1f, -1);
|
||||
}
|
||||
else if (disable && job != null)
|
||||
{
|
||||
SchedulerSystem.RemoveJob(job);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
FuckMetrics/FuckMetrics.csproj
Normal file
44
FuckMetrics/FuckMetrics.csproj
Normal 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:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>ManagedLibs\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp-firstpass">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="cohtml.Net">
|
||||
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cohtml.Runtime">
|
||||
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MelonLoader">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.InputLegacyModule">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\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>
|
25
FuckMetrics/FuckMetrics.sln
Normal file
25
FuckMetrics/FuckMetrics.sln
Normal 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}") = "FuckMetrics", "FuckMetrics.csproj", "{D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D2625DDC-48EA-4390-8B4C-69D1E4E9C5E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CE55D93A-682A-47F4-A971-65132B854210}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
58
FuckMetrics/HarmonyPatches.cs
Normal file
58
FuckMetrics/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Player;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace NAK.Melons.FuckMetrics.HarmonyPatches;
|
||||
|
||||
class PlayerSetupPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), "Start")]
|
||||
private static void Postfix_PlayerSetup_Start()
|
||||
{
|
||||
FuckMetrics.ToggleMetrics(FuckMetricsMod.EntryDisableMetrics.Value == FuckMetricsMod.SettingState.Enabled);
|
||||
FuckMetrics.ToggleCoreUpdates(FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.Enabled);
|
||||
}
|
||||
}
|
||||
|
||||
class CVR_MenuManagerPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
|
||||
private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
|
||||
{
|
||||
if (FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.Disabled) return;
|
||||
|
||||
if (FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.MenuOnly)
|
||||
{
|
||||
FuckMetrics.ToggleMetrics(show);
|
||||
FuckMetrics.ToggleCoreUpdates(show);
|
||||
}
|
||||
else if (show)
|
||||
{
|
||||
ViewManager.Instance.UpdateMetrics();
|
||||
CVR_MenuManager.Instance.SendCoreUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ViewManagerPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
|
||||
private static void Postfix_ViewManager_UiStateToggle(bool show)
|
||||
{
|
||||
if (FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.Disabled) return;
|
||||
|
||||
if (FuckMetricsMod.EntryDisableCoreUpdates.Value == FuckMetricsMod.SettingState.MenuOnly)
|
||||
{
|
||||
FuckMetrics.ToggleMetrics(show);
|
||||
FuckMetrics.ToggleCoreUpdates(show);
|
||||
}
|
||||
else if (show)
|
||||
{
|
||||
ViewManager.Instance.UpdateMetrics();
|
||||
CVR_MenuManager.Instance.SendCoreUpdate();
|
||||
}
|
||||
}
|
||||
}
|
57
FuckMetrics/Main.cs
Normal file
57
FuckMetrics/Main.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using MelonLoader;
|
||||
|
||||
namespace NAK.Melons.FuckMetrics;
|
||||
|
||||
public class FuckMetricsMod : MelonMod
|
||||
{
|
||||
public static MelonLogger.Instance Logger;
|
||||
|
||||
public const string SettingsCategory = "FuckMetrics";
|
||||
public static readonly MelonPreferences_Category CategoryFuckMetrics = MelonPreferences.CreateCategory(SettingsCategory);
|
||||
|
||||
public static readonly MelonPreferences_Entry<SettingState> EntryDisableMetrics =
|
||||
CategoryFuckMetrics.CreateEntry("Menu Metrics", SettingState.MenuOnly, description: "Disables menu metrics (FPS & Ping). Updates once on menu open if disabled.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<SettingState> EntryDisableCoreUpdates =
|
||||
CategoryFuckMetrics.CreateEntry("Menu Core Updates", SettingState.MenuOnly, description: "Disables menu core updates (Gamerule Icons & Debug Status). Updates once on menu open if disabled.");
|
||||
|
||||
public enum SettingState
|
||||
{
|
||||
Enabled,
|
||||
MenuOnly,
|
||||
Disabled
|
||||
}
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
Logger = LoggerInstance;
|
||||
EntryDisableMetrics.OnEntryValueChangedUntyped.Subscribe(OnDisableMetrics);
|
||||
EntryDisableCoreUpdates.OnEntryValueChangedUntyped.Subscribe(OnDisableCoreUpdates);
|
||||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
ApplyPatches(typeof(HarmonyPatches.CVR_MenuManagerPatches));
|
||||
ApplyPatches(typeof(HarmonyPatches.ViewManagerPatches));
|
||||
}
|
||||
|
||||
private void OnDisableMetrics(object arg1, object arg2)
|
||||
{
|
||||
FuckMetrics.ToggleMetrics(EntryDisableMetrics.Value == SettingState.Enabled);
|
||||
}
|
||||
|
||||
private void OnDisableCoreUpdates(object arg1, object arg2)
|
||||
{
|
||||
FuckMetrics.ToggleCoreUpdates(EntryDisableMetrics.Value == SettingState.Enabled);
|
||||
}
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance.PatchAll(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Msg($"Failed while patching {type.Name}!");
|
||||
Logger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
0
FuckMetrics/ManagedLibs/.keep
Normal file
0
FuckMetrics/ManagedLibs/.keep
Normal file
31
FuckMetrics/Properties/AssemblyInfo.cs
Normal file
31
FuckMetrics/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using MelonLoader;
|
||||
using NAK.Melons.FuckMetrics.Properties;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(NAK.Melons.FuckMetrics))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(NAK.Melons.FuckMetrics))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(NAK.Melons.FuckMetrics.FuckMetricsMod),
|
||||
nameof(NAK.Melons.FuckMetrics),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/FuckMetrics"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
[assembly: HarmonyDontPatchAll]
|
||||
|
||||
namespace NAK.Melons.FuckMetrics.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.1";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
24
FuckMetrics/format.json
Normal file
24
FuckMetrics/format.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"_id": -1,
|
||||
"name": "FuckMetrics",
|
||||
"modversion": "1.0.1",
|
||||
"gameversion": "2022r170",
|
||||
"loaderversion": "0.5.7",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "This mod disables UpdateMetrics & SendCoreUpdate on the menus while closed. This helps to alleviate any hitching and performance issues that may arise, particularly with FPS drops while unmuted in online instances.\n\nPlease view the Github README for more info.",
|
||||
"searchtags": [
|
||||
"cohtml",
|
||||
"menus",
|
||||
"quick",
|
||||
"fps",
|
||||
"performance"
|
||||
],
|
||||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/FuckMetrics/releases/download/v1.0.1/FuckMetrics.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/FuckMetrics/",
|
||||
"changelog": "- Initial Release\n- Renamed to FuckMetrics",
|
||||
"embedcolor": "#8ed6fb"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue