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