From 0553c477903b57d8db2325a62917caa3a49a9389 Mon Sep 17 00:00:00 2001 From: Petur Darri Petursson Date: Tue, 21 Aug 2018 16:06:44 +0000 Subject: [PATCH] Fixed negative note jump speed. Fixed cover image being mandatory. Made the custom level collections public for other plugins to use. --- SongLoaderPlugin/Plugin.cs | 2 +- SongLoaderPlugin/Properties/AssemblyInfo.cs | 4 +- SongLoaderPlugin/SongLoader.cs | 51 +++++++++++++-------- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/SongLoaderPlugin/Plugin.cs b/SongLoaderPlugin/Plugin.cs index 302016f..ecb6fcc 100644 --- a/SongLoaderPlugin/Plugin.cs +++ b/SongLoaderPlugin/Plugin.cs @@ -6,7 +6,7 @@ namespace SongLoaderPlugin { public class Plugin : IPlugin { - public const string VersionNumber = "v4.3.1"; + public const string VersionNumber = "v4.3.2"; public string Name { diff --git a/SongLoaderPlugin/Properties/AssemblyInfo.cs b/SongLoaderPlugin/Properties/AssemblyInfo.cs index d04db80..714cca1 100644 --- a/SongLoaderPlugin/Properties/AssemblyInfo.cs +++ b/SongLoaderPlugin/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.1")] -[assembly: AssemblyFileVersion("4.3.1")] \ No newline at end of file +[assembly: AssemblyVersion("4.3.2")] +[assembly: AssemblyFileVersion("4.3.2")] \ No newline at end of file diff --git a/SongLoaderPlugin/SongLoader.cs b/SongLoaderPlugin/SongLoader.cs index 7fa2724..9ade8e2 100644 --- a/SongLoaderPlugin/SongLoader.cs +++ b/SongLoaderPlugin/SongLoader.cs @@ -20,9 +20,13 @@ public class SongLoader : MonoBehaviour public static bool AreSongsLoaded { get; private set; } public static bool AreSongsLoading { get; private set; } public static float LoadingProgress { get; private set; } + public static CustomLevelCollectionsForGameplayModes CustomLevelCollectionsForGameplayModes + { + get { return _customLevelCollectionsForGameplayModes; } + } public const string MenuSceneName = "Menu"; - public const string GameSceneName = "StandardLevel"; + public const string GameSceneName = "GameCore"; private static readonly Dictionary LoadedSprites = new Dictionary(); private static readonly Dictionary LoadedAudioClips = new Dictionary(); @@ -32,7 +36,7 @@ public class SongLoader : MonoBehaviour private StandardLevelDetailViewController _standardLevelDetailViewController; private MainGameSceneSetupData _mainGameSceneSetupData; - private CustomLevelCollectionsForGameplayModes _customLevelCollectionsForGameplayModes; + private static CustomLevelCollectionsForGameplayModes _customLevelCollectionsForGameplayModes; private CustomLevelCollectionSO _standardLevelCollection; private CustomLevelCollectionSO _oneSaberLevelCollection; private CustomLevelCollectionSO _noArrowsLevelCollection; @@ -97,7 +101,7 @@ private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode) } StartCoroutine(WaitRemoveScores()); - + if (scene.name == MenuSceneName) { _currentLevelPlaying = null; @@ -123,22 +127,9 @@ private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode) { _currentLevelPlaying = beatmap; - //Beat Saber 0.11.1 introduced a check for if noteJumpMovementSpeed <= 0 - //This breaks songs that have a negative noteJumpMovementSpeed and previously required a patcher to get working again - //I've added this to add support for that again, because why not. - if (_currentLevelPlaying.noteJumpMovementSpeed <= 0) - { - var beatmapObjectSpawnController = - Resources.FindObjectsOfTypeAll().FirstOrDefault(); - if (beatmapObjectSpawnController != null) - { - beatmapObjectSpawnController.Init(_currentLevelPlaying.level.beatsPerMinute, - _currentLevelPlaying.beatmapData.beatmapLinesData.Length, - _currentLevelPlaying.noteJumpMovementSpeed); - } - } + //The note jump movement speed now gets set in the Start method, so we're too early here. We have to wait a bit before overriding. + Invoke(nameof(DelayedNoteJumpMovementSpeedFix), 0.1f); } - if (NoteHitVolumeChanger.PrefabFound) return; var song = CustomLevels.FirstOrDefault(x => x.levelID == level.level.levelID); @@ -147,6 +138,24 @@ private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode) } } + private void DelayedNoteJumpMovementSpeedFix() + { + //Beat Saber 0.11.1 introduced a check for if noteJumpMovementSpeed <= 0 + //This breaks songs that have a negative noteJumpMovementSpeed and previously required a patcher to get working again + //I've added this to add support for that again, because why not. + if (_currentLevelPlaying.noteJumpMovementSpeed <= 0) + { + var beatmapObjectSpawnController = + Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (beatmapObjectSpawnController != null) + { + beatmapObjectSpawnController.Init(_currentLevelPlaying.level.beatsPerMinute, + _currentLevelPlaying.beatmapData.beatmapLinesData.Length, + _currentLevelPlaying.noteJumpMovementSpeed); + } + } + } + private void StandardLevelListViewControllerOnDidSelectLevelEvent(StandardLevelListViewController arg1, IStandardLevel level) { var customLevel = level as CustomLevel; @@ -322,6 +331,12 @@ private void LoadSprite(string spritePath, CustomLevel customLevel) Sprite sprite; if (!LoadedSprites.ContainsKey(spritePath)) { + if (!File.Exists(spritePath)) + { + //Cover image doesn't exist, ignore it. + return; + } + var bytes = File.ReadAllBytes(spritePath); var tex = new Texture2D(256, 256); if (!tex.LoadImage(bytes, true))