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 Start() { var currentScore = Score.Current; Debug.Log(currentScore.Point); score.text = ScoreFormatter.Format(currentScore.Point); playTime.text = PlayTimeFormatter.Format(currentScore.PlayTime); }
public void SetSongInfo(SongInfo songInfo, BeatmapDifficulty difficulty) { lastSong = null; _songNameText.text = songInfo.songName; _scoreText.text = ScoreFormatter.Format(0); _difficultyText.text = difficulty.Name(); _rankText.text = "E"; _goodCutsText.text = "0<size=50%> / 0"; _fullComboText.gameObject.SetActive(false); }
public void SetSongInfo(IDifficultyBeatmap songInfo, LevelCompletionResults results) { if (lastSong != songInfo) { lastSong = songInfo; _songNameText.text = $"{songInfo.level.songName} <size=80%>{songInfo.level.songSubName}</size>"; _scoreText.text = ScoreFormatter.Format(results.score); _difficultyText.text = songInfo.difficulty.Name(); _rankText.text = RankModel.GetRankName(results.rank); _goodCutsText.text = $"{results.goodCutsCount}<size=50%> / {songInfo.beatmapData.notesCount}"; _fullComboText.gameObject.SetActive(results.fullCombo); } }
public void SetSongInfo(IDifficultyBeatmap songInfo, LevelCompletionResults results) { if (lastSong != songInfo) { Misc.Logger.Info("Updating song info on results screen!"); lastSong = songInfo; _songNameText.text = $"{songInfo.level.songName} <size=80%>{songInfo.level.songSubName}</size>"; _scoreText.text = ScoreFormatter.Format(results.score); _difficultyText.text = songInfo.difficulty.Name(); _rankText.text = RankModel.GetRankName(results.rank); _goodCutsText.text = $"{results.goodCutsCount}<size=50%> / {songInfo.beatmapData.notesCount}"; _fullComboText.gameObject.SetActive(results.fullCombo); if (IllusionInjector.PluginManager.Plugins.Any(x => x.Name == "BeatSaver Downloader")) { _firstVote = true; _favButton.onClick.RemoveAllListeners(); _favButton.onClick.AddListener(() => ToggleFavorite(songInfo.level.levelID)); BeatSaverDownloaderHelper.LoadDownloaderConfig(); _favButton.interactable = true; _favButton.SetButtonIcon(BeatSaverDownloaderHelper.favoriteSongs.Any(x => x == songInfo.level.levelID) ? Sprites.removeFromFavorites : Sprites.addToFavorites); VoteType vote = BeatSaverDownloaderHelper.GetVoteForSong(songInfo.level.levelID); _upvoteButton.interactable = false; _downvoteButton.interactable = false; _ratingText.text = "LOADING..."; SongDownloader.Instance.RequestSongByLevelID(songInfo.level.levelID.Substring(0, 32), (song) => { _ratingText.text = (int.Parse(song.upvotes) - int.Parse(song.downvotes)).ToString(); _upvoteButton.interactable = (vote != VoteType.Upvote && BeatSaverDownloaderHelper.apiAccessToken != BeatSaverDownloaderHelper.apiTokenPlaceholder); _downvoteButton.interactable = (vote != VoteType.Downvote && BeatSaverDownloaderHelper.apiAccessToken != BeatSaverDownloaderHelper.apiTokenPlaceholder); _upvoteButton.onClick.RemoveAllListeners(); _downvoteButton.onClick.RemoveAllListeners(); _upvoteButton.onClick.AddListener(() => StartCoroutine(VoteForSong(song.id, songInfo.level.levelID, true))); _downvoteButton.onClick.AddListener(() => StartCoroutine(VoteForSong(song.id, songInfo.level.levelID, false))); }); } } }
public void SetSongInfo(SongInfo songInfo, BeatmapDifficulty difficulty) { basicInfoSet = true; _songNameText.text = songInfo.songName; _scoreText.text = ScoreFormatter.Format(0); _difficultyText.text = difficulty.Name(); _rankText.text = "E"; _goodCutsText.text = "0<size=50%> / 0"; _fullComboText.gameObject.SetActive(false); if (IllusionInjector.PluginManager.Plugins.Any(x => x.Name == "BeatSaver Downloader")) { _favButton.interactable = false; _upvoteButton.interactable = false; _downvoteButton.interactable = false; _ratingText.text = ""; } }
public void SetBombCost(ulong cost) { bombCostText.text = ScoreFormatter.CostFormat(cost); }
public void SetScore(ulong score) { scoreText.text = ScoreFormatter.Format(score); }
//static void Postfix(LevelCompletionResults ___levelCompletionResults) static void Postfix(ref ResultsViewControllerPatches __instance) { int maxScore; double resultPercentage; int resultScore; int modifiedScore; // Default Rank Text string rankTextLine1 = __instance._rankText.text; string rankTextLine2 = ""; // Colors string colorPositive = "#00B300"; string colorNegative = "#FF0000"; //Empty for negatives, "+" for positives string positiveIndicator = ""; //Only calculate percentage, if map was successfully cleared if (__instance._levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared) { modifiedScore = __instance._levelCompletionResults.modifiedScore; maxScore = ScorePercentageCommon.calculateMaxScore(__instance._difficultyBeatmap.beatmapData.cuttableNotesType); //use modifiedScore with negative multipliers if (__instance._levelCompletionResults.gameplayModifiers.noFailOn0Energy || (__instance._levelCompletionResults.gameplayModifiers.enabledObstacleType != GameplayModifiers.EnabledObstacleType.All) || __instance._levelCompletionResults.gameplayModifiers.noArrows || __instance._levelCompletionResults.gameplayModifiers.noBombs || __instance._levelCompletionResults.gameplayModifiers.zenMode || __instance._levelCompletionResults.gameplayModifiers.songSpeed == GameplayModifiers.SongSpeed.Slower ) { resultScore = modifiedScore; } //use rawScore without and with positive modifiers to avoid going over 100% without recalculating maxScore else { resultScore = __instance._levelCompletionResults.rawScore; } resultPercentage = ScorePercentageCommon.calculatePercentage(maxScore, resultScore); //disable wrapping and autosize (unneccessary?) __instance._rankText.autoSizeTextContainer = false; __instance._rankText.enableWordWrapping = false; //Rank Text Changes if (PluginConfig.Instance.EnableLevelEndRank) { //Set Percentage to first line rankTextLine1 = "<line-height=27.5%><size=60%>" + resultPercentage.ToString() + "<size=45%>%"; // Add Average Cut Score to 2nd Line if enabled if (PluginConfig.Instance.EnableAvarageCutScore && !PluginConfig.Instance.EnableScorePercentageDifference) { int averageCutScore = __instance._levelCompletionResults.averageCutScore; rankTextLine2 = "\n" + "<size=40%>" + averageCutScore.ToString() + "<size=30%> / <size=0%>115"; } // Add Percent Difference to 2nd Line if enabled and previous Score exists else if (PluginConfig.Instance.EnableScorePercentageDifference && Plugin.scorePercentageCommon.currentPercentage != 0) { double currentPercentage = Plugin.scorePercentageCommon.currentPercentage; double percentageDifference = Math.Round(resultPercentage - currentPercentage, 2); string percentageDifferenceColor; //Better or same Score if (percentageDifference >= 0) { percentageDifferenceColor = colorPositive; positiveIndicator = "+"; } //Worse Score else { percentageDifferenceColor = colorNegative; positiveIndicator = ""; } rankTextLine2 = "\n<color=" + percentageDifferenceColor + "><size=40%>" + positiveIndicator + percentageDifference.ToString() + "<size=30%>%"; } __instance._newHighScoreText.SetActive(false); }//End Preparations for Changes to Rank Text __instance._rankText.text = rankTextLine1 + rankTextLine2; //Add ScoreDifference Calculation if enabled if (PluginConfig.Instance.EnableScoreDifference) { string scoreDifference = ""; string scoreDifferenceColor = ""; int currentScore = Plugin.scorePercentageCommon.currentScore; if (currentScore != 0) { scoreDifference = ScoreFormatter.Format(modifiedScore - currentScore); //Better Score if ((modifiedScore - currentScore) >= 0) { scoreDifferenceColor = colorPositive; positiveIndicator = "+"; } //Worse Score else if ((modifiedScore - currentScore) < 0) { scoreDifferenceColor = colorNegative; positiveIndicator = ""; } //Build new ScoreText string __instance._scoreText.text = "<line-height=27.5%><size=60%>" + ScoreFormatter.Format(modifiedScore) + "\n" + "<size=40%><color=" + scoreDifferenceColor + "><size=40%>" + positiveIndicator + scoreDifference; } } //End ScoreDifference Calculation } //End Level Cleared //Reset currentScore and currentPercentage in case next ResultScreen isn't loaded from StandardLevelDetailView //Does this even do anything!? Plugin.scorePercentageCommon.currentPercentage = 0; Plugin.scorePercentageCommon.currentScore = 0; } //End Postfix Function
public void ScoreFormatterTest_Format_1_234() { Assert.AreEqual("1,234", ScoreFormatter.Format(1234)); }
public void setScoreFormatter(ScoreFormatter sf) { System.Diagnostics.Debug.Assert(sf != null); scoreFormatter = sf; }
public void ScoreFormatterTest_Format_0() { Assert.AreEqual("0", ScoreFormatter.Format(0)); }
public void ScoreFormatterTest_ScoreFormat_1_234_567() { Assert.AreEqual("Cost -1,234,567", ScoreFormatter.CostFormat(1234567)); }
public void ScoreFormatterTest_ScoreFormat_1_234() { Assert.AreEqual("Cost -1,234", ScoreFormatter.CostFormat(1234)); }
public void ScoreFormatterTest_ScoreFormat_1() { Assert.AreEqual("Cost -1", ScoreFormatter.CostFormat(1)); }
public Dashboard(ScoreCalculator scoreCalculator, ScoreFormatter scoreFormatter) { _scoreCalculator = scoreCalculator; _scoreFormatter = scoreFormatter; }
public void ScoreFormatterTest_Format_1() { Assert.AreEqual("1", ScoreFormatter.Format(1)); }