mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 07:23:20 +08:00
Remove gross autoSizingAxes and life time.
This commit is contained in:
parent
6bfb716cc6
commit
5bac0919f0
@ -69,7 +69,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Alpha = 0.25f
|
Alpha = 0.25f
|
||||||
},
|
},
|
||||||
adjustmentCollection = new SpeedAdjustmentCollection
|
adjustmentCollection = new SpeedAdjustmentCollection(Axes.Y)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
VisibleTimeRange = timeRangeBindable,
|
VisibleTimeRange = timeRangeBindable,
|
||||||
@ -126,18 +126,17 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
private class TestSpeedAdjustmentContainer : SpeedAdjustmentContainer
|
private class TestSpeedAdjustmentContainer : SpeedAdjustmentContainer
|
||||||
{
|
{
|
||||||
public TestSpeedAdjustmentContainer(MultiplierControlPoint controlPoint)
|
public TestSpeedAdjustmentContainer(MultiplierControlPoint controlPoint)
|
||||||
: base(controlPoint, Axes.Y)
|
: base(controlPoint)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DrawableTimingSection CreateTimingSection() => new TestDrawableTimingSection(ControlPoint);
|
protected override DrawableTimingSection CreateTimingSection(MultiplierControlPoint controlPoint) => new TestDrawableTimingSection(controlPoint);
|
||||||
|
|
||||||
private class TestDrawableTimingSection : DrawableTimingSection
|
private class TestDrawableTimingSection : DrawableTimingSection
|
||||||
{
|
{
|
||||||
private readonly MultiplierControlPoint controlPoint;
|
private readonly MultiplierControlPoint controlPoint;
|
||||||
|
|
||||||
public TestDrawableTimingSection(MultiplierControlPoint controlPoint)
|
public TestDrawableTimingSection(MultiplierControlPoint controlPoint)
|
||||||
: base(Axes.Y)
|
|
||||||
{
|
{
|
||||||
this.controlPoint = controlPoint;
|
this.controlPoint = controlPoint;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
private readonly MultiplierControlPoint controlPoint;
|
private readonly MultiplierControlPoint controlPoint;
|
||||||
|
|
||||||
public BasicScrollingDrawableTimingSection(MultiplierControlPoint controlPoint)
|
public BasicScrollingDrawableTimingSection(MultiplierControlPoint controlPoint)
|
||||||
: base(Axes.Y)
|
|
||||||
{
|
{
|
||||||
this.controlPoint = controlPoint;
|
this.controlPoint = controlPoint;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
private readonly MultiplierControlPoint controlPoint;
|
private readonly MultiplierControlPoint controlPoint;
|
||||||
|
|
||||||
public GravityScrollingDrawableTimingSection(MultiplierControlPoint controlPoint)
|
public GravityScrollingDrawableTimingSection(MultiplierControlPoint controlPoint)
|
||||||
: base(Axes.Y)
|
|
||||||
{
|
{
|
||||||
this.controlPoint = controlPoint;
|
this.controlPoint = controlPoint;
|
||||||
}
|
}
|
||||||
|
@ -11,34 +11,20 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
private readonly ScrollingAlgorithm scrollingAlgorithm;
|
private readonly ScrollingAlgorithm scrollingAlgorithm;
|
||||||
|
|
||||||
public ManiaSpeedAdjustmentContainer(MultiplierControlPoint timingSection, ScrollingAlgorithm scrollingAlgorithm)
|
public ManiaSpeedAdjustmentContainer(MultiplierControlPoint timingSection, ScrollingAlgorithm scrollingAlgorithm)
|
||||||
: base(timingSection, Axes.Y)
|
: base(timingSection)
|
||||||
{
|
{
|
||||||
this.scrollingAlgorithm = scrollingAlgorithm;
|
this.scrollingAlgorithm = scrollingAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override DrawableTimingSection CreateTimingSection(MultiplierControlPoint controlPoint)
|
||||||
{
|
|
||||||
base.UpdateAfterChildren();
|
|
||||||
|
|
||||||
var parent = Parent as SpeedAdjustmentCollection;
|
|
||||||
|
|
||||||
if (parent == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// This is very naive and can be improved, but is adequate for now
|
|
||||||
LifetimeStart = ControlPoint.StartTime - VisibleTimeRange;
|
|
||||||
LifetimeEnd = ControlPoint.StartTime + Content.Height * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override DrawableTimingSection CreateTimingSection()
|
|
||||||
{
|
{
|
||||||
switch (scrollingAlgorithm)
|
switch (scrollingAlgorithm)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ScrollingAlgorithm.Basic:
|
case ScrollingAlgorithm.Basic:
|
||||||
return new BasicScrollingDrawableTimingSection(ControlPoint);
|
return new BasicScrollingDrawableTimingSection(controlPoint);
|
||||||
case ScrollingAlgorithm.Gravity:
|
case ScrollingAlgorithm.Gravity:
|
||||||
return new GravityScrollingDrawableTimingSection(ControlPoint);
|
return new GravityScrollingDrawableTimingSection(controlPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
speedAdjustments = new SpeedAdjustmentCollection
|
speedAdjustments = new SpeedAdjustmentCollection(Axes.Y)
|
||||||
{
|
{
|
||||||
Name = "Hit objects",
|
Name = "Hit objects",
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
@ -122,7 +122,7 @@ 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 SpeedAdjustmentCollection
|
barLineContainer = new SpeedAdjustmentCollection(Axes.Y)
|
||||||
{
|
{
|
||||||
Name = "Bar lines",
|
Name = "Bar lines",
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
|
@ -46,18 +46,18 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
|
|
||||||
protected override IComparer<Drawable> DepthComparer => new HitObjectReverseStartTimeComparer();
|
protected override IComparer<Drawable> DepthComparer => new HitObjectReverseStartTimeComparer();
|
||||||
|
|
||||||
private readonly Axes autoSizingAxes;
|
/// <summary>
|
||||||
|
/// Axes through which this timing section scrolls. This is set from <see cref="SpeedAdjustmentContainer"/>.
|
||||||
|
/// </summary>
|
||||||
|
internal Axes ScrollingAxes;
|
||||||
|
|
||||||
private Cached layout = new Cached();
|
private Cached layout = new Cached();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="DrawableTimingSection"/>.
|
/// Creates a new <see cref="DrawableTimingSection"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="autoSizingAxes">The axes on which to auto-size to the total size of items in the container.</param>
|
protected DrawableTimingSection()
|
||||||
protected DrawableTimingSection(Axes autoSizingAxes)
|
|
||||||
{
|
{
|
||||||
this.autoSizingAxes = autoSizingAxes;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
RelativePositionAxes = Axes.Both;
|
RelativePositionAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
float height = Children.Select(child => child.Y + child.Height).Max() - RelativeChildOffset.Y;
|
float height = Children.Select(child => child.Y + child.Height).Max() - RelativeChildOffset.Y;
|
||||||
|
|
||||||
// Consider that width/height are time values. To have ourselves span these time values 1:1, we first need to set our size
|
// Consider that width/height are time values. To have ourselves span these time values 1:1, we first need to set our size
|
||||||
Size = new Vector2((autoSizingAxes & Axes.X) > 0 ? width : Size.X, (autoSizingAxes & Axes.Y) > 0 ? height : Size.Y);
|
Size = new Vector2((ScrollingAxes & Axes.X) > 0 ? width : Size.X, (ScrollingAxes & Axes.Y) > 0 ? height : Size.Y);
|
||||||
// Then to make our position-space be time values again, we need our relative child size to follow our size
|
// Then to make our position-space be time values again, we need our relative child size to follow our size
|
||||||
RelativeChildSize = Size;
|
RelativeChildSize = Size;
|
||||||
});
|
});
|
||||||
|
@ -40,6 +40,17 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Queue<DrawableHitObject> queuedHitObjects = new Queue<DrawableHitObject>();
|
private readonly Queue<DrawableHitObject> queuedHitObjects = new Queue<DrawableHitObject>();
|
||||||
|
|
||||||
|
private readonly Axes scrollingAxes;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="SpeedAdjustmentCollection"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scrollingAxes">The axes upon which hit objects should appear to scroll inside this container.</param>
|
||||||
|
public SpeedAdjustmentCollection(Axes scrollingAxes)
|
||||||
|
{
|
||||||
|
this.scrollingAxes = scrollingAxes;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a hit object to this <see cref="SpeedAdjustmentCollection"/>. The hit objects will be kept in a queue
|
/// Adds a hit object to this <see cref="SpeedAdjustmentCollection"/>. The hit objects will be kept in a queue
|
||||||
/// and will be processed when new <see cref="SpeedAdjustmentContainer"/>s are added to this <see cref="SpeedAdjustmentCollection"/>.
|
/// and will be processed when new <see cref="SpeedAdjustmentContainer"/>s are added to this <see cref="SpeedAdjustmentCollection"/>.
|
||||||
@ -53,6 +64,7 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
public override void Add(SpeedAdjustmentContainer speedAdjustment)
|
public override void Add(SpeedAdjustmentContainer speedAdjustment)
|
||||||
{
|
{
|
||||||
speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange);
|
speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange);
|
||||||
|
speedAdjustment.ScrollingAxes = scrollingAxes;
|
||||||
base.Add(speedAdjustment);
|
base.Add(speedAdjustment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Timing
|
namespace osu.Game.Rulesets.Timing
|
||||||
{
|
{
|
||||||
@ -31,35 +34,34 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
set { visibleTimeRange.BindTo(value); }
|
set { visibleTimeRange.BindTo(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="MultiplierControlPoint"/> which provides the speed adjustments for this container.
|
|
||||||
/// </summary>
|
|
||||||
public readonly MultiplierControlPoint ControlPoint;
|
|
||||||
|
|
||||||
protected override Container<DrawableHitObject> Content => content;
|
protected override Container<DrawableHitObject> Content => content;
|
||||||
private Container<DrawableHitObject> content;
|
private Container<DrawableHitObject> content;
|
||||||
|
|
||||||
public readonly Axes ScrollingAxes;
|
/// <summary>
|
||||||
|
/// Axes which the content of this container will scroll through.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Axes ScrollingAxes { get; internal set; }
|
||||||
|
|
||||||
|
public readonly MultiplierControlPoint ControlPoint;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="SpeedAdjustmentContainer"/>.
|
/// Creates a new <see cref="SpeedAdjustmentContainer"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="controlPoint">The <see cref="MultiplierControlPoint"/> which provides the speed adjustments for this container.</param>
|
/// <param name="controlPoint">The <see cref="MultiplierControlPoint"/> which provides the speed adjustments for this container.</param>
|
||||||
/// <param name="scrollingAxes">The axes through which the content of this container should scroll through.</param>
|
protected SpeedAdjustmentContainer(MultiplierControlPoint controlPoint)
|
||||||
protected SpeedAdjustmentContainer(MultiplierControlPoint controlPoint, Axes scrollingAxes)
|
|
||||||
{
|
{
|
||||||
ScrollingAxes = scrollingAxes;
|
this.ControlPoint = controlPoint;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
ControlPoint = controlPoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
DrawableTimingSection timingSection = CreateTimingSection();
|
DrawableTimingSection timingSection = CreateTimingSection(ControlPoint);
|
||||||
|
|
||||||
|
timingSection.ScrollingAxes = ScrollingAxes;
|
||||||
timingSection.VisibleTimeRange.BindTo(VisibleTimeRange);
|
timingSection.VisibleTimeRange.BindTo(VisibleTimeRange);
|
||||||
timingSection.RelativeChildOffset = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)ControlPoint.StartTime : 0, (ScrollingAxes & Axes.Y) > 0 ? (float)ControlPoint.StartTime : 0);
|
timingSection.RelativeChildOffset = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)ControlPoint.StartTime : 0, (ScrollingAxes & Axes.Y) > 0 ? (float)ControlPoint.StartTime : 0);
|
||||||
|
|
||||||
@ -89,6 +91,6 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
/// Creates the container which handles the movement of a collection of hit objects.
|
/// Creates the container which handles the movement of a collection of hit objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The <see cref="DrawableTimingSection"/>.</returns>
|
/// <returns>The <see cref="DrawableTimingSection"/>.</returns>
|
||||||
protected abstract DrawableTimingSection CreateTimingSection();
|
protected abstract DrawableTimingSection CreateTimingSection(MultiplierControlPoint controlPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user