From d2158bfe185c88322877e1d675e23c614d79da82 Mon Sep 17 00:00:00 2001 From: Cameron Taylor <cameron.taylor.ninja@gmail.com> Date: Tue, 13 Oct 2020 22:02:36 -0700 Subject: [PATCH] CLEANED JSON LOL --- source/ChartingState.hx | 2 +- source/Main.hx | 2 +- source/PlayState.hx | 2 +- source/Song.hx | 14 +++++++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index b521a0112..725331b89 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -362,7 +362,7 @@ class ChartingState extends MusicBeatState "song": curSong, "bpm": Conductor.bpm, "sections": sections.length, - 'notes': getNotes + 'notes': sections }; var data:String = Json.stringify(json); diff --git a/source/Main.hx b/source/Main.hx index d4bd9a4a7..a4040a187 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -9,7 +9,7 @@ class Main extends Sprite public function new() { super(); - addChild(new FlxGame(0, 0, ChartingState)); + addChild(new FlxGame(0, 0, PlayState)); #if !mobile addChild(new FPS(10, 3, 0xFFFFFF)); diff --git a/source/PlayState.hx b/source/PlayState.hx index 631efd120..11c017eba 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -71,7 +71,7 @@ class PlayState extends MusicBeatState persistentDraw = true; if (SONG == null) - SONG = Song.loadFromJson('tutorial'); + SONG = Song.loadFromJson('smash'); var bg:FlxSprite = new FlxSprite(-600, -200).loadGraphic(AssetPaths.stageback__png); // bg.setGraphicSize(Std.int(bg.width * 2.5)); diff --git a/source/Song.hx b/source/Song.hx index bd4105b9b..26b352892 100644 --- a/source/Song.hx +++ b/source/Song.hx @@ -3,6 +3,8 @@ package; import haxe.Json; import lime.utils.Assets; +using StringTools; + class Song { public var song:String; @@ -32,7 +34,17 @@ class Song var daSong:String = ''; var daSectionLengths:Array<Int> = []; - var songData = Json.parse(Assets.getText('assets/data/' + jsonInput + '/' + jsonInput + '.json')); + var rawJson = Assets.getText('assets/data/' + jsonInput + '/' + jsonInput + '.json').trim(); + + while (!rawJson.endsWith("}")) + { + rawJson = rawJson.substr(0, rawJson.length - 1); + // LOL GOING THROUGH THE BULLSHIT TO CLEAN IDK WHATS STRANGE + } + + trace(rawJson); + + var songData = Json.parse(rawJson); daNotes = songData.notes; daSong = songData.song;