DI the scrolling info rather than pass by ctor

This commit is contained in:
smoogipoo
2018-06-08 20:13:24 +09:00
parent 0fb4e6b41b
commit ca5103615d
14 changed files with 146 additions and 118 deletions

View File

@ -18,19 +18,16 @@ namespace osu.Game.Rulesets.Mania.UI.Components
{
public ManiaAction Action;
private readonly ScrollingDirection direction;
private Box background;
private Box backgroundOverlay;
public ColumnBackground(ScrollingDirection direction)
{
this.direction = direction;
}
private ScrollingInfo scrollingInfo;
[BackgroundDependencyLoader]
private void load()
private void load(ScrollingInfo scrollingInfo)
{
this.scrollingInfo = scrollingInfo;
InternalChildren = new[]
{
background = new Box
@ -44,8 +41,8 @@ namespace osu.Game.Rulesets.Mania.UI.Components
Name = "Background Gradient Overlay",
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Anchor = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Origin = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Anchor = scrollingInfo.Direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Origin = scrollingInfo.Direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Blending = BlendingMode.Additive,
Alpha = 0
}
@ -84,8 +81,8 @@ namespace osu.Game.Rulesets.Mania.UI.Components
var dimPoint = AccentColour.Opacity(0);
backgroundOverlay.Colour = ColourInfo.GradientVertical(
direction == ScrollingDirection.Up ? brightPoint : dimPoint,
direction == ScrollingDirection.Up ? dimPoint : brightPoint);
scrollingInfo.Direction == ScrollingDirection.Up ? brightPoint : dimPoint,
scrollingInfo.Direction == ScrollingDirection.Up ? dimPoint : brightPoint);
}
public bool OnPressed(ManiaAction action)

View File

@ -20,32 +20,25 @@ namespace osu.Game.Rulesets.Mania.UI.Components
private Container<Drawable> content;
protected override Container<Drawable> Content => content;
private readonly ScrollingDirection direction;
private Container hitTargetBar;
public ColumnHitObjectArea(ScrollingDirection direction)
{
this.direction = direction;
}
[BackgroundDependencyLoader]
private void load()
private void load(ScrollingInfo scrollingInfo)
{
InternalChildren = new Drawable[]
{
new Box
{
Anchor = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Origin = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Anchor = scrollingInfo.Direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Origin = scrollingInfo.Direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = hit_target_height,
Colour = Color4.Black
},
hitTargetBar = new Container
{
Anchor = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Origin = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Anchor = scrollingInfo.Direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
Origin = scrollingInfo.Direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = hit_target_bar_height,
Masking = true,

View File

@ -22,17 +22,10 @@ namespace osu.Game.Rulesets.Mania.UI.Components
public ManiaAction Action;
private readonly ScrollingDirection direction;
private Container keyIcon;
public ColumnKeyArea(ScrollingDirection direction)
{
this.direction = direction;
}
[BackgroundDependencyLoader]
private void load()
private void load(ScrollingInfo scrollingInfo)
{
InternalChildren = new Drawable[]
{
@ -41,8 +34,8 @@ namespace osu.Game.Rulesets.Mania.UI.Components
Name = "Key gradient",
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(
direction == ScrollingDirection.Up ? Color4.Black : Color4.Black.Opacity(0),
direction == ScrollingDirection.Up ? Color4.Black.Opacity(0) : Color4.Black),
scrollingInfo.Direction == ScrollingDirection.Up ? Color4.Black : Color4.Black.Opacity(0),
scrollingInfo.Direction == ScrollingDirection.Up ? Color4.Black.Opacity(0) : Color4.Black),
Alpha = 0.5f
},
keyIcon = new Container