Skip to content

Commit

Permalink
Clear previous LastLocalUserScore when returning to song select
Browse files Browse the repository at this point in the history
This seems like the lowest friction way of fixing
ppy#30885.

We could also only null this on application, but this feels worse
because

- It would require local handling (potentially complex) in
  `BeatmapOffsetControl` if we want to continue displaying the graph and
button after clicking it.
- It would make the session static very specific in usage and
  potentially make future usage not possible due to being nulled in only
a very specific scenario.

One might argue that it would be nice to have this non-null until the
next play, but if such a usage comes up I'd propose we rename this
session static and add a new one with that purpose.
  • Loading branch information
peppy committed Nov 28, 2024
1 parent 5d7aafa commit ced8dda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit ced8dda

Please sign in to comment.