2019-08-20 01:44:06 +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.
|
|
|
|
|
|
2020-03-08 22:51:57 +08:00
|
|
|
|
using System;
|
2019-08-30 17:35:06 +08:00
|
|
|
|
using System.Linq;
|
2019-08-30 17:46:42 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2022-03-18 15:50:37 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-08-30 17:46:42 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2019-08-20 01:44:06 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-08-30 17:46:42 +08:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2019-08-20 01:44:06 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-11-13 23:53:38 +08:00
|
|
|
|
using osu.Framework.Graphics.Pooling;
|
2019-08-20 01:44:06 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-03-18 15:50:37 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2022-03-18 16:46:22 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2022-10-17 01:06:38 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2022-03-18 16:46:22 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-08-30 17:46:42 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2019-08-30 17:35:06 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-08-30 17:46:42 +08:00
|
|
|
|
using osuTK;
|
2019-08-20 01:44:06 +08:00
|
|
|
|
|
2019-08-30 17:46:42 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
2019-08-20 01:44:06 +08:00
|
|
|
|
{
|
2022-11-13 23:53:38 +08:00
|
|
|
|
[Cached]
|
2021-09-18 04:19:41 +08:00
|
|
|
|
public partial class BarHitErrorMeter : HitErrorMeter
|
2019-08-20 01:44:06 +08:00
|
|
|
|
{
|
2022-03-18 15:50:37 +08:00
|
|
|
|
[SettingSource("Judgement line thickness", "How thick the individual lines should be.")]
|
|
|
|
|
public BindableNumber<float> JudgementLineThickness { get; } = new BindableNumber<float>(4)
|
|
|
|
|
{
|
|
|
|
|
MinValue = 1,
|
|
|
|
|
MaxValue = 8,
|
|
|
|
|
Precision = 0.1f,
|
|
|
|
|
};
|
2022-03-14 18:16:38 +08:00
|
|
|
|
|
2022-03-18 15:54:09 +08:00
|
|
|
|
[SettingSource("Show moving average arrow", "Whether an arrow should move beneath the bar showing the average error.")]
|
|
|
|
|
public Bindable<bool> ShowMovingAverage { get; } = new BindableBool(true);
|
|
|
|
|
|
2022-03-18 16:16:40 +08:00
|
|
|
|
[SettingSource("Centre marker style", "How to signify the centre of the display")]
|
2022-03-18 16:23:27 +08:00
|
|
|
|
public Bindable<CentreMarkerStyles> CentreMarkerStyle { get; } = new Bindable<CentreMarkerStyles>(CentreMarkerStyles.Circle);
|
2022-03-18 16:16:40 +08:00
|
|
|
|
|
2022-03-18 16:46:22 +08:00
|
|
|
|
[SettingSource("Label style", "How to show early/late extremities")]
|
|
|
|
|
public Bindable<LabelStyles> LabelStyle { get; } = new Bindable<LabelStyles>(LabelStyles.Icons);
|
|
|
|
|
|
2022-11-14 00:07:53 +08:00
|
|
|
|
private const int judgement_line_width = 14;
|
2019-08-30 15:40:39 +08:00
|
|
|
|
|
2022-11-14 00:07:53 +08:00
|
|
|
|
private const int max_concurrent_judgements = 50;
|
2019-08-30 15:40:39 +08:00
|
|
|
|
|
2022-11-14 00:07:53 +08:00
|
|
|
|
private const int centre_marker_size = 8;
|
2019-08-30 15:40:39 +08:00
|
|
|
|
|
2019-08-30 17:35:06 +08:00
|
|
|
|
private double maxHitWindow;
|
2019-08-20 01:44:06 +08:00
|
|
|
|
|
2022-03-18 15:54:09 +08:00
|
|
|
|
private double floatingAverage;
|
|
|
|
|
|
2022-11-15 11:05:38 +08:00
|
|
|
|
private readonly DrawablePool<JudgementLine> judgementLinePool = new DrawablePool<JudgementLine>(50);
|
2022-11-14 00:07:53 +08:00
|
|
|
|
|
|
|
|
|
private SpriteIcon arrow = null!;
|
|
|
|
|
private UprightAspectMaintainingContainer labelEarly = null!;
|
|
|
|
|
private UprightAspectMaintainingContainer labelLate = null!;
|
2022-03-18 16:16:40 +08:00
|
|
|
|
|
2022-11-14 00:07:53 +08:00
|
|
|
|
private Container colourBarsEarly = null!;
|
|
|
|
|
private Container colourBarsLate = null!;
|
2022-03-18 15:54:09 +08:00
|
|
|
|
|
2022-11-14 00:07:53 +08:00
|
|
|
|
private Container judgementsContainer = null!;
|
2022-03-18 16:16:40 +08:00
|
|
|
|
|
2022-11-14 00:07:53 +08:00
|
|
|
|
private Container colourBars = null!;
|
|
|
|
|
private Container arrowContainer = null!;
|
|
|
|
|
|
|
|
|
|
private (HitResult result, double length)[] hitWindows = null!;
|
|
|
|
|
|
|
|
|
|
private Drawable[]? centreMarkerDrawables;
|
2022-03-18 16:16:40 +08:00
|
|
|
|
|
2021-05-17 18:46:50 +08:00
|
|
|
|
public BarHitErrorMeter()
|
2019-08-20 01:44:06 +08:00
|
|
|
|
{
|
2019-08-20 03:45:27 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2019-08-30 16:06:23 +08:00
|
|
|
|
}
|
2019-08-30 15:40:39 +08:00
|
|
|
|
|
2019-08-30 16:06:23 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-02-02 04:27:14 +08:00
|
|
|
|
private void load()
|
2019-08-30 16:06:23 +08:00
|
|
|
|
{
|
2022-03-14 18:18:47 +08:00
|
|
|
|
const int bar_height = 200;
|
|
|
|
|
const int bar_width = 2;
|
|
|
|
|
const float chevron_size = 8;
|
|
|
|
|
|
2022-03-18 16:16:40 +08:00
|
|
|
|
hitWindows = HitWindows.GetAllAvailableWindows().ToArray();
|
2022-03-14 18:16:38 +08:00
|
|
|
|
|
|
|
|
|
InternalChild = new Container
|
2019-08-20 01:44:06 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = bar_height,
|
2019-08-30 16:06:23 +08:00
|
|
|
|
Margin = new MarginPadding(2),
|
2019-08-20 01:44:06 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2022-11-13 23:53:38 +08:00
|
|
|
|
judgementLinePool,
|
2019-08-30 17:35:06 +08:00
|
|
|
|
colourBars = new Container
|
2019-08-20 01:44:06 +08:00
|
|
|
|
{
|
2022-03-14 18:16:38 +08:00
|
|
|
|
Name = "colour axis",
|
|
|
|
|
X = chevron_size,
|
2021-05-18 13:50:10 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2022-03-14 18:16:38 +08:00
|
|
|
|
Width = judgement_line_width,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2019-08-30 17:35:06 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2022-03-14 18:16:38 +08:00
|
|
|
|
colourBarsEarly = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Width = bar_width,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Height = 0.5f,
|
|
|
|
|
Scale = new Vector2(1, -1),
|
|
|
|
|
},
|
|
|
|
|
colourBarsLate = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Width = bar_width,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Height = 0.5f,
|
|
|
|
|
},
|
2022-03-14 18:27:53 +08:00
|
|
|
|
judgementsContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "judgements",
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = judgement_line_width,
|
|
|
|
|
},
|
2022-10-17 12:22:06 +08:00
|
|
|
|
labelEarly = new UprightAspectMaintainingContainer
|
|
|
|
|
{
|
2022-10-17 02:47:21 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Y = -10,
|
|
|
|
|
},
|
2022-10-17 12:22:06 +08:00
|
|
|
|
labelLate = new UprightAspectMaintainingContainer
|
|
|
|
|
{
|
2022-10-17 02:47:21 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Y = 10,
|
|
|
|
|
},
|
2019-08-30 17:35:06 +08:00
|
|
|
|
}
|
2019-08-20 01:44:06 +08:00
|
|
|
|
},
|
2022-03-18 15:54:09 +08:00
|
|
|
|
arrowContainer = new Container
|
2019-08-20 01:44:06 +08:00
|
|
|
|
{
|
2022-03-14 18:16:38 +08:00
|
|
|
|
Name = "average chevron",
|
2021-05-18 13:50:10 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2022-03-18 15:54:09 +08:00
|
|
|
|
Origin = Anchor.CentreRight,
|
2022-03-14 18:16:38 +08:00
|
|
|
|
Width = chevron_size,
|
2022-03-18 15:54:09 +08:00
|
|
|
|
X = chevron_size,
|
2019-08-20 01:44:06 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2022-03-18 15:54:09 +08:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
Scale = new Vector2(0, 1),
|
2022-03-14 18:16:38 +08:00
|
|
|
|
Child = arrow = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativePositionAxes = Axes.Y,
|
|
|
|
|
Y = 0.5f,
|
|
|
|
|
Icon = FontAwesome.Solid.ChevronRight,
|
|
|
|
|
Size = new Vector2(chevron_size),
|
|
|
|
|
}
|
2019-08-20 01:44:06 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
2019-08-30 16:06:23 +08:00
|
|
|
|
};
|
2019-08-20 01:44:06 +08:00
|
|
|
|
|
2022-03-14 18:16:38 +08:00
|
|
|
|
createColourBars(hitWindows);
|
2019-08-20 01:44:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-30 16:06:23 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2019-08-30 17:35:06 +08:00
|
|
|
|
colourBars.Height = 0;
|
|
|
|
|
colourBars.ResizeHeightTo(1, 800, Easing.OutQuint);
|
2019-08-30 16:06:23 +08:00
|
|
|
|
|
2022-03-18 16:16:40 +08:00
|
|
|
|
CentreMarkerStyle.BindValueChanged(style => recreateCentreMarker(style.NewValue), true);
|
2022-03-18 16:46:22 +08:00
|
|
|
|
LabelStyle.BindValueChanged(style => recreateLabels(style.NewValue), true);
|
2022-03-18 16:16:40 +08:00
|
|
|
|
|
|
|
|
|
// delay the appearance animations for only the initial appearance.
|
|
|
|
|
using (arrowContainer.BeginDelayedSequence(450))
|
2022-03-18 15:54:09 +08:00
|
|
|
|
{
|
|
|
|
|
ShowMovingAverage.BindValueChanged(visible =>
|
|
|
|
|
{
|
|
|
|
|
arrowContainer.FadeTo(visible.NewValue ? 1 : 0, 250, Easing.OutQuint);
|
|
|
|
|
arrowContainer.ScaleTo(visible.NewValue ? new Vector2(1) : new Vector2(0, 1), 250, Easing.OutQuint);
|
|
|
|
|
}, true);
|
|
|
|
|
}
|
2019-08-30 16:06:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 16:23:27 +08:00
|
|
|
|
private void recreateCentreMarker(CentreMarkerStyles style)
|
2022-03-18 16:16:40 +08:00
|
|
|
|
{
|
|
|
|
|
if (centreMarkerDrawables != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var d in centreMarkerDrawables)
|
|
|
|
|
{
|
|
|
|
|
d.ScaleTo(0, 500, Easing.OutQuint)
|
|
|
|
|
.FadeOut(500, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
d.Expire();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
centreMarkerDrawables = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (style)
|
|
|
|
|
{
|
2022-03-18 16:23:27 +08:00
|
|
|
|
case CentreMarkerStyles.None:
|
2022-03-18 16:16:40 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2022-03-18 16:23:27 +08:00
|
|
|
|
case CentreMarkerStyles.Circle:
|
2022-03-18 16:16:40 +08:00
|
|
|
|
centreMarkerDrawables = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Circle
|
|
|
|
|
{
|
|
|
|
|
Name = "middle marker behind",
|
|
|
|
|
Colour = GetColourForHitResult(hitWindows.Last().result),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Depth = float.MaxValue,
|
|
|
|
|
Size = new Vector2(centre_marker_size),
|
|
|
|
|
},
|
|
|
|
|
new Circle
|
|
|
|
|
{
|
|
|
|
|
Name = "middle marker in front",
|
|
|
|
|
Colour = GetColourForHitResult(hitWindows.Last().result).Darken(0.3f),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Depth = float.MinValue,
|
2022-03-18 16:23:27 +08:00
|
|
|
|
Size = new Vector2(centre_marker_size / 2f),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CentreMarkerStyles.Line:
|
|
|
|
|
const float border_size = 1.5f;
|
|
|
|
|
|
|
|
|
|
centreMarkerDrawables = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Name = "middle marker behind",
|
|
|
|
|
Colour = GetColourForHitResult(hitWindows.Last().result),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Depth = float.MaxValue,
|
|
|
|
|
Size = new Vector2(judgement_line_width, centre_marker_size / 3f),
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Name = "middle marker in front",
|
|
|
|
|
Colour = GetColourForHitResult(hitWindows.Last().result).Darken(0.3f),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Depth = float.MinValue,
|
|
|
|
|
Size = new Vector2(judgement_line_width - border_size, centre_marker_size / 3f - border_size),
|
2022-03-18 16:16:40 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
break;
|
2022-03-18 16:23:27 +08:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(style), style, null);
|
2022-03-18 16:16:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (centreMarkerDrawables != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var d in centreMarkerDrawables)
|
|
|
|
|
{
|
|
|
|
|
colourBars.Add(d);
|
|
|
|
|
|
|
|
|
|
d.FadeInFromZero(500, Easing.OutQuint)
|
2022-03-18 16:23:27 +08:00
|
|
|
|
.ScaleTo(0).ScaleTo(1, 1000, Easing.OutElasticHalf);
|
2022-03-18 16:16:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 16:46:22 +08:00
|
|
|
|
private void recreateLabels(LabelStyles style)
|
|
|
|
|
{
|
|
|
|
|
const float icon_size = 14;
|
|
|
|
|
|
|
|
|
|
switch (style)
|
|
|
|
|
{
|
|
|
|
|
case LabelStyles.None:
|
2022-10-28 14:36:30 +08:00
|
|
|
|
labelEarly.Clear();
|
|
|
|
|
labelLate.Clear();
|
2022-03-18 16:46:22 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LabelStyles.Icons:
|
2022-10-17 02:47:21 +08:00
|
|
|
|
labelEarly.Child = new SpriteIcon
|
2022-03-18 16:46:22 +08:00
|
|
|
|
{
|
2022-10-17 02:47:21 +08:00
|
|
|
|
Size = new Vector2(icon_size),
|
|
|
|
|
Icon = FontAwesome.Solid.ShippingFast,
|
2022-03-18 16:46:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-10-17 02:47:21 +08:00
|
|
|
|
labelLate.Child = new SpriteIcon
|
2022-03-18 16:46:22 +08:00
|
|
|
|
{
|
2022-10-17 02:47:21 +08:00
|
|
|
|
Size = new Vector2(icon_size),
|
|
|
|
|
Icon = FontAwesome.Solid.Bicycle,
|
2022-03-18 16:46:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LabelStyles.Text:
|
2022-10-17 02:47:21 +08:00
|
|
|
|
labelEarly.Child = new OsuSpriteText
|
2022-03-18 16:46:22 +08:00
|
|
|
|
{
|
2022-10-17 02:47:21 +08:00
|
|
|
|
Text = "Early",
|
|
|
|
|
Font = OsuFont.Default.With(size: 10),
|
|
|
|
|
Height = 12,
|
2022-03-18 16:46:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-10-17 02:47:21 +08:00
|
|
|
|
labelLate.Child = new OsuSpriteText
|
2022-03-18 16:46:22 +08:00
|
|
|
|
{
|
2022-10-17 02:47:21 +08:00
|
|
|
|
Text = "Late",
|
|
|
|
|
Font = OsuFont.Default.With(size: 10),
|
|
|
|
|
Height = 12,
|
2022-03-18 16:46:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(style), style, null);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-17 02:47:21 +08:00
|
|
|
|
labelEarly.FadeInFromZero(500);
|
|
|
|
|
labelLate.FadeInFromZero(500);
|
2022-03-18 16:46:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 18:16:38 +08:00
|
|
|
|
private void createColourBars((HitResult result, double length)[] windows)
|
2019-08-20 13:00:09 +08:00
|
|
|
|
{
|
2021-05-17 18:46:50 +08:00
|
|
|
|
// max to avoid div-by-zero.
|
|
|
|
|
maxHitWindow = Math.Max(1, windows.First().length);
|
2019-08-30 17:35:06 +08:00
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
|
for (int i = 0; i < windows.Length; i++)
|
2019-08-30 17:35:06 +08:00
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
(var result, double length) = windows[i];
|
2019-08-30 17:35:06 +08:00
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float hitWindow = (float)(length / maxHitWindow);
|
2021-05-17 18:46:50 +08:00
|
|
|
|
|
|
|
|
|
colourBarsEarly.Add(createColourBar(result, hitWindow, i == 0));
|
|
|
|
|
colourBarsLate.Add(createColourBar(result, hitWindow, i == 0));
|
2019-08-30 17:35:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 18:16:38 +08:00
|
|
|
|
Drawable createColourBar(HitResult result, float height, bool requireGradient = false)
|
2019-08-30 17:35:06 +08:00
|
|
|
|
{
|
2019-12-21 19:52:53 +08:00
|
|
|
|
var colour = GetColourForHitResult(result);
|
2019-08-30 17:35:06 +08:00
|
|
|
|
|
2022-03-14 18:16:38 +08:00
|
|
|
|
if (requireGradient)
|
2019-08-30 17:35:06 +08:00
|
|
|
|
{
|
|
|
|
|
// the first bar needs gradient rendering.
|
|
|
|
|
const float gradient_start = 0.8f;
|
|
|
|
|
|
|
|
|
|
return new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-12-21 19:52:53 +08:00
|
|
|
|
Colour = colour,
|
2019-08-30 17:35:06 +08:00
|
|
|
|
Height = height * gradient_start
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
Colour = ColourInfo.GradientVertical(colour, colour.Opacity(0)),
|
|
|
|
|
Y = gradient_start,
|
|
|
|
|
Height = height * (1 - gradient_start)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = colour,
|
|
|
|
|
Height = height
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-20 13:00:09 +08:00
|
|
|
|
|
2021-05-10 14:19:27 +08:00
|
|
|
|
protected override void OnNewJudgement(JudgementResult judgement)
|
2019-08-20 01:44:06 +08:00
|
|
|
|
{
|
2022-03-14 18:27:53 +08:00
|
|
|
|
const int arrow_move_duration = 800;
|
2022-03-14 18:18:47 +08:00
|
|
|
|
|
2021-06-07 18:31:24 +08:00
|
|
|
|
if (!judgement.IsHit || judgement.HitObject.HitWindows?.WindowFor(HitResult.Miss) == 0)
|
2019-08-20 01:44:06 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2021-06-08 22:09:18 +08:00
|
|
|
|
if (!judgement.Type.IsScorable() || judgement.Type.IsBonus())
|
|
|
|
|
return;
|
|
|
|
|
|
2020-02-23 04:28:59 +08:00
|
|
|
|
if (judgementsContainer.Count > max_concurrent_judgements)
|
2020-02-23 02:53:51 +08:00
|
|
|
|
{
|
|
|
|
|
const double quick_fade_time = 100;
|
|
|
|
|
|
2020-02-23 04:28:59 +08:00
|
|
|
|
// check with a bit of lenience to avoid precision error in comparison.
|
|
|
|
|
var old = judgementsContainer.FirstOrDefault(j => j.LifetimeEnd > Clock.CurrentTime + quick_fade_time * 1.1);
|
2020-02-23 02:53:51 +08:00
|
|
|
|
|
|
|
|
|
if (old != null)
|
|
|
|
|
{
|
|
|
|
|
old.ClearTransforms();
|
|
|
|
|
old.FadeOut(quick_fade_time).Expire();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-23 02:39:12 +08:00
|
|
|
|
|
2022-11-13 23:53:38 +08:00
|
|
|
|
judgementLinePool.Get(drawableJudgement =>
|
2019-08-30 15:40:39 +08:00
|
|
|
|
{
|
2022-11-13 23:53:38 +08:00
|
|
|
|
drawableJudgement.Y = getRelativeJudgementPosition(judgement.TimeOffset);
|
|
|
|
|
drawableJudgement.Colour = GetColourForHitResult(judgement.Type);
|
|
|
|
|
|
|
|
|
|
judgementsContainer.Add(drawableJudgement);
|
2019-08-30 15:40:39 +08:00
|
|
|
|
});
|
2019-08-20 01:44:06 +08:00
|
|
|
|
|
2019-08-30 17:35:06 +08:00
|
|
|
|
arrow.MoveToY(
|
|
|
|
|
getRelativeJudgementPosition(floatingAverage = floatingAverage * 0.9 + judgement.TimeOffset * 0.1)
|
2022-03-14 18:27:53 +08:00
|
|
|
|
, arrow_move_duration, Easing.OutQuint);
|
2019-08-20 01:44:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-08 22:51:57 +08:00
|
|
|
|
private float getRelativeJudgementPosition(double value) => Math.Clamp((float)((value / maxHitWindow) + 1) / 2, 0, 1);
|
2019-08-20 01:44:06 +08:00
|
|
|
|
|
2022-11-13 23:53:38 +08:00
|
|
|
|
internal partial class JudgementLine : PoolableDrawable
|
2019-08-20 01:44:06 +08:00
|
|
|
|
{
|
2022-03-18 15:50:37 +08:00
|
|
|
|
public readonly BindableNumber<float> JudgementLineThickness = new BindableFloat();
|
|
|
|
|
|
2022-11-14 00:07:53 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BarHitErrorMeter barHitErrorMeter { get; set; } = null!;
|
|
|
|
|
|
2019-08-30 15:40:39 +08:00
|
|
|
|
public JudgementLine()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
RelativePositionAxes = Axes.Y;
|
2022-03-14 18:16:38 +08:00
|
|
|
|
|
|
|
|
|
Blending = BlendingParameters.Additive;
|
2019-08-21 14:40:15 +08:00
|
|
|
|
|
2022-03-14 18:16:38 +08:00
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
|
|
|
|
|
|
InternalChild = new Circle
|
2019-08-30 15:40:39 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
};
|
|
|
|
|
}
|
2019-08-20 01:44:06 +08:00
|
|
|
|
|
2019-08-30 15:40:39 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
2022-11-13 23:53:38 +08:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
JudgementLineThickness.BindTo(barHitErrorMeter.JudgementLineThickness);
|
|
|
|
|
JudgementLineThickness.BindValueChanged(thickness => Height = thickness.NewValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PrepareForUse()
|
|
|
|
|
{
|
|
|
|
|
base.PrepareForUse();
|
|
|
|
|
|
2022-03-14 18:16:38 +08:00
|
|
|
|
const int judgement_fade_in_duration = 100;
|
|
|
|
|
const int judgement_fade_out_duration = 5000;
|
|
|
|
|
|
|
|
|
|
Alpha = 0;
|
2019-08-30 15:40:39 +08:00
|
|
|
|
Width = 0;
|
2019-08-30 17:35:06 +08:00
|
|
|
|
|
2022-03-14 18:16:38 +08:00
|
|
|
|
this
|
2022-03-14 18:27:53 +08:00
|
|
|
|
.FadeTo(0.6f, judgement_fade_in_duration, Easing.OutQuint)
|
2022-03-14 18:16:38 +08:00
|
|
|
|
.ResizeWidthTo(1, judgement_fade_in_duration, Easing.OutQuint)
|
|
|
|
|
.Then()
|
2022-03-14 18:27:53 +08:00
|
|
|
|
.FadeOut(judgement_fade_out_duration)
|
|
|
|
|
.ResizeWidthTo(0, judgement_fade_out_duration, Easing.InQuint)
|
2022-03-14 18:16:38 +08:00
|
|
|
|
.Expire();
|
2019-08-30 15:40:39 +08:00
|
|
|
|
}
|
2019-08-20 01:44:06 +08:00
|
|
|
|
}
|
2021-09-10 04:21:51 +08:00
|
|
|
|
|
2021-09-20 22:22:36 +08:00
|
|
|
|
public override void Clear() => judgementsContainer.Clear();
|
2022-03-18 16:16:40 +08:00
|
|
|
|
|
2022-03-18 16:23:27 +08:00
|
|
|
|
public enum CentreMarkerStyles
|
2022-03-18 16:16:40 +08:00
|
|
|
|
{
|
|
|
|
|
None,
|
2022-03-18 16:23:27 +08:00
|
|
|
|
Circle,
|
|
|
|
|
Line
|
2022-03-18 16:16:40 +08:00
|
|
|
|
}
|
2022-03-18 16:46:22 +08:00
|
|
|
|
|
|
|
|
|
public enum LabelStyles
|
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
Icons,
|
|
|
|
|
Text
|
|
|
|
|
}
|
2019-08-20 01:44:06 +08:00
|
|
|
|
}
|
|
|
|
|
}
|