mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:03:08 +08:00
Consider intro and outro time as "break" time (#6960)
Consider intro and outro time as "break" time Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
commit
9494a477b6
@ -95,6 +95,19 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
seekAndAssertBreak("seek to break after end", testBreaks[1].EndTime + 500, false);
|
seekAndAssertBreak("seek to break after end", testBreaks[1].EndTime + 500, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(true)]
|
||||||
|
[TestCase(false)]
|
||||||
|
public void TestBeforeGameplayStart(bool withBreaks)
|
||||||
|
{
|
||||||
|
setClock(true);
|
||||||
|
|
||||||
|
if (withBreaks)
|
||||||
|
loadBreaksStep("multiple breaks", testBreaks);
|
||||||
|
|
||||||
|
seekAndAssertBreak("seek to break intro time", -100, true);
|
||||||
|
seekAndAssertBreak("seek to break intro time", 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
private void addShowBreakStep(double seconds)
|
private void addShowBreakStep(double seconds)
|
||||||
{
|
{
|
||||||
AddStep($"show '{seconds}s' break", () => breakOverlay.Breaks = new List<BreakPeriod>
|
AddStep($"show '{seconds}s' break", () => breakOverlay.Breaks = new List<BreakPeriod>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -16,6 +16,8 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
public class BreakOverlay : Container
|
public class BreakOverlay : Container
|
||||||
{
|
{
|
||||||
|
private readonly ScoreProcessor scoreProcessor;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The duration of the break overlay fading.
|
/// The duration of the break overlay fading.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -60,9 +62,12 @@ namespace osu.Game.Screens.Play
|
|||||||
private readonly RemainingTimeCounter remainingTimeCounter;
|
private readonly RemainingTimeCounter remainingTimeCounter;
|
||||||
private readonly BreakInfo info;
|
private readonly BreakInfo info;
|
||||||
private readonly BreakArrows breakArrows;
|
private readonly BreakArrows breakArrows;
|
||||||
|
private readonly double gameplayStartTime;
|
||||||
|
|
||||||
public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor = null)
|
public BreakOverlay(bool letterboxing, double gameplayStartTime = 0, ScoreProcessor scoreProcessor = null)
|
||||||
{
|
{
|
||||||
|
this.gameplayStartTime = gameplayStartTime;
|
||||||
|
this.scoreProcessor = scoreProcessor;
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Child = fadeContainer = new Container
|
Child = fadeContainer = new Container
|
||||||
{
|
{
|
||||||
@ -135,11 +140,15 @@ namespace osu.Game.Screens.Play
|
|||||||
updateBreakTimeBindable();
|
updateBreakTimeBindable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBreakTimeBindable()
|
private void updateBreakTimeBindable() =>
|
||||||
{
|
isBreakTime.Value = getCurrentBreak()?.HasEffect == true
|
||||||
if (breaks == null || breaks.Count == 0)
|
|| Clock.CurrentTime < gameplayStartTime
|
||||||
return;
|
|| scoreProcessor?.HasCompleted == true;
|
||||||
|
|
||||||
|
private BreakPeriod getCurrentBreak()
|
||||||
|
{
|
||||||
|
if (breaks?.Count > 0)
|
||||||
|
{
|
||||||
var time = Clock.CurrentTime;
|
var time = Clock.CurrentTime;
|
||||||
|
|
||||||
if (time > breaks[CurrentBreakIndex].EndTime)
|
if (time > breaks[CurrentBreakIndex].EndTime)
|
||||||
@ -153,8 +162,12 @@ namespace osu.Game.Screens.Play
|
|||||||
CurrentBreakIndex--;
|
CurrentBreakIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentBreak = breaks[CurrentBreakIndex];
|
var closest = breaks[CurrentBreakIndex];
|
||||||
isBreakTime.Value = currentBreak.HasEffect && currentBreak.Contains(time);
|
|
||||||
|
return closest.Contains(time) ? closest : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeBreaks()
|
private void initializeBreaks()
|
||||||
|
@ -179,7 +179,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
target.AddRange(new[]
|
target.AddRange(new[]
|
||||||
{
|
{
|
||||||
breakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
breakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, DrawableRuleset.GameplayStartTime, ScoreProcessor)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -468,7 +468,7 @@ namespace osu.Game.Screens.Play
|
|||||||
PauseOverlay.Hide();
|
PauseOverlay.Hide();
|
||||||
|
|
||||||
// breaks and time-based conditions may allow instant resume.
|
// breaks and time-based conditions may allow instant resume.
|
||||||
if (breakOverlay.IsBreakTime.Value || GameplayClockContainer.GameplayClock.CurrentTime < Beatmap.Value.Beatmap.HitObjects.First().StartTime)
|
if (breakOverlay.IsBreakTime.Value)
|
||||||
completeResume();
|
completeResume();
|
||||||
else
|
else
|
||||||
DrawableRuleset.RequestResume(completeResume);
|
DrawableRuleset.RequestResume(completeResume);
|
||||||
|
Loading…
Reference in New Issue
Block a user