mirror of
https://github.com/osukey/osukey.git
synced 2025-05-17 03:27:21 +09:00
Merge branch 'master' into song-progress-graph
This commit is contained in:
commit
9d753a7798
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public BeatmapInfo BeatmapInfo;
|
public BeatmapInfo BeatmapInfo;
|
||||||
|
|
||||||
public bool IsPaused { get; private set; }
|
public bool IsPaused => !interpolatedSourceClock.IsRunning;
|
||||||
|
|
||||||
public bool HasFailed { get; private set; }
|
public bool HasFailed { get; private set; }
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private const double pause_cooldown = 1000;
|
private const double pause_cooldown = 1000;
|
||||||
private double lastPauseActionTime;
|
private double lastPauseActionTime;
|
||||||
|
|
||||||
private bool canPause => Time.Current >= lastPauseActionTime + pause_cooldown;
|
private bool canPause => ValidForResume && !HasFailed && Time.Current >= lastPauseActionTime + pause_cooldown;
|
||||||
|
|
||||||
private IAdjustableClock sourceClock;
|
private IAdjustableClock sourceClock;
|
||||||
private IFrameBasedClock interpolatedSourceClock;
|
private IFrameBasedClock interpolatedSourceClock;
|
||||||
@ -205,20 +205,31 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public void Pause(bool force = false)
|
public void Pause(bool force = false)
|
||||||
{
|
{
|
||||||
if (canPause || force)
|
if (!canPause && !force) return;
|
||||||
|
|
||||||
|
// the actual pausing is potentially happening on a different thread.
|
||||||
|
// we want to wait for the source clock to stop so we can be sure all components are in a stable state.
|
||||||
|
if (!IsPaused)
|
||||||
{
|
{
|
||||||
|
sourceClock.Stop();
|
||||||
|
|
||||||
|
Schedule(() => Pause(force));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we need to do a final check after all of our children have processed up to the paused clock time.
|
||||||
|
// this is to cover cases where, for instance, the player fails in the last processed frame (which would change canPause).
|
||||||
|
// as the scheduler runs before children updates, let's schedule for the next frame.
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
if (!canPause) return;
|
||||||
|
|
||||||
lastPauseActionTime = Time.Current;
|
lastPauseActionTime = Time.Current;
|
||||||
hudOverlay.KeyCounter.IsCounting = false;
|
hudOverlay.KeyCounter.IsCounting = false;
|
||||||
hudOverlay.Progress.Show();
|
hudOverlay.Progress.Show();
|
||||||
pauseOverlay.Retries = RestartCount;
|
pauseOverlay.Retries = RestartCount;
|
||||||
pauseOverlay.Show();
|
pauseOverlay.Show();
|
||||||
sourceClock.Stop();
|
});
|
||||||
IsPaused = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IsPaused = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Resume()
|
public void Resume()
|
||||||
@ -228,13 +239,6 @@ namespace osu.Game.Screens.Play
|
|||||||
hudOverlay.Progress.Hide();
|
hudOverlay.Progress.Hide();
|
||||||
pauseOverlay.Hide();
|
pauseOverlay.Hide();
|
||||||
sourceClock.Start();
|
sourceClock.Start();
|
||||||
IsPaused = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TogglePaused()
|
|
||||||
{
|
|
||||||
IsPaused = !IsPaused;
|
|
||||||
if (IsPaused) Pause(); else Resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
@ -243,11 +247,11 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
var newPlayer = new Player();
|
var newPlayer = new Player();
|
||||||
|
|
||||||
|
ValidForResume = false;
|
||||||
|
|
||||||
LoadComponentAsync(newPlayer, delegate
|
LoadComponentAsync(newPlayer, delegate
|
||||||
{
|
{
|
||||||
newPlayer.RestartCount = RestartCount + 1;
|
newPlayer.RestartCount = RestartCount + 1;
|
||||||
ValidForResume = false;
|
|
||||||
|
|
||||||
if (!Push(newPlayer))
|
if (!Push(newPlayer))
|
||||||
{
|
{
|
||||||
// Error(?)
|
// Error(?)
|
||||||
@ -263,10 +267,11 @@ namespace osu.Game.Screens.Play
|
|||||||
if (scoreProcessor.HasFailed || onCompletionEvent != null)
|
if (scoreProcessor.HasFailed || onCompletionEvent != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ValidForResume = false;
|
||||||
|
|
||||||
Delay(1000);
|
Delay(1000);
|
||||||
onCompletionEvent = Schedule(delegate
|
onCompletionEvent = Schedule(delegate
|
||||||
{
|
{
|
||||||
ValidForResume = false;
|
|
||||||
Push(new Results
|
Push(new Results
|
||||||
{
|
{
|
||||||
Score = scoreProcessor.CreateScore()
|
Score = scoreProcessor.CreateScore()
|
||||||
@ -278,8 +283,6 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
sourceClock.Stop();
|
sourceClock.Stop();
|
||||||
|
|
||||||
Delay(500);
|
|
||||||
|
|
||||||
HasFailed = true;
|
HasFailed = true;
|
||||||
failOverlay.Retries = RestartCount;
|
failOverlay.Retries = RestartCount;
|
||||||
failOverlay.Show();
|
failOverlay.Show();
|
||||||
@ -324,12 +327,15 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected override bool OnExiting(Screen next)
|
protected override bool OnExiting(Screen next)
|
||||||
{
|
{
|
||||||
|
if (HasFailed || !ValidForResume)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (pauseOverlay != null && !HitRenderer.HasReplayLoaded)
|
if (pauseOverlay != null && !HitRenderer.HasReplayLoaded)
|
||||||
{
|
{
|
||||||
//pause screen override logic.
|
//pause screen override logic.
|
||||||
if (pauseOverlay?.State == Visibility.Hidden && !canPause) return true;
|
if (pauseOverlay?.State == Visibility.Hidden && !canPause) return true;
|
||||||
|
|
||||||
if (!IsPaused && sourceClock.IsRunning) // For if the user presses escape quickly when entering the map
|
if (!IsPaused) // For if the user presses escape quickly when entering the map
|
||||||
{
|
{
|
||||||
Pause();
|
Pause();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user