コード例 #1
0
        private void load(OsuConfigManager config, IAPIProvider api)
        {
            streamingClient.OnNewFrames += handleIncomingFrames;

            foreach (var userId in playingUsers)
            {
                streamingClient.WatchUser(userId);

                // probably won't be required in the final implementation.
                var resolvedUser = userLookupCache.GetUserAsync(userId).Result;

                var trackedUser = new TrackedUserData();

                userScores[userId] = trackedUser;
                var leaderboardScore = AddPlayer(resolvedUser, resolvedUser?.Id == api.LocalUser.Value.Id);

                ((IBindable <double>)leaderboardScore.Accuracy).BindTo(trackedUser.Accuracy);
                ((IBindable <double>)leaderboardScore.TotalScore).BindTo(trackedUser.Score);
                ((IBindable <int>)leaderboardScore.Combo).BindTo(trackedUser.CurrentCombo);
                ((IBindable <bool>)leaderboardScore.HasQuit).BindTo(trackedUser.UserQuit);
            }

            scoringMode = config.GetBindable <ScoringMode>(OsuSetting.ScoreDisplayMode);
            scoringMode.BindValueChanged(updateAllScores, true);
        }
コード例 #2
0
        private void load(OsuConfigManager config, IAPIProvider api, CancellationToken cancellationToken)
        {
            scoringMode = config.GetBindable <ScoringMode>(OsuSetting.ScoreDisplayMode);

            foreach (var user in playingUsers)
            {
                var scoreProcessor = new SpectatorScoreProcessor(user.UserID);
                scoreProcessor.Mode.BindTo(scoringMode);
                scoreProcessor.TotalScore.BindValueChanged(_ => Scheduler.AddOnce(updateTotals));
                AddInternal(scoreProcessor);

                var trackedUser = new TrackedUserData(user, scoreProcessor);
                UserScores[user.UserID] = trackedUser;

                if (trackedUser.Team is int team && !TeamScores.ContainsKey(team))
                {
                    TeamScores.Add(team, new BindableLong());
                }
            }

            userLookupCache.GetUsersAsync(playingUsers.Select(u => u.UserID).ToArray(), cancellationToken)
            .ContinueWith(task =>
            {
                Schedule(() =>
                {
                    var users = task.GetResultSafely();

                    for (int i = 0; i < users.Length; i++)
                    {
                        var user = users[i] ?? new APIUser
                        {
                            Id       = playingUsers[i].UserID,
                            Username = "******",
                        };

                        var trackedUser = UserScores[user.Id];

                        var leaderboardScore = Add(user, user.Id == api.LocalUser.Value.Id);
                        leaderboardScore.Accuracy.BindTo(trackedUser.ScoreProcessor.Accuracy);
                        leaderboardScore.TotalScore.BindTo(trackedUser.ScoreProcessor.TotalScore);
                        leaderboardScore.Combo.BindTo(trackedUser.ScoreProcessor.Combo);
                        leaderboardScore.HasQuit.BindTo(trackedUser.UserQuit);
                    }
                });
            }, cancellationToken);
        }