mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Add reversing capability to ScrollingPlayfield.
This commit is contained in:
parent
bcd1b61529
commit
c5ce86b9f3
@ -24,6 +24,8 @@ namespace osu.Desktop.Tests.Visual
|
||||
/// </summary>
|
||||
public class TestCaseScrollingPlayfield : OsuTestCase
|
||||
{
|
||||
private readonly TestHitRenderer hitRenderer;
|
||||
|
||||
public TestCaseScrollingPlayfield()
|
||||
{
|
||||
Clock = new FramedClock();
|
||||
@ -50,7 +52,9 @@ namespace osu.Desktop.Tests.Visual
|
||||
|
||||
WorkingBeatmap beatmap = new TestWorkingBeatmap(b);
|
||||
|
||||
Add(new TestHitRenderer(beatmap, true));
|
||||
Add(hitRenderer = new TestHitRenderer(beatmap, true));
|
||||
|
||||
AddStep("Reverse direction", () => hitRenderer.Playfield.Reversed.Value = !hitRenderer.Playfield.Reversed);
|
||||
}
|
||||
|
||||
private class TestHitRenderer : ScrollingHitRenderer<TestPlayfield, TestHitObject, TestJudgement>
|
||||
@ -60,6 +64,8 @@ namespace osu.Desktop.Tests.Visual
|
||||
{
|
||||
}
|
||||
|
||||
public new TestPlayfield Playfield => base.Playfield;
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TestScoreProcessor();
|
||||
|
||||
protected override BeatmapConverter<TestHitObject> CreateBeatmapConverter() => new TestBeatmapConverter();
|
||||
|
@ -124,7 +124,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
for (int i = 0; i < columnCount; i++)
|
||||
{
|
||||
var c = new Column { VisibleTimeRange = VisibleTimeRange };
|
||||
var c = new Column();
|
||||
c.VisibleTimeRange.BindTo(VisibleTimeRange);
|
||||
|
||||
columns.Add(c);
|
||||
AddNested(c);
|
||||
}
|
||||
|
@ -26,6 +26,16 @@ namespace osu.Game.Rulesets.Timing
|
||||
set { visibleTimeRange.BindTo(value); }
|
||||
}
|
||||
|
||||
private readonly BindableBool reversed = new BindableBool();
|
||||
/// <summary>
|
||||
/// Whether to reverse the scrolling direction is reversed.
|
||||
/// </summary>
|
||||
public BindableBool Reversed
|
||||
{
|
||||
get { return reversed; }
|
||||
set { reversed.BindTo(value); }
|
||||
}
|
||||
|
||||
protected override Container<DrawableHitObject> Content => content;
|
||||
private Container<DrawableHitObject> content;
|
||||
|
||||
@ -70,7 +80,14 @@ namespace osu.Game.Rulesets.Timing
|
||||
|
||||
// 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);
|
||||
|
||||
if (Reversed)
|
||||
{
|
||||
RelativeChildSize = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)-VisibleTimeRange : 1, (ScrollingAxes & Axes.Y) > 0 ? (float)-VisibleTimeRange : 1);
|
||||
RelativeChildOffset = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)VisibleTimeRange : 0, (ScrollingAxes & Axes.Y) > 0 ? (float)VisibleTimeRange : 0);
|
||||
}
|
||||
else
|
||||
RelativeChildSize = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)VisibleTimeRange : 1, (ScrollingAxes & Axes.Y) > 0 ? (float)VisibleTimeRange : 1);
|
||||
}
|
||||
|
||||
public override double LifetimeStart => ControlPoint.StartTime - VisibleTimeRange;
|
||||
|
@ -44,10 +44,10 @@ namespace osu.Game.Rulesets.UI
|
||||
private const double time_span_step = 50;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the range of time that is visible by the length of the scrolling axes.
|
||||
/// The span of time that is visible by the length of the scrolling axes.
|
||||
/// For example, only hit objects with start time less than or equal to 1000 will be visible with <see cref="VisibleTimeRange"/> = 1000.
|
||||
/// </summary>
|
||||
private readonly BindableDouble visibleTimeRange = new BindableDouble(time_span_default)
|
||||
public readonly BindableDouble VisibleTimeRange = new BindableDouble(time_span_default)
|
||||
{
|
||||
Default = time_span_default,
|
||||
MinValue = time_span_min,
|
||||
@ -55,14 +55,9 @@ namespace osu.Game.Rulesets.UI
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The span of time visible by the length of the scrolling axes.
|
||||
/// Whether to reverse the scrolling direction is reversed.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public BindableDouble VisibleTimeRange
|
||||
{
|
||||
get { return visibleTimeRange; }
|
||||
set { visibleTimeRange.BindTo(value); }
|
||||
}
|
||||
public readonly BindableBool Reversed = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// The container that contains the <see cref="SpeedAdjustmentContainer"/>s and <see cref="DrawableHitObject"/>s.
|
||||
@ -80,7 +75,8 @@ namespace osu.Game.Rulesets.UI
|
||||
base.HitObjects = HitObjects = new ScrollingHitObjectContainer(scrollingAxes)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
VisibleTimeRange = VisibleTimeRange
|
||||
VisibleTimeRange = VisibleTimeRange,
|
||||
Reversed = Reversed
|
||||
};
|
||||
}
|
||||
|
||||
@ -158,6 +154,16 @@ namespace osu.Game.Rulesets.UI
|
||||
set { visibleTimeRange.BindTo(value); }
|
||||
}
|
||||
|
||||
private readonly BindableBool reversed = new BindableBool();
|
||||
/// <summary>
|
||||
/// Whether to reverse the scrolling direction is reversed.
|
||||
/// </summary>
|
||||
public BindableBool Reversed
|
||||
{
|
||||
get { return reversed; }
|
||||
set { reversed.BindTo(value); }
|
||||
}
|
||||
|
||||
protected override Container<DrawableHitObject<TObject, TJudgement>> Content => content;
|
||||
private readonly Container<DrawableHitObject<TObject, TJudgement>> content;
|
||||
|
||||
@ -188,6 +194,7 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange);
|
||||
speedAdjustment.ScrollingAxes = scrollingAxes;
|
||||
speedAdjustment.Reversed = Reversed;
|
||||
AddInternal(speedAdjustment);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user