From c3074c62015373e5e4c5026a968a8c6e2751dcb9 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Fri, 15 Mar 2019 18:10:18 -0400 Subject: [PATCH] Fix --- Beat Saber Utils/Beat Saber Utils.csproj | 1 - Beat Saber Utils/Gameplay/Gamemode.cs | 14 +++++++-- ...isticSelectionViewControllerDidActivate.cs | 30 ------------------- ...ticSelectionViewControllerDidDeActivate.cs | 16 +++++----- Beat Saber Utils/Plugin.cs | 2 +- Beat Saber Utils/Properties/AssemblyInfo.cs | 4 +-- 6 files changed, 23 insertions(+), 44 deletions(-) delete mode 100644 Beat Saber Utils/Gameplay/HarmonyPatches/BeatmapCharacteristicSelectionViewControllerDidActivate.cs diff --git a/Beat Saber Utils/Beat Saber Utils.csproj b/Beat Saber Utils/Beat Saber Utils.csproj index 5ae0655..7e72f73 100644 --- a/Beat Saber Utils/Beat Saber Utils.csproj +++ b/Beat Saber Utils/Beat Saber Utils.csproj @@ -85,7 +85,6 @@ - diff --git a/Beat Saber Utils/Gameplay/Gamemode.cs b/Beat Saber Utils/Gameplay/Gamemode.cs index 6457294..26bad29 100644 --- a/Beat Saber Utils/Gameplay/Gamemode.cs +++ b/Beat Saber Utils/Gameplay/Gamemode.cs @@ -8,7 +8,7 @@ namespace BS_Utils.Gameplay { public class Gamemode { - internal static BeatmapCharacteristicSelectionViewController CharacteristicSelectionViewController; + internal static BeatmapCharacteristicSegmentedControlController CharacteristicSelectionViewController; internal static SoloFreePlayFlowCoordinator SoloFreePlayFlowCoordinator; internal static PartyFreePlayFlowCoordinator PartyFreePlayFlowCoordinator; internal static MainMenuViewController MainMenuViewController; @@ -26,6 +26,14 @@ public static void Init() MainMenuViewController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (MainMenuViewController == null) return; MainMenuViewController.didFinishEvent += MainMenuViewController_didFinishEvent; + + if (CharacteristicSelectionViewController == null) + { + CharacteristicSelectionViewController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (CharacteristicSelectionViewController != null) + CharacteristicSelectionViewController.didSelectBeatmapCharacteristicEvent += CharacteristicSelectionViewController_didSelectBeatmapCharacteristicEvent; + } + } } @@ -37,9 +45,9 @@ private static void MainMenuViewController_didFinishEvent(MainMenuViewController IsPartyActive = false; } - internal static void CharacteristicSelectionViewController_didSelectBeatmapCharacteristicEvent(BeatmapCharacteristicSelectionViewController arg1, BeatmapCharacteristicSO arg2) + internal static void CharacteristicSelectionViewController_didSelectBeatmapCharacteristicEvent(BeatmapCharacteristicSegmentedControlController arg1, BeatmapCharacteristicSO arg2) { - Utilities.Logger.Log(arg2.characteristicName); + // Utilities.Logger.Log("Prev: " + GameMode + " New: " + arg2.characteristicName); GameMode = arg2.characteristicName; } diff --git a/Beat Saber Utils/Gameplay/HarmonyPatches/BeatmapCharacteristicSelectionViewControllerDidActivate.cs b/Beat Saber Utils/Gameplay/HarmonyPatches/BeatmapCharacteristicSelectionViewControllerDidActivate.cs deleted file mode 100644 index 91122f9..0000000 --- a/Beat Saber Utils/Gameplay/HarmonyPatches/BeatmapCharacteristicSelectionViewControllerDidActivate.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Harmony; -using UnityEngine; -using TMPro; -using UnityEngine.UI; -using CustomUI.BeatSaber; -namespace BS_Utils.Gameplay.Harmony_Patches -{ - [HarmonyPatch(typeof(BeatmapCharacteristicSelectionViewController), - new Type[] { typeof(bool), - typeof(VRUI.VRUIViewController.ActivationType) } - )] - [HarmonyPatch("DidActivate", MethodType.Normal)] - - class BeatmapCharacteristicSelectionViewControllerDidActivate - { - static void Prefix(BeatmapCharacteristicSelectionViewController __instance, bool firstActivation, VRUI.VRUIViewController.ActivationType activationType) - { - Utilities.Logger.Log("Activation"); - __instance.didSelectBeatmapCharacteristicEvent += Gamemode.CharacteristicSelectionViewController_didSelectBeatmapCharacteristicEvent; - - - } - } -} - diff --git a/Beat Saber Utils/Gameplay/HarmonyPatches/BeatmapCharacteristicSelectionViewControllerDidDeActivate.cs b/Beat Saber Utils/Gameplay/HarmonyPatches/BeatmapCharacteristicSelectionViewControllerDidDeActivate.cs index 814a0d6..0fec7d1 100644 --- a/Beat Saber Utils/Gameplay/HarmonyPatches/BeatmapCharacteristicSelectionViewControllerDidDeActivate.cs +++ b/Beat Saber Utils/Gameplay/HarmonyPatches/BeatmapCharacteristicSelectionViewControllerDidDeActivate.cs @@ -10,17 +10,19 @@ using CustomUI.BeatSaber; namespace BS_Utils.Gameplay.Harmony_Patches { - [HarmonyPatch(typeof(BeatmapCharacteristicSelectionViewController), - new Type[] { typeof(VRUI.VRUIViewController.DeactivationType) })] - [HarmonyPatch("DidDeactivate", MethodType.Normal)] + [HarmonyPatch(typeof(BeatmapCharacteristicSegmentedControlController), + new Type[] { + typeof(IDifficultyBeatmapSet[]), + typeof(BeatmapCharacteristicSO) + })] + + [HarmonyPatch("SetData", MethodType.Normal)] class BeatmapCharacteristicSelectionViewControllerDidDeactivate { - static void Postfix(BeatmapCharacteristicSelectionViewController __instance, VRUI.VRUIViewController.DeactivationType deactivationType) + static void Postfix(BeatmapCharacteristicSegmentedControlController __instance, IDifficultyBeatmapSet[] difficultyBeatmapSets, BeatmapCharacteristicSO selectedBeatmapCharacteristic) { - if (deactivationType == VRUI.VRUIViewController.DeactivationType.RemovedFromHierarchy) - Gamemode.ResetGameMode(); - + Gamemode.CharacteristicSelectionViewController_didSelectBeatmapCharacteristicEvent(__instance, __instance.selectedBeatmapCharacteristic); } } } diff --git a/Beat Saber Utils/Plugin.cs b/Beat Saber Utils/Plugin.cs index 643bd52..38791f7 100644 --- a/Beat Saber Utils/Plugin.cs +++ b/Beat Saber Utils/Plugin.cs @@ -15,7 +15,7 @@ namespace BS_Utils public class Plugin : IPlugin { public string Name => "Beat Saber Utils"; - public string Version => "1.2.0"; + public string Version => "1.2.1"; internal static bool patched = false; internal static HarmonyInstance harmony; public static Gameplay.LevelData LevelData = new Gameplay.LevelData(); diff --git a/Beat Saber Utils/Properties/AssemblyInfo.cs b/Beat Saber Utils/Properties/AssemblyInfo.cs index e850db3..ba9e46d 100644 --- a/Beat Saber Utils/Properties/AssemblyInfo.cs +++ b/Beat Saber Utils/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 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.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.2.1.0")] +[assembly: AssemblyFileVersion("1.2.1.0")]