From 4b4a90185cedce6f7a29f3b1a95de7e4ea63b2ab Mon Sep 17 00:00:00 2001 From: ILikeWeewees Date: Fri, 2 Jun 2023 20:13:50 -0700 Subject: [PATCH] ysy no more broken song json shit --- source/Song.hx | 12 ++++++++++-- vscode-project.hxml | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/Song.hx b/source/Song.hx index 2ea2a2f81..2ba500fae 100644 --- a/source/Song.hx +++ b/source/Song.hx @@ -4,6 +4,7 @@ import Section.SwagSection; import haxe.Json; import haxe.format.JsonParser; import lime.utils.Assets; +import sys.FileSystem; using StringTools; @@ -40,8 +41,15 @@ class Song public static function loadFromJson(jsonInput:String, ?folder:String):SwagSong { - var rawJson = Assets.getText(Paths.json(folder.toLowerCase() + '/' + jsonInput.toLowerCase())).trim(); - + var rawJson:String; + if (FileSystem.exists(Paths.json(folder.toLowerCase() + '/' + jsonInput.toLowerCase()))) + { + rawJson = Assets.getText(Paths.json(folder.toLowerCase() + '/' + jsonInput.toLowerCase())).trim(); + } + else + { + rawJson = '{"song": {"song": "' + jsonInput + '","bpm": 100.0,"needsVoices": true,"player1": "bf","player2": "dad","speed": 1.3,"notes": [{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []},{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []},{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []},{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []},{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []},{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []},{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []},{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []},{"lengthInSteps": 16,"mustHitSection": false,"sectionNotes": []}]},"generatedBy": "SNIFF ver.6"}'; + } while (!rawJson.endsWith("}")) { rawJson = rawJson.substr(0, rawJson.length - 1); diff --git a/vscode-project.hxml b/vscode-project.hxml index 8a43722f1..a0a171b8d 100644 --- a/vscode-project.hxml +++ b/vscode-project.hxml @@ -1,3 +1,3 @@ #automatically generated do not edit -#@date Fri Jun 02 2023 19:16:38 GMT-0700 (Pacific Daylight Time) +#@date Fri Jun 02 2023 19:52:08 GMT-0700 (Pacific Daylight Time) -cp c:\users\bamst\appdata\local\temp\2def77e625d453c59a42a972450a0ad156c9aa14 \ No newline at end of file