2019-01-24 16:43:03 +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.
|
2018-06-07 20:40:12 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-09-11 17:21:29 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
2018-09-21 13:35:50 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2020-03-31 11:17:44 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.UI.Components
|
|
|
|
|
{
|
2020-03-31 11:17:44 +08:00
|
|
|
|
public class ColumnHitObjectArea : SkinReloadableDrawable
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2020-03-31 11:17:44 +08:00
|
|
|
|
public readonly Container<HitExplosion> Explosions;
|
|
|
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
|
private ManiaStage stage { get; set; }
|
2018-06-08 20:41:20 +08:00
|
|
|
|
|
2020-03-31 11:17:44 +08:00
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
2019-12-29 23:37:28 +08:00
|
|
|
|
private readonly Drawable hitTarget;
|
2018-06-07 20:40:12 +08:00
|
|
|
|
|
2018-09-21 13:35:50 +08:00
|
|
|
|
public ColumnHitObjectArea(HitObjectContainer hitObjectContainer)
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2019-12-29 23:18:50 +08:00
|
|
|
|
InternalChildren = new[]
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2020-03-31 11:17:44 +08:00
|
|
|
|
hitTarget = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.HitTarget), _ => new DefaultHitTarget())
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
},
|
2020-03-31 11:17:44 +08:00
|
|
|
|
hitObjectContainer,
|
|
|
|
|
Explosions = new Container<HitExplosion> { RelativeSizeAxes = Axes.Both }
|
2018-06-07 20:40:12 +08:00
|
|
|
|
};
|
2018-09-21 13:35:50 +08:00
|
|
|
|
}
|
2018-06-08 20:41:20 +08:00
|
|
|
|
|
2018-09-21 13:35:50 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(IScrollingInfo scrollingInfo)
|
|
|
|
|
{
|
2018-06-08 20:41:20 +08:00
|
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
2020-03-31 11:17:44 +08:00
|
|
|
|
direction.BindValueChanged(onDirectionChanged, true);
|
2018-06-07 20:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-31 11:17:44 +08:00
|
|
|
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2020-03-31 11:17:44 +08:00
|
|
|
|
base.SkinChanged(skin, allowFallback);
|
|
|
|
|
updateHitPosition();
|
2018-06-07 20:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-31 11:17:44 +08:00
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
2018-06-07 20:40:12 +08:00
|
|
|
|
{
|
2020-03-31 11:17:44 +08:00
|
|
|
|
updateHitPosition();
|
|
|
|
|
}
|
2019-12-28 13:48:10 +08:00
|
|
|
|
|
2020-03-31 11:17:44 +08:00
|
|
|
|
private void updateHitPosition()
|
|
|
|
|
{
|
|
|
|
|
float hitPosition = CurrentSkin.GetConfig<LegacyManiaSkinConfigurationLookup, float>(
|
|
|
|
|
new LegacyManiaSkinConfigurationLookup(stage?.Columns.Count ?? 4, LegacyManiaSkinConfigurationLookups.HitPosition))?.Value
|
|
|
|
|
?? ManiaStage.HIT_TARGET_POSITION;
|
2019-12-28 13:48:10 +08:00
|
|
|
|
|
2020-03-31 11:17:44 +08:00
|
|
|
|
if (direction.Value == ScrollingDirection.Up)
|
2019-12-28 13:48:10 +08:00
|
|
|
|
{
|
2020-03-31 11:17:44 +08:00
|
|
|
|
hitTarget.Anchor = hitTarget.Origin = Anchor.TopLeft;
|
2019-12-28 13:48:10 +08:00
|
|
|
|
|
2020-03-31 11:17:44 +08:00
|
|
|
|
Padding = new MarginPadding { Top = hitPosition };
|
2020-03-31 14:29:25 +08:00
|
|
|
|
Explosions.Padding = new MarginPadding { Top = DefaultNotePiece.NOTE_HEIGHT };
|
2019-12-28 13:48:10 +08:00
|
|
|
|
}
|
2020-03-31 11:17:44 +08:00
|
|
|
|
else
|
2019-12-28 13:48:10 +08:00
|
|
|
|
{
|
2020-03-31 11:17:44 +08:00
|
|
|
|
hitTarget.Anchor = hitTarget.Origin = Anchor.BottomLeft;
|
2019-12-28 13:48:10 +08:00
|
|
|
|
|
2020-03-31 11:17:44 +08:00
|
|
|
|
Padding = new MarginPadding { Bottom = hitPosition };
|
2020-03-31 14:29:25 +08:00
|
|
|
|
Explosions.Padding = new MarginPadding { Bottom = DefaultNotePiece.NOTE_HEIGHT };
|
2019-12-28 13:48:10 +08:00
|
|
|
|
}
|
2018-06-07 20:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|