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