reverse LaneCover when playing up-scroll

This commit is contained in:
LastExceed
2020-07-14 11:56:31 +02:00
parent ca39f2aa24
commit fec2594ac6

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
@ -10,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -45,11 +47,9 @@ namespace osu.Game.Rulesets.Mania.Mods
Children = new Drawable[] Children = new Drawable[]
{ {
hoc, hoc,
new LaneCover(false) new LaneCover(0.5f, false)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both
SizeFilled = 0.5f,
SizeGradient = 0.25f
} }
} }
}); });
@ -60,9 +60,8 @@ namespace osu.Game.Rulesets.Mania.Mods
{ {
private readonly Box gradient; private readonly Box gradient;
private readonly Box filled; private readonly Box filled;
private readonly bool reversed;
public LaneCover(bool reversed) public LaneCover(float initialCoverage, bool reversed)
{ {
Blending = new BlendingParameters Blending = new BlendingParameters
{ {
@ -73,50 +72,61 @@ namespace osu.Game.Rulesets.Mania.Mods
SourceAlpha = BlendingType.Zero, SourceAlpha = BlendingType.Zero,
DestinationAlpha = BlendingType.OneMinusSrcAlpha DestinationAlpha = BlendingType.OneMinusSrcAlpha
}; };
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
gradient = new Box gradient = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(1f), Color4.White.Opacity(0f)) Height = 0.25f
}, },
filled = new Box filled = new Box
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
} }
}; };
Coverage = initialCoverage;
if (reversed) Reversed = reversed;
{
gradient.Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0f), Color4.White.Opacity(1f));
filled.Anchor = Anchor.BottomLeft;
filled.Origin = Anchor.BottomLeft;
}
this.reversed = reversed;
} }
public float SizeFilled private float coverage;
public float Coverage
{ {
set set
{ {
filled.Height = value; filled.Height = value;
if (!reversed) gradient.Y = reversed ? 1 - value - gradient.Height : value;
gradient.Y = value; coverage = value;
} }
} }
public float SizeGradient private bool reversed;
public bool Reversed
{ {
set set
{ {
gradient.Height = value; filled.Anchor = value ? Anchor.BottomLeft : Anchor.TopLeft;
if (reversed) filled.Origin = value ? Anchor.BottomLeft : Anchor.TopLeft;
gradient.Y = 1 - value - filled.Height; gradient.Colour = ColourInfo.GradientVertical(
Color4.White.Opacity(value ? 0f : 1f),
Color4.White.Opacity(value ? 1f : 0f)
);
reversed = value;
Coverage = coverage; //re-apply coverage to update visuals
} }
} }
[BackgroundDependencyLoader]
private void load(ManiaRulesetConfigManager configManager)
{
var scrollDirection = configManager.GetBindable<ManiaScrollingDirection>(ManiaRulesetSetting.ScrollDirection);
if (scrollDirection.Value == ManiaScrollingDirection.Up)
Reversed = !reversed;
}
} }
} }
} }