2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2018-06-08 11:13:24 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2017-05-04 06:36:37 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-05-03 06:50:42 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-03-31 06:29:25 +00:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2017-06-20 05:54:23 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2020-03-31 06:29:25 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-06-08 06:17:22 +00:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2020-12-07 03:32:52 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-12-07 03:32:52 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning.Default
|
2017-05-03 06:50:42 +00:00
|
|
|
|
{
|
2017-05-09 11:55:20 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the static hit markers of notes.
|
|
|
|
|
/// </summary>
|
2020-03-31 06:29:25 +00:00
|
|
|
|
internal partial class DefaultNotePiece : CompositeDrawable
|
2017-05-03 06:50:42 +00:00
|
|
|
|
{
|
2019-09-11 09:16:14 +00:00
|
|
|
|
public const float NOTE_HEIGHT = 12;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-06-08 12:41:20 +00:00
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
2020-03-31 06:29:25 +00:00
|
|
|
|
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
2018-06-08 12:41:20 +00:00
|
|
|
|
|
2017-05-11 04:11:36 +00:00
|
|
|
|
private readonly Box colouredBox;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-03-31 06:29:25 +00:00
|
|
|
|
public DefaultNotePiece()
|
2017-05-03 06:50:42 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-06-07 05:27:59 +00:00
|
|
|
|
Height = NOTE_HEIGHT;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-03-31 06:29:25 +00:00
|
|
|
|
CornerRadius = 5;
|
|
|
|
|
Masking = true;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
2017-05-03 06:50:42 +00:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
colouredBox = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2019-09-11 09:16:14 +00:00
|
|
|
|
Height = NOTE_HEIGHT / 2,
|
|
|
|
|
Alpha = 0.1f
|
2017-05-03 06:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-03-31 07:00:08 +00:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2022-11-09 04:37:04 +00:00
|
|
|
|
private void load(IScrollingInfo scrollingInfo, DrawableHitObject? drawableObject)
|
2018-06-08 06:17:22 +00:00
|
|
|
|
{
|
2018-06-08 12:41:20 +00:00
|
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
2020-03-31 06:29:25 +00:00
|
|
|
|
direction.BindValueChanged(onDirectionChanged, true);
|
2018-06-08 06:17:22 +00:00
|
|
|
|
|
2020-03-31 07:00:08 +00:00
|
|
|
|
if (drawableObject != null)
|
|
|
|
|
{
|
|
|
|
|
accentColour.BindTo(drawableObject.AccentColour);
|
|
|
|
|
accentColour.BindValueChanged(onAccentChanged, true);
|
|
|
|
|
}
|
2020-03-31 06:29:25 +00:00
|
|
|
|
}
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2020-03-31 06:29:25 +00:00
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
2017-05-03 06:50:42 +00:00
|
|
|
|
{
|
2020-03-31 06:29:25 +00:00
|
|
|
|
colouredBox.Anchor = colouredBox.Origin = direction.NewValue == ScrollingDirection.Up
|
|
|
|
|
? Anchor.TopCentre
|
|
|
|
|
: Anchor.BottomCentre;
|
|
|
|
|
}
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2020-03-31 06:29:25 +00:00
|
|
|
|
private void onAccentChanged(ValueChangedEvent<Color4> accent)
|
|
|
|
|
{
|
|
|
|
|
colouredBox.Colour = accent.NewValue.Lighten(0.9f);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-03-31 06:29:25 +00:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Colour = accent.NewValue.Lighten(1f).Opacity(0.2f),
|
|
|
|
|
Radius = 10,
|
|
|
|
|
};
|
2017-05-03 06:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|