1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-04 01:22:54 +08:00

Initial version

This commit is contained in:
Mk-56spn 2022-09-02 23:07:30 +02:00
parent e1e46ad7aa
commit 534c40e18e

View File

@ -5,9 +5,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Configuration;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osuTK; using osuTK;
@ -17,18 +19,39 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{ {
public class ColourHitErrorMeter : HitErrorMeter public class ColourHitErrorMeter : HitErrorMeter
{ {
internal const int MAX_DISPLAYED_JUDGEMENTS = 20;
private const int animation_duration = 200; private const int animation_duration = 200;
private const int drawable_judgement_size = 8; private const int drawable_judgement_size = 8;
private const int spacing = 2; private const int spacing = 2;
private readonly JudgementFlow judgementsFlow; 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() public ColourHitErrorMeter()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
InternalChild = judgementsFlow = new JudgementFlow(); InternalChild = judgementsFlow = new JudgementFlow(HitCircleAmount.Value, HitOpacity.Value);
} }
protected override void OnNewJudgement(JudgementResult judgement) protected override void OnNewJudgement(JudgementResult judgement)
@ -36,7 +59,15 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
if (!judgement.Type.IsScorable() || judgement.Type.IsBonus()) if (!judgement.Type.IsScorable() || judgement.Type.IsBonus())
return; 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(); 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 override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
public JudgementFlow() public JudgementFlow(int hitCircleAmount, float opacity)
{ {
AutoSizeAxes = Axes.X; AutoSizeAxes = Axes.X;
Height = MAX_DISPLAYED_JUDGEMENTS * (drawable_judgement_size + spacing) - spacing;
Spacing = new Vector2(0, spacing); Spacing = new Vector2(0, spacing);
Direction = FillDirection.Vertical; Direction = FillDirection.Vertical;
LayoutDuration = animation_duration; LayoutDuration = animation_duration;
LayoutEasing = Easing.OutQuint; LayoutEasing = Easing.OutQuint;
} }
public void Push(Color4 colour) public void Push(Color4 colour, int amount)
{ {
Add(new HitErrorCircle(colour, drawable_judgement_size)); Add(new HitErrorCircle(colour, drawable_judgement_size));
if (Children.Count > MAX_DISPLAYED_JUDGEMENTS) if (Children.Count > amount)
Children.FirstOrDefault(c => !c.IsRemoved)?.Remove(); Children.FirstOrDefault(c => !c.IsRemoved)?.Remove();
} }
} }