/// <summary> /// Creates the scoreboard for the game. /// </summary> private void CreateScoreboards() { // Use the replay's name for the scoreboard if we're watching one. var scoreboardName = Screen.InReplayMode ? Screen.LoadedReplay.PlayerName : ConfigManager.Username.Value; var selfAvatar = ConfigManager.Username.Value == scoreboardName ? SteamManager.UserAvatars[SteamUser.GetSteamID().m_SteamID] : UserInterface.UnknownAvatar; SelfScoreboard = new ScoreboardUser(Screen, ScoreboardUserType.Self, scoreboardName, null, selfAvatar, ModManager.Mods) { Parent = Container, Alignment = Alignment.MidLeft }; var users = new List <ScoreboardUser> { SelfScoreboard }; if (OnlineManager.CurrentGame != null && OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team) { // Blue Team ScoreboardRight = new Scoreboard(ScoreboardType.Teams, OnlineManager.GetTeam(OnlineManager.Self.OnlineUser.Id) == MultiplayerTeam.Blue ? users : new List <ScoreboardUser>(), MultiplayerTeam.Blue) { Parent = Container, Alignment = Alignment.TopLeft, }; } var scoreboardType = OnlineManager.CurrentGame != null && OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team ? ScoreboardType.Teams : ScoreboardType.FreeForAll; // Red team/normal leaderboard ScoreboardLeft = new Scoreboard(scoreboardType, OnlineManager.CurrentGame == null || OnlineManager.GetTeam(OnlineManager.Self.OnlineUser.Id) == MultiplayerTeam.Red ? users : new List <ScoreboardUser>()) { Parent = Container }; ScoreboardLeft?.Users.ForEach(x => x.SetImage()); ScoreboardRight?.Users.ForEach(x => x.SetImage()); }
/// <summary> /// </summary> private void OrderByTeam(bool orderInstantly) { Pool = Pool .OrderBy(x => OnlineManager.CurrentGame.RefereeUserId == x.Item.Id) .ThenBy(x => OnlineManager.GetTeam(x.Item.Id)).ToList(); for (var i = 0; i < Pool.Count; i++) { Pool[i].Index = i; var targetY = (PoolStartingIndex + i) * Pool[i].HEIGHT; if (orderInstantly) { Pool[i].Y = targetY; } else { Pool[i].ClearAnimations(); Pool[i].MoveToY(targetY, Easing.OutQuint, 400); } } }
/// <summary> /// Checks if there are new scoreboard users. /// </summary> private void CheckIfNewScoreboardUsers() { if (Screen.IsPlayTesting || StopCheckingForScoreboardUsers) { return; } var mapScores = MapManager.Selected.Value.Scores.Value; if (mapScores == null || mapScores.Count <= 0 || (ScoreboardLeft.Users?.Count < 1 && ScoreboardRight != null && ScoreboardRight.Users.Count < 1)) { return; } for (var i = 0; i < (OnlineManager.CurrentGame == null ? 4 : mapScores.Count) && i < mapScores.Count; i++) { ScoreboardUser user; // For online scores we want to just give them their score in the processor, // since we don't have access to their judgement breakdown. if (mapScores[i].IsOnline) { user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}", new List <Judgement>(), UserInterface.UnknownAvatar, (ModIdentifier)mapScores[i].Mods, mapScores[i]) { Parent = Container, Alignment = Alignment.MidLeft }; if (OnlineManager.CurrentGame != null && OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team && OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue) { user.Scoreboard = ScoreboardRight; user.X = WindowManager.Width; } else { user.Scoreboard = ScoreboardLeft; } user.SetImage(); var processor = user.Processor as ScoreProcessorKeys; processor.Accuracy = (float)mapScores[i].Accuracy; processor.MaxCombo = mapScores[i].MaxCombo; processor.Score = mapScores[i].TotalScore; user.Score.Text = $"{user.RatingProcessor.CalculateRating(processor.Accuracy):0.00} / {StringHelper.AccuracyToString(processor.Accuracy)}"; user.Combo.Text = $"{processor.MaxCombo}x"; } // Allow the user to play against their own local scores. else { // Decompress score var breakdownHits = GzipHelper.Decompress(mapScores[i].JudgementBreakdown); var judgements = new List <Judgement>(); // Get all of the hit stats for the score. foreach (var hit in breakdownHits) { judgements.Add((Judgement)int.Parse(hit.ToString())); } user = new ScoreboardUser(Screen, ScoreboardUserType.Other, $"{mapScores[i].Name}", judgements, UserInterface.UnknownAvatar, (ModIdentifier)mapScores[i].Mods, mapScores[i]) { Parent = Container, Alignment = Alignment.MidLeft }; if (OnlineManager.CurrentGame != null && OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team && OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue) { user.Scoreboard = ScoreboardRight; } else { user.Scoreboard = ScoreboardLeft; } user.SetImage(); // Make sure the user's score is updated with the current user. for (var j = 0; j < Screen.Ruleset.ScoreProcessor.TotalJudgementCount && i < judgements.Count; j++) { var processor = user.Processor as ScoreProcessorKeys; processor?.CalculateScore(judgements[i]); } } if (OnlineManager.CurrentGame != null && OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team && OnlineManager.GetTeam(user.LocalScore.PlayerId) == MultiplayerTeam.Blue) { ScoreboardRight.Users.Add(user); } else { ScoreboardLeft.Users.Add(user); } } ScoreboardLeft.SetTargetYPositions(); ScoreboardRight?.SetTargetYPositions(); // Re-change the transitioner and pause screen's parent so that they appear on top of the scoreboard // again. if (ProgressBar != null) { ProgressBar.Parent = Container; } Transitioner.Parent = Container; PauseScreen.Parent = Container; StopCheckingForScoreboardUsers = true; Screen.SetRichPresence(); }
/// <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; }
private void CreateContainer() { var options = new List <IMenuDialogOption> { new MenuDialogOption("View Profile", () => BrowserHelper.OpenURL($"https://quavergame.com/profile/{User.Id}")), new MenuDialogOption("Steam Profile", () => BrowserHelper.OpenURL($"https://steamcommunity.com/profiles/{User.SteamId}")), }; // Other Player Actions if (User.Id != OnlineManager.Self.OnlineUser.Id) { options.Add(new MenuDialogOption("Private Chat", () => { var list = new List <string>() { // Have to add a BS element in the beginning since the method assumes that its a chat command // and removes the first element "chat" }; QuaverBot.ExecuteChatCommand(list.Concat(User.Username.Split(" "))); ChatManager.ToggleChatOverlay(true); })); // We're the host, so add some host actions if (OnlineManager.Self.OnlineUser.Id == OnlineManager.CurrentGame.HostId) { options = options.Concat(new List <IMenuDialogOption> { new MenuDialogOption("Kick Player", () => OnlineManager.Client.KickMultiplayerGamePlayer(User.Id), Color.Crimson), new MenuDialogOption("Give Host", () => OnlineManager.Client.TransferMultiplayerGameHost(User.Id), Color.Lime), }).ToList(); if (OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team) { var team = OnlineManager.GetTeam(User.Id); switch (team) { case MultiplayerTeam.Red: team = MultiplayerTeam.Blue; break; case MultiplayerTeam.Blue: team = MultiplayerTeam.Red; break; default: throw new ArgumentOutOfRangeException(); } var color = team == MultiplayerTeam.Red ? Color.Crimson : new Color(25, 104, 249); options.Add(new MenuDialogOption($"Change Team ({team})", () => OnlineManager.Client.ChangeOtherPlayerTeam(User.Id, team), color)); } } } options.Add(new MenuDialogOption("Close", () => DialogManager.Dismiss(Dialog))); Container = new MultiplayerPlayerOptionsContainer(Dialog, options) { Parent = this, Alignment = Alignment.MidCenter }; }