2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-14 02:59:07 +08:00
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
2017-03-21 19:39:18 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-12-14 02:59:07 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-09-10 12:29:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2017-08-08 15:01:18 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2020-04-23 13:32:48 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
2017-03-21 19:39:18 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A line that scrolls alongside hit objects in the playfield and visualises control points.
|
|
|
|
|
/// </summary>
|
2019-09-10 12:29:50 +08:00
|
|
|
|
public class DrawableBarLine : DrawableHitObject<HitObject>
|
2017-03-21 19:39:18 +08:00
|
|
|
|
{
|
2020-12-14 02:59:07 +08:00
|
|
|
|
public new BarLine HitObject => (BarLine)base.HitObject;
|
|
|
|
|
|
2017-04-03 09:04:13 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The width of the line tracker.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float tracker_width = 2f;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-03 09:04:13 +08:00
|
|
|
|
/// <summary>
|
2020-12-14 02:59:07 +08:00
|
|
|
|
/// The vertical offset of the triangles from the line tracker.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float triangle_offset = 10f;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The size of the triangles.
|
2017-04-03 09:04:13 +08:00
|
|
|
|
/// </summary>
|
2020-12-14 02:59:07 +08:00
|
|
|
|
private const float triangle_size = 20f;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-21 19:39:18 +08:00
|
|
|
|
/// <summary>
|
2017-04-02 01:06:58 +08:00
|
|
|
|
/// The visual line tracker.
|
2017-03-21 19:39:18 +08:00
|
|
|
|
/// </summary>
|
2020-12-14 02:59:07 +08:00
|
|
|
|
private SkinnableDrawable line;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-21 19:39:18 +08:00
|
|
|
|
/// <summary>
|
2020-12-14 02:59:07 +08:00
|
|
|
|
/// Container with triangles. Only visible for major lines.
|
2017-03-21 19:39:18 +08:00
|
|
|
|
/// </summary>
|
2020-12-14 02:59:07 +08:00
|
|
|
|
private Container triangleContainer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-14 02:59:07 +08:00
|
|
|
|
private readonly Bindable<bool> major = new Bindable<bool>();
|
|
|
|
|
|
|
|
|
|
public DrawableBarLine()
|
|
|
|
|
: this(null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DrawableBarLine([CanBeNull] BarLine barLine)
|
2017-08-08 15:01:18 +08:00
|
|
|
|
: base(barLine)
|
2017-03-21 19:39:18 +08:00
|
|
|
|
{
|
2020-12-14 02:59:07 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-14 02:59:07 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2017-08-09 09:54:00 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft;
|
|
|
|
|
Origin = Anchor.Centre;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-21 19:39:18 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2017-04-03 09:04:13 +08:00
|
|
|
|
Width = tracker_width;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-14 02:59:07 +08:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
2017-03-21 19:39:18 +08:00
|
|
|
|
{
|
2020-12-14 02:59:07 +08:00
|
|
|
|
line = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.BarLine), _ => new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
EdgeSmoothness = new Vector2(0.5f, 0),
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
|
|
|
|
triangleContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new EquilateralTriangle
|
|
|
|
|
{
|
|
|
|
|
Name = "Top",
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Position = new Vector2(0, -triangle_offset),
|
|
|
|
|
Size = new Vector2(-triangle_size),
|
|
|
|
|
EdgeSmoothness = new Vector2(1),
|
|
|
|
|
},
|
|
|
|
|
new EquilateralTriangle
|
|
|
|
|
{
|
|
|
|
|
Name = "Bottom",
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Position = new Vector2(0, triangle_offset),
|
|
|
|
|
Size = new Vector2(triangle_size),
|
|
|
|
|
EdgeSmoothness = new Vector2(1),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-25 12:47:28 +08:00
|
|
|
|
});
|
2017-03-21 19:39:18 +08:00
|
|
|
|
}
|
2020-02-23 12:50:05 +08:00
|
|
|
|
|
2020-12-14 02:59:07 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2020-12-15 04:58:13 +08:00
|
|
|
|
major.BindValueChanged(updateMajor, true);
|
2020-12-14 02:59:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 14:34:32 +08:00
|
|
|
|
private void updateMajor(ValueChangedEvent<bool> major)
|
2020-12-14 02:59:07 +08:00
|
|
|
|
{
|
2020-12-14 14:34:32 +08:00
|
|
|
|
line.Alpha = major.NewValue ? 1f : 0.75f;
|
|
|
|
|
triangleContainer.Alpha = major.NewValue ? 1 : 0;
|
2020-12-14 02:59:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnApply()
|
|
|
|
|
{
|
|
|
|
|
base.OnApply();
|
|
|
|
|
major.BindTo(HitObject.MajorBindable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnFree()
|
|
|
|
|
{
|
|
|
|
|
base.OnFree();
|
|
|
|
|
major.UnbindFrom(HitObject.MajorBindable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
using (BeginAbsoluteSequence(HitObject.StartTime))
|
|
|
|
|
this.FadeOutFromOne(150).Expire();
|
|
|
|
|
}
|
2017-03-21 19:39:18 +08:00
|
|
|
|
}
|
2017-08-21 14:35:16 +08:00
|
|
|
|
}
|