1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-25 08:13:45 +00:00

Merge remote-tracking branch 'origin/note-redux' into feature/chart-editor

This commit is contained in:
MasterEric 2022-09-24 01:29:53 -04:00
commit 7b71fc2dff
2 changed files with 101 additions and 0 deletions

View file

@ -10,6 +10,8 @@ import flixel.util.FlxColor;
import flixel.util.FlxDirectionFlags;
import flixel.util.FlxTimer;
import funkin.audiovis.SpectogramSprite;
import funkin.noteStuff.NoteUtil;
import funkin.shaderslmfao.BuildingShaders;
import funkin.shaderslmfao.ColorSwap;
import funkin.shaderslmfao.TitleOutline;
import funkin.ui.AtlasText;

View file

@ -0,0 +1,99 @@
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<Int, Array<SongEventInfo>>
*/
public static function loadSongEvents(jsonPath:String):Map<Int, Array<SongEventInfo>>
{
return parseSongEvents(loadSongEventFromJson(jsonPath));
}
public static function loadSongEventFromJson(jsonPath:String):Array<SongEvent>
{
var daEvents:Array<SongEvent>;
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<SongEvent>):Map<Int, Array<SongEventInfo>>
{
var songData:Map<Int, Array<SongEventInfo>> = 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<Int, Array<SongEventInfo>>, time:Float)
{
for (eventGrp in songData.keys())
{
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;
}
}
}
}
}
}
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;
}