// 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 osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Mania.Skinning; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Skinning; namespace osu.Game.Rulesets.Mania.UI.Components { public class HitObjectArea : SkinReloadableDrawable { protected readonly IBindable Direction = new Bindable(); public HitObjectArea(HitObjectContainer hitObjectContainer) { InternalChild = new BufferedContainer { RelativeSizeAxes = Axes.Both, Child = hitObjectContainer }; } [BackgroundDependencyLoader] private void load(IScrollingInfo scrollingInfo) { Direction.BindTo(scrollingInfo.Direction); Direction.BindValueChanged(onDirectionChanged, true); } protected override void SkinChanged(ISkinSource skin, bool allowFallback) { base.SkinChanged(skin, allowFallback); UpdateHitPosition(); } private void onDirectionChanged(ValueChangedEvent direction) { UpdateHitPosition(); } protected virtual void UpdateHitPosition() { float hitPosition = CurrentSkin.GetConfig( new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.HitPosition))?.Value ?? Stage.HIT_TARGET_POSITION; Padding = Direction.Value == ScrollingDirection.Up ? new MarginPadding { Top = hitPosition } : new MarginPadding { Bottom = hitPosition }; } } }