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

Clear previous LastLocalUserScore when returning to song select #30905

Merged
merged 2 commits into from
Nov 28, 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
17 changes: 17 additions & 0 deletions osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,23 @@ public void TestRetryCountIncrements()
AddAssert("retry count is 1", () => player.RestartCount == 1);
}

[Test]
public void TestLastScoreNullAfterExitingPlayer()
{
AddUntilStep("wait for last play null", getLastPlay, () => Is.Null);

var getOriginalPlayer = playToCompletion();

AddStep("attempt to retry", () => getOriginalPlayer().ChildrenOfType<HotkeyRetryOverlay>().First().Action());
AddUntilStep("wait for last play matches player", getLastPlay, () => Is.EqualTo(getOriginalPlayer().Score.ScoreInfo));

AddUntilStep("wait for player", () => Game.ScreenStack.CurrentScreen != getOriginalPlayer() && Game.ScreenStack.CurrentScreen is Player);
AddStep("exit player", () => (Game.ScreenStack.CurrentScreen as Player)?.Exit());
AddUntilStep("wait for last play null", getLastPlay, () => Is.Null);

ScoreInfo getLastPlay() => Game.Dependencies.Get<SessionStatics>().Get<ScoreInfo>(Static.LastLocalUserScore);
}

[Test]
public void TestRetryImmediatelyAfterCompletion()
{
Expand Down
4 changes: 3 additions & 1 deletion osu.Game/Configuration/SessionStatics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Play;

namespace osu.Game.Configuration
{
Expand Down Expand Up @@ -77,7 +78,8 @@ public enum Static
TouchInputActive,

/// <summary>
/// Stores the local user's last score (can be completed or aborted).
/// Contains the local user's last score (can be completed or aborted) after exiting <see cref="Player"/>.
/// Will be cleared to <c>null</c> when leaving <see cref="PlayerLoader"/>.
/// </summary>
LastLocalUserScore,

Expand Down
7 changes: 7 additions & 0 deletions osu.Game/Screens/Play/PlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Performance;
using osu.Game.Scoring;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play.PlayerSettings;
using osu.Game.Skinning;
Expand Down Expand Up @@ -78,6 +79,8 @@ public partial class PlayerLoader : ScreenWithBeatmapBackground
private FillFlowContainer disclaimers = null!;
private OsuScrollContainer settingsScroll = null!;

private Bindable<ScoreInfo?> lastScore = null!;

private Bindable<bool> showStoryboards = null!;

private bool backgroundBrightnessReduction;
Expand Down Expand Up @@ -179,6 +182,8 @@ private void load(SessionStatics sessionStatics, OsuConfigManager config)
{
muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce);
batteryWarningShownOnce = sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce);
lastScore = sessionStatics.GetBindable<ScoreInfo?>(Static.LastLocalUserScore);

showStoryboards = config.GetBindable<bool>(OsuSetting.ShowStoryboard);

const float padding = 25;
Expand Down Expand Up @@ -347,6 +352,8 @@ public override bool OnExiting(ScreenExitEvent e)
highPerformanceSession?.Dispose();
highPerformanceSession = null;

lastScore.Value = null;

return base.OnExiting(e);
}

Expand Down
Loading