Make coverage into a bindable

This commit is contained in:
Dan Balasescu 2024-02-06 23:32:54 +09:00
parent d784934bce
commit 5265d33c12
No known key found for this signature in database
3 changed files with 23 additions and 19 deletions

View File

@ -39,18 +39,18 @@ public TestScenePlayfieldCoveringContainer()
public void TestScrollingDownwards()
{
AddStep("set down scroll", () => scrollingContainer.Direction = ScrollingDirection.Down);
AddStep("set coverage = 0.5", () => cover.Coverage = 0.5f);
AddStep("set coverage = 0.8f", () => cover.Coverage = 0.8f);
AddStep("set coverage = 0.2f", () => cover.Coverage = 0.2f);
AddStep("set coverage = 0.5", () => cover.Coverage.Value = 0.5f);
AddStep("set coverage = 0.8f", () => cover.Coverage.Value = 0.8f);
AddStep("set coverage = 0.2f", () => cover.Coverage.Value = 0.2f);
}
[Test]
public void TestScrollingUpwards()
{
AddStep("set up scroll", () => scrollingContainer.Direction = ScrollingDirection.Up);
AddStep("set coverage = 0.5", () => cover.Coverage = 0.5f);
AddStep("set coverage = 0.8f", () => cover.Coverage = 0.8f);
AddStep("set coverage = 0.2f", () => cover.Coverage = 0.2f);
AddStep("set coverage = 0.5", () => cover.Coverage.Value = 0.5f);
AddStep("set coverage = 0.8f", () => cover.Coverage.Value = 0.8f);
AddStep("set coverage = 0.2f", () => cover.Coverage.Value = 0.2f);
}
}
}

View File

@ -41,7 +41,7 @@ public virtual void ApplyToDrawableRuleset(DrawableRuleset<ManiaHitObject> drawa
{
c.RelativeSizeAxes = Axes.Both;
c.Direction = ExpandDirection;
c.Coverage = Coverage.Value;
c.Coverage.BindTo(Coverage);
}));
}
}

View File

@ -19,6 +19,11 @@ namespace osu.Game.Rulesets.Mania.UI
/// </summary>
public partial class PlayfieldCoveringWrapper : CompositeDrawable
{
/// <summary>
/// The relative area that should be completely covered. This does not include the fade.
/// </summary>
public readonly BindableFloat Coverage = new BindableFloat();
/// <summary>
/// The complete cover, including gradient and fill.
/// </summary>
@ -94,21 +99,20 @@ private void load(IScrollingInfo scrollingInfo)
scrollDirection.BindValueChanged(onScrollDirectionChanged, true);
}
protected override void LoadComplete()
{
base.LoadComplete();
Coverage.BindValueChanged(c =>
{
filled.Height = c.NewValue;
gradient.Y = -c.NewValue;
}, true);
}
private void onScrollDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
=> cover.Rotation = direction.NewValue == ScrollingDirection.Up ? 0 : 180f;
/// <summary>
/// The relative area that should be completely covered. This does not include the fade.
/// </summary>
public float Coverage
{
set
{
filled.Height = value;
gradient.Y = -value;
}
}
/// <summary>
/// The direction in which the cover expands.
/// </summary>