mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-01-26 22:56:48 +00:00
add note kind scripts
This commit is contained in:
parent
50b587e3b8
commit
a7482410b9
|
@ -27,6 +27,7 @@ import funkin.data.dialogue.speaker.SpeakerRegistry;
|
||||||
import funkin.data.freeplay.album.AlbumRegistry;
|
import funkin.data.freeplay.album.AlbumRegistry;
|
||||||
import funkin.data.song.SongRegistry;
|
import funkin.data.song.SongRegistry;
|
||||||
import funkin.play.character.CharacterData.CharacterDataParser;
|
import funkin.play.character.CharacterData.CharacterDataParser;
|
||||||
|
import funkin.play.notes.notekind.NoteKindScriptManager;
|
||||||
import funkin.modding.module.ModuleHandler;
|
import funkin.modding.module.ModuleHandler;
|
||||||
import funkin.ui.title.TitleState;
|
import funkin.ui.title.TitleState;
|
||||||
import funkin.util.CLIUtil;
|
import funkin.util.CLIUtil;
|
||||||
|
@ -176,6 +177,8 @@ class InitState extends FlxState
|
||||||
// Move it to use a BaseRegistry.
|
// Move it to use a BaseRegistry.
|
||||||
CharacterDataParser.loadCharacterCache();
|
CharacterDataParser.loadCharacterCache();
|
||||||
|
|
||||||
|
NoteKindScriptManager.loadScripts();
|
||||||
|
|
||||||
ModuleHandler.buildModuleCallbacks();
|
ModuleHandler.buildModuleCallbacks();
|
||||||
ModuleHandler.loadModuleCache();
|
ModuleHandler.loadModuleCache();
|
||||||
ModuleHandler.callOnCreate();
|
ModuleHandler.callOnCreate();
|
||||||
|
|
|
@ -49,6 +49,7 @@ import funkin.play.notes.NoteSprite;
|
||||||
import funkin.play.notes.notestyle.NoteStyle;
|
import funkin.play.notes.notestyle.NoteStyle;
|
||||||
import funkin.play.notes.Strumline;
|
import funkin.play.notes.Strumline;
|
||||||
import funkin.play.notes.SustainTrail;
|
import funkin.play.notes.SustainTrail;
|
||||||
|
import funkin.play.notes.notekind.NoteKindScriptManager;
|
||||||
import funkin.play.scoring.Scoring;
|
import funkin.play.scoring.Scoring;
|
||||||
import funkin.play.song.Song;
|
import funkin.play.song.Song;
|
||||||
import funkin.play.stage.Stage;
|
import funkin.play.stage.Stage;
|
||||||
|
@ -1177,7 +1178,12 @@ class PlayState extends MusicBeatSubState
|
||||||
// Dispatch event to conversation script.
|
// Dispatch event to conversation script.
|
||||||
ScriptEventDispatcher.callEvent(currentConversation, event);
|
ScriptEventDispatcher.callEvent(currentConversation, event);
|
||||||
|
|
||||||
// TODO: Dispatch event to note scripts
|
// Dispatch event to note script
|
||||||
|
if (Std.isOfType(event, NoteScriptEvent))
|
||||||
|
{
|
||||||
|
var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent);
|
||||||
|
NoteKindScriptManager.callEvent(noteEvent.note.noteData.kind, noteEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
45
source/funkin/play/notes/notekind/NoteKindScript.hx
Normal file
45
source/funkin/play/notes/notekind/NoteKindScript.hx
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package funkin.play.notes.notekind;
|
||||||
|
|
||||||
|
import funkin.modding.IScriptedClass.INoteScriptedClass;
|
||||||
|
import funkin.modding.events.ScriptEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for note scripts
|
||||||
|
*/
|
||||||
|
class NoteKindScript implements INoteScriptedClass
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* the name of the note kind
|
||||||
|
*/
|
||||||
|
public var noteKind:String;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* description used in chart editor
|
||||||
|
*/
|
||||||
|
public var description:String = "";
|
||||||
|
|
||||||
|
public function new(noteKind:String, description:String = "")
|
||||||
|
{
|
||||||
|
this.noteKind = noteKind;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toString():String
|
||||||
|
{
|
||||||
|
return noteKind;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onScriptEvent(event:ScriptEvent):Void {}
|
||||||
|
|
||||||
|
public function onCreate(event:ScriptEvent):Void {}
|
||||||
|
|
||||||
|
public function onDestroy(event:ScriptEvent):Void {}
|
||||||
|
|
||||||
|
public function onUpdate(event:UpdateScriptEvent):Void {}
|
||||||
|
|
||||||
|
public function onNoteIncoming(event:NoteScriptEvent):Void {}
|
||||||
|
|
||||||
|
public function onNoteHit(event:HitNoteScriptEvent):Void {}
|
||||||
|
|
||||||
|
public function onNoteMiss(event:NoteScriptEvent):Void {}
|
||||||
|
}
|
46
source/funkin/play/notes/notekind/NoteKindScriptManager.hx
Normal file
46
source/funkin/play/notes/notekind/NoteKindScriptManager.hx
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package funkin.play.notes.notekind;
|
||||||
|
|
||||||
|
import funkin.modding.events.ScriptEventDispatcher;
|
||||||
|
import funkin.modding.events.ScriptEvent;
|
||||||
|
import funkin.ui.debug.charting.util.ChartEditorDropdowns;
|
||||||
|
|
||||||
|
class NoteKindScriptManager
|
||||||
|
{
|
||||||
|
static var noteKindScripts:Map<String, NoteKindScript> = [];
|
||||||
|
|
||||||
|
public static function loadScripts():Void
|
||||||
|
{
|
||||||
|
var scriptedClassName:Array<String> = ScriptedNoteKindScript.listScriptClasses();
|
||||||
|
if (scriptedClassName.length > 0)
|
||||||
|
{
|
||||||
|
trace('Instantiating ${scriptedClassName.length} scripted note kind...');
|
||||||
|
for (scriptedClass in scriptedClassName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var script:NoteKindScript = ScriptedNoteKindScript.init(scriptedClass, "unknown");
|
||||||
|
trace(' Initialized scripted note kind: ${script.noteKind}');
|
||||||
|
noteKindScripts.set(script.noteKind, script);
|
||||||
|
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
|
||||||
|
{
|
||||||
|
var noteKindScript:NoteKindScript = noteKindScripts.get(noteKind);
|
||||||
|
|
||||||
|
if (noteKindScript == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptEventDispatcher.callEvent(noteKindScript, event);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package funkin.play.notes.notekind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A script that can be tied to a NoteKindScript.
|
||||||
|
* Create a scripted class that extends NoteKindScript,
|
||||||
|
* then call `super('noteKind')` in the constructor to use this.
|
||||||
|
*/
|
||||||
|
@:hscriptClass
|
||||||
|
class ScriptedNoteKindScript extends NoteKindScript implements polymod.hscript.HScriptedClass {}
|
|
@ -146,7 +146,7 @@ class ChartEditorDropdowns
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static final NOTE_KINDS:Map<String, String> = [
|
public static final NOTE_KINDS:Map<String, String> = [
|
||||||
// Base
|
// Base
|
||||||
"" => "Default",
|
"" => "Default",
|
||||||
"~CUSTOM~" => "Custom",
|
"~CUSTOM~" => "Custom",
|
||||||
|
|
Loading…
Reference in a new issue