add SamSWAT.PS2BIOS

This commit is contained in:
SamSWAT 2023-02-20 01:52:09 +03:00
parent 672611d5e6
commit bc0b0cd4fb
4 changed files with 178 additions and 0 deletions

View File

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

View File

@ -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")]

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{88897380-279A-4EB0-A692-B0B688587191}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SamSWAT.PS2BIOS</RootNamespace>
<AssemblyName>SamSWAT.PS2BIOS</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\References\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Aki.Reflection">
<HintPath>..\..\References\Aki.Reflection.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\References\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\References\BepInEx.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine">
<HintPath>..\..\References\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>..\..\References\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>..\..\References\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\References\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

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