1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-02 05:30:17 +08:00

Rewrite the fix to look less hacky and direct to the point

This commit is contained in:
Salman Ahmed
2024-08-19 15:43:57 +09:00
Unverified
parent 62dec1cd78
commit 86d0079dcd
+13 -10
View File
@@ -3,6 +3,7 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
@@ -36,9 +37,11 @@ namespace osu.Game.Rulesets.Osu.UI
{
OsuResumeOverlayInputBlocker? inputBlocker = null;
if (drawableRuleset != null)
var drawableOsuRuleset = (DrawableOsuRuleset?)drawableRuleset;
if (drawableOsuRuleset != null)
{
var osuPlayfield = (OsuPlayfield)drawableRuleset.Playfield;
var osuPlayfield = drawableOsuRuleset.Playfield;
osuPlayfield.AttachResumeOverlayInputBlocker(inputBlocker = new OsuResumeOverlayInputBlocker());
}
@@ -46,13 +49,14 @@ namespace osu.Game.Rulesets.Osu.UI
{
Child = clickToResumeCursor = new OsuClickToResumeCursor
{
ResumeRequested = () =>
ResumeRequested = action =>
{
// since the user had to press a button to tap the resume cursor,
// block that press event from potentially reaching a hit circle that's behind the cursor.
// we cannot do this from OsuClickToResumeCursor directly since we're in a different input manager tree than the gameplay one,
// so we rely on a dedicated input blocking component that's implanted in there to do that for us.
if (inputBlocker != null)
// note this only matters when the user didn't pause while they were holding the same key that they are resuming with.
if (inputBlocker != null && !drawableOsuRuleset.AsNonNull().KeyBindingInputManager.PressedActions.Contains(action))
inputBlocker.BlockNextPress = true;
Resume();
@@ -95,7 +99,7 @@ namespace osu.Game.Rulesets.Osu.UI
{
public override bool HandlePositionalInput => true;
public Action? ResumeRequested;
public Action<OsuAction>? ResumeRequested;
private Container scaleTransitionContainer = null!;
public OsuClickToResumeCursor()
@@ -137,7 +141,7 @@ namespace osu.Game.Rulesets.Osu.UI
return false;
scaleTransitionContainer.ScaleTo(2, TRANSITION_TIME, Easing.OutQuint);
ResumeRequested?.Invoke();
ResumeRequested?.Invoke(e.Action);
return true;
}
@@ -173,14 +177,13 @@ namespace osu.Game.Rulesets.Osu.UI
Depth = float.MinValue;
}
protected override void Update()
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
{
base.Update();
bool block = BlockNextPress;
BlockNextPress = false;
return block;
}
public bool OnPressed(KeyBindingPressEvent<OsuAction> e) => BlockNextPress;
public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
{
}