From f47e67e073ccab0b1ac04e8668027f1873adf569 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 17 Sep 2022 05:38:45 -0400 Subject: [PATCH 1/2] event parsing prototyping --- source/funkin/TitleState.hx | 5 ++ source/funkin/noteStuff/NoteUtil.hx | 86 +++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 source/funkin/noteStuff/NoteUtil.hx diff --git a/source/funkin/TitleState.hx b/source/funkin/TitleState.hx index cf8c6ea80..465b2ddeb 100644 --- a/source/funkin/TitleState.hx +++ b/source/funkin/TitleState.hx @@ -10,6 +10,7 @@ import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxTimer; import funkin.audiovis.SpectogramSprite; +import funkin.noteStuff.NoteUtil; import funkin.shaderslmfao.BuildingShaders; import funkin.shaderslmfao.ColorSwap; import funkin.shaderslmfao.TitleOutline; @@ -53,6 +54,10 @@ class TitleState extends MusicBeatState curWacky = FlxG.random.getObject(getIntroTextShit()); FlxG.sound.cache(Paths.music('freakyMenu')); + var jsonThing:String = Paths.file('data/songs/bopeebo/bopeebo-events.json'); + var songstuffLol = NoteUtil.loadSongEvents(jsonThing); + trace(songstuffLol); + // DEBUG BULLSHIT super.create(); diff --git a/source/funkin/noteStuff/NoteUtil.hx b/source/funkin/noteStuff/NoteUtil.hx new file mode 100644 index 000000000..71507355c --- /dev/null +++ b/source/funkin/noteStuff/NoteUtil.hx @@ -0,0 +1,86 @@ +package funkin.noteStuff; + +import haxe.Json; +import openfl.Assets; + +/** + * Just various functions that IDK where to put em!!! + * Semi-temp for now? the note stuff is super clutter-y right now + * so I am putting this new stuff here right now XDD + * + * A lot of this stuff can probably be moved to where appropriate! + * i dont care about NoteUtil.hx at all!!! + */ +class NoteUtil +{ + /** + * IDK THING FOR BOTH LOL! DIS SHIT HACK-Y + * @param jsonPath + * @return Map> + */ + public static function loadSongEvents(jsonPath:String):Map> + { + return parseSongEvents(loadSongEventFromJson(jsonPath)); + } + + public static function loadSongEventFromJson(jsonPath:String):Array + { + var daEvents:Array; + daEvents = cast Json.parse(Assets.getText(jsonPath)).events; // DUMB LIL DETAIL HERE: MAKE SURE THAT .events IS THERE?? + trace('GET JSON SONG EVENTS:'); + trace(daEvents); + return daEvents; + } + + /** + * Parses song event json stuff into a neater lil map grouping? + * @param songEvents + */ + public static function parseSongEvents(songEvents:Array):Map> + { + var songData:Map> = new Map(); + + for (songEvent in songEvents) + { + trace(songEvent); + if (songData[songEvent.t] == null) + songData[songEvent.t] = []; + + songData[songEvent.t].push({songEventType: songEvent.e, value: songEvent.v, activated: false}); + } + + trace("FINISH SONG EVENTS!"); + trace(songData); + + return songData; + } + + public static function checkSongEvents(songData:Map>, time:Float) + { + for (eventGrp in songData.keys()) + { + trace(eventGrp); + } + } +} + +typedef SongEventInfo = +{ + var songEventType:SongEventType; + var value:Dynamic; + var activated:Bool; +} + +typedef SongEvent = +{ + var t:Int; + var e:SongEventType; + var v:Dynamic; +} + +enum abstract SongEventType(String) +{ + var FocusCamera; + var PlayCharAnim; + var Trace; +} From f70b581bf89694df96d2069e6f40d4e56a753617 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 17 Sep 2022 05:51:21 -0400 Subject: [PATCH 2/2] song event trace prototype --- source/funkin/TitleState.hx | 6 ++++-- source/funkin/noteStuff/NoteUtil.hx | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/funkin/TitleState.hx b/source/funkin/TitleState.hx index 465b2ddeb..85853444f 100644 --- a/source/funkin/TitleState.hx +++ b/source/funkin/TitleState.hx @@ -45,6 +45,7 @@ class TitleState extends MusicBeatState var video:Video; var netStream:NetStream; private var overlay:Sprite; + var songEventStuff:Map>; override public function create():Void { @@ -55,8 +56,7 @@ class TitleState extends MusicBeatState FlxG.sound.cache(Paths.music('freakyMenu')); var jsonThing:String = Paths.file('data/songs/bopeebo/bopeebo-events.json'); - var songstuffLol = NoteUtil.loadSongEvents(jsonThing); - trace(songstuffLol); + songEventStuff = NoteUtil.loadSongEvents(jsonThing); // DEBUG BULLSHIT @@ -270,6 +270,8 @@ class TitleState extends MusicBeatState override function update(elapsed:Float) { + NoteUtil.checkSongEvents(songEventStuff, Conductor.songPosition); + #if HAS_PITCH if (FlxG.keys.pressed.UP) FlxG.sound.music.pitch += 0.5 * elapsed; diff --git a/source/funkin/noteStuff/NoteUtil.hx b/source/funkin/noteStuff/NoteUtil.hx index 71507355c..054ec2fef 100644 --- a/source/funkin/noteStuff/NoteUtil.hx +++ b/source/funkin/noteStuff/NoteUtil.hx @@ -59,7 +59,20 @@ class NoteUtil { for (eventGrp in songData.keys()) { - trace(eventGrp); + if (time >= eventGrp) + { + for (events in songData[eventGrp]) + { + if (!events.activated) + { + // TURN TO NICER SWITCH STATEMENT CHECKER OF EVENT TYPES!! + trace(events.value); + trace(eventGrp); + trace(Conductor.songPosition); + events.activated = true; + } + } + } } } }