Esempio n. 1
0
        private void updateScores()
        {
            if (!IsLoaded)
            {
                return;
            }

            Scores = null;
            getScoresRequest?.Cancel();

            if (api == null || Beatmap == null)
            {
                return;
            }

            loading.Show();

            getScoresRequest          = new GetScoresRequest(Beatmap);
            getScoresRequest.Success += r =>
            {
                Scores = r.Scores;
                loading.Hide();
            };
            api.Queue(getScoresRequest);
        }
Esempio n. 2
0
        private void updateScores()
        {
            getScoresRequest?.Cancel();
            getScoresRequest = null;

            pendingUpdateScores?.Cancel();
            pendingUpdateScores = Schedule(() =>
            {
                if (Scope == LeaderboardScope.Local)
                {
                    // TODO: get local scores from wherever here.
                    PlaceholderState = PlaceholderState.NoScores;
                    return;
                }

                if (Beatmap?.OnlineBeatmapID == null)
                {
                    PlaceholderState = PlaceholderState.Unavailable;
                    return;
                }

                if (api?.IsLoggedIn != true)
                {
                    PlaceholderState = PlaceholderState.NotLoggedIn;
                    return;
                }

                if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter)
                {
                    PlaceholderState = PlaceholderState.NotSupporter;
                    return;
                }

                PlaceholderState = PlaceholderState.Retrieving;
                loading.Show();

                getScoresRequest          = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope);
                getScoresRequest.Success += r => Schedule(() =>
                {
                    Scores           = r.Scores;
                    PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
                });

                getScoresRequest.Failure += e => Schedule(() =>
                {
                    if (e is OperationCanceledException)
                    {
                        return;
                    }

                    PlaceholderState = PlaceholderState.NetworkFailure;
                });

                api.Queue(getScoresRequest);
            });
        }
Esempio n. 3
0
        private void updateLeaderboard(WorkingBeatmap beatmap)
        {
            leaderboard.Scores = null;
            getScoresRequest?.Cancel();

            if (beatmap?.BeatmapInfo == null)
            {
                return;
            }

            getScoresRequest          = new GetScoresRequest(beatmap.BeatmapInfo);
            getScoresRequest.Success += r => leaderboard.Scores = r.Scores;
            Game.API.Queue(getScoresRequest);
        }
Esempio n. 4
0
        private void updateScores()
        {
            getScoresRequest?.Cancel();
            getScoresRequest = null;
            Scores           = null;

            if (Scope == LeaderboardScope.Local)
            {
                // TODO: get local scores from wherever here.
                PlaceholderState = PlaceholderState.NoScores;
                return;
            }

            if (Beatmap?.OnlineBeatmapID == null)
            {
                PlaceholderState = PlaceholderState.Unavailable;
                return;
            }

            if (api?.IsLoggedIn != true)
            {
                PlaceholderState = PlaceholderState.NotLoggedIn;
                return;
            }

            PlaceholderState = PlaceholderState.Retrieving;
            loading.Show();

            if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter)
            {
                loading.Hide();
                PlaceholderState = PlaceholderState.NotSupporter;
                return;
            }

            getScoresRequest          = new GetScoresRequest(Beatmap, osuGame?.Ruleset.Value ?? Beatmap.Ruleset, Scope);
            getScoresRequest.Success += r =>
            {
                Scores           = r.Scores;
                PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
            };
            getScoresRequest.Failure += onUpdateFailed;

            api.Queue(getScoresRequest);
        }
Esempio n. 5
0
        private void updateScores()
        {
            if (!IsLoaded)
            {
                return;
            }

            Leaderboard.Scores = null;
            getScoresRequest?.Cancel();

            if (api == null || beatmap?.BeatmapInfo == null || !Leaderboard.IsPresent)
            {
                return;
            }

            getScoresRequest          = new GetScoresRequest(beatmap.BeatmapInfo);
            getScoresRequest.Success += r => Leaderboard.Scores = r.Scores;
            api.Queue(getScoresRequest);
        }
Esempio n. 6
0
        private void updateScores(BeatmapInfo beatmap)
        {
            getScoresRequest?.Cancel();

            if (!beatmap.OnlineBeatmapID.HasValue)
            {
                scores.CleanAllScores();
                return;
            }

            scores.IsLoading = true;

            getScoresRequest          = new GetScoresRequest(beatmap);
            getScoresRequest.Success += r =>
            {
                scores.Scores    = r.Scores;
                scores.IsLoading = false;
            };
            api.Queue(getScoresRequest);
        }
Esempio n. 7
0
        private void getScores()
        {
            getScoresRequest?.Cancel();
            getScoresRequest = null;

            noScoresPlaceholder.Hide();

            if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending)
            {
                Scores = null;
                content.Hide();
                return;
            }

            if (scope.Value != BeatmapLeaderboardScope.Global && !userIsSupporter)
            {
                Scores = null;
                notSupporterPlaceholder.Show();
                loading.Hide();
                return;
            }

            notSupporterPlaceholder.Hide();

            content.Show();
            loading.Show();

            getScoresRequest          = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value, modSelector.SelectedMods);
            getScoresRequest.Success += scores =>
            {
                loading.Hide();
                Scores = scores;

                if (!scores.Scores.Any())
                {
                    noScoresPlaceholder.ShowWithScope(scope.Value);
                }
            };

            api.Queue(getScoresRequest);
        }
Esempio n. 8
0
        private void updateScores()
        {
            // don't display any scores or placeholder until the first Scores_Set has been called.
            // this avoids scope changes flickering a "no scores" placeholder before initialisation of song select is finished.
            if (!scoresLoadedOnce)
            {
                return;
            }

            getScoresRequest?.Cancel();
            getScoresRequest = null;

            pendingUpdateScores?.Cancel();
            pendingUpdateScores = Schedule(() =>
            {
                if (Scope == LeaderboardScope.Local)
                {
                    // TODO: get local scores from wherever here.
                    PlaceholderState = PlaceholderState.NoScores;
                    return;
                }

                if (Beatmap?.OnlineBeatmapID == null)
                {
                    PlaceholderState = PlaceholderState.Unavailable;
                    return;
                }

                if (api?.IsLoggedIn != true)
                {
                    PlaceholderState = PlaceholderState.NotLoggedIn;
                    return;
                }

                if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter)
                {
                    PlaceholderState = PlaceholderState.NotSupporter;
                    return;
                }

                PlaceholderState = PlaceholderState.Retrieving;
                loading.Show();

                getScoresRequest          = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope);
                getScoresRequest.Success += r => Schedule(() =>
                {
                    Scores           = r.Scores;
                    PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
                });

                getScoresRequest.Failure += e => Schedule(() =>
                {
                    if (e is OperationCanceledException)
                    {
                        return;
                    }

                    PlaceholderState = PlaceholderState.NetworkFailure;
                });

                api.Queue(getScoresRequest);
            });
        }
Esempio n. 9
0
        protected override void Dispose(bool isDisposing)
        {
            base.Dispose(isDisposing);

            getScoreRequest?.Cancel();
        }