make game use rfc format for spitting inputs

This commit is contained in:
Ravy 2023-03-18 19:47:23 +00:00
parent 9403eb4957
commit c68ed233f9
2 changed files with 78 additions and 8 deletions

View file

@ -43,6 +43,7 @@ import funkin.ui.PopUpStuff;
import funkin.ui.PreferencesMenu; import funkin.ui.PreferencesMenu;
import funkin.ui.stageBuildShit.StageOffsetSubstate; import funkin.ui.stageBuildShit.StageOffsetSubstate;
import funkin.util.Constants; import funkin.util.Constants;
import funkin.util.SerializerUtil;
import funkin.util.SortUtil; import funkin.util.SortUtil;
import lime.ui.Haptic; import lime.ui.Haptic;
#if discord_rpc #if discord_rpc
@ -1855,7 +1856,8 @@ class PlayState extends MusicBeatState
#if sys #if sys
// spitter for ravy, teehee!! // 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 #end
seenCutscene = false; seenCutscene = false;
@ -1948,6 +1950,7 @@ class PlayState extends MusicBeatState
else else
{ {
trace('WENT TO RESULTS SCREEN!'); trace('WENT TO RESULTS SCREEN!');
trace(songScore);
// unloadAssets(); // unloadAssets();
camZoomRate = 0; camZoomRate = 0;
@ -2035,8 +2038,32 @@ class PlayState extends MusicBeatState
controls.NOTE_UP_P, controls.NOTE_UP_P,
controls.NOTE_RIGHT_P controls.NOTE_RIGHT_P
]; ];
var lol:Array<Int> = cast pressArray; var indices:Array<Int> = [];
inputSpitter.push(Std.int(Conductor.songPosition) + " " + lol.join(" ") + " " + Std.string(score) + " " + songScore); 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); comboPopUps.displayRating(daRating);
if (Highscore.tallies.combo >= 10 || Highscore.tallies.combo == 0) comboPopUps.displayCombo(Highscore.tallies.combo); 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 🙇!! * Spitting out the input for ravy 🙇!!
*/ */
var inputSpitter:Array<String> = []; var inputSpitter:Array<ScoreInput> = [];
public function keyShit(test:Bool):Void public function keyShit(test:Bool):Void
{ {
@ -2261,8 +2288,20 @@ class PlayState extends MusicBeatState
controls.NOTE_UP_P, controls.NOTE_UP_P,
controls.NOTE_RIGHT_P controls.NOTE_RIGHT_P
]; ];
var lol:Array<Int> = cast pressArray; var indices:Array<Int> = [];
inputSpitter.push(Std.int(Conductor.songPosition) + " " + lol.join(" ") + " " + Std.string(event.scoreChange) + " " + songScore); 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) if (event.playSound)
@ -2295,8 +2334,32 @@ class PlayState extends MusicBeatState
controls.NOTE_UP_P, controls.NOTE_UP_P,
controls.NOTE_RIGHT_P controls.NOTE_RIGHT_P
]; ];
var lol:Array<Int> = cast pressArray; var indices:Array<Int> = [];
inputSpitter.push(Std.int(Conductor.songPosition) + " " + lol.join(" ") + " " + Std.string(-10) + " " + songScore); 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; vocals.volume = 0;

View file

@ -3,6 +3,13 @@ package funkin.util;
import haxe.Json; import haxe.Json;
import thx.semver.Version; import thx.semver.Version;
typedef ScoreInput =
{
var d:Int; // Key pressed
var l:Int; // Duration
var t:Int; // Start timestamp
}
class SerializerUtil class SerializerUtil
{ {
static final INDENT_CHAR = "\t"; static final INDENT_CHAR = "\t";