mirror of
https://github.com/ppy/osu
synced 2025-01-04 05:12:10 +00:00
Fix regressed HitErrorDisplay
behaviour (and localise binding to meter implementations)
This commit is contained in:
parent
78952c07b0
commit
97e72849af
@ -2,15 +2,16 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Catch.Scoring;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
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.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Scoring;
|
||||
@ -20,14 +21,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
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;
|
||||
|
||||
[Cached]
|
||||
private ScoreProcessor scoreProcessor = new ScoreProcessor();
|
||||
|
||||
public TestSceneHitErrorMeter()
|
||||
{
|
||||
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,
|
||||
Origin = Anchor.CentreRight,
|
||||
});
|
||||
|
||||
Add(barMeter2 = new BarHitErrorMeter(hitWindows, false)
|
||||
Add(new BarHitErrorMeter(hitWindows, false)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
});
|
||||
|
||||
Add(barMeter3 = new BarHitErrorMeter(hitWindows, true)
|
||||
Add(new BarHitErrorMeter(hitWindows, true)
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Rotation = 270,
|
||||
});
|
||||
|
||||
Add(colourMeter = new ColourHitErrorMeter(hitWindows)
|
||||
Add(new ColourHitErrorMeter(hitWindows)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Margin = new MarginPadding { Right = 50 }
|
||||
});
|
||||
|
||||
Add(colourMeter2 = new ColourHitErrorMeter(hitWindows)
|
||||
Add(new ColourHitErrorMeter(hitWindows)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 50 }
|
||||
});
|
||||
|
||||
Add(colourMeter3 = new ColourHitErrorMeter(hitWindows)
|
||||
Add(new ColourHitErrorMeter(hitWindows)
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.CentreLeft,
|
||||
@ -149,18 +147,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
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,
|
||||
Type = HitResult.Perfect,
|
||||
};
|
||||
|
||||
barMeter.OnNewJudgement(judgement);
|
||||
barMeter2.OnNewJudgement(judgement);
|
||||
barMeter3.OnNewJudgement(judgement);
|
||||
colourMeter.OnNewJudgement(judgement);
|
||||
colourMeter2.OnNewJudgement(judgement);
|
||||
colourMeter3.OnNewJudgement(judgement);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||
|
||||
@ -22,17 +21,11 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private readonly HitWindows hitWindows;
|
||||
|
||||
[Resolved]
|
||||
private ScoreProcessor processor { get; set; }
|
||||
|
||||
public HitErrorDisplay(HitWindows hitWindows)
|
||||
{
|
||||
this.hitWindows = hitWindows;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
if (processor != null)
|
||||
processor.NewJudgement += onNewJudgement;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -47,15 +40,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
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)
|
||||
{
|
||||
Children.ForEach(c => c.FadeOut(fade_duration, Easing.OutQuint));
|
||||
@ -139,13 +123,5 @@ namespace osu.Game.Screens.Play.HUD
|
||||
Add(display);
|
||||
display.FadeInFromZero(fade_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (processor != null)
|
||||
processor.NewJudgement -= onNewJudgement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
|
||||
private const int max_concurrent_judgements = 50;
|
||||
|
||||
public override void OnNewJudgement(JudgementResult judgement)
|
||||
protected override void OnNewJudgement(JudgementResult judgement)
|
||||
{
|
||||
if (!judgement.IsHit)
|
||||
return;
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
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>
|
||||
{
|
||||
|
@ -14,6 +14,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
protected readonly HitWindows HitWindows;
|
||||
|
||||
[Resolved]
|
||||
private ScoreProcessor processor { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
@ -22,7 +25,23 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
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)
|
||||
{
|
||||
@ -47,5 +66,13 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
return colours.BlueLight;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (processor != null)
|
||||
processor.NewJudgement -= onNewJudgement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user