示例#1
0
        public async void SetContent(IPreviewBeatmapLevel level)
        {
            songNameText.text = selectedLevel.songName;

            Plugin.log.Debug("Set content called!");
            if (PluginUI.instance.roomFlowCoordinator.levelDifficultyBeatmap != null)
            {
                var diffBeatmap  = PluginUI.instance.roomFlowCoordinator.levelDifficultyBeatmap;
                var levelResults = PluginUI.instance.roomFlowCoordinator.levelResults;

                diffValue.text     = diffBeatmap.difficulty.ToString().Replace("Plus", "+").ToUpper();
                goodCutsValue.text = $"{levelResults.goodCutsCount}<size=50%>/{diffBeatmap.beatmapData.notesCount}</size>";
                maxComboValue.text = $"MAX COMBO {levelResults.maxCombo}";
                scoreValue.text    = ScoreFormatter.Format(levelResults.modifiedScore);
                rankValue.text     = levelResults.rank.ToString();

                if (!PluginUI.instance.roomFlowCoordinator.lastHighscoreValid)
                {
                    scoreChangeValue.text  = "--";
                    scoreChangeValue.color = Color.white;
                    scoreChangeIcon.gameObject.SetActive(false);
                }
                else
                {
                    if (PluginUI.instance.roomFlowCoordinator.lastHighscoreForLevel > levelResults.modifiedScore)
                    {
                        scoreChangeValue.text  = (levelResults.modifiedScore - PluginUI.instance.roomFlowCoordinator.lastHighscoreForLevel).ToString();
                        scoreChangeValue.color = new Color32(240, 38, 31, 255);
                        scoreChangeIcon.gameObject.SetActive(true);
                        scoreChangeIcon.rectTransform.localRotation = Quaternion.Euler(0f, 0f, 0f);
                        scoreChangeIcon.color = new Color32(240, 38, 31, 255);
                    }
                    else
                    {
                        scoreChangeValue.text  = "+" + (levelResults.modifiedScore - PluginUI.instance.roomFlowCoordinator.lastHighscoreForLevel).ToString();
                        scoreChangeValue.color = new Color32(55, 235, 43, 255);
                        scoreChangeIcon.gameObject.SetActive(true);
                        scoreChangeIcon.rectTransform.localRotation = Quaternion.Euler(180f, 0f, 0f);
                        scoreChangeIcon.color = new Color32(55, 235, 43, 255);
                    }
                }


                if (PluginManager.GetPluginFromId("BeatSaverVoting") != null)
                {
                    BeatSaverVotingInterop.Setup(this, PluginUI.instance.roomFlowCoordinator.levelDifficultyBeatmap.level);
                }
            }
            else
            {
                Plugin.log.Warn("Difficulty beatmap is null, unable to set level stats!");

                if (PluginManager.GetPluginFromId("BeatSaverVoting") != null)
                {
                    BeatSaverVotingInterop.Hide();
                }
            }

            levelCoverImage.texture = await selectedLevel.GetCoverImageTexture2DAsync(new CancellationTokenSource().Token);
        }
        public void SetSong(SongInfo info)
        {
            selectedLevel = _beatmapLevelsModel.allLoadedBeatmapLevelPackCollection.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(info.levelId));

            if (selectedLevel != null)
            {
                SetContent(selectedLevel);
            }
            else
            {
                songNameText.text = info.songName;

                levelCoverImage.texture = _defaultArtworkTexture;

                diffValue.text         = "--";
                goodCutsValue.text     = "--";
                maxComboValue.text     = "";
                scoreValue.text        = "--";
                rankValue.text         = "--";
                scoreChangeValue.text  = "--";
                scoreChangeValue.color = Color.white;
                scoreChangeIcon.gameObject.SetActive(false);

                SongDownloader.Instance.RequestSongByLevelID(info.hash, (song) =>
                {
                    songNameText.text = info.songName;

                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { levelCoverImage.texture = cover; }));
                });

                if (PluginManager.GetPluginFromId("BeatSaverVoting") != null)
                {
                    BeatSaverVotingInterop.Hide();
                }
            }
        }