1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:43:00 +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.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI;
using static osu.Game.Input.Handlers.ReplayInputHandler;
@ -24,11 +25,14 @@ namespace osu.Game.Rulesets.Osu.Mods
/// </summary>
private const float relax_leniency = 3;
private bool wasHit;
private bool isDownState;
private bool wasLeft;
private OsuInputManager osuInputManager;
private ReplayState<OsuAction> state;
private double lastStateChangeTime;
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
// grab the input manager for future use.
@ -75,11 +79,14 @@ namespace osu.Game.Rulesets.Osu.Mods
if (requiresHit)
{
addAction(false);
addAction(true);
changeState(false);
changeState(true);
}
addAction(requiresHold);
if (requiresHold)
changeState(true);
else if (isDownState && time - lastStateChangeTime > AutoGenerator.KEY_UP_DELAY)
changeState(false);
void handleHitCircle(DrawableHitCircle circle)
{
@ -89,27 +96,28 @@ namespace osu.Game.Rulesets.Osu.Mods
Debug.Assert(circle.HitObject.HitWindows != null);
requiresHit |= circle.HitObject.HitWindows.CanBeHit(time - circle.HitObject.StartTime);
}
}
private void addAction(bool hitting)
{
if (wasHit == hitting)
return;
wasHit = hitting;
var state = new ReplayState<OsuAction>
void changeState(bool down)
{
PressedActions = new List<OsuAction>()
};
if (isDownState == down)
return;
if (hitting)
{
state.PressedActions.Add(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton);
wasLeft = !wasLeft;
isDownState = down;
lastStateChangeTime = time;
state = new ReplayState<OsuAction>
{
PressedActions = new List<OsuAction>()
};
if (down)
{
state.PressedActions.Add(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton);
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
// Shared amongst all modes
protected const double KEY_UP_DELAY = 50;
public const double KEY_UP_DELAY = 50;
#endregion