diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs index 1ae65dd8c0..c645ddd98d 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mania.Objects; @@ -17,9 +18,6 @@ public abstract partial class ManiaSelectionBlueprint : HitObjectSelectionBlu [Resolved] private Playfield playfield { get; set; } = null!; - [Resolved] - private IScrollingInfo scrollingInfo { get; set; } = null!; - protected ScrollingHitObjectContainer HitObjectContainer => ((ManiaPlayfield)playfield).GetColumn(HitObject.Column).HitObjectContainer; protected ManiaSelectionBlueprint(T hitObject) @@ -28,14 +26,31 @@ protected ManiaSelectionBlueprint(T hitObject) RelativeSizeAxes = Axes.None; } - protected override void Update() - { - base.Update(); + private readonly IBindable directionBindable = new Bindable(); - var anchor = scrollingInfo.Direction.Value == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; + [BackgroundDependencyLoader] + private void load(IScrollingInfo scrollingInfo) + { + directionBindable.BindTo(scrollingInfo.Direction); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + directionBindable.BindValueChanged(onDirectionChanged, true); + } + + private void onDirectionChanged(ValueChangedEvent direction) + { + var anchor = direction.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; Anchor = Origin = anchor; foreach (var child in InternalChildren) child.Anchor = child.Origin = anchor; + } + + protected override void Update() + { + base.Update(); Position = Parent!.ToLocalSpace(HitObjectContainer.ScreenSpacePositionAtTime(HitObject.StartTime)) - AnchorPosition; Width = HitObjectContainer.DrawWidth;