This commit is contained in:
Lasercar 2025-04-05 05:23:45 +10:00 committed by GitHub
commit 75a91a5e27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2178,12 +2178,40 @@ class PlayState extends MusicBeatSubState
}
}
var totalPressed:Int;
/**
* Callback executed when one of the note keys is pressed.
*/
function onKeyPress(event:PreciseInputEvent):Void
{
if (isGamePaused) return;
if (isGamePaused)
{
var totalKeys:Int = 0;
var totalPressed:Int = 0;
var totalJustPressed:Int = 0;
for (key in controls.getKeysForAction("note_" + event.noteDirection.toString()))
{
totalKeys++;
if (FlxG.keys.anyPressed([key]))
{
totalPressed++;
}
if (FlxG.keys.anyJustPressed([key]))
{
totalJustPressed++;
}
}
// A hack to ensure this all properly works despite the flixel moment
if (playerStrumline.isKeyHeld(event.noteDirection) && totalPressed == 0) this.totalPressed = 3;
else
this.totalPressed = totalPressed;
// trace('totalKeys ${totalKeys} totalPressed ${totalPressed} totalJustPressed ${totalJustPressed}');
// If one or both of the note's keys is being held down, do nothing
// Otherwise, the player has released and repressed the key, so pop the release input
if ((totalPressed - totalJustPressed) <= 0) return;
inputReleaseQueue.pop();
return;
}
// Do the minimal possible work here.
inputPressQueue.push(event);
@ -2194,8 +2222,32 @@ class PlayState extends MusicBeatSubState
*/
function onKeyRelease(event:PreciseInputEvent):Void
{
if (isGamePaused) return;
if (isGamePaused)
{
var totalKeys:Int = 0;
var totalJustReleased:Int = 0;
// If the key's still being pressed, don't add a release input
for (key in controls.getKeysForAction("note_" + event.noteDirection.toString()))
{
totalKeys++;
if (FlxG.keys.anyPressed([key]))
{
return;
}
if (FlxG.keys.anyJustPressed([key]))
{
return;
}
if (FlxG.keys.anyJustReleased([key]))
{
totalJustReleased++;
}
}
// trace('release totalKeys ${totalKeys} totalPressed ${this.totalPressed} totalJustReleased ${totalJustReleased}');
// Wait a second, a key's still being pressed, return!
if (this.totalPressed >= 3 && totalJustReleased >= 3) return;
}
// Do the minimal possible work here.
inputReleaseQueue.push(event);
}