mirror of
https://github.com/ppy/osu.git
synced 2025-01-21 08:12:56 +08:00
Create a constructor for break period
For simple construction of break periods (e.g. filling a method with an array of break periods inside a test case)
This commit is contained in:
parent
9477629a56
commit
0eaea8ef9d
@ -26,16 +26,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private readonly IReadOnlyList<BreakPeriod> testBreaks = new List<BreakPeriod>
|
private readonly IReadOnlyList<BreakPeriod> testBreaks = new List<BreakPeriod>
|
||||||
{
|
{
|
||||||
new BreakPeriod
|
new BreakPeriod(1000, 5000),
|
||||||
{
|
new BreakPeriod(6000, 13500),
|
||||||
StartTime = 1000,
|
|
||||||
EndTime = 5000,
|
|
||||||
},
|
|
||||||
new BreakPeriod
|
|
||||||
{
|
|
||||||
StartTime = 6000,
|
|
||||||
EndTime = 13500,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public TestSceneBreakTracker()
|
public TestSceneBreakTracker()
|
||||||
@ -70,7 +62,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestNoEffectsBreak()
|
public void TestNoEffectsBreak()
|
||||||
{
|
{
|
||||||
var shortBreak = new BreakPeriod { EndTime = 500 };
|
var shortBreak = new BreakPeriod(0, 500);
|
||||||
|
|
||||||
setClock(true);
|
setClock(true);
|
||||||
loadBreaksStep("short break", new[] { shortBreak });
|
loadBreaksStep("short break", new[] { shortBreak });
|
||||||
@ -127,13 +119,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private void addShowBreakStep(double seconds)
|
private void addShowBreakStep(double seconds)
|
||||||
{
|
{
|
||||||
AddStep($"show '{seconds}s' break", () => breakOverlay.Breaks = breakTracker.Breaks = new List<BreakPeriod>
|
AddStep($"show '{seconds}s' break", () =>
|
||||||
{
|
{
|
||||||
new BreakPeriod
|
breakOverlay.Breaks = breakTracker.Breaks = new List<BreakPeriod>
|
||||||
{
|
{
|
||||||
StartTime = Clock.CurrentTime,
|
new BreakPeriod(Clock.CurrentTime, Clock.CurrentTime + seconds * 1000)
|
||||||
EndTime = Clock.CurrentTime + seconds * 1000,
|
};
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,12 +305,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
case LegacyEventType.Break:
|
case LegacyEventType.Break:
|
||||||
double start = getOffsetTime(Parsing.ParseDouble(split[1]));
|
double start = getOffsetTime(Parsing.ParseDouble(split[1]));
|
||||||
|
double end = Math.Max(start, getOffsetTime(Parsing.ParseDouble(split[2])));
|
||||||
|
|
||||||
var breakEvent = new BreakPeriod
|
var breakEvent = new BreakPeriod(start, end);
|
||||||
{
|
|
||||||
StartTime = start,
|
|
||||||
EndTime = Math.Max(start, getOffsetTime(Parsing.ParseDouble(split[2])))
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!breakEvent.HasEffect)
|
if (!breakEvent.HasEffect)
|
||||||
return;
|
return;
|
||||||
|
@ -32,6 +32,17 @@ namespace osu.Game.Beatmaps.Timing
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HasEffect => Duration >= MIN_BREAK_DURATION;
|
public bool HasEffect => Duration >= MIN_BREAK_DURATION;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new break period.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="startTime">The start time of the break period.</param>
|
||||||
|
/// <param name="endTime">The end time of the break period.</param>
|
||||||
|
public BreakPeriod(double startTime, double endTime)
|
||||||
|
{
|
||||||
|
StartTime = startTime;
|
||||||
|
EndTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this break contains a specified time.
|
/// Whether this break contains a specified time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user