1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Fade display out during rewind (as the value displayed is no longer valid)

This commit is contained in:
Dean Herbert 2021-10-05 15:39:29 +09:00
parent 81a13566bc
commit 676df55a0e
3 changed files with 40 additions and 5 deletions

View File

@ -25,7 +25,9 @@ namespace osu.Game.Graphics.UserInterface
set => current.Current = value;
}
private IHasText displayedCountSpriteText;
private IHasText displayedCountText;
public Drawable DrawableCount { get; private set; }
/// <summary>
/// If true, the roll-up duration will be proportional to change in value.
@ -72,16 +74,16 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load()
{
displayedCountSpriteText = CreateText();
displayedCountText = CreateText();
UpdateDisplay();
Child = (Drawable)displayedCountSpriteText;
Child = DrawableCount = (Drawable)displayedCountText;
}
protected void UpdateDisplay()
{
if (displayedCountSpriteText != null)
displayedCountSpriteText.Text = FormatCount(DisplayedCount);
if (displayedCountText != null)
displayedCountText.Text = FormatCount(DisplayedCount);
}
protected override void LoadComplete()

View File

@ -18,6 +18,11 @@ namespace osu.Game.Rulesets.Scoring
/// </summary>
public event Action<JudgementResult> NewJudgement;
/// <summary>
/// Invoked when a judgement is reverted, usually due to rewinding gameplay.
/// </summary>
public event Action<JudgementResult> JudgementReverted;
/// <summary>
/// The maximum number of hits that can be judged.
/// </summary>
@ -71,6 +76,8 @@ namespace osu.Game.Rulesets.Scoring
JudgedHits--;
RevertResultInternal(result);
JudgementReverted?.Invoke(result);
}
/// <summary>

View File

@ -42,6 +42,9 @@ namespace osu.Game.Screens.Play.HUD
[CanBeNull]
private GameplayState gameplayState { get; set; }
[Resolved]
private GameplayClock gameplayClock { get; set; }
[CanBeNull]
private TimedDifficultyAttributes[] timedAttributes;
@ -70,7 +73,24 @@ namespace osu.Game.Screens.Play.HUD
base.LoadComplete();
if (scoreProcessor != null)
{
scoreProcessor.NewJudgement += onNewJudgement;
scoreProcessor.JudgementReverted += onJudgementReverted;
}
}
private bool isValid;
protected bool IsValid
{
set
{
if (value == isValid)
return;
isValid = value;
DrawableCount.FadeTo(isValid ? 1 : 0.3f, 1000, Easing.OutQuint);
}
}
private void onNewJudgement(JudgementResult judgement)
@ -86,6 +106,12 @@ namespace osu.Game.Screens.Play.HUD
var calculator = gameplayState.Ruleset.CreatePerformanceCalculator(timedAttributes[attribIndex].Attributes, gameplayState.Score.ScoreInfo);
Current.Value = (int)Math.Round(calculator?.Calculate() ?? 0, MidpointRounding.AwayFromZero);
IsValid = true;
}
private void onJudgementReverted(JudgementResult obj)
{
IsValid = false;
}
protected override LocalisableString FormatCount(int count) => count.ToString(@"D");