mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 08:33:21 +08:00
Reduce implementation overhead for nested playfields (e.g. playfield + columns).
This commit is contained in:
parent
376f99c1e3
commit
c6447e40f9
@ -114,12 +114,6 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
protected override Vector2 GetPlayfieldAspectAdjust() => new Vector2(1, 0.8f);
|
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);
|
protected override SpeedAdjustmentContainer CreateSpeedAdjustmentContainer(MultiplierControlPoint controlPoint) => new ManiaSpeedAdjustmentContainer(controlPoint, ScrollingAlgorithm.Basic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,8 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
private readonly FlowContainer<Column> columns;
|
private readonly FlowContainer<Column> columns;
|
||||||
public IEnumerable<Column> Columns => columns.Children;
|
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 List<Color4> normalColumnColours = new List<Color4>();
|
||||||
private Color4 specialColumnColour;
|
private Color4 specialColumnColour;
|
||||||
@ -67,7 +68,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
if (columnCount <= 0)
|
if (columnCount <= 0)
|
||||||
throw new ArgumentException("Can't have zero or fewer columns.");
|
throw new ArgumentException("Can't have zero or fewer columns.");
|
||||||
|
|
||||||
Children = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -111,13 +112,12 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
Padding = new MarginPadding { Top = HIT_TARGET_POSITION },
|
Padding = new MarginPadding { Top = HIT_TARGET_POSITION },
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
barLineContainer = new ScrollingHitObjectContainer(Axes.Y)
|
barLineContainer = new Container
|
||||||
{
|
{
|
||||||
Name = "Bar lines",
|
Name = "Bar lines",
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
VisibleTimeRange = VisibleTimeRange
|
|
||||||
// Width is set in the Update method
|
// Width is set in the Update method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +127,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < columnCount; i++)
|
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]
|
[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 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(DrawableBarLine barline) => barLineContainer.Add(barline);
|
||||||
public void Add(SpeedAdjustmentContainer speedAdjustment) => barLineContainer.AddSpeedAdjustment(speedAdjustment);
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
@ -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)
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
{
|
{
|
||||||
if (state.Keyboard.ControlPressed)
|
if (state.Keyboard.ControlPressed)
|
||||||
|
@ -35,7 +35,13 @@ namespace osu.Game.Rulesets.UI
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
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()
|
protected override void ApplyBeatmap()
|
||||||
@ -99,11 +105,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
return new MultiplierControlPoint(time, DefaultControlPoints[index].DeepClone());
|
return new MultiplierControlPoint(time, DefaultControlPoints[index].DeepClone());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ApplySpeedAdjustment(MultiplierControlPoint controlPoint)
|
|
||||||
{
|
|
||||||
Playfield.HitObjects.AddSpeedAdjustment(CreateSpeedAdjustmentContainer(controlPoint));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract SpeedAdjustmentContainer CreateSpeedAdjustmentContainer(MultiplierControlPoint controlPoint);
|
protected abstract SpeedAdjustmentContainer CreateSpeedAdjustmentContainer(MultiplierControlPoint controlPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user