1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 00:42:55 +08:00

Allow skip button to actuate more than once

This commit is contained in:
Dean Herbert 2019-11-21 15:19:06 +09:00
parent c0b9bb5a12
commit 8369be90f2
4 changed files with 29 additions and 32 deletions

View File

@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
skip = new SkipOverlay(6000)
{
RequestSeek = _ => requestCount++
RequestSkip = () => requestCount++
}
},
};
@ -60,17 +60,6 @@ namespace osu.Game.Tests.Visual.Gameplay
checkRequestCount(1);
}
[Test]
public void TestClickOnlyActuatesOnce()
{
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
AddStep("click", () => InputManager.Click(MouseButton.Left));
AddStep("click", () => InputManager.Click(MouseButton.Left));
AddStep("click", () => InputManager.Click(MouseButton.Left));
AddStep("click", () => InputManager.Click(MouseButton.Left));
checkRequestCount(1);
}
[Test]
public void TestDoesntFadeOnMouseDown()
{

View File

@ -89,6 +89,11 @@ namespace osu.Game.Screens.Play
private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
/// <summary>
/// Duration before gameplay start time required before skip button displays.
/// </summary>
public const double MINIMUM_SKIP_TIME = 1000;
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
[BackgroundDependencyLoader]
@ -104,11 +109,9 @@ namespace osu.Game.Screens.Play
startTime = Math.Min(startTime, 0);
Seek(startTime);
adjustableClock.ProcessFrame();
UserPlaybackRate.ValueChanged += _ => updateRate();
Seek(Math.Min(-beatmap.BeatmapInfo.AudioLeadIn, gameplayStartTime));
}
public void Restart()
@ -139,6 +142,23 @@ namespace osu.Game.Screens.Play
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
}
/// <summary>
/// Skip forwardto the next valid skip point.
/// </summary>
public void Skip()
{
if (GameplayClock.CurrentTime > gameplayStartTime - MINIMUM_SKIP_TIME)
return;
double skipTarget = gameplayStartTime - MINIMUM_SKIP_TIME;
if (GameplayClock.CurrentTime < 0 && skipTarget > 6000)
// double skip exception for storyboards with very long intros
skipTarget = 0;
Seek(skipTarget);
}
/// <summary>
/// Seek to a specific time in gameplay.
/// <remarks>

View File

@ -203,7 +203,7 @@ namespace osu.Game.Screens.Play
},
new SkipOverlay(DrawableRuleset.GameplayStartTime)
{
RequestSeek = GameplayClockContainer.Seek
RequestSkip = GameplayClockContainer.Skip
},
FailOverlay = new FailOverlay
{

View File

@ -27,7 +27,7 @@ namespace osu.Game.Screens.Play
{
private readonly double startTime;
public Action<double> RequestSeek;
public Action RequestSkip;
private Button button;
private Box remainingTimeBox;
@ -90,11 +90,6 @@ namespace osu.Game.Screens.Play
};
}
/// <summary>
/// Duration before gameplay start time required before skip button displays.
/// </summary>
private const double skip_buffer = 1000;
private const double fade_time = 300;
private double beginFadeTime => startTime - fade_time;
@ -104,7 +99,7 @@ namespace osu.Game.Screens.Play
base.LoadComplete();
// skip is not required if there is no extra "empty" time to skip.
if (Clock.CurrentTime > beginFadeTime - skip_buffer)
if (Clock.CurrentTime > beginFadeTime - GameplayClockContainer.MINIMUM_SKIP_TIME)
{
Alpha = 0;
Expire();
@ -115,10 +110,9 @@ namespace osu.Game.Screens.Play
using (BeginAbsoluteSequence(beginFadeTime))
this.FadeOut(fade_time);
button.Action = () => RequestSeek?.Invoke(beginFadeTime);
button.Action = () => RequestSkip?.Invoke();
displayTime = Time.Current;
Expire();
}
@ -335,13 +329,7 @@ namespace osu.Game.Screens.Play
box.FlashColour(Color4.White, 500, Easing.OutQuint);
aspect.ScaleTo(1.2f, 2000, Easing.OutQuint);
bool result = base.OnClick(e);
// for now, let's disable the skip button after the first press.
// this will likely need to be contextual in the future (bound from external components).
Enabled.Value = false;
return result;
return base.OnClick(e);
}
}
}