mirror of
https://github.com/ppy/osu.git
synced 2024-11-18 18:12:59 +08:00
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
// 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.
|
|
|
|
#nullable disable
|
|
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Game.Rulesets.Mania.UI;
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
using osu.Game.Skinning;
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
|
{
|
|
public class HitTargetInsetContainer : Container
|
|
{
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
private readonly Container content;
|
|
|
|
private float hitPosition;
|
|
|
|
public HitTargetInsetContainer()
|
|
{
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
InternalChild = content = new Container { RelativeSizeAxes = Axes.Both };
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
|
{
|
|
hitPosition = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.HitPosition)?.Value ?? Stage.HIT_TARGET_POSITION;
|
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
|
direction.BindValueChanged(onDirectionChanged, true);
|
|
}
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
|
{
|
|
content.Padding = direction.NewValue == ScrollingDirection.Up
|
|
? new MarginPadding { Top = hitPosition }
|
|
: new MarginPadding { Bottom = hitPosition };
|
|
}
|
|
}
|
|
}
|