From 7aa8cad43ca53357412191cef30e171d52871d7b Mon Sep 17 00:00:00 2001 From: NSGolova Date: Tue, 20 Aug 2024 05:55:33 +0100 Subject: [PATCH] BS 1.37.3 Support --- .../InstallersPatches/LevelDataEnhancerPatch.cs | 5 ----- .../InstallersPatches/MainSystemInitPatch.cs | 2 +- Source/2_Core/Localization/BLLocalization.cs | 6 +++--- .../Managers/DataManager/LeaderboardManager.cs | 3 +-- .../Emulation/Controllers/MenuControllersManager.cs | 7 +++---- .../2_Core/Replayer/ReplayerExtraObjectsProvider.cs | 7 +++---- Source/2_Core/Replayer/ReplayerLauncher.cs | 12 +++++------- .../Replayer/Tweaking/Tweaks/RoomOffsetsTweak.cs | 7 +++---- Source/BeatLeader.csproj | 10 ++++++++++ Source/manifest.json | 4 ++-- 10 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Source/0_Harmony/InstallersPatches/LevelDataEnhancerPatch.cs b/Source/0_Harmony/InstallersPatches/LevelDataEnhancerPatch.cs index 45f28f2b..49b0af35 100644 --- a/Source/0_Harmony/InstallersPatches/LevelDataEnhancerPatch.cs +++ b/Source/0_Harmony/InstallersPatches/LevelDataEnhancerPatch.cs @@ -1,10 +1,5 @@ using BeatLeader.Core.Managers.ReplayEnhancer; -using BeatLeader.Installers; -using BeatSaber.PerformancePresets; using HarmonyLib; -using IPA.Utilities; -using JetBrains.Annotations; -using System; using System.Linq; using System.Reflection; diff --git a/Source/0_Harmony/InstallersPatches/MainSystemInitPatch.cs b/Source/0_Harmony/InstallersPatches/MainSystemInitPatch.cs index 2e48d261..a7e00854 100644 --- a/Source/0_Harmony/InstallersPatches/MainSystemInitPatch.cs +++ b/Source/0_Harmony/InstallersPatches/MainSystemInitPatch.cs @@ -10,7 +10,7 @@ public static class MainSystemInitPatch { // ReSharper disable once InconsistentNaming private static void Postfix(MainSystemInit __instance) { try { - BLLocalization.Initialize(__instance._mainSettingsHandler); + BLLocalization.Initialize(__instance._settingsManager); } catch (Exception ex) { Plugin.Log.Critical($"---\nMainSystemInit patch exception: {ex.Message}\n{ex.StackTrace}\n---"); } diff --git a/Source/2_Core/Localization/BLLocalization.cs b/Source/2_Core/Localization/BLLocalization.cs index 72fc9487..44365d25 100644 --- a/Source/2_Core/Localization/BLLocalization.cs +++ b/Source/2_Core/Localization/BLLocalization.cs @@ -3,7 +3,7 @@ using BGLib.Polyglot; using TMPro; using UnityEngine; -using BeatSaber.GameSettings; +using System.Linq; namespace BeatLeader { public static class BLLocalization { @@ -11,8 +11,8 @@ public static class BLLocalization { private static Language _baseGameLanguage = Language.English; - internal static void Initialize(MainSettingsHandler mainSettingsModel) { - _baseGameLanguage = mainSettingsModel.instance.language; + internal static void Initialize(SettingsManager settingsmanager) { + _baseGameLanguage = Localization.Instance.SupportedLanguages.FirstOrDefault(l => l.ToSerializedName() == settingsmanager.settings.misc.language); OnBaseGameLanguageDidChange(); } diff --git a/Source/2_Core/Managers/DataManager/LeaderboardManager.cs b/Source/2_Core/Managers/DataManager/LeaderboardManager.cs index 401af4de..cb0e2724 100644 --- a/Source/2_Core/Managers/DataManager/LeaderboardManager.cs +++ b/Source/2_Core/Managers/DataManager/LeaderboardManager.cs @@ -2,7 +2,6 @@ using BeatLeader.API.Methods; using BeatLeader.Manager; using BeatLeader.Models; -using BeatSaber.GameSettings; using JetBrains.Annotations; using LeaderboardCore.Interfaces; using UnityEngine; @@ -78,7 +77,7 @@ private static void SetFakeBloomProperty() { try { var mainSystemInit = Resources.FindObjectsOfTypeAll()[0]; - enableFakeBloom = (mainSystemInit._graphicSettingsHandler.instance.customPreset?.mainEffectGraphics ?? 0) == 0; + enableFakeBloom = mainSystemInit._settingsManager.settings.quality.mainEffect == BeatSaber.Settings.QualitySettings.MainEffectOption.Off; } catch (Exception) { enableFakeBloom = false; } diff --git a/Source/2_Core/Replayer/Emulation/Controllers/MenuControllersManager.cs b/Source/2_Core/Replayer/Emulation/Controllers/MenuControllersManager.cs index cab009c3..48ac3a86 100644 --- a/Source/2_Core/Replayer/Emulation/Controllers/MenuControllersManager.cs +++ b/Source/2_Core/Replayer/Emulation/Controllers/MenuControllersManager.cs @@ -1,5 +1,4 @@ using BeatLeader.Utils; -using BeatSaber.GameSettings; using IPA.Utilities; using UnityEngine; using VRUIControls; @@ -11,7 +10,7 @@ public class MenuControllersManager : MonoBehaviour { [Inject] private readonly PauseMenuManager _pauseMenuManager = null!; [Inject] private readonly DiContainer _diContainer = null!; [Inject] private readonly VRInputModule _vrInputModule = null!; - [Inject] private readonly MainSettingsHandler _mainSettingsHandler = null!; + [Inject] private readonly SettingsManager _settingsManager = null!; public Transform HandsContainer { get; private set; } = null!; public VRController LeftHand { get; private set; } = null!; @@ -30,8 +29,8 @@ private void Awake() { menuHandsTransform.gameObject.GetComponent().TryDestroy(); LeftHand = Instantiate(menuHandsTransform.Find("ControllerLeft")).GetComponent(); RightHand = Instantiate(menuHandsTransform.Find("ControllerRight")).GetComponent(); - ((VRControllersValueSettingsOffsets)LeftHand._transformOffset)._mainSettingsHandler = _mainSettingsHandler; - ((VRControllersValueSettingsOffsets)RightHand._transformOffset)._mainSettingsHandler = _mainSettingsHandler; + ((VRControllersValueSettingsOffsets)LeftHand._transformOffset).SetField("_settingsManager", _settingsManager); + ((VRControllersValueSettingsOffsets)RightHand._transformOffset).SetField("_settingsManager", _settingsManager); _diContainer.InjectComponentsInChildren(LeftHand.gameObject); _diContainer.InjectComponentsInChildren(RightHand.gameObject); diff --git a/Source/2_Core/Replayer/ReplayerExtraObjectsProvider.cs b/Source/2_Core/Replayer/ReplayerExtraObjectsProvider.cs index 92b2823c..bab4edac 100644 --- a/Source/2_Core/Replayer/ReplayerExtraObjectsProvider.cs +++ b/Source/2_Core/Replayer/ReplayerExtraObjectsProvider.cs @@ -1,5 +1,4 @@ using BeatLeader.Utils; -using BeatSaber.GameSettings; using UnityEngine; namespace BeatLeader.Replayer { @@ -25,9 +24,9 @@ private void Awake() { ReplayerCenterAdjust = new GameObject("CenterAdjust").transform; ReplayerCenterAdjust.SetParent(ReplayerCore, false); - var settingsModel = _mainSystemInit._mainSettingsHandler.instance; - _posOffset = settingsModel.roomCenter; - _rotOffset = Quaternion.Euler(0, settingsModel.roomRotation, 0); + var settingsModel = _mainSystemInit._settingsManager.settings; + _posOffset = settingsModel.room.center; + _rotOffset = Quaternion.Euler(0, settingsModel.room.rotation, 0); } private void Start() { diff --git a/Source/2_Core/Replayer/ReplayerLauncher.cs b/Source/2_Core/Replayer/ReplayerLauncher.cs index 3f155c9d..db56b741 100644 --- a/Source/2_Core/Replayer/ReplayerLauncher.cs +++ b/Source/2_Core/Replayer/ReplayerLauncher.cs @@ -5,8 +5,6 @@ using JetBrains.Annotations; using UnityEngine; using Zenject; -using BeatSaber.PerformancePresets; -using BeatSaber.GameSettings; namespace BeatLeader.Replayer { [PublicAPI] @@ -66,7 +64,7 @@ public bool StartReplay(ReplayLaunchData data, Action? afterTransitionCallback = private static readonly EnvironmentType normalEnvironmentType = EnvironmentType.Normal; private static StandardLevelScenesTransitionSetupDataSO? _standardLevelScenesTransitionSetupDataSo; - private static GraphicSettingsHandler? _graphicSettingsHandler; + private static SettingsManager? _settingsManager; private void Awake() { if (!_standardLevelScenesTransitionSetupDataSo) { @@ -75,10 +73,10 @@ private void Awake() { .First(); } - if (_graphicSettingsHandler == null) { - _graphicSettingsHandler = Resources + if (_settingsManager == null) { + _settingsManager = Resources .FindObjectsOfTypeAll() - .First()._graphicSettingsHandler; + .First()._settingsManager; } } @@ -114,7 +112,7 @@ private void Awake() { _environmentsListModel, _audioClipAsyncLoader, _beatmapDataLoader, - _graphicSettingsHandler.instance.customPreset, + _settingsManager, "Menu", _beatmapLevelsModel, _beatmapLevelsEntitlementModel, diff --git a/Source/2_Core/Replayer/Tweaking/Tweaks/RoomOffsetsTweak.cs b/Source/2_Core/Replayer/Tweaking/Tweaks/RoomOffsetsTweak.cs index cc6e9311..e44a294e 100644 --- a/Source/2_Core/Replayer/Tweaking/Tweaks/RoomOffsetsTweak.cs +++ b/Source/2_Core/Replayer/Tweaking/Tweaks/RoomOffsetsTweak.cs @@ -1,5 +1,4 @@ using BeatLeader.Utils; -using BeatSaber.GameSettings; using UnityEngine; using Zenject; @@ -16,9 +15,9 @@ public override void Initialize() { } public override void Dispose() { if (_centerAdjust == null) return; - var settingsModel = _mainSystemInit._mainSettingsHandler.instance; - _centerAdjust.transform.localPosition = settingsModel.roomCenter; - _centerAdjust.transform.localEulerAngles = new Vector3(0, settingsModel.roomRotation, 0); + var settingsManager = _mainSystemInit._settingsManager; + _centerAdjust.transform.localPosition = settingsManager.settings.room.center; + _centerAdjust.transform.localEulerAngles = new Vector3(0, settingsManager.settings.room.rotation, 0); _centerAdjust.enabled = true; } } diff --git a/Source/BeatLeader.csproj b/Source/BeatLeader.csproj index 57f6c9c5..195302c9 100644 --- a/Source/BeatLeader.csproj +++ b/Source/BeatLeader.csproj @@ -39,6 +39,11 @@ False False + + $(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.Settings.dll + False + False + $(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.AppFlow.dll False @@ -123,6 +128,11 @@ False False + + $(BeatSaberDir)\Beat Saber_Data\Managed\Unity.Mathematics.dll + False + False + $(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll False diff --git a/Source/manifest.json b/Source/manifest.json index 5c124e63..1ef860f0 100644 --- a/Source/manifest.json +++ b/Source/manifest.json @@ -3,9 +3,9 @@ "id": "BeatLeader", "name": "BeatLeader", "author": "", - "version": "0.9.19", + "version": "0.9.21", "description": "beatleader.xyz | In-game leaderboards for custom and OST maps | Score replays | Clans, events, playlists and much more", - "gameVersion": "1.37.1", + "gameVersion": "1.37.3", "dependsOn": { "SongCore": "^3.14.11", "LeaderboardCore": "^1.6.0",