private void SetModsText() { var windows = JudgementWindowsDatabaseCache.Selected.Value == JudgementWindowsDatabaseCache.Standard ? "" : $"({JudgementWindowsDatabaseCache.Selected.Value.Name})"; Mods.Text = $"Mods: {ModHelper.GetModsString(ModManager.Mods)} {windows}"; }
/// <summary> /// Creates the text that displays the difficulty name of the map. /// </summary> private void CreateDifficultyName() { var text = $"[{Map.DifficultyName}]"; if (Screen.ScoreProcessor.Mods != 0) { text += $" + {ModHelper.GetModsString(Screen.ScoreProcessor.Mods)}"; } DifficultyName = new SpriteText(Fonts.Exo2SemiBold, text, 13) { Parent = this, X = Thumbnail.X + Thumbnail.Width + 10, Y = 25 }; }
/// <summary> /// Creates the text that displays the difficulty name of the map. /// </summary> private void CreateDifficultyName() { var text = $"[{Map.DifficultyName}]"; var windows = ""; switch (Screen.ResultsType) { case ResultScreenType.Gameplay: if (JudgementWindowsDatabaseCache.Selected.Value.Name != JudgementWindowsDatabaseCache.Standard.Name) { windows = $" ({JudgementWindowsDatabaseCache.Selected.Value.Name})"; } break; case ResultScreenType.Score: if (Screen.Score.JudgementWindowPreset != null && Screen.Score.JudgementWindowPreset != JudgementWindowsDatabaseCache.Standard.Name) { windows = $" ({Screen.Score.JudgementWindowPreset})"; } break; case ResultScreenType.Replay: break; default: break; } if (Screen.ScoreProcessor.Mods != 0) { text += $" + {ModHelper.GetModsString(Screen.ScoreProcessor.Mods)}"; } text += windows; DifficultyName = new SpriteTextBitmap(FontsBitmap.GothamRegular, text) { Parent = this, X = Thumbnail.X + Thumbnail.Width + 14, Y = 14, FontSize = 17 }; }
/// <summary> /// </summary> /// <param name="gameplay"></param> /// <param name="multiplayerScores"></param> /// <param name="multiplayerScreen"></param> public ResultScreen(GameplayScreen gameplay, List <ScoreboardUser> multiplayerScores = null, MultiplayerScreen multiplayerScreen = null) { Gameplay = gameplay; ResultsType = ResultScreenType.Gameplay; ScoreProcessor = Gameplay.Ruleset.ScoreProcessor; MultiplayerScores = multiplayerScores; MultiplayerScreen = multiplayerScreen; InitializeIfGameplayType(); ChangeDiscordPresence(); if (MultiplayerScores != null) { Logger.Important($"Multiplayer Player Game Finished!", LogType.Network); MultiplayerScores.ForEach(x => { var modsString = "None"; try { modsString = ModHelper.GetModsString(x.Processor.Mods); } catch (Exception) { // ignored } Logger.Important($"{(x.UsernameRaw)}: {x.Processor.Score}, {x.Processor.Accuracy}, " + $"{x.Processor.TotalJudgementCount}, {x.RatingProcessor.CalculateRating(x.Processor)} | " + $"{modsString}", LogType.Network); }); } View = new ResultScreenView(this); CacheMultiplayerScoreContainers(); }
/// <summary> /// Called when the activated mods change. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnModsChanged(object sender, ModsChangedEventArgs e) => Mods.Text = $"Mods: {ModHelper.GetModsString(e.Mods)}";
/// <summary> /// Creates the text that displays the mods. /// </summary> private void CreateMods() => Mods = new SpriteText(Fonts.Exo2Bold, "Mods: " + ModHelper.GetModsString(ModManager.Mods), 12) { Parent = this, Alignment = Alignment.TopLeft, X = MapDifficultyName.X, Y = 15 };
/// <summary> /// Ctor - /// </summary> /// <param name="screen"></param> internal SongInformation(GameplayScreen screen) { Screen = screen; Size = new ScalableVector2(750, 150); Tint = Colors.MainAccentInactive; Alpha = 0; // Create watching text outside of replay mode because other text relies on it. Watching = new SpriteText(Fonts.SourceSansProSemiBold, $"Watching {(screen.InReplayMode ? Screen.LoadedReplay.PlayerName : "")}", 13) { Parent = this, Alignment = Alignment.TopCenter, Y = 25, Alpha = 0 }; Title = new SpriteText(Fonts.SourceSansProSemiBold, $"{Screen.Map.Artist} - {Screen.Map.Title}", 13) { Parent = this, Alignment = Alignment.TopCenter, Y = Watching.Y + TextYSpacing + TextYSpacing, Alpha = 0, }; Difficulty = new SpriteText(Fonts.SourceSansProSemiBold, $"[{Screen.Map.DifficultyName}]", 13) { Parent = this, Alignment = Alignment.TopCenter, Y = Title.Y + TextYSpacing + TextYSpacing * 0.85f, Alpha = 0 }; Creator = new SpriteText(Fonts.SourceSansProSemiBold, $"Mapped By: \"{Screen.Map.Creator}\"", 13) { Parent = this, Alignment = Alignment.TopCenter, Y = Difficulty.Y + TextYSpacing + TextYSpacing * 0.80f, Alpha = 0 }; var difficulty = (float)MapManager.Selected.Value.DifficultyFromMods(ModManager.Mods); Rating = new SpriteText(Fonts.SourceSansProSemiBold, $"Difficulty: {StringHelper.AccuracyToString(difficulty).Replace("%", "")}", 13) { Parent = this, Alignment = Alignment.TopCenter, Y = Creator.Y + TextYSpacing + TextYSpacing * 0.75f, Alpha = 0, Tint = ColorHelper.DifficultyToColor(difficulty) }; // Get a formatted string of the activated mods. var modsString = "Mods: " + (ModManager.CurrentModifiersList.Count > 0 ? $"{ModHelper.GetModsString(ModManager.Mods)}" : "None"); Mods = new SpriteText(Fonts.SourceSansProSemiBold, modsString, 13) { Parent = this, Alignment = Alignment.TopCenter, Y = Rating.Y + TextYSpacing + TextYSpacing * 0.7f, Alpha = 0 }; }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="item"></param> /// <param name="index"></param> public override void UpdateContent(OnlineUser item, int index) { if (!OnlineManager.OnlineUsers.ContainsKey(item.Id)) { Logger.Error($"{item.Id} not found in online users when trying to update content.", LogType.Network); return; } Avatar.Border.Tint = GetPlayerColor(); Button.Image = GetPlayerPanel(); if (OnlineManager.OnlineUsers[item.Id].HasUserInfo) { var stats = OnlineManager.OnlineUsers[Item.Id].Stats; var rank = stats.ContainsKey((GameMode)OnlineManager.CurrentGame.GameMode) ? $" (#{stats[(GameMode) OnlineManager.CurrentGame.GameMode].Rank})" : ""; Username.Text = item.Username + rank; HostCrown.X = Username.Width + 12; // Handle getting the amount of wins the player has if (OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team) { var team = OnlineManager.GetTeam(Item.Id); int wins; switch (team) { case MultiplayerTeam.Red: wins = OnlineManager.CurrentGame.RedTeamWins; break; case MultiplayerTeam.Blue: wins = OnlineManager.CurrentGame.BlueTeamWins; break; default: throw new ArgumentOutOfRangeException(); } Wins.Text = $"{wins} Wins"; } else { var mpWins = OnlineManager.CurrentGame.PlayerWins.Find(x => x.UserId == item.Id); Wins.Text = mpWins != null ? $"{mpWins.Wins} Wins" : $"0 Wins"; } var playerMods = OnlineManager.CurrentGame.PlayerMods.Find(x => x.UserId == item.Id); var mods = (ModIdentifier)long.Parse(OnlineManager.CurrentGame.Modifiers); if (mods == ModIdentifier.None) { mods = 0; } if (playerMods != null) { var pmods = long.Parse(playerMods.Modifiers); if (pmods < 0) { pmods = 0; } mods |= (ModIdentifier)pmods; } Mods.Text = mods <= 0 ? "" : ModHelper.GetModsString(mods); Flag.Y = mods <= 0 ? 0 : -8; } HostCrown.Visible = OnlineManager.CurrentGame.HostId == Item.Id; }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="container"></param> /// <param name="item"></param> /// <param name="index"></param> /// <param name="header"></param> public ResultMultiplayerScoreboardUser(PoolableScrollContainer <ScoreboardUser> container, ScoreboardUser item, int index, ResultMultiplayerScoreboardTableHeader header) : base(container, item, index) { Header = header; Size = new ScalableVector2(container.Width, HEIGHT); Alpha = 0.85f; Button = new ResultMultiplayerScoreboardUserButton(Item, container) { Parent = this, Size = Size, UsePreviousSpriteBatchOptions = true }; // ReSharper disable once ObjectCreationAsStatement var rank = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{item.Rank}.") { Parent = this, Alignment = Alignment.MidLeft, X = 20, FontSize = 16, Tint = Item.Type == ScoreboardUserType.Self ? Colors.SecondaryAccent : Color.White, UsePreviousSpriteBatchOptions = true }; var avatar = new Sprite { Parent = this, Alignment = Alignment.MidLeft, Size = new ScalableVector2(32, 32), X = 56, Image = item.Avatar.Image, UsePreviousSpriteBatchOptions = true }; avatar.AddBorder(Color.White, 2); var username = new SpriteTextBitmap(FontsBitmap.GothamRegular, item.UsernameRaw) { Parent = this, Alignment = Alignment.MidLeft, X = avatar.X + avatar.Width + 16, FontSize = 16, Tint = Item.Type == ScoreboardUserType.Self ? Colors.SecondaryAccent : Color.White, UsePreviousSpriteBatchOptions = true }; if (item.Processor == null) { return; } CreateData(new Dictionary <string, string> { { "Rating", item.CalculateRating().ToString("00.00") }, { "Grade", "" }, { "Accuracy", StringHelper.AccuracyToString(item.Processor.Accuracy) }, { "Max Combo", item.Processor.MaxCombo + "x" }, { "Marv", item.Processor.CurrentJudgements[Judgement.Marv].ToString() }, { "Perf", item.Processor.CurrentJudgements[Judgement.Perf].ToString() }, { "Great", item.Processor.CurrentJudgements[Judgement.Great].ToString() }, { "Good", item.Processor.CurrentJudgements[Judgement.Good].ToString() }, { "Okay", item.Processor.CurrentJudgements[Judgement.Okay].ToString() }, { "Miss", item.Processor.CurrentJudgements[Judgement.Miss].ToString() }, { "Mods", item.Processor.Mods <= 0 ? "None" : ModHelper.GetModsString(ModHelper.GetModsFromRate(ModHelper.GetRateFromMods(item.Processor.Mods))) } }); // ReSharper disable once ObjectCreationAsStatement new Sprite { Parent = this, Alignment = Alignment.BotLeft, Size = new ScalableVector2(Width, 1), Alpha = 0.3f }; }
/// <summary> /// Sets rich presence based on which activity we're doing in gameplay. /// </summary> public void SetRichPresence() { DiscordHelper.Presence.Details = Map.ToString(); if (OnlineManager.CurrentGame != null) { if (OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Battle_Royale) { var view = View as GameplayScreenView; var alivePlayers = OnlineManager.CurrentGame.Players.Count; if (view?.ScoreboardLeft != null) { alivePlayers = view.ScoreboardLeft.Users.FindAll(x => !x.Processor.MultiplayerProcessor.IsBattleRoyaleEliminated).Count; } DiscordHelper.Presence.State = $"Battle Royale - {alivePlayers} Left"; } else { DiscordHelper.Presence.State = $"{OnlineManager.CurrentGame.Name} " + $"({OnlineManager.CurrentGame.PlayerIds.Count} of {OnlineManager.CurrentGame.MaxPlayers})"; } } else if (IsPlayTesting) { DiscordHelper.Presence.State = "Play Testing"; } else if (InReplayMode) { DiscordHelper.Presence.State = OnlineManager.IsSpectatingSomeone ? $"Spectating {LoadedReplay.PlayerName}" : $"Watching {LoadedReplay.PlayerName}"; } else { DiscordHelper.Presence.State = $"Playing {(ModManager.Mods > 0 ? "+ " + ModHelper.GetModsString(ModManager.Mods) : "")}"; } // Only set time if we're not spectating anywone if (!OnlineManager.IsSpectatingSomeone) { var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var time = Convert.ToInt64((DateTime.UtcNow.AddMilliseconds((Map.Length - Timing.Time) / AudioEngine.Track.Rate) - epoch).TotalSeconds); DiscordHelper.Presence.EndTimestamp = time; } DiscordHelper.Presence.LargeImageText = OnlineManager.GetRichPresenceLargeKeyText(Ruleset.Mode); DiscordRpc.UpdatePresence(ref DiscordHelper.Presence); }
/// <summary> /// Sets rich presence based on which activity we're doing in gameplay. /// </summary> private void SetRichPresence() { DiscordHelper.Presence.Details = Map.ToString(); if (InReplayMode) { DiscordHelper.Presence.State = $"Watching {LoadedReplay.PlayerName}"; } else { DiscordHelper.Presence.State = $"Playing {(ModManager.Mods > 0 ? "+ " + ModHelper.GetModsString(ModManager.Mods) : "")}"; } var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var time = Convert.ToInt64((DateTime.UtcNow.AddMilliseconds((Map.Length - Timing.Time) / AudioEngine.Track.Rate) - epoch).TotalSeconds); DiscordHelper.Presence.EndTimestamp = time; DiscordHelper.Presence.LargeImageText = OnlineManager.GetRichPresenceLargeKeyText(Ruleset.Mode); DiscordRpc.UpdatePresence(ref DiscordHelper.Presence); }
/// <summary> /// Creates the text that displays the mods. /// </summary> private void CreateMods() => Mods = new SpriteTextBitmap(FontsBitmap.GothamBold, "Mods: " + ModHelper.GetModsString(ModManager.Mods)) { Parent = this, Alignment = Alignment.TopLeft, X = MapDifficultyName.X, Y = 15, FontSize = 16 };