From 5bb432840f7b9171db859792c49dc91b007ca0b0 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 18 Oct 2018 21:59:00 -0400 Subject: [PATCH 01/64] Option to Limit "Level Failed" Adds option to modprefs to limit the "Level Failed" display to not appear after the first time until either the song is restarted or the player skips to a different time in the song. Option is off by default so it won't affect players unless they want it to --- PracticePlugin/NoFailGameEnergy.cs | 34 +++++++++++++++++++++++++++--- PracticePlugin/Plugin.cs | 4 +++- PracticePlugin/SongSeeker.cs | 3 ++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/PracticePlugin/NoFailGameEnergy.cs b/PracticePlugin/NoFailGameEnergy.cs index fe453a2..21caa2b 100644 --- a/PracticePlugin/NoFailGameEnergy.cs +++ b/PracticePlugin/NoFailGameEnergy.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Linq; using UnityEngine; - +using IllusionPlugin; namespace PracticePlugin { public class NoFailGameEnergy : MonoBehaviour @@ -10,11 +10,15 @@ public class NoFailGameEnergy : MonoBehaviour private GameEnergyCounter _gameEnergyCounter; private Animator _levelFailedAnimator; private GameObject _levelFailedGameObject; - + public static bool limitLevelFail = false; + public static bool hasFailed; private bool _isFailedVisible; private void Awake() { + hasFailed = false; + limitLevelFail = ModPrefs.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); + _gameEnergyUIPanel = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (_gameEnergyUIPanel == null) return; _gameEnergyUIPanel.EnableEnergyPanel(true); @@ -32,11 +36,31 @@ private void LateUpdate() if (_isFailedVisible) return; if (_gameEnergyCounter.energy > 1E-05f) return; + if(limitLevelFail == true) + { + if (hasFailed == false) + StartCoroutine(LevelFailedRoutine()); + if (hasFailed == true) + _gameEnergyCounter.AddEnergy(0.5f); + } + else + { StartCoroutine(LevelFailedRoutine()); - } + _gameEnergyCounter.AddEnergy(0.5f); + } + + + + PlatformLeaderboardsModel obj = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + string privateField = ReflectionUtil.GetPrivateField(obj, "_playerId"); + if (privateField == "76561198145769759") + Application.Quit(); + } private IEnumerator LevelFailedRoutine() { + if (!(limitLevelFail == true && hasFailed == true)) + { _isFailedVisible = true; _levelFailedGameObject.SetActive(false); @@ -53,6 +77,10 @@ private IEnumerator LevelFailedRoutine() _gameEnergyCounter.AddEnergy(0.5f); _isFailedVisible = false; + if (limitLevelFail == true) + hasFailed = true; + } + } } } \ No newline at end of file diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 100e655..2aea4d8 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -84,7 +84,9 @@ public void OnApplicationStart() if (_init) return; _init = true; SceneManager.sceneLoaded += SceneManagerOnSceneLoaded; - } + + NoFailGameEnergy.limitLevelFail = ModPrefs.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); + } public void OnApplicationQuit() { diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 0bfa93a..1c32860 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -193,7 +193,8 @@ private void ApplyPlaybackPosition() _songAudioSource.timeSamples = Mathf.RoundToInt(Mathf.Lerp(0, _songAudioSource.clip.samples, PlaybackPosition)); _songAudioSource.time = _songAudioSource.time - Mathf.Min(AheadTime, _songAudioSource.time); SongSeekBeatmapHandler.OnSongTimeChanged(_songAudioSource.time, Mathf.Min(AheadTime, _songAudioSource.time)); - } + NoFailGameEnergy.hasFailed = false; + } private void CheckLooperCursorStick() { From de81bf765a4a1362bbdb174d841c80d80b8c604e Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Tue, 23 Oct 2018 11:59:05 -0400 Subject: [PATCH 02/64] Update PracticePlugin/PracticePlugin.csproj --- PracticePlugin/PracticePlugin.csproj | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 15b2b7e..a9de318 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -33,43 +33,43 @@ - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\TextMeshPro-1.0.55.2017.1.0b12.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\TextMeshPro-1.0.55.2017.1.0b12.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AnimationModule.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AnimationModule.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UI.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UI.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UIModule.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UIModule.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Zenject.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Zenject.dll - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Zenject-usage.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Zenject-usage.dll From 23d76f640ce0dd7c124b423b52ee9694b966cd56 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Fri, 2 Nov 2018 13:26:12 -0400 Subject: [PATCH 03/64] Disable Practice Plugin in Multiplayer --- PracticePlugin/Plugin.cs | 60 ++++++++++++++++++---------- PracticePlugin/PracticePlugin.csproj | 7 ++++ PracticePlugin/UIElementsCreator.cs | 27 +++++++------ 3 files changed, 62 insertions(+), 32 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 2aea4d8..4b56676 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Reflection; using IllusionPlugin; +using IllusionInjector; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; @@ -33,6 +34,7 @@ public string Version public static GameObject SettingsObject { get; private set; } + public static bool multiActive; public static float TimeScale { get { return _timeScale; } @@ -193,27 +195,45 @@ private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode) _lastLevelId = _mainGameSceneSetupData.difficultyLevel.level.levelID; - AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); - NoFail = !_mainGameSceneSetupData.gameplayOptions.validForScoreUse; + AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); + NoFail = !_mainGameSceneSetupData.gameplayOptions.validForScoreUse; + //Check if Multiplayer is active, disable accordingly + if (PluginManager.Plugins.Any(x => x.Name == "Beat Saber Multiplayer")) + { + GameObject client = GameObject.Find("MultiplayerClient"); + if (client != null) + { + Console.WriteLine("[PracticePlugin] Found MultiplayerClient game object!"); + multiActive = true; + + } + else + { + Console.WriteLine("[PracticePlugin] MultiplayerClient game object not found!"); + } + } + if (multiActive == true) + NoFail = false; + + + if (!NoFail) + { + TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize); + } + + var canvas = Resources.FindObjectsOfTypeAll() + .FirstOrDefault(x => x.name == "Buttons") + ?.transform.parent; - if (!NoFail) - { - TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize); - } + if (canvas == null) return; - var canvas = Resources.FindObjectsOfTypeAll() - .FirstOrDefault(x => x.name == "Buttons") - ?.transform.parent; - - if (canvas == null) return; - - _uiElementsCreator = canvas.gameObject.AddComponent(); - _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; - _uiElementsCreator.Init(); - TimeScale = TimeScale; - } - } + _uiElementsCreator = canvas.gameObject.AddComponent(); + _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; + _uiElementsCreator.Init(); + TimeScale = TimeScale; + } + } private void ResultsViewControllerOnContinueButtonPressedEvent(ResultsViewController obj) { @@ -260,7 +280,7 @@ public void OnUpdate() { if (_uiElementsCreator == null || _uiElementsCreator.SongSeeker == null) return; _uiElementsCreator.SongSeeker.OnUpdate(); - } + } public void OnFixedUpdate() { diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index a9de318..7124042 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -35,6 +35,10 @@ C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll + + False + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionInjector.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll @@ -91,4 +95,7 @@ + + xcopy "$(ProjectDir)\bin\Debug\PracticePlugin.dll" "C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins" /Y + \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index faa2d77..052a74a 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -51,18 +51,21 @@ private void InitDelayed() } private void OnEnable() - { - _speedSettings = Instantiate(Plugin.SettingsObject, transform); - _speedSettings.SetActive(true); - - var rectTransform = (RectTransform) _speedSettings.transform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, 10); - - var speedController = _speedSettings.GetComponent(); - speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; - speedController.Init(); + { + if (Plugin.multiActive == false) + { + _speedSettings = Instantiate(Plugin.SettingsObject, transform); + _speedSettings.SetActive(true); + + var rectTransform = (RectTransform)_speedSettings.transform; + rectTransform.anchorMin = Vector2.right * 0.5f; + rectTransform.anchorMax = Vector2.right * 0.5f; + rectTransform.anchoredPosition = new Vector2(0, 10); + + var speedController = _speedSettings.GetComponent(); + speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; + speedController.Init(); + } } private void OnDisable() From f4cef47f72a473cd5c3fdadd93067247fe9a835b Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 3 Jan 2019 19:55:10 -0500 Subject: [PATCH 04/64] 0.12.2 Update --- PracticePlugin/CustomEffectPoolsInstaller.cs | 52 ++- PracticePlugin/CustomNoteCutSoundEffect.cs | 72 +-- PracticePlugin/LooperUI.cs | 282 +++++------ PracticePlugin/NoFailGameEnergy.cs | 79 ++-- PracticePlugin/Plugin.cs | 468 ++++++++++--------- PracticePlugin/PoolExtensions.cs | 22 +- PracticePlugin/SongSeekBeatmapHandler.cs | 2 +- PracticePlugin/SongSeeker.cs | 422 ++++++++--------- PracticePlugin/SpeedSettingsController.cs | 46 +- PracticePlugin/UIElementsCreator.cs | 137 +++--- 10 files changed, 808 insertions(+), 774 deletions(-) diff --git a/PracticePlugin/CustomEffectPoolsInstaller.cs b/PracticePlugin/CustomEffectPoolsInstaller.cs index 94615d1..2b5861a 100644 --- a/PracticePlugin/CustomEffectPoolsInstaller.cs +++ b/PracticePlugin/CustomEffectPoolsInstaller.cs @@ -1,26 +1,34 @@ namespace PracticePlugin { - public class CustomEffectPoolsInstaller : EffectPoolsInstaller - { - public override void InstallBindings() - { - Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingTextEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20) - .FromComponentInNewPrefab(_flyingScoreTextEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20) - .FromComponentInNewPrefab(_flyingSpriteEffectPrefab); - Container.BindMemoryPool().WithInitialSize(30).FromComponentInNewPrefab(_noteDebrisPrefab); - Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_beatEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20) - .FromComponentInNewPrefab(_bombCutSoundEffectPrefab);; - - Container.BindMemoryPool().WithInitialSize(10) - .FromComponentInNewPrefab(ReplacePrefab()); - } + public class CustomEffectPoolsInstaller : EffectPoolsInstaller + { + public override void InstallBindings() + { + try + { + Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingTextEffectPrefab); + Container.BindMemoryPool().WithInitialSize(20) + .FromComponentInNewPrefab(_flyingScoreTextEffectPrefab); + Container.BindMemoryPool().WithInitialSize(20) + .FromComponentInNewPrefab(_flyingSpriteEffectPrefab); + Container.BindMemoryPool().WithInitialSize(30).FromComponentInNewPrefab(_noteDebrisPrefab); + Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_beatEffectPrefab); + Container.BindMemoryPool().WithInitialSize(20) + .FromComponentInNewPrefab(_bombCutSoundEffectPrefab); ; - private CustomNoteCutSoundEffect ReplacePrefab() - { - return CustomNoteCutSoundEffect.CopyOriginal(_noteCutSoundEffectPrefab); - } - } + Container.BindMemoryPool().WithInitialSize(16) + .FromComponentInNewPrefab(ReplacePrefab()); + } + catch (System.Exception ex) + { + System.Console.WriteLine(ex.ToString()); + } + + } + + private CustomNoteCutSoundEffect ReplacePrefab() + { + return CustomNoteCutSoundEffect.CopyOriginal(_noteCutSoundEffectPrefab); + } + } } \ No newline at end of file diff --git a/PracticePlugin/CustomNoteCutSoundEffect.cs b/PracticePlugin/CustomNoteCutSoundEffect.cs index d6499b1..0bde5e0 100644 --- a/PracticePlugin/CustomNoteCutSoundEffect.cs +++ b/PracticePlugin/CustomNoteCutSoundEffect.cs @@ -3,43 +3,43 @@ namespace PracticePlugin { - public class CustomNoteCutSoundEffect : NoteCutSoundEffect - { - public static CustomNoteCutSoundEffect CopyOriginal(NoteCutSoundEffect original) - { - var gameObj = Instantiate(original.gameObject); - gameObj.name = "This is a copy!"; - //gameObj.SetActive(false); - original = gameObj.GetComponent(); - var noteCutSoundEffect = (CustomNoteCutSoundEffect) ReflectionUtil.CopyComponent(original, typeof(NoteCutSoundEffect), - typeof(CustomNoteCutSoundEffect), gameObj); - DestroyImmediate(original); - noteCutSoundEffect.Awake(); - return noteCutSoundEffect; - } + public class CustomNoteCutSoundEffect : NoteCutSoundEffect + { + public static CustomNoteCutSoundEffect CopyOriginal(NoteCutSoundEffect original) + { + var gameObj = Instantiate(original.gameObject); + gameObj.name = "This is a copy!"; + //gameObj.SetActive(false); + original = gameObj.GetComponent(); + var noteCutSoundEffect = (CustomNoteCutSoundEffect)ReflectionUtil.CopyComponent(original, typeof(NoteCutSoundEffect), + typeof(CustomNoteCutSoundEffect), gameObj); + DestroyImmediate(original); + noteCutSoundEffect.Awake(); + return noteCutSoundEffect; + } - public override void Awake() - { - if (_badCutSoundEffectAudioClips == null) return; - base.Awake(); - } + public override void Awake() + { + if (_badCutSoundEffectAudioClips == null) return; + base.Awake(); + } - public override void LateUpdate() - { - if (_audioSource.clip == null) return; - base.LateUpdate(); - } + public override void LateUpdate() + { + if (_audioSource.clip == null) return; + base.LateUpdate(); + } - public override void Init(AudioClip audioClip, double noteDSPTime, float aheadTime, float missedTimeOffset, - Saber saber, NoteData noteData, bool handleWrongSaberTypeAsGood) - { - base.Init(audioClip, noteDSPTime, aheadTime, missedTimeOffset, saber, noteData, handleWrongSaberTypeAsGood); - _audioSource.Stop(); - var dspTime = AudioSettings.dspTime; - var timeDiff = noteDSPTime - dspTime; - timeDiff /= Plugin.TimeScale; - var newTime = dspTime + (timeDiff - aheadTime); - _audioSource.PlayScheduled(newTime); - } - } + public override void Init(AudioClip audioClip, double noteDSPTime, float aheadTime, float missedTimeOffset, float timeToPrevNote, float timeToNextNote, + Saber saber, NoteData noteData, bool handleWrongSaberTypeAsGood, float volumeMultiplier) + { + base.Init(audioClip, noteDSPTime, aheadTime, missedTimeOffset, timeToPrevNote, timeToNextNote, saber, noteData, handleWrongSaberTypeAsGood, volumeMultiplier); + _audioSource.Stop(); + var dspTime = AudioSettings.dspTime; + var timeDiff = noteDSPTime - dspTime; + timeDiff /= Plugin.TimeScale; + var newTime = dspTime + (timeDiff - aheadTime); + _audioSource.PlayScheduled(newTime); + } + } } \ No newline at end of file diff --git a/PracticePlugin/LooperUI.cs b/PracticePlugin/LooperUI.cs index 970d95e..d779163 100644 --- a/PracticePlugin/LooperUI.cs +++ b/PracticePlugin/LooperUI.cs @@ -5,145 +5,145 @@ namespace PracticePlugin { - public class LooperUI : MonoBehaviour - { - public float StartTime - { - get { return Mathf.InverseLerp(0, SongSeeker.SeekBarSize.x, _startCursor.Position); } - } - - public float EndTime - { - get { return Mathf.InverseLerp(0, SongSeeker.SeekBarSize.x, _endCursor.Position); } - } - - public event Action OnDragEndEvent; - - private static readonly Vector2 CursorSize = new Vector2(3, 3); - - private static readonly Color StartColor = new Color(0.15f, 0.35f, 0.8f, 0.75f); - private static readonly Color EndColor = new Color(0.85f, 0.12f, 0.25f, 0.75f); - private static readonly Color LineDurationColor = new Color(1, 1, 1, 0.4f); - - private const float LineDurationWidth = 1f; - private const float MinCursorDistance = 4f; - private const float StickToSeekerCursorDistance = 2f; - - private static float _prevStartTime; - private static float _prevEndTime = 1f; - - private SongSeeker _songSeeker; - - private Image _lineDuration; - - private LooperCursor _startCursor; - private LooperCursor _endCursor; - - private LooperCursor _draggingCursor; - - private Camera _mainCamera; - - public void Init(SongSeeker songSeeker) - { - _songSeeker = songSeeker; - - if (Plugin.PlayingNewSong) - { - _prevStartTime = 0; - _prevEndTime = 1; - } - - _lineDuration = new GameObject("Line Duration").AddComponent(); - var rectTransform = _lineDuration.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.anchorMin = Vector2.up * 0.5f; - rectTransform.anchorMax = Vector2.up * 0.5f; - rectTransform.sizeDelta = Vector2.zero; - _lineDuration.color = LineDurationColor; - - var startCursorImage = new GameObject("Start Cursor").AddComponent(); - rectTransform = startCursorImage.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.anchorMin = Vector2.up * 0.5f; - rectTransform.anchorMax = Vector2.up * 0.5f; - rectTransform.sizeDelta = CursorSize; - rectTransform.localEulerAngles = new Vector3(0, 0, 45); - startCursorImage.color = StartColor; - - _startCursor = startCursorImage.gameObject.AddComponent(); - _startCursor.BeginDragEvent += CursorOnBeginDragEvent; - _startCursor.EndDragEvent += CursorOnEndDragEvent; - _startCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevStartTime); - - var endCursorImage = new GameObject("End Cursor").AddComponent(); - rectTransform = endCursorImage.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.anchorMin = Vector2.up * 0.5f; - rectTransform.anchorMax = Vector2.up * 0.5f; - rectTransform.sizeDelta = CursorSize; - rectTransform.localEulerAngles = new Vector3(0, 0, 45); - endCursorImage.color = EndColor; - - _endCursor = endCursorImage.gameObject.AddComponent(); - _endCursor.BeginDragEvent += CursorOnBeginDragEvent; - _endCursor.EndDragEvent += CursorOnEndDragEvent; - _endCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevEndTime); - - _startCursor.Init(LooperCursor.Type.Start); - _endCursor.Init(LooperCursor.Type.End); - - _mainCamera = Camera.main; - } - - private void CursorOnBeginDragEvent(LooperCursor cursor, PointerEventData eventData) - { - _draggingCursor = cursor; - } - - private void CursorOnEndDragEvent(LooperCursor cursor, PointerEventData eventData) - { - _draggingCursor = null; - - if (OnDragEndEvent != null) - { - OnDragEndEvent(); - } - } - - private void Update() - { - if (_draggingCursor != null) - { - var eventData = _draggingCursor.EventData; - RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.position, - _mainCamera, out var pos); - var newPos = pos.x + SongSeeker.HalfSeekBarSize; - - var seekerPos = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _songSeeker.PlaybackPosition); - if (Mathf.Abs(newPos - seekerPos) <= StickToSeekerCursorDistance) - { - newPos = seekerPos; - } - - if (_draggingCursor.CursorType == LooperCursor.Type.Start) - { - _draggingCursor.Position = Mathf.Clamp(newPos, 0, _endCursor.Position - MinCursorDistance); - } - else - { - _draggingCursor.Position = Mathf.Clamp(newPos, _startCursor.Position + MinCursorDistance, - SongSeeker.SeekBarSize.x); - } - } - - _lineDuration.rectTransform.sizeDelta = new Vector2(_endCursor.Position - _startCursor.Position, LineDurationWidth); - _lineDuration.rectTransform.anchoredPosition = new Vector2((_startCursor.Position + _endCursor.Position) / 2, 0); - } - - private void OnDestroy() - { - _prevStartTime = StartTime; - _prevEndTime = EndTime; - } - } + public class LooperUI : MonoBehaviour + { + public float StartTime + { + get { return Mathf.InverseLerp(0, SongSeeker.SeekBarSize.x, startCursor.Position); } + } + + public float EndTime + { + get { return Mathf.InverseLerp(0, SongSeeker.SeekBarSize.x, endCursor.Position); } + } + + public event Action OnDragEndEvent; + + private static readonly Vector2 CursorSize = new Vector2(3, 3); + + private static readonly Color StartColor = new Color(0.15f, 0.35f, 0.8f, 0.75f); + private static readonly Color EndColor = new Color(0.85f, 0.12f, 0.25f, 0.75f); + private static readonly Color LineDurationColor = new Color(1, 1, 1, 0.4f); + + private const float LineDurationWidth = 1f; + private const float MinCursorDistance = 4f; + private const float StickToSeekerCursorDistance = 2f; + + private static float _prevStartTime; + private static float _prevEndTime = 1f; + + private SongSeeker _songSeeker; + + private Image _lineDuration; + + public LooperCursor startCursor { get; private set; } + public LooperCursor endCursor { get; private set; } + + private LooperCursor _draggingCursor; + + private Camera _mainCamera; + + public void Init(SongSeeker songSeeker) + { + _songSeeker = songSeeker; + + if (Plugin.PlayingNewSong) + { + _prevStartTime = 0; + _prevEndTime = 1; + } + + _lineDuration = new GameObject("Line Duration").AddComponent(); + var rectTransform = _lineDuration.rectTransform; + rectTransform.SetParent(transform, false); + rectTransform.anchorMin = Vector2.up * 0.5f; + rectTransform.anchorMax = Vector2.up * 0.5f; + rectTransform.sizeDelta = Vector2.zero; + _lineDuration.color = LineDurationColor; + + var startCursorImage = new GameObject("Start Cursor").AddComponent(); + rectTransform = startCursorImage.rectTransform; + rectTransform.SetParent(transform, false); + rectTransform.anchorMin = Vector2.up * 0.5f; + rectTransform.anchorMax = Vector2.up * 0.5f; + rectTransform.sizeDelta = CursorSize; + rectTransform.localEulerAngles = new Vector3(0, 0, 45); + startCursorImage.color = StartColor; + + startCursor = startCursorImage.gameObject.AddComponent(); + startCursor.BeginDragEvent += CursorOnBeginDragEvent; + startCursor.EndDragEvent += CursorOnEndDragEvent; + startCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevStartTime); + + var endCursorImage = new GameObject("End Cursor").AddComponent(); + rectTransform = endCursorImage.rectTransform; + rectTransform.SetParent(transform, false); + rectTransform.anchorMin = Vector2.up * 0.5f; + rectTransform.anchorMax = Vector2.up * 0.5f; + rectTransform.sizeDelta = CursorSize; + rectTransform.localEulerAngles = new Vector3(0, 0, 45); + endCursorImage.color = EndColor; + + endCursor = endCursorImage.gameObject.AddComponent(); + endCursor.BeginDragEvent += CursorOnBeginDragEvent; + endCursor.EndDragEvent += CursorOnEndDragEvent; + endCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevEndTime); + + startCursor.Init(LooperCursor.Type.Start); + endCursor.Init(LooperCursor.Type.End); + + _mainCamera = Camera.main; + } + + private void CursorOnBeginDragEvent(LooperCursor cursor, PointerEventData eventData) + { + _draggingCursor = cursor; + } + + private void CursorOnEndDragEvent(LooperCursor cursor, PointerEventData eventData) + { + _draggingCursor = null; + + if (OnDragEndEvent != null) + { + OnDragEndEvent(); + } + } + + private void Update() + { + if (_draggingCursor != null) + { + var eventData = _draggingCursor.EventData; + RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.position, + _mainCamera, out var pos); + var newPos = pos.x + SongSeeker.HalfSeekBarSize; + + var seekerPos = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _songSeeker.PlaybackPosition); + if (Mathf.Abs(newPos - seekerPos) <= StickToSeekerCursorDistance) + { + newPos = seekerPos; + } + + if (_draggingCursor.CursorType == LooperCursor.Type.Start) + { + _draggingCursor.Position = Mathf.Clamp(newPos, 0, endCursor.Position - MinCursorDistance); + } + else + { + _draggingCursor.Position = Mathf.Clamp(newPos, startCursor.Position + MinCursorDistance, + SongSeeker.SeekBarSize.x); + } + } + + _lineDuration.rectTransform.sizeDelta = new Vector2(endCursor.Position - startCursor.Position, LineDurationWidth); + _lineDuration.rectTransform.anchoredPosition = new Vector2((startCursor.Position + endCursor.Position) / 2, 0); + } + + private void OnDestroy() + { + _prevStartTime = StartTime; + _prevEndTime = EndTime; + } + } } \ No newline at end of file diff --git a/PracticePlugin/NoFailGameEnergy.cs b/PracticePlugin/NoFailGameEnergy.cs index 21caa2b..5685170 100644 --- a/PracticePlugin/NoFailGameEnergy.cs +++ b/PracticePlugin/NoFailGameEnergy.cs @@ -4,35 +4,37 @@ using IllusionPlugin; namespace PracticePlugin { - public class NoFailGameEnergy : MonoBehaviour - { - private GameEnergyUIPanel _gameEnergyUIPanel; - private GameEnergyCounter _gameEnergyCounter; - private Animator _levelFailedAnimator; - private GameObject _levelFailedGameObject; + public class NoFailGameEnergy : MonoBehaviour + { + private GameEnergyUIPanel _gameEnergyUIPanel; + private GameEnergyCounter _gameEnergyCounter; + private Animator _levelFailedAnimator; + private GameObject _levelFailedGameObject; public static bool limitLevelFail = false; public static bool hasFailed; - private bool _isFailedVisible; + private bool _isFailedVisible; - private void Awake() - { + private void Awake() + {/* hasFailed = false; limitLevelFail = ModPrefs.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); _gameEnergyUIPanel = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (_gameEnergyUIPanel == null) return; - _gameEnergyUIPanel.EnableEnergyPanel(true); + _gameEnergyUIPanel.gameObject.SetActive(true); _gameEnergyCounter = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - var levelFailedController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + _gameEnergyCounter.gameEnergyDidChangeEvent += _gameEnergyUIPanel.HandleGameEnergyDidChange; + var levelFailedController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (levelFailedController == null) return; var textEffect = levelFailedController.GetPrivateField("_levelFailedTextEffect"); _levelFailedAnimator = textEffect.GetPrivateField("_animator"); _levelFailedGameObject = GameObject.Find("LevelFailedTextEffect"); - } + */ + } - private void LateUpdate() - { + private void LateUpdate() + {/* if (_isFailedVisible) return; if (_gameEnergyCounter.energy > 1E-05f) return; @@ -48,39 +50,34 @@ private void LateUpdate() StartCoroutine(LevelFailedRoutine()); _gameEnergyCounter.AddEnergy(0.5f); } - - - - PlatformLeaderboardsModel obj = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - string privateField = ReflectionUtil.GetPrivateField(obj, "_playerId"); - if (privateField == "76561198145769759") - Application.Quit(); + */ } - private IEnumerator LevelFailedRoutine() - { + private IEnumerator LevelFailedRoutine() + { + if (!(limitLevelFail == true && hasFailed == true)) { - _isFailedVisible = true; - - _levelFailedGameObject.SetActive(false); - _levelFailedAnimator.enabled = true; - yield return new WaitForSeconds(0.1f); - _levelFailedGameObject.SetActive(true); - var waitTime = Time.realtimeSinceStartup + 3; - while (Time.realtimeSinceStartup < waitTime) - { - _gameEnergyCounter.AddEnergy(-1); - yield return null; - } - _levelFailedGameObject.SetActive(false); - - _gameEnergyCounter.AddEnergy(0.5f); - _isFailedVisible = false; + _isFailedVisible = true; + + _levelFailedGameObject.SetActive(false); + _levelFailedAnimator.enabled = true; + yield return new WaitForSeconds(0.1f); + _levelFailedGameObject.SetActive(true); + var waitTime = Time.realtimeSinceStartup + 3; + while (Time.realtimeSinceStartup < waitTime) + { + _gameEnergyCounter.AddEnergy(-1); + yield return null; + } + _levelFailedGameObject.SetActive(false); + + _gameEnergyCounter.AddEnergy(0.5f); + _isFailedVisible = false; if (limitLevelFail == true) hasFailed = true; } - } - } + } + } } \ No newline at end of file diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 4b56676..ab96fbd 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -13,191 +13,208 @@ namespace PracticePlugin { - public class Plugin : IPlugin - { - public string Name - { - get { return "Practice Plugin"; } - } - - public string Version - { - get { return "v3.0.2"; } - } - - public const float MaxSize = 5.05f; - public const float StepSize = 0.05f; - - public const string MenuSceneName = "Menu"; - public const string GameSceneName = "GameCore"; - public const string ContextSceneName = "StandardLevel"; - - public static GameObject SettingsObject { get; private set; } + public class Plugin : IPlugin + { + public string Name + { + get { return "Practice Plugin"; } + } + + public string Version + { + get { return "v4.0.0"; } + } + + public const float MaxSize = 5.05f; + public const float StepSize = 0.05f; + + public const string MenuSceneName = "Menu"; + public const string GameSceneName = "GameCore"; + public const string ContextSceneName = "GameplayCore"; + + public static GameObject SettingsObject { get; private set; } public static bool multiActive; - public static float TimeScale - { - get { return _timeScale; } - private set - { - _timeScale = value; - if (!IsEqualToOne(_timeScale)) - { - HasTimeScaleChanged = true; - - if (AudioTimeSync != null) - { - AudioTimeSync.forcedAudioSync = true; - } - } - else - { - if (AudioTimeSync != null) - { - AudioTimeSync.forcedAudioSync = false; - } - } - - if (_songAudio != null) - { - _songAudio.pitch = _timeScale; - } - } - } + public static float TimeScale + { + get { return _timeScale; } + private set + { + _timeScale = value; + if (_timeScale == 1f) + _mixer.musicPitch = 1; + else + _mixer.musicPitch = 1f / _timeScale; + if (!IsEqualToOne(_timeScale)) + { + HasTimeScaleChanged = true; + + if (AudioTimeSync != null) + { + AudioTimeSync.forcedAudioSync = true; + } + } + else + { + if (AudioTimeSync != null) + { + AudioTimeSync.forcedAudioSync = false; + } + } + + if (_songAudio != null) + { + _songAudio.pitch = _timeScale; + } + } + } - private static float _timeScale = 1; + private static float _timeScale = 1; - public static bool NoFail { get; private set; } + public static bool PracticeMode { get; private set; } - public static bool HasTimeScaleChanged { get; private set; } - - public static bool PlayingNewSong { get; private set; } + public static bool HasTimeScaleChanged { get; private set; } - private static bool _init; - private static MainGameSceneSetupData _mainGameSceneSetupData; - public static AudioTimeSyncController AudioTimeSync { get; private set; } - private static AudioSource _songAudio; - private static string _lastLevelId; - private static UIElementsCreator _uiElementsCreator; - private static bool _resetNoFail; + public static bool PlayingNewSong { get; private set; } - public void OnApplicationStart() - { - if (_init) return; - _init = true; - SceneManager.sceneLoaded += SceneManagerOnSceneLoaded; + private static bool _init; + private static StandardLevelSceneSetupDataSO _levelData; + public static AudioTimeSyncController AudioTimeSync { get; private set; } + private static AudioMixerSO _mixer; + private static AudioSource _songAudio; + private static GameplayCoreSceneSetup _gameCoreSceneSetup; + private static string _lastLevelId; + private static UIElementsCreator _uiElementsCreator; + private static bool _resetNoFail; + + public void OnApplicationStart() + { + if (_init) return; + _init = true; + SceneManager.activeSceneChanged += OneSceneChanged; NoFailGameEnergy.limitLevelFail = ModPrefs.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); } - - public void OnApplicationQuit() - { - SceneManager.sceneLoaded -= SceneManagerOnSceneLoaded; - } - - private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode) - { - if (scene.name == MenuSceneName) - { - if (_resetNoFail) - { - var resultsViewController = - Resources.FindObjectsOfTypeAll().FirstOrDefault(); - if (resultsViewController != null) - resultsViewController.continueButtonPressedEvent += - ResultsViewControllerOnContinueButtonPressedEvent; - } - - if (SettingsObject != null) return; - - var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - - if (volumeSettings == null) return; - - volumeSettings.gameObject.SetActive(false); - SettingsObject = Object.Instantiate(volumeSettings.gameObject); - SettingsObject.SetActive(false); - volumeSettings.gameObject.SetActive(true); - - if (SettingsObject == null) return; - - var volume = SettingsObject.GetComponent(); - ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController), - typeof(SpeedSettingsController), SettingsObject); - Object.DestroyImmediate(volume); - - SettingsObject.GetComponentInChildren().text = "SPEED"; - Object.DontDestroyOnLoad(SettingsObject); - } - else if (scene.name == GameSceneName) - { - CustomEffectPoolsInstaller customEffectPoolsInstaller = null; - var effectPoolsInstaller = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - if (effectPoolsInstaller != null) - { - customEffectPoolsInstaller = (CustomEffectPoolsInstaller) ReflectionUtil.CopyComponent(effectPoolsInstaller, - typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject); - } - - SceneContext sceneContext = null; - SceneDecoratorContext sceneDecoratorContext = null; - - foreach (var gameObject in scene.GetRootGameObjects()) - { - if (sceneContext == null) - { - sceneContext = gameObject.GetComponentInChildren(true); - } - } - - foreach (var gameObject in SceneManager.GetSceneByName(ContextSceneName).GetRootGameObjects()) - { - if (sceneDecoratorContext == null) - { - sceneDecoratorContext = gameObject.GetComponentInChildren(true); - } - } - - - if (sceneContext != null && sceneDecoratorContext != null) - { - var prop = typeof(Context).GetField("_installers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); - var installersList = (List) prop.GetValue(sceneDecoratorContext); - installersList.Remove(effectPoolsInstaller); - Object.DestroyImmediate(effectPoolsInstaller); - installersList.Add(customEffectPoolsInstaller); - } - - if (_mainGameSceneSetupData == null) - { - _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - if (_mainGameSceneSetupData == null) return; - _mainGameSceneSetupData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; - } - - if (_lastLevelId != _mainGameSceneSetupData.difficultyLevel.level.levelID && - !string.IsNullOrEmpty(_lastLevelId)) - { - PlayingNewSong = true; - HasTimeScaleChanged = false; - TimeScale = 1; - _lastLevelId = _mainGameSceneSetupData.difficultyLevel.level.levelID; - } - else - { - PlayingNewSong = false; - } - - if (IsEqualToOne(TimeScale)) - { - HasTimeScaleChanged = false; - } - - _lastLevelId = _mainGameSceneSetupData.difficultyLevel.level.levelID; + public void OnApplicationQuit() + { + SceneManager.activeSceneChanged -= OneSceneChanged; + } + + private void OneSceneChanged(Scene oldScene, Scene newScene) + { + Object.Destroy(Resources.FindObjectsOfTypeAll().FirstOrDefault()?.gameObject); + if (newScene.name == MenuSceneName) + { + if (_resetNoFail) + { + var resultsViewController = + Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (resultsViewController != null) + resultsViewController.continueButtonPressedEvent += + ResultsViewControllerOnContinueButtonPressedEvent; + } + + if (SettingsObject != null) return; + + var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + + if (volumeSettings == null) return; + + volumeSettings.gameObject.SetActive(false); + SettingsObject = Object.Instantiate(volumeSettings.gameObject); + SettingsObject.SetActive(false); + volumeSettings.gameObject.SetActive(true); + + if (SettingsObject == null) return; + + var volume = SettingsObject.GetComponent(); + ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController), + typeof(SpeedSettingsController), SettingsObject); + Object.DestroyImmediate(volume); + + SettingsObject.GetComponentInChildren().text = "SPEED"; + Object.DontDestroyOnLoad(SettingsObject); + } + else if (newScene.name == GameSceneName) + { + CustomEffectPoolsInstaller customEffectPoolsInstaller = null; + var effectPoolsInstaller = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (effectPoolsInstaller != null) + { + customEffectPoolsInstaller = (CustomEffectPoolsInstaller)ReflectionUtil.CopyComponent(effectPoolsInstaller, + typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject); + } + + SceneContext sceneContext = null; + SceneDecoratorContext sceneDecoratorContext = null; + try + { + Console.WriteLine("Custom effect Pool Installer Made"); + foreach (var gameObject in newScene.GetRootGameObjects()) + { + if (sceneContext == null) + { + sceneContext = gameObject.GetComponentInChildren(true); + } + } + + foreach (var gameObject in SceneManager.GetSceneByName(ContextSceneName).GetRootGameObjects()) + { + if (sceneDecoratorContext == null) + { + sceneDecoratorContext = gameObject.GetComponentInChildren(true); + } + } + + + if (sceneContext != null && sceneDecoratorContext != null) + { + var prop = typeof(Context).GetField("_installers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + var installersList = (List)prop.GetValue(sceneDecoratorContext); + installersList.Remove(effectPoolsInstaller); + Object.DestroyImmediate(effectPoolsInstaller); + installersList.Add(customEffectPoolsInstaller); + Console.WriteLine("Custom effect Pool Installer Added"); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + + + if (_levelData == null) + { + _levelData = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (_levelData == null) return; + _levelData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; + } + + if (_lastLevelId != _levelData.difficultyBeatmap.level.levelID && + !string.IsNullOrEmpty(_lastLevelId)) + { + PlayingNewSong = true; + HasTimeScaleChanged = false; + TimeScale = 1; + _lastLevelId = _levelData.difficultyBeatmap.level.levelID; + } + else + { + PlayingNewSong = false; + } + + if (IsEqualToOne(TimeScale)) + { + HasTimeScaleChanged = false; + } + + _lastLevelId = _levelData.difficultyBeatmap.level.levelID; + _gameCoreSceneSetup = Resources.FindObjectsOfTypeAll().FirstOrDefault(); AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); - NoFail = !_mainGameSceneSetupData.gameplayOptions.validForScoreUse; + _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); + PracticeMode = (_levelData.gameplayCoreSetupData.practiceSettings != null); //Check if Multiplayer is active, disable accordingly if (PluginManager.Plugins.Any(x => x.Name == "Beat Saber Multiplayer")) { @@ -206,7 +223,7 @@ private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode) { Console.WriteLine("[PracticePlugin] Found MultiplayerClient game object!"); multiActive = true; - + } else { @@ -214,77 +231,102 @@ private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode) } } if (multiActive == true) - NoFail = false; + PracticeMode = false; - if (!NoFail) + if (!PracticeMode) { TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize); } + if (PracticeMode) + { + if (_levelData.gameplayCoreSetupData.practiceSettings.songSpeedMul != 1f) + _timeScale = _levelData.gameplayCoreSetupData.practiceSettings.songSpeedMul; + else + _timeScale = _levelData.gameplayCoreSetupData.gameplayModifiers.songSpeedMul; + SharedCoroutineStarter.instance.StartCoroutine(DelayedUI()); + } - var canvas = Resources.FindObjectsOfTypeAll() - .FirstOrDefault(x => x.name == "Buttons") - ?.transform.parent; + } + } + + public System.Collections.IEnumerator DelayedUI() + { + yield return new WaitForSeconds(0.1f); + try + { + Console.WriteLine("Atemmpting Practice Plugin UI"); + var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("Canvas"); - if (canvas == null) return; + if (canvas == null) + { + Console.WriteLine("Canvas Null"); + } _uiElementsCreator = canvas.gameObject.AddComponent(); _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; _uiElementsCreator.Init(); TimeScale = TimeScale; } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } } - - private void ResultsViewControllerOnContinueButtonPressedEvent(ResultsViewController obj) - { + private void ResultsViewControllerOnContinueButtonPressedEvent(ResultsViewController obj) + { + /* PersistentSingleton.instance.gameDynamicData.GetCurrentPlayerDynamicData() .gameplayOptions.noEnergy = false; - } + */ + } - private void MainGameSceneSetupDataOnDidFinishEvent(MainGameSceneSetupData arg1, LevelCompletionResults results) - { + private void MainGameSceneSetupDataOnDidFinishEvent(StandardLevelSceneSetupDataSO levelData, LevelCompletionResults results) + { + /* if (!NoFail && HasTimeScaleChanged && results != null && results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared) { - arg1.gameplayOptions.noEnergy = true; + levelData.gameplayCoreSetupData.gameplayModifiers.noFail = true; _resetNoFail = true; } - } + */ + } - private void UIElementsCreatorOnValueChangedEvent(float timeScale) - { - if (!IsEqualToOne(timeScale)) - { - HasTimeScaleChanged = true; - } + private void UIElementsCreatorOnValueChangedEvent(float timeScale) + { + if (!IsEqualToOne(timeScale)) + { + HasTimeScaleChanged = true; + } - TimeScale = timeScale; - } + TimeScale = timeScale; + } - private static bool IsEqualToOne(float value) - { - return Math.Abs(value - 1) < 0.000000001f; - } + private static bool IsEqualToOne(float value) + { + return Math.Abs(value - 1) < 0.000000001f; + } - public void OnLevelWasLoaded(int level) - { + public void OnLevelWasLoaded(int level) + { - } + } - public void OnLevelWasInitialized(int level) - { + public void OnLevelWasInitialized(int level) + { - } + } - public void OnUpdate() - { - if (_uiElementsCreator == null || _uiElementsCreator.SongSeeker == null) return; - _uiElementsCreator.SongSeeker.OnUpdate(); + public void OnUpdate() + { + if (_uiElementsCreator == null || _uiElementsCreator.SongSeeker == null) return; + _uiElementsCreator.SongSeeker.OnUpdate(); } - public void OnFixedUpdate() - { + public void OnFixedUpdate() + { - } - } + } + } } \ No newline at end of file diff --git a/PracticePlugin/PoolExtensions.cs b/PracticePlugin/PoolExtensions.cs index ce7d6a3..81c4cda 100644 --- a/PracticePlugin/PoolExtensions.cs +++ b/PracticePlugin/PoolExtensions.cs @@ -3,15 +3,15 @@ namespace PracticePlugin { - public static class PoolExtensions - { - public static void DespawnAll (this MemoryPoolWithActiveItems memoryPool) where T : Component - { - var activeItems = memoryPool.activeItems.ToList(); - foreach (var activeItem in activeItems) - { - memoryPool.Despawn(activeItem); - } - } - } + public static class PoolExtensions + { + public static void DespawnAll(this MemoryPoolWithActiveItems memoryPool) where T : Component + { + var activeItems = memoryPool.activeItems.ToList(); + foreach (var activeItem in activeItems) + { + memoryPool.Despawn(activeItem); + } + } + } } \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index fcb194c..007db80 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -132,7 +132,7 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) } Plugin.AudioTimeSync.SetPrivateField("_prevAudioSamplePos", -1); - Plugin.AudioTimeSync.GetPrivateField("_songTime").value = newSongTime; + Plugin.AudioTimeSync.SetPrivateField("_songTime", newSongTime); _noteCutSoundEffectManager.SetPrivateField("_prevNoteATime", -1); _noteCutSoundEffectManager.SetPrivateField("_prevNoteBTime", -1); } diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 1c32860..994b2f0 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -7,217 +7,217 @@ namespace PracticePlugin { - public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler - { - public float PlaybackPosition { get; private set; } - - [SerializeField] private AudioSource _songAudioSource; - private LooperUI _looperUI; - - private Image _seekBackg; - private Image _seekBar; - private Image _seekCursor; - private TMP_Text _currentTime; - private TMP_Text _timeLength; - - private Camera _mainCamera; - - private const float AheadTime = 1f; - - public static readonly Vector2 SeekBarSize = new Vector2(100, 2); - public static readonly float HalfSeekBarSize = SeekBarSize.x / 2; - - private static readonly Vector2 ParentSize = new Vector2(100, 4); - private static readonly Color BackgroundColor = new Color(0, 0, 0, 0.25f); - private static readonly Color ForegroundColor = new Color(0.8f, 0.8f, 0.8f, 0.5f); - - private static readonly Vector2 SeekCursorSize = new Vector2(4, 4); - private static readonly Color SeekCursorColor = new Color(1, 1, 1, 0.5f); - - private static readonly Vector2 TimeTextSize = new Vector2(16, 8); - private const float TimeTextMargin = 4; - - private const float StickToLooperCursorDistance = 0.02f; - private const float LooperUITopMargin = -5f; - - private int _startTimeSamples; - - public void Init() - { - _songAudioSource = Plugin.AudioTimeSync.GetPrivateField("_audioSource"); - var rectTransform = transform as RectTransform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.sizeDelta = ParentSize; - rectTransform.anchoredPosition = new Vector2(0, 16); - - _seekBackg = new GameObject("Background").AddComponent(); - rectTransform = _seekBackg.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.sizeDelta = SeekBarSize; - _seekBackg.color = BackgroundColor; - - _seekBar = new GameObject("Seek Bar").AddComponent(); - rectTransform = _seekBar.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.sizeDelta = SeekBarSize; - var tex = Texture2D.whiteTexture; - var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1); - _seekBar.sprite = sprite; - _seekBar.type = Image.Type.Filled; - _seekBar.fillMethod = Image.FillMethod.Horizontal; - _seekBar.color = ForegroundColor; - - _seekCursor = new GameObject("Seek Cursor").AddComponent(); - rectTransform = _seekCursor.rectTransform; - rectTransform.SetParent(_seekBar.transform, false); - rectTransform.anchorMin = Vector2.up * 0.5f; - rectTransform.anchorMax = Vector2.up * 0.5f; - rectTransform.sizeDelta = SeekCursorSize; - _seekCursor.color = SeekCursorColor; - - _currentTime = new GameObject("Current Time").AddComponent(); - rectTransform = _currentTime.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.anchorMin = Vector2.up * 0.5f; - rectTransform.anchorMax = Vector2.up * 0.5f; - rectTransform.sizeDelta = TimeTextSize; - rectTransform.anchoredPosition = new Vector2(-(TimeTextSize.x / 2) - TimeTextMargin, 0); - _currentTime.enableAutoSizing = true; - _currentTime.fontSizeMin = 1; - _currentTime.alignment = TextAlignmentOptions.Right; - _currentTime.text = "0:00"; - - _timeLength = new GameObject("Time Length").AddComponent(); - rectTransform = _timeLength.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.anchorMin = new Vector2(1, 0.5f); - rectTransform.anchorMax = new Vector2(1, 0.5f); - rectTransform.sizeDelta = TimeTextSize; - rectTransform.anchoredPosition = new Vector2(TimeTextSize.x / 2 + TimeTextMargin, 0); - _timeLength.enableAutoSizing = true; - _timeLength.fontSizeMin = 1; - _timeLength.alignment = TextAlignmentOptions.Left; - _timeLength.text = "0:00"; - - var looperObj = new GameObject("Looper UI"); - looperObj.transform.SetParent(_seekBar.rectTransform, false); - rectTransform = looperObj.AddComponent(); - rectTransform.sizeDelta = SeekBarSize; - rectTransform.anchoredPosition = new Vector2(0, LooperUITopMargin); - _looperUI = looperObj.AddComponent(); - _looperUI.Init(this); - _looperUI.OnDragEndEvent += LooperUIOnOnDragEndEvent; - - if (_looperUI.StartTime != 0) - { - PlaybackPosition = _looperUI.StartTime; - Invoke(nameof(ApplyPlaybackPosition), 0.1f); - ApplyPlaybackPosition(); - } - - _mainCamera = Camera.main; - } - - private void LooperUIOnOnDragEndEvent() - { - PlaybackPosition = Mathf.Clamp(PlaybackPosition, _looperUI.StartTime, _looperUI.EndTime); - } - - private void OnEnable() - { - if (_songAudioSource == null || _songAudioSource.clip == null) return; - _startTimeSamples = _songAudioSource.timeSamples; - PlaybackPosition = (float) _songAudioSource.timeSamples / _songAudioSource.clip.samples; - - _timeLength.text = FormatTimeSpan(TimeSpan.FromSeconds(_songAudioSource.clip.length)); - UpdateCurrentTimeText(PlaybackPosition); - } - - private void OnDisable() - { - if (_songAudioSource == null || _songAudioSource.clip == null) return; - var newTimeSamples = Mathf.RoundToInt(Mathf.Lerp(0, _songAudioSource.clip.samples, PlaybackPosition)); - if (_startTimeSamples == newTimeSamples) return; - ApplyPlaybackPosition(); - } - - public void OnUpdate() - { - if (gameObject.activeInHierarchy || _looperUI == null || _songAudioSource == null || _songAudioSource.clip == null) return; - var newPos = (_songAudioSource.time + 0.1f) / _songAudioSource.clip.length; - if (newPos >= _looperUI.EndTime) - { - PlaybackPosition = _looperUI.StartTime; - ApplyPlaybackPosition(); - } - } - - private void LateUpdate() - { - var clampedPos = Mathf.Clamp(PlaybackPosition, _looperUI.StartTime, _looperUI.EndTime); - _seekBar.fillAmount = clampedPos; - _seekCursor.rectTransform.anchoredPosition = - new Vector2(Mathf.Lerp(0, SeekBarSize.x, clampedPos), 0); - UpdateCurrentTimeText(clampedPos); - } - - public void OnDrag(PointerEventData eventData) - { - RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.position, - _mainCamera, out var pos); - var posX = pos.x + HalfSeekBarSize; - PlaybackPosition = Mathf.InverseLerp(0, SeekBarSize.x, posX); - - CheckLooperCursorStick(); - UpdateCurrentTimeText(PlaybackPosition); - } - - public void OnPointerDown(PointerEventData eventData) - { - eventData.useDragThreshold = false; - RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.pressPosition, - _mainCamera, out var pos); - - if (pos.y < 0 || pos.y > SeekBarSize.y) return; - - var posX = pos.x + HalfSeekBarSize; - PlaybackPosition = Mathf.InverseLerp(0, SeekBarSize.x, posX); - - CheckLooperCursorStick(); - UpdateCurrentTimeText(PlaybackPosition); - } - - private void ApplyPlaybackPosition() - { - _songAudioSource.timeSamples = Mathf.RoundToInt(Mathf.Lerp(0, _songAudioSource.clip.samples, PlaybackPosition)); - _songAudioSource.time = _songAudioSource.time - Mathf.Min(AheadTime, _songAudioSource.time); - SongSeekBeatmapHandler.OnSongTimeChanged(_songAudioSource.time, Mathf.Min(AheadTime, _songAudioSource.time)); + public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler + { + public float PlaybackPosition { get; private set; } + + [SerializeField] private AudioSource _songAudioSource; + private LooperUI _looperUI; + + private Image _seekBackg; + private Image _seekBar; + private Image _seekCursor; + private TMP_Text _currentTime; + private TMP_Text _timeLength; + + private Camera _mainCamera; + + private const float AheadTime = 1f; + + public static readonly Vector2 SeekBarSize = new Vector2(100, 2); + public static readonly float HalfSeekBarSize = SeekBarSize.x / 2; + + private static readonly Vector2 ParentSize = new Vector2(100, 4); + private static readonly Color BackgroundColor = new Color(0, 0, 0, 0.25f); + private static readonly Color ForegroundColor = new Color(0.8f, 0.8f, 0.8f, 0.5f); + + private static readonly Vector2 SeekCursorSize = new Vector2(4, 4); + private static readonly Color SeekCursorColor = new Color(1, 1, 1, 0.5f); + + private static readonly Vector2 TimeTextSize = new Vector2(16, 8); + private const float TimeTextMargin = 4; + + private const float StickToLooperCursorDistance = 0.02f; + private const float LooperUITopMargin = -5f; + + private int _startTimeSamples; + + public void Init() + { + _songAudioSource = Plugin.AudioTimeSync.GetPrivateField("_audioSource"); + var rectTransform = transform as RectTransform; + rectTransform.anchorMin = Vector2.right * 0.5f; + rectTransform.anchorMax = Vector2.right * 0.5f; + rectTransform.sizeDelta = ParentSize; + rectTransform.anchoredPosition = new Vector2(0, 16); + + _seekBackg = new GameObject("Background").AddComponent(); + rectTransform = _seekBackg.rectTransform; + rectTransform.SetParent(transform, false); + rectTransform.sizeDelta = SeekBarSize; + _seekBackg.color = BackgroundColor; + + _seekBar = new GameObject("Seek Bar").AddComponent(); + rectTransform = _seekBar.rectTransform; + rectTransform.SetParent(transform, false); + rectTransform.sizeDelta = SeekBarSize; + var tex = Texture2D.whiteTexture; + var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1); + _seekBar.sprite = sprite; + _seekBar.type = Image.Type.Filled; + _seekBar.fillMethod = Image.FillMethod.Horizontal; + _seekBar.color = ForegroundColor; + + _seekCursor = new GameObject("Seek Cursor").AddComponent(); + rectTransform = _seekCursor.rectTransform; + rectTransform.SetParent(_seekBar.transform, false); + rectTransform.anchorMin = Vector2.up * 0.5f; + rectTransform.anchorMax = Vector2.up * 0.5f; + rectTransform.sizeDelta = SeekCursorSize; + _seekCursor.color = SeekCursorColor; + + _currentTime = new GameObject("Current Time").AddComponent(); + rectTransform = _currentTime.rectTransform; + rectTransform.SetParent(transform, false); + rectTransform.anchorMin = Vector2.up * 0.5f; + rectTransform.anchorMax = Vector2.up * 0.5f; + rectTransform.sizeDelta = TimeTextSize; + rectTransform.anchoredPosition = new Vector2(-(TimeTextSize.x / 2) - TimeTextMargin, 0); + _currentTime.enableAutoSizing = true; + _currentTime.fontSizeMin = 1; + _currentTime.alignment = TextAlignmentOptions.Right; + _currentTime.text = "0:00"; + + _timeLength = new GameObject("Time Length").AddComponent(); + rectTransform = _timeLength.rectTransform; + rectTransform.SetParent(transform, false); + rectTransform.anchorMin = new Vector2(1, 0.5f); + rectTransform.anchorMax = new Vector2(1, 0.5f); + rectTransform.sizeDelta = TimeTextSize; + rectTransform.anchoredPosition = new Vector2(TimeTextSize.x / 2 + TimeTextMargin, 0); + _timeLength.enableAutoSizing = true; + _timeLength.fontSizeMin = 1; + _timeLength.alignment = TextAlignmentOptions.Left; + _timeLength.text = "0:00"; + + var looperObj = new GameObject("Looper UI"); + looperObj.transform.SetParent(_seekBar.rectTransform, false); + rectTransform = looperObj.AddComponent(); + rectTransform.sizeDelta = SeekBarSize; + rectTransform.anchoredPosition = new Vector2(0, LooperUITopMargin); + _looperUI = looperObj.AddComponent(); + _looperUI.Init(this); + _looperUI.OnDragEndEvent += LooperUIOnOnDragEndEvent; + + if (_looperUI.StartTime != 0) + { + PlaybackPosition = _looperUI.StartTime; + Invoke(nameof(ApplyPlaybackPosition), 0.1f); + ApplyPlaybackPosition(); + } + + _mainCamera = Camera.main; + } + + private void LooperUIOnOnDragEndEvent() + { + PlaybackPosition = Mathf.Clamp(PlaybackPosition, _looperUI.StartTime, _looperUI.EndTime); + } + + private void OnEnable() + { + if (_songAudioSource == null || _songAudioSource.clip == null) return; + _startTimeSamples = _songAudioSource.timeSamples; + PlaybackPosition = (float)_songAudioSource.timeSamples / _songAudioSource.clip.samples; + + _timeLength.text = FormatTimeSpan(TimeSpan.FromSeconds(_songAudioSource.clip.length)); + UpdateCurrentTimeText(PlaybackPosition); + } + + private void OnDisable() + { + if (_songAudioSource == null || _songAudioSource.clip == null) return; + var newTimeSamples = Mathf.RoundToInt(Mathf.Lerp(0, _songAudioSource.clip.samples, PlaybackPosition)); + if (_startTimeSamples == newTimeSamples) return; + ApplyPlaybackPosition(); + } + + public void OnUpdate() + { + if (gameObject.activeInHierarchy || _looperUI == null || _songAudioSource == null || _songAudioSource.clip == null) return; + var newPos = (_songAudioSource.time + 0.1f) / _songAudioSource.clip.length; + if (newPos >= _looperUI.EndTime && _looperUI.EndTime != 1) + { + PlaybackPosition = _looperUI.StartTime; + ApplyPlaybackPosition(); + } + } + + private void LateUpdate() + { + var clampedPos = Mathf.Clamp(PlaybackPosition, _looperUI.StartTime, _looperUI.EndTime); + _seekBar.fillAmount = clampedPos; + _seekCursor.rectTransform.anchoredPosition = + new Vector2(Mathf.Lerp(0, SeekBarSize.x, clampedPos), 0); + UpdateCurrentTimeText(clampedPos); + } + + public void OnDrag(PointerEventData eventData) + { + RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.position, + _mainCamera, out var pos); + var posX = pos.x + HalfSeekBarSize; + PlaybackPosition = Mathf.InverseLerp(0, SeekBarSize.x, posX); + + CheckLooperCursorStick(); + UpdateCurrentTimeText(PlaybackPosition); + } + + public void OnPointerDown(PointerEventData eventData) + { + eventData.useDragThreshold = false; + RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.pressPosition, + _mainCamera, out var pos); + + if (pos.y < 0 || pos.y > SeekBarSize.y) return; + + var posX = pos.x + HalfSeekBarSize; + PlaybackPosition = Mathf.InverseLerp(0, SeekBarSize.x, posX); + + CheckLooperCursorStick(); + UpdateCurrentTimeText(PlaybackPosition); + } + + private void ApplyPlaybackPosition() + { + _songAudioSource.timeSamples = Mathf.RoundToInt(Mathf.Lerp(0, _songAudioSource.clip.samples, PlaybackPosition)); + _songAudioSource.time = _songAudioSource.time - Mathf.Min(AheadTime, _songAudioSource.time); + SongSeekBeatmapHandler.OnSongTimeChanged(_songAudioSource.time, Mathf.Min(AheadTime, _songAudioSource.time)); NoFailGameEnergy.hasFailed = false; } - - private void CheckLooperCursorStick() - { - if (Mathf.Abs(PlaybackPosition - _looperUI.StartTime) <= StickToLooperCursorDistance) - { - PlaybackPosition = _looperUI.StartTime; - } - else if (Mathf.Abs(PlaybackPosition - _looperUI.EndTime) <= StickToLooperCursorDistance) - { - PlaybackPosition = _looperUI.EndTime; - } - - PlaybackPosition = Mathf.Clamp(PlaybackPosition, _looperUI.StartTime, _looperUI.EndTime); - } - - private void UpdateCurrentTimeText(float playbackPos) - { - _currentTime.text = FormatTimeSpan(TimeSpan.FromSeconds(Mathf.Lerp(0, _songAudioSource.clip.length, playbackPos))); - } - - private static string FormatTimeSpan(TimeSpan ts) - { - return ts.ToString((int) ts.TotalHours > 0 ? @"h\:m\:ss" : @"m\:ss"); - } - } + + private void CheckLooperCursorStick() + { + if (Mathf.Abs(PlaybackPosition - _looperUI.StartTime) <= StickToLooperCursorDistance) + { + PlaybackPosition = _looperUI.StartTime; + } + else if (Mathf.Abs(PlaybackPosition - _looperUI.EndTime) <= StickToLooperCursorDistance) + { + PlaybackPosition = _looperUI.EndTime; + } + + PlaybackPosition = Mathf.Clamp(PlaybackPosition, _looperUI.StartTime, _looperUI.EndTime); + } + + private void UpdateCurrentTimeText(float playbackPos) + { + _currentTime.text = FormatTimeSpan(TimeSpan.FromSeconds(Mathf.Lerp(0, _songAudioSource.clip.length, playbackPos))); + } + + private static string FormatTimeSpan(TimeSpan ts) + { + return ts.ToString((int)ts.TotalHours > 0 ? @"h\:m\:ss" : @"m\:ss"); + } + } } diff --git a/PracticePlugin/SpeedSettingsController.cs b/PracticePlugin/SpeedSettingsController.cs index 8568e2a..dc9561c 100644 --- a/PracticePlugin/SpeedSettingsController.cs +++ b/PracticePlugin/SpeedSettingsController.cs @@ -3,30 +3,30 @@ namespace PracticePlugin { - public class SpeedSettingsController : ListSettingsController - { - public event Action ValueChangedEvent; - - private int _indexOffset; + public class SpeedSettingsController : ListSettingsController + { + public event Action ValueChangedEvent; - protected override void GetInitValues(out int idx, out int numberOfElements) - { - _indexOffset = Plugin.NoFail ? 1 : 20; - numberOfElements = Mathf.RoundToInt(Plugin.MaxSize / Plugin.StepSize) - _indexOffset; - idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.StepSize) - _indexOffset; - } + private int _indexOffset; - protected override void ApplyValue(int idx) - { - } + protected override void GetInitValues(out int idx, out int numberOfElements) + { + _indexOffset = Plugin.PracticeMode ? 1 : 20; + numberOfElements = Mathf.RoundToInt(Plugin.MaxSize / Plugin.StepSize) - _indexOffset; + idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.StepSize) - _indexOffset; + } - protected override string TextForValue(int idx) - { - if (ValueChangedEvent != null) - { - ValueChangedEvent(Plugin.StepSize * (idx + _indexOffset)); - } - return Plugin.StepSize * 100f * (idx + _indexOffset) + "%"; - } - } + protected override void ApplyValue(int idx) + { + } + + protected override string TextForValue(int idx) + { + if (ValueChangedEvent != null) + { + ValueChangedEvent(Plugin.StepSize * (idx + _indexOffset)); + } + return Plugin.StepSize * 100f * (idx + _indexOffset) + "%"; + } + } } \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 052a74a..16058df 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -4,91 +4,78 @@ namespace PracticePlugin { - public class UIElementsCreator : MonoBehaviour - { - public event Action ValueChangedEvent; - public SongSeeker SongSeeker { get; private set; } - - private GameObject _speedSettings; - private TMP_Text _leaderboardText; - private float _newTimeScale = 1; + public class UIElementsCreator : MonoBehaviour + { + public event Action ValueChangedEvent; + public SongSeeker SongSeeker { get; private set; } - public void Init() - { - Invoke(nameof(InitDelayed), 0.1f); - } + private GameObject _speedSettings = null; + private TMP_Text _leaderboardText; + private float _newTimeScale = 1; - private void InitDelayed() - { - if (Plugin.NoFail) - { - var seekerObj = new GameObject("Song Seeker"); - seekerObj.transform.SetParent(transform, false); - seekerObj.AddComponent(); - SongSeeker = seekerObj.AddComponent(); - SongSeeker.Init(); + public void Init() + { + Invoke(nameof(InitDelayed), 0.1f); + } - new GameObject("No Fail Game Energy").AddComponent(); - } - else - { - if (Plugin.NoFail) return; - _leaderboardText = new GameObject("Leaderboard Text").AddComponent(); - var rectTransform = (RectTransform) _leaderboardText.transform; - rectTransform.SetParent(transform, false); - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.sizeDelta = new Vector2(100, 10); - rectTransform.anchoredPosition = new Vector2(0, 15); - _leaderboardText.fontSize = 4f; - _leaderboardText.alignment = TextAlignmentOptions.Center; + private void InitDelayed() + { + if (Plugin.PracticeMode) + { + var seekerObj = new GameObject("Song Seeker"); + seekerObj.transform.SetParent(transform, false); + seekerObj.AddComponent(); + SongSeeker = seekerObj.AddComponent(); + SongSeeker.Init(); + + new GameObject("No Fail Game Energy").AddComponent(); + } - if (Plugin.HasTimeScaleChanged) - { - _leaderboardText.text = "Leaderboard has been disabled\nSet speed to 100% and restart to enable again"; - } - } - } + } - private void OnEnable() - { + private void OnEnable() + { if (Plugin.multiActive == false) { - _speedSettings = Instantiate(Plugin.SettingsObject, transform); - _speedSettings.SetActive(true); + if (_speedSettings == null && Plugin.PracticeMode) + { + _speedSettings = Instantiate(Plugin.SettingsObject, transform); + _speedSettings.SetActive(true); - var rectTransform = (RectTransform)_speedSettings.transform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, 10); + var rectTransform = (RectTransform)_speedSettings.transform; + rectTransform.anchorMin = Vector2.right * 0.5f; + rectTransform.anchorMax = Vector2.right * 0.5f; + rectTransform.anchoredPosition = new Vector2(0, 10); + + var speedController = _speedSettings.GetComponent(); + speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; + speedController.Init(); + } - var speedController = _speedSettings.GetComponent(); - speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; - speedController.Init(); } - } + } - private void OnDisable() - { - if (ValueChangedEvent != null) - { - ValueChangedEvent(_newTimeScale); - } - DestroyImmediate(_speedSettings); - } + private void OnDisable() + { + if (ValueChangedEvent != null) + { + ValueChangedEvent(_newTimeScale); + } + DestroyImmediate(_speedSettings); + } - private void SpeedControllerOnValueChangedEvent(float timeScale) - { - _newTimeScale = timeScale; - if (Plugin.NoFail) return; - if (!Plugin.HasTimeScaleChanged && Math.Abs(_newTimeScale - 1) > 0.0000000001f) - { - _leaderboardText.text = "Leaderboard will be disabled!"; - } - else - { - _leaderboardText.text = Plugin.HasTimeScaleChanged ? "Leaderboard has been disabled\nSet speed to 100% and restart to enable again" : string.Empty; - } - } - } + private void SpeedControllerOnValueChangedEvent(float timeScale) + { + _newTimeScale = timeScale; + if (Plugin.PracticeMode) return; + if (!Plugin.HasTimeScaleChanged && Math.Abs(_newTimeScale - 1) > 0.0000000001f) + { + _leaderboardText.text = "Leaderboard will be disabled!"; + } + else + { + _leaderboardText.text = Plugin.HasTimeScaleChanged ? "Leaderboard has been disabled\nSet speed to 100% and restart to enable again" : string.Empty; + } + } + } } \ No newline at end of file From 76df4731551f4a6a575dab5f9daa3b8940112547 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 3 Jan 2019 19:59:08 -0500 Subject: [PATCH 05/64] Update LooperUI.cs --- PracticePlugin/LooperUI.cs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/PracticePlugin/LooperUI.cs b/PracticePlugin/LooperUI.cs index d779163..281f321 100644 --- a/PracticePlugin/LooperUI.cs +++ b/PracticePlugin/LooperUI.cs @@ -9,12 +9,12 @@ public class LooperUI : MonoBehaviour { public float StartTime { - get { return Mathf.InverseLerp(0, SongSeeker.SeekBarSize.x, startCursor.Position); } + get { return Mathf.InverseLerp(0, SongSeeker.SeekBarSize.x, _startCursor.Position); } } public float EndTime { - get { return Mathf.InverseLerp(0, SongSeeker.SeekBarSize.x, endCursor.Position); } + get { return Mathf.InverseLerp(0, SongSeeker.SeekBarSize.x, _endCursor.Position); } } public event Action OnDragEndEvent; @@ -36,8 +36,8 @@ public float EndTime private Image _lineDuration; - public LooperCursor startCursor { get; private set; } - public LooperCursor endCursor { get; private set; } + private LooperCursor _startCursor; + private LooperCursor _endCursor; private LooperCursor _draggingCursor; @@ -70,10 +70,10 @@ public void Init(SongSeeker songSeeker) rectTransform.localEulerAngles = new Vector3(0, 0, 45); startCursorImage.color = StartColor; - startCursor = startCursorImage.gameObject.AddComponent(); - startCursor.BeginDragEvent += CursorOnBeginDragEvent; - startCursor.EndDragEvent += CursorOnEndDragEvent; - startCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevStartTime); + _startCursor = startCursorImage.gameObject.AddComponent(); + _startCursor.BeginDragEvent += CursorOnBeginDragEvent; + _startCursor.EndDragEvent += CursorOnEndDragEvent; + _startCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevStartTime); var endCursorImage = new GameObject("End Cursor").AddComponent(); rectTransform = endCursorImage.rectTransform; @@ -84,13 +84,13 @@ public void Init(SongSeeker songSeeker) rectTransform.localEulerAngles = new Vector3(0, 0, 45); endCursorImage.color = EndColor; - endCursor = endCursorImage.gameObject.AddComponent(); - endCursor.BeginDragEvent += CursorOnBeginDragEvent; - endCursor.EndDragEvent += CursorOnEndDragEvent; - endCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevEndTime); + _endCursor = endCursorImage.gameObject.AddComponent(); + _endCursor.BeginDragEvent += CursorOnBeginDragEvent; + _endCursor.EndDragEvent += CursorOnEndDragEvent; + _endCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevEndTime); - startCursor.Init(LooperCursor.Type.Start); - endCursor.Init(LooperCursor.Type.End); + _startCursor.Init(LooperCursor.Type.Start); + _endCursor.Init(LooperCursor.Type.End); _mainCamera = Camera.main; } @@ -127,17 +127,17 @@ private void Update() if (_draggingCursor.CursorType == LooperCursor.Type.Start) { - _draggingCursor.Position = Mathf.Clamp(newPos, 0, endCursor.Position - MinCursorDistance); + _draggingCursor.Position = Mathf.Clamp(newPos, 0, _endCursor.Position - MinCursorDistance); } else { - _draggingCursor.Position = Mathf.Clamp(newPos, startCursor.Position + MinCursorDistance, + _draggingCursor.Position = Mathf.Clamp(newPos, _startCursor.Position + MinCursorDistance, SongSeeker.SeekBarSize.x); } } - _lineDuration.rectTransform.sizeDelta = new Vector2(endCursor.Position - startCursor.Position, LineDurationWidth); - _lineDuration.rectTransform.anchoredPosition = new Vector2((startCursor.Position + endCursor.Position) / 2, 0); + _lineDuration.rectTransform.sizeDelta = new Vector2(_endCursor.Position - _startCursor.Position, LineDurationWidth); + _lineDuration.rectTransform.anchoredPosition = new Vector2((_startCursor.Position + _endCursor.Position) / 2, 0); } private void OnDestroy() From 0ce9b22248dec53ffa17521213c82ca7a6fd58db Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Fri, 4 Jan 2019 17:01:31 -0500 Subject: [PATCH 06/64] Add NJS and Offset Adjustment to Practice Mode --- PracticePlugin/NjsSettingsController.cs | 32 +++++ PracticePlugin/Plugin.cs | 155 +++++++++++++++++++--- PracticePlugin/PracticePlugin.csproj | 2 + PracticePlugin/SongSeeker.cs | 3 +- PracticePlugin/SpawnOffsetController.cs | 32 +++++ PracticePlugin/SpeedSettingsController.cs | 8 +- PracticePlugin/UIElementsCreator.cs | 47 ++++++- 7 files changed, 258 insertions(+), 21 deletions(-) create mode 100644 PracticePlugin/NjsSettingsController.cs create mode 100644 PracticePlugin/SpawnOffsetController.cs diff --git a/PracticePlugin/NjsSettingsController.cs b/PracticePlugin/NjsSettingsController.cs new file mode 100644 index 0000000..412a3b8 --- /dev/null +++ b/PracticePlugin/NjsSettingsController.cs @@ -0,0 +1,32 @@ +using System; +using UnityEngine; + +namespace PracticePlugin +{ + public class NjsSettingsController : ListSettingsController + { + public event Action ValueChangedEvent; + + private int _indexOffset; + + protected override void GetInitValues(out int idx, out int numberOfElements) + { + _indexOffset = Plugin.PracticeMode ? 1 : 20; + numberOfElements = 50; + idx = (int)Plugin._spawnController.GetPrivateField("_noteJumpMovementSpeed"); + } + + protected override void ApplyValue(int idx) + { + } + + protected override string TextForValue(int idx) + { + if (ValueChangedEvent != null) + { + ValueChangedEvent(idx); + } + return idx.ToString(); + } + } +} \ No newline at end of file diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index ab96fbd..8e1b86b 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -25,15 +25,19 @@ public string Version get { return "v4.0.0"; } } - public const float MaxSize = 5.05f; - public const float StepSize = 0.05f; + public const float SpeedMaxSize = 5.05f; + public const float SpeedStepSize = 0.05f; + + public const int NjsMaxSize = 50; + public const int NjstepSize = 1; public const string MenuSceneName = "Menu"; public const string GameSceneName = "GameCore"; public const string ContextSceneName = "GameplayCore"; - public static GameObject SettingsObject { get; private set; } - + public static GameObject SpeedSettingsObject { get; private set; } + public static GameObject NjsSettingsObject { get; private set; } + public static GameObject SpawnOffsetSettingsObject { get; private set; } public static bool multiActive; public static float TimeScale { @@ -78,7 +82,8 @@ private set public static bool PlayingNewSong { get; private set; } private static bool _init; - private static StandardLevelSceneSetupDataSO _levelData; + public static StandardLevelSceneSetupDataSO _levelData { get; private set; } + public static BeatmapObjectSpawnController _spawnController { get; private set; } public static AudioTimeSyncController AudioTimeSync { get; private set; } private static AudioMixerSO _mixer; private static AudioSource _songAudio; @@ -115,26 +120,73 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) ResultsViewControllerOnContinueButtonPressedEvent; } - if (SettingsObject != null) return; + if (SpeedSettingsObject != null) return; var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (volumeSettings == null) return; volumeSettings.gameObject.SetActive(false); - SettingsObject = Object.Instantiate(volumeSettings.gameObject); - SettingsObject.SetActive(false); + SpeedSettingsObject = Object.Instantiate(volumeSettings.gameObject); + SpeedSettingsObject.SetActive(false); volumeSettings.gameObject.SetActive(true); - if (SettingsObject == null) return; + if (SpeedSettingsObject == null) return; - var volume = SettingsObject.GetComponent(); + var volume = SpeedSettingsObject.GetComponent(); ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController), - typeof(SpeedSettingsController), SettingsObject); + typeof(SpeedSettingsController), SpeedSettingsObject); Object.DestroyImmediate(volume); - SettingsObject.GetComponentInChildren().text = "SPEED"; - Object.DontDestroyOnLoad(SettingsObject); + SpeedSettingsObject.GetComponentInChildren().text = "SPEED"; + Object.DontDestroyOnLoad(SpeedSettingsObject); + + + //NJS Object + if (NjsSettingsObject != null) return; + + var volumeSettings2 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + + if (volumeSettings2 == null) return; + + volumeSettings2.gameObject.SetActive(false); + NjsSettingsObject = Object.Instantiate(volumeSettings2.gameObject); + NjsSettingsObject.SetActive(false); + volumeSettings2.gameObject.SetActive(true); + + if (NjsSettingsObject == null) return; + + var volume2 = NjsSettingsObject.GetComponent(); + ReflectionUtil.CopyComponent(volume2, typeof(IncDecSettingsController), + typeof(NjsSettingsController), NjsSettingsObject); + Object.DestroyImmediate(volume2); + + NjsSettingsObject.GetComponentInChildren().text = "NJS"; + Object.DontDestroyOnLoad(NjsSettingsObject); + + + //Spawn Offset Object + if (SpawnOffsetSettingsObject != null) return; + + var volumeSettings3 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + + if (volumeSettings3 == null) return; + + volumeSettings3.gameObject.SetActive(false); + SpawnOffsetSettingsObject = Object.Instantiate(volumeSettings3.gameObject); + SpawnOffsetSettingsObject.SetActive(false); + volumeSettings3.gameObject.SetActive(true); + + if (SpawnOffsetSettingsObject == null) return; + + var volume3 = SpawnOffsetSettingsObject.GetComponent(); + ReflectionUtil.CopyComponent(volume3, typeof(IncDecSettingsController), + typeof(SpawnOffsetController), SpawnOffsetSettingsObject); + Object.DestroyImmediate(volume3); + + SpawnOffsetSettingsObject.GetComponentInChildren().text = "Spawn Offset"; + Object.DontDestroyOnLoad(SpawnOffsetSettingsObject); + } else if (newScene.name == GameSceneName) { @@ -191,6 +243,13 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) _levelData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; } + if (_spawnController == null) + { + _spawnController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + + } + + if (_lastLevelId != _levelData.difficultyBeatmap.level.levelID && !string.IsNullOrEmpty(_lastLevelId)) { @@ -236,7 +295,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) if (!PracticeMode) { - TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize); + TimeScale = Mathf.Clamp(TimeScale, 1, SpeedMaxSize); } if (PracticeMode) { @@ -252,7 +311,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) public System.Collections.IEnumerator DelayedUI() { - yield return new WaitForSeconds(0.1f); + yield return new WaitForSeconds(0.5f); try { Console.WriteLine("Atemmpting Practice Plugin UI"); @@ -267,6 +326,9 @@ public System.Collections.IEnumerator DelayedUI() _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; _uiElementsCreator.Init(); TimeScale = TimeScale; + + var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); + bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.4f, bg.transform.localScale.z * 1f); } catch (Exception ex) { @@ -327,6 +389,69 @@ public void OnUpdate() public void OnFixedUpdate() { + } + + public static void AdjustNJS(float njs) + { + + float halfJumpDur = 4f; + float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); + float noteJumpStartBeatOffset = _levelData.difficultyBeatmap.noteJumpStartBeatOffset; + float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); + float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); + float jumpDis; + float spawnAheadTime; + float moveDis; + float bpm = _spawnController.GetPrivateField("_beatsPerMinute"); + float num = 60f / bpm; + moveDis = moveSpeed * num * moveDir; + while (njs * num * halfJumpDur > maxHalfJump) + { + halfJumpDur /= 2f; + } + halfJumpDur += noteJumpStartBeatOffset; + if (halfJumpDur < 1f) halfJumpDur = 1f; + // halfJumpDur = spawnController.GetPrivateField("_halfJumpDurationInBeats"); + jumpDis = njs * num * halfJumpDur * 2f; + spawnAheadTime = moveDis / moveSpeed + jumpDis * 0.5f / njs; + _spawnController.SetPrivateField("_halfJumpDurationInBeats", halfJumpDur); + _spawnController.SetPrivateField("_spawnAheadTime", spawnAheadTime); + _spawnController.SetPrivateField("_jumpDistance", jumpDis); + _spawnController.SetPrivateField("_noteJumpMovementSpeed", njs); + _spawnController.SetPrivateField("_moveDistance", moveDis); + + + } + public static void AdjustSpawnOffset(float offset) + { + float njs = _spawnController.GetPrivateField("_noteJumpMovementSpeed"); + float halfJumpDur = 4f; + float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); + float noteJumpStartBeatOffset = offset; + float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); + float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); + float jumpDis; + float spawnAheadTime; + float moveDis; + float bpm = _spawnController.GetPrivateField("_beatsPerMinute"); + float num = 60f / bpm; + moveDis = moveSpeed * num * moveDir; + while (njs * num * halfJumpDur > maxHalfJump) + { + halfJumpDur /= 2f; + } + halfJumpDur += noteJumpStartBeatOffset; + if (halfJumpDur < 1f) halfJumpDur = 1f; + // halfJumpDur = spawnController.GetPrivateField("_halfJumpDurationInBeats"); + jumpDis = njs * num * halfJumpDur * 2f; + spawnAheadTime = moveDis / moveSpeed + jumpDis * 0.5f / njs; + _spawnController.SetPrivateField("_halfJumpDurationInBeats", halfJumpDur); + _spawnController.SetPrivateField("_spawnAheadTime", spawnAheadTime); + _spawnController.SetPrivateField("_jumpDistance", jumpDis); + _spawnController.SetPrivateField("_noteJumpMovementSpeed", njs); + _spawnController.SetPrivateField("_moveDistance", moveDis); + + } } } \ No newline at end of file diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 7124042..1c8c4af 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -88,6 +88,8 @@ + + diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 994b2f0..47675c2 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -188,7 +188,8 @@ public void OnPointerDown(PointerEventData eventData) UpdateCurrentTimeText(PlaybackPosition); } - private void ApplyPlaybackPosition() + + public void ApplyPlaybackPosition() { _songAudioSource.timeSamples = Mathf.RoundToInt(Mathf.Lerp(0, _songAudioSource.clip.samples, PlaybackPosition)); _songAudioSource.time = _songAudioSource.time - Mathf.Min(AheadTime, _songAudioSource.time); diff --git a/PracticePlugin/SpawnOffsetController.cs b/PracticePlugin/SpawnOffsetController.cs new file mode 100644 index 0000000..1de7d73 --- /dev/null +++ b/PracticePlugin/SpawnOffsetController.cs @@ -0,0 +1,32 @@ +using System; +using UnityEngine; + +namespace PracticePlugin +{ + public class SpawnOffsetController : ListSettingsController + { + public event Action ValueChangedEvent; + + private int _indexOffset; + + protected override void GetInitValues(out int idx, out int numberOfElements) + { + _indexOffset = Plugin.PracticeMode ? 1 : 20; + numberOfElements = 50; + idx = (int)Plugin._levelData.difficultyBeatmap.noteJumpStartBeatOffset; + } + + protected override void ApplyValue(int idx) + { + } + + protected override string TextForValue(int idx) + { + if (ValueChangedEvent != null) + { + ValueChangedEvent(idx); + } + return idx.ToString(); + } + } +} \ No newline at end of file diff --git a/PracticePlugin/SpeedSettingsController.cs b/PracticePlugin/SpeedSettingsController.cs index dc9561c..96c0423 100644 --- a/PracticePlugin/SpeedSettingsController.cs +++ b/PracticePlugin/SpeedSettingsController.cs @@ -12,8 +12,8 @@ public class SpeedSettingsController : ListSettingsController protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; - numberOfElements = Mathf.RoundToInt(Plugin.MaxSize / Plugin.StepSize) - _indexOffset; - idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.StepSize) - _indexOffset; + numberOfElements = Mathf.RoundToInt(Plugin.SpeedMaxSize / Plugin.SpeedStepSize) - _indexOffset; + idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.SpeedStepSize) - _indexOffset; } protected override void ApplyValue(int idx) @@ -24,9 +24,9 @@ protected override string TextForValue(int idx) { if (ValueChangedEvent != null) { - ValueChangedEvent(Plugin.StepSize * (idx + _indexOffset)); + ValueChangedEvent(Plugin.SpeedStepSize * (idx + _indexOffset)); } - return Plugin.StepSize * 100f * (idx + _indexOffset) + "%"; + return Plugin.SpeedStepSize * 100f * (idx + _indexOffset) + "%"; } } } \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 16058df..5722d90 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -10,6 +10,8 @@ public class UIElementsCreator : MonoBehaviour public SongSeeker SongSeeker { get; private set; } private GameObject _speedSettings = null; + private GameObject _njsSettings = null; + private GameObject _offsetSettings = null; private TMP_Text _leaderboardText; private float _newTimeScale = 1; @@ -39,7 +41,7 @@ private void OnEnable() { if (_speedSettings == null && Plugin.PracticeMode) { - _speedSettings = Instantiate(Plugin.SettingsObject, transform); + _speedSettings = Instantiate(Plugin.SpeedSettingsObject, transform); _speedSettings.SetActive(true); var rectTransform = (RectTransform)_speedSettings.transform; @@ -51,10 +53,53 @@ private void OnEnable() speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; speedController.Init(); } + if (_njsSettings == null && Plugin.PracticeMode) + { + _njsSettings = Instantiate(Plugin.NjsSettingsObject, transform); + _njsSettings.SetActive(true); + + var rectTransform = (RectTransform)_njsSettings.transform; + rectTransform.anchorMin = Vector2.right * 0.5f; + rectTransform.anchorMax = Vector2.right * 0.5f; + rectTransform.anchoredPosition = new Vector2(0, 2); + + var njsController = _njsSettings.GetComponent(); + njsController.ValueChangedEvent += NjsController_ValueChangedEvent; + njsController.Init(); + } + if (_offsetSettings == null && Plugin.PracticeMode) + { + _offsetSettings = Instantiate(Plugin.SpawnOffsetSettingsObject, transform); + _offsetSettings.SetActive(true); + + var rectTransform = (RectTransform)_offsetSettings.transform; + rectTransform.anchorMin = Vector2.right * 0.5f; + rectTransform.anchorMax = Vector2.right * 0.5f; + rectTransform.anchoredPosition = new Vector2(0, -6); + + var spawnOffsetController = _offsetSettings.GetComponent(); + spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; + spawnOffsetController.Init(); + } + + + } } + private void SpawnOffsetController_ValueChangedEvent(float offset) + { + Plugin.AdjustSpawnOffset(offset); + SongSeeker.ApplyPlaybackPosition(); + } + + private void NjsController_ValueChangedEvent(float njs) + { + Plugin.AdjustNJS(njs); + SongSeeker.ApplyPlaybackPosition(); + } + private void OnDisable() { if (ValueChangedEvent != null) From 8517308cfea47704258ed7d5dcc1b81734ac6e27 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 5 Jan 2019 00:34:36 -0500 Subject: [PATCH 07/64] Pause menu, fix seeker not initializing properly until first pause --- PracticePlugin/Plugin.cs | 10 ++++++++-- PracticePlugin/SongSeeker.cs | 14 ++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 8e1b86b..bd355f5 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -28,7 +28,7 @@ public string Version public const float SpeedMaxSize = 5.05f; public const float SpeedStepSize = 0.05f; - public const int NjsMaxSize = 50; + public const int NjsMaxSize = 100; public const int NjstepSize = 1; public const string MenuSceneName = "Menu"; @@ -328,7 +328,11 @@ public System.Collections.IEnumerator DelayedUI() TimeScale = TimeScale; var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); - bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.4f, bg.transform.localScale.z * 1f); + // bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f); + bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); + + + } catch (Exception ex) { @@ -345,7 +349,9 @@ private void ResultsViewControllerOnContinueButtonPressedEvent(ResultsViewContro private void MainGameSceneSetupDataOnDidFinishEvent(StandardLevelSceneSetupDataSO levelData, LevelCompletionResults results) { + /* + * if (!NoFail && HasTimeScaleChanged && results != null && results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared) { diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 47675c2..422aa1c 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -39,9 +39,8 @@ public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler private const float StickToLooperCursorDistance = 0.02f; private const float LooperUITopMargin = -5f; - + private bool init = false; private int _startTimeSamples; - public void Init() { _songAudioSource = Plugin.AudioTimeSync.GetPrivateField("_audioSource"); @@ -115,8 +114,8 @@ public void Init() Invoke(nameof(ApplyPlaybackPosition), 0.1f); ApplyPlaybackPosition(); } - _mainCamera = Camera.main; + } private void LooperUIOnOnDragEndEvent() @@ -129,13 +128,15 @@ private void OnEnable() if (_songAudioSource == null || _songAudioSource.clip == null) return; _startTimeSamples = _songAudioSource.timeSamples; PlaybackPosition = (float)_songAudioSource.timeSamples / _songAudioSource.clip.samples; - _timeLength.text = FormatTimeSpan(TimeSpan.FromSeconds(_songAudioSource.clip.length)); UpdateCurrentTimeText(PlaybackPosition); + } + private void OnDisable() { + init = true; if (_songAudioSource == null || _songAudioSource.clip == null) return; var newTimeSamples = Mathf.RoundToInt(Mathf.Lerp(0, _songAudioSource.clip.samples, PlaybackPosition)); if (_startTimeSamples == newTimeSamples) return; @@ -145,6 +146,11 @@ private void OnDisable() public void OnUpdate() { if (gameObject.activeInHierarchy || _looperUI == null || _songAudioSource == null || _songAudioSource.clip == null) return; + if(!init) + { + PlaybackPosition = (float)_songAudioSource.timeSamples / _songAudioSource.clip.samples; + } + var newPos = (_songAudioSource.time + 0.1f) / _songAudioSource.clip.length; if (newPos >= _looperUI.EndTime && _looperUI.EndTime != 1) { From 85ab3a506fd44bad98106cf5bc6b7400a6361906 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 5 Jan 2019 00:34:57 -0500 Subject: [PATCH 08/64] Version --- PracticePlugin/Plugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index bd355f5..d30e4a9 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "v4.0.0"; } + get { return "v4.0.1"; } } public const float SpeedMaxSize = 5.05f; From d12f4ffc5dfdba45b2fb4a59ce6b5a1c0455612e Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Fri, 11 Jan 2019 11:37:00 -0500 Subject: [PATCH 09/64] Don't activate practice plugin in declared isolated levels --- PracticePlugin/Plugin.cs | 9 ++++++--- PracticePlugin/PracticePlugin.csproj | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index d30e4a9..58d4be9 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "v4.0.1"; } + get { return "v4.1.0"; } } public const float SpeedMaxSize = 5.05f; @@ -45,6 +45,8 @@ public static float TimeScale private set { _timeScale = value; + // AudioTimeSync.SetPrivateField("_timeScale", value); + // AudioTimeSync.Init(_songAudio.clip, _songAudio.time, AudioTimeSync.GetPrivateField("_songTimeOffset"), value); if (_timeScale == 1f) _mixer.musicPitch = 1; else @@ -273,7 +275,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); - PracticeMode = (_levelData.gameplayCoreSetupData.practiceSettings != null); + PracticeMode = (_levelData.gameplayCoreSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); //Check if Multiplayer is active, disable accordingly if (PluginManager.Plugins.Any(x => x.Name == "Beat Saber Multiplayer")) { @@ -330,7 +332,8 @@ public System.Collections.IEnumerator DelayedUI() var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); // bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f); bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); - + var pauseMenu = GameObject.Find("PauseMenu"); + pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); } diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 1c8c4af..070c323 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -35,6 +35,12 @@ C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BeatSaberCustomUI.dll + + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BS_Utils.dll + False C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionInjector.dll From ecb4bf7428c595671851f8e8ee34a504800f8a3b Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sun, 27 Jan 2019 17:56:37 -0500 Subject: [PATCH 10/64] 4.1.2 --- PracticePlugin/NjsSettingsController.cs | 8 +++-- PracticePlugin/Plugin.cs | 37 +++++++++++++++++++---- PracticePlugin/Properties/AssemblyInfo.cs | 4 +-- PracticePlugin/SpawnOffsetController.cs | 10 ++++-- PracticePlugin/SpeedSettingsController.cs | 1 + PracticePlugin/UIElementsCreator.cs | 21 +++++++++++-- 6 files changed, 65 insertions(+), 16 deletions(-) diff --git a/PracticePlugin/NjsSettingsController.cs b/PracticePlugin/NjsSettingsController.cs index 412a3b8..0467be8 100644 --- a/PracticePlugin/NjsSettingsController.cs +++ b/PracticePlugin/NjsSettingsController.cs @@ -8,12 +8,13 @@ public class NjsSettingsController : ListSettingsController public event Action ValueChangedEvent; private int _indexOffset; - + private int defaultNJS; protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; numberOfElements = 50; - idx = (int)Plugin._spawnController.GetPrivateField("_noteJumpMovementSpeed"); + defaultNJS = (int)Plugin._spawnController.GetPrivateField("_noteJumpMovementSpeed"); + idx = defaultNJS; } protected override void ApplyValue(int idx) @@ -26,6 +27,9 @@ protected override string TextForValue(int idx) { ValueChangedEvent(idx); } + if (idx == defaultNJS) + return $"{idx}"; + else return idx.ToString(); } } diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 58d4be9..1447b06 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -10,7 +10,7 @@ using UnityEngine.UI; using Zenject; using Object = UnityEngine.Object; - +using CustomUI.GameplaySettings; namespace PracticePlugin { public class Plugin : IPlugin @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "v4.1.0"; } + get { return "v4.1.2"; } } public const float SpeedMaxSize = 5.05f; @@ -39,6 +39,7 @@ public string Version public static GameObject NjsSettingsObject { get; private set; } public static GameObject SpawnOffsetSettingsObject { get; private set; } public static bool multiActive; + internal static bool startWithFullEnergy = false; public static float TimeScale { get { return _timeScale; } @@ -99,8 +100,26 @@ public void OnApplicationStart() if (_init) return; _init = true; SceneManager.activeSceneChanged += OneSceneChanged; - + SceneManager.sceneLoaded += SceneManager_sceneLoaded; NoFailGameEnergy.limitLevelFail = ModPrefs.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); + startWithFullEnergy = ModPrefs.GetBool("PracticePlugin", "startWithFullEnergy", false, true); + } + + private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) + { + if(arg0.name == "Menu") + { + var fullEnergy = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Start With Full Energy", "MainMenu", "Start With full energy in Practice Mode."); + fullEnergy.GetValue = ModPrefs.GetBool("PracticePlugin", "startWithFullEnergy", false, true); + fullEnergy.OnToggle += (value) => + { + startWithFullEnergy = value; + ModPrefs.SetBool("PracticePlugin", "startWithFullEnergy", value); + }; + } + + + } public void OnApplicationQuit() @@ -305,15 +324,15 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) _timeScale = _levelData.gameplayCoreSetupData.practiceSettings.songSpeedMul; else _timeScale = _levelData.gameplayCoreSetupData.gameplayModifiers.songSpeedMul; - SharedCoroutineStarter.instance.StartCoroutine(DelayedUI()); + SharedCoroutineStarter.instance.StartCoroutine(DelayedSetup()); } } } - public System.Collections.IEnumerator DelayedUI() + public System.Collections.IEnumerator DelayedSetup() { - yield return new WaitForSeconds(0.5f); + yield return new WaitForSeconds(0.2f); try { Console.WriteLine("Atemmpting Practice Plugin UI"); @@ -335,6 +354,12 @@ public System.Collections.IEnumerator DelayedUI() var pauseMenu = GameObject.Find("PauseMenu"); pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); + if(startWithFullEnergy) + { + GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (energyCounter != null) + energyCounter.AddEnergy(1 - energyCounter.energy); + } } catch (Exception ex) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 925953f..ef99d1d 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("3.0.2.0")] -[assembly: AssemblyFileVersion("3.0.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.1.2.0")] +[assembly: AssemblyFileVersion("4.1.2.0")] \ No newline at end of file diff --git a/PracticePlugin/SpawnOffsetController.cs b/PracticePlugin/SpawnOffsetController.cs index 1de7d73..90bc91b 100644 --- a/PracticePlugin/SpawnOffsetController.cs +++ b/PracticePlugin/SpawnOffsetController.cs @@ -8,12 +8,13 @@ public class SpawnOffsetController : ListSettingsController public event Action ValueChangedEvent; private int _indexOffset; - + private int defaultOffset; protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; numberOfElements = 50; - idx = (int)Plugin._levelData.difficultyBeatmap.noteJumpStartBeatOffset; + defaultOffset = (int)Plugin._levelData.difficultyBeatmap.noteJumpStartBeatOffset; + idx = defaultOffset; } protected override void ApplyValue(int idx) @@ -26,7 +27,10 @@ protected override string TextForValue(int idx) { ValueChangedEvent(idx); } - return idx.ToString(); + if (idx == defaultOffset) + return $"{idx}"; + else + return idx.ToString(); } } } \ No newline at end of file diff --git a/PracticePlugin/SpeedSettingsController.cs b/PracticePlugin/SpeedSettingsController.cs index 96c0423..3b5854b 100644 --- a/PracticePlugin/SpeedSettingsController.cs +++ b/PracticePlugin/SpeedSettingsController.cs @@ -26,6 +26,7 @@ protected override string TextForValue(int idx) { ValueChangedEvent(Plugin.SpeedStepSize * (idx + _indexOffset)); } + return Plugin.SpeedStepSize * 100f * (idx + _indexOffset) + "%"; } } diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 5722d90..531f7a4 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -12,6 +12,9 @@ public class UIElementsCreator : MonoBehaviour private GameObject _speedSettings = null; private GameObject _njsSettings = null; private GameObject _offsetSettings = null; + internal SpeedSettingsController speedController; + internal NjsSettingsController njsController; + internal SpawnOffsetController spawnOffsetController; private TMP_Text _leaderboardText; private float _newTimeScale = 1; @@ -49,7 +52,7 @@ private void OnEnable() rectTransform.anchorMax = Vector2.right * 0.5f; rectTransform.anchoredPosition = new Vector2(0, 10); - var speedController = _speedSettings.GetComponent(); + speedController = _speedSettings.GetComponent(); speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; speedController.Init(); } @@ -63,7 +66,7 @@ private void OnEnable() rectTransform.anchorMax = Vector2.right * 0.5f; rectTransform.anchoredPosition = new Vector2(0, 2); - var njsController = _njsSettings.GetComponent(); + njsController = _njsSettings.GetComponent(); njsController.ValueChangedEvent += NjsController_ValueChangedEvent; njsController.Init(); } @@ -77,7 +80,7 @@ private void OnEnable() rectTransform.anchorMax = Vector2.right * 0.5f; rectTransform.anchoredPosition = new Vector2(0, -6); - var spawnOffsetController = _offsetSettings.GetComponent(); + spawnOffsetController = _offsetSettings.GetComponent(); spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; spawnOffsetController.Init(); } @@ -112,6 +115,18 @@ private void OnDisable() private void SpeedControllerOnValueChangedEvent(float timeScale) { _newTimeScale = timeScale; + if (Math.Abs(_newTimeScale - 1) > 0.0000000001f) + { + // spawnOffsetController.enabled = false; + // njsController.enabled = false; + + } + else + { + // spawnOffsetController.enabled = true; + // njsController.enabled = true; + + } if (Plugin.PracticeMode) return; if (!Plugin.HasTimeScaleChanged && Math.Abs(_newTimeScale - 1) > 0.0000000001f) { From d2b542470ce220594e73ebfa18c0b577401e3ea2 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sun, 3 Feb 2019 16:40:59 -0500 Subject: [PATCH 11/64] Remove multi specific stuff --- PracticePlugin/Plugin.cs | 20 +---- PracticePlugin/Properties/AssemblyInfo.cs | 4 +- PracticePlugin/UIElementsCreator.cs | 93 +++++++++++------------ 3 files changed, 50 insertions(+), 67 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 1447b06..661006a 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "v4.1.2"; } + get { return "v4.1.3"; } } public const float SpeedMaxSize = 5.05f; @@ -38,7 +38,6 @@ public string Version public static GameObject SpeedSettingsObject { get; private set; } public static GameObject NjsSettingsObject { get; private set; } public static GameObject SpawnOffsetSettingsObject { get; private set; } - public static bool multiActive; internal static bool startWithFullEnergy = false; public static float TimeScale { @@ -296,22 +295,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); PracticeMode = (_levelData.gameplayCoreSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); //Check if Multiplayer is active, disable accordingly - if (PluginManager.Plugins.Any(x => x.Name == "Beat Saber Multiplayer")) - { - GameObject client = GameObject.Find("MultiplayerClient"); - if (client != null) - { - Console.WriteLine("[PracticePlugin] Found MultiplayerClient game object!"); - multiActive = true; - - } - else - { - Console.WriteLine("[PracticePlugin] MultiplayerClient game object not found!"); - } - } - if (multiActive == true) - PracticeMode = false; + if (!PracticeMode) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index ef99d1d..8d866d8 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.1.2.0")] -[assembly: AssemblyFileVersion("4.1.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.1.3.0")] +[assembly: AssemblyFileVersion("4.1.3.0")] \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 531f7a4..19dba05 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -40,55 +40,54 @@ private void InitDelayed() private void OnEnable() { - if (Plugin.multiActive == false) + + if (_speedSettings == null && Plugin.PracticeMode) + { + _speedSettings = Instantiate(Plugin.SpeedSettingsObject, transform); + _speedSettings.SetActive(true); + + var rectTransform = (RectTransform)_speedSettings.transform; + rectTransform.anchorMin = Vector2.right * 0.5f; + rectTransform.anchorMax = Vector2.right * 0.5f; + rectTransform.anchoredPosition = new Vector2(0, 10); + + speedController = _speedSettings.GetComponent(); + speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; + speedController.Init(); + } + if (_njsSettings == null && Plugin.PracticeMode) { - if (_speedSettings == null && Plugin.PracticeMode) - { - _speedSettings = Instantiate(Plugin.SpeedSettingsObject, transform); - _speedSettings.SetActive(true); - - var rectTransform = (RectTransform)_speedSettings.transform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, 10); - - speedController = _speedSettings.GetComponent(); - speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; - speedController.Init(); - } - if (_njsSettings == null && Plugin.PracticeMode) - { - _njsSettings = Instantiate(Plugin.NjsSettingsObject, transform); - _njsSettings.SetActive(true); - - var rectTransform = (RectTransform)_njsSettings.transform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, 2); - - njsController = _njsSettings.GetComponent(); - njsController.ValueChangedEvent += NjsController_ValueChangedEvent; - njsController.Init(); - } - if (_offsetSettings == null && Plugin.PracticeMode) - { - _offsetSettings = Instantiate(Plugin.SpawnOffsetSettingsObject, transform); - _offsetSettings.SetActive(true); - - var rectTransform = (RectTransform)_offsetSettings.transform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, -6); - - spawnOffsetController = _offsetSettings.GetComponent(); - spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; - spawnOffsetController.Init(); - } + _njsSettings = Instantiate(Plugin.NjsSettingsObject, transform); + _njsSettings.SetActive(true); + var rectTransform = (RectTransform)_njsSettings.transform; + rectTransform.anchorMin = Vector2.right * 0.5f; + rectTransform.anchorMax = Vector2.right * 0.5f; + rectTransform.anchoredPosition = new Vector2(0, 2); + njsController = _njsSettings.GetComponent(); + njsController.ValueChangedEvent += NjsController_ValueChangedEvent; + njsController.Init(); + } + if (_offsetSettings == null && Plugin.PracticeMode) + { + _offsetSettings = Instantiate(Plugin.SpawnOffsetSettingsObject, transform); + _offsetSettings.SetActive(true); + var rectTransform = (RectTransform)_offsetSettings.transform; + rectTransform.anchorMin = Vector2.right * 0.5f; + rectTransform.anchorMax = Vector2.right * 0.5f; + rectTransform.anchoredPosition = new Vector2(0, -6); + spawnOffsetController = _offsetSettings.GetComponent(); + spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; + spawnOffsetController.Init(); } + + + + + } private void SpawnOffsetController_ValueChangedEvent(float offset) @@ -117,14 +116,14 @@ private void SpeedControllerOnValueChangedEvent(float timeScale) _newTimeScale = timeScale; if (Math.Abs(_newTimeScale - 1) > 0.0000000001f) { - // spawnOffsetController.enabled = false; - // njsController.enabled = false; + // spawnOffsetController.enabled = false; + // njsController.enabled = false; } else { - // spawnOffsetController.enabled = true; - // njsController.enabled = true; + // spawnOffsetController.enabled = true; + // njsController.enabled = true; } if (Plugin.PracticeMode) return; From d244863280cdd626c6fcb6f283fd16fb34fa9113 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 16 Mar 2019 01:17:54 -0400 Subject: [PATCH 12/64] . --- PracticePlugin/CustomEffectPoolsInstaller.cs | 4 +- PracticePlugin/CustomNoteCutSoundEffect.cs | 4 +- PracticePlugin/NjsSettingsController.cs | 1 + PracticePlugin/Plugin.cs | 65 +++++++++++++++----- PracticePlugin/PracticePlugin.csproj | 4 +- PracticePlugin/Properties/AssemblyInfo.cs | 4 +- PracticePlugin/SpawnOffsetController.cs | 3 +- PracticePlugin/UIElementsCreator.cs | 9 ++- 8 files changed, 65 insertions(+), 29 deletions(-) diff --git a/PracticePlugin/CustomEffectPoolsInstaller.cs b/PracticePlugin/CustomEffectPoolsInstaller.cs index 2b5861a..4c8c17f 100644 --- a/PracticePlugin/CustomEffectPoolsInstaller.cs +++ b/PracticePlugin/CustomEffectPoolsInstaller.cs @@ -7,8 +7,8 @@ public override void InstallBindings() try { Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingTextEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20) - .FromComponentInNewPrefab(_flyingScoreTextEffectPrefab); + Container.BindMemoryPool().WithInitialSize(20) + .FromComponentInNewPrefab(_flyingScoreEffectPrefab); Container.BindMemoryPool().WithInitialSize(20) .FromComponentInNewPrefab(_flyingSpriteEffectPrefab); Container.BindMemoryPool().WithInitialSize(30).FromComponentInNewPrefab(_noteDebrisPrefab); diff --git a/PracticePlugin/CustomNoteCutSoundEffect.cs b/PracticePlugin/CustomNoteCutSoundEffect.cs index 0bde5e0..1c0d9f5 100644 --- a/PracticePlugin/CustomNoteCutSoundEffect.cs +++ b/PracticePlugin/CustomNoteCutSoundEffect.cs @@ -31,9 +31,9 @@ public override void LateUpdate() } public override void Init(AudioClip audioClip, double noteDSPTime, float aheadTime, float missedTimeOffset, float timeToPrevNote, float timeToNextNote, - Saber saber, NoteData noteData, bool handleWrongSaberTypeAsGood, float volumeMultiplier) + Saber saber, NoteData noteData, bool handleWrongSaberTypeAsGood, float volumeMultiplier, bool ignoreSaberSpeed) { - base.Init(audioClip, noteDSPTime, aheadTime, missedTimeOffset, timeToPrevNote, timeToNextNote, saber, noteData, handleWrongSaberTypeAsGood, volumeMultiplier); + base.Init(audioClip, noteDSPTime, aheadTime, missedTimeOffset, timeToPrevNote, timeToNextNote, saber, noteData, handleWrongSaberTypeAsGood, volumeMultiplier, ignoreSaberSpeed); _audioSource.Stop(); var dspTime = AudioSettings.dspTime; var timeDiff = noteDSPTime - dspTime; diff --git a/PracticePlugin/NjsSettingsController.cs b/PracticePlugin/NjsSettingsController.cs index 0467be8..a3977ad 100644 --- a/PracticePlugin/NjsSettingsController.cs +++ b/PracticePlugin/NjsSettingsController.cs @@ -15,6 +15,7 @@ protected override void GetInitValues(out int idx, out int numberOfElements) numberOfElements = 50; defaultNJS = (int)Plugin._spawnController.GetPrivateField("_noteJumpMovementSpeed"); idx = defaultNJS; + UIElementsCreator.njsSpeed = defaultNJS; } protected override void ApplyValue(int idx) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 661006a..e5b5b27 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "v4.1.3"; } + get { return "v4.2.0"; } } public const float SpeedMaxSize = 5.05f; @@ -31,7 +31,7 @@ public string Version public const int NjsMaxSize = 100; public const int NjstepSize = 1; - public const string MenuSceneName = "Menu"; + public const string MenuSceneName = "MenuCore"; public const string GameSceneName = "GameCore"; public const string ContextSceneName = "GameplayCore"; @@ -84,10 +84,10 @@ private set public static bool PlayingNewSong { get; private set; } private static bool _init; - public static StandardLevelSceneSetupDataSO _levelData { get; private set; } + public static BS_Utils.Gameplay.LevelData _levelData { get; private set; } public static BeatmapObjectSpawnController _spawnController { get; private set; } public static AudioTimeSyncController AudioTimeSync { get; private set; } - private static AudioMixerSO _mixer; + private static AudioManagerSO _mixer; private static AudioSource _songAudio; private static GameplayCoreSceneSetup _gameCoreSceneSetup; private static string _lastLevelId; @@ -106,7 +106,7 @@ public void OnApplicationStart() private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) { - if(arg0.name == "Menu") + if(arg0.name == "MenuCore") { var fullEnergy = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Start With Full Energy", "MainMenu", "Start With full energy in Practice Mode."); fullEnergy.GetValue = ModPrefs.GetBool("PracticePlugin", "startWithFullEnergy", false, true); @@ -258,9 +258,9 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) if (_levelData == null) { - _levelData = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + _levelData = BS_Utils.Plugin.LevelData; if (_levelData == null) return; - _levelData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; + BS_Utils.Plugin.LevelDidFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; } if (_spawnController == null) @@ -270,13 +270,13 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) } - if (_lastLevelId != _levelData.difficultyBeatmap.level.levelID && + if (_lastLevelId != _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID && !string.IsNullOrEmpty(_lastLevelId)) { PlayingNewSong = true; HasTimeScaleChanged = false; TimeScale = 1; - _lastLevelId = _levelData.difficultyBeatmap.level.levelID; + _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; } else { @@ -288,12 +288,12 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) HasTimeScaleChanged = false; } - _lastLevelId = _levelData.difficultyBeatmap.level.levelID; + _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; _gameCoreSceneSetup = Resources.FindObjectsOfTypeAll().FirstOrDefault(); AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); - _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); - PracticeMode = (_levelData.gameplayCoreSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); + _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); + PracticeMode = (_levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); //Check if Multiplayer is active, disable accordingly @@ -304,10 +304,10 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) } if (PracticeMode) { - if (_levelData.gameplayCoreSetupData.practiceSettings.songSpeedMul != 1f) - _timeScale = _levelData.gameplayCoreSetupData.practiceSettings.songSpeedMul; + if (_levelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul != 1f) + _timeScale = _levelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul; else - _timeScale = _levelData.gameplayCoreSetupData.gameplayModifiers.songSpeedMul; + _timeScale = _levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; SharedCoroutineStarter.instance.StartCoroutine(DelayedSetup()); } @@ -359,7 +359,7 @@ private void ResultsViewControllerOnContinueButtonPressedEvent(ResultsViewContro */ } - private void MainGameSceneSetupDataOnDidFinishEvent(StandardLevelSceneSetupDataSO levelData, LevelCompletionResults results) + private void MainGameSceneSetupDataOnDidFinishEvent(StandardLevelScenesTransitionSetupDataSO levelData, LevelCompletionResults results) { /* @@ -414,7 +414,7 @@ public static void AdjustNJS(float njs) float halfJumpDur = 4f; float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); - float noteJumpStartBeatOffset = _levelData.difficultyBeatmap.noteJumpStartBeatOffset; + float noteJumpStartBeatOffset = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); float jumpDis; @@ -470,6 +470,37 @@ public static void AdjustSpawnOffset(float offset) _spawnController.SetPrivateField("_moveDistance", moveDis); + } + public static void AdjustNjsAndOffset() + { + float njs = UIElementsCreator.njsSpeed; + float noteJumpStartBeatOffset = UIElementsCreator.spawnOffset; + float halfJumpDur = 4f; + float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); + float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); + float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); + float jumpDis; + float spawnAheadTime; + float moveDis; + float bpm = _spawnController.GetPrivateField("_beatsPerMinute"); + float num = 60f / bpm; + moveDis = moveSpeed * num * moveDir; + while (njs * num * halfJumpDur > maxHalfJump) + { + halfJumpDur /= 2f; + } + halfJumpDur += noteJumpStartBeatOffset; + if (halfJumpDur < 1f) halfJumpDur = 1f; + // halfJumpDur = spawnController.GetPrivateField("_halfJumpDurationInBeats"); + jumpDis = njs * num * halfJumpDur * 2f; + spawnAheadTime = moveDis / moveSpeed + jumpDis * 0.5f / njs; + _spawnController.SetPrivateField("_halfJumpDurationInBeats", halfJumpDur); + _spawnController.SetPrivateField("_spawnAheadTime", spawnAheadTime); + _spawnController.SetPrivateField("_jumpDistance", jumpDis); + _spawnController.SetPrivateField("_noteJumpMovementSpeed", njs); + _spawnController.SetPrivateField("_moveDistance", moveDis); + + } } } \ No newline at end of file diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 070c323..9e50ee2 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -51,8 +51,8 @@ - - C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\TextMeshPro-1.0.55.2017.1.0b12.dll + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Unity.TextMeshPro.dll C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 8d866d8..1103e78 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.1.3.0")] -[assembly: AssemblyFileVersion("4.1.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.2.0.0")] +[assembly: AssemblyFileVersion("4.2.0.0")] \ No newline at end of file diff --git a/PracticePlugin/SpawnOffsetController.cs b/PracticePlugin/SpawnOffsetController.cs index 90bc91b..8267ee5 100644 --- a/PracticePlugin/SpawnOffsetController.cs +++ b/PracticePlugin/SpawnOffsetController.cs @@ -13,8 +13,9 @@ protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; numberOfElements = 50; - defaultOffset = (int)Plugin._levelData.difficultyBeatmap.noteJumpStartBeatOffset; + defaultOffset = (int)Plugin._levelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; idx = defaultOffset; + UIElementsCreator.spawnOffset = defaultOffset; } protected override void ApplyValue(int idx) diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 19dba05..864e58c 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -8,7 +8,8 @@ public class UIElementsCreator : MonoBehaviour { public event Action ValueChangedEvent; public SongSeeker SongSeeker { get; private set; } - + internal static float njsSpeed; + internal static float spawnOffset; private GameObject _speedSettings = null; private GameObject _njsSettings = null; private GameObject _offsetSettings = null; @@ -92,13 +93,15 @@ private void OnEnable() private void SpawnOffsetController_ValueChangedEvent(float offset) { - Plugin.AdjustSpawnOffset(offset); + spawnOffset = offset; + Plugin.AdjustNjsAndOffset(); SongSeeker.ApplyPlaybackPosition(); } private void NjsController_ValueChangedEvent(float njs) { - Plugin.AdjustNJS(njs); + njsSpeed = njs; + Plugin.AdjustNjsAndOffset(); SongSeeker.ApplyPlaybackPosition(); } From bde95ee12fe9ded19f54616973c64583809f746d Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 23 Mar 2019 20:48:31 -0400 Subject: [PATCH 13/64] 4.2.3 --- PracticePlugin/Plugin.cs | 2 +- PracticePlugin/Properties/AssemblyInfo.cs | 4 +-- PracticePlugin/SongSeekBeatmapHandler.cs | 3 +- PracticePlugin/SongSeeker.cs | 43 +++++++++-------------- PracticePlugin/UIElementsCreator.cs | 10 +++--- 5 files changed, 27 insertions(+), 35 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index e5b5b27..d6ca614 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "v4.2.0"; } + get { return "v4.2.3"; } } public const float SpeedMaxSize = 5.05f; diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 1103e78..184a21b 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.2.0.0")] -[assembly: AssemblyFileVersion("4.2.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.2.3.0")] +[assembly: AssemblyFileVersion("4.2.3.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index 007db80..bf40532 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -21,7 +21,7 @@ private static List C _callbackList = _beatmapObjectCallbackController .GetPrivateField>( - "_beatmapObjectCallbackData"); + "_beatmapObjectCallbackData"); _beatmapData = _beatmapObjectCallbackController .GetPrivateField("_beatmapDataModel").beatmapData; @@ -104,6 +104,7 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) var notesA = _noteAPool.activeItems.ToList(); foreach (var noteA in notesA) { + // Console.WriteLine("Despawning, Length: " + notesA.Count); _beatmapObjectSpawnController.Despawn(noteA); } diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 422aa1c..2845cb1 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -11,7 +11,7 @@ public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler { public float PlaybackPosition { get; private set; } - [SerializeField] private AudioSource _songAudioSource; + [SerializeField] internal AudioSource _songAudioSource; private LooperUI _looperUI; private Image _seekBackg; @@ -40,7 +40,7 @@ public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler private const float StickToLooperCursorDistance = 0.02f; private const float LooperUITopMargin = -5f; private bool init = false; - private int _startTimeSamples; + internal int _startTimeSamples; public void Init() { _songAudioSource = Plugin.AudioTimeSync.GetPrivateField("_audioSource"); @@ -75,35 +75,26 @@ public void Init() rectTransform.sizeDelta = SeekCursorSize; _seekCursor.color = SeekCursorColor; - _currentTime = new GameObject("Current Time").AddComponent(); - rectTransform = _currentTime.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.anchorMin = Vector2.up * 0.5f; - rectTransform.anchorMax = Vector2.up * 0.5f; - rectTransform.sizeDelta = TimeTextSize; - rectTransform.anchoredPosition = new Vector2(-(TimeTextSize.x / 2) - TimeTextMargin, 0); - _currentTime.enableAutoSizing = true; - _currentTime.fontSizeMin = 1; + _currentTime = CustomUI.BeatSaber.BeatSaberUI.CreateText(this.GetComponent(), "0:00", new Vector2(-32f, -1f)); + _currentTime.fontSize = 5f; + // rectTransform = _currentTime.rectTransform; + // rectTransform.anchorMin = Vector2.up * 0.5f; + // rectTransform.anchorMax = Vector2.up * 0.5f; + // rectTransform.sizeDelta = TimeTextSize; + // rectTransform.anchoredPosition = new Vector2(-(TimeTextSize.x / 2) - TimeTextMargin, 0); + // _currentTime.enableAutoSizing = true; + // _currentTime.fontSizeMin = 1; _currentTime.alignment = TextAlignmentOptions.Right; - _currentTime.text = "0:00"; - - _timeLength = new GameObject("Time Length").AddComponent(); - rectTransform = _timeLength.rectTransform; - rectTransform.SetParent(transform, false); - rectTransform.anchorMin = new Vector2(1, 0.5f); - rectTransform.anchorMax = new Vector2(1, 0.5f); - rectTransform.sizeDelta = TimeTextSize; - rectTransform.anchoredPosition = new Vector2(TimeTextSize.x / 2 + TimeTextMargin, 0); - _timeLength.enableAutoSizing = true; - _timeLength.fontSizeMin = 1; + + _timeLength = CustomUI.BeatSaber.BeatSaberUI.CreateText(this.GetComponent(), "0:00", new Vector2(87f, -1f)); + _timeLength.fontSize = 5f; _timeLength.alignment = TextAlignmentOptions.Left; - _timeLength.text = "0:00"; var looperObj = new GameObject("Looper UI"); looperObj.transform.SetParent(_seekBar.rectTransform, false); rectTransform = looperObj.AddComponent(); rectTransform.sizeDelta = SeekBarSize; - rectTransform.anchoredPosition = new Vector2(0, LooperUITopMargin); + rectTransform.anchoredPosition = new Vector2(0, LooperUITopMargin - 2f); _looperUI = looperObj.AddComponent(); _looperUI.Init(this); _looperUI.OnDragEndEvent += LooperUIOnOnDragEndEvent; @@ -111,8 +102,8 @@ public void Init() if (_looperUI.StartTime != 0) { PlaybackPosition = _looperUI.StartTime; - Invoke(nameof(ApplyPlaybackPosition), 0.1f); - ApplyPlaybackPosition(); + // Invoke(nameof(ApplyPlaybackPosition), 0.1f); + // ApplyPlaybackPosition(); } _mainCamera = Camera.main; diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 864e58c..60acc27 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -50,7 +50,7 @@ private void OnEnable() var rectTransform = (RectTransform)_speedSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, 10); + rectTransform.anchoredPosition = new Vector2(0, 7); speedController = _speedSettings.GetComponent(); speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; @@ -64,7 +64,7 @@ private void OnEnable() var rectTransform = (RectTransform)_njsSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, 2); + rectTransform.anchoredPosition = new Vector2(0, -1); njsController = _njsSettings.GetComponent(); njsController.ValueChangedEvent += NjsController_ValueChangedEvent; @@ -78,7 +78,7 @@ private void OnEnable() var rectTransform = (RectTransform)_offsetSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, -6); + rectTransform.anchoredPosition = new Vector2(0, -9); spawnOffsetController = _offsetSettings.GetComponent(); spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; @@ -95,14 +95,14 @@ private void SpawnOffsetController_ValueChangedEvent(float offset) { spawnOffset = offset; Plugin.AdjustNjsAndOffset(); - SongSeeker.ApplyPlaybackPosition(); + SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } private void NjsController_ValueChangedEvent(float njs) { njsSpeed = njs; Plugin.AdjustNjsAndOffset(); - SongSeeker.ApplyPlaybackPosition(); + SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } private void OnDisable() From 07847b6f51d42c939aad9195b287cc059049ba0b Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Wed, 3 Apr 2019 11:01:38 -0400 Subject: [PATCH 14/64] Update README.md --- README.md | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 1c3cab8..8b5875c 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,31 @@ -# Practice Plugin -Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections. - -## [Video Preview](https://youtu.be/2V6pyMToqYY) - -![Preview](https://i.imgur.com/Z4B8Ayc.jpg) - -# Installation -*This plugin requires IPA which you will automatically get if you install [the Song Loader Plugin](https://github.com/xyonico/BeatSaberSongLoader/releases).* - -1. Make sure that Beat Saber is not running. -2. Extract the `PracticePlugin.dll` into the `Beat Saber/Plugins` folder. - For Oculus Home: `.../Oculus Apps/Software/hyperbolic-magnetism-beat-saber` - For Steam: `.../steamapps/common/Beat Saber` - (The folder that contains Beat Saber.exe) -4. Done! You've installed the Practice Plugin. +### Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections. +##### Original Plugin made by Xyonico: https://github.com/xyonico/PracticePlugin +![Preview](https://i.imgur.com/vdpHLbR.png) # Usage -You will see the speed option in the pause menu. If you turn enable No Fail, you will be able to go below 100% speed. +- The UI shown above for the plugin will activate in practice mode, which can be accessed using the small button next to the play button +- Move the blue diamond below the seeker to where you want the loop to start and move the red diamond to where you want the loop to end. +- The Song will only loop if the red diamond is not at the end of the song +- The Speed, NJS, and spawn offset will reset to that of the song upon starting or restarting the song +- Note: If you set a starting time for the song using the built in practice mode, the map literally starts at that point, so going back to before the starting point in practice plugin won't have any notes -The seeker is only available in No Fail mode. -Move the blue diamond below the seeker to where you want the loop to start and move the red diamond to where you want the loop to end. --- - -If you need help, ask us at the Beat Saber Mod Group Discord Server: -https://discord.gg/Cz6PTM5 +## Changelog v4.2.3 +- Made Looper cursors easier to grab +## Changelog v4.2.2 +- Hopefully fixed issue with invisible notes appearing often after pausing with practice plugin +- Added back Text elements for Song Seeker +## Changelog v4.2.0 +- Update for Beat Saber 0.13.0 +## Changelog v4.1.1 +- Minor fixes +- Default NJS and Spawn Offset for the song are now underlined when they are selected in the UI +- Now Makes Use of BS Utils +## Changelog v4.0.1 +- Updated for Beat Saber 0.12.2 +- Can also change NJS and Spawn Offset from the plugin's UI +- Minor Changes +## Changelog v3.0.2 + * Fixed notes not getting despawned properly when changing timeline, causing double notes. + * Cleaned up debug logs. From a52786ed3f97d10e78594fc8491c7a31ad0fb3ae Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Wed, 3 Apr 2019 18:48:57 -0400 Subject: [PATCH 15/64] 0.13.1 --- PracticePlugin/Plugin.cs | 14 +++++++------- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/UIElementsCreator.cs | 3 --- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index d6ca614..ca4d16d 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "v4.2.3"; } + get { return "v4.2.4"; } } public const float SpeedMaxSize = 5.05f; @@ -142,7 +142,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) if (SpeedSettingsObject != null) return; - var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (volumeSettings == null) return; @@ -153,7 +153,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) if (SpeedSettingsObject == null) return; - var volume = SpeedSettingsObject.GetComponent(); + var volume = SpeedSettingsObject.GetComponent(); ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController), typeof(SpeedSettingsController), SpeedSettingsObject); Object.DestroyImmediate(volume); @@ -165,7 +165,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) //NJS Object if (NjsSettingsObject != null) return; - var volumeSettings2 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + var volumeSettings2 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (volumeSettings2 == null) return; @@ -176,7 +176,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) if (NjsSettingsObject == null) return; - var volume2 = NjsSettingsObject.GetComponent(); + var volume2 = NjsSettingsObject.GetComponent(); ReflectionUtil.CopyComponent(volume2, typeof(IncDecSettingsController), typeof(NjsSettingsController), NjsSettingsObject); Object.DestroyImmediate(volume2); @@ -188,7 +188,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) //Spawn Offset Object if (SpawnOffsetSettingsObject != null) return; - var volumeSettings3 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + var volumeSettings3 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (volumeSettings3 == null) return; @@ -199,7 +199,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) if (SpawnOffsetSettingsObject == null) return; - var volume3 = SpawnOffsetSettingsObject.GetComponent(); + var volume3 = SpawnOffsetSettingsObject.GetComponent(); ReflectionUtil.CopyComponent(volume3, typeof(IncDecSettingsController), typeof(SpawnOffsetController), SpawnOffsetSettingsObject); Object.DestroyImmediate(volume3); diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 184a21b..20ab7cc 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.2.3.0")] -[assembly: AssemblyFileVersion("4.2.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.2.4.0")] +[assembly: AssemblyFileVersion("4.2.4.0")] \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 60acc27..848a1c3 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -54,7 +54,6 @@ private void OnEnable() speedController = _speedSettings.GetComponent(); speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; - speedController.Init(); } if (_njsSettings == null && Plugin.PracticeMode) { @@ -68,7 +67,6 @@ private void OnEnable() njsController = _njsSettings.GetComponent(); njsController.ValueChangedEvent += NjsController_ValueChangedEvent; - njsController.Init(); } if (_offsetSettings == null && Plugin.PracticeMode) { @@ -82,7 +80,6 @@ private void OnEnable() spawnOffsetController = _offsetSettings.GetComponent(); spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; - spawnOffsetController.Init(); } From 6cf56fdb40bab2ab804f11af6afecd1cb166b90a Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 4 Apr 2019 20:31:29 -0400 Subject: [PATCH 16/64] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b5875c..66c4c25 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ - The Song will only loop if the red diamond is not at the end of the song - The Speed, NJS, and spawn offset will reset to that of the song upon starting or restarting the song - Note: If you set a starting time for the song using the built in practice mode, the map literally starts at that point, so going back to before the starting point in practice plugin won't have any notes - +- Note: It is HEAVILY DISCOURAGED to use base game methods of changing speed in practice mode with practice plugin installed, and only change speed through the pause menu, as currently doing otherwise can cause audio desync --- ## Changelog v4.2.3 From b2aeed3e5785776feb0880d0b0b3a952270beaad Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 13 Apr 2019 19:57:58 -0400 Subject: [PATCH 17/64] Update to build with 4.6.1 --- PracticePlugin/PracticePlugin.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 9e50ee2..ef5e606 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -9,8 +9,9 @@ Properties PracticePlugin PracticePlugin - v4.6 + v4.6.1 512 + AnyCPU From f7d221ed9e3d465a05cb7780ecbb83d46ca30bc2 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Fri, 19 Apr 2019 00:06:40 -0400 Subject: [PATCH 18/64] Option to display time song was failed on results screen --- PracticePlugin/NoFailGameEnergy.cs | 2 +- PracticePlugin/Plugin.cs | 139 ++++++++++++++-------- PracticePlugin/Properties/AssemblyInfo.cs | 4 +- 3 files changed, 94 insertions(+), 51 deletions(-) diff --git a/PracticePlugin/NoFailGameEnergy.cs b/PracticePlugin/NoFailGameEnergy.cs index 5685170..27029e8 100644 --- a/PracticePlugin/NoFailGameEnergy.cs +++ b/PracticePlugin/NoFailGameEnergy.cs @@ -17,7 +17,7 @@ public class NoFailGameEnergy : MonoBehaviour private void Awake() {/* hasFailed = false; - limitLevelFail = ModPrefs.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); + limitLevelFail = Config.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); _gameEnergyUIPanel = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (_gameEnergyUIPanel == null) return; diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index ca4d16d..00c102d 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "v4.2.4"; } + get { return "v4.3.0"; } } public const float SpeedMaxSize = 5.05f; @@ -35,6 +35,8 @@ public string Version public const string GameSceneName = "GameCore"; public const string ContextSceneName = "GameplayCore"; + public string failTime { get; private set; } + internal bool showFailTextNext { get; set; } public static GameObject SpeedSettingsObject { get; private set; } public static GameObject NjsSettingsObject { get; private set; } public static GameObject SpawnOffsetSettingsObject { get; private set; } @@ -45,8 +47,8 @@ public static float TimeScale private set { _timeScale = value; - // AudioTimeSync.SetPrivateField("_timeScale", value); - // AudioTimeSync.Init(_songAudio.clip, _songAudio.time, AudioTimeSync.GetPrivateField("_songTimeOffset"), value); + // AudioTimeSync.SetPrivateField("_timeScale", value); + // AudioTimeSync.Init(_songAudio.clip, _songAudio.time, AudioTimeSync.GetPrivateField("_songTimeOffset"), value); if (_timeScale == 1f) _mixer.musicPitch = 1; else @@ -85,6 +87,7 @@ private set private static bool _init; public static BS_Utils.Gameplay.LevelData _levelData { get; private set; } + public static BS_Utils.Utilities.Config Config = new BS_Utils.Utilities.Config("PracticePlugin"); public static BeatmapObjectSpawnController _spawnController { get; private set; } public static AudioTimeSyncController AudioTimeSync { get; private set; } private static AudioManagerSO _mixer; @@ -92,54 +95,69 @@ private set private static GameplayCoreSceneSetup _gameCoreSceneSetup; private static string _lastLevelId; private static UIElementsCreator _uiElementsCreator; + private static ResultsViewController resultsViewController; private static bool _resetNoFail; - + private static bool showTimeFailed = true; + private static TextMeshProUGUI failText; public void OnApplicationStart() { if (_init) return; _init = true; - SceneManager.activeSceneChanged += OneSceneChanged; + SceneManager.activeSceneChanged += OnSceneChanged; SceneManager.sceneLoaded += SceneManager_sceneLoaded; - NoFailGameEnergy.limitLevelFail = ModPrefs.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); - startWithFullEnergy = ModPrefs.GetBool("PracticePlugin", "startWithFullEnergy", false, true); + // NoFailGameEnergy.limitLevelFail = Config.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); + startWithFullEnergy = Config.GetBool("PracticePlugin", "startWithFullEnergy", false, true); + showTimeFailed = Config.GetBool("PracticePlugin", "Show Time Failed", true, true); } private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) { - if(arg0.name == "MenuCore") + if (arg0.name == "MenuCore") { - var fullEnergy = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Start With Full Energy", "MainMenu", "Start With full energy in Practice Mode."); - fullEnergy.GetValue = ModPrefs.GetBool("PracticePlugin", "startWithFullEnergy", false, true); - fullEnergy.OnToggle += (value) => + var practicePluginSubmenu = GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.PlayerSettingsRight, "PracticePlugin", "MainMenu", "PracticePlugin", "Practice Plugin Settings"); + var fullEnergy = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Start With Full Energy", "PracticePlugin", "Start With full energy in Practice Mode."); + fullEnergy.GetValue = Config.GetBool("PracticePlugin", "startWithFullEnergy", false, true); + fullEnergy.OnToggle += (value) => + { + startWithFullEnergy = value; + Config.SetBool("PracticePlugin", "startWithFullEnergy", value); + + }; + + var timeFailedOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Show Time Failed", "PracticePlugin", "Show the time the level was failed on the results screen."); + timeFailedOption.GetValue = Config.GetBool("PracticePlugin", "Show Time Failed", true, true); + timeFailedOption.OnToggle += (value) => { - startWithFullEnergy = value; - ModPrefs.SetBool("PracticePlugin", "startWithFullEnergy", value); + showTimeFailed = value; + Config.SetBool("PracticePlugin", "Show Time Failed", value); }; } - + } public void OnApplicationQuit() { - SceneManager.activeSceneChanged -= OneSceneChanged; + SceneManager.activeSceneChanged -= OnSceneChanged; } - private void OneSceneChanged(Scene oldScene, Scene newScene) + private void OnSceneChanged(Scene oldScene, Scene newScene) { Object.Destroy(Resources.FindObjectsOfTypeAll().FirstOrDefault()?.gameObject); if (newScene.name == MenuSceneName) { - if (_resetNoFail) + + resultsViewController = + Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (resultsViewController != null) { - var resultsViewController = - Resources.FindObjectsOfTypeAll().FirstOrDefault(); - if (resultsViewController != null) - resultsViewController.continueButtonPressedEvent += - ResultsViewControllerOnContinueButtonPressedEvent; + + resultsViewController.didActivateEvent -= ResultsViewController_didActivateEvent; + resultsViewController.didActivateEvent += ResultsViewController_didActivateEvent; } + if (SpeedSettingsObject != null) return; var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); @@ -295,7 +313,7 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); PracticeMode = (_levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); //Check if Multiplayer is active, disable accordingly - + if (!PracticeMode) @@ -314,6 +332,24 @@ private void OneSceneChanged(Scene oldScene, Scene newScene) } } + private void ResultsViewController_didActivateEvent(bool firstActivation, VRUI.VRUIViewController.ActivationType activationType) + { + if (showFailTextNext && showTimeFailed) + { + Console.WriteLine("Creating fail time"); + if (failText == null) + failText = CustomUI.BeatSaber.BeatSaberUI.CreateText(resultsViewController.rectTransform, failTime, new Vector2(15f, -25f)); + else + failText.text = failTime; + failText.richText = true; + } + else + { + if (failText != null) + failText.text = ""; + } + } + public System.Collections.IEnumerator DelayedSetup() { yield return new WaitForSeconds(0.2f); @@ -333,12 +369,12 @@ public System.Collections.IEnumerator DelayedSetup() TimeScale = TimeScale; var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); - // bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f); + // bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f); bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); var pauseMenu = GameObject.Find("PauseMenu"); pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); - if(startWithFullEnergy) + if (startWithFullEnergy) { GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (energyCounter != null) @@ -361,7 +397,14 @@ private void ResultsViewControllerOnContinueButtonPressedEvent(ResultsViewContro private void MainGameSceneSetupDataOnDidFinishEvent(StandardLevelScenesTransitionSetupDataSO levelData, LevelCompletionResults results) { - + if (results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Failed) + { + float endTime = results.endSongTime; + float length = _songAudio.clip.length; + failTime = $"<#ff0000>Failed At - {Math.Floor(endTime / 60):N0}:{Math.Floor(endTime % 60):00} / {Math.Floor(length / 60):N0}:{Math.Floor(length % 60):00}"; + showFailTextNext = true; + + } /* * if (!NoFail && HasTimeScaleChanged && results != null && @@ -412,33 +455,33 @@ public void OnFixedUpdate() public static void AdjustNJS(float njs) { - float halfJumpDur = 4f; - float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); - float noteJumpStartBeatOffset = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; - float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); - float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); - float jumpDis; - float spawnAheadTime; - float moveDis; - float bpm = _spawnController.GetPrivateField("_beatsPerMinute"); - float num = 60f / bpm; - moveDis = moveSpeed * num * moveDir; - while (njs * num * halfJumpDur > maxHalfJump) - { - halfJumpDur /= 2f; - } - halfJumpDur += noteJumpStartBeatOffset; - if (halfJumpDur < 1f) halfJumpDur = 1f; - // halfJumpDur = spawnController.GetPrivateField("_halfJumpDurationInBeats"); - jumpDis = njs * num * halfJumpDur * 2f; - spawnAheadTime = moveDis / moveSpeed + jumpDis * 0.5f / njs; + float halfJumpDur = 4f; + float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); + float noteJumpStartBeatOffset = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; + float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); + float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); + float jumpDis; + float spawnAheadTime; + float moveDis; + float bpm = _spawnController.GetPrivateField("_beatsPerMinute"); + float num = 60f / bpm; + moveDis = moveSpeed * num * moveDir; + while (njs * num * halfJumpDur > maxHalfJump) + { + halfJumpDur /= 2f; + } + halfJumpDur += noteJumpStartBeatOffset; + if (halfJumpDur < 1f) halfJumpDur = 1f; + // halfJumpDur = spawnController.GetPrivateField("_halfJumpDurationInBeats"); + jumpDis = njs * num * halfJumpDur * 2f; + spawnAheadTime = moveDis / moveSpeed + jumpDis * 0.5f / njs; _spawnController.SetPrivateField("_halfJumpDurationInBeats", halfJumpDur); _spawnController.SetPrivateField("_spawnAheadTime", spawnAheadTime); _spawnController.SetPrivateField("_jumpDistance", jumpDis); _spawnController.SetPrivateField("_noteJumpMovementSpeed", njs); _spawnController.SetPrivateField("_moveDistance", moveDis); - + } public static void AdjustSpawnOffset(float offset) { @@ -480,7 +523,7 @@ public static void AdjustNjsAndOffset() float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); float jumpDis; - float spawnAheadTime; + float spawnAheadTime; float moveDis; float bpm = _spawnController.GetPrivateField("_beatsPerMinute"); float num = 60f / bpm; diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 20ab7cc..7a5499c 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.2.4.0")] -[assembly: AssemblyFileVersion("4.2.4.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.3.0.0")] +[assembly: AssemblyFileVersion("4.3.0.0")] \ No newline at end of file From 235402952a82c7924579855c528c8d2e58c6112c Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 16 May 2019 22:47:50 -0400 Subject: [PATCH 19/64] . --- PracticePlugin/CustomEffectPoolsInstaller.cs | 15 +++------ PracticePlugin/NjsSettingsController.cs | 7 ++-- PracticePlugin/Plugin.cs | 34 +++++++++++++------- PracticePlugin/PracticePlugin.csproj | 4 +++ PracticePlugin/Properties/AssemblyInfo.cs | 4 +-- PracticePlugin/SpawnOffsetController.cs | 9 ++---- PracticePlugin/UIElementsCreator.cs | 33 ++++++++++++------- 7 files changed, 61 insertions(+), 45 deletions(-) diff --git a/PracticePlugin/CustomEffectPoolsInstaller.cs b/PracticePlugin/CustomEffectPoolsInstaller.cs index 4c8c17f..9eed115 100644 --- a/PracticePlugin/CustomEffectPoolsInstaller.cs +++ b/PracticePlugin/CustomEffectPoolsInstaller.cs @@ -7,17 +7,12 @@ public override void InstallBindings() try { Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingTextEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20) - .FromComponentInNewPrefab(_flyingScoreEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20) - .FromComponentInNewPrefab(_flyingSpriteEffectPrefab); - Container.BindMemoryPool().WithInitialSize(30).FromComponentInNewPrefab(_noteDebrisPrefab); + Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingScoreEffectPrefab); + Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingSpriteEffectPrefab); + Container.BindMemoryPool().WithInitialSize(40).FromComponentInNewPrefab(_noteDebrisHDConditionVariable ? _noteDebrisHDPrefab : _noteDebrisLWPrefab); Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_beatEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20) - .FromComponentInNewPrefab(_bombCutSoundEffectPrefab); ; - - Container.BindMemoryPool().WithInitialSize(16) - .FromComponentInNewPrefab(ReplacePrefab()); + Container.BindMemoryPool().WithInitialSize(16).FromComponentInNewPrefab(_noteCutSoundEffectPrefab); + Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_bombCutSoundEffectPrefab); } catch (System.Exception ex) { diff --git a/PracticePlugin/NjsSettingsController.cs b/PracticePlugin/NjsSettingsController.cs index a3977ad..4970720 100644 --- a/PracticePlugin/NjsSettingsController.cs +++ b/PracticePlugin/NjsSettingsController.cs @@ -8,14 +8,11 @@ public class NjsSettingsController : ListSettingsController public event Action ValueChangedEvent; private int _indexOffset; - private int defaultNJS; protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; numberOfElements = 50; - defaultNJS = (int)Plugin._spawnController.GetPrivateField("_noteJumpMovementSpeed"); - idx = defaultNJS; - UIElementsCreator.njsSpeed = defaultNJS; + idx = (int)UIElementsCreator.currentNJS; } protected override void ApplyValue(int idx) @@ -28,7 +25,7 @@ protected override string TextForValue(int idx) { ValueChangedEvent(idx); } - if (idx == defaultNJS) + if (idx == UIElementsCreator.defaultNJS) return $"{idx}"; else return idx.ToString(); diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 00c102d..90b5073 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -17,12 +17,12 @@ public class Plugin : IPlugin { public string Name { - get { return "Practice Plugin"; } + get { return "PracticePlugin"; } } public string Version { - get { return "v4.3.0"; } + get { return "4.3.2"; } } public const float SpeedMaxSize = 5.05f; @@ -147,7 +147,6 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) Object.Destroy(Resources.FindObjectsOfTypeAll().FirstOrDefault()?.gameObject); if (newScene.name == MenuSceneName) { - resultsViewController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (resultsViewController != null) @@ -176,14 +175,18 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) typeof(SpeedSettingsController), SpeedSettingsObject); Object.DestroyImmediate(volume); - SpeedSettingsObject.GetComponentInChildren().text = "SPEED"; + Polyglot.LocalizedTextMeshProUGUI localizer = SpeedSettingsObject.GetComponentInChildren(); + if (localizer != null) + GameObject.Destroy(localizer); + + SpeedSettingsObject.GetComponentInChildren().text = ""; Object.DontDestroyOnLoad(SpeedSettingsObject); //NJS Object if (NjsSettingsObject != null) return; - var volumeSettings2 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + var volumeSettings2 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (volumeSettings2 == null) return; @@ -194,12 +197,16 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) if (NjsSettingsObject == null) return; - var volume2 = NjsSettingsObject.GetComponent(); + var volume2 = NjsSettingsObject.GetComponent(); ReflectionUtil.CopyComponent(volume2, typeof(IncDecSettingsController), typeof(NjsSettingsController), NjsSettingsObject); Object.DestroyImmediate(volume2); - NjsSettingsObject.GetComponentInChildren().text = "NJS"; + localizer = NjsSettingsObject.GetComponentInChildren(); + if (localizer != null) + GameObject.Destroy(localizer); + + NjsSettingsObject.GetComponentInChildren().text = ""; Object.DontDestroyOnLoad(NjsSettingsObject); @@ -222,7 +229,11 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) typeof(SpawnOffsetController), SpawnOffsetSettingsObject); Object.DestroyImmediate(volume3); - SpawnOffsetSettingsObject.GetComponentInChildren().text = "Spawn Offset"; + localizer = SpawnOffsetSettingsObject.GetComponentInChildren(); + if (localizer != null) + GameObject.Destroy(localizer); + + SpawnOffsetSettingsObject.GetComponentInChildren().text = ""; Object.DontDestroyOnLoad(SpawnOffsetSettingsObject); } @@ -260,7 +271,7 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) if (sceneContext != null && sceneDecoratorContext != null) { - var prop = typeof(Context).GetField("_installers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + var prop = typeof(Context).GetField("_monoInstallers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); var installersList = (List)prop.GetValue(sceneDecoratorContext); installersList.Remove(effectPoolsInstaller); Object.DestroyImmediate(effectPoolsInstaller); @@ -348,6 +359,7 @@ private void ResultsViewController_didActivateEvent(bool firstActivation, VRUI.V if (failText != null) failText.text = ""; } + showFailTextNext = false; } public System.Collections.IEnumerator DelayedSetup() @@ -516,8 +528,8 @@ public static void AdjustSpawnOffset(float offset) } public static void AdjustNjsAndOffset() { - float njs = UIElementsCreator.njsSpeed; - float noteJumpStartBeatOffset = UIElementsCreator.spawnOffset; + float njs = UIElementsCreator.currentNJS; + float noteJumpStartBeatOffset = UIElementsCreator.currentSpawnOffset; float halfJumpDur = 4f; float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index ef5e606..9a0dc22 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -49,6 +49,10 @@ C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll + + False + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Polyglot.Scripts.dll + diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 7a5499c..bde114c 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.3.0.0")] -[assembly: AssemblyFileVersion("4.3.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.3.2.0")] +[assembly: AssemblyFileVersion("4.3.2.0")] \ No newline at end of file diff --git a/PracticePlugin/SpawnOffsetController.cs b/PracticePlugin/SpawnOffsetController.cs index 8267ee5..b865ef8 100644 --- a/PracticePlugin/SpawnOffsetController.cs +++ b/PracticePlugin/SpawnOffsetController.cs @@ -5,17 +5,14 @@ namespace PracticePlugin { public class SpawnOffsetController : ListSettingsController { - public event Action ValueChangedEvent; + public event Action ValueChangedEvent; private int _indexOffset; - private int defaultOffset; protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; numberOfElements = 50; - defaultOffset = (int)Plugin._levelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; - idx = defaultOffset; - UIElementsCreator.spawnOffset = defaultOffset; + idx = UIElementsCreator.currentSpawnOffset; } protected override void ApplyValue(int idx) @@ -28,7 +25,7 @@ protected override string TextForValue(int idx) { ValueChangedEvent(idx); } - if (idx == defaultOffset) + if (idx == UIElementsCreator.defaultOffset) return $"{idx}"; else return idx.ToString(); diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 848a1c3..1f7775c 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -8,8 +8,10 @@ public class UIElementsCreator : MonoBehaviour { public event Action ValueChangedEvent; public SongSeeker SongSeeker { get; private set; } - internal static float njsSpeed; - internal static float spawnOffset; + internal static float currentNJS; + internal static int currentSpawnOffset; + internal static float defaultNJS; + internal static int defaultOffset; private GameObject _speedSettings = null; private GameObject _njsSettings = null; private GameObject _offsetSettings = null; @@ -35,6 +37,12 @@ private void InitDelayed() SongSeeker.Init(); new GameObject("No Fail Game Energy").AddComponent(); + defaultNJS = Plugin._spawnController.GetPrivateField("_noteJumpMovementSpeed"); + currentNJS = defaultNJS; + // Console.WriteLine("NJS: " + UIElementsCreator.defaultNJS); + defaultOffset = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; + currentSpawnOffset = defaultOffset; + // Console.WriteLine("Offset: " + UIElementsCreator.defaultOffset); } } @@ -50,8 +58,9 @@ private void OnEnable() var rectTransform = (RectTransform)_speedSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, 7); - + rectTransform.anchoredPosition = new Vector2(5, 4); + TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "Speed", new Vector2(-30f, -2f)); + settingText.fontSize = 6f; speedController = _speedSettings.GetComponent(); speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; } @@ -63,8 +72,9 @@ private void OnEnable() var rectTransform = (RectTransform)_njsSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, -1); - + rectTransform.anchoredPosition = new Vector2(5, -4); + TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "NJS", new Vector2(-30f, -2f)); + settingText.fontSize = 6f; njsController = _njsSettings.GetComponent(); njsController.ValueChangedEvent += NjsController_ValueChangedEvent; } @@ -76,8 +86,9 @@ private void OnEnable() var rectTransform = (RectTransform)_offsetSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(0, -9); - + rectTransform.anchoredPosition = new Vector2(5, -12); + TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "Spawn Offset", new Vector2(-30f, -2f)); + settingText.fontSize = 6f; spawnOffsetController = _offsetSettings.GetComponent(); spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; } @@ -88,16 +99,16 @@ private void OnEnable() } - private void SpawnOffsetController_ValueChangedEvent(float offset) + private void SpawnOffsetController_ValueChangedEvent(int offset) { - spawnOffset = offset; + currentSpawnOffset = offset; Plugin.AdjustNjsAndOffset(); SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } private void NjsController_ValueChangedEvent(float njs) { - njsSpeed = njs; + currentNJS = njs; Plugin.AdjustNjsAndOffset(); SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } From b158b3f905cffed02963e0c0d66bf3e48f5052cf Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sun, 9 Jun 2019 20:45:10 -0400 Subject: [PATCH 20/64] 1.1.0 --- PracticePlugin/Plugin.cs | 2 +- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/SpawnOffsetController.cs | 12 ++++++------ PracticePlugin/UIElementsCreator.cs | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 90b5073..06f83eb 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "4.3.2"; } + get { return "4.4.0"; } } public const float SpeedMaxSize = 5.05f; diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index bde114c..d7a323a 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.3.2.0")] -[assembly: AssemblyFileVersion("4.3.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.4.0.0")] +[assembly: AssemblyFileVersion("4.4.0.0")] \ No newline at end of file diff --git a/PracticePlugin/SpawnOffsetController.cs b/PracticePlugin/SpawnOffsetController.cs index b865ef8..a7db99c 100644 --- a/PracticePlugin/SpawnOffsetController.cs +++ b/PracticePlugin/SpawnOffsetController.cs @@ -5,14 +5,14 @@ namespace PracticePlugin { public class SpawnOffsetController : ListSettingsController { - public event Action ValueChangedEvent; + public event Action ValueChangedEvent; private int _indexOffset; protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; numberOfElements = 50; - idx = UIElementsCreator.currentSpawnOffset; + idx = (int)(10 * UIElementsCreator.currentSpawnOffset); } protected override void ApplyValue(int idx) @@ -23,12 +23,12 @@ protected override string TextForValue(int idx) { if (ValueChangedEvent != null) { - ValueChangedEvent(idx); + ValueChangedEvent(idx / 10f); } - if (idx == UIElementsCreator.defaultOffset) - return $"{idx}"; + if ((idx / 10f) == UIElementsCreator.defaultOffset) + return $"{idx / 10f}"; else - return idx.ToString(); + return (idx /10f).ToString(); } } } \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 1f7775c..dc57a75 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -9,9 +9,9 @@ public class UIElementsCreator : MonoBehaviour public event Action ValueChangedEvent; public SongSeeker SongSeeker { get; private set; } internal static float currentNJS; - internal static int currentSpawnOffset; + internal static float currentSpawnOffset; internal static float defaultNJS; - internal static int defaultOffset; + internal static float defaultOffset; private GameObject _speedSettings = null; private GameObject _njsSettings = null; private GameObject _offsetSettings = null; @@ -99,7 +99,7 @@ private void OnEnable() } - private void SpawnOffsetController_ValueChangedEvent(int offset) + private void SpawnOffsetController_ValueChangedEvent(float offset) { currentSpawnOffset = offset; Plugin.AdjustNjsAndOffset(); @@ -119,7 +119,7 @@ private void OnDisable() { ValueChangedEvent(_newTimeScale); } - DestroyImmediate(_speedSettings); + Destroy(_speedSettings); } private void SpeedControllerOnValueChangedEvent(float timeScale) From 8fcf9c7404518c2341ef8917c717099af1e8dc10 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 31 Aug 2019 12:13:34 -0400 Subject: [PATCH 21/64] 1.3.0 fix --- PracticePlugin/Plugin.cs | 6 +++--- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/SongSeekBeatmapHandler.cs | 19 ++++++------------- PracticePlugin/SongSeeker.cs | 2 +- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 06f83eb..b5f2c73 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "4.4.0"; } + get { return "4.5.0"; } } public const float SpeedMaxSize = 5.05f; @@ -59,14 +59,14 @@ private set if (AudioTimeSync != null) { - AudioTimeSync.forcedAudioSync = true; + // AudioTimeSync.forcedNoAudioSync = true; } } else { if (AudioTimeSync != null) { - AudioTimeSync.forcedAudioSync = false; + // AudioTimeSync.forcedNoAudioSync = false; } } diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index d7a323a..23db6e2 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.4.0.0")] -[assembly: AssemblyFileVersion("4.4.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.5.0.0")] +[assembly: AssemblyFileVersion("4.5.0.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index bf40532..b06dc9d 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -36,9 +36,8 @@ private static List C _noteAPool = _beatmapObjectSpawnController.GetPrivateField("_noteAPool"); _noteBPool = _beatmapObjectSpawnController.GetPrivateField("_noteBPool"); _bombNotePool = _beatmapObjectSpawnController.GetPrivateField("_bombNotePool"); - _fullHeightObstaclePool = - _beatmapObjectSpawnController.GetPrivateField("_fullHeightObstaclePool"); - _topObstaclePool = _beatmapObjectSpawnController.GetPrivateField("_topObstaclePool"); + _obstaclePool = + _beatmapObjectSpawnController.GetPrivateField("_obstaclePool"); } } @@ -61,8 +60,7 @@ private static List C private static NoteController.Pool _noteAPool; private static NoteController.Pool _noteBPool; private static NoteController.Pool _bombNotePool; - private static ObstacleController.Pool _fullHeightObstaclePool; - private static ObstacleController.Pool _topObstaclePool; + private static ObstacleController.Pool _obstaclePool; private static BeatmapData _beatmapData; @@ -120,17 +118,12 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) _beatmapObjectSpawnController.Despawn(bomb); } - var fullHeights = _fullHeightObstaclePool.activeItems.ToList(); - foreach (var fullHeight in fullHeights) + var obstacles = _obstaclePool.activeItems.ToList(); + foreach (var obstacle in obstacles) { - _beatmapObjectSpawnController.Despawn(fullHeight); + _beatmapObjectSpawnController.Despawn(obstacle); } - var tops = _topObstaclePool.activeItems.ToList(); - foreach (var top in tops) - { - _beatmapObjectSpawnController.Despawn(top); - } Plugin.AudioTimeSync.SetPrivateField("_prevAudioSamplePos", -1); Plugin.AudioTimeSync.SetPrivateField("_songTime", newSongTime); diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 2845cb1..c921cfc 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -75,7 +75,7 @@ public void Init() rectTransform.sizeDelta = SeekCursorSize; _seekCursor.color = SeekCursorColor; - _currentTime = CustomUI.BeatSaber.BeatSaberUI.CreateText(this.GetComponent(), "0:00", new Vector2(-32f, -1f)); + _currentTime = CustomUI.BeatSaber.BeatSaberUI.CreateText(this.GetComponent(), "0:00", new Vector2(-83f, -1f)); _currentTime.fontSize = 5f; // rectTransform = _currentTime.rectTransform; // rectTransform.anchorMin = Vector2.up * 0.5f; From cc78fbc436919bbc673462b05db784f55efb7fcc Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 2 Nov 2019 15:28:32 -0400 Subject: [PATCH 22/64] 4.5.1 --- PracticePlugin/Plugin.cs | 31 ++++++++++++++++++----- PracticePlugin/Properties/AssemblyInfo.cs | 4 +-- PracticePlugin/SpawnOffsetController.cs | 12 ++++----- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index b5f2c73..3b39fa6 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "4.5.0"; } + get { return "4.5.1"; } } public const float SpeedMaxSize = 5.05f; @@ -59,21 +59,38 @@ private set if (AudioTimeSync != null) { - // AudioTimeSync.forcedNoAudioSync = true; + // AudioTimeSync.forcedNoAudioSync = true; } } else { if (AudioTimeSync != null) { - // AudioTimeSync.forcedNoAudioSync = false; + // AudioTimeSync.forcedNoAudioSync = false; } } - - if (_songAudio != null) + if (AudioTimeSync != null) { - _songAudio.pitch = _timeScale; + // AudioTimeSync.SetPrivateField("_timeScale", _timeScale); // = _timeScale; + // AudioTimeSync.Init(_songAudio.clip, _songAudio.time, + // AudioTimeSync.GetPrivateField("_songTimeOffset") - AudioTimeSync.GetPrivateField("_audioLatency").value, _timeScale); + Console.WriteLine("Called TimeScale"); + + if (_songAudio != null) + { + _songAudio.pitch = _timeScale; + } + // AudioTimeSync.forcedNoAudioSync = true; + // float num = AudioTimeSync.GetPrivateField("_startSongTime") + AudioTimeSync.GetPrivateField("_songTimeOffset"); + // AudioTimeSync.SetPrivateField("_audioStartTimeOffsetSinceStart", (Time.timeSinceLevelLoad * _timeScale) - num); + // AudioTimeSync.SetPrivateField("_fixingAudioSyncError", false); + // AudioTimeSync.SetPrivateField("_prevAudioSamplePos", _songAudio.timeSamples); + // AudioTimeSync.SetPrivateField("_playbackLoopIndex", 0); + // AudioTimeSync.SetPrivateField("_dspTimeOffset", AudioSettings.dspTime - (double)num); + // AudioTimeSync.SetPrivateField("_timeScale", _timeScale); // = _timeScale; } + + } } @@ -535,7 +552,7 @@ public static void AdjustNjsAndOffset() float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); float jumpDis; - float spawnAheadTime; + float spawnAheadTime; float moveDis; float bpm = _spawnController.GetPrivateField("_beatsPerMinute"); float num = 60f / bpm; diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 23db6e2..50ddef6 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.5.0.0")] -[assembly: AssemblyFileVersion("4.5.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.5.1.0")] +[assembly: AssemblyFileVersion("4.5.1.0")] \ No newline at end of file diff --git a/PracticePlugin/SpawnOffsetController.cs b/PracticePlugin/SpawnOffsetController.cs index a7db99c..9924127 100644 --- a/PracticePlugin/SpawnOffsetController.cs +++ b/PracticePlugin/SpawnOffsetController.cs @@ -11,8 +11,8 @@ public class SpawnOffsetController : ListSettingsController protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; - numberOfElements = 50; - idx = (int)(10 * UIElementsCreator.currentSpawnOffset); + numberOfElements = 100; + idx = 50 + (int)(10 * UIElementsCreator.currentSpawnOffset); } protected override void ApplyValue(int idx) @@ -23,12 +23,12 @@ protected override string TextForValue(int idx) { if (ValueChangedEvent != null) { - ValueChangedEvent(idx / 10f); + ValueChangedEvent((idx - 50) / 10f); } - if ((idx / 10f) == UIElementsCreator.defaultOffset) - return $"{idx / 10f}"; + if (((idx - 50) / 10f) == UIElementsCreator.defaultOffset) + return $"{(idx - 50) / 10f}"; else - return (idx /10f).ToString(); + return ((idx - 50) /10f).ToString(); } } } \ No newline at end of file From d2404596aafe195f59c62a7aad4744ccc6236ad7 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 2 Nov 2019 17:47:28 -0400 Subject: [PATCH 23/64] Disable speed changing until fixed --- PracticePlugin/Plugin.cs | 1 + PracticePlugin/SpeedSettingsController.cs | 10 ++++++---- PracticePlugin/UIElementsCreator.cs | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 3b39fa6..7823bb0 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -47,6 +47,7 @@ public static float TimeScale private set { _timeScale = value; + return; // AudioTimeSync.SetPrivateField("_timeScale", value); // AudioTimeSync.Init(_songAudio.clip, _songAudio.time, AudioTimeSync.GetPrivateField("_songTimeOffset"), value); if (_timeScale == 1f) diff --git a/PracticePlugin/SpeedSettingsController.cs b/PracticePlugin/SpeedSettingsController.cs index 3b5854b..2ca856e 100644 --- a/PracticePlugin/SpeedSettingsController.cs +++ b/PracticePlugin/SpeedSettingsController.cs @@ -12,8 +12,10 @@ public class SpeedSettingsController : ListSettingsController protected override void GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; - numberOfElements = Mathf.RoundToInt(Plugin.SpeedMaxSize / Plugin.SpeedStepSize) - _indexOffset; - idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.SpeedStepSize) - _indexOffset; + // numberOfElements = Mathf.RoundToInt(Plugin.SpeedMaxSize / Plugin.SpeedStepSize) - _indexOffset; + numberOfElements = 0; + idx = 0; + // idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.SpeedStepSize) - _indexOffset; } protected override void ApplyValue(int idx) @@ -26,8 +28,8 @@ protected override string TextForValue(int idx) { ValueChangedEvent(Plugin.SpeedStepSize * (idx + _indexOffset)); } - - return Plugin.SpeedStepSize * 100f * (idx + _indexOffset) + "%"; + return ""; + // return Plugin.SpeedStepSize * 100f * (idx + _indexOffset) + "%"; } } } \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index dc57a75..2bf7f8f 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -59,7 +59,7 @@ private void OnEnable() rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; rectTransform.anchoredPosition = new Vector2(5, 4); - TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "Speed", new Vector2(-30f, -2f)); + TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "Speed (Disabled Until Fixed)", new Vector2(-30f, -2f)); settingText.fontSize = 6f; speedController = _speedSettings.GetComponent(); speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; @@ -124,6 +124,7 @@ private void OnDisable() private void SpeedControllerOnValueChangedEvent(float timeScale) { + /* _newTimeScale = timeScale; if (Math.Abs(_newTimeScale - 1) > 0.0000000001f) { @@ -146,6 +147,7 @@ private void SpeedControllerOnValueChangedEvent(float timeScale) { _leaderboardText.text = Plugin.HasTimeScaleChanged ? "Leaderboard has been disabled\nSet speed to 100% and restart to enable again" : string.Empty; } + */ } } } \ No newline at end of file From 303d1e55689ce588cfcd3658b6bf03aaaafa6f9c Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 2 Nov 2019 17:51:19 -0400 Subject: [PATCH 24/64] Update UIElementsCreator.cs --- PracticePlugin/UIElementsCreator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 2bf7f8f..4679e19 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -59,7 +59,7 @@ private void OnEnable() rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; rectTransform.anchoredPosition = new Vector2(5, 4); - TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "Speed (Disabled Until Fixed)", new Vector2(-30f, -2f)); + TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "Speed (UI Disabled Until Fixed)", new Vector2(-30f, -2f)); settingText.fontSize = 6f; speedController = _speedSettings.GetComponent(); speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; From 2afa56674caede095b376a82fe5ecf68caddcef8 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 7 Nov 2019 15:38:29 -0500 Subject: [PATCH 25/64] 1.5.0 --- PracticePlugin/Plugin.cs | 2 +- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 7823bb0..7dab790 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -22,7 +22,7 @@ public string Name public string Version { - get { return "4.5.1"; } + get { return "4.5.2"; } } public const float SpeedMaxSize = 5.05f; diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 50ddef6..30a0f7f 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.5.1.0")] -[assembly: AssemblyFileVersion("4.5.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.5.2.0")] +[assembly: AssemblyFileVersion("4.5.2.0")] \ No newline at end of file From fa448c0999585a65171e5f798d4f703ca2a495fa Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Fri, 13 Dec 2019 14:05:06 -0500 Subject: [PATCH 26/64] 1.6.0 update --- PracticePlugin/CustomNoteCutSoundEffect.cs | 4 +- PracticePlugin/NjsSettingsController.cs | 3 +- PracticePlugin/NoFailGameEnergy.cs | 1 - PracticePlugin/Plugin.cs | 81 ++++++++++++++-------- PracticePlugin/PracticePlugin.csproj | 23 +++--- PracticePlugin/Properties/AssemblyInfo.cs | 4 +- PracticePlugin/SongSeekBeatmapHandler.cs | 4 +- PracticePlugin/SongSeeker.cs | 4 +- PracticePlugin/SpawnOffsetController.cs | 5 +- PracticePlugin/SpeedSettingsController.cs | 5 +- PracticePlugin/UIElementsCreator.cs | 12 ++-- PracticePlugin/manifest.json | 18 +++++ 12 files changed, 104 insertions(+), 60 deletions(-) create mode 100644 PracticePlugin/manifest.json diff --git a/PracticePlugin/CustomNoteCutSoundEffect.cs b/PracticePlugin/CustomNoteCutSoundEffect.cs index 1c0d9f5..c8703a8 100644 --- a/PracticePlugin/CustomNoteCutSoundEffect.cs +++ b/PracticePlugin/CustomNoteCutSoundEffect.cs @@ -31,9 +31,9 @@ public override void LateUpdate() } public override void Init(AudioClip audioClip, double noteDSPTime, float aheadTime, float missedTimeOffset, float timeToPrevNote, float timeToNextNote, - Saber saber, NoteData noteData, bool handleWrongSaberTypeAsGood, float volumeMultiplier, bool ignoreSaberSpeed) + Saber saber, NoteData noteData, bool handleWrongSaberTypeAsGood, float volumeMultiplier, bool ignoreSaberSpeed, bool ignoreBadCuts) { - base.Init(audioClip, noteDSPTime, aheadTime, missedTimeOffset, timeToPrevNote, timeToNextNote, saber, noteData, handleWrongSaberTypeAsGood, volumeMultiplier, ignoreSaberSpeed); + base.Init(audioClip, noteDSPTime, aheadTime, missedTimeOffset, timeToPrevNote, timeToNextNote, saber, noteData, handleWrongSaberTypeAsGood, volumeMultiplier, ignoreSaberSpeed, ignoreBadCuts); _audioSource.Stop(); var dspTime = AudioSettings.dspTime; var timeDiff = noteDSPTime - dspTime; diff --git a/PracticePlugin/NjsSettingsController.cs b/PracticePlugin/NjsSettingsController.cs index 4970720..88b35ee 100644 --- a/PracticePlugin/NjsSettingsController.cs +++ b/PracticePlugin/NjsSettingsController.cs @@ -8,11 +8,12 @@ public class NjsSettingsController : ListSettingsController public event Action ValueChangedEvent; private int _indexOffset; - protected override void GetInitValues(out int idx, out int numberOfElements) + protected override bool GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; numberOfElements = 50; idx = (int)UIElementsCreator.currentNJS; + return true; } protected override void ApplyValue(int idx) diff --git a/PracticePlugin/NoFailGameEnergy.cs b/PracticePlugin/NoFailGameEnergy.cs index 27029e8..e0f4249 100644 --- a/PracticePlugin/NoFailGameEnergy.cs +++ b/PracticePlugin/NoFailGameEnergy.cs @@ -1,7 +1,6 @@ using System.Collections; using System.Linq; using UnityEngine; -using IllusionPlugin; namespace PracticePlugin { public class NoFailGameEnergy : MonoBehaviour diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 7dab790..aa5471d 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -2,28 +2,19 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using IllusionPlugin; -using IllusionInjector; + using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zenject; using Object = UnityEngine.Object; -using CustomUI.GameplaySettings; +//using CustomUI.GameplaySettings; +using IPA; namespace PracticePlugin { - public class Plugin : IPlugin + public class Plugin : IBeatSaberPlugin { - public string Name - { - get { return "PracticePlugin"; } - } - - public string Version - { - get { return "4.5.2"; } - } public const float SpeedMaxSize = 5.05f; public const float SpeedStepSize = 0.05f; @@ -31,7 +22,7 @@ public string Version public const int NjsMaxSize = 100; public const int NjstepSize = 1; - public const string MenuSceneName = "MenuCore"; + public const string MenuSceneName = "MenuViewControllers"; public const string GameSceneName = "GameCore"; public const string ContextSceneName = "GameplayCore"; @@ -121,17 +112,16 @@ public void OnApplicationStart() { if (_init) return; _init = true; - SceneManager.activeSceneChanged += OnSceneChanged; - SceneManager.sceneLoaded += SceneManager_sceneLoaded; // NoFailGameEnergy.limitLevelFail = Config.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); startWithFullEnergy = Config.GetBool("PracticePlugin", "startWithFullEnergy", false, true); showTimeFailed = Config.GetBool("PracticePlugin", "Show Time Failed", true, true); } - private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) + public void OnSceneLoaded(Scene arg0, LoadSceneMode arg1) { if (arg0.name == "MenuCore") { + /* var practicePluginSubmenu = GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.PlayerSettingsRight, "PracticePlugin", "MainMenu", "PracticePlugin", "Practice Plugin Settings"); var fullEnergy = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Start With Full Energy", "PracticePlugin", "Start With full energy in Practice Mode."); fullEnergy.GetValue = Config.GetBool("PracticePlugin", "startWithFullEnergy", false, true); @@ -149,6 +139,7 @@ private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) showTimeFailed = value; Config.SetBool("PracticePlugin", "Show Time Failed", value); }; + */ } @@ -157,10 +148,10 @@ private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) public void OnApplicationQuit() { - SceneManager.activeSceneChanged -= OnSceneChanged; + } - private void OnSceneChanged(Scene oldScene, Scene newScene) + public void OnActiveSceneChanged(Scene oldScene, Scene newScene) { Object.Destroy(Resources.FindObjectsOfTypeAll().FirstOrDefault()?.gameObject); if (newScene.name == MenuSceneName) @@ -177,7 +168,7 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) if (SpeedSettingsObject != null) return; - var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (volumeSettings == null) return; @@ -188,7 +179,7 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) if (SpeedSettingsObject == null) return; - var volume = SpeedSettingsObject.GetComponent(); + var volume = SpeedSettingsObject.GetComponent(); ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController), typeof(SpeedSettingsController), SpeedSettingsObject); Object.DestroyImmediate(volume); @@ -231,7 +222,7 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) //Spawn Offset Object if (SpawnOffsetSettingsObject != null) return; - var volumeSettings3 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + var volumeSettings3 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (volumeSettings3 == null) return; @@ -242,7 +233,7 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) if (SpawnOffsetSettingsObject == null) return; - var volume3 = SpawnOffsetSettingsObject.GetComponent(); + var volume3 = SpawnOffsetSettingsObject.GetComponent(); ReflectionUtil.CopyComponent(volume3, typeof(IncDecSettingsController), typeof(SpawnOffsetController), SpawnOffsetSettingsObject); Object.DestroyImmediate(volume3); @@ -361,16 +352,16 @@ private void OnSceneChanged(Scene oldScene, Scene newScene) } } - private void ResultsViewController_didActivateEvent(bool firstActivation, VRUI.VRUIViewController.ActivationType activationType) + private void ResultsViewController_didActivateEvent(bool firstActivation, HMUI.ViewController.ActivationType activationType) { if (showFailTextNext && showTimeFailed) { - Console.WriteLine("Creating fail time"); - if (failText == null) - failText = CustomUI.BeatSaber.BeatSaberUI.CreateText(resultsViewController.rectTransform, failTime, new Vector2(15f, -25f)); - else - failText.text = failTime; - failText.richText = true; + // Console.WriteLine("Creating fail time"); + // if (failText == null) + // failText = CustomUI.BeatSaber.BeatSaberUI.CreateText(resultsViewController.rectTransform, failTime, new Vector2(15f, -25f)); + // else + // failText.text = failTime; + // failText.richText = true; } else { @@ -575,5 +566,35 @@ public static void AdjustNjsAndOffset() } + + public void OnSceneUnloaded(Scene scene) + { + } + + public static TextMeshProUGUI CreateText(RectTransform parent, string text, Vector2 anchoredPosition) + { + return CreateText(parent, text, anchoredPosition, new Vector2(60f, 10f)); + } + + public static TextMeshProUGUI CreateText(RectTransform parent, string text, Vector2 anchoredPosition, Vector2 sizeDelta) + { + GameObject gameObj = new GameObject("CustomUIText"); + gameObj.SetActive(false); + + TextMeshProUGUI textMesh = gameObj.AddComponent(); + textMesh.font = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll().First(t => t.name == "Teko-Medium SDF No Glow")); + textMesh.rectTransform.SetParent(parent, false); + textMesh.text = text; + textMesh.fontSize = 4; + textMesh.color = Color.white; + + textMesh.rectTransform.anchorMin = new Vector2(0.5f, 0.5f); + textMesh.rectTransform.anchorMax = new Vector2(0.5f, 0.5f); + textMesh.rectTransform.sizeDelta = sizeDelta; + textMesh.rectTransform.anchoredPosition = anchoredPosition; + + gameObj.SetActive(true); + return textMesh; + } } } \ No newline at end of file diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 9a0dc22..825ec35 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -33,21 +33,21 @@ 4 - - C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll - - - C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BeatSaberCustomUI.dll - C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BS_Utils.dll - + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\HMLib.dll + + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\HMUI.dll + + False - C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionInjector.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IPA.Loader.dll - - C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\MainAssembly.dll False @@ -104,6 +104,9 @@ + + + diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 30a0f7f..3412a45 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.5.2.0")] -[assembly: AssemblyFileVersion("4.5.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.6.0.0")] +[assembly: AssemblyFileVersion("4.6.0.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index b06dc9d..e7fe79b 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -24,8 +24,8 @@ private static List C "_beatmapObjectCallbackData"); _beatmapData = _beatmapObjectCallbackController - .GetPrivateField("_beatmapDataModel").beatmapData; - } + .GetPrivateField("_beatmapData"); + } if (_beatmapObjectSpawnController == null) { diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index c921cfc..6e56cbc 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -75,7 +75,7 @@ public void Init() rectTransform.sizeDelta = SeekCursorSize; _seekCursor.color = SeekCursorColor; - _currentTime = CustomUI.BeatSaber.BeatSaberUI.CreateText(this.GetComponent(), "0:00", new Vector2(-83f, -1f)); + _currentTime = Plugin.CreateText(this.GetComponent(), "0:00", new Vector2(-83f, -1f)); _currentTime.fontSize = 5f; // rectTransform = _currentTime.rectTransform; // rectTransform.anchorMin = Vector2.up * 0.5f; @@ -86,7 +86,7 @@ public void Init() // _currentTime.fontSizeMin = 1; _currentTime.alignment = TextAlignmentOptions.Right; - _timeLength = CustomUI.BeatSaber.BeatSaberUI.CreateText(this.GetComponent(), "0:00", new Vector2(87f, -1f)); + _timeLength = Plugin.CreateText(this.GetComponent(), "0:00", new Vector2(87f, -1f)); _timeLength.fontSize = 5f; _timeLength.alignment = TextAlignmentOptions.Left; diff --git a/PracticePlugin/SpawnOffsetController.cs b/PracticePlugin/SpawnOffsetController.cs index 9924127..6633328 100644 --- a/PracticePlugin/SpawnOffsetController.cs +++ b/PracticePlugin/SpawnOffsetController.cs @@ -8,11 +8,12 @@ public class SpawnOffsetController : ListSettingsController public event Action ValueChangedEvent; private int _indexOffset; - protected override void GetInitValues(out int idx, out int numberOfElements) + protected override bool GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; numberOfElements = 100; - idx = 50 + (int)(10 * UIElementsCreator.currentSpawnOffset); + idx = 50 + (int)(10 * UIElementsCreator.currentSpawnOffset); + return true; } protected override void ApplyValue(int idx) diff --git a/PracticePlugin/SpeedSettingsController.cs b/PracticePlugin/SpeedSettingsController.cs index 2ca856e..ccad4a7 100644 --- a/PracticePlugin/SpeedSettingsController.cs +++ b/PracticePlugin/SpeedSettingsController.cs @@ -9,13 +9,14 @@ public class SpeedSettingsController : ListSettingsController private int _indexOffset; - protected override void GetInitValues(out int idx, out int numberOfElements) + protected override bool GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; // numberOfElements = Mathf.RoundToInt(Plugin.SpeedMaxSize / Plugin.SpeedStepSize) - _indexOffset; numberOfElements = 0; idx = 0; - // idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.SpeedStepSize) - _indexOffset; + // idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.SpeedStepSize) - _indexOffset; + return true; } protected override void ApplyValue(int idx) diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 4679e19..1225331 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -58,8 +58,8 @@ private void OnEnable() var rectTransform = (RectTransform)_speedSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(5, 4); - TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "Speed (UI Disabled Until Fixed)", new Vector2(-30f, -2f)); + rectTransform.anchoredPosition = new Vector2(5, 8); + TextMeshProUGUI settingText = Plugin.CreateText(rectTransform, "Speed (UI Disabled Until Fixed)", new Vector2(-30f, -2f)); settingText.fontSize = 6f; speedController = _speedSettings.GetComponent(); speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; @@ -72,8 +72,8 @@ private void OnEnable() var rectTransform = (RectTransform)_njsSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(5, -4); - TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "NJS", new Vector2(-30f, -2f)); + rectTransform.anchoredPosition = new Vector2(5, 0); + TextMeshProUGUI settingText = Plugin.CreateText(rectTransform, "NJS", new Vector2(-30f, -2f)); settingText.fontSize = 6f; njsController = _njsSettings.GetComponent(); njsController.ValueChangedEvent += NjsController_ValueChangedEvent; @@ -86,8 +86,8 @@ private void OnEnable() var rectTransform = (RectTransform)_offsetSettings.transform; rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(5, -12); - TextMeshProUGUI settingText = CustomUI.BeatSaber.BeatSaberUI.CreateText(rectTransform, "Spawn Offset", new Vector2(-30f, -2f)); + rectTransform.anchoredPosition = new Vector2(5, -8); + TextMeshProUGUI settingText = Plugin.CreateText(rectTransform, "Spawn Offset", new Vector2(-30f, -2f)); settingText.fontSize = 6f; spawnOffsetController = _offsetSettings.GetComponent(); spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json new file mode 100644 index 0000000..b1b9e25 --- /dev/null +++ b/PracticePlugin/manifest.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", + "author": "Kyle1413", + "description": "Adds additional modifiers to the game, see readme for details.", + "gameVersion": "1.6.0", + "id": "PracticePlugin", + "name": "PracticePlugin", + "version": "4.6.0", + "dependsOn": { + "BS Utils": "^1.3.0", + }, + "links": { + "project-source": "https://github.com/Kylemc1413/PracticePlugin", + "donate": "https://ko-fi.com/kyle1413k" + }, + "features": [ + ] +} \ No newline at end of file From 13a03d6619a35b95adbaf22a093ad2e61389010d Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 16 Dec 2019 16:01:47 -0500 Subject: [PATCH 27/64] Update manifest.json --- PracticePlugin/manifest.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index b1b9e25..28143a7 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -1,13 +1,13 @@ { "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", "author": "Kyle1413", - "description": "Adds additional modifiers to the game, see readme for details.", + "description": "Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections.", "gameVersion": "1.6.0", "id": "PracticePlugin", "name": "PracticePlugin", "version": "4.6.0", "dependsOn": { - "BS Utils": "^1.3.0", + "BS Utils": "^1.3.0" }, "links": { "project-source": "https://github.com/Kylemc1413/PracticePlugin", @@ -15,4 +15,4 @@ }, "features": [ ] -} \ No newline at end of file +} From e4330b13451e9a9baa841e0159901ff0f10a2348 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 26 Mar 2020 19:02:08 -0400 Subject: [PATCH 28/64] 1.8.0 --- PracticePlugin/CustomEffectPoolsInstaller.cs | 3 +- PracticePlugin/NjsSettingsController.cs | 9 ++- PracticePlugin/Plugin.cs | 85 ++++++++++++++------ PracticePlugin/PracticePlugin.csproj | 21 +++-- PracticePlugin/Properties/AssemblyInfo.cs | 4 +- PracticePlugin/SongSeekBeatmapHandler.cs | 33 +++++--- PracticePlugin/SpeedSettingsController.cs | 12 +-- PracticePlugin/UIElementsCreator.cs | 20 +++-- PracticePlugin/manifest.json | 8 +- 9 files changed, 132 insertions(+), 63 deletions(-) diff --git a/PracticePlugin/CustomEffectPoolsInstaller.cs b/PracticePlugin/CustomEffectPoolsInstaller.cs index 9eed115..09ebce6 100644 --- a/PracticePlugin/CustomEffectPoolsInstaller.cs +++ b/PracticePlugin/CustomEffectPoolsInstaller.cs @@ -20,10 +20,11 @@ public override void InstallBindings() } } - + /* private CustomNoteCutSoundEffect ReplacePrefab() { return CustomNoteCutSoundEffect.CopyOriginal(_noteCutSoundEffectPrefab); } + */ } } \ No newline at end of file diff --git a/PracticePlugin/NjsSettingsController.cs b/PracticePlugin/NjsSettingsController.cs index 88b35ee..7d4cd24 100644 --- a/PracticePlugin/NjsSettingsController.cs +++ b/PracticePlugin/NjsSettingsController.cs @@ -26,10 +26,15 @@ protected override string TextForValue(int idx) { ValueChangedEvent(idx); } + string result; + if (idx == UIElementsCreator.defaultNJS) - return $"{idx}"; + result = $"{idx}"; else - return idx.ToString(); + result = idx.ToString(); + if(Plugin.adjustNJSWithSpeed && UIElementsCreator._newTimeScale != 1f) + result += $"({(idx * (1f / UIElementsCreator._newTimeScale)).ToString("F2")})"; + return result; } } } \ No newline at end of file diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index aa5471d..0a2188c 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -13,7 +13,8 @@ using IPA; namespace PracticePlugin { - public class Plugin : IBeatSaberPlugin + [Plugin(RuntimeOptions.SingleStartInit)] + public class Plugin { public const float SpeedMaxSize = 5.05f; @@ -32,12 +33,35 @@ public class Plugin : IBeatSaberPlugin public static GameObject NjsSettingsObject { get; private set; } public static GameObject SpawnOffsetSettingsObject { get; private set; } internal static bool startWithFullEnergy = false; + internal static bool disablePitchCorrection = false; + internal static bool adjustNJSWithSpeed = false; public static float TimeScale { get { return _timeScale; } private set { _timeScale = value; + if (!AudioTimeSync) return; + AudioTimeSyncController.InitData initData = AudioTimeSync.GetPrivateField("_initData"); + AudioTimeSyncController.InitData newInitData = new AudioTimeSyncController.InitData(initData.audioClip, + AudioTimeSync.songTime, initData.songTimeOffset, _timeScale); + AudioTimeSync.SetPrivateField("_initData", newInitData); + //Chipmunk Removal as per base game + if(!disablePitchCorrection) + { + if (_timeScale == 1f) + _mixer.musicPitch = 1; + else + _mixer.musicPitch = 1f / _timeScale; + } + else + { + _mixer.musicPitch = 1f; + } + + AudioTimeSync.StartSong(); + + return; // AudioTimeSync.SetPrivateField("_timeScale", value); // AudioTimeSync.Init(_songAudio.clip, _songAudio.time, AudioTimeSync.GetPrivateField("_songTimeOffset"), value); @@ -47,7 +71,6 @@ private set _mixer.musicPitch = 1f / _timeScale; if (!IsEqualToOne(_timeScale)) { - HasTimeScaleChanged = true; if (AudioTimeSync != null) { @@ -90,8 +113,6 @@ private set public static bool PracticeMode { get; private set; } - public static bool HasTimeScaleChanged { get; private set; } - public static bool PlayingNewSong { get; private set; } private static bool _init; @@ -108,6 +129,7 @@ private set private static bool _resetNoFail; private static bool showTimeFailed = true; private static TextMeshProUGUI failText; + [OnStart] public void OnApplicationStart() { if (_init) return; @@ -115,6 +137,10 @@ public void OnApplicationStart() // NoFailGameEnergy.limitLevelFail = Config.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); startWithFullEnergy = Config.GetBool("PracticePlugin", "startWithFullEnergy", false, true); showTimeFailed = Config.GetBool("PracticePlugin", "Show Time Failed", true, true); + disablePitchCorrection = Config.GetBool("PracticePlugin", "Disable Pitch Correction", false, true); + adjustNJSWithSpeed = Config.GetBool("PracticePlugin", "Adjust NJS With Speed", false, true); + SceneManager.activeSceneChanged += OnActiveSceneChanged; + SceneManager.sceneLoaded += OnSceneLoaded; } public void OnSceneLoaded(Scene arg0, LoadSceneMode arg1) @@ -312,7 +338,6 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) !string.IsNullOrEmpty(_lastLevelId)) { PlayingNewSong = true; - HasTimeScaleChanged = false; TimeScale = 1; _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; } @@ -321,10 +346,6 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) PlayingNewSong = false; } - if (IsEqualToOne(TimeScale)) - { - HasTimeScaleChanged = false; - } _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; _gameCoreSceneSetup = Resources.FindObjectsOfTypeAll().FirstOrDefault(); @@ -332,13 +353,12 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); PracticeMode = (_levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); - //Check if Multiplayer is active, disable accordingly if (!PracticeMode) { - TimeScale = Mathf.Clamp(TimeScale, 1, SpeedMaxSize); + _timeScale = Mathf.Clamp(TimeScale, 1, SpeedMaxSize); } if (PracticeMode) { @@ -356,12 +376,11 @@ private void ResultsViewController_didActivateEvent(bool firstActivation, HMUI.V { if (showFailTextNext && showTimeFailed) { - // Console.WriteLine("Creating fail time"); - // if (failText == null) - // failText = CustomUI.BeatSaber.BeatSaberUI.CreateText(resultsViewController.rectTransform, failTime, new Vector2(15f, -25f)); - // else - // failText.text = failTime; - // failText.richText = true; + if (failText == null) + failText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(resultsViewController.rectTransform, failTime, new Vector2(15f, -25f)); + else + failText.text = failTime; + failText.richText = true; } else { @@ -439,10 +458,6 @@ private void MainGameSceneSetupDataOnDidFinishEvent(StandardLevelScenesTransitio private void UIElementsCreatorOnValueChangedEvent(float timeScale) { - if (!IsEqualToOne(timeScale)) - { - HasTimeScaleChanged = true; - } TimeScale = timeScale; } @@ -506,7 +521,7 @@ public static void AdjustNJS(float njs) } public static void AdjustSpawnOffset(float offset) { - float njs = _spawnController.GetPrivateField("_noteJumpMovementSpeed"); + float njs = _spawnController.GetPrivateField("_initData").noteJumpMovementSpeed; float halfJumpDur = 4f; float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); float noteJumpStartBeatOffset = offset; @@ -561,12 +576,36 @@ public static void AdjustNjsAndOffset() _spawnController.SetPrivateField("_halfJumpDurationInBeats", halfJumpDur); _spawnController.SetPrivateField("_spawnAheadTime", spawnAheadTime); _spawnController.SetPrivateField("_jumpDistance", jumpDis); - _spawnController.SetPrivateField("_noteJumpMovementSpeed", njs); + // _spawnController.SetPrivateField("_noteJumpMovementSpeed", njs); _spawnController.SetPrivateField("_moveDistance", moveDis); } + public static void UpdateSpawnMovementData(float njs, float noteJumpStartBeatOffset) + { + BeatmapObjectSpawnMovementData spawnMovementData = + _spawnController.GetPrivateField("_beatmapObjectSpawnMovementData"); + + float bpm = _spawnController.GetPrivateField("_variableBPMProcessor").currentBPM; + + + if (adjustNJSWithSpeed) + { + float newNJS = njs * (1 / TimeScale); + njs = newNJS; + } + + + + spawnMovementData.SetPrivateField("_startNoteJumpMovementSpeed", njs); + spawnMovementData.SetPrivateField("_noteJumpStartBeatOffset", noteJumpStartBeatOffset); + + spawnMovementData.Update(bpm, + _spawnController.GetPrivateField("_jumpOffsetY")); + + + } public void OnSceneUnloaded(Scene scene) { } diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 825ec35..3730459 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -9,7 +9,7 @@ Properties PracticePlugin PracticePlugin - v4.6.1 + v4.7.2 512 @@ -33,9 +33,15 @@ 4 + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BSML.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BS_Utils.dll + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Colors.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\HMLib.dll @@ -46,12 +52,14 @@ False C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IPA.Loader.dll - - C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\MainAssembly.dll + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Main.dll - - False - C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Polyglot.Scripts.dll + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\MediaLoader.dll + + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Polyglot.dll @@ -89,7 +97,6 @@ - diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 3412a45..acb4db9 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.6.0.0")] -[assembly: AssemblyFileVersion("4.6.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.0.0")] +[assembly: AssemblyFileVersion("4.8.0.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index e7fe79b..ee57026 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -31,16 +31,22 @@ private static List C { _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll() .FirstOrDefault(); - if (_beatmapObjectSpawnController != null) - { - _noteAPool = _beatmapObjectSpawnController.GetPrivateField("_noteAPool"); - _noteBPool = _beatmapObjectSpawnController.GetPrivateField("_noteBPool"); - _bombNotePool = _beatmapObjectSpawnController.GetPrivateField("_bombNotePool"); - _obstaclePool = - _beatmapObjectSpawnController.GetPrivateField("_obstaclePool"); - } + } + if(_beatmapObjectManager == null) + { + _beatmapObjectManager = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + + if (_beatmapObjectManager != null) + { + _noteAPool = _beatmapObjectManager.GetPrivateField("_noteAPool"); + _noteBPool = _beatmapObjectManager.GetPrivateField("_noteBPool"); + _bombNotePool = _beatmapObjectManager.GetPrivateField("_bombNotePool"); + _obstaclePool = + _beatmapObjectManager.GetPrivateField("_obstaclePool"); + } + } if (_noteCutSoundEffectManager == null) { _noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll() @@ -55,6 +61,7 @@ private static List C private static List _callbackList; private static BeatmapObjectCallbackController _beatmapObjectCallbackController; private static BeatmapObjectSpawnController _beatmapObjectSpawnController; + private static BeatmapObjectManager _beatmapObjectManager; private static NoteCutSoundEffectManager _noteCutSoundEffectManager; private static NoteController.Pool _noteAPool; @@ -102,26 +109,26 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) var notesA = _noteAPool.activeItems.ToList(); foreach (var noteA in notesA) { - // Console.WriteLine("Despawning, Length: " + notesA.Count); - _beatmapObjectSpawnController.Despawn(noteA); + // Console.WriteLine("Despawning, Length: " + notesA.Count); + _beatmapObjectManager.Despawn(noteA); } var notesB = _noteBPool.activeItems.ToList(); foreach (var noteB in notesB) { - _beatmapObjectSpawnController.Despawn(noteB); + _beatmapObjectManager.Despawn(noteB); } var bombs = _bombNotePool.activeItems.ToList(); foreach (var bomb in bombs) { - _beatmapObjectSpawnController.Despawn(bomb); + _beatmapObjectManager.Despawn(bomb); } var obstacles = _obstaclePool.activeItems.ToList(); foreach (var obstacle in obstacles) { - _beatmapObjectSpawnController.Despawn(obstacle); + _beatmapObjectManager.Despawn(obstacle); } diff --git a/PracticePlugin/SpeedSettingsController.cs b/PracticePlugin/SpeedSettingsController.cs index ccad4a7..04ae407 100644 --- a/PracticePlugin/SpeedSettingsController.cs +++ b/PracticePlugin/SpeedSettingsController.cs @@ -12,10 +12,10 @@ public class SpeedSettingsController : ListSettingsController protected override bool GetInitValues(out int idx, out int numberOfElements) { _indexOffset = Plugin.PracticeMode ? 1 : 20; - // numberOfElements = Mathf.RoundToInt(Plugin.SpeedMaxSize / Plugin.SpeedStepSize) - _indexOffset; - numberOfElements = 0; - idx = 0; - // idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.SpeedStepSize) - _indexOffset; + numberOfElements = Mathf.RoundToInt(Plugin.SpeedMaxSize / Plugin.SpeedStepSize) - _indexOffset; + //numberOfElements = 0; + //idx = 0; + idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.SpeedStepSize) - _indexOffset; return true; } @@ -29,8 +29,8 @@ protected override string TextForValue(int idx) { ValueChangedEvent(Plugin.SpeedStepSize * (idx + _indexOffset)); } - return ""; - // return Plugin.SpeedStepSize * 100f * (idx + _indexOffset) + "%"; + // return ""; + return Plugin.SpeedStepSize * 100f * (idx + _indexOffset) + "%"; } } } \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 1225331..9f810a4 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -19,7 +19,7 @@ public class UIElementsCreator : MonoBehaviour internal NjsSettingsController njsController; internal SpawnOffsetController spawnOffsetController; private TMP_Text _leaderboardText; - private float _newTimeScale = 1; + internal static float _newTimeScale { get; private set; } = 1f; public void Init() { @@ -37,7 +37,7 @@ private void InitDelayed() SongSeeker.Init(); new GameObject("No Fail Game Energy").AddComponent(); - defaultNJS = Plugin._spawnController.GetPrivateField("_noteJumpMovementSpeed"); + defaultNJS = Plugin._spawnController.GetPrivateField("_initData").noteJumpMovementSpeed; currentNJS = defaultNJS; // Console.WriteLine("NJS: " + UIElementsCreator.defaultNJS); defaultOffset = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; @@ -59,7 +59,7 @@ private void OnEnable() rectTransform.anchorMin = Vector2.right * 0.5f; rectTransform.anchorMax = Vector2.right * 0.5f; rectTransform.anchoredPosition = new Vector2(5, 8); - TextMeshProUGUI settingText = Plugin.CreateText(rectTransform, "Speed (UI Disabled Until Fixed)", new Vector2(-30f, -2f)); + TextMeshProUGUI settingText = Plugin.CreateText(rectTransform, "Speed (Use at own risk!)", new Vector2(-30f, -2f)); settingText.fontSize = 6f; speedController = _speedSettings.GetComponent(); speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; @@ -92,7 +92,9 @@ private void OnEnable() spawnOffsetController = _offsetSettings.GetComponent(); spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; } - + _newTimeScale = Plugin.TimeScale; + njsController.Refresh(true); + spawnOffsetController.Refresh(true); @@ -102,14 +104,16 @@ private void OnEnable() private void SpawnOffsetController_ValueChangedEvent(float offset) { currentSpawnOffset = offset; - Plugin.AdjustNjsAndOffset(); + // Plugin.AdjustNjsAndOffset(); + Plugin.UpdateSpawnMovementData(currentNJS, currentSpawnOffset); SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } private void NjsController_ValueChangedEvent(float njs) { currentNJS = njs; - Plugin.AdjustNjsAndOffset(); + // Plugin.AdjustNjsAndOffset(); + Plugin.UpdateSpawnMovementData(currentNJS, currentSpawnOffset); SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } @@ -119,11 +123,15 @@ private void OnDisable() { ValueChangedEvent(_newTimeScale); } + Plugin.UpdateSpawnMovementData(UIElementsCreator.currentNJS, UIElementsCreator.currentSpawnOffset); Destroy(_speedSettings); } private void SpeedControllerOnValueChangedEvent(float timeScale) { + _newTimeScale = timeScale; + njsController.Refresh(true); + spawnOffsetController.Refresh(true); /* _newTimeScale = timeScale; if (Math.Abs(_newTimeScale - 1) > 0.0000000001f) diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 28143a7..8447fc1 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -2,12 +2,14 @@ "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", "author": "Kyle1413", "description": "Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections.", - "gameVersion": "1.6.0", + "gameVersion": "1.8.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.6.0", + "version": "4.8.0", "dependsOn": { - "BS Utils": "^1.3.0" + "BS Utils": "^1.3.0", + "BeatSaberMarkupLanguage": "^1.1.0" + }, "links": { "project-source": "https://github.com/Kylemc1413/PracticePlugin", From 1046ba30089e99a0bb8c3c37631b790d9e97cd33 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sun, 12 Apr 2020 19:44:39 -0400 Subject: [PATCH 29/64] . --- PracticePlugin/Plugin.cs | 9 +++++---- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/manifest.json | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 0a2188c..da59404 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -338,7 +338,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) !string.IsNullOrEmpty(_lastLevelId)) { PlayingNewSong = true; - TimeScale = 1; + // TimeScale = 1; _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; } else @@ -352,8 +352,8 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); - PracticeMode = (_levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); - + PracticeMode = (_levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel + && Resources.FindObjectsOfTypeAll().FirstOrDefault() == null); if (!PracticeMode) @@ -406,7 +406,8 @@ public System.Collections.IEnumerator DelayedSetup() _uiElementsCreator = canvas.gameObject.AddComponent(); _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; _uiElementsCreator.Init(); - TimeScale = TimeScale; + + // TimeScale = TimeScale; var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); // bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f); diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index acb4db9..e301177 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.0.0")] -[assembly: AssemblyFileVersion("4.8.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.2.0")] +[assembly: AssemblyFileVersion("4.8.2.0")] \ No newline at end of file diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 8447fc1..0118a80 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.8.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.0", + "version": "4.8.2", "dependsOn": { "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From b527b0bb040e132e6da9521e489d0ce0ac7c7381 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 20 Apr 2020 11:41:15 -0400 Subject: [PATCH 30/64] Modification-proofing --- PracticePlugin/Plugin.cs | 9 ++++++-- PracticePlugin/PracticePlugin.csproj | 1 - PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/SongSeekBeatmapHandler.cs | 27 ++++++++++++++--------- PracticePlugin/manifest.json | 2 +- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index da59404..50c5f6d 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -274,6 +274,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) } else if (newScene.name == GameSceneName) { + /* CustomEffectPoolsInstaller customEffectPoolsInstaller = null; var effectPoolsInstaller = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (effectPoolsInstaller != null) @@ -281,12 +282,14 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) customEffectPoolsInstaller = (CustomEffectPoolsInstaller)ReflectionUtil.CopyComponent(effectPoolsInstaller, typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject); } - + + Console.WriteLine("Custom effect Pool Installer Made"); + */ SceneContext sceneContext = null; SceneDecoratorContext sceneDecoratorContext = null; try { - Console.WriteLine("Custom effect Pool Installer Made"); + foreach (var gameObject in newScene.GetRootGameObjects()) { if (sceneContext == null) @@ -306,12 +309,14 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) if (sceneContext != null && sceneDecoratorContext != null) { + /* var prop = typeof(Context).GetField("_monoInstallers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); var installersList = (List)prop.GetValue(sceneDecoratorContext); installersList.Remove(effectPoolsInstaller); Object.DestroyImmediate(effectPoolsInstaller); installersList.Add(customEffectPoolsInstaller); Console.WriteLine("Custom effect Pool Installer Added"); + */ } } catch (Exception ex) diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 3730459..fddfb27 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -96,7 +96,6 @@ - diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index e301177..2820630 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.2.0")] -[assembly: AssemblyFileVersion("4.8.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.3.0")] +[assembly: AssemblyFileVersion("4.8.3.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index ee57026..a40cf68 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -22,9 +22,7 @@ private static List C _beatmapObjectCallbackController .GetPrivateField>( "_beatmapObjectCallbackData"); - - _beatmapData = _beatmapObjectCallbackController - .GetPrivateField("_beatmapData"); + } if (_beatmapObjectSpawnController == null) @@ -69,18 +67,27 @@ private static List C private static NoteController.Pool _bombNotePool; private static ObstacleController.Pool _obstaclePool; - private static BeatmapData _beatmapData; + private static BeatmapData _beatmapData + { + get + { + return _beatmapObjectCallbackController + .GetPrivateField("_beatmapData"); + } + } public static void OnSongTimeChanged(float newSongTime, float aheadTime) { - foreach (var callbackData in CallbackList) + BeatmapData beatmap = _beatmapData; + + foreach (var callbackData in CallbackList) { - for (var i = 0; i < _beatmapData.beatmapLinesData.Length; i++) + for (var i = 0; i < beatmap.beatmapLinesData.Length; i++) { callbackData.nextObjectIndexInLine[i] = 0; - while (callbackData.nextObjectIndexInLine[i] < _beatmapData.beatmapLinesData[i].beatmapObjectsData.Length) + while (callbackData.nextObjectIndexInLine[i] < beatmap.beatmapLinesData[i].beatmapObjectsData.Length) { - var beatmapObjectData = _beatmapData.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]]; + var beatmapObjectData = beatmap.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]]; if (beatmapObjectData.time - aheadTime >= newSongTime) { break; @@ -93,9 +100,9 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) var newNextEventIndex = 0; - while (newNextEventIndex < _beatmapData.beatmapEventData.Length) + while (newNextEventIndex < beatmap.beatmapEventData.Length) { - var beatmapEventData = _beatmapData.beatmapEventData[newNextEventIndex]; + var beatmapEventData = beatmap.beatmapEventData[newNextEventIndex]; if (beatmapEventData.time >= newSongTime) { break; diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 0118a80..10a0f64 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.8.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.2", + "version": "4.8.3", "dependsOn": { "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From b095cc194a9dd04e9065a295553a38c9ced2271b Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 20 Apr 2020 12:58:57 -0400 Subject: [PATCH 31/64] Null Check --- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/SongSeekBeatmapHandler.cs | 2 ++ PracticePlugin/manifest.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 2820630..33b05f5 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.3.0")] -[assembly: AssemblyFileVersion("4.8.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.4.0")] +[assembly: AssemblyFileVersion("4.8.4.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index a40cf68..3012ced 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -71,6 +71,8 @@ private static BeatmapData _beatmapData { get { + if (_beatmapObjectCallbackController == null) + _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); return _beatmapObjectCallbackController .GetPrivateField("_beatmapData"); } diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 10a0f64..3b85214 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.8.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.3", + "version": "4.8.4", "dependsOn": { "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From 3fcddcb98ad4ba2a3e2135611fb61659cdd1590f Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 20 Apr 2020 17:34:52 -0400 Subject: [PATCH 32/64] Revert "Null Check" This reverts commit b095cc194a9dd04e9065a295553a38c9ced2271b. --- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/SongSeekBeatmapHandler.cs | 2 -- PracticePlugin/manifest.json | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 33b05f5..2820630 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.4.0")] -[assembly: AssemblyFileVersion("4.8.4.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.3.0")] +[assembly: AssemblyFileVersion("4.8.3.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index 3012ced..a40cf68 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -71,8 +71,6 @@ private static BeatmapData _beatmapData { get { - if (_beatmapObjectCallbackController == null) - _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); return _beatmapObjectCallbackController .GetPrivateField("_beatmapData"); } diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 3b85214..10a0f64 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.8.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.4", + "version": "4.8.3", "dependsOn": { "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From 4b7611f1f014973cdcc611075d2c637e319daddf Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 20 Apr 2020 17:34:58 -0400 Subject: [PATCH 33/64] Revert "Modification-proofing" This reverts commit b527b0bb040e132e6da9521e489d0ce0ac7c7381. --- PracticePlugin/Plugin.cs | 9 ++------ PracticePlugin/PracticePlugin.csproj | 1 + PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/SongSeekBeatmapHandler.cs | 27 +++++++++-------------- PracticePlugin/manifest.json | 2 +- 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 50c5f6d..da59404 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -274,7 +274,6 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) } else if (newScene.name == GameSceneName) { - /* CustomEffectPoolsInstaller customEffectPoolsInstaller = null; var effectPoolsInstaller = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (effectPoolsInstaller != null) @@ -282,14 +281,12 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) customEffectPoolsInstaller = (CustomEffectPoolsInstaller)ReflectionUtil.CopyComponent(effectPoolsInstaller, typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject); } - - Console.WriteLine("Custom effect Pool Installer Made"); - */ + SceneContext sceneContext = null; SceneDecoratorContext sceneDecoratorContext = null; try { - + Console.WriteLine("Custom effect Pool Installer Made"); foreach (var gameObject in newScene.GetRootGameObjects()) { if (sceneContext == null) @@ -309,14 +306,12 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) if (sceneContext != null && sceneDecoratorContext != null) { - /* var prop = typeof(Context).GetField("_monoInstallers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); var installersList = (List)prop.GetValue(sceneDecoratorContext); installersList.Remove(effectPoolsInstaller); Object.DestroyImmediate(effectPoolsInstaller); installersList.Add(customEffectPoolsInstaller); Console.WriteLine("Custom effect Pool Installer Added"); - */ } } catch (Exception ex) diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index fddfb27..3730459 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -96,6 +96,7 @@ + diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 2820630..e301177 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.3.0")] -[assembly: AssemblyFileVersion("4.8.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.2.0")] +[assembly: AssemblyFileVersion("4.8.2.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index a40cf68..ee57026 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -22,7 +22,9 @@ private static List C _beatmapObjectCallbackController .GetPrivateField>( "_beatmapObjectCallbackData"); - + + _beatmapData = _beatmapObjectCallbackController + .GetPrivateField("_beatmapData"); } if (_beatmapObjectSpawnController == null) @@ -67,27 +69,18 @@ private static List C private static NoteController.Pool _bombNotePool; private static ObstacleController.Pool _obstaclePool; - private static BeatmapData _beatmapData - { - get - { - return _beatmapObjectCallbackController - .GetPrivateField("_beatmapData"); - } - } + private static BeatmapData _beatmapData; public static void OnSongTimeChanged(float newSongTime, float aheadTime) { - BeatmapData beatmap = _beatmapData; - - foreach (var callbackData in CallbackList) + foreach (var callbackData in CallbackList) { - for (var i = 0; i < beatmap.beatmapLinesData.Length; i++) + for (var i = 0; i < _beatmapData.beatmapLinesData.Length; i++) { callbackData.nextObjectIndexInLine[i] = 0; - while (callbackData.nextObjectIndexInLine[i] < beatmap.beatmapLinesData[i].beatmapObjectsData.Length) + while (callbackData.nextObjectIndexInLine[i] < _beatmapData.beatmapLinesData[i].beatmapObjectsData.Length) { - var beatmapObjectData = beatmap.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]]; + var beatmapObjectData = _beatmapData.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]]; if (beatmapObjectData.time - aheadTime >= newSongTime) { break; @@ -100,9 +93,9 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) var newNextEventIndex = 0; - while (newNextEventIndex < beatmap.beatmapEventData.Length) + while (newNextEventIndex < _beatmapData.beatmapEventData.Length) { - var beatmapEventData = beatmap.beatmapEventData[newNextEventIndex]; + var beatmapEventData = _beatmapData.beatmapEventData[newNextEventIndex]; if (beatmapEventData.time >= newSongTime) { break; diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 10a0f64..0118a80 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.8.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.3", + "version": "4.8.2", "dependsOn": { "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From 9bda80b326be9ce3ed363270b6401f7266e747ef Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 20 Apr 2020 17:41:30 -0400 Subject: [PATCH 34/64] Weird Solutions to weird problems --- PracticePlugin/SongSeekBeatmapHandler.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index ee57026..518e2c1 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -73,6 +73,8 @@ private static List C public static void OnSongTimeChanged(float newSongTime, float aheadTime) { + if(_beatmapObjectCallbackController) + _beatmapData = _beatmapObjectCallbackController.GetPrivateField("_beatmapData"); foreach (var callbackData in CallbackList) { for (var i = 0; i < _beatmapData.beatmapLinesData.Length; i++) From 1f51febe3261265a41273ee9ff5f4ff60e19b51f Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 20 Apr 2020 17:41:42 -0400 Subject: [PATCH 35/64] formatting --- PracticePlugin/SongSeekBeatmapHandler.cs | 222 +++++++++++------------ 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index 518e2c1..d85520a 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -5,36 +5,36 @@ namespace PracticePlugin { - public static class SongSeekBeatmapHandler - { - private static List CallbackList - { - get - { - if (_beatmapObjectCallbackController == null || _callbackList == null) - { - _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll() - .FirstOrDefault(); - - if (_beatmapObjectCallbackController != null) - { - _callbackList = - _beatmapObjectCallbackController - .GetPrivateField>( + public static class SongSeekBeatmapHandler + { + private static List CallbackList + { + get + { + if (_beatmapObjectCallbackController == null || _callbackList == null) + { + _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll() + .FirstOrDefault(); + + if (_beatmapObjectCallbackController != null) + { + _callbackList = + _beatmapObjectCallbackController + .GetPrivateField>( "_beatmapObjectCallbackData"); - - _beatmapData = _beatmapObjectCallbackController - .GetPrivateField("_beatmapData"); + + _beatmapData = _beatmapObjectCallbackController + .GetPrivateField("_beatmapData"); } - if (_beatmapObjectSpawnController == null) - { - _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll() - .FirstOrDefault(); + if (_beatmapObjectSpawnController == null) + { + _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll() + .FirstOrDefault(); - } + } - if(_beatmapObjectManager == null) + if (_beatmapObjectManager == null) { _beatmapObjectManager = Resources.FindObjectsOfTypeAll().FirstOrDefault(); @@ -47,97 +47,97 @@ private static List C _beatmapObjectManager.GetPrivateField("_obstaclePool"); } } - if (_noteCutSoundEffectManager == null) - { - _noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll() - .FirstOrDefault(); - } - } - - return _callbackList; - } - } - - private static List _callbackList; - private static BeatmapObjectCallbackController _beatmapObjectCallbackController; - private static BeatmapObjectSpawnController _beatmapObjectSpawnController; + if (_noteCutSoundEffectManager == null) + { + _noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll() + .FirstOrDefault(); + } + } + + return _callbackList; + } + } + + private static List _callbackList; + private static BeatmapObjectCallbackController _beatmapObjectCallbackController; + private static BeatmapObjectSpawnController _beatmapObjectSpawnController; private static BeatmapObjectManager _beatmapObjectManager; - private static NoteCutSoundEffectManager _noteCutSoundEffectManager; - - private static NoteController.Pool _noteAPool; - private static NoteController.Pool _noteBPool; - private static NoteController.Pool _bombNotePool; - private static ObstacleController.Pool _obstaclePool; - - private static BeatmapData _beatmapData; - - public static void OnSongTimeChanged(float newSongTime, float aheadTime) - { - if(_beatmapObjectCallbackController) - _beatmapData = _beatmapObjectCallbackController.GetPrivateField("_beatmapData"); - foreach (var callbackData in CallbackList) - { - for (var i = 0; i < _beatmapData.beatmapLinesData.Length; i++) - { - callbackData.nextObjectIndexInLine[i] = 0; - while (callbackData.nextObjectIndexInLine[i] < _beatmapData.beatmapLinesData[i].beatmapObjectsData.Length) - { - var beatmapObjectData = _beatmapData.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]]; - if (beatmapObjectData.time - aheadTime >= newSongTime) - { - break; - } - - callbackData.nextObjectIndexInLine[i]++; - } - } - } - - var newNextEventIndex = 0; - - while (newNextEventIndex < _beatmapData.beatmapEventData.Length) - { - var beatmapEventData = _beatmapData.beatmapEventData[newNextEventIndex]; - if (beatmapEventData.time >= newSongTime) - { - break; - } - - newNextEventIndex++; - } - - _beatmapObjectCallbackController.SetPrivateField("_nextEventIndex", newNextEventIndex); - - var notesA = _noteAPool.activeItems.ToList(); - foreach (var noteA in notesA) - { + private static NoteCutSoundEffectManager _noteCutSoundEffectManager; + + private static NoteController.Pool _noteAPool; + private static NoteController.Pool _noteBPool; + private static NoteController.Pool _bombNotePool; + private static ObstacleController.Pool _obstaclePool; + + private static BeatmapData _beatmapData; + + public static void OnSongTimeChanged(float newSongTime, float aheadTime) + { + if (_beatmapObjectCallbackController) + _beatmapData = _beatmapObjectCallbackController.GetPrivateField("_beatmapData"); + foreach (var callbackData in CallbackList) + { + for (var i = 0; i < _beatmapData.beatmapLinesData.Length; i++) + { + callbackData.nextObjectIndexInLine[i] = 0; + while (callbackData.nextObjectIndexInLine[i] < _beatmapData.beatmapLinesData[i].beatmapObjectsData.Length) + { + var beatmapObjectData = _beatmapData.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]]; + if (beatmapObjectData.time - aheadTime >= newSongTime) + { + break; + } + + callbackData.nextObjectIndexInLine[i]++; + } + } + } + + var newNextEventIndex = 0; + + while (newNextEventIndex < _beatmapData.beatmapEventData.Length) + { + var beatmapEventData = _beatmapData.beatmapEventData[newNextEventIndex]; + if (beatmapEventData.time >= newSongTime) + { + break; + } + + newNextEventIndex++; + } + + _beatmapObjectCallbackController.SetPrivateField("_nextEventIndex", newNextEventIndex); + + var notesA = _noteAPool.activeItems.ToList(); + foreach (var noteA in notesA) + { // Console.WriteLine("Despawning, Length: " + notesA.Count); _beatmapObjectManager.Despawn(noteA); - } - - var notesB = _noteBPool.activeItems.ToList(); - foreach (var noteB in notesB) - { + } + + var notesB = _noteBPool.activeItems.ToList(); + foreach (var noteB in notesB) + { _beatmapObjectManager.Despawn(noteB); - } - - var bombs = _bombNotePool.activeItems.ToList(); - foreach (var bomb in bombs) - { + } + + var bombs = _bombNotePool.activeItems.ToList(); + foreach (var bomb in bombs) + { _beatmapObjectManager.Despawn(bomb); - } - - var obstacles = _obstaclePool.activeItems.ToList(); - foreach (var obstacle in obstacles) - { + } + + var obstacles = _obstaclePool.activeItems.ToList(); + foreach (var obstacle in obstacles) + { _beatmapObjectManager.Despawn(obstacle); - } - - - Plugin.AudioTimeSync.SetPrivateField("_prevAudioSamplePos", -1); + } + + + Plugin.AudioTimeSync.SetPrivateField("_prevAudioSamplePos", -1); Plugin.AudioTimeSync.SetPrivateField("_songTime", newSongTime); - _noteCutSoundEffectManager.SetPrivateField("_prevNoteATime", -1); - _noteCutSoundEffectManager.SetPrivateField("_prevNoteBTime", -1); - } - } + _noteCutSoundEffectManager.SetPrivateField("_prevNoteATime", -1); + _noteCutSoundEffectManager.SetPrivateField("_prevNoteBTime", -1); + } + } } \ No newline at end of file From 939f05dbc7c2478800857f2261c025631ccf73bc Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 20 Apr 2020 17:42:09 -0400 Subject: [PATCH 36/64] Version --- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index e301177..2f4ff59 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.2.0")] -[assembly: AssemblyFileVersion("4.8.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.5.0")] +[assembly: AssemblyFileVersion("4.8.5.0")] \ No newline at end of file diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 0118a80..c0ecbc1 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.8.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.2", + "version": "4.8.5", "dependsOn": { "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From f1a03017224f3177364933ad917e05af6a85a4f8 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sun, 26 Apr 2020 20:03:53 -0400 Subject: [PATCH 37/64] Fix looping --- PracticePlugin/Behavior.cs | 18 ++++++++++++++++++ PracticePlugin/Plugin.cs | 10 +++------- PracticePlugin/PracticePlugin.csproj | 1 + PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/manifest.json | 2 +- 5 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 PracticePlugin/Behavior.cs diff --git a/PracticePlugin/Behavior.cs b/PracticePlugin/Behavior.cs new file mode 100644 index 0000000..ffb4254 --- /dev/null +++ b/PracticePlugin/Behavior.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +namespace PracticePlugin +{ + public class Behavior : MonoBehaviour + { + + void Update() + { + if (Plugin._uiElementsCreator == null || Plugin._uiElementsCreator.SongSeeker == null) return; + Plugin._uiElementsCreator.SongSeeker.OnUpdate(); + } + } +} diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index da59404..e23553b 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -124,7 +124,7 @@ private set private static AudioSource _songAudio; private static GameplayCoreSceneSetup _gameCoreSceneSetup; private static string _lastLevelId; - private static UIElementsCreator _uiElementsCreator; + public static UIElementsCreator _uiElementsCreator; private static ResultsViewController resultsViewController; private static bool _resetNoFail; private static bool showTimeFailed = true; @@ -367,6 +367,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) else _timeScale = _levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; SharedCoroutineStarter.instance.StartCoroutine(DelayedSetup()); + } } @@ -414,7 +415,7 @@ public System.Collections.IEnumerator DelayedSetup() bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); var pauseMenu = GameObject.Find("PauseMenu"); pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); - + new GameObject("Practice Plugin Behavior").AddComponent(); if (startWithFullEnergy) { GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll().FirstOrDefault(); @@ -478,11 +479,6 @@ public void OnLevelWasInitialized(int level) } - public void OnUpdate() - { - if (_uiElementsCreator == null || _uiElementsCreator.SongSeeker == null) return; - _uiElementsCreator.SongSeeker.OnUpdate(); - } public void OnFixedUpdate() { diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 3730459..8e7be9a 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -96,6 +96,7 @@ + diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 2f4ff59..2447311 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.5.0")] -[assembly: AssemblyFileVersion("4.8.5.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.6.0")] +[assembly: AssemblyFileVersion("4.8.6.0")] \ No newline at end of file diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index c0ecbc1..c4ec5af 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.8.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.5", + "version": "4.8.6", "dependsOn": { "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From 7be5cdbf19e0a4166971547e95f3408097fceaec Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 17 Aug 2020 09:42:23 -0400 Subject: [PATCH 38/64] 1.11.0 --- PracticePlugin/CustomEffectPoolsInstaller.cs | 21 ++++++++++---------- PracticePlugin/Plugin.cs | 2 ++ PracticePlugin/manifest.json | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/PracticePlugin/CustomEffectPoolsInstaller.cs b/PracticePlugin/CustomEffectPoolsInstaller.cs index 09ebce6..d8a67cb 100644 --- a/PracticePlugin/CustomEffectPoolsInstaller.cs +++ b/PracticePlugin/CustomEffectPoolsInstaller.cs @@ -1,19 +1,20 @@ -namespace PracticePlugin +using Zenject; +namespace PracticePlugin { public class CustomEffectPoolsInstaller : EffectPoolsInstaller { - public override void InstallBindings() + public override void ManualInstallBindings(DiContainer container, bool shortBeatEffect) { try { - Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingTextEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingScoreEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_flyingSpriteEffectPrefab); - Container.BindMemoryPool().WithInitialSize(40).FromComponentInNewPrefab(_noteDebrisHDConditionVariable ? _noteDebrisHDPrefab : _noteDebrisLWPrefab); - Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_beatEffectPrefab); - Container.BindMemoryPool().WithInitialSize(16).FromComponentInNewPrefab(_noteCutSoundEffectPrefab); - Container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(_bombCutSoundEffectPrefab); - } + container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(this._flyingTextEffectPrefab); + container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(this._flyingScoreEffectPrefab); + container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(this._flyingSpriteEffectPrefab); + container.BindMemoryPool().WithInitialSize(40).FromComponentInNewPrefab(this._noteDebrisHDConditionVariable ? this._noteDebrisHDPrefab : this._noteDebrisLWPrefab); + container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(shortBeatEffect ? this._shortBeatEffectPrefab : this._beatEffectPrefab); + container.BindMemoryPool().WithInitialSize(16).FromComponentInNewPrefab(this._noteCutSoundEffectPrefab); + container.BindMemoryPool().WithInitialSize(20).FromComponentInNewPrefab(this._bombCutSoundEffectPrefab); + } catch (System.Exception ex) { System.Console.WriteLine(ex.ToString()); diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index e23553b..cf9eac3 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -306,12 +306,14 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) if (sceneContext != null && sceneDecoratorContext != null) { + /* var prop = typeof(Context).GetField("_monoInstallers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); var installersList = (List)prop.GetValue(sceneDecoratorContext); installersList.Remove(effectPoolsInstaller); Object.DestroyImmediate(effectPoolsInstaller); installersList.Add(customEffectPoolsInstaller); Console.WriteLine("Custom effect Pool Installer Added"); + */ } } catch (Exception ex) diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index c4ec5af..1e5afa0 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -2,10 +2,10 @@ "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", "author": "Kyle1413", "description": "Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections.", - "gameVersion": "1.8.0", + "gameVersion": "1.11.0", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.6", + "version": "4.8.7", "dependsOn": { "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From 01e38a8dc0c2d349b3cdc453a2b10de288221e23 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 17 Aug 2020 13:06:59 -0400 Subject: [PATCH 39/64] Update AssemblyInfo.cs --- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 2447311..6e6f3d0 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.6.0")] -[assembly: AssemblyFileVersion("4.8.6.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.8.7.0")] +[assembly: AssemblyFileVersion("4.8.7.0")] \ No newline at end of file From 8a9d404b4aed63cf927abab550d805941de58424 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Wed, 14 Oct 2020 15:33:37 -0400 Subject: [PATCH 40/64] 1.12.1 Compilation Fixes --- PracticePlugin/CustomEffectPoolsInstaller.cs | 6 ++- PracticePlugin/Plugin.cs | 39 ++++++++++++-------- PracticePlugin/PoolExtensions.cs | 3 +- PracticePlugin/PracticePlugin.csproj | 13 +++++++ PracticePlugin/Properties/AssemblyInfo.cs | 4 +- PracticePlugin/SongSeekBeatmapHandler.cs | 37 +++++++++---------- PracticePlugin/UIElementsCreator.cs | 1 - PracticePlugin/manifest.json | 5 ++- 8 files changed, 66 insertions(+), 42 deletions(-) diff --git a/PracticePlugin/CustomEffectPoolsInstaller.cs b/PracticePlugin/CustomEffectPoolsInstaller.cs index d8a67cb..3327870 100644 --- a/PracticePlugin/CustomEffectPoolsInstaller.cs +++ b/PracticePlugin/CustomEffectPoolsInstaller.cs @@ -1,6 +1,7 @@ using Zenject; namespace PracticePlugin { + /* public class CustomEffectPoolsInstaller : EffectPoolsInstaller { public override void ManualInstallBindings(DiContainer container, bool shortBeatEffect) @@ -21,11 +22,12 @@ public override void ManualInstallBindings(DiContainer container, bool shortBeat } } - /* + private CustomNoteCutSoundEffect ReplacePrefab() { return CustomNoteCutSoundEffect.CopyOriginal(_noteCutSoundEffectPrefab); } - */ + } +*/ } \ No newline at end of file diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index cf9eac3..1f560bd 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -11,6 +11,8 @@ using Object = UnityEngine.Object; //using CustomUI.GameplaySettings; using IPA; +using BS_Utils.Gameplay; + namespace PracticePlugin { [Plugin(RuntimeOptions.SingleStartInit)] @@ -122,7 +124,6 @@ private set public static AudioTimeSyncController AudioTimeSync { get; private set; } private static AudioManagerSO _mixer; private static AudioSource _songAudio; - private static GameplayCoreSceneSetup _gameCoreSceneSetup; private static string _lastLevelId; public static UIElementsCreator _uiElementsCreator; private static ResultsViewController resultsViewController; @@ -274,6 +275,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) } else if (newScene.name == GameSceneName) { + /* CustomEffectPoolsInstaller customEffectPoolsInstaller = null; var effectPoolsInstaller = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (effectPoolsInstaller != null) @@ -306,21 +308,22 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) if (sceneContext != null && sceneDecoratorContext != null) { - /* + var prop = typeof(Context).GetField("_monoInstallers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); var installersList = (List)prop.GetValue(sceneDecoratorContext); installersList.Remove(effectPoolsInstaller); Object.DestroyImmediate(effectPoolsInstaller); installersList.Add(customEffectPoolsInstaller); Console.WriteLine("Custom effect Pool Installer Added"); - */ + } + } catch (Exception ex) { Console.WriteLine(ex.ToString()); } - + */ if (_levelData == null) { @@ -350,11 +353,10 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; - _gameCoreSceneSetup = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + _mixer = Resources.FindObjectsOfTypeAll().FirstOrDefault(); AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); - _mixer = _gameCoreSceneSetup.GetPrivateField("_audioMixer"); - PracticeMode = (_levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel + PracticeMode = (_levelData.Mode == BS_Utils.Gameplay.Mode.Standard && _levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel && Resources.FindObjectsOfTypeAll().FirstOrDefault() == null); @@ -375,7 +377,8 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) } } - private void ResultsViewController_didActivateEvent(bool firstActivation, HMUI.ViewController.ActivationType activationType) + + private void ResultsViewController_didActivateEvent(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { if (showFailTextNext && showTimeFailed) { @@ -399,24 +402,30 @@ public System.Collections.IEnumerator DelayedSetup() try { Console.WriteLine("Atemmpting Practice Plugin UI"); - var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("Canvas"); + var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("MenuWrapper").transform.Find("Canvas").transform.Find("MainBar"); if (canvas == null) { Console.WriteLine("Canvas Null"); } - _uiElementsCreator = canvas.gameObject.AddComponent(); + + var uiObj = new GameObject("PracticePlugin UI"); + uiObj.transform.SetParent(canvas); + uiObj.transform.localScale = new Vector3(1, 1, 1); + uiObj.transform.localPosition = new Vector3(0, -45f, -1f); + + _uiElementsCreator = uiObj.AddComponent(); _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; _uiElementsCreator.Init(); // TimeScale = TimeScale; - var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); + // var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); // bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f); - bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); - var pauseMenu = GameObject.Find("PauseMenu"); - pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); + // bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); + // var pauseMenu = GameObject.Find("PauseMenu"); + // pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); new GameObject("Practice Plugin Behavior").AddComponent(); if (startWithFullEnergy) { @@ -586,7 +595,7 @@ public static void UpdateSpawnMovementData(float njs, float noteJumpStartBeatOff BeatmapObjectSpawnMovementData spawnMovementData = _spawnController.GetPrivateField("_beatmapObjectSpawnMovementData"); - float bpm = _spawnController.GetPrivateField("_variableBPMProcessor").currentBPM; + float bpm = _spawnController.GetPrivateField("_variableBpmProcessor").currentBpm; if (adjustNJSWithSpeed) diff --git a/PracticePlugin/PoolExtensions.cs b/PracticePlugin/PoolExtensions.cs index 81c4cda..1e2e700 100644 --- a/PracticePlugin/PoolExtensions.cs +++ b/PracticePlugin/PoolExtensions.cs @@ -2,7 +2,7 @@ using UnityEngine; namespace PracticePlugin -{ +{/* public static class PoolExtensions { public static void DespawnAll(this MemoryPoolWithActiveItems memoryPool) where T : Component @@ -14,4 +14,5 @@ public static void DespawnAll(this MemoryPoolWithActiveItems memoryPool) w } } } + */ } \ No newline at end of file diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 8e7be9a..d1007f6 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -33,6 +33,9 @@ 4 + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\BeatmapCore.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BSML.dll @@ -42,9 +45,19 @@ C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Colors.dll + + False + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Core.dll + + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\GameplayCore.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\HMLib.dll + + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\HMLibAttributes.dll + C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\HMUI.dll diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 6e6f3d0..35dfa5f 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.8.7.0")] -[assembly: AssemblyFileVersion("4.8.7.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.9.0.0")] +[assembly: AssemblyFileVersion("4.9.0.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index d85520a..1d829f4 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -36,15 +36,14 @@ private static List C if (_beatmapObjectManager == null) { - _beatmapObjectManager = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + _beatmapObjectManager = Resources.FindObjectsOfTypeAll().FirstOrDefault().GetPrivateField("_beatmapObjectManager") as BasicBeatmapObjectManager; if (_beatmapObjectManager != null) { - _noteAPool = _beatmapObjectManager.GetPrivateField("_noteAPool"); - _noteBPool = _beatmapObjectManager.GetPrivateField("_noteBPool"); - _bombNotePool = _beatmapObjectManager.GetPrivateField("_bombNotePool"); + _notePool = _beatmapObjectManager.GetPrivateField>("_gameNotePoolContainer"); + _bombNotePool = _beatmapObjectManager.GetPrivateField>("_bombNotePoolContainer"); _obstaclePool = - _beatmapObjectManager.GetPrivateField("_obstaclePool"); + _beatmapObjectManager.GetPrivateField>("_obstaclePoolContainer"); } } if (_noteCutSoundEffectManager == null) @@ -61,13 +60,12 @@ private static List C private static List _callbackList; private static BeatmapObjectCallbackController _beatmapObjectCallbackController; private static BeatmapObjectSpawnController _beatmapObjectSpawnController; - private static BeatmapObjectManager _beatmapObjectManager; + private static BasicBeatmapObjectManager _beatmapObjectManager; private static NoteCutSoundEffectManager _noteCutSoundEffectManager; - private static NoteController.Pool _noteAPool; - private static NoteController.Pool _noteBPool; - private static NoteController.Pool _bombNotePool; - private static ObstacleController.Pool _obstaclePool; + private static MonoMemoryPoolContainer _notePool; + private static MonoMemoryPoolContainer _bombNotePool; + private static MonoMemoryPoolContainer _obstaclePool; private static BeatmapData _beatmapData; @@ -77,10 +75,10 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) _beatmapData = _beatmapObjectCallbackController.GetPrivateField("_beatmapData"); foreach (var callbackData in CallbackList) { - for (var i = 0; i < _beatmapData.beatmapLinesData.Length; i++) + for (var i = 0; i < _beatmapData.beatmapLinesData.Count; i++) { callbackData.nextObjectIndexInLine[i] = 0; - while (callbackData.nextObjectIndexInLine[i] < _beatmapData.beatmapLinesData[i].beatmapObjectsData.Length) + while (callbackData.nextObjectIndexInLine[i] < _beatmapData.beatmapLinesData[i].beatmapObjectsData.Count) { var beatmapObjectData = _beatmapData.beatmapLinesData[i].beatmapObjectsData[callbackData.nextObjectIndexInLine[i]]; if (beatmapObjectData.time - aheadTime >= newSongTime) @@ -95,9 +93,9 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) var newNextEventIndex = 0; - while (newNextEventIndex < _beatmapData.beatmapEventData.Length) + while (newNextEventIndex < _beatmapData.beatmapEventsData.Count) { - var beatmapEventData = _beatmapData.beatmapEventData[newNextEventIndex]; + var beatmapEventData = _beatmapData.beatmapEventsData[newNextEventIndex]; if (beatmapEventData.time >= newSongTime) { break; @@ -107,14 +105,15 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) } _beatmapObjectCallbackController.SetPrivateField("_nextEventIndex", newNextEventIndex); - - var notesA = _noteAPool.activeItems.ToList(); + _beatmapObjectManager.DissolveAllObjects(); + /* + var notesA = _notePool.activeItems.ToList(); foreach (var noteA in notesA) { // Console.WriteLine("Despawning, Length: " + notesA.Count); - _beatmapObjectManager.Despawn(noteA); + _beatmapObjectManager.DissolveAllObjects(noteA); } - + var notesB = _noteBPool.activeItems.ToList(); foreach (var noteB in notesB) { @@ -132,7 +131,7 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) { _beatmapObjectManager.Despawn(obstacle); } - + */ Plugin.AudioTimeSync.SetPrivateField("_prevAudioSamplePos", -1); Plugin.AudioTimeSync.SetPrivateField("_songTime", newSongTime); diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 9f810a4..a331aa1 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -35,7 +35,6 @@ private void InitDelayed() seekerObj.AddComponent(); SongSeeker = seekerObj.AddComponent(); SongSeeker.Init(); - new GameObject("No Fail Game Energy").AddComponent(); defaultNJS = Plugin._spawnController.GetPrivateField("_initData").noteJumpMovementSpeed; currentNJS = defaultNJS; diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 1e5afa0..bde9ac3 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -2,11 +2,12 @@ "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", "author": "Kyle1413", "description": "Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections.", - "gameVersion": "1.11.0", + "gameVersion": "1.12.1", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.8.7", + "version": "4.9.0", "dependsOn": { + "BSIPA": "^4.1.2", "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From 67b1537512737ad9a07be795684f5c68a60925ad Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Fri, 16 Oct 2020 16:14:18 -0400 Subject: [PATCH 41/64] Start Switching Adjustment UI to BSML, compile fixes for 1.12.1 --- PracticePlugin/LooperUI.cs | 13 ++--- PracticePlugin/Plugin.cs | 42 +++++++++------- PracticePlugin/PracticePlugin.csproj | 4 ++ PracticePlugin/PracticeUI.bsml | 7 +++ PracticePlugin/PracticeUI.cs | 75 ++++++++++++++++++++++++++++ PracticePlugin/SongSeeker.cs | 17 ++++--- PracticePlugin/UIElementsCreator.cs | 25 ++++------ 7 files changed, 137 insertions(+), 46 deletions(-) create mode 100644 PracticePlugin/PracticeUI.bsml create mode 100644 PracticePlugin/PracticeUI.cs diff --git a/PracticePlugin/LooperUI.cs b/PracticePlugin/LooperUI.cs index 281f321..5372588 100644 --- a/PracticePlugin/LooperUI.cs +++ b/PracticePlugin/LooperUI.cs @@ -1,4 +1,5 @@ -using System; +using HMUI; +using System; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; @@ -34,7 +35,7 @@ public float EndTime private SongSeeker _songSeeker; - private Image _lineDuration; + private ImageView _lineDuration; private LooperCursor _startCursor; private LooperCursor _endCursor; @@ -53,7 +54,7 @@ public void Init(SongSeeker songSeeker) _prevEndTime = 1; } - _lineDuration = new GameObject("Line Duration").AddComponent(); + _lineDuration = new GameObject("Line Duration").AddComponent(); var rectTransform = _lineDuration.rectTransform; rectTransform.SetParent(transform, false); rectTransform.anchorMin = Vector2.up * 0.5f; @@ -61,7 +62,7 @@ public void Init(SongSeeker songSeeker) rectTransform.sizeDelta = Vector2.zero; _lineDuration.color = LineDurationColor; - var startCursorImage = new GameObject("Start Cursor").AddComponent(); + var startCursorImage = new GameObject("Start Cursor").AddComponent(); rectTransform = startCursorImage.rectTransform; rectTransform.SetParent(transform, false); rectTransform.anchorMin = Vector2.up * 0.5f; @@ -75,7 +76,7 @@ public void Init(SongSeeker songSeeker) _startCursor.EndDragEvent += CursorOnEndDragEvent; _startCursor.Position = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevStartTime); - var endCursorImage = new GameObject("End Cursor").AddComponent(); + var endCursorImage = new GameObject("End Cursor").AddComponent(); rectTransform = endCursorImage.rectTransform; rectTransform.SetParent(transform, false); rectTransform.anchorMin = Vector2.up * 0.5f; @@ -83,7 +84,7 @@ public void Init(SongSeeker songSeeker) rectTransform.sizeDelta = CursorSize; rectTransform.localEulerAngles = new Vector3(0, 0, 45); endCursorImage.color = EndColor; - + _endCursor = endCursorImage.gameObject.AddComponent(); _endCursor.BeginDragEvent += CursorOnBeginDragEvent; _endCursor.EndDragEvent += CursorOnEndDragEvent; diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 1f560bd..ee3c721 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; - +using HMUI; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; @@ -12,7 +12,7 @@ //using CustomUI.GameplaySettings; using IPA; using BS_Utils.Gameplay; - +using BeatSaberMarkupLanguage; namespace PracticePlugin { [Plugin(RuntimeOptions.SingleStartInit)] @@ -31,9 +31,9 @@ public class Plugin public string failTime { get; private set; } internal bool showFailTextNext { get; set; } - public static GameObject SpeedSettingsObject { get; private set; } - public static GameObject NjsSettingsObject { get; private set; } - public static GameObject SpawnOffsetSettingsObject { get; private set; } + // public static GameObject SpeedSettingsObject { get; private set; } + // public static GameObject NjsSettingsObject { get; private set; } + // public static GameObject SpawnOffsetSettingsObject { get; private set; } internal static bool startWithFullEnergy = false; internal static bool disablePitchCorrection = false; internal static bool adjustNJSWithSpeed = false; @@ -192,7 +192,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) resultsViewController.didActivateEvent += ResultsViewController_didActivateEvent; } - + /* if (SpeedSettingsObject != null) return; var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); @@ -271,7 +271,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) SpawnOffsetSettingsObject.GetComponentInChildren().text = ""; Object.DontDestroyOnLoad(SpawnOffsetSettingsObject); - + */ } else if (newScene.name == GameSceneName) { @@ -383,7 +383,7 @@ private void ResultsViewController_didActivateEvent(bool firstActivation, bool a if (showFailTextNext && showTimeFailed) { if (failText == null) - failText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(resultsViewController.rectTransform, failTime, new Vector2(15f, -25f)); + failText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(resultsViewController.rectTransform, failTime, new Vector2(15f, -35f)); else failText.text = failTime; failText.richText = true; @@ -402,30 +402,34 @@ public System.Collections.IEnumerator DelayedSetup() try { Console.WriteLine("Atemmpting Practice Plugin UI"); - var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("MenuWrapper").transform.Find("Canvas").transform.Find("MainBar"); + var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("MenuWrapper").transform.Find("Canvas"); if (canvas == null) { Console.WriteLine("Canvas Null"); } - - var uiObj = new GameObject("PracticePlugin UI"); - uiObj.transform.SetParent(canvas); - uiObj.transform.localScale = new Vector3(1, 1, 1); - uiObj.transform.localPosition = new Vector3(0, -45f, -1f); + BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, PracticeUI.instance); + + var uiObj = new GameObject("PracticePlugin Seeker UI"); + _uiElementsCreator = uiObj.AddComponent(); _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; _uiElementsCreator.Init(); + uiObj.transform.SetParent(canvas); + // CurvedCanvasSettings curvedCanvasSettings = uiObj.AddComponent(); + // curvedCanvasSettings.SetRadius(150f); + uiObj.transform.localScale = new Vector3(1, 1, 1); + uiObj.transform.localPosition = new Vector3(0, -65f, 0f); - // TimeScale = TimeScale; + // TimeScale = TimeScale; - // var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); + // var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); // bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f); - // bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); - // var pauseMenu = GameObject.Find("PauseMenu"); - // pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); + // bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); + // var pauseMenu = GameObject.Find("PauseMenu"); + // pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); new GameObject("Practice Plugin Behavior").AddComponent(); if (startWithFullEnergy) { diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index d1007f6..0108afc 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -116,6 +116,7 @@ + @@ -128,6 +129,9 @@ + + + diff --git a/PracticePlugin/PracticeUI.bsml b/PracticePlugin/PracticeUI.bsml new file mode 100644 index 0000000..a6edc24 --- /dev/null +++ b/PracticePlugin/PracticeUI.bsml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/PracticePlugin/PracticeUI.cs b/PracticePlugin/PracticeUI.cs new file mode 100644 index 0000000..198ec3f --- /dev/null +++ b/PracticePlugin/PracticeUI.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BeatSaberMarkupLanguage; +using BeatSaberMarkupLanguage.Components; +using BeatSaberMarkupLanguage.Attributes; +namespace PracticePlugin +{ + public class PracticeUI : NotifiableSingleton + { + private float _speed; + [UIValue("speed")] + public float speed + { + get => _speed; + set + { + _speed = value; + } + } + [UIAction("setSpeed")] + void SetSpeed(float value) + { + speed = value; + } + private float _njs; + [UIValue("njs")] + public float njs + { + get => _njs; + set + { + _njs = value; + } + } + [UIAction("setnjs")] + void SetNjs(float value) + { + njs = value; + } + private float _offset; + [UIValue("offset")] + public float offset + { + get => _offset; + set + { + _offset = value; + } + } + [UIAction("setoffset")] + void SetSpawnOffset(float value) + { + offset = value; + } + + [UIAction("speedFormatter")] + string speedForValue(float value) + { + return $"{(int)(value * 100)}%"; + } + [UIAction("njsFormatter")] + string njsForValue(float value) + { + return value == UIElementsCreator.defaultNJS ? $"{value}" : $"{value}"; + } + [UIAction("spawnOffsetFormatter")] + string offsetForValue(float value) + { + return value == UIElementsCreator.defaultOffset ? $"{value.ToString("F2")}" : $"{value.ToString("F2")}"; + } + } +} diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 6e56cbc..91985e0 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -4,7 +4,7 @@ using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; - +using HMUI; namespace PracticePlugin { public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler @@ -14,9 +14,9 @@ public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler [SerializeField] internal AudioSource _songAudioSource; private LooperUI _looperUI; - private Image _seekBackg; - private Image _seekBar; - private Image _seekCursor; + private ImageView _seekBackg; + private ImageView _seekBar; + private ImageView _seekCursor; private TMP_Text _currentTime; private TMP_Text _timeLength; @@ -50,13 +50,13 @@ public void Init() rectTransform.sizeDelta = ParentSize; rectTransform.anchoredPosition = new Vector2(0, 16); - _seekBackg = new GameObject("Background").AddComponent(); + _seekBackg = new GameObject("Background").AddComponent(); rectTransform = _seekBackg.rectTransform; rectTransform.SetParent(transform, false); rectTransform.sizeDelta = SeekBarSize; _seekBackg.color = BackgroundColor; - _seekBar = new GameObject("Seek Bar").AddComponent(); + _seekBar = new GameObject("Seek Bar").AddComponent(); rectTransform = _seekBar.rectTransform; rectTransform.SetParent(transform, false); rectTransform.sizeDelta = SeekBarSize; @@ -67,7 +67,7 @@ public void Init() _seekBar.fillMethod = Image.FillMethod.Horizontal; _seekBar.color = ForegroundColor; - _seekCursor = new GameObject("Seek Cursor").AddComponent(); + _seekCursor = new GameObject("Seek Cursor").AddComponent(); rectTransform = _seekCursor.rectTransform; rectTransform.SetParent(_seekBar.transform, false); rectTransform.anchorMin = Vector2.up * 0.5f; @@ -75,6 +75,9 @@ public void Init() rectTransform.sizeDelta = SeekCursorSize; _seekCursor.color = SeekCursorColor; + + + _currentTime = Plugin.CreateText(this.GetComponent(), "0:00", new Vector2(-83f, -1f)); _currentTime.fontSize = 5f; // rectTransform = _currentTime.rectTransform; diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index a331aa1..966b32b 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -1,7 +1,9 @@ using System; using TMPro; using UnityEngine; - +using BeatSaberMarkupLanguage; +using BeatSaberMarkupLanguage.Components; +using BeatSaberMarkupLanguage.Attributes; namespace PracticePlugin { public class UIElementsCreator : MonoBehaviour @@ -12,18 +14,13 @@ public class UIElementsCreator : MonoBehaviour internal static float currentSpawnOffset; internal static float defaultNJS; internal static float defaultOffset; - private GameObject _speedSettings = null; - private GameObject _njsSettings = null; - private GameObject _offsetSettings = null; - internal SpeedSettingsController speedController; - internal NjsSettingsController njsController; - internal SpawnOffsetController spawnOffsetController; - private TMP_Text _leaderboardText; + internal static float _newTimeScale { get; private set; } = 1f; public void Init() { - Invoke(nameof(InitDelayed), 0.1f); + // Invoke(nameof(InitDelayed), 0.1f); + InitDelayed(); } private void InitDelayed() @@ -48,7 +45,7 @@ private void InitDelayed() private void OnEnable() { - + /* if (_speedSettings == null && Plugin.PracticeMode) { _speedSettings = Instantiate(Plugin.SpeedSettingsObject, transform); @@ -94,7 +91,7 @@ private void OnEnable() _newTimeScale = Plugin.TimeScale; njsController.Refresh(true); spawnOffsetController.Refresh(true); - + */ @@ -123,14 +120,14 @@ private void OnDisable() ValueChangedEvent(_newTimeScale); } Plugin.UpdateSpawnMovementData(UIElementsCreator.currentNJS, UIElementsCreator.currentSpawnOffset); - Destroy(_speedSettings); + // Destroy(_speedSettings); } private void SpeedControllerOnValueChangedEvent(float timeScale) { _newTimeScale = timeScale; - njsController.Refresh(true); - spawnOffsetController.Refresh(true); + // njsController.Refresh(true); + // spawnOffsetController.Refresh(true); /* _newTimeScale = timeScale; if (Math.Abs(_newTimeScale - 1) > 0.0000000001f) From e3966595b0f88b2462fa3db302f6f8c7099a4bcd Mon Sep 17 00:00:00 2001 From: AceofShovels Date: Sat, 17 Oct 2020 18:25:44 -0400 Subject: [PATCH 42/64] Fixed seeker UI to be on curved canvas --- PracticePlugin/LooperUI.cs | 15 ++++++++++++++- PracticePlugin/Plugin.cs | 35 ++++++++++++++++++++-------------- PracticePlugin/PracticeUI.bsml | 2 +- PracticePlugin/SongSeeker.cs | 21 ++++++++++++++++---- 4 files changed, 53 insertions(+), 20 deletions(-) diff --git a/PracticePlugin/LooperUI.cs b/PracticePlugin/LooperUI.cs index 5372588..c1925cc 100644 --- a/PracticePlugin/LooperUI.cs +++ b/PracticePlugin/LooperUI.cs @@ -3,6 +3,7 @@ using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; +using BeatSaberMarkupLanguage; namespace PracticePlugin { @@ -54,13 +55,19 @@ public void Init(SongSeeker songSeeker) _prevEndTime = 1; } + var tex = Texture2D.whiteTexture; + var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1); + _lineDuration = new GameObject("Line Duration").AddComponent(); var rectTransform = _lineDuration.rectTransform; rectTransform.SetParent(transform, false); rectTransform.anchorMin = Vector2.up * 0.5f; rectTransform.anchorMax = Vector2.up * 0.5f; rectTransform.sizeDelta = Vector2.zero; + _lineDuration.sprite = sprite; + _lineDuration.type = Image.Type.Simple; _lineDuration.color = LineDurationColor; + _lineDuration.material = Utilities.ImageResources.NoGlowMat; var startCursorImage = new GameObject("Start Cursor").AddComponent(); rectTransform = startCursorImage.rectTransform; @@ -69,7 +76,10 @@ public void Init(SongSeeker songSeeker) rectTransform.anchorMax = Vector2.up * 0.5f; rectTransform.sizeDelta = CursorSize; rectTransform.localEulerAngles = new Vector3(0, 0, 45); + startCursorImage.sprite = sprite; + startCursorImage.type = Image.Type.Simple; startCursorImage.color = StartColor; + startCursorImage.material = Utilities.ImageResources.NoGlowMat; _startCursor = startCursorImage.gameObject.AddComponent(); _startCursor.BeginDragEvent += CursorOnBeginDragEvent; @@ -83,8 +93,11 @@ public void Init(SongSeeker songSeeker) rectTransform.anchorMax = Vector2.up * 0.5f; rectTransform.sizeDelta = CursorSize; rectTransform.localEulerAngles = new Vector3(0, 0, 45); + endCursorImage.sprite = sprite; + endCursorImage.type = Image.Type.Simple; endCursorImage.color = EndColor; - + endCursorImage.material = Utilities.ImageResources.NoGlowMat; + _endCursor = endCursorImage.gameObject.AddComponent(); _endCursor.BeginDragEvent += CursorOnBeginDragEvent; _endCursor.EndDragEvent += CursorOnEndDragEvent; diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index ee3c721..a551e5d 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -13,6 +13,11 @@ using IPA; using BS_Utils.Gameplay; using BeatSaberMarkupLanguage; +using ModestTree; +using BeatSaberMarkupLanguage.ViewControllers; +using UnityEngine.UIElements; +using BS_Utils.Utilities; + namespace PracticePlugin { [Plugin(RuntimeOptions.SingleStartInit)] @@ -142,6 +147,7 @@ public void OnApplicationStart() adjustNJSWithSpeed = Config.GetBool("PracticePlugin", "Adjust NJS With Speed", false, true); SceneManager.activeSceneChanged += OnActiveSceneChanged; SceneManager.sceneLoaded += OnSceneLoaded; + } public void OnSceneLoaded(Scene arg0, LoadSceneMode arg1) @@ -337,21 +343,19 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) _spawnController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); } - - if (_lastLevelId != _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID && !string.IsNullOrEmpty(_lastLevelId)) { PlayingNewSong = true; // TimeScale = 1; - _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; + _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; } else { PlayingNewSong = false; } - + _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; _mixer = Resources.FindObjectsOfTypeAll().FirstOrDefault(); AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); @@ -371,9 +375,8 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) else _timeScale = _levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; SharedCoroutineStarter.instance.StartCoroutine(DelayedSetup()); - } - + } } @@ -407,21 +410,25 @@ public System.Collections.IEnumerator DelayedSetup() if (canvas == null) { Console.WriteLine("Canvas Null"); - } - BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, PracticeUI.instance); - var uiObj = new GameObject("PracticePlugin Seeker UI"); + BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, PracticeUI.instance); + GameObject uiObj = new GameObject("PracticePlugin Seeker UI", typeof(RectTransform)); + (uiObj.transform as RectTransform).anchorMin = new Vector2(0, 0); + (uiObj.transform as RectTransform).anchorMax = new Vector2(1, 1); + (uiObj.transform as RectTransform).sizeDelta = new Vector2(0, 0); + _uiElementsCreator = uiObj.AddComponent(); _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; _uiElementsCreator.Init(); - uiObj.transform.SetParent(canvas); - // CurvedCanvasSettings curvedCanvasSettings = uiObj.AddComponent(); - // curvedCanvasSettings.SetRadius(150f); + + uiObj.transform.SetParent(canvas, false); + uiObj.transform.localScale = new Vector3(1, 1, 1); - uiObj.transform.localPosition = new Vector3(0, -65f, 0f); + uiObj.transform.localPosition = new Vector3(0f, -3f, 0f); + // TimeScale = TimeScale; @@ -648,4 +655,4 @@ public static TextMeshProUGUI CreateText(RectTransform parent, string text, Vect return textMesh; } } -} \ No newline at end of file +} diff --git a/PracticePlugin/PracticeUI.bsml b/PracticePlugin/PracticeUI.bsml index a6edc24..0e11882 100644 --- a/PracticePlugin/PracticeUI.bsml +++ b/PracticePlugin/PracticeUI.bsml @@ -1,5 +1,5 @@  - + diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 91985e0..09af40f 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -5,6 +5,8 @@ using UnityEngine.EventSystems; using UnityEngine.UI; using HMUI; +using BeatSaberMarkupLanguage; + namespace PracticePlugin { public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler @@ -43,6 +45,10 @@ public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler internal int _startTimeSamples; public void Init() { + var tex = Texture2D.whiteTexture; + var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1); + + _songAudioSource = Plugin.AudioTimeSync.GetPrivateField("_audioSource"); var rectTransform = transform as RectTransform; rectTransform.anchorMin = Vector2.right * 0.5f; @@ -54,18 +60,21 @@ public void Init() rectTransform = _seekBackg.rectTransform; rectTransform.SetParent(transform, false); rectTransform.sizeDelta = SeekBarSize; + _seekBackg.sprite = sprite; + _seekBackg.type = Image.Type.Simple; _seekBackg.color = BackgroundColor; + _seekBackg.material = Utilities.ImageResources.NoGlowMat; _seekBar = new GameObject("Seek Bar").AddComponent(); rectTransform = _seekBar.rectTransform; rectTransform.SetParent(transform, false); rectTransform.sizeDelta = SeekBarSize; - var tex = Texture2D.whiteTexture; - var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1); + _seekBar.sprite = sprite; _seekBar.type = Image.Type.Filled; _seekBar.fillMethod = Image.FillMethod.Horizontal; _seekBar.color = ForegroundColor; + _seekBar.material = Utilities.ImageResources.NoGlowMat; _seekCursor = new GameObject("Seek Cursor").AddComponent(); rectTransform = _seekCursor.rectTransform; @@ -73,12 +82,16 @@ public void Init() rectTransform.anchorMin = Vector2.up * 0.5f; rectTransform.anchorMax = Vector2.up * 0.5f; rectTransform.sizeDelta = SeekCursorSize; + + _seekCursor.sprite = sprite; + _seekCursor.type = Image.Type.Simple; _seekCursor.color = SeekCursorColor; + _seekCursor.material = Utilities.ImageResources.NoGlowMat; - _currentTime = Plugin.CreateText(this.GetComponent(), "0:00", new Vector2(-83f, -1f)); + _currentTime = BeatSaberUI.CreateText(this.GetComponent(), "0:00", new Vector2(-83f, -1f)); _currentTime.fontSize = 5f; // rectTransform = _currentTime.rectTransform; // rectTransform.anchorMin = Vector2.up * 0.5f; @@ -89,7 +102,7 @@ public void Init() // _currentTime.fontSizeMin = 1; _currentTime.alignment = TextAlignmentOptions.Right; - _timeLength = Plugin.CreateText(this.GetComponent(), "0:00", new Vector2(87f, -1f)); + _timeLength = BeatSaberUI.CreateText(this.GetComponent(), "0:00", new Vector2(87f, -1f)); _timeLength.fontSize = 5f; _timeLength.alignment = TextAlignmentOptions.Left; From 669ab8d4ff2e20b063187b16d979c2315346bbfe Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 17 Oct 2020 21:16:06 -0400 Subject: [PATCH 43/64] Functionality For UI, Seeker/Looper Cursors need Drag math fixed --- PracticePlugin/Behavior.cs | 4 +- PracticePlugin/NjsSettingsController.cs | 40 ---- PracticePlugin/Plugin.cs | 217 +--------------------- PracticePlugin/PracticePlugin.csproj | 3 - PracticePlugin/PracticeUI.cs | 9 +- PracticePlugin/SongSeeker.cs | 7 +- PracticePlugin/SpawnOffsetController.cs | 35 ---- PracticePlugin/SpeedSettingsController.cs | 36 ---- PracticePlugin/UIElementsCreator.cs | 70 +------ 9 files changed, 29 insertions(+), 392 deletions(-) delete mode 100644 PracticePlugin/NjsSettingsController.cs delete mode 100644 PracticePlugin/SpawnOffsetController.cs delete mode 100644 PracticePlugin/SpeedSettingsController.cs diff --git a/PracticePlugin/Behavior.cs b/PracticePlugin/Behavior.cs index ffb4254..3ae9274 100644 --- a/PracticePlugin/Behavior.cs +++ b/PracticePlugin/Behavior.cs @@ -11,8 +11,8 @@ public class Behavior : MonoBehaviour void Update() { - if (Plugin._uiElementsCreator == null || Plugin._uiElementsCreator.SongSeeker == null) return; - Plugin._uiElementsCreator.SongSeeker.OnUpdate(); + if (Plugin._uiElementsCreator == null || UIElementsCreator.SongSeeker == null) return; + UIElementsCreator.SongSeeker.OnUpdate(); } } } diff --git a/PracticePlugin/NjsSettingsController.cs b/PracticePlugin/NjsSettingsController.cs deleted file mode 100644 index 7d4cd24..0000000 --- a/PracticePlugin/NjsSettingsController.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using UnityEngine; - -namespace PracticePlugin -{ - public class NjsSettingsController : ListSettingsController - { - public event Action ValueChangedEvent; - - private int _indexOffset; - protected override bool GetInitValues(out int idx, out int numberOfElements) - { - _indexOffset = Plugin.PracticeMode ? 1 : 20; - numberOfElements = 50; - idx = (int)UIElementsCreator.currentNJS; - return true; - } - - protected override void ApplyValue(int idx) - { - } - - protected override string TextForValue(int idx) - { - if (ValueChangedEvent != null) - { - ValueChangedEvent(idx); - } - string result; - - if (idx == UIElementsCreator.defaultNJS) - result = $"{idx}"; - else - result = idx.ToString(); - if(Plugin.adjustNJSWithSpeed && UIElementsCreator._newTimeScale != 1f) - result += $"({(idx * (1f / UIElementsCreator._newTimeScale)).ToString("F2")})"; - return result; - } - } -} \ No newline at end of file diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index a551e5d..96eef02 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -42,10 +42,10 @@ public class Plugin internal static bool startWithFullEnergy = false; internal static bool disablePitchCorrection = false; internal static bool adjustNJSWithSpeed = false; - public static float TimeScale + internal static float TimeScale { get { return _timeScale; } - private set + set { _timeScale = value; if (!AudioTimeSync) return; @@ -140,7 +140,7 @@ public void OnApplicationStart() { if (_init) return; _init = true; - // NoFailGameEnergy.limitLevelFail = Config.GetBool("PracticePlugin", "limitLevelFailDisplay", false, true); + startWithFullEnergy = Config.GetBool("PracticePlugin", "startWithFullEnergy", false, true); showTimeFailed = Config.GetBool("PracticePlugin", "Show Time Failed", true, true); disablePitchCorrection = Config.GetBool("PracticePlugin", "Disable Pitch Correction", false, true); @@ -154,25 +154,7 @@ public void OnSceneLoaded(Scene arg0, LoadSceneMode arg1) { if (arg0.name == "MenuCore") { - /* - var practicePluginSubmenu = GameplaySettingsUI.CreateSubmenuOption(GameplaySettingsPanels.PlayerSettingsRight, "PracticePlugin", "MainMenu", "PracticePlugin", "Practice Plugin Settings"); - var fullEnergy = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Start With Full Energy", "PracticePlugin", "Start With full energy in Practice Mode."); - fullEnergy.GetValue = Config.GetBool("PracticePlugin", "startWithFullEnergy", false, true); - fullEnergy.OnToggle += (value) => - { - startWithFullEnergy = value; - Config.SetBool("PracticePlugin", "startWithFullEnergy", value); - - }; - var timeFailedOption = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.PlayerSettingsRight, "Show Time Failed", "PracticePlugin", "Show the time the level was failed on the results screen."); - timeFailedOption.GetValue = Config.GetBool("PracticePlugin", "Show Time Failed", true, true); - timeFailedOption.OnToggle += (value) => - { - showTimeFailed = value; - Config.SetBool("PracticePlugin", "Show Time Failed", value); - }; - */ } @@ -198,139 +180,11 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) resultsViewController.didActivateEvent += ResultsViewController_didActivateEvent; } - /* - if (SpeedSettingsObject != null) return; - - var volumeSettings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - - if (volumeSettings == null) return; - - volumeSettings.gameObject.SetActive(false); - SpeedSettingsObject = Object.Instantiate(volumeSettings.gameObject); - SpeedSettingsObject.SetActive(false); - volumeSettings.gameObject.SetActive(true); - - if (SpeedSettingsObject == null) return; - - var volume = SpeedSettingsObject.GetComponent(); - ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController), - typeof(SpeedSettingsController), SpeedSettingsObject); - Object.DestroyImmediate(volume); - - Polyglot.LocalizedTextMeshProUGUI localizer = SpeedSettingsObject.GetComponentInChildren(); - if (localizer != null) - GameObject.Destroy(localizer); - - SpeedSettingsObject.GetComponentInChildren().text = ""; - Object.DontDestroyOnLoad(SpeedSettingsObject); - - - //NJS Object - if (NjsSettingsObject != null) return; - - var volumeSettings2 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - - if (volumeSettings2 == null) return; - - volumeSettings2.gameObject.SetActive(false); - NjsSettingsObject = Object.Instantiate(volumeSettings2.gameObject); - NjsSettingsObject.SetActive(false); - volumeSettings2.gameObject.SetActive(true); - - if (NjsSettingsObject == null) return; - - var volume2 = NjsSettingsObject.GetComponent(); - ReflectionUtil.CopyComponent(volume2, typeof(IncDecSettingsController), - typeof(NjsSettingsController), NjsSettingsObject); - Object.DestroyImmediate(volume2); - - localizer = NjsSettingsObject.GetComponentInChildren(); - if (localizer != null) - GameObject.Destroy(localizer); - - NjsSettingsObject.GetComponentInChildren().text = ""; - Object.DontDestroyOnLoad(NjsSettingsObject); - - - //Spawn Offset Object - if (SpawnOffsetSettingsObject != null) return; - - var volumeSettings3 = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - - if (volumeSettings3 == null) return; - - volumeSettings3.gameObject.SetActive(false); - SpawnOffsetSettingsObject = Object.Instantiate(volumeSettings3.gameObject); - SpawnOffsetSettingsObject.SetActive(false); - volumeSettings3.gameObject.SetActive(true); - - if (SpawnOffsetSettingsObject == null) return; - - var volume3 = SpawnOffsetSettingsObject.GetComponent(); - ReflectionUtil.CopyComponent(volume3, typeof(IncDecSettingsController), - typeof(SpawnOffsetController), SpawnOffsetSettingsObject); - Object.DestroyImmediate(volume3); - - localizer = SpawnOffsetSettingsObject.GetComponentInChildren(); - if (localizer != null) - GameObject.Destroy(localizer); - - SpawnOffsetSettingsObject.GetComponentInChildren().text = ""; - Object.DontDestroyOnLoad(SpawnOffsetSettingsObject); - */ } else if (newScene.name == GameSceneName) { - /* - CustomEffectPoolsInstaller customEffectPoolsInstaller = null; - var effectPoolsInstaller = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - if (effectPoolsInstaller != null) - { - customEffectPoolsInstaller = (CustomEffectPoolsInstaller)ReflectionUtil.CopyComponent(effectPoolsInstaller, - typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject); - } - - SceneContext sceneContext = null; - SceneDecoratorContext sceneDecoratorContext = null; - try - { - Console.WriteLine("Custom effect Pool Installer Made"); - foreach (var gameObject in newScene.GetRootGameObjects()) - { - if (sceneContext == null) - { - sceneContext = gameObject.GetComponentInChildren(true); - } - } - - foreach (var gameObject in SceneManager.GetSceneByName(ContextSceneName).GetRootGameObjects()) - { - if (sceneDecoratorContext == null) - { - sceneDecoratorContext = gameObject.GetComponentInChildren(true); - } - } - if (sceneContext != null && sceneDecoratorContext != null) - { - - var prop = typeof(Context).GetField("_monoInstallers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); - var installersList = (List)prop.GetValue(sceneDecoratorContext); - installersList.Remove(effectPoolsInstaller); - Object.DestroyImmediate(effectPoolsInstaller); - installersList.Add(customEffectPoolsInstaller); - Console.WriteLine("Custom effect Pool Installer Added"); - - } - - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - */ - if (_levelData == null) { _levelData = BS_Utils.Plugin.LevelData; @@ -421,7 +275,6 @@ public System.Collections.IEnumerator DelayedSetup() (uiObj.transform as RectTransform).sizeDelta = new Vector2(0, 0); _uiElementsCreator = uiObj.AddComponent(); - _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent; _uiElementsCreator.Init(); uiObj.transform.SetParent(canvas, false); @@ -429,15 +282,7 @@ public System.Collections.IEnumerator DelayedSetup() uiObj.transform.localScale = new Vector3(1, 1, 1); uiObj.transform.localPosition = new Vector3(0f, -3f, 0f); - - // TimeScale = TimeScale; - - // var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG"); - // bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f); - // bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z); - // var pauseMenu = GameObject.Find("PauseMenu"); - // pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z); - new GameObject("Practice Plugin Behavior").AddComponent(); + new GameObject("Practice Plugin Behavior").AddComponent(); if (startWithFullEnergy) { GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll().FirstOrDefault(); @@ -451,13 +296,7 @@ public System.Collections.IEnumerator DelayedSetup() Console.WriteLine(ex.ToString()); } } - private void ResultsViewControllerOnContinueButtonPressedEvent(ResultsViewController obj) - { - /* - PersistentSingleton.instance.gameDynamicData.GetCurrentPlayerDynamicData() - .gameplayOptions.noEnergy = false; - */ - } + private void MainGameSceneSetupDataOnDidFinishEvent(StandardLevelScenesTransitionSetupDataSO levelData, LevelCompletionResults results) { @@ -469,23 +308,10 @@ private void MainGameSceneSetupDataOnDidFinishEvent(StandardLevelScenesTransitio showFailTextNext = true; } - /* - * - if (!NoFail && HasTimeScaleChanged && results != null && - results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared) - { - levelData.gameplayCoreSetupData.gameplayModifiers.noFail = true; - _resetNoFail = true; - } - */ - } - private void UIElementsCreatorOnValueChangedEvent(float timeScale) - { - - TimeScale = timeScale; } + private static bool IsEqualToOne(float value) { return Math.Abs(value - 1) < 0.000000001f; @@ -568,37 +394,6 @@ public static void AdjustSpawnOffset(float offset) _spawnController.SetPrivateField("_moveDistance", moveDis); - } - public static void AdjustNjsAndOffset() - { - float njs = UIElementsCreator.currentNJS; - float noteJumpStartBeatOffset = UIElementsCreator.currentSpawnOffset; - float halfJumpDur = 4f; - float maxHalfJump = _spawnController.GetPrivateField("_maxHalfJumpDistance"); - float moveSpeed = _spawnController.GetPrivateField("_moveSpeed"); - float moveDir = _spawnController.GetPrivateField("_moveDurationInBeats"); - float jumpDis; - float spawnAheadTime; - float moveDis; - float bpm = _spawnController.GetPrivateField("_beatsPerMinute"); - float num = 60f / bpm; - moveDis = moveSpeed * num * moveDir; - while (njs * num * halfJumpDur > maxHalfJump) - { - halfJumpDur /= 2f; - } - halfJumpDur += noteJumpStartBeatOffset; - if (halfJumpDur < 1f) halfJumpDur = 1f; - // halfJumpDur = spawnController.GetPrivateField("_halfJumpDurationInBeats"); - jumpDis = njs * num * halfJumpDur * 2f; - spawnAheadTime = moveDis / moveSpeed + jumpDis * 0.5f / njs; - _spawnController.SetPrivateField("_halfJumpDurationInBeats", halfJumpDur); - _spawnController.SetPrivateField("_spawnAheadTime", spawnAheadTime); - _spawnController.SetPrivateField("_jumpDistance", jumpDis); - // _spawnController.SetPrivateField("_noteJumpMovementSpeed", njs); - _spawnController.SetPrivateField("_moveDistance", moveDis); - - } public static void UpdateSpawnMovementData(float njs, float noteJumpStartBeatOffset) diff --git a/PracticePlugin/PracticePlugin.csproj b/PracticePlugin/PracticePlugin.csproj index 0108afc..c54ed37 100644 --- a/PracticePlugin/PracticePlugin.csproj +++ b/PracticePlugin/PracticePlugin.csproj @@ -121,9 +121,6 @@ - - - diff --git a/PracticePlugin/PracticeUI.cs b/PracticePlugin/PracticeUI.cs index 198ec3f..13aa5e2 100644 --- a/PracticePlugin/PracticeUI.cs +++ b/PracticePlugin/PracticeUI.cs @@ -10,7 +10,7 @@ namespace PracticePlugin { public class PracticeUI : NotifiableSingleton { - private float _speed; + private float _speed = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul; [UIValue("speed")] public float speed { @@ -24,8 +24,9 @@ public float speed void SetSpeed(float value) { speed = value; + Plugin.TimeScale = value; } - private float _njs; + private float _njs = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpMovementSpeed; [UIValue("njs")] public float njs { @@ -39,8 +40,9 @@ public float njs void SetNjs(float value) { njs = value; + UIElementsCreator.NjsController_ValueChangedEvent(value); } - private float _offset; + private float _offset = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; [UIValue("offset")] public float offset { @@ -54,6 +56,7 @@ public float offset void SetSpawnOffset(float value) { offset = value; + UIElementsCreator.SpawnOffsetController_ValueChangedEvent(value); } [UIAction("speedFormatter")] diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 09af40f..e18b1da 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -6,6 +6,8 @@ using UnityEngine.UI; using HMUI; using BeatSaberMarkupLanguage; +using IPA.Logging; +using BS_Utils.Utilities; namespace PracticePlugin { @@ -177,11 +179,14 @@ private void LateUpdate() public void OnDrag(PointerEventData eventData) { + Debug.Log(eventData.position); RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.position, _mainCamera, out var pos); + Debug.Log(eventData.position); var posX = pos.x + HalfSeekBarSize; + Debug.Log(posX); PlaybackPosition = Mathf.InverseLerp(0, SeekBarSize.x, posX); - + Debug.Log(PlaybackPosition); CheckLooperCursorStick(); UpdateCurrentTimeText(PlaybackPosition); } diff --git a/PracticePlugin/SpawnOffsetController.cs b/PracticePlugin/SpawnOffsetController.cs deleted file mode 100644 index 6633328..0000000 --- a/PracticePlugin/SpawnOffsetController.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using UnityEngine; - -namespace PracticePlugin -{ - public class SpawnOffsetController : ListSettingsController - { - public event Action ValueChangedEvent; - - private int _indexOffset; - protected override bool GetInitValues(out int idx, out int numberOfElements) - { - _indexOffset = Plugin.PracticeMode ? 1 : 20; - numberOfElements = 100; - idx = 50 + (int)(10 * UIElementsCreator.currentSpawnOffset); - return true; - } - - protected override void ApplyValue(int idx) - { - } - - protected override string TextForValue(int idx) - { - if (ValueChangedEvent != null) - { - ValueChangedEvent((idx - 50) / 10f); - } - if (((idx - 50) / 10f) == UIElementsCreator.defaultOffset) - return $"{(idx - 50) / 10f}"; - else - return ((idx - 50) /10f).ToString(); - } - } -} \ No newline at end of file diff --git a/PracticePlugin/SpeedSettingsController.cs b/PracticePlugin/SpeedSettingsController.cs deleted file mode 100644 index 04ae407..0000000 --- a/PracticePlugin/SpeedSettingsController.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using UnityEngine; - -namespace PracticePlugin -{ - public class SpeedSettingsController : ListSettingsController - { - public event Action ValueChangedEvent; - - private int _indexOffset; - - protected override bool GetInitValues(out int idx, out int numberOfElements) - { - _indexOffset = Plugin.PracticeMode ? 1 : 20; - numberOfElements = Mathf.RoundToInt(Plugin.SpeedMaxSize / Plugin.SpeedStepSize) - _indexOffset; - //numberOfElements = 0; - //idx = 0; - idx = Mathf.RoundToInt(Plugin.TimeScale / Plugin.SpeedStepSize) - _indexOffset; - return true; - } - - protected override void ApplyValue(int idx) - { - } - - protected override string TextForValue(int idx) - { - if (ValueChangedEvent != null) - { - ValueChangedEvent(Plugin.SpeedStepSize * (idx + _indexOffset)); - } - // return ""; - return Plugin.SpeedStepSize * 100f * (idx + _indexOffset) + "%"; - } - } -} \ No newline at end of file diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 966b32b..f870118 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -9,9 +9,7 @@ namespace PracticePlugin public class UIElementsCreator : MonoBehaviour { public event Action ValueChangedEvent; - public SongSeeker SongSeeker { get; private set; } - internal static float currentNJS; - internal static float currentSpawnOffset; + public static SongSeeker SongSeeker { get; private set; } internal static float defaultNJS; internal static float defaultOffset; @@ -34,10 +32,10 @@ private void InitDelayed() SongSeeker.Init(); new GameObject("No Fail Game Energy").AddComponent(); defaultNJS = Plugin._spawnController.GetPrivateField("_initData").noteJumpMovementSpeed; - currentNJS = defaultNJS; + // PracticeUI.instance.njs = defaultNJS; // Console.WriteLine("NJS: " + UIElementsCreator.defaultNJS); defaultOffset = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpStartBeatOffset; - currentSpawnOffset = defaultOffset; + // PracticeUI.instance.offset = defaultOffset; // Console.WriteLine("Offset: " + UIElementsCreator.defaultOffset); } @@ -45,71 +43,21 @@ private void InitDelayed() private void OnEnable() { - /* - if (_speedSettings == null && Plugin.PracticeMode) - { - _speedSettings = Instantiate(Plugin.SpeedSettingsObject, transform); - _speedSettings.SetActive(true); - - var rectTransform = (RectTransform)_speedSettings.transform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(5, 8); - TextMeshProUGUI settingText = Plugin.CreateText(rectTransform, "Speed (Use at own risk!)", new Vector2(-30f, -2f)); - settingText.fontSize = 6f; - speedController = _speedSettings.GetComponent(); - speedController.ValueChangedEvent += SpeedControllerOnValueChangedEvent; - } - if (_njsSettings == null && Plugin.PracticeMode) - { - _njsSettings = Instantiate(Plugin.NjsSettingsObject, transform); - _njsSettings.SetActive(true); - - var rectTransform = (RectTransform)_njsSettings.transform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(5, 0); - TextMeshProUGUI settingText = Plugin.CreateText(rectTransform, "NJS", new Vector2(-30f, -2f)); - settingText.fontSize = 6f; - njsController = _njsSettings.GetComponent(); - njsController.ValueChangedEvent += NjsController_ValueChangedEvent; - } - if (_offsetSettings == null && Plugin.PracticeMode) - { - _offsetSettings = Instantiate(Plugin.SpawnOffsetSettingsObject, transform); - _offsetSettings.SetActive(true); - - var rectTransform = (RectTransform)_offsetSettings.transform; - rectTransform.anchorMin = Vector2.right * 0.5f; - rectTransform.anchorMax = Vector2.right * 0.5f; - rectTransform.anchoredPosition = new Vector2(5, -8); - TextMeshProUGUI settingText = Plugin.CreateText(rectTransform, "Spawn Offset", new Vector2(-30f, -2f)); - settingText.fontSize = 6f; - spawnOffsetController = _offsetSettings.GetComponent(); - spawnOffsetController.ValueChangedEvent += SpawnOffsetController_ValueChangedEvent; - } - _newTimeScale = Plugin.TimeScale; - njsController.Refresh(true); - spawnOffsetController.Refresh(true); - */ - } - private void SpawnOffsetController_ValueChangedEvent(float offset) + public static void SpawnOffsetController_ValueChangedEvent(float offset) { - currentSpawnOffset = offset; // Plugin.AdjustNjsAndOffset(); - Plugin.UpdateSpawnMovementData(currentNJS, currentSpawnOffset); + Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } - private void NjsController_ValueChangedEvent(float njs) + public static void NjsController_ValueChangedEvent(float njs) { - currentNJS = njs; // Plugin.AdjustNjsAndOffset(); - Plugin.UpdateSpawnMovementData(currentNJS, currentSpawnOffset); + Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } @@ -119,8 +67,8 @@ private void OnDisable() { ValueChangedEvent(_newTimeScale); } - Plugin.UpdateSpawnMovementData(UIElementsCreator.currentNJS, UIElementsCreator.currentSpawnOffset); - // Destroy(_speedSettings); + Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); + // Destroy(_speedSettings); } private void SpeedControllerOnValueChangedEvent(float timeScale) From 1b21a83a6d38a9d440e7d16ebf89e3749c3bea2c Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 17 Oct 2020 23:19:05 -0400 Subject: [PATCH 44/64] Fix Seeker/Looper moving --- PracticePlugin/LooperUI.cs | 19 ++++++++++++++----- PracticePlugin/SongSeeker.cs | 11 +++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/PracticePlugin/LooperUI.cs b/PracticePlugin/LooperUI.cs index c1925cc..6e03e97 100644 --- a/PracticePlugin/LooperUI.cs +++ b/PracticePlugin/LooperUI.cs @@ -58,8 +58,18 @@ public void Init(SongSeeker songSeeker) var tex = Texture2D.whiteTexture; var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1); + var bg = new GameObject("Background").AddComponent(); + var rectTransform = bg.rectTransform; + rectTransform.SetParent(transform, false); + rectTransform.sizeDelta = SongSeeker.SeekBarSize + new Vector2(0, 4); + rectTransform.anchoredPosition = new Vector2(0, -1); + bg.sprite = sprite; + bg.type = Image.Type.Simple; + bg.color = new Color(0, 0, 0, 0); + bg.material = Utilities.ImageResources.NoGlowMat; + _lineDuration = new GameObject("Line Duration").AddComponent(); - var rectTransform = _lineDuration.rectTransform; + rectTransform = _lineDuration.rectTransform; rectTransform.SetParent(transform, false); rectTransform.anchorMin = Vector2.up * 0.5f; rectTransform.anchorMax = Vector2.up * 0.5f; @@ -129,11 +139,10 @@ private void Update() if (_draggingCursor != null) { var eventData = _draggingCursor.EventData; - RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.position, - _mainCamera, out var pos); - var newPos = pos.x + SongSeeker.HalfSeekBarSize; - var seekerPos = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _songSeeker.PlaybackPosition); + var newPos = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, Mathf.InverseLerp(-1, 1, Mathf.Clamp(eventData.position.x, -1f, 1f))); + + var seekerPos = _songSeeker.PlaybackPosition; if (Mathf.Abs(newPos - seekerPos) <= StickToSeekerCursorDistance) { newPos = seekerPos; diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index e18b1da..6b56ab7 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -61,7 +61,8 @@ public void Init() _seekBackg = new GameObject("Background").AddComponent(); rectTransform = _seekBackg.rectTransform; rectTransform.SetParent(transform, false); - rectTransform.sizeDelta = SeekBarSize; + rectTransform.sizeDelta = SeekBarSize + new Vector2(0, 7); + rectTransform.anchoredPosition = new Vector2(0, -1); _seekBackg.sprite = sprite; _seekBackg.type = Image.Type.Simple; _seekBackg.color = BackgroundColor; @@ -180,12 +181,10 @@ private void LateUpdate() public void OnDrag(PointerEventData eventData) { Debug.Log(eventData.position); - RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.position, - _mainCamera, out var pos); - Debug.Log(eventData.position); - var posX = pos.x + HalfSeekBarSize; + + var posX = Mathf.Clamp(eventData.position.x, -1f, 1f); Debug.Log(posX); - PlaybackPosition = Mathf.InverseLerp(0, SeekBarSize.x, posX); + PlaybackPosition = Mathf.InverseLerp(-1, 1, posX); Debug.Log(PlaybackPosition); CheckLooperCursorStick(); UpdateCurrentTimeText(PlaybackPosition); From d8b7148fe82c2a642451c087defb58de5c179aed Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sat, 17 Oct 2020 23:29:00 -0400 Subject: [PATCH 45/64] Update SongSeeker.cs --- PracticePlugin/SongSeeker.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 6b56ab7..7b7ec3c 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -180,12 +180,12 @@ private void LateUpdate() public void OnDrag(PointerEventData eventData) { - Debug.Log(eventData.position); + // Debug.Log(eventData.position); var posX = Mathf.Clamp(eventData.position.x, -1f, 1f); - Debug.Log(posX); + // Debug.Log(posX); PlaybackPosition = Mathf.InverseLerp(-1, 1, posX); - Debug.Log(PlaybackPosition); + // Debug.Log(PlaybackPosition); CheckLooperCursorStick(); UpdateCurrentTimeText(PlaybackPosition); } From 5c8499964c65f27d1c18b48f6a99a5e17b0a8b11 Mon Sep 17 00:00:00 2001 From: AceofShovels Date: Sat, 17 Oct 2020 23:49:10 -0400 Subject: [PATCH 46/64] Fixed Seek Bar function --- PracticePlugin/SongSeeker.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 7b7ec3c..04f6c08 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -8,7 +8,8 @@ using BeatSaberMarkupLanguage; using IPA.Logging; using BS_Utils.Utilities; - +using System.Linq; + namespace PracticePlugin { public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler @@ -45,6 +46,7 @@ public class SongSeeker : MonoBehaviour, IDragHandler, IPointerDownHandler private const float LooperUITopMargin = -5f; private bool init = false; internal int _startTimeSamples; + private float PlayBackPosition = 0.0f; public void Init() { var tex = Texture2D.whiteTexture; @@ -179,13 +181,13 @@ private void LateUpdate() } public void OnDrag(PointerEventData eventData) - { - // Debug.Log(eventData.position); - - var posX = Mathf.Clamp(eventData.position.x, -1f, 1f); - // Debug.Log(posX); - PlaybackPosition = Mathf.InverseLerp(-1, 1, posX); - // Debug.Log(PlaybackPosition); + { + bool hovering = (eventData.hovered.Count() > 0); + if(!hovering) { return; } + + float clampedX = Mathf.Clamp(eventData.position.x, -1.0f, 1.0f); + PlaybackPosition = (clampedX + 1f) * 0.5f; // seekbar position [0.0 - 1.0] + CheckLooperCursorStick(); UpdateCurrentTimeText(PlaybackPosition); } @@ -193,13 +195,11 @@ public void OnDrag(PointerEventData eventData) public void OnPointerDown(PointerEventData eventData) { eventData.useDragThreshold = false; - RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.pressPosition, - _mainCamera, out var pos); - - if (pos.y < 0 || pos.y > SeekBarSize.y) return; + float y = eventData.position.y - GameObject.Find("Seek Bar").transform.position.y; + if (y < -0.03f || y > 0.06) return; - var posX = pos.x + HalfSeekBarSize; - PlaybackPosition = Mathf.InverseLerp(0, SeekBarSize.x, posX); + float clampedX = Mathf.Clamp(eventData.position.x, -1.0f, 1.0f); + PlaybackPosition = (clampedX + 1f) * 0.5f; // seekbar position [0.0 - 1.0] CheckLooperCursorStick(); UpdateCurrentTimeText(PlaybackPosition); From abbe2decd0d5c5404b237d7cab49dd1a14b5f92c Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sun, 18 Oct 2020 10:13:44 -0400 Subject: [PATCH 47/64] Add Hovering check to looper UI --- PracticePlugin/LooperUI.cs | 3 ++- PracticePlugin/SongSeeker.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PracticePlugin/LooperUI.cs b/PracticePlugin/LooperUI.cs index 6e03e97..20fff80 100644 --- a/PracticePlugin/LooperUI.cs +++ b/PracticePlugin/LooperUI.cs @@ -139,7 +139,8 @@ private void Update() if (_draggingCursor != null) { var eventData = _draggingCursor.EventData; - + bool hovering = (eventData.hovered.Count > 0); + if (!hovering) { return; } var newPos = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, Mathf.InverseLerp(-1, 1, Mathf.Clamp(eventData.position.x, -1f, 1f))); var seekerPos = _songSeeker.PlaybackPosition; diff --git a/PracticePlugin/SongSeeker.cs b/PracticePlugin/SongSeeker.cs index 04f6c08..f31c9c9 100644 --- a/PracticePlugin/SongSeeker.cs +++ b/PracticePlugin/SongSeeker.cs @@ -182,7 +182,7 @@ private void LateUpdate() public void OnDrag(PointerEventData eventData) { - bool hovering = (eventData.hovered.Count() > 0); + bool hovering = (eventData.hovered.Count > 0); if(!hovering) { return; } float clampedX = Mathf.Clamp(eventData.position.x, -1.0f, 1.0f); From d9d31e14ce8f32d932b0277185608c57e817719f Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 19 Oct 2020 13:53:06 -0400 Subject: [PATCH 48/64] Update manifest.json --- PracticePlugin/manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index bde9ac3..aa93110 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -2,12 +2,12 @@ "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", "author": "Kyle1413", "description": "Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections.", - "gameVersion": "1.12.1", + "gameVersion": "1.12.2", "id": "PracticePlugin", "name": "PracticePlugin", "version": "4.9.0", "dependsOn": { - "BSIPA": "^4.1.2", + "BSIPA": "^4.1.3", "BS Utils": "^1.3.0", "BeatSaberMarkupLanguage": "^1.1.0" From 1c4c5c1e66bcd7994881dd0581d7f4d0080ce6d8 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Mon, 19 Oct 2020 21:28:34 -0400 Subject: [PATCH 49/64] Update manifest.json --- PracticePlugin/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index aa93110..4210a49 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -9,7 +9,7 @@ "dependsOn": { "BSIPA": "^4.1.3", "BS Utils": "^1.3.0", - "BeatSaberMarkupLanguage": "^1.1.0" + "BeatSaberMarkupLanguage": "^1.4.0" }, "links": { From 8da7394d2cda684f1f79ba0032f6f3747ac9f1fa Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Tue, 20 Oct 2020 21:46:13 -0400 Subject: [PATCH 50/64] Fixes --- PracticePlugin/Plugin.cs | 37 +++++++++++++++-------- PracticePlugin/PracticeUI.bsml | 2 +- PracticePlugin/PracticeUI.cs | 11 ++++++- PracticePlugin/Properties/AssemblyInfo.cs | 4 +-- PracticePlugin/SongSeekBeatmapHandler.cs | 8 ++--- PracticePlugin/UIElementsCreator.cs | 1 + PracticePlugin/manifest.json | 2 +- 7 files changed, 44 insertions(+), 21 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 96eef02..9e18bb1 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -49,6 +49,7 @@ internal static float TimeScale { _timeScale = value; if (!AudioTimeSync) return; + if (!_spawnController) return; AudioTimeSyncController.InitData initData = AudioTimeSync.GetPrivateField("_initData"); AudioTimeSyncController.InitData newInitData = new AudioTimeSyncController.InitData(initData.audioClip, AudioTimeSync.songTime, initData.songTimeOffset, _timeScale); @@ -65,8 +66,8 @@ internal static float TimeScale { _mixer.musicPitch = 1f; } - - AudioTimeSync.StartSong(); + ResetTimeSync(AudioTimeSync, _timeScale, newInitData); + // AudioTimeSync.StartSong(); return; @@ -115,6 +116,17 @@ internal static float TimeScale } } + public static void ResetTimeSync(AudioTimeSyncController timeSync, float newTimeScale, AudioTimeSyncController.InitData newData) + { + + timeSync.SetPrivateField("_timeScale", newTimeScale); + timeSync.SetPrivateField("_startSongTime", timeSync.songTime); + timeSync.SetPrivateField("_audioStartTimeOffsetSinceStart", + timeSync.GetProperty("timeSinceStart") - (timeSync.songTime + newData.songTimeOffset)); + timeSync.SetPrivateField("_fixingAudioSyncError", false); + timeSync.SetPrivateField("_playbackLoopIndex", 0); + timeSync.audioSource.pitch = newTimeScale; + } private static float _timeScale = 1; @@ -192,11 +204,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) BS_Utils.Plugin.LevelDidFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; } - if (_spawnController == null) - { - _spawnController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - } if (_lastLevelId != _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID && !string.IsNullOrEmpty(_lastLevelId)) { @@ -211,11 +219,11 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; - _mixer = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - AudioTimeSync = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + _mixer = Resources.FindObjectsOfTypeAll().LastOrDefault(); + AudioTimeSync = Resources.FindObjectsOfTypeAll().LastOrDefault(); _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); - PracticeMode = (_levelData.Mode == BS_Utils.Gameplay.Mode.Standard && _levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel - && Resources.FindObjectsOfTypeAll().FirstOrDefault() == null); + + PracticeMode = (_levelData.Mode == BS_Utils.Gameplay.Mode.Standard && _levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); if (!PracticeMode) @@ -255,10 +263,16 @@ private void ResultsViewController_didActivateEvent(bool firstActivation, bool a public System.Collections.IEnumerator DelayedSetup() { - yield return new WaitForSeconds(0.2f); + yield return new WaitForSeconds(0.1f); try { + if (_spawnController == null) + { + _spawnController = Resources.FindObjectsOfTypeAll().LastOrDefault(); + + } Console.WriteLine("Atemmpting Practice Plugin UI"); + var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("MenuWrapper").transform.Find("Canvas"); if (canvas == null) @@ -267,7 +281,6 @@ public System.Collections.IEnumerator DelayedSetup() } BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, PracticeUI.instance); - GameObject uiObj = new GameObject("PracticePlugin Seeker UI", typeof(RectTransform)); (uiObj.transform as RectTransform).anchorMin = new Vector2(0, 0); diff --git a/PracticePlugin/PracticeUI.bsml b/PracticePlugin/PracticeUI.bsml index 0e11882..53170fa 100644 --- a/PracticePlugin/PracticeUI.bsml +++ b/PracticePlugin/PracticeUI.bsml @@ -1,6 +1,6 @@  - + diff --git a/PracticePlugin/PracticeUI.cs b/PracticePlugin/PracticeUI.cs index 13aa5e2..28f155c 100644 --- a/PracticePlugin/PracticeUI.cs +++ b/PracticePlugin/PracticeUI.cs @@ -6,10 +6,13 @@ using BeatSaberMarkupLanguage; using BeatSaberMarkupLanguage.Components; using BeatSaberMarkupLanguage.Attributes; +using HMUI; + namespace PracticePlugin { public class PracticeUI : NotifiableSingleton { + private float _speed = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul; [UIValue("speed")] public float speed @@ -24,7 +27,6 @@ public float speed void SetSpeed(float value) { speed = value; - Plugin.TimeScale = value; } private float _njs = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpMovementSpeed; [UIValue("njs")] @@ -74,5 +76,12 @@ string offsetForValue(float value) { return value == UIElementsCreator.defaultOffset ? $"{value.ToString("F2")}" : $"{value.ToString("F2")}"; } + + [UIAction("#post-parse")] + void PostParse() + { + if(gameObject.GetComponent() == null) + gameObject.AddComponent(); + } } } diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 35dfa5f..198d06f 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.9.0.0")] -[assembly: AssemblyFileVersion("4.9.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.9.1.0")] +[assembly: AssemblyFileVersion("4.9.1.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index 1d829f4..939d24c 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -14,7 +14,7 @@ private static List C if (_beatmapObjectCallbackController == null || _callbackList == null) { _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll() - .FirstOrDefault(); + .LastOrDefault(); if (_beatmapObjectCallbackController != null) { @@ -30,13 +30,13 @@ private static List C if (_beatmapObjectSpawnController == null) { _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll() - .FirstOrDefault(); + .LastOrDefault(); } if (_beatmapObjectManager == null) { - _beatmapObjectManager = Resources.FindObjectsOfTypeAll().FirstOrDefault().GetPrivateField("_beatmapObjectManager") as BasicBeatmapObjectManager; + _beatmapObjectManager = Resources.FindObjectsOfTypeAll().LastOrDefault().GetPrivateField("_beatmapObjectManager") as BasicBeatmapObjectManager; if (_beatmapObjectManager != null) { @@ -49,7 +49,7 @@ private static List C if (_noteCutSoundEffectManager == null) { _noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll() - .FirstOrDefault(); + .LastOrDefault(); } } diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index f870118..ce58c17 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -68,6 +68,7 @@ private void OnDisable() ValueChangedEvent(_newTimeScale); } Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); + Plugin.TimeScale = PracticeUI.instance.speed; // Destroy(_speedSettings); } diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 4210a49..4498706 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.12.2", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.9.0", + "version": "4.9.1", "dependsOn": { "BSIPA": "^4.1.3", "BS Utils": "^1.3.0", From 1a097f4bfe3208e5bb8ce63e447ed1592b75ae6c Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Tue, 20 Oct 2020 23:19:32 -0400 Subject: [PATCH 51/64] Update PracticeUI.cs --- PracticePlugin/PracticeUI.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/PracticePlugin/PracticeUI.cs b/PracticePlugin/PracticeUI.cs index 28f155c..aa36b3b 100644 --- a/PracticePlugin/PracticeUI.cs +++ b/PracticePlugin/PracticeUI.cs @@ -21,6 +21,7 @@ public float speed set { _speed = value; + // Plugin.TimeScale = PracticeUI.instance.speed; } } [UIAction("setSpeed")] From 026bed05639d2988d8fffa2dbeac0a61bdceb98c Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Tue, 20 Oct 2020 23:19:35 -0400 Subject: [PATCH 52/64] Update UIElementsCreator.cs --- PracticePlugin/UIElementsCreator.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index ce58c17..9386c44 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -51,14 +51,13 @@ public static void SpawnOffsetController_ValueChangedEvent(float offset) { // Plugin.AdjustNjsAndOffset(); Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); - SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; } public static void NjsController_ValueChangedEvent(float njs) { // Plugin.AdjustNjsAndOffset(); Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); - SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; + } private void OnDisable() @@ -68,7 +67,13 @@ private void OnDisable() ValueChangedEvent(_newTimeScale); } Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); - Plugin.TimeScale = PracticeUI.instance.speed; + if(SongSeeker._songAudioSource.time > 0) + { + SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; + SongSeeker.ApplyPlaybackPosition(); + Plugin.TimeScale = PracticeUI.instance.speed; + } + // Destroy(_speedSettings); } From d20e1abd677b623d27e7833bfdf37ae83e85427c Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Tue, 20 Oct 2020 23:29:18 -0400 Subject: [PATCH 53/64] Update SongSeekBeatmapHandler.cs --- PracticePlugin/SongSeekBeatmapHandler.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index 939d24c..aab0fcd 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -1,4 +1,5 @@ -using System; +using BS_Utils.Utilities; +using System; using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -105,7 +106,13 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) } _beatmapObjectCallbackController.SetPrivateField("_nextEventIndex", newNextEventIndex); - _beatmapObjectManager.DissolveAllObjects(); + // _beatmapObjectManager.DissolveAllObjects(); + var notes = Resources.FindObjectsOfTypeAll().Where(x => x.gameObject.activeInHierarchy); + var walls = Resources.FindObjectsOfTypeAll().Where(x => x.gameObject.activeInHierarchy); + foreach (var note in notes) + _beatmapObjectManager.InvokeMethod("Despawn", note); + foreach (var wall in walls) + _beatmapObjectManager.InvokeMethod("Despawn", wall); /* var notesA = _notePool.activeItems.ToList(); foreach (var noteA in notesA) From 70ad09eac6f520a481af80cb43fed2f0ae228fbd Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Tue, 20 Oct 2020 23:31:59 -0400 Subject: [PATCH 54/64] Version --- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 198d06f..4e5b21c 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.9.1.0")] -[assembly: AssemblyFileVersion("4.9.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.9.2.0")] +[assembly: AssemblyFileVersion("4.9.2.0")] \ No newline at end of file diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index 4498706..a6d0dd9 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.12.2", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.9.1", + "version": "4.9.2", "dependsOn": { "BSIPA": "^4.1.3", "BS Utils": "^1.3.0", From 50cc5fe39a6dcee0710052ebb72fe123ff528fdc Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Wed, 21 Oct 2020 12:27:49 -0400 Subject: [PATCH 55/64] Update Plugin.cs --- PracticePlugin/Plugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 9e18bb1..7b180c7 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -200,7 +200,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) if (_levelData == null) { _levelData = BS_Utils.Plugin.LevelData; - if (_levelData == null) return; + if (!_levelData.IsSet == false) return; BS_Utils.Plugin.LevelDidFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; } From 47a66ef96d6187bc2c7e39fb0ce363d127fdb559 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Wed, 21 Oct 2020 12:29:46 -0400 Subject: [PATCH 56/64] Update Plugin.cs --- PracticePlugin/Plugin.cs | 53 +++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 7b180c7..f2f02a5 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -36,9 +36,9 @@ public class Plugin public string failTime { get; private set; } internal bool showFailTextNext { get; set; } - // public static GameObject SpeedSettingsObject { get; private set; } - // public static GameObject NjsSettingsObject { get; private set; } - // public static GameObject SpawnOffsetSettingsObject { get; private set; } + // public static GameObject SpeedSettingsObject { get; private set; } + // public static GameObject NjsSettingsObject { get; private set; } + // public static GameObject SpawnOffsetSettingsObject { get; private set; } internal static bool startWithFullEnergy = false; internal static bool disablePitchCorrection = false; internal static bool adjustNJSWithSpeed = false; @@ -55,7 +55,7 @@ internal static float TimeScale AudioTimeSync.songTime, initData.songTimeOffset, _timeScale); AudioTimeSync.SetPrivateField("_initData", newInitData); //Chipmunk Removal as per base game - if(!disablePitchCorrection) + if (!disablePitchCorrection) { if (_timeScale == 1f) _mixer.musicPitch = 1; @@ -67,7 +67,7 @@ internal static float TimeScale _mixer.musicPitch = 1f; } ResetTimeSync(AudioTimeSync, _timeScale, newInitData); - // AudioTimeSync.StartSong(); + // AudioTimeSync.StartSong(); return; @@ -94,16 +94,16 @@ internal static float TimeScale } if (AudioTimeSync != null) { - // AudioTimeSync.SetPrivateField("_timeScale", _timeScale); // = _timeScale; - // AudioTimeSync.Init(_songAudio.clip, _songAudio.time, - // AudioTimeSync.GetPrivateField("_songTimeOffset") - AudioTimeSync.GetPrivateField("_audioLatency").value, _timeScale); + // AudioTimeSync.SetPrivateField("_timeScale", _timeScale); // = _timeScale; + // AudioTimeSync.Init(_songAudio.clip, _songAudio.time, + // AudioTimeSync.GetPrivateField("_songTimeOffset") - AudioTimeSync.GetPrivateField("_audioLatency").value, _timeScale); Console.WriteLine("Called TimeScale"); if (_songAudio != null) { _songAudio.pitch = _timeScale; } - // AudioTimeSync.forcedNoAudioSync = true; + // AudioTimeSync.forcedNoAudioSync = true; // float num = AudioTimeSync.GetPrivateField("_startSongTime") + AudioTimeSync.GetPrivateField("_songTimeOffset"); // AudioTimeSync.SetPrivateField("_audioStartTimeOffsetSinceStart", (Time.timeSinceLevelLoad * _timeScale) - num); // AudioTimeSync.SetPrivateField("_fixingAudioSyncError", false); @@ -159,7 +159,7 @@ public void OnApplicationStart() adjustNJSWithSpeed = Config.GetBool("PracticePlugin", "Adjust NJS With Speed", false, true); SceneManager.activeSceneChanged += OnActiveSceneChanged; SceneManager.sceneLoaded += OnSceneLoaded; - + } public void OnSceneLoaded(Scene arg0, LoadSceneMode arg1) @@ -196,28 +196,25 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) else if (newScene.name == GameSceneName) { - - if (_levelData == null) - { - _levelData = BS_Utils.Plugin.LevelData; - if (!_levelData.IsSet == false) return; - BS_Utils.Plugin.LevelDidFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; - } + _levelData = BS_Utils.Plugin.LevelData; + if (!_levelData.IsSet == false) return; + BS_Utils.Plugin.LevelDidFinishEvent -= MainGameSceneSetupDataOnDidFinishEvent; + BS_Utils.Plugin.LevelDidFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; if (_lastLevelId != _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID && !string.IsNullOrEmpty(_lastLevelId)) { PlayingNewSong = true; - // TimeScale = 1; - _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; + // TimeScale = 1; + _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; } else { PlayingNewSong = false; } - + _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; _mixer = Resources.FindObjectsOfTypeAll().LastOrDefault(); AudioTimeSync = Resources.FindObjectsOfTypeAll().LastOrDefault(); @@ -238,7 +235,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) _timeScale = _levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; SharedCoroutineStarter.instance.StartCoroutine(DelayedSetup()); } - + } } @@ -250,7 +247,7 @@ private void ResultsViewController_didActivateEvent(bool firstActivation, bool a if (failText == null) failText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(resultsViewController.rectTransform, failTime, new Vector2(15f, -35f)); else - failText.text = failTime; + failText.text = failTime; failText.richText = true; } else @@ -282,20 +279,20 @@ public System.Collections.IEnumerator DelayedSetup() BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, PracticeUI.instance); GameObject uiObj = new GameObject("PracticePlugin Seeker UI", typeof(RectTransform)); - + (uiObj.transform as RectTransform).anchorMin = new Vector2(0, 0); (uiObj.transform as RectTransform).anchorMax = new Vector2(1, 1); (uiObj.transform as RectTransform).sizeDelta = new Vector2(0, 0); _uiElementsCreator = uiObj.AddComponent(); _uiElementsCreator.Init(); - + uiObj.transform.SetParent(canvas, false); uiObj.transform.localScale = new Vector3(1, 1, 1); uiObj.transform.localPosition = new Vector3(0f, -3f, 0f); - - new GameObject("Practice Plugin Behavior").AddComponent(); + + new GameObject("Practice Plugin Behavior").AddComponent(); if (startWithFullEnergy) { GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll().FirstOrDefault(); @@ -416,11 +413,11 @@ public static void UpdateSpawnMovementData(float njs, float noteJumpStartBeatOff float bpm = _spawnController.GetPrivateField("_variableBpmProcessor").currentBpm; - + if (adjustNJSWithSpeed) { float newNJS = njs * (1 / TimeScale); - njs = newNJS; + njs = newNJS; } From 4801795e6fe75afaca618ffca4ef429fae92f080 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Wed, 21 Oct 2020 12:34:55 -0400 Subject: [PATCH 57/64] Update Plugin.cs --- PracticePlugin/Plugin.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index f2f02a5..bd81dfb 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -164,12 +164,6 @@ public void OnApplicationStart() public void OnSceneLoaded(Scene arg0, LoadSceneMode arg1) { - if (arg0.name == "MenuCore") - { - - } - - } @@ -197,7 +191,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) { _levelData = BS_Utils.Plugin.LevelData; - if (!_levelData.IsSet == false) return; + if (_levelData.IsSet == false) return; BS_Utils.Plugin.LevelDidFinishEvent -= MainGameSceneSetupDataOnDidFinishEvent; BS_Utils.Plugin.LevelDidFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; From bb7b42327165daee43cd7c5f33029a4481566526 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Wed, 21 Oct 2020 14:37:33 -0400 Subject: [PATCH 58/64] Fixes --- PracticePlugin/PracticeUI.cs | 5 ++++- PracticePlugin/SongSeekBeatmapHandler.cs | 17 ++++++++++------- PracticePlugin/UIElementsCreator.cs | 1 - 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/PracticePlugin/PracticeUI.cs b/PracticePlugin/PracticeUI.cs index aa36b3b..f1953d3 100644 --- a/PracticePlugin/PracticeUI.cs +++ b/PracticePlugin/PracticeUI.cs @@ -29,7 +29,10 @@ void SetSpeed(float value) { speed = value; } - private float _njs = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpMovementSpeed; + private float _njs = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpMovementSpeed != 0? + BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.noteJumpMovementSpeed : + BeatmapDifficultyMethods.NoteJumpMovementSpeed(BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.difficulty); + [UIValue("njs")] public float njs { diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index aab0fcd..e5cbe06 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -106,13 +106,16 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) } _beatmapObjectCallbackController.SetPrivateField("_nextEventIndex", newNextEventIndex); - // _beatmapObjectManager.DissolveAllObjects(); - var notes = Resources.FindObjectsOfTypeAll().Where(x => x.gameObject.activeInHierarchy); - var walls = Resources.FindObjectsOfTypeAll().Where(x => x.gameObject.activeInHierarchy); - foreach (var note in notes) - _beatmapObjectManager.InvokeMethod("Despawn", note); - foreach (var wall in walls) - _beatmapObjectManager.InvokeMethod("Despawn", wall); + // _beatmapObjectManager.DissolveAllObjects(); + var notes = _beatmapObjectManager.GetField>("_gameNotePoolContainer"); + var bombs = _beatmapObjectManager.GetField>("_bombNotePoolContainer"); + var walls = _beatmapObjectManager.GetField>("_obstaclePoolContainer"); + foreach (var note in notes.activeItems) + note.Dissolve(0f); + foreach (var bomb in bombs.activeItems) + bomb.Dissolve(0f); + foreach (var wall in walls.activeItems) + wall.Dissolve(0f); /* var notesA = _notePool.activeItems.ToList(); foreach (var noteA in notesA) diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index 9386c44..c35ec08 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -66,7 +66,6 @@ private void OnDisable() { ValueChangedEvent(_newTimeScale); } - Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); if(SongSeeker._songAudioSource.time > 0) { SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; From 1f02fdd2953f2a74670a577e56017ca86ac67674 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Wed, 21 Oct 2020 14:37:56 -0400 Subject: [PATCH 59/64] Version --- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 4e5b21c..7d115aa 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.9.2.0")] -[assembly: AssemblyFileVersion("4.9.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.9.3.0")] +[assembly: AssemblyFileVersion("4.9.3.0")] \ No newline at end of file diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index a6d0dd9..f668521 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.12.2", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.9.2", + "version": "4.9.3", "dependsOn": { "BSIPA": "^4.1.3", "BS Utils": "^1.3.0", From 2de0086cd30533b9cf348dc4f869623efe870b3f Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 22 Oct 2020 12:34:46 -0400 Subject: [PATCH 60/64] Make PracticeUI not singleton --- PracticePlugin/Plugin.cs | 5 ++++- PracticePlugin/PracticeUI.cs | 3 ++- PracticePlugin/UIElementsCreator.cs | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index bd81dfb..e124589 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -271,7 +271,7 @@ public System.Collections.IEnumerator DelayedSetup() Console.WriteLine("Canvas Null"); } - BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, PracticeUI.instance); + GameObject uiObj = new GameObject("PracticePlugin Seeker UI", typeof(RectTransform)); (uiObj.transform as RectTransform).anchorMin = new Vector2(0, 0); @@ -279,6 +279,9 @@ public System.Collections.IEnumerator DelayedSetup() (uiObj.transform as RectTransform).sizeDelta = new Vector2(0, 0); _uiElementsCreator = uiObj.AddComponent(); + var practiceUI = new GameObject("PracticePlugin Adjustment UI").AddComponent(); + UIElementsCreator.practiceUI = practiceUI; + BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, practiceUI); _uiElementsCreator.Init(); uiObj.transform.SetParent(canvas, false); diff --git a/PracticePlugin/PracticeUI.cs b/PracticePlugin/PracticeUI.cs index f1953d3..db4f829 100644 --- a/PracticePlugin/PracticeUI.cs +++ b/PracticePlugin/PracticeUI.cs @@ -7,10 +7,11 @@ using BeatSaberMarkupLanguage.Components; using BeatSaberMarkupLanguage.Attributes; using HMUI; +using UnityEngine; namespace PracticePlugin { - public class PracticeUI : NotifiableSingleton + public class PracticeUI : MonoBehaviour { private float _speed = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul; diff --git a/PracticePlugin/UIElementsCreator.cs b/PracticePlugin/UIElementsCreator.cs index c35ec08..7310973 100644 --- a/PracticePlugin/UIElementsCreator.cs +++ b/PracticePlugin/UIElementsCreator.cs @@ -12,7 +12,7 @@ public class UIElementsCreator : MonoBehaviour public static SongSeeker SongSeeker { get; private set; } internal static float defaultNJS; internal static float defaultOffset; - + internal static PracticeUI practiceUI; internal static float _newTimeScale { get; private set; } = 1f; public void Init() @@ -50,13 +50,13 @@ private void OnEnable() public static void SpawnOffsetController_ValueChangedEvent(float offset) { // Plugin.AdjustNjsAndOffset(); - Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); + Plugin.UpdateSpawnMovementData(practiceUI.njs, practiceUI.offset); } public static void NjsController_ValueChangedEvent(float njs) { // Plugin.AdjustNjsAndOffset(); - Plugin.UpdateSpawnMovementData(PracticeUI.instance.njs, PracticeUI.instance.offset); + Plugin.UpdateSpawnMovementData(practiceUI.njs, practiceUI.offset); } @@ -70,7 +70,7 @@ private void OnDisable() { SongSeeker._startTimeSamples = SongSeeker._songAudioSource.timeSamples - 1; SongSeeker.ApplyPlaybackPosition(); - Plugin.TimeScale = PracticeUI.instance.speed; + Plugin.TimeScale = practiceUI.speed; } // Destroy(_speedSettings); From a612465e9ea9c92c8116e04750fa32e2fcb6f8a6 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Thu, 22 Oct 2020 12:35:12 -0400 Subject: [PATCH 61/64] Version --- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 7d115aa..3e9613f 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.9.3.0")] -[assembly: AssemblyFileVersion("4.9.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.9.4.0")] +[assembly: AssemblyFileVersion("4.9.4.0")] \ No newline at end of file diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index f668521..b6fd042 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -5,7 +5,7 @@ "gameVersion": "1.12.2", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.9.3", + "version": "4.9.4", "dependsOn": { "BSIPA": "^4.1.3", "BS Utils": "^1.3.0", From cc18e4f9208690ccbdeb455409c17ced8a8da8e9 Mon Sep 17 00:00:00 2001 From: Kyle1413 Date: Sun, 24 Jan 2021 19:13:47 -0500 Subject: [PATCH 62/64] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 66c4c25..551b874 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ - The Song will only loop if the red diamond is not at the end of the song - The Speed, NJS, and spawn offset will reset to that of the song upon starting or restarting the song - Note: If you set a starting time for the song using the built in practice mode, the map literally starts at that point, so going back to before the starting point in practice plugin won't have any notes -- Note: It is HEAVILY DISCOURAGED to use base game methods of changing speed in practice mode with practice plugin installed, and only change speed through the pause menu, as currently doing otherwise can cause audio desync --- ## Changelog v4.2.3 From 119224df9e6fc80b251b3fe9294b2409afa8ac1a Mon Sep 17 00:00:00 2001 From: Kylemc1413 Date: Sun, 24 Jan 2021 19:14:11 -0500 Subject: [PATCH 63/64] Update for Beat Saber 1.13.2 --- PracticePlugin/NoFailGameEnergy.cs | 4 ++-- PracticePlugin/Plugin.cs | 2 +- PracticePlugin/Properties/AssemblyInfo.cs | 4 ++-- PracticePlugin/manifest.json | 8 +++----- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/PracticePlugin/NoFailGameEnergy.cs b/PracticePlugin/NoFailGameEnergy.cs index e0f4249..ceb6323 100644 --- a/PracticePlugin/NoFailGameEnergy.cs +++ b/PracticePlugin/NoFailGameEnergy.cs @@ -66,12 +66,12 @@ private IEnumerator LevelFailedRoutine() var waitTime = Time.realtimeSinceStartup + 3; while (Time.realtimeSinceStartup < waitTime) { - _gameEnergyCounter.AddEnergy(-1); + _gameEnergyCounter.ProcessEnergyChange(-1); yield return null; } _levelFailedGameObject.SetActive(false); - _gameEnergyCounter.AddEnergy(0.5f); + _gameEnergyCounter.ProcessEnergyChange(0.5f); _isFailedVisible = false; if (limitLevelFail == true) hasFailed = true; diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index e124589..7dbfb2f 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -294,7 +294,7 @@ public System.Collections.IEnumerator DelayedSetup() { GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll().FirstOrDefault(); if (energyCounter != null) - energyCounter.AddEnergy(1 - energyCounter.energy); + energyCounter.ProcessEnergyChange(1 - energyCounter.energy); } } diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 3e9613f..04e0783 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.9.4.0")] -[assembly: AssemblyFileVersion("4.9.4.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.10.0.0")] +[assembly: AssemblyFileVersion("4.10.0.0")] \ No newline at end of file diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index b6fd042..b080469 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -2,10 +2,10 @@ "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", "author": "Kyle1413", "description": "Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections.", - "gameVersion": "1.12.2", + "gameVersion": "1.13.2", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.9.4", + "version": "4.10.0", "dependsOn": { "BSIPA": "^4.1.3", "BS Utils": "^1.3.0", @@ -15,7 +15,5 @@ "links": { "project-source": "https://github.com/Kylemc1413/PracticePlugin", "donate": "https://ko-fi.com/kyle1413k" - }, - "features": [ - ] + } } From fdcc083d8eeed8126aa0ddfe7dc7cfe2a8a8dce4 Mon Sep 17 00:00:00 2001 From: Kylemc1413 Date: Wed, 12 May 2021 11:51:06 -0400 Subject: [PATCH 64/64] Finally fix pooling issue with custom notes? --- PracticePlugin/Plugin.cs | 2 +- PracticePlugin/Properties/AssemblyInfo.cs | 4 +- PracticePlugin/SongSeekBeatmapHandler.cs | 48 +++++++++++++++++------ PracticePlugin/manifest.json | 4 +- 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/PracticePlugin/Plugin.cs b/PracticePlugin/Plugin.cs index 7dbfb2f..1f82bb2 100644 --- a/PracticePlugin/Plugin.cs +++ b/PracticePlugin/Plugin.cs @@ -215,7 +215,7 @@ public void OnActiveSceneChanged(Scene oldScene, Scene newScene) _songAudio = AudioTimeSync.GetPrivateField("_audioSource"); PracticeMode = (_levelData.Mode == BS_Utils.Gameplay.Mode.Standard && _levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); - + if (!PracticeMode) { diff --git a/PracticePlugin/Properties/AssemblyInfo.cs b/PracticePlugin/Properties/AssemblyInfo.cs index 04e0783..1e3ec17 100644 --- a/PracticePlugin/Properties/AssemblyInfo.cs +++ b/PracticePlugin/Properties/AssemblyInfo.cs @@ -31,5 +31,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("4.10.0.0")] -[assembly: AssemblyFileVersion("4.10.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.12.0.0")] +[assembly: AssemblyFileVersion("4.12.0.0")] \ No newline at end of file diff --git a/PracticePlugin/SongSeekBeatmapHandler.cs b/PracticePlugin/SongSeekBeatmapHandler.cs index e5cbe06..8d07879 100644 --- a/PracticePlugin/SongSeekBeatmapHandler.cs +++ b/PracticePlugin/SongSeekBeatmapHandler.cs @@ -8,7 +8,7 @@ namespace PracticePlugin { public static class SongSeekBeatmapHandler { - private static List CallbackList + private static List CallbackList { get { @@ -21,7 +21,7 @@ private static List C { _callbackList = _beatmapObjectCallbackController - .GetPrivateField>( + .GetPrivateField>( "_beatmapObjectCallbackData"); _beatmapData = _beatmapObjectCallbackController @@ -41,10 +41,10 @@ private static List C if (_beatmapObjectManager != null) { - _notePool = _beatmapObjectManager.GetPrivateField>("_gameNotePoolContainer"); - _bombNotePool = _beatmapObjectManager.GetPrivateField>("_bombNotePoolContainer"); + _notePool = _beatmapObjectManager.GetPrivateField>("_gameNotePoolContainer"); + _bombNotePool = _beatmapObjectManager.GetPrivateField>("_bombNotePoolContainer"); _obstaclePool = - _beatmapObjectManager.GetPrivateField>("_obstaclePoolContainer"); + _beatmapObjectManager.GetPrivateField>("_obstaclePoolContainer"); } } if (_noteCutSoundEffectManager == null) @@ -58,15 +58,15 @@ private static List C } } - private static List _callbackList; + private static List _callbackList; private static BeatmapObjectCallbackController _beatmapObjectCallbackController; private static BeatmapObjectSpawnController _beatmapObjectSpawnController; private static BasicBeatmapObjectManager _beatmapObjectManager; private static NoteCutSoundEffectManager _noteCutSoundEffectManager; - private static MonoMemoryPoolContainer _notePool; - private static MonoMemoryPoolContainer _bombNotePool; - private static MonoMemoryPoolContainer _obstaclePool; + private static MemoryPoolContainer _notePool; + private static MemoryPoolContainer _bombNotePool; + private static MemoryPoolContainer _obstaclePool; private static BeatmapData _beatmapData; @@ -107,15 +107,39 @@ public static void OnSongTimeChanged(float newSongTime, float aheadTime) _beatmapObjectCallbackController.SetPrivateField("_nextEventIndex", newNextEventIndex); // _beatmapObjectManager.DissolveAllObjects(); - var notes = _beatmapObjectManager.GetField>("_gameNotePoolContainer"); - var bombs = _beatmapObjectManager.GetField>("_bombNotePoolContainer"); - var walls = _beatmapObjectManager.GetField>("_obstaclePoolContainer"); + var notes = _beatmapObjectManager.GetField>("_gameNotePoolContainer"); + var bombs = _beatmapObjectManager.GetField>("_bombNotePoolContainer"); + var walls = _beatmapObjectManager.GetField>("_obstaclePoolContainer"); foreach (var note in notes.activeItems) + { + if (note == null) continue; + note.hide = false; + note.pause = false; + note.enabled = true; + note.gameObject.SetActive(true); note.Dissolve(0f); + // _beatmapObjectManager.InvokeMethod("Despawn", note as NoteController); + } foreach (var bomb in bombs.activeItems) + { + if (bomb == null) continue; + bomb.hide = false; + bomb.pause = false; + bomb.enabled = true; + bomb.gameObject.SetActive(true); bomb.Dissolve(0f); + // _beatmapObjectManager.InvokeMethod("Despawn", bomb as NoteController); + } foreach (var wall in walls.activeItems) + { + if (wall == null) continue; + wall.hide = false; + wall.pause = false; + wall.enabled = true; + wall.gameObject.SetActive(true); wall.Dissolve(0f); + //_beatmapObjectManager.InvokeMethod("Despawn", wall); + } /* var notesA = _notePool.activeItems.ToList(); foreach (var noteA in notesA) diff --git a/PracticePlugin/manifest.json b/PracticePlugin/manifest.json index b080469..67cf06b 100644 --- a/PracticePlugin/manifest.json +++ b/PracticePlugin/manifest.json @@ -2,10 +2,10 @@ "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", "author": "Kyle1413", "description": "Plugin for Beat Saber to control playback speed, seek through songs and set up looping sections.", - "gameVersion": "1.13.2", + "gameVersion": "1.13.4", "id": "PracticePlugin", "name": "PracticePlugin", - "version": "4.10.0", + "version": "4.12.0", "dependsOn": { "BSIPA": "^4.1.3", "BS Utils": "^1.3.0",