1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:47:46 +08:00

Merge pull request #28050 from peppy/delay-resume-visibility

Tweak resume overlay to allow better visibility of hit objects underneath
This commit is contained in:
Bartłomiej Dach 2024-05-01 15:49:31 +02:00 committed by GitHub
commit fe9e6168fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 17 deletions

View File

@ -529,7 +529,7 @@ namespace osu.Game.Rulesets.UI
public ResumeOverlay ResumeOverlay { get; protected set; } public ResumeOverlay ResumeOverlay { get; protected set; }
/// <summary> /// <summary>
/// Whether the <see cref="ResumeOverlay"/> should be used to return the user's cursor position to its previous location after a pause. /// Whether a <see cref="ResumeOverlay"/> should be displayed on resuming after a pause.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Defaults to <c>true</c>. /// Defaults to <c>true</c>.

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Threading;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays; using osu.Game.Overlays;
@ -24,8 +23,9 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public partial class DelayedResumeOverlay : ResumeOverlay public partial class DelayedResumeOverlay : ResumeOverlay
{ {
// todo: this shouldn't define its own colour provider, but nothing in Player screen does, so let's do that for now. // todo: this shouldn't define its own colour provider, but nothing in DrawableRuleset guarantees this, so let's do it locally for now.
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); // (of note, Player does cache one but any test which uses a DrawableRuleset without Player will fail without this).
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
private const float outer_size = 200; private const float outer_size = 200;
private const float inner_size = 150; private const float inner_size = 150;
@ -34,9 +34,10 @@ namespace osu.Game.Screens.Play
private const double countdown_time = 2000; private const double countdown_time = 2000;
private const int total_count = 3;
protected override LocalisableString Message => string.Empty; protected override LocalisableString Message => string.Empty;
private ScheduledDelegate? scheduledResume;
private int? countdownCount; private int? countdownCount;
private double countdownStartTime; private double countdownStartTime;
private bool countdownComplete; private bool countdownComplete;
@ -120,21 +121,17 @@ namespace osu.Game.Screens.Play
innerContent.FadeIn().ScaleTo(Vector2.Zero).Then().ScaleTo(Vector2.One, 400, Easing.OutElasticHalf); innerContent.FadeIn().ScaleTo(Vector2.Zero).Then().ScaleTo(Vector2.One, 400, Easing.OutElasticHalf);
countdownComponents.FadeOut().Delay(50).FadeTo(1, 100); countdownComponents.FadeOut().Delay(50).FadeTo(1, 100);
countdownProgress.Progress = 0;
// Reset states for various components. // Reset states for various components.
countdownBackground.FadeIn(); countdownBackground.FadeIn();
countdownText.FadeIn(); countdownText.FadeIn();
countdownText.Text = string.Empty;
countdownProgress.FadeIn().ScaleTo(1); countdownProgress.FadeIn().ScaleTo(1);
countdownComplete = false; countdownComplete = false;
countdownCount = null; countdownCount = null;
countdownStartTime = Time.Current; countdownStartTime = Time.Current + 200;
scheduledResume?.Cancel();
scheduledResume = Scheduler.AddDelayed(() =>
{
countdownComplete = true;
Resume();
}, countdown_time);
} }
protected override void PopOut() protected override void PopOut()
@ -152,8 +149,6 @@ namespace osu.Game.Screens.Play
} }
else else
countdownProgress.FadeOut(); countdownProgress.FadeOut();
scheduledResume?.Cancel();
} }
protected override void Update() protected override void Update()
@ -164,12 +159,17 @@ namespace osu.Game.Screens.Play
private void updateCountdown() private void updateCountdown()
{ {
double amountTimePassed = Math.Min(countdown_time, Time.Current - countdownStartTime) / countdown_time; if (State.Value == Visibility.Hidden || countdownComplete || Time.Current < countdownStartTime)
int newCount = 3 - (int)Math.Floor(amountTimePassed * 3); return;
double amountTimePassed = Math.Clamp((Time.Current - countdownStartTime) / countdown_time, 0, countdown_time);
int newCount = Math.Clamp(total_count - (int)Math.Floor(amountTimePassed * total_count), 0, total_count);
countdownProgress.Progress = amountTimePassed; countdownProgress.Progress = amountTimePassed;
countdownProgress.InnerRadius = progress_stroke_width / progress_size / countdownProgress.Scale.X; countdownProgress.InnerRadius = progress_stroke_width / progress_size / countdownProgress.Scale.X;
Alpha = 0.2f + 0.8f * newCount / total_count;
if (countdownCount != newCount) if (countdownCount != newCount)
{ {
if (newCount > 0) if (newCount > 0)
@ -191,6 +191,12 @@ namespace osu.Game.Screens.Play
} }
countdownCount = newCount; countdownCount = newCount;
if (countdownCount == 0)
{
countdownComplete = true;
Resume();
}
} }
} }
} }