From c68ed233f92e1f2e40793839989194ab4ad2712f Mon Sep 17 00:00:00 2001 From: Ravy Date: Sat, 18 Mar 2023 19:47:23 +0000 Subject: [PATCH] make game use rfc format for spitting inputs --- source/funkin/play/PlayState.hx | 79 +++++++++++++++++++++++++--- source/funkin/util/SerializerUtil.hx | 7 +++ 2 files changed, 78 insertions(+), 8 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 401a6e7c3..8e51db8a0 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -43,6 +43,7 @@ import funkin.ui.PopUpStuff; import funkin.ui.PreferencesMenu; import funkin.ui.stageBuildShit.StageOffsetSubstate; import funkin.util.Constants; +import funkin.util.SerializerUtil; import funkin.util.SortUtil; import lime.ui.Haptic; #if discord_rpc @@ -1855,7 +1856,8 @@ class PlayState extends MusicBeatState #if sys // spitter for ravy, teehee!! - sys.io.File.saveContent("./scores.txt", inputSpitter.join("\n")); + var output = SerializerUtil.toJSON(inputSpitter); + sys.io.File.saveContent("./scores.json", output); #end seenCutscene = false; @@ -1948,6 +1950,7 @@ class PlayState extends MusicBeatState else { trace('WENT TO RESULTS SCREEN!'); + trace(songScore); // unloadAssets(); camZoomRate = 0; @@ -2035,8 +2038,32 @@ class PlayState extends MusicBeatState controls.NOTE_UP_P, controls.NOTE_RIGHT_P ]; - var lol:Array = cast pressArray; - inputSpitter.push(Std.int(Conductor.songPosition) + " " + lol.join(" ") + " " + Std.string(score) + " " + songScore); + var indices:Array = []; + for (i in 0...pressArray.length) + { + if (pressArray[i]) indices.push(i); + } + if (indices.length > 0) + { + for (i in 0...indices.length) + { + inputSpitter.push( + { + t: Std.int(Conductor.songPosition), + d: indices[i], + l: 20 + }); + } + } + else + { + inputSpitter.push( + { + t: Std.int(Conductor.songPosition), + d: -1, + l: 20 + }); + } } comboPopUps.displayRating(daRating); if (Highscore.tallies.combo >= 10 || Highscore.tallies.combo == 0) comboPopUps.displayCombo(Highscore.tallies.combo); @@ -2103,7 +2130,7 @@ class PlayState extends MusicBeatState /** * Spitting out the input for ravy 🙇‍♂️!! */ - var inputSpitter:Array = []; + var inputSpitter:Array = []; public function keyShit(test:Bool):Void { @@ -2261,8 +2288,20 @@ class PlayState extends MusicBeatState controls.NOTE_UP_P, controls.NOTE_RIGHT_P ]; - var lol:Array = cast pressArray; - inputSpitter.push(Std.int(Conductor.songPosition) + " " + lol.join(" ") + " " + Std.string(event.scoreChange) + " " + songScore); + var indices:Array = []; + for (i in 0...pressArray.length) + { + if (pressArray[i]) indices.push(i); + } + for (i in 0...indices.length) + { + inputSpitter.push( + { + t: Std.int(Conductor.songPosition), + d: indices[i], + l: 20 + }); + } } if (event.playSound) @@ -2295,8 +2334,32 @@ class PlayState extends MusicBeatState controls.NOTE_UP_P, controls.NOTE_RIGHT_P ]; - var lol:Array = cast pressArray; - inputSpitter.push(Std.int(Conductor.songPosition) + " " + lol.join(" ") + " " + Std.string(-10) + " " + songScore); + var indices:Array = []; + for (i in 0...pressArray.length) + { + if (pressArray[i]) indices.push(i); + } + if (indices.length > 0) + { + for (i in 0...indices.length) + { + inputSpitter.push( + { + t: Std.int(Conductor.songPosition), + d: indices[i], + l: 20 + }); + } + } + else + { + inputSpitter.push( + { + t: Std.int(Conductor.songPosition), + d: -1, + l: 20 + }); + } } vocals.volume = 0; diff --git a/source/funkin/util/SerializerUtil.hx b/source/funkin/util/SerializerUtil.hx index b478f9e98..dae3327c6 100644 --- a/source/funkin/util/SerializerUtil.hx +++ b/source/funkin/util/SerializerUtil.hx @@ -3,6 +3,13 @@ package funkin.util; import haxe.Json; import thx.semver.Version; +typedef ScoreInput = +{ + var d:Int; // Key pressed + var l:Int; // Duration + var t:Int; // Start timestamp +} + class SerializerUtil { static final INDENT_CHAR = "\t";