예제 #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;
        }
예제 #2
0
        private void ConfirmDeleteButtonPressed(CustomBeatmapLevel level)
        {
            // scrolling back to the previous position is done by SongListUIAdditions
            // just need to deal with setting up the current pack here
            var currentPack = LevelSelectionNavigationController.GetPrivateField <IBeatmapLevelPack>("_levelPack", typeof(LevelSelectionNavigationController));

            // if the current list of levels does not belong to a level pack, just provide the same levels minus the deleted song
            if (currentPack == null)
            {
                IPreviewBeatmapLevel[] levels            = _levelCollectionTableView.GetPrivateField <IPreviewBeatmapLevel[]>("_previewBeatmapLevels", typeof(LevelCollectionTableView));
                BeatmapLevelCollection replacementLevels = new BeatmapLevelCollection(levels.Where(x => x.levelID != level.levelID).ToArray());

                Loader.Instance.DeleteSong(level.customLevelPath);

                LevelSelectionNavigationController.SetData(
                    replacementLevels,
                    LevelSelectionNavigationController.GetPrivateField <bool>("_showPlayerStatsInDetailView", typeof(LevelSelectionNavigationController)),
                    LevelSelectionNavigationController.GetPrivateField <bool>("_showPracticeButtonInDetailView", typeof(LevelSelectionNavigationController)),
                    null);
            }
            // check if the current level pack is this mod's filtered/sorted level pack
            // if it is, just remove the song from the level pack and show it again
            else if (currentPack.packID == FilteredLevelsLevelPack.PackID || currentPack.packID.Contains(SortedLevelsLevelPack.PackIDSuffix))
            {
                // remove the song from the pack
                var replacementPack = new BeatmapLevelPack(
                    currentPack.packID,
                    currentPack.packName,
                    currentPack.shortPackName,
                    currentPack.coverImage,
                    new BeatmapLevelCollection(currentPack.beatmapLevelCollection.beatmapLevels.Where(x => x.levelID != level.levelID).ToArray()));

                try
                {
                    _isDeletingSongInModOwnedLevelPack = true;
                    Loader.Instance.DeleteSong(level.customLevelPath);
                }
                finally
                {
                    _isDeletingSongInModOwnedLevelPack = false;
                }

                LevelSelectionNavigationController.SetData(
                    replacementPack,
                    true,
                    LevelSelectionNavigationController.GetPrivateField <bool>("_showPlayerStatsInDetailView", typeof(LevelSelectionNavigationController)),
                    LevelSelectionNavigationController.GetPrivateField <bool>("_showPracticeButtonInDetailView", typeof(LevelSelectionNavigationController)));
            }
            // if the current level pack is not from this mod, just delete
            // SongCore should automatically reload the pack
            else
            {
                Loader.Instance.DeleteSong(level.customLevelPath);
            }
        }