Example #1
0
        public void SetupFromPlaylist(Playlist playlist, IBeatmapLevelPackCollection coll, BeatmapLevelsModel model = null)
        {
            collectionName = playlist.Title;


            HashSet <string> vs = new HashSet <string>();

            for (int i = 0; i < playlist.Maps.Count; i++)
            {
                var map = playlist.Maps[i];
                if (map.Type == BeatmapType.LevelID && !vs.Contains(map.LevelID))
                {
                    vs.Add(map.LevelID);
                }
                else if (map.Type == BeatmapType.Hash && !vs.Contains("custom_level_" + IPA.Utilities.Utils.ByteArrayToString(map.Hash).ToUpper()))
                {
                    vs.Add("custom_level_" + IPA.Utilities.Utils.ByteArrayToString(map.Hash).ToUpper());
                }
                else if (map.Type == BeatmapType.Key && Loader.KeyToHashDB.TryGetValue(map.Key.ToString(), out string hash) && !vs.Contains("custom_level_" + hash.ToUpper()))
                {
                    vs.Add("custom_level_" + hash.ToUpper());
                }
            }
            BeatmapLevelFilterModel.LevelFilterParams levelFilterParams = BeatmapLevelFilterModel.LevelFilterParams.ByBeatmapLevelIds(vs);
            var filtered = BeatmapLevelFilterModel.FilerBeatmapLevelPackCollection(coll, levelFilterParams).beatmapLevels;
            BeatmapLevelCollection collection = new BeatmapLevelCollection(filtered.ToArray());

            beatmapLevelCollection = collection;



            isDirty = false;
        }
Example #2
0
 internal static void Prefix(ref IBeatmapLevelCollection beatmapLevelCollection)
 {
     if (beatmapLevelCollection == null)
     {
         beatmapLevels = new IPreviewBeatmapLevel[0];
     }
     else if (beatmapLevelCollection is BeatSaberPlaylistsLib.Legacy.LegacyPlaylist legacyPlaylist)
     {
         beatmapLevels = legacyPlaylist.BeatmapLevels;
     }
     else if (beatmapLevelCollection is BeatSaberPlaylistsLib.Blist.BlistPlaylist blistPlaylist)
     {
         beatmapLevels = blistPlaylist.BeatmapLevels;
     }
     else
     {
         beatmapLevels = beatmapLevelCollection.beatmapLevels;
     }
 }