Enforce exception better

This commit is contained in:
Dean Herbert 2017-06-15 14:48:02 +09:00
parent 585e7ba312
commit 32226f90db
2 changed files with 8 additions and 8 deletions

View File

@ -40,11 +40,11 @@ public Bindable<double> VisibleTimeRange
/// <param name="hitObject">The hit object to add.</param>
public void Add(DrawableHitObject hitObject)
{
if (hitObject.RelativePositionAxes == Axes.None)
throw new InvalidOperationException($"Make sure to set all {nameof(DrawableHitObject)}'s {nameof(RelativePositionAxes)} to some axis of relativity");
var target = adjustmentContainerFor(hitObject);
if (hitObject.RelativePositionAxes != target.ScrollingAxes)
throw new InvalidOperationException($"Make sure to set all {nameof(DrawableHitObject)}'s {nameof(RelativePositionAxes)} are equal to the correct axes of scrolling ({target.ScrollingAxes}).");
if (target == null)
throw new ArgumentException("No speed adjustment could be found that can contain the hit object.", nameof(hitObject));

View File

@ -39,7 +39,7 @@ public Bindable<double> VisibleTimeRange
protected override Container<DrawableHitObject> Content => content;
private Container<DrawableHitObject> content;
private readonly Axes scrollingAxes;
public readonly Axes ScrollingAxes;
/// <summary>
/// Creates a new <see cref="SpeedAdjustmentContainer"/>.
@ -48,7 +48,7 @@ public Bindable<double> VisibleTimeRange
/// <param name="scrollingAxes">The axes through which the content of this container should scroll through.</param>
protected SpeedAdjustmentContainer(MultiplierControlPoint controlPoint, Axes scrollingAxes)
{
this.scrollingAxes = scrollingAxes;
ScrollingAxes = scrollingAxes;
RelativeSizeAxes = Axes.Both;
@ -61,7 +61,7 @@ private void load()
DrawableTimingSection timingSection = CreateTimingSection();
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);
AddInternal(content = timingSection);
}
@ -71,8 +71,8 @@ protected override void Update()
float multiplier = (float)ControlPoint.Multiplier;
// The speed adjustment happens by modifying our size by the multiplier while maintaining the visible time range as the relatve size for our children
Size = new Vector2((scrollingAxes & Axes.X) > 0 ? multiplier : 1, (scrollingAxes & Axes.Y) > 0 ? multiplier : 1);
RelativeChildSize = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)VisibleTimeRange : 1, (scrollingAxes & Axes.Y) > 0 ? (float)VisibleTimeRange : 1);
Size = new Vector2((ScrollingAxes & Axes.X) > 0 ? multiplier : 1, (ScrollingAxes & Axes.Y) > 0 ? multiplier : 1);
RelativeChildSize = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)VisibleTimeRange : 1, (ScrollingAxes & Axes.Y) > 0 ? (float)VisibleTimeRange : 1);
}
/// <summary>