2020-08-26 19:23:01 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-26 19:23:01 +08:00
|
|
|
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;
|
|
|
|
|
2020-12-07 11:32:52 +08:00
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
2020-08-26 19:23:01 +08:00
|
|
|
{
|
|
|
|
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]
|
2022-10-06 13:10:39 +08:00
|
|
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
2020-08-26 19:23:01 +08:00
|
|
|
{
|
2022-10-06 13:10:39 +08:00
|
|
|
hitPosition = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.HitPosition)?.Value ?? Stage.HIT_TARGET_POSITION;
|
2020-08-26 19:23:01 +08:00
|
|
|
|
|
|
|
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 };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|