Browse Source

commit: first commit

HOME 3 years ago
parent
commit
f4719265e2

+ 31 - 0
BeatSaberTweakers.sln

@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30309.148
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HapticFeedbackAdjust", "HapticFeedbackAdjust\HapticFeedbackAdjust.csproj", "{17543AC2-0AA3-4F12-A1E9-994798BE1250}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VolumeAdjust", "VolumeAdjust\VolumeAdjust.csproj", "{0A0B98E1-2644-41EA-A4A1-E31EAC44822A}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{17543AC2-0AA3-4F12-A1E9-994798BE1250}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{17543AC2-0AA3-4F12-A1E9-994798BE1250}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{17543AC2-0AA3-4F12-A1E9-994798BE1250}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{17543AC2-0AA3-4F12-A1E9-994798BE1250}.Release|Any CPU.Build.0 = Release|Any CPU
+		{0A0B98E1-2644-41EA-A4A1-E31EAC44822A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0A0B98E1-2644-41EA-A4A1-E31EAC44822A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0A0B98E1-2644-41EA-A4A1-E31EAC44822A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0A0B98E1-2644-41EA-A4A1-E31EAC44822A}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {05F52B31-19F8-4F6A-8137-194C2537B545}
+	EndGlobalSection
+EndGlobal

+ 89 - 0
HapticFeedbackAdjust/HapticFeedbackAdjust.csproj

@@ -0,0 +1,89 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net472</TargetFramework>
+    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+    <LangVersion>8</LangVersion>
+    <RootNamespace>BeatSaberTweakers.HapticFeedbackAdjust</RootNamespace>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+    <OutputPath>bin\Debug\</OutputPath>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <None Remove="manifest.json" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <EmbeddedResource Include="manifest.json" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Reference Include="Main">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll</HintPath>
+    </Reference>
+    <Reference Include="GamePlayCore">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\GamePlayCore.dll</HintPath>
+    </Reference>
+    <Reference Include="HMUI">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath>
+    </Reference>
+    <Reference Include="Unity.TextMeshPro">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.XRModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.XRModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.AudioModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.CoreModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UnityWebRequestModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UI">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UIElementsModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UIModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.VRModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.InputLegacyModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
+    </Reference>
+    <Reference Include="HMLib">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath>
+    </Reference>
+    <Reference Include="IPA.Injector">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Injector.dll</HintPath>
+    </Reference>
+    <Reference Include="IPA.Loader">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
+    </Reference>
+    <Reference Include="Zenject">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll</HintPath>
+    </Reference>
+    <Reference Include="BS_Utils">
+      <HintPath>$(BeatSaberDir)\Plugins\BS_Utils.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>$(BeatSaberDir)\Libs\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="0Harmony">
+      <HintPath>$(BeatSaberDir)\Libs\0Harmony.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+
+  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
+    <Copy SourceFiles="$(TargetDir)$(TargetName).dll" DestinationFolder="$(BeatSaberDir)\Plugins" />
+  </Target>
+
+</Project>

+ 23 - 0
HapticFeedbackAdjust/HarmonyPatches/HapticFeedbackPatch.cs

@@ -0,0 +1,23 @@
+using HarmonyLib;
+using Libraries.HM.HMLib.VR;
+using UnityEngine.XR;
+
+namespace BeatSaberTweakers.HapticFeedbackAdjust.HarmonyPatches
+{
+    //// **virtual** void PlayHapticFeedback(XRNode node, HapticPresetSO hapticPreset)
+    //[HarmonyPatch(typeof(HapticFeedbackController))]
+    //[HarmonyPatch("PlayHapticFeedback")]
+    //[HarmonyPatch(new[] { typeof(XRNode), typeof(HapticPresetSO) })]
+    //internal static class HapticFeedbackPatch
+    //{
+    //    static bool PreFix(HapticFeedbackController __instance, XRNode node,ref HapticPresetSO hapticPreset)
+    //    {
+    //        Plugin.Logger.Debug("PlayHapticFeedback:" + node + ", s:" + hapticPreset._strength + ", d:" + hapticPreset._duration + ", f:" + hapticPreset._frequency);
+    //        var copy = new HapticPresetSO();
+    //        copy.CopyFrom(hapticPreset);
+    //        copy._strength *= 3;
+    //        hapticPreset = copy;
+    //        return false;
+    //    }
+    //}
+}

+ 37 - 0
HapticFeedbackAdjust/HarmonyPatches/NoteCutHapticEffectPatch.cs

