2021-09-20 10:28:58 -04:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-08-30 15:32:47 +09:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-12-21 14:52:53 +03:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-08-30 15:32:47 +09:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-12-21 14:52:53 +03:00
|
|
|
|
using osu.Game.Graphics;
|
2019-08-30 15:32:47 +09:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2019-09-06 15:24:00 +09:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2021-05-17 19:46:50 +09:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osu.Game.Skinning;
|
2019-12-21 14:52:53 +03:00
|
|
|
|
using osuTK.Graphics;
|
2019-08-30 15:32:47 +09:00
|
|
|
|
|
2019-08-30 18:46:42 +09:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
2019-08-30 15:32:47 +09:00
|
|
|
|
{
|
2021-05-17 19:46:50 +09:00
|
|
|
|
public abstract partial class HitErrorMeter : CompositeDrawable, ISkinnableDrawable
|
2019-08-30 15:32:47 +09:00
|
|
|
|
{
|
2021-05-17 19:46:50 +09:00
|
|
|
|
protected HitWindows HitWindows { get; private set; }
|
2019-08-30 15:32:47 +09:00
|
|
|
|
|
2021-05-10 15:19:27 +09:00
|
|
|
|
[Resolved]
|
|
|
|
|
private ScoreProcessor processor { get; set; }
|
|
|
|
|
|
2019-12-21 14:52:53 +03:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
2021-09-17 16:19:41 -04:00
|
|
|
|
[Resolved(canBeNull: true)]
|
2021-09-20 10:28:58 -04:00
|
|
|
|
private GameplayClockContainer gameplayClockContainer { get; set; }
|
2021-09-17 16:19:41 -04:00
|
|
|
|
|
2021-06-08 08:22:35 -04:00
|
|
|
|
public bool UsesFixedAnchor { get; set; }
|
2021-06-06 23:47:47 -04:00
|
|
|
|
|
2021-05-17 19:46:50 +09:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
|
private void load(DrawableRuleset drawableRuleset)
|
2019-08-30 15:32:47 +09:00
|
|
|
|
{
|
2021-05-17 19:46:50 +09:00
|
|
|
|
HitWindows = drawableRuleset?.FirstAvailableHitWindows ?? HitWindows.Empty;
|
2022-06-13 23:54:43 +09:00
|
|
|
|
|
|
|
|
|
// This is to allow the visual state to be correct after HUD comes visible after being hidden.
|
|
|
|
|
AlwaysPresent = true;
|
2019-08-30 15:32:47 +09:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-10 15:19:27 +09:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2021-09-20 10:28:58 -04:00
|
|
|
|
if (gameplayClockContainer != null)
|
|
|
|
|
gameplayClockContainer.OnSeek += Clear;
|
2021-09-17 16:19:41 -04:00
|
|
|
|
|
2021-12-21 13:05:26 +09:00
|
|
|
|
processor.NewJudgement += processorNewJudgement;
|
2021-05-10 15:19:27 +09:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-21 13:05:26 +09:00
|
|
|
|
// Scheduled as meter implementations are likely going to change/add drawables when reacting to this.
|
|
|
|
|
private void processorNewJudgement(JudgementResult j) => Schedule(() => OnNewJudgement(j));
|
|
|
|
|
|
2021-12-21 12:55:21 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fired when a new judgement arrives.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="judgement">The new judgement.</param>
|
2021-05-10 15:19:27 +09:00
|
|
|
|
protected abstract void OnNewJudgement(JudgementResult judgement);
|
2019-12-21 14:52:53 +03:00
|
|
|
|
|
|
|
|
|
protected Color4 GetColourForHitResult(HitResult result)
|
|
|
|
|
{
|
2022-09-07 23:34:46 +09:00
|
|
|
|
return colours.ForHitResult(result);
|
2019-12-21 14:52:53 +03:00
|
|
|
|
}
|
2021-05-10 15:19:27 +09:00
|
|
|
|
|
2021-09-18 12:18:11 -04:00
|
|
|
|
/// <summary>
|
2021-09-20 10:28:58 -04:00
|
|
|
|
/// Invoked by <see cref="GameplayClockContainer.OnSeek"/>.
|
2021-09-18 12:18:11 -04:00
|
|
|
|
/// Any inheritors of <see cref="HitErrorMeter"/> should have this method clear their container that displays the hit error results.
|
|
|
|
|
/// </summary>
|
2021-09-20 10:22:36 -04:00
|
|
|
|
public abstract void Clear();
|
2021-09-17 16:19:41 -04:00
|
|
|
|
|
2021-05-10 15:19:27 +09:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
|
|
if (processor != null)
|
2021-12-21 13:05:26 +09:00
|
|
|
|
processor.NewJudgement -= processorNewJudgement;
|
2021-09-20 10:07:42 -04:00
|
|
|
|
|
2021-09-20 10:28:58 -04:00
|
|
|
|
if (gameplayClockContainer != null)
|
|
|
|
|
gameplayClockContainer.OnSeek -= Clear;
|
2021-05-10 15:19:27 +09:00
|
|
|
|
}
|
2019-08-30 15:32:47 +09:00
|
|
|
|
}
|
|
|
|
|
}
|