Skip to content

Commit

Permalink
Fix PlaylistsLib not being optional but in a different place
Browse files Browse the repository at this point in the history
  • Loading branch information
kinsi55 committed Mar 16, 2022
1 parent 16db380 commit 68f93c4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
56 changes: 28 additions & 28 deletions AppLogic/MapPool.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<IPreviewBeatmapLevel, BeatmapDifficulty[]> 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<IPreviewBeatmapLevel, BeatmapDifficulty[]> 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<IGrouping<IPreviewBeatmapLevel, PlaylistSong>> theThing = null;
IEnumerable<IGrouping<IPreviewBeatmapLevel, BeatSaberPlaylistsLib.Types.PlaylistSong>> theThing = null;

if(x is LegacyPlaylist l) {
theThing = l.BeatmapLevels.Cast<PlaylistSong>().GroupBy(x => x.PreviewBeatmapLevel);
} else if(x is BlistPlaylist bl) {
theThing = bl.BeatmapLevels.Cast<BlistPlaylistSong>().GroupBy(x => x.PreviewBeatmapLevel);
if(x is BeatSaberPlaylistsLib.Legacy.LegacyPlaylist l) {
theThing = l.BeatmapLevels.Cast<BeatSaberPlaylistsLib.Types.PlaylistSong>().GroupBy(x => x.PreviewBeatmapLevel);
} else if(x is BeatSaberPlaylistsLib.Blist.BlistPlaylist bl) {
theThing = bl.BeatmapLevels.Cast<BeatSaberPlaylistsLib.Blist.BlistPlaylistSong>().GroupBy(x => x.PreviewBeatmapLevel);
} else {
return;
return null;
}

playlistSongs = new ConditionalWeakTable<IPreviewBeatmapLevel, BeatmapDifficulty[]>();
var playlistSongs = new ConditionalWeakTable<IPreviewBeatmapLevel, BeatmapDifficulty[]>();

foreach(var xy in theThing) {
if(!Config.Instance.filter_playlist_onlyHighlighted) {
Expand All @@ -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<IPreviewBeatmapLevel, BeatmapDifficulty[]> 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;

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 68f93c4

Please # to comment.