mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:20:04 +08:00
Merge pull request #27079 from smoogipoo/tcm-resume
Add delayed resume for taiko/catch/mania
This commit is contained in:
commit
0589924dc6
@ -16,6 +16,8 @@ using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
@ -52,5 +54,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
protected override PassThroughInputManager CreateInputManager() => new CatchInputManager(Ruleset.RulesetInfo);
|
||||
|
||||
public override DrawableHitObject<CatchHitObject>? CreateDrawableRepresentation(CatchHitObject h) => null;
|
||||
|
||||
protected override ResumeOverlay CreateResumeOverlay() => new DelayedResumeOverlay { Scale = new Vector2(0.65f) };
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.UI
|
||||
@ -164,6 +165,8 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
protected override ReplayRecorder CreateReplayRecorder(Score score) => new ManiaReplayRecorder(score);
|
||||
|
||||
protected override ResumeOverlay CreateResumeOverlay() => new DelayedResumeOverlay();
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
@ -6,11 +6,11 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Gameplay;
|
||||
using osu.Game.Tests.Visual;
|
||||
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
public partial class TestSceneResumeOverlay : OsuManualInputManagerTestScene
|
||||
{
|
||||
private ManualOsuInputManager osuInputManager = null!;
|
||||
private CursorContainer cursor = null!;
|
||||
private GameplayCursorContainer cursor = null!;
|
||||
private ResumeOverlay resume = null!;
|
||||
|
||||
private bool resumeFired;
|
||||
@ -99,7 +99,17 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
private void loadContent()
|
||||
{
|
||||
Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo) { Children = new Drawable[] { cursor = new CursorContainer(), resume = new OsuResumeOverlay { GameplayCursor = cursor }, } };
|
||||
Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
cursor = new GameplayCursorContainer(),
|
||||
resume = new OsuResumeOverlay
|
||||
{
|
||||
GameplayCursor = cursor
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
resumeFired = false;
|
||||
resume.ResumeAction = () => resumeFired = true;
|
||||
|
@ -39,6 +39,13 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
// Can't display if the cursor is outside the window.
|
||||
if (GameplayCursor.LastFrameState == Visibility.Hidden || !Contains(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre))
|
||||
{
|
||||
Resume();
|
||||
return;
|
||||
}
|
||||
|
||||
base.PopIn();
|
||||
|
||||
GameplayCursor.ActiveCursor.Hide();
|
||||
|
@ -116,5 +116,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new TaikoFramedReplayInputHandler(replay);
|
||||
|
||||
protected override ReplayRecorder CreateReplayRecorder(Score score) => new TaikoReplayRecorder(score);
|
||||
|
||||
protected override ResumeOverlay CreateResumeOverlay() => new DelayedResumeOverlay();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Gameplay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneDelayedResumeOverlay : OsuTestScene
|
||||
{
|
||||
private ResumeOverlay resume = null!;
|
||||
private bool resumeFired;
|
||||
|
||||
[Cached]
|
||||
private GameplayState gameplayState;
|
||||
|
||||
public TestSceneDelayedResumeOverlay()
|
||||
{
|
||||
gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(loadContent);
|
||||
|
||||
[Test]
|
||||
public void TestResume()
|
||||
{
|
||||
AddStep("show", () => resume.Show());
|
||||
AddUntilStep("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
private void loadContent()
|
||||
{
|
||||
Child = resume = new DelayedResumeOverlay();
|
||||
|
||||
resumeFired = false;
|
||||
resume.ResumeAction = () => resumeFired = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -240,7 +240,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
public override void RequestResume(Action continueResume)
|
||||
{
|
||||
if (ResumeOverlay != null && UseResumeOverlay && (Cursor == null || (Cursor.LastFrameState == Visibility.Visible && Contains(Cursor.ActiveCursor.ScreenSpaceDrawQuad.Centre))))
|
||||
if (ResumeOverlay != null && UseResumeOverlay)
|
||||
{
|
||||
ResumeOverlay.GameplayCursor = Cursor;
|
||||
ResumeOverlay.ResumeAction = continueResume;
|
||||
|
196
osu.Game/Screens/Play/DelayedResumeOverlay.cs
Normal file
196
osu.Game/Screens/Play/DelayedResumeOverlay.cs
Normal file
@ -0,0 +1,196 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple <see cref="ResumeOverlay"/> that resumes after a short delay.
|
||||
/// </summary>
|
||||
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.
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||
|
||||
private const float outer_size = 200;
|
||||
private const float inner_size = 150;
|
||||
private const float progress_stroke_width = 7;
|
||||
private const float progress_size = inner_size + progress_stroke_width / 2f;
|
||||
|
||||
private const double countdown_time = 2000;
|
||||
|
||||
protected override LocalisableString Message => string.Empty;
|
||||
|
||||
private ScheduledDelegate? scheduledResume;
|
||||
private int? countdownCount;
|
||||
private double countdownStartTime;
|
||||
private bool countdownComplete;
|
||||
|
||||
private Drawable outerContent = null!;
|
||||
private Container innerContent = null!;
|
||||
|
||||
private Container countdownComponents = null!;
|
||||
private Drawable countdownBackground = null!;
|
||||
private SpriteText countdownText = null!;
|
||||
private CircularProgress countdownProgress = null!;
|
||||
|
||||
private Sample? sampleCountdown;
|
||||
|
||||
public DelayedResumeOverlay()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
Add(outerContent = new Circle
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(outer_size),
|
||||
Colour = colourProvider.Background6,
|
||||
});
|
||||
|
||||
Add(innerContent = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
countdownBackground = new Circle
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(inner_size),
|
||||
Colour = colourProvider.Background4,
|
||||
},
|
||||
countdownComponents = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
countdownProgress = new CircularProgress
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(progress_size),
|
||||
InnerRadius = progress_stroke_width / progress_size,
|
||||
RoundedCaps = true
|
||||
},
|
||||
countdownText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
UseFullGlyphHeight = false,
|
||||
AlwaysPresent = true,
|
||||
Font = OsuFont.Torus.With(size: 70, weight: FontWeight.Light)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
sampleCountdown = audio.Samples.Get(@"Gameplay/resume-countdown");
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.FadeIn();
|
||||
|
||||
// The transition effects.
|
||||
outerContent.FadeIn().ScaleTo(Vector2.Zero).Then().ScaleTo(Vector2.One, 200, Easing.OutQuint);
|
||||
innerContent.FadeIn().ScaleTo(Vector2.Zero).Then().ScaleTo(Vector2.One, 400, Easing.OutElasticHalf);
|
||||
countdownComponents.FadeOut().Delay(50).FadeTo(1, 100);
|
||||
|
||||
// Reset states for various components.
|
||||
countdownBackground.FadeIn();
|
||||
countdownText.FadeIn();
|
||||
countdownProgress.FadeIn().ScaleTo(1);
|
||||
|
||||
countdownComplete = false;
|
||||
countdownCount = null;
|
||||
countdownStartTime = Time.Current;
|
||||
|
||||
scheduledResume?.Cancel();
|
||||
scheduledResume = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
countdownComplete = true;
|
||||
Resume();
|
||||
}, countdown_time);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
this.Delay(300).FadeOut();
|
||||
|
||||
outerContent.FadeOut();
|
||||
countdownBackground.FadeOut();
|
||||
countdownText.FadeOut();
|
||||
|
||||
if (countdownComplete)
|
||||
{
|
||||
countdownProgress.ScaleTo(2f, 300, Easing.OutQuint);
|
||||
countdownProgress.FadeOut(300, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
countdownProgress.FadeOut();
|
||||
|
||||
scheduledResume?.Cancel();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
updateCountdown();
|
||||
}
|
||||
|
||||
private void updateCountdown()
|
||||
{
|
||||
double amountTimePassed = Math.Min(countdown_time, Time.Current - countdownStartTime) / countdown_time;
|
||||
int newCount = 3 - (int)Math.Floor(amountTimePassed * 3);
|
||||
|
||||
countdownProgress.Progress = amountTimePassed;
|
||||
countdownProgress.InnerRadius = progress_stroke_width / progress_size / countdownProgress.Scale.X;
|
||||
|
||||
if (countdownCount != newCount)
|
||||
{
|
||||
if (newCount > 0)
|
||||
{
|
||||
countdownText.Text = Math.Max(1, newCount).ToString();
|
||||
countdownText.ScaleTo(0.25f).Then().ScaleTo(1, 200, Easing.OutQuint);
|
||||
outerContent.Delay(25).Then().ScaleTo(1.05f, 100).Then().ScaleTo(1f, 200, Easing.Out);
|
||||
|
||||
countdownBackground.FlashColour(colourProvider.Background3, 400, Easing.Out);
|
||||
}
|
||||
|
||||
var chan = sampleCountdown?.GetChannel();
|
||||
|
||||
if (chan != null)
|
||||
{
|
||||
chan.Frequency.Value = newCount == 0 ? 0.5f : 1;
|
||||
chan.Play();
|
||||
}
|
||||
}
|
||||
|
||||
countdownCount = newCount;
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -21,7 +22,7 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public abstract partial class ResumeOverlay : VisibilityContainer
|
||||
{
|
||||
public CursorContainer GameplayCursor { get; set; }
|
||||
public GameplayCursorContainer GameplayCursor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The action to be performed to complete resuming.
|
||||
|
@ -36,7 +36,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="11.5.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2024.306.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.309.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.321.0" />
|
||||
<PackageReference Include="Sentry" Version="3.41.3" />
|
||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||
<PackageReference Include="SharpCompress" Version="0.36.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user