private void _levelListViewController_didSelectLevelEvent(LevelListViewController sender, IBeatmapLevel beatmap) { if (_difficultyViewController.isInViewControllerHierarchy && _difficultyViewController.selectedDifficultyBeatmap != null && beatmap.levelID.Length >= 32) { ScrappedSong song = ScrappedData.Songs.FirstOrDefault(x => x.Hash == beatmap.levelID.Substring(0, 32)); if (song != null && song.Diffs.Any(x => x.Diff == _difficultyViewController.selectedDifficultyBeatmap.difficulty.ToString())) { _starStatText.text = song.Diffs.First(x => x.Diff == _difficultyViewController.selectedDifficultyBeatmap.difficulty.ToString()).Stars.ToString(); } else { _starStatText.text = "--"; } } else { _starStatText.text = "--"; } }
private static void Tests() { var thing = new ScrappedSong(); Web.HttpClientWrapper.Initialize(5); List <ScrappedSong> scrapedDict; using (StreamReader file = File.OpenText(@"C:\Users\Jared\source\repos\SyncSaberService\SyncSaberService\bin\Debug\ScrapedData\combinedScrappedData.json")) { JsonSerializer serializer = new JsonSerializer(); scrapedDict = (List <ScrappedSong>)serializer.Deserialize(file, typeof(List <ScrappedSong>)); } DownloadJob testJob = new DownloadJob(new SongInfo("111-111", "testName", "", "testAuthor"), "temp", "CustomSongs"); var testTask = testJob.RunJobAsync(); testTask.Wait(); var searchTest = BeatSaverReader.Search("6A097D39A5FA94F3B736E6EEF5A519A2", BeatSaverReader.SearchType.hash); var testReader = new ScoreSaberReader(); var sssongs = testReader.GetSSSongsFromPage(HttpClientWrapper.GetPageText("https://scoresaber.com/api.php?function=get-leaderboards&cat=3&limit=5&page=39&ranked=1")); foreach (var sssong in sssongs) { sssong.PopulateFields(); } var songs = testReader.GetSongsFromFeed(new ScoreSaberFeedSettings(0) { MaxPages = 10 }); SongInfo song = new SongInfo("18750-20381", "test", "testUrl", "testAuthor"); song.PopulateFields(); var test = song["key"]; var test2 = song["id"]; var test3 = song["uploaderId"]; }
private void _levelListViewController_didSelectLevelEvent(LevelPackLevelsViewController sender, IPreviewBeatmapLevel beatmap) { _favoriteButton.SetButtonIcon(PluginConfig.favoriteSongs.Any(x => x.Contains(beatmap.levelID)) ? Sprites.RemoveFromFavorites : Sprites.AddToFavorites); _deleteButton.interactable = !PluginConfig.disableDeleteButton && (beatmap.levelID.Length >= 32); if (beatmap.levelID.Length >= 32) { ScrappedSong song = ScrappedData.Songs.FirstOrDefault(x => x.Hash == beatmap.levelID.Substring(0, 32)); if (song != null && song.Diffs.Any()) { _starStatText.text = song.Diffs.Max(x => x.Stars).ToString(); } else { _starStatText.text = "--"; } } else { _starStatText.text = "--"; } }
public void UpdateContent() { if (_selectedLevel != null) { songNameText.text = _selectedLevel.songName; durationText.text = _selectedLevel.beatmapLevelData.audioClip.length.MinSecDurationText(); bpmText.text = Mathf.RoundToInt(_selectedLevel.beatsPerMinute).ToString(); if (_selectedDifficultyBeatmap != null) { npsText.text = (_selectedDifficultyBeatmap.beatmapData.notesCount / _selectedLevel.beatmapLevelData.audioClip.length).ToString("0.00"); notesCountText.text = _selectedDifficultyBeatmap.beatmapData.notesCount.ToString(); obstaclesCountText.text = _selectedDifficultyBeatmap.beatmapData.obstaclesCount.ToString(); bombsCountText.text = _selectedDifficultyBeatmap.beatmapData.bombsCount.ToString(); var playerLevelStats = _playerDataModel.playerData.GetPlayerLevelStatsData(_selectedDifficultyBeatmap); if (playerLevelStats.validScore) { maxComboValue.text = playerLevelStats.maxCombo.ToString(); highscoreValue.text = playerLevelStats.highScore.ToString(); maxRankValue.text = playerLevelStats.maxRank.ToString(); } else { maxComboValue.text = "--"; highscoreValue.text = "--"; maxRankValue.text = "--"; } string levelHash = SongCore.Collections.hashForLevelID(_selectedLevel.levelID); ScrappedSong scrappedSongData = ScrappedData.Songs.FirstOrDefault(x => x.Hash == levelHash); if (scrappedSongData != default) { DifficultyStats stats = scrappedSongData.Diffs.FirstOrDefault(x => x.Diff == selectedDifficulty.ToString().Replace("+", "Plus")); if (stats != default) { starsText.text = stats.Stars.ToString(); rankingValue.text = $"<color={(stats.Ranked == 0 ? "red" : "green")}>{(stats.Ranked == 0 ? "UNRANKED" : "RANKED")}</color>"; } else { starsText.text = (stats.Stars > float.Epsilon) ? stats.Stars.ToString() : "--"; rankingValue.text = $"<color=red>UNRANKED</color>"; } long votes = scrappedSongData.Upvotes - scrappedSongData.Downvotes; ratingText.text = (votes < 0 ? votes.ToString() : $"+{votes}"); } else { rankingValue.text = $"<color=yellow>NOT FOUND</color>"; starsText.text = "--"; ratingText.text = "--"; } } else { npsText.text = "--"; notesCountText.text = "--"; obstaclesCountText.text = "--"; bombsCountText.text = "--"; maxComboValue.text = "--"; highscoreValue.text = "--"; maxRankValue.text = "--"; rankingValue.text = "--"; starsText.text = "--"; ratingText.text = "--"; } } }