2018-06-07 20:40:12 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2018-06-08 20:41:20 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-09-21 13:35:50 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.UI.Components
|
|
|
|
|
{
|
2018-09-21 13:35:50 +08:00
|
|
|
|
public class ColumnHitObjectArea : CompositeDrawable, IHasAccentColour
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
|
|
|
|
private const float hit_target_height = 10;
|
|
|
|
|
private const float hit_target_bar_height = 2;
|
|
|
|
|
|
2018-06-08 20:41:20 +08:00
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
|
2018-09-21 13:35:50 +08:00
|
|
|
|
private readonly Container hitTargetLine;
|
|
|
|
|
private readonly Drawable hitTargetBar;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
|
2018-09-21 13:35:50 +08:00
|
|
|
|
public ColumnHitObjectArea(HitObjectContainer hitObjectContainer)
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2018-06-08 20:41:20 +08:00
|
|
|
|
InternalChildren = new[]
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2018-06-08 20:41:20 +08:00
|
|
|
|
hitTargetBar = new Box
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = hit_target_height,
|
|
|
|
|
Colour = Color4.Black
|
|
|
|
|
},
|
2018-06-08 20:41:20 +08:00
|
|
|
|
hitTargetLine = new Container
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = hit_target_bar_height,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
|
|
|
|
},
|
2018-09-21 13:35:50 +08:00
|
|
|
|
hitObjectContainer
|
2018-06-07 20:40:12 +08:00
|
|
|
|
};
|
2018-09-21 13:35:50 +08:00
|
|
|
|
}
|
2018-06-08 20:41:20 +08:00
|
|
|
|
|
2018-09-21 13:35:50 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(IScrollingInfo scrollingInfo)
|
|
|
|
|
{
|
2018-06-08 20:41:20 +08:00
|
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
|
|
|
|
direction.BindValueChanged(direction =>
|
|
|
|
|
{
|
2018-06-25 18:28:38 +08:00
|
|
|
|
Anchor anchor = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft;
|
|
|
|
|
|
|
|
|
|
hitTargetBar.Anchor = hitTargetBar.Origin = anchor;
|
|
|
|
|
hitTargetLine.Anchor = hitTargetLine.Origin = anchor;
|
2018-06-08 20:41:20 +08:00
|
|
|
|
}, true);
|
2018-06-07 20:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
updateColours();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Color4 accentColour;
|
|
|
|
|
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
|
|
|
|
get => accentColour;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (accentColour == value)
|
|
|
|
|
return;
|
|
|
|
|
accentColour = value;
|
|
|
|
|
|
|
|
|
|
updateColours();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateColours()
|
|
|
|
|
{
|
|
|
|
|
if (!IsLoaded)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-06-08 20:41:20 +08:00
|
|
|
|
hitTargetLine.EdgeEffect = new EdgeEffectParameters
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Radius = 5,
|
|
|
|
|
Colour = accentColour.Opacity(0.5f),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|