Merge branch 'master' into patch-3

This commit is contained in:
Lucky56
2021-06-22 13:12:54 +02:00
committed by GitHub
13 changed files with 210 additions and 32 deletions

View File

@ -1,5 +1,9 @@
package;
import openfl.events.Event;
import haxe.EnumTools;
import openfl.ui.Keyboard;
import openfl.events.KeyboardEvent;
import Replay.Ana;
import Replay.Analysis;
import webm.WebmPlayer;
@ -254,7 +258,7 @@ class PlayState extends MusicBeatState
PlayStateChangeables.safeFrames = FlxG.save.data.frames;
PlayStateChangeables.scrollSpeed = FlxG.save.data.scrollSpeed;
PlayStateChangeables.botPlay = FlxG.save.data.botplay;
PlayStateChangeables.Optimize = FlxG.save.data.optimize;
// pre lowercasing the song name (create)
var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase();
@ -267,6 +271,8 @@ class PlayState extends MusicBeatState
#if windows
executeModchart = FileSystem.exists(Paths.lua(songLowercase + "/modchart"));
if (executeModchart)
PlayStateChangeables.Optimize = false;
#end
#if !cpp
executeModchart = false; // FORCE disable for non cpp targets
@ -373,6 +379,9 @@ class PlayState extends MusicBeatState
}
} else {stageCheck = SONG.stage;}
if (!PlayStateChangeables.Optimize)
{
switch(stageCheck)
{
case 'halloween':
@ -752,7 +761,7 @@ class PlayState extends MusicBeatState
add(stageCurtains);
}
}
}
//defaults if no gf was found in chart
var gfCheck:String = 'gf';
@ -777,7 +786,7 @@ class PlayState extends MusicBeatState
default:
curGf = 'gf';
}
gf = new Character(400, 130, curGf);
gf.scrollFactor.set(0.95, 0.95);
@ -866,14 +875,19 @@ class PlayState extends MusicBeatState
gf.y += 300;
}
add(gf);
if (!PlayStateChangeables.Optimize)
{
add(gf);
// Shitty layering but whatev it works LOL
if (curStage == 'limo')
add(limo);
add(dad);
add(boyfriend);
}
// Shitty layering but whatev it works LOL
if (curStage == 'limo')
add(limo);
add(dad);
add(boyfriend);
if (loadRep)
{
FlxG.watch.addQuick('rep rpesses',repPresses);
@ -1109,6 +1123,8 @@ class PlayState extends MusicBeatState
if (!loadRep)
rep = new Replay("na");
FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN,handleInput);
super.create();
}
@ -1337,6 +1353,49 @@ class PlayState extends MusicBeatState
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;
function startSong():Void
@ -1489,6 +1548,10 @@ class PlayState extends MusicBeatState
oldNote = null;
var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote);
if (!gottaHitNote && PlayStateChangeables.Optimize)
continue;
swagNote.sustainLength = songNotes[2];
swagNote.scrollFactor.set(0, 0);
@ -1549,6 +1612,9 @@ class PlayState extends MusicBeatState
//defaults if no noteStyle was found in chart
var noteTypeCheck:String = 'normal';
if (PlayStateChangeables.Optimize && player == 0)
continue;
if (SONG.noteStyle == null) {
switch(storyWeek) {case 6: noteTypeCheck = 'pixel';}
} else {noteTypeCheck = SONG.noteStyle;}
@ -1683,6 +1749,9 @@ class PlayState extends MusicBeatState
babyArrow.x += 50;
babyArrow.x += ((FlxG.width / 2) * player);
if (PlayStateChangeables.Optimize)
babyArrow.x -= 275;
cpuStrums.forEach(function(spr:FlxSprite)
{
spr.centerOffsets(); //CPU arrows start out slightly off-center
@ -1880,7 +1949,7 @@ class PlayState extends MusicBeatState
switch (curStage)
{
case 'philly':
if (trainMoving)
if (trainMoving && !PlayStateChangeables.Optimize)
{
trainFrameTiming += elapsed;
@ -1931,6 +2000,7 @@ class PlayState extends MusicBeatState
DiscordClient.changePresence("Chart Editor", null, null, true);
#end
FlxG.switchState(new ChartingState());
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN,handleInput);
#if windows
if (luaModchart != null)
{
@ -1982,6 +2052,7 @@ class PlayState extends MusicBeatState
}
FlxG.switchState(new AnimationDebug(SONG.player2));
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN,handleInput);
#if windows
if (luaModchart != null)
{
@ -1994,6 +2065,7 @@ class PlayState extends MusicBeatState
if (FlxG.keys.justPressed.ZERO)
{
FlxG.switchState(new AnimationDebug(SONG.player1));
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN,handleInput);
#if windows
if (luaModchart != null)
{
@ -2547,6 +2619,7 @@ class PlayState extends MusicBeatState
function endSong():Void
{
FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN,handleInput);
if (useVideo)
{
GlobalVideo.get().stop();
@ -3005,6 +3078,8 @@ class PlayState extends MusicBeatState
var rightHold: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
{
// control arrays, order L D R U
@ -3029,7 +3104,6 @@ class PlayState extends MusicBeatState
if (controls.RIGHT_P){luaModchart.executeState('keyPressed',["right"]);};
};
#end
// Prevent player input if botplay is on
if(PlayStateChangeables.botPlay)
@ -3041,9 +3115,9 @@ class PlayState extends MusicBeatState
var anas:Array<Ana> = [null,null,null,null];
for (i in 0...pressArray.length)
/*for (i in 0...pressArray.length)
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
if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
@ -3056,7 +3130,7 @@ class PlayState extends MusicBeatState
}
// PRESSES, check for note hits
if (pressArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
/*if (pressArray.contains(true) && generatedMusic)
{
boyfriend.holdTimer = 0;
@ -3071,13 +3145,36 @@ class PlayState extends MusicBeatState
{
if (!directionsAccounted[daNote.noteData])
{
directionsAccounted[daNote.noteData] = true;
possibleNotes.push(daNote);
directionList.push(daNote.noteData);
if (directionList.contains(daNote.noteData))
{
directionsAccounted[daNote.noteData] = true;
for (coolNote in possibleNotes)
{
if (coolNote.noteData == daNote.noteData && Math.abs(daNote.strumTime - coolNote.strumTime) < 10)
{ // if it's the same note twice at < 10ms distance, just delete it
// EXCEPT u cant delete it in this loop cuz it fucks with the collection lol
dumbNotes.push(daNote);
break;
}
else if (coolNote.noteData == daNote.noteData && daNote.strumTime < coolNote.strumTime)
{ // if daNote is earlier than existing note (coolNote), replace
possibleNotes.remove(coolNote);
possibleNotes.push(daNote);
break;
}
}
}
else
{
possibleNotes.push(daNote);
directionList.push(daNote.noteData);
}
}
}
});
trace('notes that can be hit: ' + possibleNotes.length);
for (note in dumbNotes)
{
FlxG.log.add("killing dumb ass note at " + note.strumTime);
@ -3122,12 +3219,12 @@ class PlayState extends MusicBeatState
noteMiss(shit, null);
}
}
}*/
if (!loadRep)
/*if (!loadRep)
for (i in anas)
if (i != null)
replayAna.anaArray.push(i); // put em all there
replayAna.anaArray.push(i); // put em all there*/
notes.forEachAlive(function(daNote:Note)
{
@ -3508,7 +3605,6 @@ class PlayState extends MusicBeatState
var array = [note.strumTime,note.sustainLength,note.noteData,noteDiff];
if (note.isSustainNote)
array[1] = -1;
trace('pushing ' + array[0]);
saveNotes.push(array);
saveJudge.push(note.rating);
}