optimized the FUCK out of input
This commit is contained in:
parent
4fca4f3c6d
commit
7932341de1
@ -1,5 +1,9 @@
|
|||||||
package;
|
package;
|
||||||
|
|
||||||
|
import openfl.events.Event;
|
||||||
|
import haxe.EnumTools;
|
||||||
|
import openfl.ui.Keyboard;
|
||||||
|
import openfl.events.KeyboardEvent;
|
||||||
import Replay.Ana;
|
import Replay.Ana;
|
||||||
import Replay.Analysis;
|
import Replay.Analysis;
|
||||||
import webm.WebmPlayer;
|
import webm.WebmPlayer;
|
||||||
@ -1109,6 +1113,8 @@ class PlayState extends MusicBeatState
|
|||||||
if (!loadRep)
|
if (!loadRep)
|
||||||
rep = new Replay("na");
|
rep = new Replay("na");
|
||||||
|
|
||||||
|
FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN,handleInput);
|
||||||
|
|
||||||
super.create();
|
super.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1337,6 +1343,49 @@ class PlayState extends MusicBeatState
|
|||||||
var songTime:Float = 0;
|
var songTime:Float = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private function handleInput(evt:KeyboardEvent):Void { // this actually handles press inputs
|
||||||
|
|
||||||
|
if (PlayStateChangeables.botPlay || loadRep || paused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var key = String.fromCharCode(evt.charCode);
|
||||||
|
|
||||||
|
var binds:Array<String> = [FlxG.save.data.leftBind,FlxG.save.data.downBind, FlxG.save.data.upBind, FlxG.save.data.rightBind];
|
||||||
|
|
||||||
|
var data = -1;
|
||||||
|
|
||||||
|
for (i in 0...binds.length)
|
||||||
|
if (binds[i].toLowerCase() == key)
|
||||||
|
data = i;
|
||||||
|
|
||||||
|
if (data == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ana = new Ana(Conductor.songPosition, null, false, "miss", data);
|
||||||
|
|
||||||
|
var dataNotes = [];
|
||||||
|
notes.forEachAlive(function(daNote:Note)
|
||||||
|
{
|
||||||
|
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit && daNote.noteData == data)
|
||||||
|
dataNotes.push(daNote);
|
||||||
|
}); // Collect notes that can be hit
|
||||||
|
|
||||||
|
|
||||||
|
dataNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); // sort by the earliest note
|
||||||
|
|
||||||
|
if (dataNotes.length != 0)
|
||||||
|
{
|
||||||
|
var coolNote = dataNotes[0];
|
||||||
|
|
||||||
|
goodNoteHit(coolNote);
|
||||||
|
var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition);
|
||||||
|
ana.hit = true;
|
||||||
|
ana.hitJudge = Ratings.CalculateRating(noteDiff, Math.floor((PlayStateChangeables.safeFrames / 60) * 1000));
|
||||||
|
ana.nearestNote = [coolNote.strumTime,coolNote.noteData,coolNote.sustainLength];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var songStarted = false;
|
var songStarted = false;
|
||||||
|
|
||||||
function startSong():Void
|
function startSong():Void
|
||||||
@ -1931,6 +1980,7 @@ class PlayState extends MusicBeatState
|
|||||||
DiscordClient.changePresence("Chart Editor", null, null, true);
|
DiscordClient.changePresence("Chart Editor", null, null, true);
|
||||||
#end
|
#end
|
||||||
FlxG.switchState(new ChartingState());
|
FlxG.switchState(new ChartingState());
|
||||||
|
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN,handleInput);
|
||||||
#if windows
|
#if windows
|
||||||
if (luaModchart != null)
|
if (luaModchart != null)
|
||||||
{
|
{
|
||||||
@ -1982,6 +2032,7 @@ class PlayState extends MusicBeatState
|
|||||||
}
|
}
|
||||||
|
|
||||||
FlxG.switchState(new AnimationDebug(SONG.player2));
|
FlxG.switchState(new AnimationDebug(SONG.player2));
|
||||||
|
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN,handleInput);
|
||||||
#if windows
|
#if windows
|
||||||
if (luaModchart != null)
|
if (luaModchart != null)
|
||||||
{
|
{
|
||||||
@ -1994,6 +2045,7 @@ class PlayState extends MusicBeatState
|
|||||||
if (FlxG.keys.justPressed.ZERO)
|
if (FlxG.keys.justPressed.ZERO)
|
||||||
{
|
{
|
||||||
FlxG.switchState(new AnimationDebug(SONG.player1));
|
FlxG.switchState(new AnimationDebug(SONG.player1));
|
||||||
|
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN,handleInput);
|
||||||
#if windows
|
#if windows
|
||||||
if (luaModchart != null)
|
if (luaModchart != null)
|
||||||
{
|
{
|
||||||
@ -2547,6 +2599,7 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
function endSong():Void
|
function endSong():Void
|
||||||
{
|
{
|
||||||
|
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN,handleInput);
|
||||||
if (useVideo)
|
if (useVideo)
|
||||||
{
|
{
|
||||||
GlobalVideo.get().stop();
|
GlobalVideo.get().stop();
|
||||||
@ -3009,6 +3062,8 @@ class PlayState extends MusicBeatState
|
|||||||
var rightHold:Bool = false;
|
var rightHold:Bool = false;
|
||||||
var leftHold:Bool = false;
|
var leftHold:Bool = false;
|
||||||
|
|
||||||
|
// THIS FUNCTION JUST FUCKS WIT HELD NOTES AND BOTPLAY/REPLAY
|
||||||
|
|
||||||
private function keyShit():Void // I've invested in emma stocks
|
private function keyShit():Void // I've invested in emma stocks
|
||||||
{
|
{
|
||||||
// control arrays, order L D R U
|
// control arrays, order L D R U
|
||||||
@ -3033,7 +3088,6 @@ class PlayState extends MusicBeatState
|
|||||||
if (controls.RIGHT_P){luaModchart.executeState('keyPressed',["right"]);};
|
if (controls.RIGHT_P){luaModchart.executeState('keyPressed',["right"]);};
|
||||||
};
|
};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
// Prevent player input if botplay is on
|
// Prevent player input if botplay is on
|
||||||
if(PlayStateChangeables.botPlay)
|
if(PlayStateChangeables.botPlay)
|
||||||
@ -3045,9 +3099,9 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
var anas:Array<Ana> = [null,null,null,null];
|
var anas:Array<Ana> = [null,null,null,null];
|
||||||
|
|
||||||
for (i in 0...pressArray.length)
|
/*for (i in 0...pressArray.length)
|
||||||
if (pressArray[i])
|
if (pressArray[i])
|
||||||
anas[i] = new Ana(Conductor.songPosition, null, false, "miss", i);
|
anas[i] = new Ana(Conductor.songPosition, null, false, "miss", i);*/
|
||||||
|
|
||||||
// HOLDS, check for sustain notes
|
// HOLDS, check for sustain notes
|
||||||
if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
|
if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
|
||||||
@ -3060,7 +3114,7 @@ class PlayState extends MusicBeatState
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PRESSES, check for note hits
|
// PRESSES, check for note hits
|
||||||
if (pressArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
|
/*if (pressArray.contains(true) && generatedMusic)
|
||||||
{
|
{
|
||||||
boyfriend.holdTimer = 0;
|
boyfriend.holdTimer = 0;
|
||||||
|
|
||||||
@ -3149,12 +3203,12 @@ class PlayState extends MusicBeatState
|
|||||||
noteMiss(shit, null);
|
noteMiss(shit, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (!loadRep)
|
/*if (!loadRep)
|
||||||
for (i in anas)
|
for (i in anas)
|
||||||
if (i != null)
|
if (i != null)
|
||||||
replayAna.anaArray.push(i); // put em all there
|
replayAna.anaArray.push(i); // put em all there*/
|
||||||
|
|
||||||
notes.forEachAlive(function(daNote:Note)
|
notes.forEachAlive(function(daNote:Note)
|
||||||
{
|
{
|
||||||
@ -3535,7 +3589,6 @@ class PlayState extends MusicBeatState
|
|||||||
var array = [note.strumTime,note.sustainLength,note.noteData,noteDiff];
|
var array = [note.strumTime,note.sustainLength,note.noteData,noteDiff];
|
||||||
if (note.isSustainNote)
|
if (note.isSustainNote)
|
||||||
array[1] = -1;
|
array[1] = -1;
|
||||||
trace('pushing ' + array[0]);
|
|
||||||
saveNotes.push(array);
|
saveNotes.push(array);
|
||||||
saveJudge.push(note.rating);
|
saveJudge.push(note.rating);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user