2020-04-01 17:00:17 +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-04-01 17:00:17 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
2020-07-12 19:57:06 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-04-02 17:39:49 +08:00
|
|
|
using osu.Game.Rulesets.Mania.Skinning;
|
2020-04-01 17:00:17 +08:00
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.UI.Components
|
|
|
|
{
|
|
|
|
public partial class HitObjectArea : SkinReloadableDrawable
|
|
|
|
{
|
|
|
|
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
2020-07-13 17:55:13 +08:00
|
|
|
public readonly HitObjectContainer HitObjectContainer;
|
2020-04-01 17:00:17 +08:00
|
|
|
|
|
|
|
public HitObjectArea(HitObjectContainer hitObjectContainer)
|
|
|
|
{
|
2020-07-13 19:43:32 +08:00
|
|
|
InternalChild = new Container
|
2020-04-01 17:00:17 +08:00
|
|
|
{
|
2020-07-12 19:57:06 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-13 17:55:13 +08:00
|
|
|
Child = HitObjectContainer = hitObjectContainer
|
2020-04-01 17:00:17 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(IScrollingInfo scrollingInfo)
|
|
|
|
{
|
|
|
|
Direction.BindTo(scrollingInfo.Direction);
|
|
|
|
Direction.BindValueChanged(onDirectionChanged, true);
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:50:42 +08:00
|
|
|
protected override void SkinChanged(ISkinSource skin)
|
2020-04-01 17:00:17 +08:00
|
|
|
{
|
2021-05-27 13:50:42 +08:00
|
|
|
base.SkinChanged(skin);
|
2020-04-01 17:00:17 +08:00
|
|
|
UpdateHitPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
|
|
|
{
|
|
|
|
UpdateHitPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void UpdateHitPosition()
|
|
|
|
{
|
2020-04-02 17:39:49 +08:00
|
|
|
float hitPosition = CurrentSkin.GetConfig<ManiaSkinConfigurationLookup, float>(
|
|
|
|
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.HitPosition))?.Value
|
2020-04-08 13:08:34 +08:00
|
|
|
?? Stage.HIT_TARGET_POSITION;
|
2020-04-01 17:00:17 +08:00
|
|
|
|
|
|
|
Padding = Direction.Value == ScrollingDirection.Up
|
|
|
|
? new MarginPadding { Top = hitPosition }
|
|
|
|
: new MarginPadding { Bottom = hitPosition };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|