2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2020-04-01 17:00:17 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class HitObjectArea : SkinReloadableDrawable
|
2020-04-01 17:00:17 +08:00
|
|
|
|
{
|
|
|
|
|
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 };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|