Make IScrollingInfo and store direction as bindable

This commit is contained in:
smoogipoo
2018-06-08 21:41:20 +09:00
parent ca5103615d
commit baaf431b9e
14 changed files with 122 additions and 74 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects.Drawables;
@ -19,6 +20,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
public new TObject HitObject;
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
protected DrawableManiaHitObject(TObject hitObject, ManiaAction? action = null)
: base(hitObject)
{
@ -29,9 +32,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
}
[BackgroundDependencyLoader]
private void load(ScrollingInfo scrollingInfo)
private void load(IScrollingInfo scrollingInfo)
{
Anchor = scrollingInfo.Direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
Direction.BindTo(scrollingInfo.Direction);
Direction.BindValueChanged(OnDirectionChanged, true);
}
protected virtual void OnDirectionChanged(ScrollingDirection direction)
{
Anchor = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
Origin = Anchor;
}