1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:33:21 +08:00

Merge pull request #14702 from sh0ckR6/14470-ur-not-updating

Clear UR bar marks after seeking
This commit is contained in:
Bartłomiej Dach 2021-09-20 22:31:53 +02:00 committed by GitHub
commit 064e0659e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 0 deletions

View File

@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
@ -137,6 +138,23 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
}
[Test]
public void TestClear()
{
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
AddStep("hit", () => newJudgement(0.2D));
AddAssert("bar added", () => this.ChildrenOfType<BarHitErrorMeter>().All(
meter => meter.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Count() == 1));
AddAssert("circle added", () => this.ChildrenOfType<ColourHitErrorMeter>().All(
meter => meter.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Count() == 1));
AddStep("clear", () => this.ChildrenOfType<HitErrorMeter>().ForEach(meter => meter.Clear()));
AddAssert("bar cleared", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
AddAssert("colour cleared", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
}
private void recreateDisplay(HitWindows hitWindows, float overallDifficulty)
{
hitWindows?.SetDifficulty(overallDifficulty);

View File

@ -13,6 +13,7 @@ namespace osu.Game.Screens.Play
/// <summary>
/// Encapsulates gameplay timing logic and provides a <see cref="GameplayClock"/> via DI for gameplay components to use.
/// </summary>
[Cached]
public abstract class GameplayClockContainer : Container, IAdjustableClock
{
/// <summary>
@ -35,6 +36,11 @@ namespace osu.Game.Screens.Play
/// </summary>
protected IClock SourceClock { get; private set; }
/// <summary>
/// Invoked when a seek has been performed via <see cref="Seek"/>
/// </summary>
public event Action OnSeek;
/// <summary>
/// Creates a new <see cref="GameplayClockContainer"/>.
/// </summary>
@ -88,6 +94,8 @@ namespace osu.Game.Screens.Play
// Manually process to make sure the gameplay clock is correctly updated after a seek.
GameplayClock.UnderlyingClock.ProcessFrame();
OnSeek?.Invoke();
}
/// <summary>

View File

@ -286,5 +286,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
this.FadeTo(0.8f, 150).Then().FadeOut(judgement_fade_duration).Expire();
}
}
public override void Clear() => judgementsContainer.Clear();
}
}

View File

@ -33,6 +33,8 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
judgementsFlow.Push(GetColourForHitResult(judgement.Type));
}
public override void Clear() => judgementsFlow.Clear();
private class JudgementFlow : FillFlowContainer<HitErrorCircle>
{
private const int max_available_judgements = 20;

View File

@ -22,6 +22,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
[Resolved]
private OsuColour colours { get; set; }
[Resolved(canBeNull: true)]
private GameplayClockContainer gameplayClockContainer { get; set; }
public bool UsesFixedAnchor { get; set; }
[BackgroundDependencyLoader(true)]
@ -34,6 +37,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
base.LoadComplete();
if (gameplayClockContainer != null)
gameplayClockContainer.OnSeek += Clear;
processor.NewJudgement += OnNewJudgement;
}
@ -67,12 +73,21 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
}
}
/// <summary>
/// Invoked by <see cref="GameplayClockContainer.OnSeek"/>.
/// Any inheritors of <see cref="HitErrorMeter"/> should have this method clear their container that displays the hit error results.
/// </summary>
public abstract void Clear();
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (processor != null)
processor.NewJudgement -= OnNewJudgement;
if (gameplayClockContainer != null)
gameplayClockContainer.OnSeek -= Clear;
}
}
}