mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Make ScrollingPlayfield.Reversed protected; make ManiaPlayfield 'invertible'.
This commit is contained in:
parent
17900fea62
commit
115e5c95af
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
@ -13,7 +12,6 @@ using osu.Game.Rulesets.Mania.Objects.Drawables;
|
|||||||
using osu.Game.Rulesets.Mania.Timing;
|
using osu.Game.Rulesets.Mania.Timing;
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.Timing;
|
using osu.Game.Rulesets.Timing;
|
||||||
using OpenTK;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
namespace osu.Desktop.Tests.Visual
|
namespace osu.Desktop.Tests.Visual
|
||||||
@ -39,12 +37,12 @@ namespace osu.Desktop.Tests.Visual
|
|||||||
AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal));
|
AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal));
|
||||||
AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left));
|
AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left));
|
||||||
AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right));
|
AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right));
|
||||||
|
AddStep("Reversed", () => createPlayfield(4, SpecialColumnPosition.Normal, true));
|
||||||
|
|
||||||
AddStep("Notes with input", () => createPlayfieldWithNotes(false));
|
AddStep("Notes with input", () => createPlayfieldWithNotes(false));
|
||||||
AddWaitStep((int)Math.Ceiling((start_time + duration) / TimePerAction));
|
AddStep("Notes with input (reversed)", () => createPlayfieldWithNotes(false, true));
|
||||||
|
|
||||||
AddStep("Notes with gravity", () => createPlayfieldWithNotes(true));
|
AddStep("Notes with gravity", () => createPlayfieldWithNotes(true));
|
||||||
AddWaitStep((int)Math.Ceiling((start_time + duration) / TimePerAction));
|
AddStep("Notes with gravity (reversed)", () => createPlayfieldWithNotes(true, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -58,23 +56,25 @@ namespace osu.Desktop.Tests.Visual
|
|||||||
TimingPoint = { BeatLength = 1000 }
|
TimingPoint = { BeatLength = 1000 }
|
||||||
}, gravity ? ScrollingAlgorithm.Gravity : ScrollingAlgorithm.Basic);
|
}, gravity ? ScrollingAlgorithm.Gravity : ScrollingAlgorithm.Basic);
|
||||||
|
|
||||||
private void createPlayfield(int cols, SpecialColumnPosition specialPos)
|
private void createPlayfield(int cols, SpecialColumnPosition specialPos, bool inverted = false)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
var inputManager = new ManiaInputManager(maniaRuleset, cols) { RelativeSizeAxes = Axes.Both };
|
var inputManager = new ManiaInputManager(maniaRuleset, cols) { RelativeSizeAxes = Axes.Both };
|
||||||
Add(inputManager);
|
Add(inputManager);
|
||||||
|
|
||||||
inputManager.Add(new ManiaPlayfield(cols)
|
ManiaPlayfield playfield;
|
||||||
|
inputManager.Add(playfield = new ManiaPlayfield(cols)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
SpecialColumnPosition = specialPos,
|
SpecialColumnPosition = specialPos
|
||||||
Scale = new Vector2(1, -1)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
playfield.Inverted.Value = inverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPlayfieldWithNotes(bool gravity)
|
private void createPlayfieldWithNotes(bool gravity, bool inverted = false)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
@ -83,33 +83,34 @@ namespace osu.Desktop.Tests.Visual
|
|||||||
var inputManager = new ManiaInputManager(maniaRuleset, 4) { RelativeSizeAxes = Axes.Both };
|
var inputManager = new ManiaInputManager(maniaRuleset, 4) { RelativeSizeAxes = Axes.Both };
|
||||||
Add(inputManager);
|
Add(inputManager);
|
||||||
|
|
||||||
ManiaPlayfield playField;
|
ManiaPlayfield playfield;
|
||||||
inputManager.Add(playField = new ManiaPlayfield(4)
|
inputManager.Add(playfield = new ManiaPlayfield(4)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Scale = new Vector2(1, -1),
|
|
||||||
Clock = new FramedClock(rateAdjustClock)
|
Clock = new FramedClock(rateAdjustClock)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
playfield.Inverted.Value = inverted;
|
||||||
|
|
||||||
if (!gravity)
|
if (!gravity)
|
||||||
playField.Columns.ForEach(c => c.Add(createTimingChange(0, false)));
|
playfield.Columns.ForEach(c => c.Add(createTimingChange(0, false)));
|
||||||
|
|
||||||
for (double t = start_time; t <= start_time + duration; t += 100)
|
for (double t = start_time; t <= start_time + duration; t += 100)
|
||||||
{
|
{
|
||||||
if (gravity)
|
if (gravity)
|
||||||
playField.Columns.ElementAt(0).Add(createTimingChange(t, true));
|
playfield.Columns.ElementAt(0).Add(createTimingChange(t, true));
|
||||||
|
|
||||||
playField.Add(new DrawableNote(new Note
|
playfield.Add(new DrawableNote(new Note
|
||||||
{
|
{
|
||||||
StartTime = t,
|
StartTime = t,
|
||||||
Column = 0
|
Column = 0
|
||||||
}, ManiaAction.Key1));
|
}, ManiaAction.Key1));
|
||||||
|
|
||||||
if (gravity)
|
if (gravity)
|
||||||
playField.Columns.ElementAt(3).Add(createTimingChange(t, true));
|
playfield.Columns.ElementAt(3).Add(createTimingChange(t, true));
|
||||||
|
|
||||||
playField.Add(new DrawableNote(new Note
|
playfield.Add(new DrawableNote(new Note
|
||||||
{
|
{
|
||||||
StartTime = t,
|
StartTime = t,
|
||||||
Column = 3
|
Column = 3
|
||||||
@ -117,9 +118,9 @@ namespace osu.Desktop.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gravity)
|
if (gravity)
|
||||||
playField.Columns.ElementAt(1).Add(createTimingChange(start_time, true));
|
playfield.Columns.ElementAt(1).Add(createTimingChange(start_time, true));
|
||||||
|
|
||||||
playField.Add(new DrawableHoldNote(new HoldNote
|
playfield.Add(new DrawableHoldNote(new HoldNote
|
||||||
{
|
{
|
||||||
StartTime = start_time,
|
StartTime = start_time,
|
||||||
Duration = duration,
|
Duration = duration,
|
||||||
@ -127,9 +128,9 @@ namespace osu.Desktop.Tests.Visual
|
|||||||
}, ManiaAction.Key2));
|
}, ManiaAction.Key2));
|
||||||
|
|
||||||
if (gravity)
|
if (gravity)
|
||||||
playField.Columns.ElementAt(2).Add(createTimingChange(start_time, true));
|
playfield.Columns.ElementAt(2).Add(createTimingChange(start_time, true));
|
||||||
|
|
||||||
playField.Add(new DrawableHoldNote(new HoldNote
|
playfield.Add(new DrawableHoldNote(new HoldNote
|
||||||
{
|
{
|
||||||
StartTime = start_time,
|
StartTime = start_time,
|
||||||
Duration = duration,
|
Duration = duration,
|
||||||
|
@ -64,8 +64,8 @@ namespace osu.Desktop.Tests.Visual
|
|||||||
|
|
||||||
AddStep("Reverse direction", () =>
|
AddStep("Reverse direction", () =>
|
||||||
{
|
{
|
||||||
horizontalRulesetContainer.Playfield.Reversed.Toggle();
|
horizontalRulesetContainer.Playfield.Reverse();
|
||||||
verticalRulesetContainer.Playfield.Reversed.Toggle();
|
verticalRulesetContainer.Playfield.Reverse();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,6 +210,8 @@ namespace osu.Desktop.Tests.Visual
|
|||||||
content = new Container { RelativeSizeAxes = Axes.Both }
|
content = new Container { RelativeSizeAxes = Axes.Both }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Reverse() => Reversed.Toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Allocation;
|
|||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -45,6 +46,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this playfield should be inverted. This flips everything inside the playfield.
|
||||||
|
/// </summary>
|
||||||
|
public readonly Bindable<bool> Inverted = new Bindable<bool>(true);
|
||||||
|
|
||||||
private readonly FlowContainer<Column> columns;
|
private readonly FlowContainer<Column> columns;
|
||||||
public IEnumerable<Column> Columns => columns.Children;
|
public IEnumerable<Column> Columns => columns.Children;
|
||||||
|
|
||||||
@ -64,6 +70,8 @@ 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.");
|
||||||
|
|
||||||
|
Inverted.Value = true;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container
|
new Container
|
||||||
@ -126,7 +134,6 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
for (int i = 0; i < columnCount; i++)
|
for (int i = 0; i < columnCount; i++)
|
||||||
{
|
{
|
||||||
var c = new Column();
|
var c = new Column();
|
||||||
c.Reversed.BindTo(Reversed);
|
|
||||||
c.VisibleTimeRange.BindTo(VisibleTimeRange);
|
c.VisibleTimeRange.BindTo(VisibleTimeRange);
|
||||||
|
|
||||||
c.IsSpecial = isSpecialColumn(i);
|
c.IsSpecial = isSpecialColumn(i);
|
||||||
@ -135,6 +142,14 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
columns.Add(c);
|
columns.Add(c);
|
||||||
AddNested(c);
|
AddNested(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Inverted.ValueChanged += invertedChanged;
|
||||||
|
Inverted.TriggerChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invertedChanged(bool newValue)
|
||||||
|
{
|
||||||
|
Scale = new Vector2(1, newValue ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -55,9 +55,9 @@ namespace osu.Game.Rulesets.UI
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to reverse the scrolling direction is reversed.
|
/// Whether to reverse the scrolling direction is reversed. Note that this does _not_ invert the hit objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly BindableBool Reversed = new BindableBool();
|
protected readonly BindableBool Reversed = new BindableBool();
|
||||||
|
|
||||||
/// <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.
|
||||||
|
Loading…
Reference in New Issue
Block a user