mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Apply NRT to base Leaderboard
classes
This commit is contained in:
@ -1,14 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Development;
|
||||
@ -54,23 +51,23 @@ namespace osu.Game.Online.Leaderboards
|
||||
private readonly Container placeholderContainer;
|
||||
private readonly UserTopScoreContainer<TScoreInfo> userScoreContainer;
|
||||
|
||||
private FillFlowContainer<LeaderboardScore> scoreFlowContainer;
|
||||
private FillFlowContainer<LeaderboardScore>? scoreFlowContainer;
|
||||
|
||||
private readonly LoadingSpinner loading;
|
||||
|
||||
private CancellationTokenSource currentFetchCancellationSource;
|
||||
private CancellationTokenSource currentScoresAsyncLoadCancellationSource;
|
||||
private CancellationTokenSource? currentFetchCancellationSource;
|
||||
private CancellationTokenSource? currentScoresAsyncLoadCancellationSource;
|
||||
|
||||
private APIRequest fetchScoresRequest;
|
||||
private APIRequest? fetchScoresRequest;
|
||||
|
||||
private LeaderboardState state;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IAPIProvider api { get; set; }
|
||||
private IAPIProvider? api { get; set; }
|
||||
|
||||
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
||||
|
||||
private TScope scope;
|
||||
private TScope scope = default!;
|
||||
|
||||
public TScope Scope
|
||||
{
|
||||
@ -179,7 +176,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
/// </summary>
|
||||
/// <param name="scores">The scores to display.</param>
|
||||
/// <param name="userScore">The user top score, if any.</param>
|
||||
protected void SetScores(IEnumerable<TScoreInfo> scores, TScoreInfo userScore = default)
|
||||
protected void SetScores(IEnumerable<TScoreInfo>? scores, TScoreInfo? userScore = default)
|
||||
{
|
||||
this.scores.Clear();
|
||||
if (scores != null)
|
||||
@ -213,8 +210,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
|
||||
[CanBeNull]
|
||||
protected abstract APIRequest FetchScores(CancellationToken cancellationToken);
|
||||
protected abstract APIRequest? FetchScores(CancellationToken cancellationToken);
|
||||
|
||||
protected abstract LeaderboardScore CreateDrawableScore(TScoreInfo model, int index);
|
||||
|
||||
@ -298,7 +294,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
|
||||
#region Placeholder handling
|
||||
|
||||
private Placeholder placeholder;
|
||||
private Placeholder? placeholder;
|
||||
|
||||
private void setState(LeaderboardState state)
|
||||
{
|
||||
@ -325,7 +321,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
placeholder.FadeInFromZero(fade_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private Placeholder getPlaceholderFor(LeaderboardState state)
|
||||
private Placeholder? getPlaceholderFor(LeaderboardState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using osu.Framework.Bindables;
|
||||
@ -18,13 +16,15 @@ namespace osu.Game.Online.Leaderboards
|
||||
{
|
||||
private const int duration = 500;
|
||||
|
||||
public Bindable<TScoreInfo> Score = new Bindable<TScoreInfo>();
|
||||
public Bindable<TScoreInfo?> Score = new Bindable<TScoreInfo?>();
|
||||
|
||||
private readonly Container scoreContainer;
|
||||
private readonly Func<TScoreInfo, LeaderboardScore> createScoreDelegate;
|
||||
|
||||
protected override bool StartHidden => true;
|
||||
|
||||
private CancellationTokenSource? loadScoreCancellation;
|
||||
|
||||
public UserTopScoreContainer(Func<TScoreInfo, LeaderboardScore> createScoreDelegate)
|
||||
{
|
||||
this.createScoreDelegate = createScoreDelegate;
|
||||
@ -65,9 +65,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
Score.BindValueChanged(onScoreChanged);
|
||||
}
|
||||
|
||||
private CancellationTokenSource loadScoreCancellation;
|
||||
|
||||
private void onScoreChanged(ValueChangedEvent<TScoreInfo> score)
|
||||
private void onScoreChanged(ValueChangedEvent<TScoreInfo?> score)
|
||||
{
|
||||
var newScore = score.NewValue;
|
||||
|
||||
|
Reference in New Issue
Block a user