1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-07 16:52:54 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs
Bartłomiej Dach 0531c2dcd9 Move empty window check to bar error meter
It's not valid in the base `HitErrorMeter`, as the colour meter only
displays colour for a given judgement, so it is still valid to add new
items to it even if the hit window is 0, as misses are still possible.
2021-06-07 13:16:07 +02:00

73 lines
2.0 KiB
C#

// 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.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Skinning;
using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
public abstract class HitErrorMeter : CompositeDrawable, ISkinnableDrawable
{
protected HitWindows HitWindows { get; private set; }
[Resolved]
private ScoreProcessor processor { get; set; }
[Resolved]
private OsuColour colours { get; set; }
[BackgroundDependencyLoader(true)]
private void load(DrawableRuleset drawableRuleset)
{
HitWindows = drawableRuleset?.FirstAvailableHitWindows ?? HitWindows.Empty;
}
protected override void LoadComplete()
{
base.LoadComplete();
processor.NewJudgement += OnNewJudgement;
}
protected abstract void OnNewJudgement(JudgementResult judgement);
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;
}
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (processor != null)
processor.NewJudgement -= OnNewJudgement;
}
}
}