diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 6d7bad77f..6d7ddcd1b 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -23,11 +23,17 @@ class NoteKind implements INoteScriptedClass */ public var noteStyleId:Null; - public function new(noteKind:String, description:String = "", ?noteStyleId:String) + /** + * Custom parameters for the chart editor + */ + public var params:Array; + + public function new(noteKind:String, description:String = "", ?noteStyleId:String, ?params:Array) { this.noteKind = noteKind; this.description = description; this.noteStyleId = noteStyleId; + this.params = params ?? []; } public function toString():String @@ -35,6 +41,25 @@ class NoteKind implements INoteScriptedClass return noteKind; } + /** + * Retrieve the param with the given name + * If there exists no param with the given name then `null` is returned + * @param name Name of the param + * @return Null + */ + public function getParam(name:String):Null + { + for (param in params) + { + if (param.name == name) + { + return param; + } + } + + return null; + } + /** * Retrieve all notes of this kind * @return Array @@ -61,3 +86,46 @@ class NoteKind implements INoteScriptedClass public function onNoteMiss(event:NoteScriptEvent):Void {} } + +/** + * Abstract for setting the type of the `NoteKindParam` + * This was supposed to be an enum but polymod kept being annoying + */ +abstract NoteKindParamType(String) +{ + public static var STRING:String = "String"; + + public static var INT:String = "Int"; + + public static var RANGED_INT:String = "RangedInt"; + + public static var FLOAT:String = "Float"; + + public static var RANGED_FLOAT:String = "RangedFloat"; +} + +typedef NoteKindParamData = +{ + /** + * Only used for `RangedInt` and `RangedFloat` + */ + var min:Null; + + /** + * Only used for `RangedInt` and `RangedFloat` + */ + var max:Null; + + var value:Dynamic; +} + +/** + * Typedef for creating custom parameters in the chart editor + */ +typedef NoteKindParam = +{ + var name:String; + var description:String; + var type:NoteKindParamType; + var data:NoteKindParamData; +}