1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 17:23:52 +08:00

Fix regressed HitErrorDisplay behaviour (and localise binding to meter implementations)

This commit is contained in:
Dean Herbert 2021-05-10 15:19:27 +09:00
parent 78952c07b0
commit 97e72849af
5 changed files with 45 additions and 51 deletions

View File

@ -2,15 +2,16 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Rulesets.Judgements; using osu.Framework.Allocation;
using osu.Framework.Utils;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Catch.Scoring; using osu.Game.Rulesets.Catch.Scoring;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Scoring; using osu.Game.Rulesets.Taiko.Scoring;
@ -20,14 +21,11 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
public class TestSceneHitErrorMeter : OsuTestScene public class TestSceneHitErrorMeter : OsuTestScene
{ {
private BarHitErrorMeter barMeter;
private BarHitErrorMeter barMeter2;
private BarHitErrorMeter barMeter3;
private ColourHitErrorMeter colourMeter;
private ColourHitErrorMeter colourMeter2;
private ColourHitErrorMeter colourMeter3;
private HitWindows hitWindows; private HitWindows hitWindows;
[Cached]
private ScoreProcessor scoreProcessor = new ScoreProcessor();
public TestSceneHitErrorMeter() public TestSceneHitErrorMeter()
{ {
recreateDisplay(new OsuHitWindows(), 5); recreateDisplay(new OsuHitWindows(), 5);
@ -105,40 +103,40 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
}); });
Add(barMeter = new BarHitErrorMeter(hitWindows, true) Add(new BarHitErrorMeter(hitWindows, true)
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
}); });
Add(barMeter2 = new BarHitErrorMeter(hitWindows, false) Add(new BarHitErrorMeter(hitWindows, false)
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
}); });
Add(barMeter3 = new BarHitErrorMeter(hitWindows, true) Add(new BarHitErrorMeter(hitWindows, true)
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Rotation = 270, Rotation = 270,
}); });
Add(colourMeter = new ColourHitErrorMeter(hitWindows) Add(new ColourHitErrorMeter(hitWindows)
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 50 } Margin = new MarginPadding { Right = 50 }
}); });
Add(colourMeter2 = new ColourHitErrorMeter(hitWindows) Add(new ColourHitErrorMeter(hitWindows)
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Left = 50 } Margin = new MarginPadding { Left = 50 }
}); });
Add(colourMeter3 = new ColourHitErrorMeter(hitWindows) Add(new ColourHitErrorMeter(hitWindows)
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
@ -149,18 +147,11 @@ namespace osu.Game.Tests.Visual.Gameplay
private void newJudgement(double offset = 0) private void newJudgement(double offset = 0)
{ {
var judgement = new JudgementResult(new HitObject(), new Judgement()) scoreProcessor.ApplyResult(new JudgementResult(new HitCircle { HitWindows = hitWindows }, new Judgement())
{ {
TimeOffset = offset == 0 ? RNG.Next(-150, 150) : offset, TimeOffset = offset == 0 ? RNG.Next(-150, 150) : offset,
Type = HitResult.Perfect, Type = HitResult.Perfect,
}; });
barMeter.OnNewJudgement(judgement);
barMeter2.OnNewJudgement(judgement);
barMeter3.OnNewJudgement(judgement);
colourMeter.OnNewJudgement(judgement);
colourMeter2.OnNewJudgement(judgement);
colourMeter3.OnNewJudgement(judgement);
} }
} }
} }

View File

@ -7,7 +7,6 @@ using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD.HitErrorMeters; using osu.Game.Screens.Play.HUD.HitErrorMeters;
@ -22,17 +21,11 @@ namespace osu.Game.Screens.Play.HUD
private readonly HitWindows hitWindows; private readonly HitWindows hitWindows;
[Resolved]
private ScoreProcessor processor { get; set; }
public HitErrorDisplay(HitWindows hitWindows) public HitErrorDisplay(HitWindows hitWindows)
{ {
this.hitWindows = hitWindows; this.hitWindows = hitWindows;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
if (processor != null)
processor.NewJudgement += onNewJudgement;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -47,15 +40,6 @@ namespace osu.Game.Screens.Play.HUD
type.BindValueChanged(typeChanged, true); type.BindValueChanged(typeChanged, true);
} }
private void onNewJudgement(JudgementResult result)
{
if (result.HitObject.HitWindows.WindowFor(HitResult.Miss) == 0)
return;
foreach (var c in Children)
c.OnNewJudgement(result);
}
private void typeChanged(ValueChangedEvent<ScoreMeterType> type) private void typeChanged(ValueChangedEvent<ScoreMeterType> type)
{ {
Children.ForEach(c => c.FadeOut(fade_duration, Easing.OutQuint)); Children.ForEach(c => c.FadeOut(fade_duration, Easing.OutQuint));
@ -139,13 +123,5 @@ namespace osu.Game.Screens.Play.HUD
Add(display); Add(display);
display.FadeInFromZero(fade_duration, Easing.OutQuint); display.FadeInFromZero(fade_duration, Easing.OutQuint);
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (processor != null)
processor.NewJudgement -= onNewJudgement;
}
} }
} }

View File

@ -214,7 +214,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
private const int max_concurrent_judgements = 50; private const int max_concurrent_judgements = 50;
public override void OnNewJudgement(JudgementResult judgement) protected override void OnNewJudgement(JudgementResult judgement)
{ {
if (!judgement.IsHit) if (!judgement.IsHit)
return; return;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
InternalChild = judgementsFlow = new JudgementFlow(); InternalChild = judgementsFlow = new JudgementFlow();
} }
public override void OnNewJudgement(JudgementResult judgement) => judgementsFlow.Push(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset))); protected override void OnNewJudgement(JudgementResult judgement) => judgementsFlow.Push(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)));
private class JudgementFlow : FillFlowContainer<HitErrorCircle> private class JudgementFlow : FillFlowContainer<HitErrorCircle>
{ {

View File

@ -14,6 +14,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{ {
protected readonly HitWindows HitWindows; protected readonly HitWindows HitWindows;
[Resolved]
private ScoreProcessor processor { get; set; }
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; }
@ -22,7 +25,23 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
HitWindows = hitWindows; HitWindows = hitWindows;
} }
public abstract void OnNewJudgement(JudgementResult judgement); protected override void LoadComplete()
{
base.LoadComplete();
if (processor != null)
processor.NewJudgement += onNewJudgement;
}
private void onNewJudgement(JudgementResult result)
{
if (result.HitObject.HitWindows?.WindowFor(HitResult.Miss) == 0)
return;
OnNewJudgement(result);
}
protected abstract void OnNewJudgement(JudgementResult judgement);
protected Color4 GetColourForHitResult(HitResult result) protected Color4 GetColourForHitResult(HitResult result)
{ {
@ -47,5 +66,13 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
return colours.BlueLight; return colours.BlueLight;
} }
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (processor != null)
processor.NewJudgement -= onNewJudgement;
}
} }
} }