bind laneCover direction to scroll direction

This commit is contained in:
LastExceed 2020-07-14 16:43:15 +02:00
parent 921939f97a
commit 25fb49d59f
1 changed files with 13 additions and 23 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
@ -40,7 +41,7 @@ public void ApplyToDrawableRuleset(DrawableRuleset<ManiaHitObject> drawableRules
Children = new Drawable[]
{
hoc,
new LaneCover(false)
new LaneCover
{
Coverage = 0.5f,
RelativeSizeAxes = Axes.Both
@ -54,8 +55,10 @@ private class LaneCover : CompositeDrawable
{
private readonly Box gradient;
private readonly Box filled;
private bool reversed;
private readonly Bindable<ManiaScrollingDirection> scrollDirection = new Bindable<ManiaScrollingDirection>();
public LaneCover(bool reversed)
public LaneCover()
{
Blending = new BlendingParameters
{
@ -80,8 +83,6 @@ public LaneCover(bool reversed)
RelativeSizeAxes = Axes.Both
}
};
Reversed = reversed;
}
private void updateCoverage()
@ -97,6 +98,12 @@ private void updateCoverage()
);
}
private void onScrollDirectionChanged(ValueChangedEvent<ManiaScrollingDirection> valueChangedEvent)
{
reversed = valueChangedEvent.NewValue == ManiaScrollingDirection.Up;
updateCoverage();
}
private float coverage;
public float Coverage
@ -112,28 +119,11 @@ public float Coverage
}
}
private bool reversed;
public bool Reversed
{
set
{
if (reversed == value)
return;
reversed = value;
updateCoverage();
}
}
[BackgroundDependencyLoader]
private void load(ManiaRulesetConfigManager configManager)
{
var scrollDirection = configManager.GetBindable<ManiaScrollingDirection>(ManiaRulesetSetting.ScrollDirection);
if (scrollDirection.Value == ManiaScrollingDirection.Up)
Reversed = !reversed;
scrollDirection.BindTo(configManager.GetBindable<ManiaScrollingDirection>(ManiaRulesetSetting.ScrollDirection));
scrollDirection.BindValueChanged(onScrollDirectionChanged, true);
}
}
}