1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Add a sane key up delay to relax mod

This commit is contained in:
Dean Herbert 2020-02-14 17:13:50 +09:00
parent 4ce687d608
commit 61a7f04efb
2 changed files with 30 additions and 22 deletions

View File

@ -9,6 +9,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using static osu.Game.Input.Handlers.ReplayInputHandler; using static osu.Game.Input.Handlers.ReplayInputHandler;
@ -24,11 +25,14 @@ namespace osu.Game.Rulesets.Osu.Mods
/// </summary> /// </summary>
private const float relax_leniency = 3; private const float relax_leniency = 3;
private bool wasHit; private bool isDownState;
private bool wasLeft; private bool wasLeft;
private OsuInputManager osuInputManager; private OsuInputManager osuInputManager;
private ReplayState<OsuAction> state;
private double lastStateChangeTime;
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset) public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{ {
// grab the input manager for future use. // grab the input manager for future use.
@ -75,11 +79,14 @@ namespace osu.Game.Rulesets.Osu.Mods
if (requiresHit) if (requiresHit)
{ {
addAction(false); changeState(false);
addAction(true); changeState(true);
} }
addAction(requiresHold); if (requiresHold)
changeState(true);
else if (isDownState && time - lastStateChangeTime > AutoGenerator.KEY_UP_DELAY)
changeState(false);
void handleHitCircle(DrawableHitCircle circle) void handleHitCircle(DrawableHitCircle circle)
{ {
@ -89,27 +96,28 @@ namespace osu.Game.Rulesets.Osu.Mods
Debug.Assert(circle.HitObject.HitWindows != null); Debug.Assert(circle.HitObject.HitWindows != null);
requiresHit |= circle.HitObject.HitWindows.CanBeHit(time - circle.HitObject.StartTime); requiresHit |= circle.HitObject.HitWindows.CanBeHit(time - circle.HitObject.StartTime);
} }
}
private void addAction(bool hitting) void changeState(bool down)
{ {
if (wasHit == hitting) if (isDownState == down)
return; return;
wasHit = hitting; isDownState = down;
lastStateChangeTime = time;
var state = new ReplayState<OsuAction> state = new ReplayState<OsuAction>
{ {
PressedActions = new List<OsuAction>() PressedActions = new List<OsuAction>()
}; };
if (hitting) if (down)
{ {
state.PressedActions.Add(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton); state.PressedActions.Add(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton);
wasLeft = !wasLeft; wasLeft = !wasLeft;
} }
state.Apply(osuInputManager.CurrentState, osuInputManager); state?.Apply(osuInputManager.CurrentState, osuInputManager);
}
} }
} }
} }

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Replays
#region Constants #region Constants
// Shared amongst all modes // Shared amongst all modes
protected const double KEY_UP_DELAY = 50; public const double KEY_UP_DELAY = 50;
#endregion #endregion