// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; using osu.Framework.Bindables; using osuTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI.Scrolling; namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces { /// /// Represents the static hit markers of notes. /// internal class DefaultNotePiece : CompositeDrawable { public const float NOTE_HEIGHT = 12; private readonly IBindable direction = new Bindable(); private readonly IBindable accentColour = new Bindable(); private readonly Box colouredBox; public DefaultNotePiece() { RelativeSizeAxes = Axes.X; Height = NOTE_HEIGHT; CornerRadius = 5; Masking = true; InternalChildren = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both }, colouredBox = new Box { RelativeSizeAxes = Axes.X, Height = NOTE_HEIGHT / 2, Alpha = 0.1f } }; } [BackgroundDependencyLoader] private void load(IScrollingInfo scrollingInfo, DrawableHitObject drawableObject) { direction.BindTo(scrollingInfo.Direction); direction.BindValueChanged(onDirectionChanged, true); accentColour.BindTo(drawableObject.AccentColour); accentColour.BindValueChanged(onAccentChanged, true); } private void onDirectionChanged(ValueChangedEvent direction) { colouredBox.Anchor = colouredBox.Origin = direction.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; } private void onAccentChanged(ValueChangedEvent accent) { colouredBox.Colour = accent.NewValue.Lighten(0.9f); EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow, Colour = accent.NewValue.Lighten(1f).Opacity(0.2f), Radius = 10, }; } } }