1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 18:43:04 +08:00

Add static memory of last applied offset score

I don't really like adding this new session static, but we don't have a
better place to put this.
This commit is contained in:
Dean Herbert 2025-01-02 16:20:21 +09:00
parent 2d3595f768
commit 2a28c5f4de
No known key found for this signature in database
2 changed files with 23 additions and 1 deletions

View File

@ -29,6 +29,7 @@ namespace osu.Game.Configuration
SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null);
SetDefault(Static.TouchInputActive, RuntimeInfo.IsMobile);
SetDefault<ScoreInfo>(Static.LastLocalUserScore, null);
SetDefault<ScoreInfo>(Static.LastAppliedOffsetScore, null);
}
/// <summary>
@ -81,6 +82,11 @@ namespace osu.Game.Configuration
/// </summary>
LastLocalUserScore,
/// <summary>
/// Stores the local user's last score which was used to apply an offset.
/// </summary>
LastAppliedOffsetScore,
/// <summary>
/// Whether the intro animation for the daily challenge screen has been played once.
/// This is reset when a new challenge is up.

View File

@ -15,6 +15,7 @@ using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -36,6 +37,8 @@ namespace osu.Game.Screens.Play.PlayerSettings
{
public Bindable<ScoreInfo?> ReferenceScore { get; } = new Bindable<ScoreInfo?>();
private Bindable<ScoreInfo?> lastAppliedScore { get; } = new Bindable<ScoreInfo?>();
public BindableDouble Current { get; } = new BindableDouble
{
MinValue = -50,
@ -100,6 +103,12 @@ namespace osu.Game.Screens.Play.PlayerSettings
};
}
[BackgroundDependencyLoader]
private void load(SessionStatics statics)
{
statics.BindWith(Static.LastAppliedOffsetScore, lastAppliedScore);
}
protected override void LoadComplete()
{
base.LoadComplete();
@ -176,6 +185,9 @@ namespace osu.Game.Screens.Play.PlayerSettings
if (score.NewValue == null)
return;
if (score.NewValue.Equals(lastAppliedScore.Value))
return;
if (!score.NewValue.BeatmapInfo.AsNonNull().Equals(beatmap.Value.BeatmapInfo))
return;
@ -230,7 +242,11 @@ namespace osu.Game.Screens.Play.PlayerSettings
useAverageButton = new SettingsButton
{
Text = BeatmapOffsetControlStrings.CalibrateUsingLastPlay,
Action = () => Current.Value = lastPlayBeatmapOffset - lastPlayAverage,
Action = () =>
{
Current.Value = lastPlayBeatmapOffset - lastPlayAverage;
lastAppliedScore.Value = ReferenceScore.Value;
},
Enabled = { Value = !Precision.AlmostEquals(lastPlayAverage, 0, Current.Precision / 2) }
},
globalOffsetText = new LinkFlowContainer