public TableCell CellForIdx(TableView sender, int row)
        {
            LevelListTableCell cell = Instantiate(_songTableCellInstance);

            IPreviewBeatmapLevel song = availableSongs[row];

            song.GetCoverImageTexture2DAsync(new CancellationToken()).ContinueWith((tex) => {
                if (!tex.IsFaulted)
                {
                    cell.SetIcon(tex.Result);
                }
            }).ConfigureAwait(false);

            cell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
            cell.SetSubText(song.songAuthorName + " <size=80%>[" + song.levelAuthorName + "]</size>");

            cell.reuseIdentifier = "SongCell";

            cell.SetPrivateField("_beatmapCharacteristicAlphas", new float[3] {
                song.beatmapCharacteristics.Any(x => x.serializedName == "Standard") ? 1f : 0.1f, song.beatmapCharacteristics.Any(x => x.serializedName == "NoArrows") ? 1f : 0.1f, song.beatmapCharacteristics.Any(x => x.serializedName == "OneSaber") ? 1f : 0.1f
            });
            cell.SetPrivateField("_beatmapCharacteristicImages", cell.GetComponentsInChildren <UnityEngine.UI.Image>().Where(x => x.name.StartsWith("LevelTypeIcon")).ToArray());
            cell.SetPrivateField("_bought", true);

            return(cell);
        }
Esempio n. 2
0
        public void SetSongInfo(SongInfo songInfo)
        {
            _currentSongInfo = songInfo;

            if (_currentSongCell != null)
            {
                IPreviewBeatmapLevel level = SongCore.Loader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(songInfo.levelId));

                if (level == null)
                {
                    _currentSongCell.SetText(_currentSongInfo.songName);
                    _currentSongCell.SetSubText("Loading info...");
                    SongDownloader.Instance.RequestSongByLevelID(_currentSongInfo.hash, (song) =>
                    {
                        _currentSongCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                        _currentSongCell.SetSubText(song.songAuthorName + " <size=80%>[" + song.levelAuthorName + "]</size>");
                        StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { _currentSongCell.SetIcon(cover); }));
                    }
                                                                 );
                }
                else
                {
                    _currentSongCell.SetText($"{level.songName} <size=80%>{level.songSubName}</size>");
                    _currentSongCell.SetSubText(level.songAuthorName + " <size=80%>[" + level.levelAuthorName + "]</size>");

                    level.GetCoverImageTexture2DAsync(new CancellationTokenSource().Token).ContinueWith((tex) => {
                        if (!tex.IsFaulted)
                        {
                            _currentSongCell.SetIcon(tex.Result);
                        }
                    }).ConfigureAwait(false);
                }
            }
        }
        private async void SetBaseGameCoverImageAsync(TableCell tableCell, IPreviewBeatmapLevel level)
        {
            RawImage coverImage = tableCell.GetPrivateField <RawImage>("_coverRawImage");

            Texture2D texture = await level.GetCoverImageTexture2DAsync(CancellationToken.None);

            coverImage.texture = texture;
            coverImage.color   = Color.white;
        }
        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 if (PluginManager.GetPluginFromId("BeatSaverVoting") != null)
            {
                BeatSaverVotingInterop.Hide();
            }

            levelCoverImage.texture = await selectedLevel.GetCoverImageTexture2DAsync(new CancellationTokenSource().Token);
        }
Esempio n. 5
0
        public void SetSong(SongInfo info, Boolean finished)
        {
            if (_songTableCell == null)
            {
                return;
            }

            if (finished)
            {
                var highscore = PluginUI.instance.roomFlowCoordinator.lastHighScore;
                if (highscore == 0)
                {
                    _lastHighscoreText.SetText("No previous highscore");
                }
                else
                {
                    _lastHighscoreText.SetText($"Previous highscore: {highscore}");
                }
                _lastHighscoreText.gameObject.SetActive(true);
            }
            else
            {
                _lastHighscoreText.gameObject.SetActive(false);
            }

            _selectedSong = SongCore.Loader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(info.levelId));

            if (_selectedSong != null)
            {
                _songTableCell.SetText(_selectedSong.songName + " <size=80%>" + _selectedSong.songSubName + "</size>");
                _songTableCell.SetSubText(_selectedSong.songAuthorName + " <size=80%>[" + _selectedSong.levelAuthorName + "]</size>");

                _selectedSong.GetCoverImageTexture2DAsync(new CancellationTokenSource().Token).ContinueWith((tex) =>
                {
                    if (!tex.IsFaulted)
                    {
                        _songTableCell.SetIcon(tex.Result);
                    }
                }).ConfigureAwait(false);
            }
            else
            {
                _songTableCell.SetText(info.songName);
                _songTableCell.SetSubText("Loading info...");
                SongDownloader.Instance.RequestSongByLevelID(info.hash, (song) =>
                {
                    _songTableCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                    _songTableCell.SetSubText(song.songAuthorName + " <size=80%>[" + song.levelAuthorName + "]</size>");
                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { _songTableCell.SetIcon(cover); }));
                });
            }
        }
Esempio n. 6
0
        private async void SetContent(IPreviewBeatmapLevel level)
        {
            songNameText.text       = level.songName;
            durationText.text       = "--";
            bpmText.text            = Mathf.RoundToInt(level.beatsPerMinute).ToString();
            npsText.text            = "--";
            notesCountText.text     = "--";
            obstaclesCountText.text = "--";
            bombsCountText.text     = "--";

            levelCoverImage.texture = await level.GetCoverImageTexture2DAsync(cancellationToken.Token);

            SetLoadingState(false);
        }
Esempio n. 7
0
        public void SetSelectedSong(IPreviewBeatmapLevel level)
        {
            SetLoadingState(false);

            _selectedSong = null;

            _selectedSongCell.SetText(level.songName + " <size=80%>" + level.songSubName + "</size>");
            _selectedSongCell.SetSubText(level.songAuthorName + " <size=80%>[" + level.levelAuthorName + "]</size>");

            _playButton.SetButtonText("NOT BOUGHT");
            _playBtnGlow.color = Color.red;

            level.GetCoverImageTexture2DAsync(new CancellationToken()).ContinueWith((tex) => {
                if (!tex.IsFaulted)
                {
                    _selectedSongCell.SetIcon(tex.Result);
                }
            }).ConfigureAwait(false);

            _timeParamText.transform.parent.gameObject.SetActive(true);
            _bpmParamText.transform.parent.gameObject.SetActive(true);
            _blocksParamText.transform.parent.gameObject.SetActive(true);
            _obstaclesParamText.transform.parent.gameObject.SetActive(true);
            _starsParamText.transform.parent.gameObject.SetActive(true);
            _ratingParamText.transform.parent.gameObject.SetActive(true);

            _rankedText.gameObject.SetActive(true);
            _rankedText.alignment = TextAlignmentOptions.Center;

            _timeParamText.text      = EssentialHelpers.MinSecDurationText(level.songDuration);
            _bpmParamText.text       = level.beatsPerMinute.ToString();
            _blocksParamText.text    = "--";
            _obstaclesParamText.text = "--";
            _starsParamText.text     = "--";
            _ratingParamText.text    = "--";
            _rankedText.text         = "LOADING...";

            _characteristicControl.SetTexts(new string[] { "None" });
            _characteristicControl.SelectCellWithNumber(0);
            _difficultyControl.SetTexts(new string[] { "None" });
            _difficultyControl.SelectCellWithNumber(0);
        }