@@ -0,0 +1,37 @@
+using System;
+using HarmonyLib;
+using IPA.Utilities;
+using Libraries.HM.HMLib.VR;
+
+namespace BeatSaberTweakers.HapticFeedbackAdjust.HarmonyPatches
+{
+    //  void HitNote(SaberType saberType)
+    [HarmonyPatch(typeof(NoteCutHapticEffect))]
+    [HarmonyPatch("HitNote")]
+    [HarmonyPatch(new Type[] { typeof(SaberType) })]
+    internal static class NoteCutHapticEffectPatch
+    {
+        private static readonly HapticPresetSO RumblePreset = new HapticPresetSO
+        {
+            _continuous = false,
+            _duration = 0.14f,
+            _strength = 1f,
+            _frequency = 1f,
+        };
+
+        private static readonly AccessTools.FieldRef<NoteCutHapticEffect, HapticFeedbackController> CtlFieldRef = AccessTools.FieldRefAccess<NoteCutHapticEffect, HapticFeedbackController>("_hapticFeedbackController");
+        private static readonly AccessTools.FieldRef<NoteCutHapticEffect, HapticPresetSO> HapticPresetRef = AccessTools.FieldRefAccess<NoteCutHapticEffect, HapticPresetSO>("_rumblePreset");
+
+        static bool Prefix(NoteCutHapticEffect __instance, SaberType saberType)
+        {
+            var ctl = CtlFieldRef(__instance);
+            var hapticPreset = HapticPresetRef(__instance);
+
+            Plugin.Logger.Debug("HitNote:" + saberType + ", s:" + hapticPreset._strength + ", d:" + hapticPreset._duration + ", f:" + hapticPreset._frequency);
+
+            ctl.PlayHapticFeedback(saberType.Node(), RumblePreset);
+            return false;
+        }
+    }
+
+}

+ 38 - 0
HapticFeedbackAdjust/Plugin.cs

@@ -0,0 +1,38 @@
+using HarmonyLib;
+using IPA;
+using System;
+using System.Reflection;
+using IPALogger = IPA.Logging.Logger;
+
+namespace BeatSaberTweakers.HapticFeedbackAdjust
+{
+    /// <summary>
+    ///   Entry point of the plugin.
+    /// </summary>
+    [Plugin(RuntimeOptions.SingleStartInit)]
+    public sealed class Plugin //: IPlugin
+    {
+        internal static IPALogger Logger;
+
+        [Init]
+        public void Init(IPALogger logger)
+        {
+            Logger = logger;
+            Logger.Debug("Init");
+
+            try
+            {
+                Logger?.Debug("Applying Harmony patches.");
+                harmony.PatchAll(Assembly.GetExecutingAssembly());
+            }
+            catch (Exception ex)
+            {
+                Logger?.Critical("Error applying Harmony patches: " + ex.Message);
+                Logger?.Debug(ex);
+            }
+        }
+
+        public const string HarmonyId = nameof(BeatSaberTweakers) + "." + nameof(HapticFeedbackAdjust);
+        internal static Harmony harmony => new Harmony(HarmonyId);
+    }
+}

+ 15 - 0
HapticFeedbackAdjust/manifest.json

@@ -0,0 +1,15 @@
+{
+  "$schema": "https://raw.githubusercontent.com/bsmg/BSIPA-MetadataFileSchema/master/Schema.json",
+  "author": "Coder",
+  "description": "A plugin for adjust Haptic Feedback in Beat Saber.",
+  "gameVersion": "1.12.1",
+  "id": "HapticFeedbackAdjust",
+  "name": "HapticFeedbackAdjust",
+  "version": "1.0.0",
+  "dependsOn": {
+    "BSIPA": "^4.1.2"
+  },
+  "links": {
+    "project-source": "no provided"
+  }
+} 

+ 31 - 0
VolumeAdjust/HarmonyPatches/EffectPoolsManualInstallerPatch.cs

@@ -0,0 +1,31 @@
+using HarmonyLib;
+using IPA.Utilities;
+
+namespace BeatSaberTweakers.VolumeAdjust.HarmonyPatches
+{
+    [HarmonyPatch(typeof(EffectPoolsManualInstaller), "ManualInstallBindings")]
+    internal static class EffectPoolsManualInstallerPatch
+    {
+        private static readonly FieldAccessor<EffectPoolsManualInstaller, NoteCutSoundEffect>.Accessor GetNoteCutSoundEffect = FieldAccessor<EffectPoolsManualInstaller, NoteCutSoundEffect>.GetAccessor("_noteCutSoundEffectPrefab");
+
+        private static readonly FieldAccessor<NoteCutSoundEffect, float>.Accessor GetGoodCutVolume = FieldAccessor<NoteCutSoundEffect, float>.GetAccessor("_goodCutVolume");
+        private static readonly FieldAccessor<NoteCutSoundEffect, float>.Accessor GetBadCutVolume = FieldAccessor<NoteCutSoundEffect, float>.GetAccessor("_badCutVolume");
+
+        internal static void Prefix(EffectPoolsManualInstaller __instance)
+        {
+            var eff = GetNoteCutSoundEffect(ref __instance);
+            var gc = GetGoodCutVolume(ref eff);
+            var bc = GetBadCutVolume(ref eff);
+
+            Plugin.Logger.Debug("EffectPoolsManualInstallerPatch original gc:" + gc + ", bc:" + bc);
+
+            gc = 1;
+            bc = 1;
+
+            GetGoodCutVolume(ref eff) = gc;
+            GetBadCutVolume(ref eff) = bc;
+
+            Plugin.Logger.Debug("EffectPoolsManualInstallerPatch to gc:" + gc + ", bc:" + bc);
+        }
+    }
+}

