Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix daily challenge not showing a replay button in results screen #29057

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public void TestButtonWithReplayStartsDownload()

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]
Expand Down
12 changes: 7 additions & 5 deletions osu.Game/Screens/Ranking/ReplayDownloadButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>();

Expand All @@ -44,7 +44,7 @@ private ReplayAvailability replayAvailability
}
}

public ReplayDownloadButton(ScoreInfo score)
public ReplayDownloadButton(ScoreInfo? score)
{
Score.Value = score;
Size = new Vector2(50, 30);
Expand All @@ -67,11 +67,11 @@ private void load(OsuGame? game, ScoreModelDownloader scoreDownloader)
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:
Expand All @@ -88,6 +88,8 @@ private void load(OsuGame? game, ScoreModelDownloader scoreDownloader)
State.ValueChanged -= exportWhenReady;

downloadTracker?.RemoveAndDisposeImmediately();
downloadTracker = null;
State.SetDefault();

if (score.NewValue != null)
{
Expand Down Expand Up @@ -147,7 +149,7 @@ private void exportWhenReady(ValueChangedEvent<DownloadState> state)
{
if (state.NewValue != DownloadState.LocallyAvailable) return;

scoreManager.Export(Score.Value);
scoreManager.Export(Score.Value!);

State.ValueChanged -= exportWhenReady;
}
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Screens/Ranking/ResultsScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ private void load(AudioManager audio)
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
});
}
Expand Down
Loading