mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Improve state reset flow
This commit is contained in:
@ -120,9 +120,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
{
|
{
|
||||||
if (value != PlaceholderState.Successful)
|
if (value != PlaceholderState.Successful)
|
||||||
{
|
{
|
||||||
getScoresRequest?.Cancel();
|
Reset();
|
||||||
getScoresRequest = null;
|
|
||||||
Scores = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == placeholderState)
|
if (value == placeholderState)
|
||||||
@ -166,7 +164,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
|
|
||||||
protected Leaderboard()
|
protected Leaderboard()
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new GridContainer
|
new GridContainer
|
||||||
{
|
{
|
||||||
@ -204,6 +202,13 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void Reset()
|
||||||
|
{
|
||||||
|
getScoresRequest?.Cancel();
|
||||||
|
getScoresRequest = null;
|
||||||
|
Scores = null;
|
||||||
|
}
|
||||||
|
|
||||||
private IAPIProvider api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
private ScheduledDelegate pendingUpdateScores;
|
private ScheduledDelegate pendingUpdateScores;
|
||||||
|
@ -17,9 +17,8 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
public class UserTopScoreContainer : VisibilityContainer
|
public class UserTopScoreContainer : VisibilityContainer
|
||||||
{
|
{
|
||||||
private const int height = 90;
|
private const int height = 90;
|
||||||
private const int duration = 800;
|
private const int duration = 500;
|
||||||
|
|
||||||
private readonly Container contentContainer;
|
|
||||||
private readonly Container scoreContainer;
|
private readonly Container scoreContainer;
|
||||||
|
|
||||||
public Bindable<APILegacyUserTopScoreInfo> Score = new Bindable<APILegacyUserTopScoreInfo>();
|
public Bindable<APILegacyUserTopScoreInfo> Score = new Bindable<APILegacyUserTopScoreInfo>();
|
||||||
@ -38,7 +37,7 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
contentContainer = new Container
|
new Container
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
@ -74,15 +73,12 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
{
|
{
|
||||||
var newScore = score.NewValue;
|
var newScore = score.NewValue;
|
||||||
|
|
||||||
if (newScore == null)
|
|
||||||
{
|
|
||||||
Hide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scoreContainer.Clear();
|
scoreContainer.Clear();
|
||||||
loadScoreCancellation?.Cancel();
|
loadScoreCancellation?.Cancel();
|
||||||
|
|
||||||
|
if (newScore == null)
|
||||||
|
return;
|
||||||
|
|
||||||
LoadComponentAsync(new LeaderboardScore(newScore.Score, newScore.Position)
|
LoadComponentAsync(new LeaderboardScore(newScore.Score, newScore.Position)
|
||||||
{
|
{
|
||||||
Action = () => ScoreSelected?.Invoke(newScore.Score)
|
Action = () => ScoreSelected?.Invoke(newScore.Score)
|
||||||
@ -93,12 +89,14 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
}, (loadScoreCancellation = new CancellationTokenSource()).Token);
|
}, (loadScoreCancellation = new CancellationTokenSource()).Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn() => this.ResizeHeightTo(height, duration / 4f, Easing.OutQuint).OnComplete(_ => contentContainer.FadeIn(duration, Easing.OutQuint));
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
this.FadeIn(duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
{
|
{
|
||||||
this.ResizeHeightTo(0);
|
this.FadeOut(duration, Easing.OutQuint);
|
||||||
contentContainer.FadeOut(duration / 4f, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,12 @@ using osu.Game.Online.Leaderboards;
|
|||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Select.Details;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Leaderboards
|
namespace osu.Game.Screens.Select.Leaderboards
|
||||||
{
|
{
|
||||||
public class BeatmapLeaderboard : Leaderboard<BeatmapLeaderboardScope, ScoreInfo>
|
public class BeatmapLeaderboard : Leaderboard<BeatmapLeaderboardScope, ScoreInfo>
|
||||||
{
|
{
|
||||||
public Bindable<APILegacyUserTopScoreInfo> TopScore = new Bindable<APILegacyUserTopScoreInfo>();
|
|
||||||
|
|
||||||
public Action<ScoreInfo> ScoreSelected;
|
public Action<ScoreInfo> ScoreSelected;
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmap;
|
||||||
@ -40,8 +39,25 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public APILegacyUserTopScoreInfo TopScore
|
||||||
|
{
|
||||||
|
get => topScoreContainer.Score.Value;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
topScoreContainer.Hide();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
topScoreContainer.Show();
|
||||||
|
topScoreContainer.Score.Value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool filterMods;
|
private bool filterMods;
|
||||||
|
|
||||||
|
private UserTopScoreContainer topScoreContainer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to apply the game's currently selected mods as a filter when retrieving scores.
|
/// Whether to apply the game's currently selected mods as a filter when retrieving scores.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -81,25 +97,19 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
UpdateScores();
|
UpdateScores();
|
||||||
};
|
};
|
||||||
|
|
||||||
TopScore.BindValueChanged(newTopScore);
|
Content.Add(topScoreContainer = new UserTopScoreContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newTopScore(ValueChangedEvent<APILegacyUserTopScoreInfo> score)
|
protected override void Reset()
|
||||||
{
|
{
|
||||||
Content.Clear();
|
base.Reset();
|
||||||
|
TopScore = null;
|
||||||
if (score.NewValue != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsOnlineScope => Scope != BeatmapLeaderboardScope.Local;
|
protected override bool IsOnlineScope => Scope != BeatmapLeaderboardScope.Local;
|
||||||
|
|
||||||
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
||||||
{
|
{
|
||||||
TopScore.Value = null;
|
|
||||||
|
|
||||||
if (Beatmap == null)
|
if (Beatmap == null)
|
||||||
{
|
{
|
||||||
PlaceholderState = PlaceholderState.NoneSelected;
|
PlaceholderState = PlaceholderState.NoneSelected;
|
||||||
@ -161,7 +171,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
req.Success += r =>
|
req.Success += r =>
|
||||||
{
|
{
|
||||||
scoresCallback?.Invoke(r.Scores);
|
scoresCallback?.Invoke(r.Scores);
|
||||||
TopScore.Value = r.UserScore;
|
TopScore = r.UserScore;
|
||||||
};
|
};
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
|
Reference in New Issue
Block a user