1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Reduce implementation overhead for nested playfields (e.g. playfield + columns).

This commit is contained in:
smoogipooo 2017-08-07 14:56:26 +09:00
parent 376f99c1e3
commit c6447e40f9
4 changed files with 27 additions and 18 deletions

View File

@ -114,12 +114,6 @@ namespace osu.Game.Rulesets.Mania.UI
protected override Vector2 GetPlayfieldAspectAdjust() => new Vector2(1, 0.8f);
protected override void ApplySpeedAdjustment(MultiplierControlPoint controlPoint)
{
base.ApplySpeedAdjustment(controlPoint);
Playfield.Columns.ForEach(c => c.HitObjects.AddSpeedAdjustment(CreateSpeedAdjustmentContainer(controlPoint)));
}
protected override SpeedAdjustmentContainer CreateSpeedAdjustmentContainer(MultiplierControlPoint controlPoint) => new ManiaSpeedAdjustmentContainer(controlPoint, ScrollingAlgorithm.Basic);
}
}

View File

@ -52,7 +52,8 @@ namespace osu.Game.Rulesets.Mania.UI
private readonly FlowContainer<Column> columns;
public IEnumerable<Column> Columns => columns.Children;
private readonly ScrollingHitObjectContainer barLineContainer;
protected override Container<Drawable> Content => barLineContainer;
private readonly Container<Drawable> barLineContainer;
private List<Color4> normalColumnColours = new List<Color4>();
private Color4 specialColumnColour;
@ -67,7 +68,7 @@ namespace osu.Game.Rulesets.Mania.UI
if (columnCount <= 0)
throw new ArgumentException("Can't have zero or fewer columns.");
Children = new Drawable[]
InternalChildren = new Drawable[]
{
new Container
{
@ -111,13 +112,12 @@ namespace osu.Game.Rulesets.Mania.UI
Padding = new MarginPadding { Top = HIT_TARGET_POSITION },
Children = new[]
{
barLineContainer = new ScrollingHitObjectContainer(Axes.Y)
barLineContainer = new Container
{
Name = "Bar lines",
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Y,
VisibleTimeRange = VisibleTimeRange
// Width is set in the Update method
}
}
@ -127,7 +127,11 @@ namespace osu.Game.Rulesets.Mania.UI
};
for (int i = 0; i < columnCount; i++)
columns.Add(new Column { VisibleTimeRange = VisibleTimeRange });
{
var c = new Column { VisibleTimeRange = VisibleTimeRange };
columns.Add(c);
AddNested(c);
}
}
[BackgroundDependencyLoader]
@ -202,7 +206,6 @@ namespace osu.Game.Rulesets.Mania.UI
public override void Add(DrawableHitObject<ManiaHitObject, ManiaJudgement> h) => Columns.ElementAt(h.HitObject.Column).Add(h);
public void Add(DrawableBarLine barline) => barLineContainer.Add(barline);
public void Add(SpeedAdjustmentContainer speedAdjustment) => barLineContainer.AddSpeedAdjustment(speedAdjustment);
protected override void Update()
{

View File

@ -53,6 +53,17 @@ namespace osu.Game.Rulesets.UI
};
}
private List<ScrollingPlayfield<TObject, TJudgement>> nestedPlayfields;
public IEnumerable<ScrollingPlayfield<TObject, TJudgement>> NestedPlayfields => nestedPlayfields;
protected void AddNested(ScrollingPlayfield<TObject, TJudgement> otherPlayfield)
{
if (nestedPlayfields == null)
nestedPlayfields = new List<ScrollingPlayfield<TObject, TJudgement>>();
nestedPlayfields.Add(otherPlayfield);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (state.Keyboard.ControlPressed)

View File

@ -35,7 +35,13 @@ namespace osu.Game.Rulesets.UI
[BackgroundDependencyLoader]
private void load()
{
DefaultControlPoints.ForEach(c => ApplySpeedAdjustment(c));
DefaultControlPoints.ForEach(c => applySpeedAdjustment(c, Playfield));
}
private void applySpeedAdjustment(MultiplierControlPoint controlPoint, ScrollingPlayfield<TObject, TJudgement> playfield)
{
playfield.HitObjects.AddSpeedAdjustment(CreateSpeedAdjustmentContainer(controlPoint));
playfield.NestedPlayfields.ForEach(p => applySpeedAdjustment(controlPoint, p));
}
protected override void ApplyBeatmap()
@ -99,11 +105,6 @@ namespace osu.Game.Rulesets.UI
return new MultiplierControlPoint(time, DefaultControlPoints[index].DeepClone());
}
protected virtual void ApplySpeedAdjustment(MultiplierControlPoint controlPoint)
{
Playfield.HitObjects.AddSpeedAdjustment(CreateSpeedAdjustmentContainer(controlPoint));
}
protected abstract SpeedAdjustmentContainer CreateSpeedAdjustmentContainer(MultiplierControlPoint controlPoint);
}
}