2024-05-31 08:02:28 -04:00
|
|
|
package funkin.play.notes.notekind;
|
|
|
|
|
|
|
|
import funkin.modding.events.ScriptEventDispatcher;
|
|
|
|
import funkin.modding.events.ScriptEvent;
|
|
|
|
import funkin.ui.debug.charting.util.ChartEditorDropdowns;
|
|
|
|
|
2024-05-31 10:55:42 -04:00
|
|
|
class NoteKindManager
|
2024-05-31 08:02:28 -04:00
|
|
|
{
|
2024-05-31 10:55:42 -04:00
|
|
|
static var noteKinds:Map<String, NoteKind> = [];
|
2024-05-31 08:02:28 -04:00
|
|
|
|
|
|
|
public static function loadScripts():Void
|
|
|
|
{
|
2024-05-31 10:55:42 -04:00
|
|
|
var scriptedClassName:Array<String> = ScriptedNoteKind.listScriptClasses();
|
2024-05-31 08:02:28 -04:00
|
|
|
if (scriptedClassName.length > 0)
|
|
|
|
{
|
2024-05-31 11:24:51 -04:00
|
|
|
trace('Instantiating ${scriptedClassName.length} scripted note kind(s)...');
|
2024-05-31 08:02:28 -04:00
|
|
|
for (scriptedClass in scriptedClassName)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2024-05-31 10:55:42 -04:00
|
|
|
var script:NoteKind = ScriptedNoteKind.init(scriptedClass, "unknown");
|
2024-05-31 08:02:28 -04:00
|
|
|
trace(' Initialized scripted note kind: ${script.noteKind}');
|
2024-05-31 10:55:42 -04:00
|
|
|
noteKinds.set(script.noteKind, script);
|
2024-05-31 08:02:28 -04:00
|
|
|
ChartEditorDropdowns.NOTE_KINDS.set(script.noteKind, script.description);
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
trace(' FAILED to instantiate scripted note kind: ${scriptedClass}');
|
|
|
|
trace(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function callEvent(noteKind:String, event:ScriptEvent):Void
|
|
|
|
{
|
2024-05-31 10:55:42 -04:00
|
|
|
var noteKind:NoteKind = noteKinds.get(noteKind);
|
2024-05-31 08:02:28 -04:00
|
|
|
|
2024-05-31 10:55:42 -04:00
|
|
|
if (noteKind == null)
|
2024-05-31 08:02:28 -04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-05-31 10:55:42 -04:00
|
|
|
ScriptEventDispatcher.callEvent(noteKind, event);
|
2024-05-31 08:02:28 -04:00
|
|
|
}
|
|
|
|
}
|