Merge pull request #29057 from frenzibyte/daily-challenge-replay-download-button

Fix daily challenge not showing a replay button in results screen
This commit is contained in:
Bartłomiej Dach 2024-07-26 08:03:17 +02:00 committed by GitHub
commit 09a1fd2cd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

View File

@ -117,6 +117,9 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("state entered downloading", () => downloadStarted);
AddUntilStep("state left downloading", () => downloadFinished);
AddStep("change score to null", () => downloadButton.Score.Value = null);
AddUntilStep("state changed to unknown", () => downloadButton.State.Value, () => Is.EqualTo(DownloadState.Unknown));
}
[Test]

View File

@ -18,7 +18,7 @@ namespace osu.Game.Screens.Ranking
{
public partial class ReplayDownloadButton : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
public readonly Bindable<ScoreInfo> Score = new Bindable<ScoreInfo>();
public readonly Bindable<ScoreInfo?> Score = new Bindable<ScoreInfo?>();
protected readonly Bindable<DownloadState> State = new Bindable<DownloadState>();
@ -44,7 +44,7 @@ namespace osu.Game.Screens.Ranking
}
}
public ReplayDownloadButton(ScoreInfo score)
public ReplayDownloadButton(ScoreInfo? score)
{
Score.Value = score;
Size = new Vector2(50, 30);
@ -67,11 +67,11 @@ namespace osu.Game.Screens.Ranking
switch (State.Value)
{
case DownloadState.LocallyAvailable:
game?.PresentScore(Score.Value, ScorePresentType.Gameplay);
game?.PresentScore(Score.Value!, ScorePresentType.Gameplay);
break;
case DownloadState.NotDownloaded:
scoreDownloader.Download(Score.Value);
scoreDownloader.Download(Score.Value!);
break;
case DownloadState.Importing:
@ -88,6 +88,8 @@ namespace osu.Game.Screens.Ranking
State.ValueChanged -= exportWhenReady;
downloadTracker?.RemoveAndDisposeImmediately();
downloadTracker = null;
State.SetDefault();
if (score.NewValue != null)
{
@ -147,7 +149,7 @@ namespace osu.Game.Screens.Ranking
{
if (state.NewValue != DownloadState.LocallyAvailable) return;
scoreManager.Export(Score.Value);
scoreManager.Export(Score.Value!);
State.ValueChanged -= exportWhenReady;
}

View File

@ -179,11 +179,11 @@ namespace osu.Game.Screens.Ranking
Scheduler.AddDelayed(() => OverlayActivationMode.Value = OverlayActivation.All, shouldFlair ? AccuracyCircle.TOTAL_DURATION + 1000 : 0);
}
if (SelectedScore.Value != null && AllowWatchingReplay)
if (AllowWatchingReplay)
{
buttons.Add(new ReplayDownloadButton(SelectedScore.Value)
{
Score = { BindTarget = SelectedScore! },
Score = { BindTarget = SelectedScore },
Width = 300
});
}