From bc0b0cd4fb4e3e5af74eab8a24fd1e91179b2dac Mon Sep 17 00:00:00 2001 From: SamSWAT Date: Mon, 20 Feb 2023 01:52:09 +0300 Subject: [PATCH] add SamSWAT.PS2BIOS --- Projects/SamSWAT.PS2BIOS/Plugin.cs | 53 +++++++++++++ .../Properties/AssemblyInfo.cs | 35 +++++++++ .../SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.csproj | 74 +++++++++++++++++++ Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.sln | 16 ++++ 4 files changed, 178 insertions(+) create mode 100644 Projects/SamSWAT.PS2BIOS/Plugin.cs create mode 100644 Projects/SamSWAT.PS2BIOS/Properties/AssemblyInfo.cs create mode 100644 Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.csproj create mode 100644 Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.sln diff --git a/Projects/SamSWAT.PS2BIOS/Plugin.cs b/Projects/SamSWAT.PS2BIOS/Plugin.cs new file mode 100644 index 0000000..bba22b2 --- /dev/null +++ b/Projects/SamSWAT.PS2BIOS/Plugin.cs @@ -0,0 +1,53 @@ +using System.IO; +using System.Reflection; +using Aki.Reflection.Patching; +using BepInEx; +using EFT.UI; +using UnityEngine; + +namespace SamSWAT.PS2BIOS +{ + [BepInPlugin("com.samswat.ps2bios", "SamSWAT.PS2BIOS", "1.0.0")] + public class Plugin : BaseUnityPlugin + { + internal static AudioClip ButtonOver; + internal static AudioClip ButtonClick; + + private void Awake() + { + LoadSoundBundle(); + new Patch().Enable(); + } + + private void LoadSoundBundle() + { + var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/bundles/ps2bios.bundle"; + var bundle = AssetBundle.LoadFromFile(path); + var assets = bundle.LoadAllAssets(); + ButtonOver = assets[0] as AudioClip; + ButtonClick = assets[1] as AudioClip; + } + } + + public class Patch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(UISoundsWrapper).GetMethod(nameof(UISoundsWrapper.GetUIClip)); + } + + [PatchPostfix] + private static void PatchPostfix(ref AudioClip __result, EUISoundType soundType) + { + switch (soundType) + { + case EUISoundType.ButtonClick: + __result = Plugin.ButtonClick; + break; + case EUISoundType.ButtonOver: + __result = Plugin.ButtonOver; + break; + } + } + } +} \ No newline at end of file diff --git a/Projects/SamSWAT.PS2BIOS/Properties/AssemblyInfo.cs b/Projects/SamSWAT.PS2BIOS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b3d528d --- /dev/null +++ b/Projects/SamSWAT.PS2BIOS/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SamSWAT.PS2BIOS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SamSWAT.PS2BIOS")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("88897380-279A-4EB0-A692-B0B688587191")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.csproj b/Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.csproj new file mode 100644 index 0000000..c7cbb66 --- /dev/null +++ b/Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {88897380-279A-4EB0-A692-B0B688587191} + Library + Properties + SamSWAT.PS2BIOS + SamSWAT.PS2BIOS + v4.7.2 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\References\0Harmony.dll + + + ..\..\References\Aki.Reflection.dll + + + ..\..\References\Assembly-CSharp.dll + + + ..\..\References\BepInEx.dll + + + + ..\..\References\UnityEngine.dll + + + ..\..\References\UnityEngine.AssetBundleModule.dll + + + ..\..\References\UnityEngine.AudioModule.dll + + + ..\..\References\UnityEngine.CoreModule.dll + + + + + + + + + + diff --git a/Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.sln b/Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.sln new file mode 100644 index 0000000..7ef7d4d --- /dev/null +++ b/Projects/SamSWAT.PS2BIOS/SamSWAT.PS2BIOS.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamSWAT.PS2BIOS", "SamSWAT.PS2BIOS.csproj", "{88897380-279A-4EB0-A692-B0B688587191}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {88897380-279A-4EB0-A692-B0B688587191}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88897380-279A-4EB0-A692-B0B688587191}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88897380-279A-4EB0-A692-B0B688587191}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88897380-279A-4EB0-A692-B0B688587191}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal