mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 04:13:11 +08:00
Merge pull request #23647 from peppy/pause-screen-progress
Show current progress on pause screen
This commit is contained in:
commit
574ecf939c
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Effects;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -120,7 +121,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
State.ValueChanged += _ => InternalButtons.Deselect();
|
State.ValueChanged += _ => InternalButtons.Deselect();
|
||||||
|
|
||||||
updateRetryCount();
|
updateInfoText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int retries;
|
private int retries;
|
||||||
@ -135,11 +136,16 @@ namespace osu.Game.Screens.Play
|
|||||||
retries = value;
|
retries = value;
|
||||||
|
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
updateRetryCount();
|
updateInfoText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn(TRANSITION_DURATION, Easing.In);
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
this.FadeIn(TRANSITION_DURATION, Easing.In);
|
||||||
|
updateInfoText();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void PopOut() => this.FadeOut(TRANSITION_DURATION, Easing.In);
|
protected override void PopOut() => this.FadeOut(TRANSITION_DURATION, Easing.In);
|
||||||
|
|
||||||
// Don't let mouse down events through the overlay or people can click circles while paused.
|
// Don't let mouse down events through the overlay or people can click circles while paused.
|
||||||
@ -194,14 +200,39 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRetryCount()
|
[Resolved]
|
||||||
{
|
private IGameplayClock? gameplayClock { get; set; }
|
||||||
// "You've retried 1,065 times in this session"
|
|
||||||
// "You've retried 1 time in this session"
|
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private GameplayState? gameplayState { get; set; }
|
||||||
|
|
||||||
|
private void updateInfoText()
|
||||||
|
{
|
||||||
playInfoText.Clear();
|
playInfoText.Clear();
|
||||||
playInfoText.AddText("Retry count: ");
|
playInfoText.AddText("Retry count: ");
|
||||||
playInfoText.AddText(retries.ToString(), cp => cp.Font = cp.Font.With(weight: FontWeight.Bold));
|
playInfoText.AddText(retries.ToString(), cp => cp.Font = cp.Font.With(weight: FontWeight.Bold));
|
||||||
|
|
||||||
|
if (getSongProgress() is int progress)
|
||||||
|
{
|
||||||
|
playInfoText.NewLine();
|
||||||
|
playInfoText.AddText("Song progress: ");
|
||||||
|
playInfoText.AddText($"{progress}%", cp => cp.Font = cp.Font.With(weight: FontWeight.Bold));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int? getSongProgress()
|
||||||
|
{
|
||||||
|
if (gameplayClock == null || gameplayState == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
(double firstHitTime, double lastHitTime) = gameplayState.Beatmap.CalculatePlayableBounds();
|
||||||
|
|
||||||
|
double playableLength = (lastHitTime - firstHitTime);
|
||||||
|
|
||||||
|
if (playableLength == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return (int)Math.Clamp(((gameplayClock.CurrentTime - firstHitTime) / playableLength) * 100, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private partial class Button : DialogButton
|
private partial class Button : DialogButton
|
||||||
|
@ -145,12 +145,12 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
double time = gameplayClock?.CurrentTime ?? Time.Current;
|
double time = gameplayClock?.CurrentTime ?? Time.Current;
|
||||||
|
|
||||||
double songCurrentTime = time - startTime;
|
double songCurrentTime = time - startTime;
|
||||||
int currentPercent = Math.Max(0, Math.Min(100, (int)(songCurrentTime / songLength * 100)));
|
int currentPercent = songLength == 0 ? 0 : Math.Max(0, Math.Min(100, (int)(songCurrentTime / songLength * 100)));
|
||||||
int currentSecond = (int)Math.Floor(songCurrentTime / 1000.0);
|
int currentSecond = (int)Math.Floor(songCurrentTime / 1000.0);
|
||||||
|
|
||||||
if (currentPercent != previousPercent)
|
if (currentPercent != previousPercent)
|
||||||
{
|
{
|
||||||
progress.Text = currentPercent + @"%";
|
progress.Text = $@"{currentPercent}%";
|
||||||
previousPercent = currentPercent;
|
previousPercent = currentPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user