+ 49 - 0
VolumeAdjust/Plugin.cs

@@ -0,0 +1,49 @@
+using HarmonyLib;
+using IPA;
+using System;
+using System.Reflection;
+using IPALogger = IPA.Logging.Logger;
+
+namespace BeatSaberTweakers.VolumeAdjust
+{
+    /// <summary>
+    ///   Entry point of the plugin.
+    /// </summary>
+    [Plugin(RuntimeOptions.SingleStartInit)]
+    public sealed class Plugin //: IPlugin
+    {
+        internal static IPALogger Logger;
+
+        public const string HarmonyId = nameof(BeatSaberTweakers) + "." + nameof(VolumeAdjust);
+
+        private Harmony _harmony => new Harmony(HarmonyId);
+
+        [Init]
+        public void Init(IPALogger logger)
+        {
+            Logger = logger;
+            Logger.Debug("Init");
+        }
+
+        [OnEnable]
+        public void OnEnable()
+        {
+            try
+            {
+                Logger?.Debug("Applying Harmony patches.");
+                _harmony.PatchAll(Assembly.GetExecutingAssembly());
+            }
+            catch (Exception ex)
+            {
+                Logger?.Critical("Error applying Harmony patches: " + ex.Message);
+                Logger?.Debug(ex);
+            }
+        }
+
+        [OnDisable]
+        public void OnDisable()
+        {
+            _harmony.UnpatchAll(HarmonyId);
+        }
+    }
+}

+ 89 - 0
VolumeAdjust/VolumeAdjust.csproj

@@ -0,0 +1,89 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net472</TargetFramework>
+    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+    <LangVersion>8</LangVersion>
+    <RootNamespace>BeatSaberTweakers.VolumeAdjust</RootNamespace>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+    <OutputPath>bin\Debug\</OutputPath>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <None Remove="manifest.json" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <EmbeddedResource Include="manifest.json" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Reference Include="Main">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll</HintPath>
+    </Reference>
+    <Reference Include="GamePlayCore">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\GamePlayCore.dll</HintPath>
+    </Reference>
+    <Reference Include="HMUI">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath>
+    </Reference>
+    <Reference Include="Unity.TextMeshPro">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.XRModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.XRModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.AudioModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.CoreModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UnityWebRequestModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UI">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UIElementsModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UIModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.VRModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.InputLegacyModule">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
+    </Reference>
+    <Reference Include="HMLib">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath>
+    </Reference>
+    <Reference Include="IPA.Injector">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Injector.dll</HintPath>
+    </Reference>
+    <Reference Include="IPA.Loader">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
+    </Reference>
+    <Reference Include="Zenject">
+      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll</HintPath>
+    </Reference>
+    <Reference Include="BS_Utils">
+      <HintPath>$(BeatSaberDir)\Plugins\BS_Utils.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>$(BeatSaberDir)\Libs\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="0Harmony">
+      <HintPath>$(BeatSaberDir)\Libs\0Harmony.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+
+  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
+    <Copy SourceFiles="$(TargetDir)$(TargetName).dll" DestinationFolder="$(BeatSaberDir)\Plugins" />
+  </Target>
+
+</Project>

+ 15 - 0
VolumeAdjust/manifest.json

@@ -0,0 +1,15 @@
+{
+  "$schema": "https://raw.githubusercontent.com/bsmg/BSIPA-MetadataFileSchema/master/Schema.json",
+  "author": "Coder",
+  "description": "A plugin for turn cut note and miss SFX Volume to maximize in Beat Saber. No config UI.",
+  "gameVersion": "1.12.2",
+  "id": "MaximizeSFX",
+  "name": "MaximizeSFX",
+  "version": "1.0.0",
+  "dependsOn": {
+    "BSIPA": "^4.1.2"
+  },
+  "links": {
+    "project-source": "https://topcl.net/gogs/coder/BeatSaberTweakers"
+  }
+}