mirror of
https://github.com/ppy/osu.git
synced 2024-11-16 11:57:30 +08:00
0d21c0e49c
I added this for future usage, but it turns out I can get the definitions directly from `ManiaBeatmap`.
61 lines
2.0 KiB
C#
61 lines
2.0 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.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<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
|
public readonly HitObjectContainer HitObjectContainer;
|
|
|
|
public HitObjectArea(HitObjectContainer hitObjectContainer)
|
|
{
|
|
InternalChild = new Container
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Child = HitObjectContainer = hitObjectContainer
|
|
};
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(IScrollingInfo scrollingInfo)
|
|
{
|
|
Direction.BindTo(scrollingInfo.Direction);
|
|
Direction.BindValueChanged(onDirectionChanged, true);
|
|
}
|
|
|
|
protected override void SkinChanged(ISkinSource skin)
|
|
{
|
|
base.SkinChanged(skin);
|
|
UpdateHitPosition();
|
|
}
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
|
{
|
|
UpdateHitPosition();
|
|
}
|
|
|
|
protected virtual void UpdateHitPosition()
|
|
{
|
|
float hitPosition = CurrentSkin.GetConfig<ManiaSkinConfigurationLookup, float>(
|
|
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.HitPosition))?.Value
|
|
?? Stage.HIT_TARGET_POSITION;
|
|
|
|
Padding = Direction.Value == ScrollingDirection.Up
|
|
? new MarginPadding { Top = hitPosition }
|
|
: new MarginPadding { Bottom = hitPosition };
|
|
}
|
|
}
|
|
}
|