diff --git a/Source/0_Harmony/InstallersPatches/AppInstallerPatch.cs b/Source/0_Harmony/InstallersPatches/AppInstallerPatch.cs index 25c2948..0ab1ad9 100644 --- a/Source/0_Harmony/InstallersPatches/AppInstallerPatch.cs +++ b/Source/0_Harmony/InstallersPatches/AppInstallerPatch.cs @@ -8,8 +8,7 @@ public static class AppInstallerPatch { [UsedImplicitly] // ReSharper disable once InconsistentNaming private static void Postfix(PCAppInit __instance) { - var container = __instance.GetContainer(); - OnAppInstaller.Install(container); + OnAppInstaller.Install(__instance.Container); } } } \ No newline at end of file diff --git a/Source/0_Harmony/InstallersPatches/MenuInstallerPatch.cs b/Source/0_Harmony/InstallersPatches/MenuInstallerPatch.cs index ca64343..db84c51 100644 --- a/Source/0_Harmony/InstallersPatches/MenuInstallerPatch.cs +++ b/Source/0_Harmony/InstallersPatches/MenuInstallerPatch.cs @@ -8,8 +8,7 @@ public static class MenuInstallerPatch { [UsedImplicitly] // ReSharper disable once InconsistentNaming private static void Postfix(MainSettingsMenuViewControllersInstaller __instance) { - var container = __instance.GetContainer(); - OnMenuInstaller.Install(container); + OnMenuInstaller.Install(__instance.Container); } } } \ No newline at end of file diff --git a/Source/0_Harmony/PermanentPatches/AppInstallerPermanentPatch.cs b/Source/0_Harmony/PermanentPatches/AppInstallerPermanentPatch.cs index 0579f2d..e8d9f2c 100644 --- a/Source/0_Harmony/PermanentPatches/AppInstallerPermanentPatch.cs +++ b/Source/0_Harmony/PermanentPatches/AppInstallerPermanentPatch.cs @@ -4,32 +4,17 @@ namespace EasyOffset { public static class AppInstallerPermanentPatch { - #region ApplyPatch - - private static MethodInfo OriginalMethodInfo => typeof(PCAppInit).GetMethod("InstallBindings"); - private static MethodInfo PostfixMethodInfo => typeof(AppInstallerPermanentPatch).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic); - public static void ApplyPatch(Harmony harmony) { - harmony.Patch(OriginalMethodInfo, null, new HarmonyMethod(PostfixMethodInfo)); + var originalMethodInfo = typeof(PCAppInit).GetMethod("InstallBindings"); + var postfixMethodInfo = typeof(AppInstallerPermanentPatch).GetMethod(nameof(Postfix), BindingFlags.Static | BindingFlags.NonPublic); + harmony.Patch(originalMethodInfo, null, new HarmonyMethod(postfixMethodInfo)); } - #endregion - - #region Postfix - - private static readonly FieldInfo MainSettingsFieldInfo = typeof(PCAppInit).GetField( - "_mainSettingsModel", - BindingFlags.Instance | BindingFlags.NonPublic - ); - [UsedImplicitly] // ReSharper disable once InconsistentNaming private static void Postfix(PCAppInit __instance) { - var container = __instance.GetContainer(); - PluginConfig.VRPlatformHelper = container.TryResolve(); - PluginConfig.MainSettingsModel = (MainSettingsModelSO) MainSettingsFieldInfo.GetValue(__instance); + PluginConfig.VRPlatformHelper = __instance.Container.TryResolve(); + PluginConfig.MainSettingsModel = __instance._mainSystemInit._mainSettingsModel; } - - #endregion } } \ No newline at end of file diff --git a/Source/0_Harmony/PermanentPatches/MenuInstallerPermanentPatch.cs b/Source/0_Harmony/PermanentPatches/MenuInstallerPermanentPatch.cs index 1e8ba00..94acb3d 100644 --- a/Source/0_Harmony/PermanentPatches/MenuInstallerPermanentPatch.cs +++ b/Source/0_Harmony/PermanentPatches/MenuInstallerPermanentPatch.cs @@ -4,24 +4,15 @@ namespace EasyOffset { public static class MenuInstallerPermanentPatch { - #region ApplyPatch - - private static MethodInfo OriginalMethodInfo => typeof(MainSettingsMenuViewControllersInstaller).GetMethod("InstallBindings"); - private static MethodInfo PostfixMethodInfo => typeof(MenuInstallerPermanentPatch).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic); - public static void ApplyPatch(Harmony harmony) { - harmony.Patch(OriginalMethodInfo, null, new HarmonyMethod(PostfixMethodInfo)); + var originalMethodInfo = typeof(MainSettingsMenuViewControllersInstaller).GetMethod("InstallBindings"); + var postfixMethodInfo = typeof(MenuInstallerPermanentPatch).GetMethod(nameof(Postfix), BindingFlags.Static | BindingFlags.NonPublic); + harmony.Patch(originalMethodInfo, null, new HarmonyMethod(postfixMethodInfo)); } - #endregion - - #region Postfix - [UsedImplicitly] private static void Postfix() { Plugin.InitializeUI(); } - - #endregion } } \ No newline at end of file diff --git a/Source/0_Harmony/UIPatches/ModMenuOrderPatch.cs b/Source/0_Harmony/UIPatches/ModMenuOrderPatch.cs deleted file mode 100644 index 59738c9..0000000 --- a/Source/0_Harmony/UIPatches/ModMenuOrderPatch.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using BeatSaberMarkupLanguage.GameplaySetup; -using HarmonyLib; -using JetBrains.Annotations; - -namespace EasyOffset { - [HarmonyPatch( - typeof(GameplaySetup), - "AddTab", - typeof(Assembly), - typeof(string), - typeof(string), - typeof(object), - typeof(MenuType) - )] - internal class ModMenuOrderPatch { - #region Reflection - - private static readonly FieldInfo MenusFieldInfo = typeof(GameplaySetup).GetField( - "menus", - BindingFlags.Instance | BindingFlags.NonPublic - ); - - [CanBeNull] - private static readonly Type GameplaySetupMenuType = BsmlUtils.GetType("GameplaySetupMenu"); - - [CanBeNull] - private static readonly FieldInfo NameFieldInfo = GameplaySetupMenuType?.GetField( - "name", - BindingFlags.Instance | BindingFlags.Public - ); - - private static readonly bool ReflectionError = (MenusFieldInfo == null || NameFieldInfo == null); - - #endregion - - [UsedImplicitly] - // ReSharper disable once InconsistentNaming - private static void Postfix(GameplaySetup __instance) { - if (ReflectionError) { - Plugin.Log.Debug("BSML tab re-order patch failed: reflection error"); - return; - } - - try { - var menusList = (List) MenusFieldInfo.GetValue(__instance); - - for (var i = menusList.Count - 1; i >= 0; i--) { - var menu = menusList[i]; - - var name = NameFieldInfo!.GetValue(menu).ToString(); - if (name != ModPanelUIHelper.TabName) continue; - - menusList.RemoveAt(i); - menusList.Add(menu); - break; - } - } catch (Exception) { - Plugin.Log.Debug("BSML tab re-order patch failed: exception"); - // ignored - } - } - } -} \ No newline at end of file diff --git a/Source/0_Harmony/VRControllerPatches/VRControllerUpdatePatch.cs b/Source/0_Harmony/VRControllerPatches/VRControllerUpdatePatch.cs index 14444dd..a76074f 100644 --- a/Source/0_Harmony/VRControllerPatches/VRControllerUpdatePatch.cs +++ b/Source/0_Harmony/VRControllerPatches/VRControllerUpdatePatch.cs @@ -11,6 +11,7 @@ internal class VRControllerUpdatePatch { private static readonly Vector3 DefaultRightPosition = new Vector3(0.2f, 0.05f, 0.0f); [UsedImplicitly] + // ReSharper disable InconsistentNaming private static bool Prefix( VRController __instance, IVRPlatformHelper ____vrPlatformHelper, @@ -18,7 +19,7 @@ private static bool Prefix( ref Quaternion ____lastTrackedRotation ) { if (PluginConfig.IsDeviceless && !PluginConfig.EnabledForDeviceless) return true; - + if (____vrPlatformHelper.GetNodePose(__instance.node, __instance.nodeIdx, out var pos, out var rot)) { ____lastTrackedPosition = pos; ____lastTrackedRotation = rot; diff --git a/Source/7_Utils/StaticUtils/InstallerUtils.cs b/Source/7_Utils/StaticUtils/InstallerUtils.cs deleted file mode 100644 index ed0e4c8..0000000 --- a/Source/7_Utils/StaticUtils/InstallerUtils.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using Zenject; - -namespace EasyOffset { - public static class InstallerUtils { - #region GetContainer - - private static readonly PropertyInfo ContainerPropertyInfo = typeof(MonoInstallerBase).GetProperty( - "Container", - BindingFlags.Instance | BindingFlags.NonPublic - ); - - public static DiContainer GetContainer(this MonoInstallerBase monoInstallerBase) { - return (DiContainer) ContainerPropertyInfo.GetValue(monoInstallerBase); - } - - #endregion - } -} \ No newline at end of file diff --git a/Source/EasyOffset.csproj b/Source/EasyOffset.csproj index 61f7eeb..1ff2426 100644 --- a/Source/EasyOffset.csproj +++ b/Source/EasyOffset.csproj @@ -96,7 +96,7 @@ $(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll - + $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll diff --git a/Source/manifest.json b/Source/manifest.json index c010b44..62c31fb 100644 --- a/Source/manifest.json +++ b/Source/manifest.json @@ -3,9 +3,9 @@ "id": "EasyOffset", "name": "EasyOffset", "author": "Reezonate", - "version": "2.1.6", + "version": "2.1.7", "description": "Easy controller offset adjustment tool", - "gameVersion": "1.33.0", + "gameVersion": "1.34.0", "dependsOn": { "BSIPA": "^4.3.0", "BeatSaberMarkupLanguage": "^1.7.6",