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-06-07 20:40:12 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-04-02 13:51:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
2019-09-11 17:21:29 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
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_bar_height = 2;
|
|
|
|
|
|
2018-06-08 20:41:20 +08:00
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
|
2019-12-29 23:37:28 +08:00
|
|
|
|
private readonly Drawable hitTarget;
|
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
|
|
|
|
{
|
2019-12-29 23:18:50 +08:00
|
|
|
|
InternalChildren = new[]
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2019-12-29 23:37:28 +08:00
|
|
|
|
hitTarget = new DefaultHitTarget
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
},
|
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);
|
2019-02-22 19:13:38 +08:00
|
|
|
|
direction.BindValueChanged(dir =>
|
2018-06-08 20:41:20 +08:00
|
|
|
|
{
|
2019-02-22 19:13:38 +08:00
|
|
|
|
Anchor anchor = dir.NewValue == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft;
|
2018-06-25 18:28:38 +08:00
|
|
|
|
|
2019-12-29 23:37:28 +08:00
|
|
|
|
hitTarget.Anchor = hitTarget.Origin = anchor;
|
2018-06-08 20:41:20 +08:00
|
|
|
|
}, true);
|
2018-06-07 20:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Color4 accentColour;
|
|
|
|
|
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
|
|
|
|
get => accentColour;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (accentColour == value)
|
|
|
|
|
return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-06-07 20:40:12 +08:00
|
|
|
|
accentColour = value;
|
2019-12-28 14:05:46 +08:00
|
|
|
|
|
2019-12-29 23:37:28 +08:00
|
|
|
|
if (hitTarget is IHasAccentColour colouredHitTarget)
|
2019-12-29 23:18:50 +08:00
|
|
|
|
colouredHitTarget.AccentColour = accentColour;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-29 23:37:28 +08:00
|
|
|
|
private class DefaultHitTarget : CompositeDrawable, IHasAccentColour
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2019-12-28 13:48:10 +08:00
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
|
|
|
|
|
private readonly Container hitTargetLine;
|
|
|
|
|
private readonly Drawable hitTargetBar;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
|
2019-12-29 23:37:28 +08:00
|
|
|
|
public DefaultHitTarget()
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2019-12-28 13:48:10 +08:00
|
|
|
|
InternalChildren = new[]
|
|
|
|
|
{
|
|
|
|
|
hitTargetBar = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = NotePiece.NOTE_HEIGHT,
|
|
|
|
|
Alpha = 0.6f,
|
|
|
|
|
Colour = Color4.Black
|
|
|
|
|
},
|
|
|
|
|
hitTargetLine = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = hit_target_bar_height,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(IScrollingInfo scrollingInfo)
|
|
|
|
|
{
|
|
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
|
|
|
|
direction.BindValueChanged(dir =>
|
|
|
|
|
{
|
|
|
|
|
Anchor anchor = dir.NewValue == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft;
|
|
|
|
|
|
|
|
|
|
hitTargetBar.Anchor = hitTargetBar.Origin = anchor;
|
|
|
|
|
hitTargetLine.Anchor = hitTargetLine.Origin = anchor;
|
|
|
|
|
}, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
updateColours();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Color4 accentColour;
|
|
|
|
|
|
2019-12-29 23:29:00 +08:00
|
|
|
|
public Color4 AccentColour
|
2019-12-28 13:48:10 +08:00
|
|
|
|
{
|
|
|
|
|
get => accentColour;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (accentColour == value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
accentColour = value;
|
|
|
|
|
|
|
|
|
|
updateColours();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateColours()
|
|
|
|
|
{
|
|
|
|
|
if (!IsLoaded)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
hitTargetLine.EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Radius = 5,
|
|
|
|
|
Colour = accentColour.Opacity(0.5f),
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-06-07 20:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|