Skip to content

Commit

Permalink
Clean out old Favorites filter code.
Browse files Browse the repository at this point in the history
  • Loading branch information
halsafar committed Jul 11, 2022
1 parent 43e8486 commit b812441
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
5 changes: 3 additions & 2 deletions SongBrowserPlugin/Configuration/SongFilterMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace SongBrowser.Configuration
public enum SongFilterMode
{
None,
Favorites,
Playlist,
Search,
Ranked,
Expand All @@ -18,7 +17,9 @@ public enum SongFilterMode
Expert,
ExpertPlus,
// For other mods that extend SongBrowser
Custom
Custom,
// Deprecated
Favorites
}

static class SongFilterModeMethods
Expand Down
16 changes: 1 addition & 15 deletions SongBrowserPlugin/DataAccess/SongBrowserModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,6 @@ public void ProcessSongList(IAnnotatedBeatmapLevelCollection selectedBeatmapColl
case SongFilterMode.ExpertPlus:
filteredSongs = FilterDifficulty(filteredSongs, (BeatmapDifficulty)Enum.Parse(typeof(BeatmapDifficulty), kvp.Key.ToString()));
break;
case SongFilterMode.Favorites:
filteredSongs = FilterFavorites(filteredSongs);
break;
case SongFilterMode.Search:
filteredSongs = FilterSearch(filteredSongs);
break;
Expand Down Expand Up @@ -425,7 +422,7 @@ public void ProcessSongList(IAnnotatedBeatmapLevelCollection selectedBeatmapColl
}

Plugin.Log.Debug("Creating filtered level pack...");
BeatmapLevelPack levelPack = new BeatmapLevelPack(SongBrowserModel.FilteredSongsCollectionName, packName, selectedBeatmapCollection.collectionName, coverImage, smallCoverImage, new BeatmapLevelCollection(sortedSongs.ToArray()));
BeatmapLevelPack levelPack = new BeatmapLevelPack(SongBrowserModel.FilteredSongsCollectionName, packName, packName, coverImage, smallCoverImage, new BeatmapLevelCollection(sortedSongs.ToArray()));

Plugin.Log.Debug("Acquiring necessary fields to call SetData(pack)...");
LevelCollectionNavigationController lcnvc = navController.GetField<LevelCollectionNavigationController, LevelSelectionNavigationController>("_levelCollectionNavigationController");
Expand All @@ -449,17 +446,6 @@ public void ProcessSongList(IAnnotatedBeatmapLevelCollection selectedBeatmapColl
//_sortedSongs.ForEach(x => Plugin.Log.Debug(x.levelID));
}

/// <summary>
/// Filter songs based on playerdata favorites.
/// </summary>
private List<IPreviewBeatmapLevel> FilterFavorites(List<IPreviewBeatmapLevel> levels)
{
Plugin.Log.Info("Filtering song list as favorites playlist...");

PlayerDataModel playerData = Resources.FindObjectsOfTypeAll<PlayerDataModel>().FirstOrDefault();
return levels.Where(x => playerData.playerData.favoritesLevelIds.Contains(x.levelID)).ToList();
}

/// <summary>
/// Filter for a search query.
/// </summary>
Expand Down

0 comments on commit b812441

Please sign in to comment.