diff --git a/MuteSFX/AudioModuleManager.cs b/MuteSFX/AudioModuleManager.cs new file mode 100644 index 0000000..b999fac --- /dev/null +++ b/MuteSFX/AudioModuleManager.cs @@ -0,0 +1,49 @@ +using ABI_RC.Core.AudioEffects; +using System.Reflection; +using UnityEngine; + +namespace NAK.MuteSFX; + +public static class AudioModuleManager +{ + public const string sfx_mute = "MuteSFX_sfx_mute"; + public const string sfx_unmute = "MuteSFX_sfx_unmute"; + + public static void SetupDefaultAudioClips() + { + string path = Application.streamingAssetsPath + "/Cohtml/UIResources/GameUI/mods/MuteSFX/audio/"; + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + MuteSFX.Logger.Msg("Created MuteSFX/audio directory!"); + } + + string[] clipNames = { "sfx_mute.wav", "sfx_unmute.wav" }; + foreach (string clipName in clipNames) + { + string clipPath = Path.Combine(path, clipName); + if (!File.Exists(clipPath)) + { + byte[] clipData = null; + string resourceName = "MuteSFX.SFX." + clipName; + using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) + { + clipData = new byte[stream.Length]; + stream.Read(clipData, 0, clipData.Length); + } + + using (FileStream fileStream = new FileStream(clipPath, FileMode.CreateNew)) + { + fileStream.Write(clipData, 0, clipData.Length); + } + + MuteSFX.Logger.Msg("Placed missing sfx in audio folder: " + clipName); + } + } + } + + public static void PlayAudioModule(string module) + { + InterfaceAudio.PlayModule(module); + } +} \ No newline at end of file diff --git a/MuteSFX/Main.cs b/MuteSFX/Main.cs new file mode 100644 index 0000000..f809356 --- /dev/null +++ b/MuteSFX/Main.cs @@ -0,0 +1,35 @@ +using ABI_RC.Core.Base; +using MelonLoader; +using System.Reflection; + +namespace NAK.MuteSFX; + +public class MuteSFX : MelonMod +{ + internal static MelonLogger.Instance Logger; + internal const string SettingsCategory = nameof(MuteSFX); + + public static readonly MelonPreferences_Category Category = + MelonPreferences.CreateCategory(SettingsCategory); + + public static readonly MelonPreferences_Entry EntryEnabled = + Category.CreateEntry("Enabled", true, description: "Toggle MuteSFX entirely."); + + public override void OnInitializeMelon() + { + Logger = LoggerInstance; + + HarmonyInstance.Patch( + typeof(Audio).GetMethod(nameof(Audio.SetMicrophoneActive)), + postfix: new HarmonyLib.HarmonyMethod(typeof(MuteSFX).GetMethod(nameof(OnSetMicrophoneActive_Postfix), BindingFlags.NonPublic | BindingFlags.Static)) + ); + + AudioModuleManager.SetupDefaultAudioClips(); + } + + private static void OnSetMicrophoneActive_Postfix(bool muted) + { + if (EntryEnabled.Value) + AudioModuleManager.PlayAudioModule(muted ? AudioModuleManager.sfx_mute : AudioModuleManager.sfx_unmute); + } +} \ No newline at end of file diff --git a/MuteSFX/MuteSFX.csproj b/MuteSFX/MuteSFX.csproj new file mode 100644 index 0000000..21b218c --- /dev/null +++ b/MuteSFX/MuteSFX.csproj @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/MuteSFX/Properties/AssemblyInfo.cs b/MuteSFX/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..14016f9 --- /dev/null +++ b/MuteSFX/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using MelonLoader; +using NAK.MuteSFX.Properties; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.MuteSFX))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.MuteSFX))] + +[assembly: MelonInfo( + typeof(NAK.MuteSFX.MuteSFX), + nameof(NAK.MuteSFX), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/MuteSFX" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] + +namespace NAK.MuteSFX.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/MuteSFX/README.md b/MuteSFX/README.md new file mode 100644 index 0000000..91c2637 --- /dev/null +++ b/MuteSFX/README.md @@ -0,0 +1,18 @@ +# MuteSFX + +A simple mod that makes the CVR_DesktopCameraController defaultFov adjustable. + +The custom FOV setting is ignored if a world author specified a FOV other than 60f. + +It is limited between 60f and 120f to match the limitations world creators have with setting custom FOV. + +--- + +Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI. +https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games + +> This mod is an independent creation and is not affiliated with, supported by or approved by Alpha Blend Interactive. + +> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use. + +> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive. diff --git a/MuteSFX/SFX/sfx_mute.wav b/MuteSFX/SFX/sfx_mute.wav new file mode 100644 index 0000000..e1ec432 Binary files /dev/null and b/MuteSFX/SFX/sfx_mute.wav differ diff --git a/MuteSFX/SFX/sfx_unmute.wav b/MuteSFX/SFX/sfx_unmute.wav new file mode 100644 index 0000000..0820918 Binary files /dev/null and b/MuteSFX/SFX/sfx_unmute.wav differ diff --git a/MuteSFX/format.json b/MuteSFX/format.json new file mode 100644 index 0000000..b8f18e2 --- /dev/null +++ b/MuteSFX/format.json @@ -0,0 +1,23 @@ +{ + "_id": -1, + "name": "MuteSFX", + "modversion": "1.0.0", + "gameversion": "2022r170p1", + "loaderversion": "0.6.1", + "modtype": "Mod", + "author": "Exterrata & NotAKidoS", + "description": "A simple mod to add an audio queue for muting and unmuting.\n\nYou can replace the sfx in 'ChilloutVR\\ChilloutVR_Data\\StreamingAssets\\Cohtml\\UIResources\\GameUI\\mods\\MuteSFX\\audio'.", + "searchtags": [ + "mute", + "unmute", + "audio", + "sound" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r13/MuteSFX.dll", + "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/MuteSFX/", + "changelog": "- Initial CVRMG release", + "embedcolor": "92e492" +} \ No newline at end of file diff --git a/NAK_CVR_Mods.sln b/NAK_CVR_Mods.sln index 62b3786..c06e1bf 100644 --- a/NAK_CVR_Mods.sln +++ b/NAK_CVR_Mods.sln @@ -71,6 +71,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlaySpaceScaleFix", "PlaySp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FOVAdjustment", "FOVAdjustment\FOVAdjustment.csproj", "{EE552804-30B1-49CF-BBDE-3B312895AFF7}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MuteSFX", "MuteSFX\MuteSFX.csproj", "{77D222FC-4AEC-4672-A87A-B860B4C39E17}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -213,6 +215,10 @@ Global {EE552804-30B1-49CF-BBDE-3B312895AFF7}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE552804-30B1-49CF-BBDE-3B312895AFF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {EE552804-30B1-49CF-BBDE-3B312895AFF7}.Release|Any CPU.Build.0 = Release|Any CPU + {77D222FC-4AEC-4672-A87A-B860B4C39E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77D222FC-4AEC-4672-A87A-B860B4C39E17}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77D222FC-4AEC-4672-A87A-B860B4C39E17}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77D222FC-4AEC-4672-A87A-B860B4C39E17}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE