mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 00:42:55 +08:00
Initial version
This commit is contained in:
parent
e1e46ad7aa
commit
534c40e18e
@ -5,9 +5,11 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
@ -17,18 +19,39 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
public class ColourHitErrorMeter : HitErrorMeter
|
||||
{
|
||||
internal const int MAX_DISPLAYED_JUDGEMENTS = 20;
|
||||
|
||||
private const int animation_duration = 200;
|
||||
private const int drawable_judgement_size = 8;
|
||||
private const int spacing = 2;
|
||||
|
||||
private readonly JudgementFlow judgementsFlow;
|
||||
|
||||
[SettingSource("Colour hit number", "number of coloured hits")]
|
||||
public BindableNumber<int> HitCircleAmount { get; } = new BindableNumber<int>(20)
|
||||
{
|
||||
MinValue = 1,
|
||||
MaxValue = 30,
|
||||
Precision = 1
|
||||
};
|
||||
|
||||
[SettingSource("Opacity", "Visibility of object")]
|
||||
public BindableNumber<float> HitOpacity { get; } = new BindableNumber<float>(1)
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 1,
|
||||
Precision = .01f
|
||||
};
|
||||
|
||||
[SettingSource("Spacing", "space between hit colour circles")]
|
||||
public BindableNumber<float> HitSpacing { get; } = new BindableNumber<float>(1)
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 1,
|
||||
Precision = .01f
|
||||
};
|
||||
|
||||
public ColourHitErrorMeter()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
InternalChild = judgementsFlow = new JudgementFlow();
|
||||
InternalChild = judgementsFlow = new JudgementFlow(HitCircleAmount.Value, HitOpacity.Value);
|
||||
}
|
||||
|
||||
protected override void OnNewJudgement(JudgementResult judgement)
|
||||
@ -36,7 +59,15 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
if (!judgement.Type.IsScorable() || judgement.Type.IsBonus())
|
||||
return;
|
||||
|
||||
judgementsFlow.Push(GetColourForHitResult(judgement.Type));
|
||||
judgementsFlow.Push(GetColourForHitResult(judgement.Type), HitCircleAmount.Value);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
judgementsFlow.Height = HitCircleAmount.Value * (drawable_judgement_size + spacing) - spacing;
|
||||
judgementsFlow.Alpha = HitOpacity.Value;
|
||||
judgementsFlow.Spacing = new Vector2(0, HitSpacing.Value);
|
||||
}
|
||||
|
||||
public override void Clear() => judgementsFlow.Clear();
|
||||
@ -45,21 +76,20 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
||||
|
||||
public JudgementFlow()
|
||||
public JudgementFlow(int hitCircleAmount, float opacity)
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
Height = MAX_DISPLAYED_JUDGEMENTS * (drawable_judgement_size + spacing) - spacing;
|
||||
Spacing = new Vector2(0, spacing);
|
||||
Direction = FillDirection.Vertical;
|
||||
LayoutDuration = animation_duration;
|
||||
LayoutEasing = Easing.OutQuint;
|
||||
}
|
||||
|
||||
public void Push(Color4 colour)
|
||||
public void Push(Color4 colour, int amount)
|
||||
{
|
||||
Add(new HitErrorCircle(colour, drawable_judgement_size));
|
||||
|
||||
if (Children.Count > MAX_DISPLAYED_JUDGEMENTS)
|
||||
if (Children.Count > amount)
|
||||
Children.FirstOrDefault(c => !c.IsRemoved)?.Remove();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user