2019-08-30 14:32:47 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2019-12-21 19:52:53 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-08-30 14:32:47 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-12-21 19:52:53 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2019-08-30 14:32:47 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2019-09-06 14:24:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-12-21 19:52:53 +08:00
|
|
|
|
using osuTK.Graphics;
|
2019-08-30 14:32:47 +08:00
|
|
|
|
|
2019-08-30 17:46:42 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
2019-08-30 14:32:47 +08:00
|
|
|
|
{
|
|
|
|
|
public abstract class HitErrorMeter : CompositeDrawable
|
|
|
|
|
{
|
|
|
|
|
protected readonly HitWindows HitWindows;
|
|
|
|
|
|
2021-05-10 14:19:27 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private ScoreProcessor processor { get; set; }
|
|
|
|
|
|
2019-12-21 19:52:53 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
2019-08-30 14:32:47 +08:00
|
|
|
|
protected HitErrorMeter(HitWindows hitWindows)
|
|
|
|
|
{
|
|
|
|
|
HitWindows = hitWindows;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-10 14:19:27 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2021-05-10 15:40:06 +08:00
|
|
|
|
processor.NewJudgement += onNewJudgement;
|
2021-05-10 14:19:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onNewJudgement(JudgementResult result)
|
|
|
|
|
{
|
|
|
|
|
if (result.HitObject.HitWindows?.WindowFor(HitResult.Miss) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
OnNewJudgement(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract void OnNewJudgement(JudgementResult judgement);
|
2019-12-21 19:52:53 +08:00
|
|
|
|
|
|
|
|
|
protected Color4 GetColourForHitResult(HitResult result)
|
|
|
|
|
{
|
|
|
|
|
switch (result)
|
|
|
|
|
{
|
|
|
|
|
case HitResult.Miss:
|
|
|
|
|
return colours.Red;
|
|
|
|
|
|
|
|
|
|
case HitResult.Meh:
|
|
|
|
|
return colours.Yellow;
|
|
|
|
|
|
|
|
|
|
case HitResult.Ok:
|
|
|
|
|
return colours.Green;
|
|
|
|
|
|
|
|
|
|
case HitResult.Good:
|
|
|
|
|
return colours.GreenLight;
|
|
|
|
|
|
|
|
|
|
case HitResult.Great:
|
|
|
|
|
return colours.Blue;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return colours.BlueLight;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-10 14:19:27 +08:00
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
|
|
if (processor != null)
|
|
|
|
|
processor.NewJudgement -= onNewJudgement;
|
|
|
|
|
}
|
2019-08-30 14:32:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|