From 68f93c4489762a074aad7f149d38c26c68066694 Mon Sep 17 00:00:00 2001 From: Kinsi Date: Wed, 16 Mar 2022 16:03:20 +0100 Subject: [PATCH] Fix PlaylistsLib not being optional but in a different place --- AppLogic/MapPool.cs | 56 ++++++++++++++++++++++----------------------- README.md | 1 + 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/AppLogic/MapPool.cs b/AppLogic/MapPool.cs index 0ab9054..15a15c1 100644 --- a/AppLogic/MapPool.cs +++ b/AppLogic/MapPool.cs @@ -1,7 +1,4 @@ -using BeatSaberPlaylistsLib.Blist; -using BeatSaberPlaylistsLib.Legacy; -using BeatSaberPlaylistsLib.Types; -using Shaffuru.MenuLogic; +using Shaffuru.MenuLogic; using SiraUtil.Zenject; using SongDetailsCache; using System; @@ -68,38 +65,25 @@ public void Clear() { public void Dispose() => Clear(); - public async Task ProcessBeatmapPool() { - var minLength = Config.Instance.jumpcut_enabled ? Math.Max(Config.Instance.filter_minSeconds, Config.Instance.jumpcut_minSeconds) : Config.Instance.filter_minSeconds; - - var maps = beatmapLevelsModel - .allLoadedBeatmapLevelPackCollection.beatmapLevelPacks - .Where(x => !(x is PreviewBeatmapLevelPackSO)) - .SelectMany(x => x.beatmapLevelCollection.beatmapLevels); - - allLevels = maps.ToArray(); - - maps = maps.Where(x => x.songDuration - x.songTimeOffset >= minLength); - - ConditionalWeakTable playlistSongs = null; - - // Wrapping this to prevent missing symbol stuff if no bsplaylistlib - void FilterInPlaylist() { + // Wrapping this to prevent missing symbol stuff if no bsplaylistlib + static class TheJ { + public static ConditionalWeakTable GetAllSongsInSelectedPlaylist() { // This implementation kinda pains me from an overhead standpoint but its the simplest I could come up with var x = BeatSaberPlaylistsLib.PlaylistManager.DefaultManager .GetAllPlaylists(true) .FirstOrDefault(x => x.packName == Config.Instance.filter_playlist); - IEnumerable> theThing = null; + IEnumerable> theThing = null; - if(x is LegacyPlaylist l) { - theThing = l.BeatmapLevels.Cast().GroupBy(x => x.PreviewBeatmapLevel); - } else if(x is BlistPlaylist bl) { - theThing = bl.BeatmapLevels.Cast().GroupBy(x => x.PreviewBeatmapLevel); + if(x is BeatSaberPlaylistsLib.Legacy.LegacyPlaylist l) { + theThing = l.BeatmapLevels.Cast().GroupBy(x => x.PreviewBeatmapLevel); + } else if(x is BeatSaberPlaylistsLib.Blist.BlistPlaylist bl) { + theThing = bl.BeatmapLevels.Cast().GroupBy(x => x.PreviewBeatmapLevel); } else { - return; + return null; } - playlistSongs = new ConditionalWeakTable(); + var playlistSongs = new ConditionalWeakTable(); foreach(var xy in theThing) { if(!Config.Instance.filter_playlist_onlyHighlighted) { @@ -119,10 +103,26 @@ void FilterInPlaylist() { ); } + return playlistSongs; } + } + + public async Task ProcessBeatmapPool() { + var minLength = Config.Instance.jumpcut_enabled ? Math.Max(Config.Instance.filter_minSeconds, Config.Instance.jumpcut_minSeconds) : Config.Instance.filter_minSeconds; + + var maps = beatmapLevelsModel + .allLoadedBeatmapLevelPackCollection.beatmapLevelPacks + .Where(x => !(x is PreviewBeatmapLevelPackSO)) + .SelectMany(x => x.beatmapLevelCollection.beatmapLevels); + + allLevels = maps.ToArray(); + + maps = maps.Where(x => x.songDuration - x.songTimeOffset >= minLength); + + ConditionalWeakTable playlistSongs = null; if(IPA.Loader.PluginManager.GetPluginFromId("BeatSaberPlaylistsLib") != null) - FilterInPlaylist(); + playlistSongs = TheJ.GetAllSongsInSelectedPlaylist(); var allowME = Config.Instance.filter_AllowME && IPA.Loader.PluginManager.GetPluginFromId("MappingExtensions") != null; diff --git a/README.md b/README.md index 973d006..3efbfa5 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ For now - **Make sure to not use any mods that disable score submission** as tha - **BeatSaberMarkupLanguage** - **SongDetailsCache** - **CatCore** (Optional, only needed if you want Chat requests to work) +- **BeatSaberPlaylistsLib** (Optional, only needed for playlist filtering) ## How to Play