private void songSelection_SongSelected(GameplayParameters parameters)
        {
            _currentParameters = parameters;

            SongUtils.LoadSong(parameters.Beatmap.LevelId, (loadedLevel) =>
            {
                PresentViewController(_songDetail, () =>
                {
                    _songDetail.SetSelectedSong(loadedLevel);
                    _songDetail.SetSelectedDifficulty((int)parameters.Beatmap.Difficulty);
                    _songDetail.SetSelectedCharacteristic(parameters.Beatmap.Characteristic.SerializedName);

                    if (_globalLeaderboard == null)
                    {
                        _globalLeaderboard      = Resources.FindObjectsOfTypeAll <PlatformLeaderboardViewController>().First();
                        _globalLeaderboard.name = "Global Leaderboard";
                    }

                    _globalLeaderboard.SetData(SongUtils.GetClosestDifficultyPreferLower(loadedLevel, (BeatmapDifficulty)(int)parameters.Beatmap.Difficulty, parameters.Beatmap.Characteristic.SerializedName));
                    SetRightScreenViewController(_globalLeaderboard, ViewController.AnimationType.In);

                    _customLeaderboard = BeatSaberUI.CreateViewController <CustomLeaderboard>();
                    PlayerUtils.GetPlatformUserData(RequestLeaderboardWhenResolved);
                    SetLeftScreenViewController(_customLeaderboard, ViewController.AnimationType.In);
                });
            });
        }
Exemple #2
0
        public async void SetBeatmapLevel(IBeatmapLevel beatmapLevel)
        {
            if (beatmapLevel.beatmapLevelData.difficultyBeatmapSets.Any(x => x.beatmapCharacteristic == _playerDataModel.playerData.lastSelectedBeatmapCharacteristic))
            {
                _selectedDifficultyBeatmap = SongUtils.GetClosestDifficultyPreferLower(beatmapLevel, _playerDataModel.playerData.lastSelectedBeatmapDifficulty, _playerDataModel.playerData.lastSelectedBeatmapCharacteristic.serializedName);
            }
            else if (beatmapLevel.beatmapLevelData.difficultyBeatmapSets.Length > 0)
            {
                _selectedDifficultyBeatmap = SongUtils.GetClosestDifficultyPreferLower(beatmapLevel, _playerDataModel.playerData.lastSelectedBeatmapDifficulty, "Standard");
            }

            UpdateContent();

            _playerDataModel.playerData.SetLastSelectedBeatmapCharacteristic(_selectedDifficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
            _playerDataModel.playerData.SetLastSelectedBeatmapDifficulty(_selectedDifficultyBeatmap.difficulty);

            SetControlData(_selectedLevel.beatmapLevelData.difficultyBeatmapSets, _playerDataModel.playerData.lastSelectedBeatmapCharacteristic);

            levelCoverImage.texture = await beatmapLevel.GetCoverImageTexture2DAsync(cancellationToken.Token);
        }
Exemple #3
0
        public void SetSelectedCharacteristic(IconSegmentedControl _, int index)
        {
            _playerDataModel.playerData.SetLastSelectedBeatmapCharacteristic(_beatmapCharacteristics[index]);

            var diffBeatmaps      = _selectedLevel.beatmapLevelData.GetDifficultyBeatmapSet(_beatmapCharacteristics[index]).difficultyBeatmaps;
            var closestDifficulty = SongUtils.GetClosestDifficultyPreferLower(_selectedLevel, _playerDataModel.playerData.lastSelectedBeatmapDifficulty, _beatmapCharacteristics[index].serializedName);

            var extraData = Collections.RetrieveExtraSongData(Collections.hashForLevelID(_selectedLevel.levelID));

            if (extraData != null)
            {
                string[] difficultyLabels = new string[diffBeatmaps.Length];

                var extraDifficulties = extraData._difficulties.Where(x => x._beatmapCharacteristicName == _beatmapCharacteristics[index].serializedName || x._beatmapCharacteristicName == _beatmapCharacteristics[index].characteristicNameLocalizationKey);

                for (int i = 0; i < diffBeatmaps.Length; i++)
                {
                    var customDiff = extraDifficulties.FirstOrDefault(x => x._difficulty == diffBeatmaps[i].difficulty);
                    if (customDiff != null && !string.IsNullOrEmpty(customDiff._difficultyLabel))
                    {
                        difficultyLabels[i] = customDiff._difficultyLabel;
                    }
                    else
                    {
                        difficultyLabels[i] = diffBeatmaps[i].difficulty.ToString().Replace("Plus", "+");
                    }
                }

                difficultyControl.SetTexts(difficultyLabels);
            }
            else
            {
                difficultyControl.SetTexts(diffBeatmaps.Select(x => x.difficulty.ToString().Replace("Plus", "+")).ToArray());
            }

            var diffIndex = Array.FindIndex(diffBeatmaps, x => x.difficulty == closestDifficulty.difficulty);

            difficultyControl.SelectCellWithNumber(diffIndex);
            SetSelectedDifficulty(null, diffIndex);
        }
Exemple #4
0
        private void SongListRowSelected(Song song)
        {
            Action <IBeatmapLevel> songLoaded = (level) =>
            {
                song.Beatmap = SongUtils.GetClosestDifficultyPreferLower(level, (BeatmapDifficulty)(int)song.Difficulty, song.Characteristic);

                //Open up the custom/global leaderboard pane when we need to
                if (_communityLeaderboard == null)
                {
                    _communityLeaderboard              = BeatSaberUI.CreateViewController <CustomLeaderboardController>();
                    _communityLeaderboard.PlayPressed += SongPlayPressed;
                }
                SetLeftScreenViewController(_communityLeaderboard);

                if (_globalLeaderboard == null)
                {
                    _globalLeaderboard      = Resources.FindObjectsOfTypeAll <PlatformLeaderboardViewController>().First();
                    _globalLeaderboard.name = "Community Global Leaderboard";
                }

                //Change global leaderboard view
                _globalLeaderboard.SetData(song.Beatmap);

                SetRightScreenViewController(_globalLeaderboard);

                //Change community leaderboard view
                //Use the currently selected team, if it exists
                //TODO: Reimplement?
                //int teamIndex = _communityLeaderboard.selectedTeamIndex;
                //if (teamIndex <= -1) teamIndex = Team.allTeams.FindIndex(x => x.TeamId == Player.Instance.Team);
                _communityLeaderboard.SetSong(song, -1);
            };

            //When the row is selected, load the beatmap
            SongUtils.LoadSong(song.PreviewBeatmap, songLoaded);
        }