1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 19:53:23 +08:00

Expose current break index

This commit is contained in:
iiSaLMaN 2019-07-30 13:29:41 +03:00
parent e8e5b2742d
commit e6e315e07b
2 changed files with 11 additions and 8 deletions

View File

@ -147,6 +147,8 @@ namespace osu.Game.Tests.Visual.Gameplay
private readonly ManualClock manualClock;
private IFrameBasedClock originalClock;
public new int CurrentBreakIndex => base.CurrentBreakIndex;
public double ManualClockTime
{
get => manualClock.CurrentTime;

View File

@ -34,7 +34,7 @@ namespace osu.Game.Screens.Play
// reset index in case the new breaks list is smaller than last one
isBreakTime.Value = false;
currentBreakIndex = 0;
CurrentBreakIndex = 0;
initializeBreaks();
}
@ -47,7 +47,8 @@ namespace osu.Game.Screens.Play
/// </summary>
public IBindable<bool> IsBreakTime => isBreakTime;
private int currentBreakIndex;
protected int CurrentBreakIndex;
private readonly BindableBool isBreakTime = new BindableBool();
private readonly Container remainingTimeAdjustmentBox;
@ -137,21 +138,21 @@ namespace osu.Game.Screens.Play
var time = Clock.CurrentTime;
if (time > breaks[currentBreakIndex].EndTime)
if (time > breaks[CurrentBreakIndex].EndTime)
{
while (time > breaks[currentBreakIndex].EndTime && currentBreakIndex < breaks.Count - 1)
currentBreakIndex++;
while (time > breaks[CurrentBreakIndex].EndTime && CurrentBreakIndex < breaks.Count - 1)
CurrentBreakIndex++;
}
else
{
while (time < breaks[currentBreakIndex].StartTime && currentBreakIndex > 0)
currentBreakIndex--;
while (time < breaks[CurrentBreakIndex].StartTime && CurrentBreakIndex > 0)
CurrentBreakIndex--;
}
// This ensures that IsBreakTime is generally consistent with the overlay's transforms during a break.
// If the current break doesn't have effects, IsBreakTime should be false.
// We also assume that the overlay's fade out transform is "not break time".
var currentBreak = breaks[currentBreakIndex];
var currentBreak = breaks[CurrentBreakIndex];
isBreakTime.Value = currentBreak.HasEffect && time >= currentBreak.StartTime && time <= currentBreak.EndTime - fade_duration;
}