mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
Use alternative method of releasing user-pressed keys when activating autoplay
This commit is contained in:
parent
e73faaefd2
commit
0ab13e4486
@ -20,6 +20,7 @@ using osu.Game.Input.Handlers;
|
|||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Play.HUD.ClicksPerSecond;
|
using osu.Game.Screens.Play.HUD.ClicksPerSecond;
|
||||||
|
using osuTK;
|
||||||
using static osu.Game.Input.Handlers.ReplayInputHandler;
|
using static osu.Game.Input.Handlers.ReplayInputHandler;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
@ -113,17 +114,12 @@ namespace osu.Game.Rulesets.UI
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (replayInputHandler != null)
|
if (replayInputHandler != null)
|
||||||
{
|
|
||||||
RemoveHandler(replayInputHandler);
|
RemoveHandler(replayInputHandler);
|
||||||
// ensures that all replay keys are released, and that the last replay state is correctly cleared
|
|
||||||
new ReplayStateReset().Apply(CurrentState, this);
|
// ensures that all replay keys are released, that the last replay state is correctly cleared,
|
||||||
}
|
// and that all user-pressed keys are released, so that the replay handler may trigger them itself
|
||||||
else
|
// setting `UseParentInput` will only sync releases (https://github.com/ppy/osu-framework/blob/17d65f476d51cc5f2aaea818534f8fbac47e5fe6/osu.Framework/Input/PassThroughInputManager.cs#L179-L182)
|
||||||
{
|
new ReplayStateReset().Apply(CurrentState, this);
|
||||||
// ensures that all user-pressed keys are released, so that the replay handler may trigger them itself
|
|
||||||
// setting `UseParentInput` will only sync releases (https://github.com/ppy/osu-framework/blob/45cd7c7c702c081334fce41e7771b9dc6481b28d/osu.Framework/Input/PassThroughInputManager.cs#L179-L182)
|
|
||||||
SyncInputState(CreateInitialState());
|
|
||||||
}
|
|
||||||
|
|
||||||
replayInputHandler = value;
|
replayInputHandler = value;
|
||||||
UseParentInput = replayInputHandler == null;
|
UseParentInput = replayInputHandler == null;
|
||||||
@ -243,9 +239,16 @@ namespace osu.Game.Rulesets.UI
|
|||||||
if (!(state is RulesetInputManagerInputState<T> inputState))
|
if (!(state is RulesetInputManagerInputState<T> inputState))
|
||||||
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
|
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
|
||||||
|
|
||||||
inputState.LastReplayState = null;
|
new MouseButtonInput([], state.Mouse.Buttons).Apply(state, handler);
|
||||||
|
new KeyboardKeyInput([], state.Keyboard.Keys).Apply(state, handler);
|
||||||
|
new TouchInput(Enum.GetValues<TouchSource>().Select(s => new Touch(s, Vector2.Zero)), false).Apply(state, handler);
|
||||||
|
new JoystickButtonInput([], state.Joystick.Buttons).Apply(state, handler);
|
||||||
|
new MidiKeyInput(new MidiState(), state.Midi).Apply(state, handler);
|
||||||
|
new TabletPenButtonInput([], state.Tablet.PenButtons).Apply(state, handler);
|
||||||
|
new TabletAuxiliaryButtonInput([], state.Tablet.AuxiliaryButtons).Apply(state, handler);
|
||||||
|
|
||||||
handler.HandleInputStateChange(new ReplayStateChangeEvent<T>(state, this, inputState.LastReplayState?.PressedActions.ToArray() ?? [], []));
|
handler.HandleInputStateChange(new ReplayStateChangeEvent<T>(state, this, inputState.LastReplayState?.PressedActions.ToArray() ?? [], []));
|
||||||
|
inputState.LastReplayState = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user