Пример #1
0
        private async void LoadSong(string levelId, Action <IBeatmapLevel> loadedCallback)
        {
            IPreviewBeatmapLevel level = Plugin.masterLevelList.Where(x => x.levelID == levelId).First();

            //Load IBeatmapLevel
            if (level is PreviewBeatmapLevelSO || level is CustomPreviewBeatmapLevel)
            {
                if (level is PreviewBeatmapLevelSO)
                {
                    if (!await SaberUtilities.HasDLCLevel(level.levelID))
                    {
                        return;                                                   //In the case of unowned DLC, just bail out and do nothing
                    }
                }

                var map = ((CustomPreviewBeatmapLevel)level).standardLevelInfoSaveData.difficultyBeatmapSets.First().difficultyBeatmaps.First();

                var result = await SaberUtilities.GetLevelFromPreview(level);

                if (result != null && !(result?.isError == true))
                {
                    loadedCallback(result?.beatmapLevel);
                }
            }
            else if (level is BeatmapLevelSO)
            {
                loadedCallback(level as IBeatmapLevel);
            }
        }
Пример #2
0
        private async void songListView_SelectedIndexChangedAsync(object sender, EventArgs e)
        {
            if (songListView.SelectedItems.Count >= 1)
            {
                var levelID = songListView.SelectedItems[0].ImageKey;
                IPreviewBeatmapLevel level = masterLevelList.Where(x => x.levelID == levelID).First();

                //Clear out old info
                characteristicDropdown.Items.Clear();
                difficultyDropdown.Items.Clear();

                //Callback for when the IBeatmapLevel is loaded
                Action <IBeatmapLevel> SongLoaded = (loadedLevel) =>
                {
                    currentSelection = loadedLevel;

                    loadedLevel.beatmapCharacteristics.ToList().ForEach(x => characteristicDropdown.Items.Add(x.serializedName));
                    characteristicDropdown.SelectedIndex = 0;

                    //We'll assume we've currently selected the 0th checkbox, since, well, we have
                    loadedLevel
                    .beatmapLevelData.difficultyBeatmapSets.First(x => x.beatmapCharacteristic == loadedLevel.beatmapCharacteristics.First())
                    .difficultyBeatmaps.ToList().ForEach(x => difficultyDropdown.Items.Add(x.difficulty));
                    difficultyDropdown.SelectedIndex = difficultyDropdown.Items.Count - 1;
                };

                //Load IBeatmapLevel
                if (level is PreviewBeatmapLevelSO || level is CustomPreviewBeatmapLevel)
                {
                    if (level is PreviewBeatmapLevelSO)
                    {
                        if (!await SaberUtilities.HasDLCLevel(level.levelID))
                        {
                            return;                                                   //In the case of unowned DLC, just bail out and do nothing
                        }
                    }

                    var map = ((CustomPreviewBeatmapLevel)level).standardLevelInfoSaveData.difficultyBeatmapSets.First().difficultyBeatmaps.First();

                    var result = await SaberUtilities.GetLevelFromPreview(level);

                    if (result != null && !(result?.isError == true))
                    {
                        SongLoaded(result?.beatmapLevel);
                    }
                }
                else if (level is BeatmapLevelSO)
                {
                    SongLoaded(level as IBeatmapLevel);
                }
            }
        }