1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-28 07:56:46 +00:00

JSON load fixins

This commit is contained in:
Cameron Taylor 2022-01-25 13:30:08 -05:00
parent 649fa99999
commit 4f1a413430
2 changed files with 51 additions and 2 deletions

View file

@ -1,5 +1,6 @@
package;
import Note.NoteData;
import Section.SwagSection;
import haxe.Json;
import haxe.format.JsonParser;
@ -129,9 +130,55 @@ class SongLoad
};
}
public static function getDefaultNoteData():NoteData
{
return {
strumTime: 0,
altNote: false,
sustainLength: 0,
noteData: 0
}
}
public static function parseJSONshit(rawJson:String):SwagSong
{
var swagShit:SwagSong = cast Json.parse(rawJson).song;
for (diff in Reflect.fields(Json.parse(rawJson).song.notes))
{
function funnyNoteSetter(noteStuff:Array<SwagSection>)
{
for (sectionIndex => section in noteStuff)
{
for (noteIndex => noteDataArray in section.sectionNotes)
{
trace(noteDataArray);
var arrayDipshit:Array<Dynamic> = cast noteDataArray; // crackhead
noteStuff[sectionIndex].sectionNotes[noteIndex] = cast SongLoad.getDefaultNoteData(); // turn it from an array (because of the cast), back to noteData?
noteStuff[sectionIndex].sectionNotes[noteIndex].strumTime = arrayDipshit[0];
noteStuff[sectionIndex].sectionNotes[noteIndex].noteData = arrayDipshit[1];
noteStuff[sectionIndex].sectionNotes[noteIndex].sustainLength = arrayDipshit[2];
noteStuff[sectionIndex].sectionNotes[noteIndex].altNote = arrayDipshit[3];
}
}
}
switch (diff)
{
case "easy":
funnyNoteSetter(swagShit.notes.hard);
case "normal":
funnyNoteSetter(swagShit.notes.normal);
case "hard":
funnyNoteSetter(swagShit.notes.hard);
}
trace(diff);
}
swagShit.validScore = true;
trace("SONG SHIT ABOUTTA WEEK AGOOO");
@ -144,7 +191,6 @@ class SongLoad
// swagShit.notes = cast Json.parse(rawJson).song.notes[SongLoad.curDiff]; // by default uses
// trace(swagShit.notes);
trace('THAT SHIT WAS JUST THE NORMAL NOTES!!!');
songData = swagShit;
// curNotes = songData.notes.get('normal');

View file

@ -129,7 +129,10 @@ class ChartingState extends MusicBeatState
curRenderedSustains = new FlxTypedGroup<FlxSprite>();
if (PlayState.SONG != null)
_song = PlayState.SONG;
{
_song = SongLoad.songData = PlayState.SONG;
trace("LOADED A PLAYSTATE SONGFILE");
}
else
{
_song = SongLoad.songData = SongLoad.getDefaultSwagSong();