From a7482410b91e82fbd7b7cf37a123b0e7aaa72fec Mon Sep 17 00:00:00 2001 From: lemz Date: Fri, 31 May 2024 14:02:28 +0200 Subject: [PATCH 01/38] add note kind scripts --- source/funkin/InitState.hx | 3 ++ source/funkin/play/PlayState.hx | 8 +++- .../play/notes/notekind/NoteKindScript.hx | 45 ++++++++++++++++++ .../notes/notekind/NoteKindScriptManager.hx | 46 +++++++++++++++++++ .../notes/notekind/ScriptedNoteKindScript.hx | 9 ++++ .../charting/util/ChartEditorDropdowns.hx | 2 +- 6 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 source/funkin/play/notes/notekind/NoteKindScript.hx create mode 100644 source/funkin/play/notes/notekind/NoteKindScriptManager.hx create mode 100644 source/funkin/play/notes/notekind/ScriptedNoteKindScript.hx diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index 6e370b5ff..a339d2655 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -27,6 +27,7 @@ import funkin.data.dialogue.speaker.SpeakerRegistry; import funkin.data.freeplay.album.AlbumRegistry; import funkin.data.song.SongRegistry; import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.play.notes.notekind.NoteKindScriptManager; import funkin.modding.module.ModuleHandler; import funkin.ui.title.TitleState; import funkin.util.CLIUtil; @@ -176,6 +177,8 @@ class InitState extends FlxState // Move it to use a BaseRegistry. CharacterDataParser.loadCharacterCache(); + NoteKindScriptManager.loadScripts(); + ModuleHandler.buildModuleCallbacks(); ModuleHandler.loadModuleCache(); ModuleHandler.callOnCreate(); diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 8d7d82aab..93306e9d5 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -49,6 +49,7 @@ import funkin.play.notes.NoteSprite; import funkin.play.notes.notestyle.NoteStyle; import funkin.play.notes.Strumline; import funkin.play.notes.SustainTrail; +import funkin.play.notes.notekind.NoteKindScriptManager; import funkin.play.scoring.Scoring; import funkin.play.song.Song; import funkin.play.stage.Stage; @@ -1177,7 +1178,12 @@ class PlayState extends MusicBeatSubState // Dispatch event to conversation script. 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); + } } /** diff --git a/source/funkin/play/notes/notekind/NoteKindScript.hx b/source/funkin/play/notes/notekind/NoteKindScript.hx new file mode 100644 index 000000000..baa57b146 --- /dev/null +++ b/source/funkin/play/notes/notekind/NoteKindScript.hx @@ -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 {} +} diff --git a/source/funkin/play/notes/notekind/NoteKindScriptManager.hx b/source/funkin/play/notes/notekind/NoteKindScriptManager.hx new file mode 100644 index 000000000..dc22732b6 --- /dev/null +++ b/source/funkin/play/notes/notekind/NoteKindScriptManager.hx @@ -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 = []; + + public static function loadScripts():Void + { + var scriptedClassName:Array = 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); + } +} diff --git a/source/funkin/play/notes/notekind/ScriptedNoteKindScript.hx b/source/funkin/play/notes/notekind/ScriptedNoteKindScript.hx new file mode 100644 index 000000000..d54a0cde2 --- /dev/null +++ b/source/funkin/play/notes/notekind/ScriptedNoteKindScript.hx @@ -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 {} diff --git a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx index 55aab0ab0..f20b75650 100644 --- a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx +++ b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx @@ -146,7 +146,7 @@ class ChartEditorDropdowns return returnValue; } - static final NOTE_KINDS:Map = [ + public static final NOTE_KINDS:Map = [ // Base "" => "Default", "~CUSTOM~" => "Custom", From 134b4678769de803b245c182fed9afe07fc29049 Mon Sep 17 00:00:00 2001 From: lemz Date: Fri, 31 May 2024 16:55:42 +0200 Subject: [PATCH 02/38] rename stuff --- source/funkin/InitState.hx | 4 ++-- source/funkin/play/PlayState.hx | 4 ++-- .../notekind/{NoteKindScript.hx => NoteKind.hx} | 2 +- ...teKindScriptManager.hx => NoteKindManager.hx} | 16 ++++++++-------- .../play/notes/notekind/ScriptedNoteKind.hx | 9 +++++++++ .../notes/notekind/ScriptedNoteKindScript.hx | 9 --------- 6 files changed, 22 insertions(+), 22 deletions(-) rename source/funkin/play/notes/notekind/{NoteKindScript.hx => NoteKind.hx} (94%) rename source/funkin/play/notes/notekind/{NoteKindScriptManager.hx => NoteKindManager.hx} (64%) create mode 100644 source/funkin/play/notes/notekind/ScriptedNoteKind.hx delete mode 100644 source/funkin/play/notes/notekind/ScriptedNoteKindScript.hx diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index a339d2655..34516dee1 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -27,7 +27,7 @@ import funkin.data.dialogue.speaker.SpeakerRegistry; import funkin.data.freeplay.album.AlbumRegistry; import funkin.data.song.SongRegistry; import funkin.play.character.CharacterData.CharacterDataParser; -import funkin.play.notes.notekind.NoteKindScriptManager; +import funkin.play.notes.notekind.NoteKindManager; import funkin.modding.module.ModuleHandler; import funkin.ui.title.TitleState; import funkin.util.CLIUtil; @@ -177,7 +177,7 @@ class InitState extends FlxState // Move it to use a BaseRegistry. CharacterDataParser.loadCharacterCache(); - NoteKindScriptManager.loadScripts(); + NoteKindManager.loadScripts(); ModuleHandler.buildModuleCallbacks(); ModuleHandler.loadModuleCache(); diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 93306e9d5..bc441a7d5 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -49,7 +49,7 @@ import funkin.play.notes.NoteSprite; import funkin.play.notes.notestyle.NoteStyle; import funkin.play.notes.Strumline; import funkin.play.notes.SustainTrail; -import funkin.play.notes.notekind.NoteKindScriptManager; +import funkin.play.notes.notekind.NoteKindManager; import funkin.play.scoring.Scoring; import funkin.play.song.Song; import funkin.play.stage.Stage; @@ -1182,7 +1182,7 @@ class PlayState extends MusicBeatSubState if (Std.isOfType(event, NoteScriptEvent)) { var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent); - NoteKindScriptManager.callEvent(noteEvent.note.noteData.kind, noteEvent); + NoteKindManager.callEvent(noteEvent.note.noteData.kind, noteEvent); } } diff --git a/source/funkin/play/notes/notekind/NoteKindScript.hx b/source/funkin/play/notes/notekind/NoteKind.hx similarity index 94% rename from source/funkin/play/notes/notekind/NoteKindScript.hx rename to source/funkin/play/notes/notekind/NoteKind.hx index baa57b146..77b2bbc45 100644 --- a/source/funkin/play/notes/notekind/NoteKindScript.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -6,7 +6,7 @@ import funkin.modding.events.ScriptEvent; /** * Class for note scripts */ -class NoteKindScript implements INoteScriptedClass +class NoteKind implements INoteScriptedClass { /** * the name of the note kind diff --git a/source/funkin/play/notes/notekind/NoteKindScriptManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx similarity index 64% rename from source/funkin/play/notes/notekind/NoteKindScriptManager.hx rename to source/funkin/play/notes/notekind/NoteKindManager.hx index dc22732b6..eaee0d319 100644 --- a/source/funkin/play/notes/notekind/NoteKindScriptManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -4,13 +4,13 @@ import funkin.modding.events.ScriptEventDispatcher; import funkin.modding.events.ScriptEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; -class NoteKindScriptManager +class NoteKindManager { - static var noteKindScripts:Map = []; + static var noteKinds:Map = []; public static function loadScripts():Void { - var scriptedClassName:Array = ScriptedNoteKindScript.listScriptClasses(); + var scriptedClassName:Array = ScriptedNoteKind.listScriptClasses(); if (scriptedClassName.length > 0) { trace('Instantiating ${scriptedClassName.length} scripted note kind...'); @@ -18,9 +18,9 @@ class NoteKindScriptManager { try { - var script:NoteKindScript = ScriptedNoteKindScript.init(scriptedClass, "unknown"); + var script:NoteKind = ScriptedNoteKind.init(scriptedClass, "unknown"); trace(' Initialized scripted note kind: ${script.noteKind}'); - noteKindScripts.set(script.noteKind, script); + noteKinds.set(script.noteKind, script); ChartEditorDropdowns.NOTE_KINDS.set(script.noteKind, script.description); } catch (e) @@ -34,13 +34,13 @@ class NoteKindScriptManager public static function callEvent(noteKind:String, event:ScriptEvent):Void { - var noteKindScript:NoteKindScript = noteKindScripts.get(noteKind); + var noteKind:NoteKind = noteKinds.get(noteKind); - if (noteKindScript == null) + if (noteKind == null) { return; } - ScriptEventDispatcher.callEvent(noteKindScript, event); + ScriptEventDispatcher.callEvent(noteKind, event); } } diff --git a/source/funkin/play/notes/notekind/ScriptedNoteKind.hx b/source/funkin/play/notes/notekind/ScriptedNoteKind.hx new file mode 100644 index 000000000..cd1781394 --- /dev/null +++ b/source/funkin/play/notes/notekind/ScriptedNoteKind.hx @@ -0,0 +1,9 @@ +package funkin.play.notes.notekind; + +/** + * A script that can be tied to a NoteKind. + * Create a scripted class that extends NoteKind, + * then call `super('noteKind')` in the constructor to use this. + */ +@:hscriptClass +class ScriptedNoteKind extends NoteKind implements polymod.hscript.HScriptedClass {} diff --git a/source/funkin/play/notes/notekind/ScriptedNoteKindScript.hx b/source/funkin/play/notes/notekind/ScriptedNoteKindScript.hx deleted file mode 100644 index d54a0cde2..000000000 --- a/source/funkin/play/notes/notekind/ScriptedNoteKindScript.hx +++ /dev/null @@ -1,9 +0,0 @@ -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 {} From 606d9d4af47ea50a89e921ef369aaa73b5dc3c7b Mon Sep 17 00:00:00 2001 From: lemz Date: Fri, 31 May 2024 17:24:51 +0200 Subject: [PATCH 03/38] Update NoteKindManager.hx --- source/funkin/play/notes/notekind/NoteKindManager.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index eaee0d319..99502af08 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -13,7 +13,7 @@ class NoteKindManager var scriptedClassName:Array = ScriptedNoteKind.listScriptClasses(); if (scriptedClassName.length > 0) { - trace('Instantiating ${scriptedClassName.length} scripted note kind...'); + trace('Instantiating ${scriptedClassName.length} scripted note kind(s)...'); for (scriptedClass in scriptedClassName) { try From c83e505f5bae0e1a61a1d010aec8765d53cab36d Mon Sep 17 00:00:00 2001 From: lemz Date: Fri, 31 May 2024 17:49:25 +0200 Subject: [PATCH 04/38] onUpdate, etc. works now too --- source/funkin/play/PlayState.hx | 6 +++++- source/funkin/play/notes/notekind/NoteKindManager.hx | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index bc441a7d5..3b098be14 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1178,12 +1178,16 @@ class PlayState extends MusicBeatSubState // Dispatch event to conversation script. ScriptEventDispatcher.callEvent(currentConversation, event); - // Dispatch event to note script + // Dispatch event to only the specific note script if (Std.isOfType(event, NoteScriptEvent)) { var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent); NoteKindManager.callEvent(noteEvent.note.noteData.kind, noteEvent); } + else // Dispatch event to all note scripts + { + NoteKindManager.callEventForAll(event); + } } /** diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 99502af08..0de1a0a33 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -43,4 +43,12 @@ class NoteKindManager ScriptEventDispatcher.callEvent(noteKind, event); } + + public static function callEventForAll(event:ScriptEvent):Void + { + for (noteKind in noteKinds.iterator()) + { + ScriptEventDispatcher.callEvent(noteKind, event); + } + } } From e3e4e9fac01844a807ecd54e34fc162205c59ed9 Mon Sep 17 00:00:00 2001 From: lemz Date: Fri, 31 May 2024 20:28:56 +0200 Subject: [PATCH 05/38] helper function --- source/funkin/play/notes/notekind/NoteKind.hx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 77b2bbc45..8b87e0442 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -18,6 +18,16 @@ class NoteKind implements INoteScriptedClass */ public var description:String = ""; + /** + * this only exists for people that don't like calling functions + */ + var notes(get, never):Array; + + function get_notes():Array + { + return this.getNotes(); + } + public function new(noteKind:String, description:String = "") { this.noteKind = noteKind; @@ -29,6 +39,18 @@ class NoteKind implements INoteScriptedClass return noteKind; } + /** + * Retrieve all notes of this kind + * @return Array + */ + function getNotes():Array + { + var allNotes:Array = PlayState.instance.playerStrumline.notes.members.concat(PlayState.instance.opponentStrumline.notes.members); + return allNotes.filter(function(note:NoteSprite) { + return note != null && note.noteData.kind == this.noteKind; + }); + } + public function onScriptEvent(event:ScriptEvent):Void {} public function onCreate(event:ScriptEvent):Void {} From 3f39d9509c1e2a02d4ace85553991b6679a83d14 Mon Sep 17 00:00:00 2001 From: lemz Date: Fri, 31 May 2024 23:56:57 +0200 Subject: [PATCH 06/38] make custom note style less clunky --- source/funkin/play/notes/notekind/NoteKind.hx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 8b87e0442..f4936c59e 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -1,5 +1,7 @@ package funkin.play.notes.notekind; +import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.notes.notestyle.NoteStyle; import funkin.modding.IScriptedClass.INoteScriptedClass; import funkin.modding.events.ScriptEvent; @@ -39,6 +41,23 @@ class NoteKind implements INoteScriptedClass return noteKind; } + /** + * Changes the note style of the given note. Use this in `onNoteIncoming` + * @param note + * @param noteStyle + */ + function setNoteStyle(note:NoteSprite, noteStyleId:String):Void + { + var noteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyleId); + noteStyle.buildNoteSprite(note); + + note.setGraphicSize(Strumline.STRUMLINE_SIZE); + note.updateHitbox(); + + // this calls the setter for playing the correct animation + note.direction = note.direction; + } + /** * Retrieve all notes of this kind * @return Array From 14771e72deb7f08b9658e0801c9e088bb5d1aa96 Mon Sep 17 00:00:00 2001 From: lemz Date: Fri, 31 May 2024 23:59:40 +0200 Subject: [PATCH 07/38] no more note getter --- source/funkin/play/notes/notekind/NoteKind.hx | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index f4936c59e..262660eea 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -20,16 +20,6 @@ class NoteKind implements INoteScriptedClass */ public var description:String = ""; - /** - * this only exists for people that don't like calling functions - */ - var notes(get, never):Array; - - function get_notes():Array - { - return this.getNotes(); - } - public function new(noteKind:String, description:String = "") { this.noteKind = noteKind; From b6eda8e498be12f40c6086678a48c7c038e4b69e Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 1 Jun 2024 18:25:46 +0200 Subject: [PATCH 08/38] remove note kind logic from playstate --- source/funkin/play/PlayState.hx | 12 ++----- .../play/notes/notekind/NoteKindManager.hx | 34 ++++++++++++------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 3b098be14..da343f43f 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1178,16 +1178,8 @@ class PlayState extends MusicBeatSubState // Dispatch event to conversation script. ScriptEventDispatcher.callEvent(currentConversation, event); - // Dispatch event to only the specific note script - if (Std.isOfType(event, NoteScriptEvent)) - { - var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent); - NoteKindManager.callEvent(noteEvent.note.noteData.kind, noteEvent); - } - else // Dispatch event to all note scripts - { - NoteKindManager.callEventForAll(event); - } + // Dispatch event to note kind scripts + NoteKindManager.callEvent(event); } /** diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 0de1a0a33..6efd601c7 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -32,23 +32,31 @@ class NoteKindManager } } - public static function callEvent(noteKind:String, event:ScriptEvent):Void + /** + * Calls the given event for note kind scripts + * @param event The event + */ + public static function callEvent(event:ScriptEvent):Void { - var noteKind:NoteKind = noteKinds.get(noteKind); - - if (noteKind == null) + // if it is a note script event, + // then only call the event for the specific note kind script + if (Std.isOfType(event, NoteScriptEvent)) { - return; + var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent); + + var noteKind:NoteKind = noteKinds.get(noteEvent.note.noteData.kind); + + if (noteKind != null) + { + ScriptEventDispatcher.callEvent(noteKind, event); + } } - - ScriptEventDispatcher.callEvent(noteKind, event); - } - - public static function callEventForAll(event:ScriptEvent):Void - { - for (noteKind in noteKinds.iterator()) + else // call the event for all note kind scripts { - ScriptEventDispatcher.callEvent(noteKind, event); + for (noteKind in noteKinds.iterator()) + { + ScriptEventDispatcher.callEvent(noteKind, event); + } } } } From 328e590f92901f3dab711a725af02cc40763f359 Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 1 Jun 2024 19:47:45 +0200 Subject: [PATCH 09/38] hold assets are updated aswell --- source/funkin/play/notes/NoteSprite.hx | 6 ++- source/funkin/play/notes/Strumline.hx | 7 ++++ source/funkin/play/notes/SustainTrail.hx | 38 ++++++++++++++----- source/funkin/play/notes/notekind/NoteKind.hx | 33 +++++----------- .../play/notes/notekind/NoteKindManager.hx | 16 +++++++- 5 files changed, 65 insertions(+), 35 deletions(-) diff --git a/source/funkin/play/notes/NoteSprite.hx b/source/funkin/play/notes/NoteSprite.hx index b16b88466..17a5e57fc 100644 --- a/source/funkin/play/notes/NoteSprite.hx +++ b/source/funkin/play/notes/NoteSprite.hx @@ -140,7 +140,11 @@ class NoteSprite extends FunkinSprite this.active = false; } - function setupNoteGraphic(noteStyle:NoteStyle):Void + /** + * Creates frames and animations + * @param noteStyle The `NoteStyle` instance + */ + public function setupNoteGraphic(noteStyle:NoteStyle):Void { noteStyle.buildNoteSprite(this); diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index fdb32bb85..ebc48a8c7 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -16,6 +16,7 @@ import funkin.data.song.SongData.SongNoteData; import funkin.ui.options.PreferencesMenu; import funkin.util.SortUtil; import funkin.modding.events.ScriptEvent; +import funkin.play.notes.notekind.NoteKindManager; /** * A group of sprites which handles the receptor, the note splashes, and the notes (with sustains) for a given player. @@ -708,6 +709,9 @@ class Strumline extends FlxSpriteGroup if (noteSprite != null) { + var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind) ?? this.noteStyle; + noteSprite.setupNoteGraphic(noteKindStyle); + noteSprite.direction = note.getDirection(); noteSprite.noteData = note; @@ -727,6 +731,9 @@ class Strumline extends FlxSpriteGroup if (holdNoteSprite != null) { + var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind) ?? this.noteStyle; + holdNoteSprite.setupHoldNoteGraphic(noteKindStyle); + holdNoteSprite.parentStrumline = this; holdNoteSprite.noteData = note; holdNoteSprite.strumTime = note.time; diff --git a/source/funkin/play/notes/SustainTrail.hx b/source/funkin/play/notes/SustainTrail.hx index f6d43b33f..570c05190 100644 --- a/source/funkin/play/notes/SustainTrail.hx +++ b/source/funkin/play/notes/SustainTrail.hx @@ -99,7 +99,27 @@ class SustainTrail extends FlxSprite */ public function new(noteDirection:NoteDirection, sustainLength:Float, noteStyle:NoteStyle) { - super(0, 0, noteStyle.getHoldNoteAssetPath()); + super(0, 0); + + // BASIC SETUP + this.sustainLength = sustainLength; + this.fullSustainLength = sustainLength; + this.noteDirection = noteDirection; + + setupHoldNoteGraphic(noteStyle); + + indices = new DrawData(12, true, TRIANGLE_VERTEX_INDICES); + + this.active = true; // This NEEDS to be true for the note to be drawn! + } + + /** + * Creates hold note graphic and applies correct zooming + * @param noteStyle The note style + */ + public function setupHoldNoteGraphic(noteStyle:NoteStyle):Void + { + loadGraphic(noteStyle.getHoldNoteAssetPath()); antialiasing = true; @@ -109,13 +129,9 @@ class SustainTrail extends FlxSprite endOffset = bottomClip = 1; antialiasing = false; } + + zoom = 1.0; zoom *= noteStyle.fetchHoldNoteScale(); - - // BASIC SETUP - this.sustainLength = sustainLength; - this.fullSustainLength = sustainLength; - this.noteDirection = noteDirection; - zoom *= 0.7; // CALCULATE SIZE @@ -131,9 +147,6 @@ class SustainTrail extends FlxSprite updateColorTransform(); updateClipping(); - indices = new DrawData(12, true, TRIANGLE_VERTEX_INDICES); - - this.active = true; // This NEEDS to be true for the note to be drawn! } function getBaseScrollSpeed() @@ -195,6 +208,11 @@ class SustainTrail extends FlxSprite */ public function updateClipping(songTime:Float = 0):Void { + if (graphic == null) + { + return; + } + var clipHeight:Float = FlxMath.bound(sustainHeight(sustainLength - (songTime - strumTime), parentStrumline?.scrollSpeed ?? 1.0), 0, graphicHeight); if (clipHeight <= 0.1) { diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 262660eea..53393623a 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -1,7 +1,5 @@ package funkin.play.notes.notekind; -import funkin.data.notestyle.NoteStyleRegistry; -import funkin.play.notes.notestyle.NoteStyle; import funkin.modding.IScriptedClass.INoteScriptedClass; import funkin.modding.events.ScriptEvent; @@ -11,19 +9,25 @@ import funkin.modding.events.ScriptEvent; class NoteKind implements INoteScriptedClass { /** - * the name of the note kind + * The name of the note kind */ public var noteKind:String; /** - * description used in chart editor + * Description used in chart editor */ - public var description:String = ""; + public var description:String; - public function new(noteKind:String, description:String = "") + /** + * Custom note style + */ + public var noteStyleId:String; + + public function new(noteKind:String, description:String = "", noteStyleId:String = "") { this.noteKind = noteKind; this.description = description; + this.noteStyleId = noteStyleId; } public function toString():String @@ -31,23 +35,6 @@ class NoteKind implements INoteScriptedClass return noteKind; } - /** - * Changes the note style of the given note. Use this in `onNoteIncoming` - * @param note - * @param noteStyle - */ - function setNoteStyle(note:NoteSprite, noteStyleId:String):Void - { - var noteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyleId); - noteStyle.buildNoteSprite(note); - - note.setGraphicSize(Strumline.STRUMLINE_SIZE); - note.updateHitbox(); - - // this calls the setter for playing the correct animation - note.direction = note.direction; - } - /** * Retrieve all notes of this kind * @return Array diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 6efd601c7..849034fc4 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -3,6 +3,8 @@ package funkin.play.notes.notekind; import funkin.modding.events.ScriptEventDispatcher; import funkin.modding.events.ScriptEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; +import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.notes.notestyle.NoteStyle; class NoteKindManager { @@ -44,7 +46,7 @@ class NoteKindManager { var noteEvent:NoteScriptEvent = cast(event, NoteScriptEvent); - var noteKind:NoteKind = noteKinds.get(noteEvent.note.noteData.kind); + var noteKind:NoteKind = noteKinds.get(noteEvent.note.kind); if (noteKind != null) { @@ -59,4 +61,16 @@ class NoteKindManager } } } + + /** + * Retrieve the note style from the given note kind + * @param noteKind note kind name + * @return NoteStyle + */ + public static function getNoteStyle(noteKind:String):Null + { + var noteStyleId:String = noteKinds.get(noteKind)?.noteStyleId ?? ""; + + return NoteStyleRegistry.instance.fetchEntry(noteStyleId); + } } From ca69e7b850332e0aa4a35574566867cca649cdbf Mon Sep 17 00:00:00 2001 From: lemz Date: Sun, 2 Jun 2024 02:44:16 +0200 Subject: [PATCH 10/38] custom note styles in chart editor --- .../ui/debug/charting/ChartEditorState.hx | 2 + .../components/ChartEditorNoteSprite.hx | 106 ++++++++++-------- .../toolboxes/ChartEditorNoteDataToolbox.hx | 5 + 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index f72cca77f..0117d8a51 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1663,6 +1663,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState return currentSongMetadata.playData.characters.instrumental = value; } + var currentCustomNoteKindStyle:Null; + /** * HAXEUI COMPONENTS */ diff --git a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx index 98f5a47aa..c97aee1f8 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx @@ -7,7 +7,11 @@ import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxFrame; import flixel.graphics.frames.FlxTileFrames; import flixel.math.FlxPoint; +import funkin.data.animation.AnimationData; import funkin.data.song.SongData.SongNoteData; +import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.notes.notestyle.NoteStyle; +import funkin.play.notes.NoteDirection; /** * A sprite that can be used to display a note in a chart. @@ -68,68 +72,62 @@ class ChartEditorNoteSprite extends FlxSprite if (noteFrameCollection == null) { - initFrameCollection(); + buildEmptyFrameCollection(); + + addNoteStyleFrames(fetchNoteStyle('funkin')); + addNoteStyleFrames(fetchNoteStyle('pixel')); } if (noteFrameCollection == null) throw 'ERROR: Could not initialize note sprite animations.'; this.frames = noteFrameCollection; - // Initialize all the animations, not just the one we're going to use immediately, - // so that later we can reuse the sprite without having to initialize more animations during scrolling. - this.animation.addByPrefix('tapLeftFunkin', 'purple instance'); - this.animation.addByPrefix('tapDownFunkin', 'blue instance'); - this.animation.addByPrefix('tapUpFunkin', 'green instance'); - this.animation.addByPrefix('tapRightFunkin', 'red instance'); - - this.animation.addByPrefix('holdLeftFunkin', 'LeftHoldPiece'); - this.animation.addByPrefix('holdDownFunkin', 'DownHoldPiece'); - this.animation.addByPrefix('holdUpFunkin', 'UpHoldPiece'); - this.animation.addByPrefix('holdRightFunkin', 'RightHoldPiece'); - - this.animation.addByPrefix('holdEndLeftFunkin', 'LeftHoldEnd'); - this.animation.addByPrefix('holdEndDownFunkin', 'DownHoldEnd'); - this.animation.addByPrefix('holdEndUpFunkin', 'UpHoldEnd'); - this.animation.addByPrefix('holdEndRightFunkin', 'RightHoldEnd'); - - this.animation.addByPrefix('tapLeftPixel', 'pixel4'); - this.animation.addByPrefix('tapDownPixel', 'pixel5'); - this.animation.addByPrefix('tapUpPixel', 'pixel6'); - this.animation.addByPrefix('tapRightPixel', 'pixel7'); + addNoteStyleAnimations(fetchNoteStyle('funkin')); + addNoteStyleAnimations(fetchNoteStyle('pixel')); } static var noteFrameCollection:Null = null; - /** - * We load all the note frames once, then reuse them. - */ - static function initFrameCollection():Void + function fetchNoteStyle(noteStyleId:String):NoteStyle { - buildEmptyFrameCollection(); - if (noteFrameCollection == null) return; + return NoteStyleRegistry.instance.fetchEntry(noteStyleId) ?? NoteStyleRegistry.instance.fetchDefault(); + } - // TODO: Automatically iterate over the list of note skins. + @:access(funkin.play.notes.notestyle.NoteStyle) + @:nullSafety(Off) + static function addNoteStyleFrames(noteStyle:NoteStyle):Void + { + var prefix:String = noteStyle.id.toTitleCase(); - // Normal notes - var frameCollectionNormal:FlxAtlasFrames = Paths.getSparrowAtlas('NOTE_assets'); - - for (frame in frameCollectionNormal.frames) + var frameCollection:FlxAtlasFrames = Paths.getSparrowAtlas(noteStyle.getNoteAssetPath(), noteStyle.getNoteAssetLibrary()); + for (frame in frameCollection.frames) { - noteFrameCollection.pushFrame(frame); + // cloning the frame because else + // we will fuck up the frame data used in game + var clonedFrame:FlxFrame = frame.copyTo(); + clonedFrame.name = '$prefix${clonedFrame.name}'; + noteFrameCollection.pushFrame(clonedFrame); } + } - // Pixel notes - var graphicPixel = FlxG.bitmap.add(Paths.image('weeb/pixelUI/arrows-pixels', 'week6'), false, null); - if (graphicPixel == null) trace('ERROR: Could not load graphic: ' + Paths.image('weeb/pixelUI/arrows-pixels', 'week6')); - var frameCollectionPixel = FlxTileFrames.fromGraphic(graphicPixel, new FlxPoint(17, 17)); - for (i in 0...frameCollectionPixel.frames.length) - { - var frame:Null = frameCollectionPixel.frames[i]; - if (frame == null) continue; + @:access(funkin.play.notes.notestyle.NoteStyle) + @:nullSafety(Off) + function addNoteStyleAnimations(noteStyle:NoteStyle):Void + { + var prefix:String = noteStyle.id.toTitleCase(); + var suffix:String = noteStyle.id.toTitleCase(); - frame.name = 'pixel' + i; - noteFrameCollection.pushFrame(frame); - } + var leftData:AnimationData = noteStyle.fetchNoteAnimationData(NoteDirection.LEFT); + this.animation.addByPrefix('tapLeft$suffix', '$prefix${leftData.prefix}', leftData.frameRate, leftData.looped, leftData.flipX, leftData.flipY); + + var downData:AnimationData = noteStyle.fetchNoteAnimationData(NoteDirection.DOWN); + this.animation.addByPrefix('tapDown$suffix', '$prefix${downData.prefix}', downData.frameRate, downData.looped, downData.flipX, downData.flipY); + + var upData:AnimationData = noteStyle.fetchNoteAnimationData(NoteDirection.UP); + this.animation.addByPrefix('tapUp$suffix', '$prefix${upData.prefix}', upData.frameRate, upData.looped, upData.flipX, upData.flipY); + + var rightData:AnimationData = noteStyle.fetchNoteAnimationData(NoteDirection.RIGHT); + this.animation.addByPrefix('tapRight$suffix', '$prefix${rightData.prefix}', rightData.frameRate, rightData.looped, rightData.flipX, rightData.flipY); } @:nullSafety(Off) @@ -187,10 +185,20 @@ class ChartEditorNoteSprite extends FlxSprite function get_noteStyle():String { - // Fall back to Funkin' if it's not a valid note style. - return if (NOTE_STYLES.contains(this.parentState.currentSongNoteStyle)) this.parentState.currentSongNoteStyle else 'funkin'; + if (this.parentState.currentCustomNoteKindStyle != null) + { + return this.parentState.currentCustomNoteKindStyle; + } + + if (NOTE_STYLES.contains(this.parentState.currentSongNoteStyle)) + { + return this.parentState.currentSongNoteStyle; + } + + return 'funkin'; } + @:nullSafety(Off) public function playNoteAnimation():Void { if (this.noteData == null) return; @@ -213,8 +221,8 @@ class ChartEditorNoteSprite extends FlxSprite } this.updateHitbox(); - // TODO: Make this an attribute of the note skin. - this.antialiasing = (this.parentState.currentSongNoteStyle != 'Pixel'); + var bruhStyle:NoteStyle = fetchNoteStyle(this.noteStyle); + this.antialiasing = !bruhStyle._data?.assets?.note?.isPixel ?? true; } /** diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index d4fc69fc1..952513f0e 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -4,6 +4,8 @@ import haxe.ui.components.DropDown; import haxe.ui.components.TextField; import haxe.ui.events.UIEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; +import funkin.play.notes.notestyle.NoteStyle; +import funkin.play.notes.notekind.NoteKindManager; /** * The toolbox which allows modifying information like Note Kind. @@ -73,6 +75,9 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox var customKind:Null = event?.target?.text; chartEditorState.noteKindToPlace = customKind; + var noteStyle:Null = NoteKindManager.getNoteStyle(customKind); + chartEditorState.currentCustomNoteKindStyle = noteStyle?.id; + if (chartEditorState.currentEventSelection.length > 0) { // Edit the note data of any selected notes. From 9d7846a0d551a005897f1ea0ca099d19f4ac359f Mon Sep 17 00:00:00 2001 From: lemz Date: Sun, 2 Jun 2024 02:58:56 +0200 Subject: [PATCH 11/38] loop through all note style entries --- .../charting/components/ChartEditorNoteSprite.hx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx index c97aee1f8..6517b61c2 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx @@ -70,20 +70,26 @@ class ChartEditorNoteSprite extends FlxSprite this.parentState = parent; + var entries:Array = NoteStyleRegistry.instance.listEntryIds(); + if (noteFrameCollection == null) { buildEmptyFrameCollection(); - addNoteStyleFrames(fetchNoteStyle('funkin')); - addNoteStyleFrames(fetchNoteStyle('pixel')); + for (entry in entries) + { + addNoteStyleFrames(fetchNoteStyle(entry)); + } } if (noteFrameCollection == null) throw 'ERROR: Could not initialize note sprite animations.'; this.frames = noteFrameCollection; - addNoteStyleAnimations(fetchNoteStyle('funkin')); - addNoteStyleAnimations(fetchNoteStyle('pixel')); + for (entry in entries) + { + addNoteStyleAnimations(fetchNoteStyle(entry)); + } } static var noteFrameCollection:Null = null; From ca2cbb44f520361b73c60378e0beaf0459e308c2 Mon Sep 17 00:00:00 2001 From: lemz Date: Sun, 2 Jun 2024 22:11:17 +0200 Subject: [PATCH 12/38] display custom note style in chart editor --- .../play/notes/notekind/NoteKindManager.hx | 10 ++++++ .../ui/debug/charting/ChartEditorState.hx | 10 ++++-- .../components/ChartEditorHoldNoteSprite.hx | 34 +++++++++++++++++++ .../components/ChartEditorNoteSprite.hx | 22 ++++++------ .../toolboxes/ChartEditorNoteDataToolbox.hx | 3 -- 5 files changed, 61 insertions(+), 18 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 849034fc4..82b2c4d39 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -73,4 +73,14 @@ class NoteKindManager return NoteStyleRegistry.instance.fetchEntry(noteStyleId); } + + /** + * Retrieve the note style id from the given note kind + * @param noteKind note kind name + * @return Null + */ + public static function getNoteStyleId(noteKind:String):Null + { + return noteKinds.get(noteKind)?.noteStyleId; + } } diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 0117d8a51..bc0acc6d6 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -45,6 +45,7 @@ import funkin.input.TurboActionHandler; import funkin.input.TurboButtonHandler; import funkin.input.TurboKeyHandler; import funkin.modding.events.ScriptEvent; +import funkin.play.notes.notekind.NoteKindManager; import funkin.play.character.BaseCharacter.CharacterType; import funkin.play.character.CharacterData; import funkin.play.character.CharacterData.CharacterDataParser; @@ -1663,8 +1664,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState return currentSongMetadata.playData.characters.instrumental = value; } - var currentCustomNoteKindStyle:Null; - /** * HAXEUI COMPONENTS */ @@ -3586,6 +3585,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // The note sprite handles animation playback and positioning. noteSprite.noteData = noteData; + noteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind) ?? currentSongNoteStyle; noteSprite.overrideStepTime = null; noteSprite.overrideData = null; @@ -3606,6 +3606,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState holdNoteSprite.noteData = noteSprite.noteData; holdNoteSprite.noteDirection = noteSprite.noteData.getDirection(); + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteSprite.noteData.kind) ?? currentSongNoteStyle; holdNoteSprite.setHeightDirectly(noteLengthPixels); @@ -3671,7 +3672,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState holdNoteSprite.noteData = noteData; holdNoteSprite.noteDirection = noteData.getDirection(); - + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind) ?? currentSongNoteStyle; holdNoteSprite.setHeightDirectly(noteLengthPixels); holdNoteSprite.updateHoldNotePosition(renderedHoldNotes); @@ -4570,6 +4571,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState gridGhostHoldNote.visible = true; gridGhostHoldNote.noteData = currentPlaceNoteData; gridGhostHoldNote.noteDirection = currentPlaceNoteData.getDirection(); + gridGhostHoldNote.noteStyle = NoteKindManager.getNoteStyleId(currentPlaceNoteData.kind) ?? currentSongNoteStyle; gridGhostHoldNote.setHeightDirectly(dragLengthPixels, true); gridGhostHoldNote.updateHoldNotePosition(renderedHoldNotes); @@ -4893,6 +4895,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { noteData.kind = noteKindToPlace; noteData.data = cursorColumn; + gridGhostNote.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind) ?? currentSongNoteStyle; gridGhostNote.playNoteAnimation(); } noteData.time = cursorSnappedMs; @@ -5281,6 +5284,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // Readd the new ghost hold note. ghostHold.noteData = targetNoteData.clone(); ghostHold.noteDirection = ghostHold.noteData.getDirection(); + ghostHold.noteStyle = NoteKindManager.getNoteStyleId(ghostHold.noteData.kind) ?? currentSongNoteStyle; ghostHold.visible = true; ghostHold.alpha = 0.6; ghostHold.setHeightDirectly(0); diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index ded48abe3..ccf462c56 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -2,6 +2,7 @@ package funkin.ui.debug.charting.components; import funkin.play.notes.Strumline; import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.notes.notestyle.NoteStyle; import flixel.FlxObject; import flixel.FlxSprite; import flixel.graphics.frames.FlxFramesCollection; @@ -15,6 +16,7 @@ import flixel.math.FlxMath; * A sprite that can be used to display the trail of a hold note in a chart. * Designed to be used and reused efficiently. Has no gameplay functionality. */ +@:access(funkin.ui.debug.charting.ChartEditorState) @:nullSafety class ChartEditorHoldNoteSprite extends SustainTrail { @@ -23,6 +25,22 @@ class ChartEditorHoldNoteSprite extends SustainTrail */ public var parentState:ChartEditorState; + @:isVar + public var noteStyle(get, set):Null; + + function get_noteStyle():Null + { + return this.noteStyle ?? this.parentState.currentSongNoteStyle; + } + + @:nullSafety(Off) + function set_noteStyle(value:Null):Null + { + this.noteStyle = value; + this.updateHoldNoteGraphic(); + return value; + } + public function new(parent:ChartEditorState) { var noteStyle = NoteStyleRegistry.instance.fetchDefault(); @@ -41,6 +59,22 @@ class ChartEditorHoldNoteSprite extends SustainTrail setup(); } + @:nullSafety(Off) + function updateHoldNoteGraphic():Void + { + var bruhStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle); + this.setupHoldNoteGraphic(bruhStyle); + + zoom = 1.0; + zoom *= bruhStyle.fetchHoldNoteScale(); + zoom *= 0.7; + zoom *= ChartEditorState.GRID_SIZE / Strumline.STRUMLINE_SIZE; + + flipY = false; + + setup(); + } + public override function updateHitbox():Void { // Expand the clickable hitbox to the full column width, then nudge to the left to re-center it. diff --git a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx index 6517b61c2..009532401 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx @@ -40,7 +40,8 @@ class ChartEditorNoteSprite extends FlxSprite /** * The name of the note style currently in use. */ - public var noteStyle(get, never):String; + @:isVar + public var noteStyle(get, set):Null; public var overrideStepTime(default, set):Null = null; @@ -189,19 +190,16 @@ class ChartEditorNoteSprite extends FlxSprite } } - function get_noteStyle():String + function get_noteStyle():Null { - if (this.parentState.currentCustomNoteKindStyle != null) - { - return this.parentState.currentCustomNoteKindStyle; - } + return this.noteStyle ?? this.parentState.currentSongNoteStyle; + } - if (NOTE_STYLES.contains(this.parentState.currentSongNoteStyle)) - { - return this.parentState.currentSongNoteStyle; - } - - return 'funkin'; + function set_noteStyle(value:Null):Null + { + this.noteStyle = value; + this.playNoteAnimation(); + return value; } @:nullSafety(Off) diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index 952513f0e..f1223eb9c 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -75,9 +75,6 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox var customKind:Null = event?.target?.text; chartEditorState.noteKindToPlace = customKind; - var noteStyle:Null = NoteKindManager.getNoteStyle(customKind); - chartEditorState.currentCustomNoteKindStyle = noteStyle?.id; - if (chartEditorState.currentEventSelection.length > 0) { // Edit the note data of any selected notes. From 040fc85a6263408646e6cac60c1a25da2c99fcaf Mon Sep 17 00:00:00 2001 From: lemz Date: Sun, 2 Jun 2024 23:31:49 +0200 Subject: [PATCH 13/38] change note style on change --- .../components/ChartEditorHoldNoteSprite.hx | 2 +- .../toolboxes/ChartEditorNoteDataToolbox.hx | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index ccf462c56..26322c6f9 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -63,7 +63,7 @@ class ChartEditorHoldNoteSprite extends SustainTrail function updateHoldNoteGraphic():Void { var bruhStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle); - this.setupHoldNoteGraphic(bruhStyle); + setupHoldNoteGraphic(bruhStyle); zoom = 1.0; zoom *= bruhStyle.fetchHoldNoteScale(); diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index f1223eb9c..d872eda38 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -4,6 +4,8 @@ import haxe.ui.components.DropDown; import haxe.ui.components.TextField; import haxe.ui.events.UIEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; +import funkin.ui.debug.charting.components.ChartEditorNoteSprite; +import funkin.ui.debug.charting.components.ChartEditorHoldNoteSprite; import funkin.play.notes.notestyle.NoteStyle; import funkin.play.notes.notekind.NoteKindManager; @@ -59,8 +61,32 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox if (!_initializing && chartEditorState.currentNoteSelection.length > 0) { // Edit the note data of any selected notes. + var noteSprites:Array = chartEditorState.renderedNotes.members.copy(); + var holdNoteSprites:Array = chartEditorState.renderedHoldNotes.members.copy(); for (note in chartEditorState.currentNoteSelection) { + // update note sprites + for (noteSprite in noteSprites) + { + if (noteSprite.noteData == note) + { + noteSprite.noteStyle = NoteKindManager.getNoteStyleId(chartEditorState.noteKindToPlace) ?? chartEditorState.currentSongNoteStyle; + noteSprites.remove(noteSprite); + break; + } + } + + // update hold note sprites + for (holdNoteSprite in holdNoteSprites) + { + if (holdNoteSprite.noteData == note) + { + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(chartEditorState.noteKindToPlace) ?? chartEditorState.currentSongNoteStyle; + holdNoteSprites.remove(holdNoteSprite); + break; + } + } + note.kind = chartEditorState.noteKindToPlace; } chartEditorState.saveDataDirty = true; From bb975491712445a272f5e8817e34dacbd62a0d03 Mon Sep 17 00:00:00 2001 From: lemz Date: Mon, 3 Jun 2024 00:03:47 +0200 Subject: [PATCH 14/38] fixed a bit --- .../ui/debug/charting/ChartEditorState.hx | 11 ++++++----- .../components/ChartEditorHoldNoteSprite.hx | 2 ++ .../toolboxes/ChartEditorNoteDataToolbox.hx | 18 +++++++----------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index bc0acc6d6..c867ddfd2 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -3606,10 +3606,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState holdNoteSprite.noteData = noteSprite.noteData; holdNoteSprite.noteDirection = noteSprite.noteData.getDirection(); - holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteSprite.noteData.kind) ?? currentSongNoteStyle; holdNoteSprite.setHeightDirectly(noteLengthPixels); + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteSprite.noteData.kind) ?? currentSongNoteStyle; + holdNoteSprite.updateHoldNotePosition(renderedHoldNotes); trace(holdNoteSprite.x + ', ' + holdNoteSprite.y + ', ' + holdNoteSprite.width + ', ' + holdNoteSprite.height); @@ -3672,9 +3673,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState holdNoteSprite.noteData = noteData; holdNoteSprite.noteDirection = noteData.getDirection(); - holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind) ?? currentSongNoteStyle; holdNoteSprite.setHeightDirectly(noteLengthPixels); + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind) ?? currentSongNoteStyle; + holdNoteSprite.updateHoldNotePosition(renderedHoldNotes); displayedHoldNoteData.push(noteData); @@ -4571,9 +4573,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState gridGhostHoldNote.visible = true; gridGhostHoldNote.noteData = currentPlaceNoteData; gridGhostHoldNote.noteDirection = currentPlaceNoteData.getDirection(); - gridGhostHoldNote.noteStyle = NoteKindManager.getNoteStyleId(currentPlaceNoteData.kind) ?? currentSongNoteStyle; gridGhostHoldNote.setHeightDirectly(dragLengthPixels, true); - + gridGhostHoldNote.noteStyle = NoteKindManager.getNoteStyleId(currentPlaceNoteData.kind) ?? currentSongNoteStyle; gridGhostHoldNote.updateHoldNotePosition(renderedHoldNotes); } else @@ -5284,10 +5285,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // Readd the new ghost hold note. ghostHold.noteData = targetNoteData.clone(); ghostHold.noteDirection = ghostHold.noteData.getDirection(); - ghostHold.noteStyle = NoteKindManager.getNoteStyleId(ghostHold.noteData.kind) ?? currentSongNoteStyle; ghostHold.visible = true; ghostHold.alpha = 0.6; ghostHold.setHeightDirectly(0); + ghostHold.noteStyle = NoteKindManager.getNoteStyleId(ghostHold.noteData.kind) ?? currentSongNoteStyle; ghostHold.updateHoldNotePosition(renderedHoldNotes); } diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index 26322c6f9..e8ca991b6 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -73,6 +73,8 @@ class ChartEditorHoldNoteSprite extends SustainTrail flipY = false; setup(); + + triggerRedraw(); } public override function updateHitbox():Void diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index d872eda38..531bce255 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -60,34 +60,30 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox if (!_initializing && chartEditorState.currentNoteSelection.length > 0) { - // Edit the note data of any selected notes. - var noteSprites:Array = chartEditorState.renderedNotes.members.copy(); - var holdNoteSprites:Array = chartEditorState.renderedHoldNotes.members.copy(); for (note in chartEditorState.currentNoteSelection) { + // Edit the note data of any selected notes. + note.kind = chartEditorState.noteKindToPlace; + // update note sprites - for (noteSprite in noteSprites) + for (noteSprite in chartEditorState.renderedNotes.members) { if (noteSprite.noteData == note) { - noteSprite.noteStyle = NoteKindManager.getNoteStyleId(chartEditorState.noteKindToPlace) ?? chartEditorState.currentSongNoteStyle; - noteSprites.remove(noteSprite); + noteSprite.noteStyle = NoteKindManager.getNoteStyleId(note.kind) ?? chartEditorState.currentSongNoteStyle; break; } } // update hold note sprites - for (holdNoteSprite in holdNoteSprites) + for (holdNoteSprite in chartEditorState.renderedHoldNotes.members) { if (holdNoteSprite.noteData == note) { - holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(chartEditorState.noteKindToPlace) ?? chartEditorState.currentSongNoteStyle; - holdNoteSprites.remove(holdNoteSprite); + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(note.kind) ?? chartEditorState.currentSongNoteStyle; break; } } - - note.kind = chartEditorState.noteKindToPlace; } chartEditorState.saveDataDirty = true; chartEditorState.noteDisplayDirty = true; From 49d302be956edb19d470ccfdee3792d3fcdae324 Mon Sep 17 00:00:00 2001 From: lemz Date: Wed, 5 Jun 2024 19:47:34 +0200 Subject: [PATCH 15/38] make code a bit simpler --- .../components/ChartEditorHoldNoteSprite.hx | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index e8ca991b6..e474ee93d 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -48,15 +48,6 @@ class ChartEditorHoldNoteSprite extends SustainTrail super(0, 100, noteStyle); this.parentState = parent; - - zoom = 1.0; - zoom *= noteStyle.fetchHoldNoteScale(); - zoom *= 0.7; - zoom *= ChartEditorState.GRID_SIZE / Strumline.STRUMLINE_SIZE; - - flipY = false; - - setup(); } @:nullSafety(Off) @@ -64,17 +55,38 @@ class ChartEditorHoldNoteSprite extends SustainTrail { var bruhStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle); setupHoldNoteGraphic(bruhStyle); + } + + override function setupHoldNoteGraphic(noteStyle:NoteStyle):Void + { + loadGraphic(noteStyle.getHoldNoteAssetPath()); + + antialiasing = true; + + this.isPixel = noteStyle.isHoldNotePixel(); + if (isPixel) + { + endOffset = bottomClip = 1; + antialiasing = false; + } zoom = 1.0; - zoom *= bruhStyle.fetchHoldNoteScale(); + zoom *= noteStyle.fetchHoldNoteScale(); zoom *= 0.7; zoom *= ChartEditorState.GRID_SIZE / Strumline.STRUMLINE_SIZE; + graphicWidth = graphic.width / 8 * zoom; // amount of notes * 2 + graphicHeight = sustainLength * 0.45; // sustainHeight + flipY = false; - setup(); + alpha = 1.0; - triggerRedraw(); + updateColorTransform(); + + updateClipping(); + + setup(); } public override function updateHitbox():Void From c4855c0ca8e6e77d62b32b705c40ab0a0e106c11 Mon Sep 17 00:00:00 2001 From: lemz Date: Tue, 11 Jun 2024 20:52:08 +0200 Subject: [PATCH 16/38] fix hold note --- source/funkin/play/notes/SustainTrail.hx | 5 +++++ .../debug/charting/components/ChartEditorHoldNoteSprite.hx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/source/funkin/play/notes/SustainTrail.hx b/source/funkin/play/notes/SustainTrail.hx index 570c05190..90b36b009 100644 --- a/source/funkin/play/notes/SustainTrail.hx +++ b/source/funkin/play/notes/SustainTrail.hx @@ -129,6 +129,11 @@ class SustainTrail extends FlxSprite endOffset = bottomClip = 1; antialiasing = false; } + else + { + endOffset = 0.5; + bottomClip = 0.9; + } zoom = 1.0; zoom *= noteStyle.fetchHoldNoteScale(); diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index e474ee93d..b8d6ee22e 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -69,6 +69,11 @@ class ChartEditorHoldNoteSprite extends SustainTrail endOffset = bottomClip = 1; antialiasing = false; } + else + { + endOffset = 0.5; + bottomClip = 0.9; + } zoom = 1.0; zoom *= noteStyle.fetchHoldNoteScale(); From 928de7b8eb8861878b2e78a3502a8ee64b2784d9 Mon Sep 17 00:00:00 2001 From: lemz Date: Tue, 11 Jun 2024 23:45:08 +0200 Subject: [PATCH 17/38] check for pixel style if necessary --- source/funkin/play/notes/Strumline.hx | 4 ++-- source/funkin/play/notes/notekind/NoteKind.hx | 4 ++-- .../play/notes/notekind/NoteKindManager.hx | 21 +++++++++++++++---- .../ui/debug/charting/ChartEditorState.hx | 17 +++++++++------ 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index ebc48a8c7..86b7a3ee1 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -709,7 +709,7 @@ class Strumline extends FlxSpriteGroup if (noteSprite != null) { - var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind) ?? this.noteStyle; + var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind, this.noteStyle.isHoldNotePixel()) ?? this.noteStyle; noteSprite.setupNoteGraphic(noteKindStyle); noteSprite.direction = note.getDirection(); @@ -731,7 +731,7 @@ class Strumline extends FlxSpriteGroup if (holdNoteSprite != null) { - var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind) ?? this.noteStyle; + var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind, this.noteStyle.isHoldNotePixel()) ?? this.noteStyle; holdNoteSprite.setupHoldNoteGraphic(noteKindStyle); holdNoteSprite.parentStrumline = this; diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 53393623a..6d7bad77f 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -21,9 +21,9 @@ class NoteKind implements INoteScriptedClass /** * Custom note style */ - public var noteStyleId:String; + public var noteStyleId:Null; - public function new(noteKind:String, description:String = "", noteStyleId:String = "") + public function new(noteKind:String, description:String = "", ?noteStyleId:String) { this.noteKind = noteKind; this.description = description; diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 82b2c4d39..110e1859b 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -65,11 +65,17 @@ class NoteKindManager /** * Retrieve the note style from the given note kind * @param noteKind note kind name + * @param isPixel whether to use pixel style * @return NoteStyle */ - public static function getNoteStyle(noteKind:String):Null + public static function getNoteStyle(noteKind:String, isPixel:Bool = false):Null { - var noteStyleId:String = noteKinds.get(noteKind)?.noteStyleId ?? ""; + var noteStyleId:Null = getNoteStyleId(noteKind, isPixel); + + if (noteStyleId == null) + { + return null; + } return NoteStyleRegistry.instance.fetchEntry(noteStyleId); } @@ -77,10 +83,17 @@ class NoteKindManager /** * Retrieve the note style id from the given note kind * @param noteKind note kind name + * @param isPixel whether to use pixel style * @return Null */ - public static function getNoteStyleId(noteKind:String):Null + public static function getNoteStyleId(noteKind:String, isPixel:Bool = false):Null { - return noteKinds.get(noteKind)?.noteStyleId; + var noteStyleId:Null = noteKinds.get(noteKind)?.noteStyleId; + if (isPixel && noteStyleId != null) + { + noteStyleId = NoteStyleRegistry.instance.hasEntry('$noteStyleId-pixel') ? '$noteStyleId-pixel' : noteStyleId; + } + + return noteStyleId; } } diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index c867ddfd2..2a07be52d 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -3585,7 +3585,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // The note sprite handles animation playback and positioning. noteSprite.noteData = noteData; - noteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind) ?? currentSongNoteStyle; + noteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; noteSprite.overrideStepTime = null; noteSprite.overrideData = null; @@ -3609,7 +3609,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState holdNoteSprite.setHeightDirectly(noteLengthPixels); - holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteSprite.noteData.kind) ?? currentSongNoteStyle; + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteSprite.noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; holdNoteSprite.updateHoldNotePosition(renderedHoldNotes); @@ -3675,7 +3675,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState holdNoteSprite.noteDirection = noteData.getDirection(); holdNoteSprite.setHeightDirectly(noteLengthPixels); - holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind) ?? currentSongNoteStyle; + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; holdNoteSprite.updateHoldNotePosition(renderedHoldNotes); @@ -4574,7 +4574,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState gridGhostHoldNote.noteData = currentPlaceNoteData; gridGhostHoldNote.noteDirection = currentPlaceNoteData.getDirection(); gridGhostHoldNote.setHeightDirectly(dragLengthPixels, true); - gridGhostHoldNote.noteStyle = NoteKindManager.getNoteStyleId(currentPlaceNoteData.kind) ?? currentSongNoteStyle; + gridGhostHoldNote.noteStyle = NoteKindManager.getNoteStyleId(currentPlaceNoteData.kind, isPixelStyle()) ?? currentSongNoteStyle; gridGhostHoldNote.updateHoldNotePosition(renderedHoldNotes); } else @@ -4896,7 +4896,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { noteData.kind = noteKindToPlace; noteData.data = cursorColumn; - gridGhostNote.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind) ?? currentSongNoteStyle; + gridGhostNote.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; gridGhostNote.playNoteAnimation(); } noteData.time = cursorSnappedMs; @@ -5288,7 +5288,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState ghostHold.visible = true; ghostHold.alpha = 0.6; ghostHold.setHeightDirectly(0); - ghostHold.noteStyle = NoteKindManager.getNoteStyleId(ghostHold.noteData.kind) ?? currentSongNoteStyle; + ghostHold.noteStyle = NoteKindManager.getNoteStyleId(ghostHold.noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; ghostHold.updateHoldNotePosition(renderedHoldNotes); } @@ -6413,6 +6413,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState return note != null && currentNoteSelection.indexOf(note) != -1; } + function isPixelStyle():Bool + { + return currentSongNoteStyle == 'pixel'; + } + override function destroy():Void { super.destroy(); From 7a0c7ade357a7e6151295b182650dd807e52390f Mon Sep 17 00:00:00 2001 From: lemz Date: Tue, 11 Jun 2024 23:48:05 +0200 Subject: [PATCH 18/38] Update ChartEditorDropdowns.hx --- source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx index f20b75650..65ec2a0c3 100644 --- a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx +++ b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx @@ -126,7 +126,10 @@ class ChartEditorDropdowns { dropDown.dataSource.clear(); - var noteStyleIds:Array = NoteStyleRegistry.instance.listEntryIds(); + // hardcoding this because i dont want note kind styles to be shown as well + // there is probably a better solution + // var noteStyleIds:Array = NoteStyleRegistry.instance.listEntryIds(); + var noteStyleIds:Array = ['funkin', 'pixel']; var returnValue:DropDownEntry = {id: "funkin", text: "Funkin'"}; From fbcc73dceebdcfcba2b14922c6b7c38adae0b086 Mon Sep 17 00:00:00 2001 From: lemz Date: Mon, 17 Jun 2024 17:21:52 +0200 Subject: [PATCH 19/38] unhardcode notestyledropdown --- .../ui/debug/charting/util/ChartEditorDropdowns.hx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx index 65ec2a0c3..6a426c391 100644 --- a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx +++ b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx @@ -126,10 +126,7 @@ class ChartEditorDropdowns { dropDown.dataSource.clear(); - // hardcoding this because i dont want note kind styles to be shown as well - // there is probably a better solution - // var noteStyleIds:Array = NoteStyleRegistry.instance.listEntryIds(); - var noteStyleIds:Array = ['funkin', 'pixel']; + var noteStyleIds:Array = NoteStyleRegistry.instance.listEntryIds(); var returnValue:DropDownEntry = {id: "funkin", text: "Funkin'"}; @@ -138,6 +135,14 @@ class ChartEditorDropdowns var noteStyle:Null = NoteStyleRegistry.instance.fetchEntry(noteStyleId); if (noteStyle == null) continue; + // check if the note style has all necessary assets (strums, notes, holdNotes) + if (noteStyle._data?.assets?.noteStrumline == null + || noteStyle._data?.assets?.note == null + || noteStyle._data?.assets?.holdNote == null) + { + continue; + } + var value = {id: noteStyleId, text: noteStyle.getName()}; if (startingStyleId == noteStyleId) returnValue = value; From acd8912d162d71b3dd11d97e112e64da06815ec9 Mon Sep 17 00:00:00 2001 From: lemz Date: Fri, 21 Jun 2024 23:54:29 +0200 Subject: [PATCH 20/38] Add Custom Params For NoteKind still need to implement the chart editor stuff --- source/funkin/play/notes/notekind/NoteKind.hx | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) 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; +} From c8d019da2fdcc22627dbfb78c587a5374273f6b6 Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 00:20:58 +0200 Subject: [PATCH 21/38] Update NoteKind.hx --- source/funkin/play/notes/notekind/NoteKind.hx | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 6d7ddcd1b..3aa02088b 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -2,6 +2,7 @@ package funkin.play.notes.notekind; import funkin.modding.IScriptedClass.INoteScriptedClass; import funkin.modding.events.ScriptEvent; +import flixel.math.FlxMath; /** * Class for note scripts @@ -42,24 +43,49 @@ class NoteKind implements INoteScriptedClass } /** - * Retrieve the param with the given name + * Retrieve the value of 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 + * @return Null */ - public function getParam(name:String):Null + public function getParam(name:String):Null { for (param in params) { if (param.name == name) { - return param; + return param.data.value; } } return null; } + /** + * Set the value of the param with the given name + * @param name Name of the param + * @param value New value + */ + public function setParam(name:String, value:Dynamic):Void + { + for (param in params) + { + if (param.name == name) + { + if (param.type == NoteKindParamType.RANGED_INT || param.type == NoteKindParamType.RANGED_FLOAT) + { + param.data.value = FlxMath.bound(value, param.data.min, param.data.max); + } + else + { + param.data.value = value; + } + + break; + } + } + } + /** * Retrieve all notes of this kind * @return Array @@ -91,7 +117,7 @@ class NoteKind implements INoteScriptedClass * Abstract for setting the type of the `NoteKindParam` * This was supposed to be an enum but polymod kept being annoying */ -abstract NoteKindParamType(String) +abstract NoteKindParamType(String) to String { public static var STRING:String = "String"; @@ -108,11 +134,13 @@ typedef NoteKindParamData = { /** * Only used for `RangedInt` and `RangedFloat` + * If `min` is null, there is no minimum */ var min:Null; /** * Only used for `RangedInt` and `RangedFloat` + * If `max` is null, there is no maximum */ var max:Null; From 94fe4a06b90089fb8187c177c39cb255c90609fb Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 10:44:12 +0200 Subject: [PATCH 22/38] Update NoteKind.hx --- source/funkin/play/notes/notekind/NoteKind.hx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 3aa02088b..a0f759949 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -72,13 +72,12 @@ class NoteKind implements INoteScriptedClass { if (param.name == name) { - if (param.type == NoteKindParamType.RANGED_INT || param.type == NoteKindParamType.RANGED_FLOAT) + switch (param.type) { - param.data.value = FlxMath.bound(value, param.data.min, param.data.max); - } - else - { - param.data.value = value; + case NoteKindParamType.INT | NoteKindParamType.FLOAT: + param.data.value = FlxMath.bound(value, param.data.min, param.data.max); + default: + param.data.value = value; } break; @@ -123,23 +122,17 @@ abstract NoteKindParamType(String) to 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` * If `min` is null, there is no minimum */ var min:Null; /** - * Only used for `RangedInt` and `RangedFloat` * If `max` is null, there is no maximum */ var max:Null; From 9a563ec46b56e4daacd70f301c1d107347e6738f Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 10:52:26 +0200 Subject: [PATCH 23/38] switch seemingly doesnt work --- source/funkin/play/notes/notekind/NoteKind.hx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index a0f759949..f2a44dc8a 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -72,12 +72,13 @@ class NoteKind implements INoteScriptedClass { if (param.name == name) { - switch (param.type) + if (param.type == NoteKindParamType.INT || param.type == NoteKindParamType.FLOAT) { - case NoteKindParamType.INT | NoteKindParamType.FLOAT: - param.data.value = FlxMath.bound(value, param.data.min, param.data.max); - default: - param.data.value = value; + param.data.value = FlxMath.bound(value, param.data.min, param.data.max); + } + else + { + param.data.value = value; } break; @@ -118,11 +119,11 @@ class NoteKind implements INoteScriptedClass */ abstract NoteKindParamType(String) to String { - public static var STRING:String = "String"; + public static final STRING:String = 'String'; - public static var INT:String = "Int"; + public static final INT:String = 'Int'; - public static var FLOAT:String = "Float"; + public static final FLOAT:String = 'Float'; } typedef NoteKindParamData = From d9b9854d9106d20d2ea7ec75468fcc315b281e98 Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 14:17:07 +0200 Subject: [PATCH 24/38] add params to toolbox not completely finished --- .../play/notes/notekind/NoteKindManager.hx | 10 +++ .../toolboxes/ChartEditorNoteDataToolbox.hx | 73 ++++++++++++++++++- 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 110e1859b..3e2174a66 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -96,4 +96,14 @@ class NoteKindManager return noteStyleId; } + + /** + * Retrive custom params of the given note kind + * @param noteKind Name of the note kind + * @return Array + */ + public static function getParams(noteKind:String):Array + { + return noteKinds.get(noteKind)?.params ?? []; + } } diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index 531bce255..472372a6e 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -2,11 +2,12 @@ package funkin.ui.debug.charting.toolboxes; import haxe.ui.components.DropDown; import haxe.ui.components.TextField; +import haxe.ui.components.Label; +import haxe.ui.components.NumberStepper; +import haxe.ui.containers.Grid; +import haxe.ui.core.Component; import haxe.ui.events.UIEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; -import funkin.ui.debug.charting.components.ChartEditorNoteSprite; -import funkin.ui.debug.charting.components.ChartEditorHoldNoteSprite; -import funkin.play.notes.notestyle.NoteStyle; import funkin.play.notes.notekind.NoteKindManager; /** @@ -16,8 +17,12 @@ import funkin.play.notes.notekind.NoteKindManager; @:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/toolboxes/note-data.xml")) class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox { + static final DIALOG_HEIGHT:Int = 100; + + var toolboxNotesGrid:Grid; var toolboxNotesNoteKind:DropDown; var toolboxNotesCustomKind:TextField; + var toolboxNotesParams:Array = []; var _initializing:Bool = true; @@ -49,6 +54,7 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox if (noteKind == '~CUSTOM~') { showCustom(); + clearNoteKindParams(); toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace; } else @@ -56,6 +62,25 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox hideCustom(); chartEditorState.noteKindToPlace = noteKind; toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace; + + clearNoteKindParams(); + for (param in NoteKindManager.getParams(noteKind)) + { + var paramLabel:Label = new Label(); + paramLabel.value = param.description; + paramLabel.verticalAlign = "center"; + paramLabel.horizontalAlign = "right"; + + var paramStepper:NumberStepper = new NumberStepper(); + paramStepper.min = param.data.min; + paramStepper.max = param.data.max; + paramStepper.value = param.data.value; + paramStepper.precision = 1; + paramStepper.step = 0.1; + paramStepper.percentWidth = 100; + + addNoteKindParam(paramLabel, paramStepper); + } } if (!_initializing && chartEditorState.currentNoteSelection.length > 0) @@ -110,6 +135,9 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox } }; toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace; + + // just to be safe + clearNoteKindParams(); } public override function refresh():Void @@ -132,8 +160,47 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox toolboxNotesCustomKind.hidden = true; } + function addNoteKindParam(label:Label, component:Component):Void + { + toolboxNotesParams.push({label: label, component: component}); + toolboxNotesGrid.addComponent(label); + toolboxNotesGrid.addComponent(component); + + this.height = Math.max(DIALOG_HEIGHT, DIALOG_HEIGHT - 30 + toolboxNotesParams.length * 30); + } + + override function update(elapsed:Float):Void + { + super.update(elapsed); + + // toolboxNotesGrid.height + 45 + // this is what i found out is the calculation by printing this.height and grid.height + var heightToSet:Int = Std.int(Math.max(DIALOG_HEIGHT, toolboxNotesGrid.height + 45)); + if (this.height != heightToSet) + { + this.height = heightToSet; + } + } + + function clearNoteKindParams():Void + { + for (param in toolboxNotesParams) + { + toolboxNotesGrid.removeComponent(param.component); + toolboxNotesGrid.removeComponent(param.label); + } + toolboxNotesParams = []; + this.height = DIALOG_HEIGHT; + } + public static function build(chartEditorState:ChartEditorState):ChartEditorNoteDataToolbox { return new ChartEditorNoteDataToolbox(chartEditorState); } } + +typedef ToolboxNoteKindParam = +{ + var label:Label; + var component:Component; +} From 93475ae8aa94ff5d12872dd5ebe4b1e207d3d85e Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 14:31:07 +0200 Subject: [PATCH 25/38] minimized check --- .../charting/toolboxes/ChartEditorNoteDataToolbox.hx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index 472372a6e..c557eef1f 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -135,9 +135,6 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox } }; toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace; - - // just to be safe - clearNoteKindParams(); } public override function refresh():Void @@ -173,6 +170,12 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox { super.update(elapsed); + // current dialog is minimized, dont change the height + if (this.minimized) + { + return; + } + // toolboxNotesGrid.height + 45 // this is what i found out is the calculation by printing this.height and grid.height var heightToSet:Int = Std.int(Math.max(DIALOG_HEIGHT, toolboxNotesGrid.height + 45)); From 437cc68ba7af70f4060efc739dfc6d3ff21bbeed Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 14:49:04 +0200 Subject: [PATCH 26/38] adapt to minimize problem --- .../toolboxes/ChartEditorNoteDataToolbox.hx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index c557eef1f..278fc1fd6 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -17,8 +17,18 @@ import funkin.play.notes.notekind.NoteKindManager; @:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/toolboxes/note-data.xml")) class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox { + // 100 is the height used in note-data.xml static final DIALOG_HEIGHT:Int = 100; + // toolboxNotesGrid.height + 45 + // this is what i found out by printing this.height and grid.height + // and then seeing that this.height is 100 and grid.height is 55 + static final HEIGHT_OFFSET:Int = 45; + + // minimizing creates a gray bar the bottom, which would obscure the components, + // which is why we use an extra offset of 20 + static final MINIMIZE_FIX:Int = 20; + var toolboxNotesGrid:Grid; var toolboxNotesNoteKind:DropDown; var toolboxNotesCustomKind:TextField; @@ -176,9 +186,7 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox return; } - // toolboxNotesGrid.height + 45 - // this is what i found out is the calculation by printing this.height and grid.height - var heightToSet:Int = Std.int(Math.max(DIALOG_HEIGHT, toolboxNotesGrid.height + 45)); + var heightToSet:Int = Std.int(Math.max(DIALOG_HEIGHT, toolboxNotesGrid.height + HEIGHT_OFFSET)) + MINIMIZE_FIX; if (this.height != heightToSet) { this.height = heightToSet; From 0fe726cefa926b2e4de6963acc0284090e2fed99 Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 15:38:04 +0200 Subject: [PATCH 27/38] fix min, max --- source/funkin/play/notes/notekind/NoteKind.hx | 58 +++---------------- .../toolboxes/ChartEditorNoteDataToolbox.hx | 14 ++++- 2 files changed, 18 insertions(+), 54 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index f2a44dc8a..7efa93de6 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -42,50 +42,6 @@ class NoteKind implements INoteScriptedClass return noteKind; } - /** - * Retrieve the value of 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.data.value; - } - } - - return null; - } - - /** - * Set the value of the param with the given name - * @param name Name of the param - * @param value New value - */ - public function setParam(name:String, value:Dynamic):Void - { - for (param in params) - { - if (param.name == name) - { - if (param.type == NoteKindParamType.INT || param.type == NoteKindParamType.FLOAT) - { - param.data.value = FlxMath.bound(value, param.data.min, param.data.max); - } - else - { - param.data.value = value; - } - - break; - } - } - } - /** * Retrieve all notes of this kind * @return Array @@ -131,14 +87,14 @@ typedef NoteKindParamData = /** * If `min` is null, there is no minimum */ - var min:Null; + ?min:Null, /** * If `max` is null, there is no maximum */ - var max:Null; + ?max:Null, - var value:Dynamic; + defaultValue:Dynamic } /** @@ -146,8 +102,8 @@ typedef NoteKindParamData = */ typedef NoteKindParam = { - var name:String; - var description:String; - var type:NoteKindParamType; - var data:NoteKindParamData; + name:String, + description:String, + type:NoteKindParamType, + data:NoteKindParamData } diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index 278fc1fd6..751af5dff 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -82,13 +82,21 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox paramLabel.horizontalAlign = "right"; var paramStepper:NumberStepper = new NumberStepper(); - paramStepper.min = param.data.min; - paramStepper.max = param.data.max; - paramStepper.value = param.data.value; + paramStepper.value = param.data.defaultValue; paramStepper.precision = 1; paramStepper.step = 0.1; paramStepper.percentWidth = 100; + // this check should be unnecessary but for some reason even when min or max is null it will set it to 0 + if (param.data.min != null) + { + paramStepper.min = param.data.min; + } + if (param.data.max != null) + { + paramStepper.max = param.data.max; + } + addNoteKindParam(paramLabel, paramStepper); } } From 764cdee63de762395f070916369a99bc6d81c80d Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 15:48:07 +0200 Subject: [PATCH 28/38] add more options --- source/funkin/play/notes/notekind/NoteKind.hx | 10 ++++++++++ .../charting/toolboxes/ChartEditorNoteDataToolbox.hx | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 7efa93de6..a06670503 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -94,6 +94,16 @@ typedef NoteKindParamData = */ ?max:Null, + /** + * If `step` is null, it will use 1.0 + */ + ?step:Null, + + /** + * If `precision` is null, there will be 0 decimal places + */ + ?precision:Null, + defaultValue:Dynamic } diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index 751af5dff..26e495dcc 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -83,11 +83,11 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox var paramStepper:NumberStepper = new NumberStepper(); paramStepper.value = param.data.defaultValue; - paramStepper.precision = 1; - paramStepper.step = 0.1; paramStepper.percentWidth = 100; + paramStepper.step = param.data.step ?? 1; - // this check should be unnecessary but for some reason even when min or max is null it will set it to 0 + // this check should be unnecessary but for some reason + // even when these are null it will set it to 0 if (param.data.min != null) { paramStepper.min = param.data.min; @@ -96,6 +96,10 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox { paramStepper.max = param.data.max; } + if (param.data.precision != null) + { + paramStepper.precision = param.data.precision; + } addNoteKindParam(paramLabel, paramStepper); } From c41d846df5dfd5331dad37e71aa4d2b18595b3a9 Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 20:49:30 +0200 Subject: [PATCH 29/38] store params in chart chart editor still doesnt fully work --- source/funkin/data/song/SongData.hx | 41 +++++++++++++++++-- source/funkin/play/notes/NoteSprite.hx | 34 +++++++++++++++ .../play/notes/notekind/NoteKindManager.hx | 5 ++- .../ui/debug/charting/ChartEditorState.hx | 19 ++++++--- .../toolboxes/ChartEditorNoteDataToolbox.hx | 24 ++++++++++- 5 files changed, 111 insertions(+), 12 deletions(-) diff --git a/source/funkin/data/song/SongData.hx b/source/funkin/data/song/SongData.hx index 769af8f08..6bbeb4435 100644 --- a/source/funkin/data/song/SongData.hx +++ b/source/funkin/data/song/SongData.hx @@ -951,12 +951,18 @@ class SongNoteDataRaw implements ICloneable return this.kind = value; } - public function new(time:Float, data:Int, length:Float = 0, kind:String = '') + @:alias("p") + @:default([]) + @:optional + public var params:Array; + + public function new(time:Float, data:Int, length:Float = 0, kind:String = '', ?params:Array) { this.time = time; this.data = data; this.length = length; this.kind = kind; + this.params = params ?? []; } /** @@ -1053,7 +1059,7 @@ class SongNoteDataRaw implements ICloneable public function clone():SongNoteDataRaw { - return new SongNoteDataRaw(this.time, this.data, this.length, this.kind); + return new SongNoteDataRaw(this.time, this.data, this.length, this.kind, this.params); } public function toString():String @@ -1069,9 +1075,9 @@ class SongNoteDataRaw implements ICloneable @:forward abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw { - public function new(time:Float, data:Int, length:Float = 0, kind:String = '') + public function new(time:Float, data:Int, length:Float = 0, kind:String = '', ?params:Array) { - this = new SongNoteDataRaw(time, data, length, kind); + this = new SongNoteDataRaw(time, data, length, kind, params); } public static function buildDirectionName(data:Int, strumlineSize:Int = 4):String @@ -1183,3 +1189,30 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw + (this.kind != '' ? ' [kind: ${this.kind}])' : ')'); } } + +class NoteParamData implements ICloneable +{ + @:alias("n") + public var name:String; + + @:alias("v") + @:jcustomparse(funkin.data.DataParse.dynamicValue) + @:jcustomwrite(funkin.data.DataWrite.dynamicValue) + public var value:Dynamic; + + public function new(name:String, value:Dynamic) + { + this.name = name; + this.value = value; + } + + public function clone():NoteParamData + { + return new NoteParamData(this.name, this.value); + } + + public function toString():String + { + return 'NoteParamData(${this.name}, ${this.value})'; + } +} diff --git a/source/funkin/play/notes/NoteSprite.hx b/source/funkin/play/notes/NoteSprite.hx index 17a5e57fc..d8d471496 100644 --- a/source/funkin/play/notes/NoteSprite.hx +++ b/source/funkin/play/notes/NoteSprite.hx @@ -1,6 +1,7 @@ package funkin.play.notes; import funkin.data.song.SongData.SongNoteData; +import funkin.data.song.SongData.NoteParamData; import funkin.play.notes.notestyle.NoteStyle; import flixel.graphics.frames.FlxAtlasFrames; import flixel.FlxSprite; @@ -65,6 +66,22 @@ class NoteSprite extends FunkinSprite return this.noteData.kind = value; } + /** + * An array of custom parameters for this note + */ + public var params(get, set):Array; + + function get_params():Array + { + return this.noteData?.params ?? []; + } + + function set_params(value:Array):Array + { + if (this.noteData == null) return value; + return this.noteData.params = value; + } + /** * The data of the note (i.e. the direction.) */ @@ -154,6 +171,23 @@ class NoteSprite extends FunkinSprite this.shader = hsvShader; } + /** + * Retrieve the value of the param with the given name + * @param name Name of the param + * @return Null + */ + public function getParam(name:String):Null + { + for (param in params) + { + if (param.name == name) + { + return param.value; + } + } + return null; + } + #if FLX_DEBUG /** * Call this to override how debug bounding boxes are drawn for this sprite. diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 3e2174a66..30eede978 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -5,6 +5,7 @@ import funkin.modding.events.ScriptEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; import funkin.data.notestyle.NoteStyleRegistry; import funkin.play.notes.notestyle.NoteStyle; +import funkin.play.notes.notekind.NoteKind.NoteKindParam; class NoteKindManager { @@ -100,9 +101,9 @@ class NoteKindManager /** * Retrive custom params of the given note kind * @param noteKind Name of the note kind - * @return Array + * @return Array */ - public static function getParams(noteKind:String):Array + public static function getParams(noteKind:String):Array { return noteKinds.get(noteKind)?.params ?? []; } diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 2a07be52d..22de29849 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -35,6 +35,7 @@ import funkin.data.song.SongData.SongEventData; import funkin.data.song.SongData.SongMetadata; import funkin.data.song.SongData.SongNoteData; import funkin.data.song.SongData.SongOffsets; +import funkin.data.song.SongData.NoteParamData; import funkin.data.song.SongDataUtils; import funkin.data.song.SongRegistry; import funkin.data.stage.StageData; @@ -539,6 +540,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState */ var noteKindToPlace:Null = null; + /** + * The note params to use for notes being placed in the chart. Defaults to `[]`. + */ + var noteParamsToPlace:Array = []; + /** * The event type to use for events being placed in the chart. Defaults to `''`. */ @@ -2437,7 +2443,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState gridGhostNote = new ChartEditorNoteSprite(this); gridGhostNote.alpha = 0.6; - gridGhostNote.noteData = new SongNoteData(0, 0, 0, ""); + gridGhostNote.noteData = new SongNoteData(0, 0, 0, "", []); gridGhostNote.visible = false; add(gridGhostNote); gridGhostNote.zIndex = 11; @@ -4731,7 +4737,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState else { // Create a note and place it in the chart. - var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace); + var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace, noteParamsToPlace.clone()); performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL)); @@ -4890,11 +4896,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState if (gridGhostNote == null) throw "ERROR: Tried to handle cursor, but gridGhostNote is null! Check ChartEditorState.buildGrid()"; - var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, noteKindToPlace); + var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, noteKindToPlace, + noteParamsToPlace.clone()); - if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind) + if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind || noteParamsToPlace != noteData.params) { noteData.kind = noteKindToPlace; + noteData.params = noteParamsToPlace; noteData.data = cursorColumn; gridGhostNote.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; gridGhostNote.playNoteAnimation(); @@ -5202,7 +5210,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState if (notesAtPos.length == 0 && !removeNoteInstead) { trace('Placing note. ${column}'); - var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace); + var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace, noteParamsToPlace.clone()); performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL)); currentLiveInputPlaceNoteData[column] = newNoteData; } @@ -5655,6 +5663,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState FlxG.watch.addQuick('musicTime', audioInstTrack?.time ?? 0.0); FlxG.watch.addQuick('noteKindToPlace', noteKindToPlace); + FlxG.watch.addQuick('noteParamsToPlace', noteParamsToPlace); FlxG.watch.addQuick('eventKindToPlace', eventKindToPlace); FlxG.watch.addQuick('scrollPosInPixels', scrollPositionInPixels); diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index 26e495dcc..027ffdf81 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -9,6 +9,8 @@ import haxe.ui.core.Component; import haxe.ui.events.UIEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; import funkin.play.notes.notekind.NoteKindManager; +import funkin.play.notes.notekind.NoteKind.NoteKindParam; +import funkin.data.song.SongData.NoteParamData; /** * The toolbox which allows modifying information like Note Kind. @@ -60,6 +62,13 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox trace('ChartEditorToolboxHandler.buildToolboxNoteDataLayout() - Note kind changed: $noteKind'); + var noteKindParams:Array = NoteKindManager.getParams(noteKind); + var noteParamData:Array = []; + for (noteKindParam in noteKindParams) + { + noteParamData.push(new NoteParamData(noteKindParam.name, noteKindParam.data.defaultValue)); + } + // Edit the note data to place. if (noteKind == '~CUSTOM~') { @@ -71,10 +80,11 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox { hideCustom(); chartEditorState.noteKindToPlace = noteKind; + chartEditorState.noteParamsToPlace = noteParamData; toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace; clearNoteKindParams(); - for (param in NoteKindManager.getParams(noteKind)) + for (param in noteKindParams) { var paramLabel:Label = new Label(); paramLabel.value = param.description; @@ -107,10 +117,22 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox if (!_initializing && chartEditorState.currentNoteSelection.length > 0) { + for (i in 0...toolboxNotesParams.length) + { + var toolboxComponent:Component = toolboxNotesParams[i].component; + toolboxComponent.onChange = function(event:UIEvent) { + for (note in chartEditorState.currentNoteSelection) + { + note.params[i].value = toolboxComponent.value; + } + } + } + for (note in chartEditorState.currentNoteSelection) { // Edit the note data of any selected notes. note.kind = chartEditorState.noteKindToPlace; + note.params = noteParamData.clone(); // update note sprites for (noteSprite in chartEditorState.renderedNotes.members) From 44d978531727eba19e694ac0bed8e0f1f9c76306 Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 22 Jun 2024 22:36:39 +0200 Subject: [PATCH 30/38] editing them works now still need to implement String and do some testing --- source/funkin/data/song/SongData.hx | 18 +- .../play/notes/notekind/NoteKindManager.hx | 7 +- .../ui/debug/charting/ChartEditorState.hx | 17 +- .../toolboxes/ChartEditorNoteDataToolbox.hx | 157 +++++++++++------- 4 files changed, 128 insertions(+), 71 deletions(-) diff --git a/source/funkin/data/song/SongData.hx b/source/funkin/data/song/SongData.hx index 6bbeb4435..7bf3f8f19 100644 --- a/source/funkin/data/song/SongData.hx +++ b/source/funkin/data/song/SongData.hx @@ -1057,9 +1057,19 @@ class SongNoteDataRaw implements ICloneable _stepLength = null; } + public function cloneParams():Array + { + var params:Array = []; + for (param in this.params) + { + params.push(param.clone()); + } + return params; + } + public function clone():SongNoteDataRaw { - return new SongNoteDataRaw(this.time, this.data, this.length, this.kind, this.params); + return new SongNoteDataRaw(this.time, this.data, this.length, this.kind, cloneParams()); } public function toString():String @@ -1121,7 +1131,7 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw if (other.kind == '' || this.kind == null) return false; } - return this.time == other.time && this.data == other.data && this.length == other.length; + return this.time == other.time && this.data == other.data && this.length == other.length && this.params == other.params; } @:op(A != B) @@ -1140,7 +1150,7 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw if (other.kind == '') return true; } - return this.time != other.time || this.data != other.data || this.length != other.length; + return this.time != other.time || this.data != other.data || this.length != other.length || this.params != other.params; } @:op(A > B) @@ -1177,7 +1187,7 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw public function clone():SongNoteData { - return new SongNoteData(this.time, this.data, this.length, this.kind); + return new SongNoteData(this.time, this.data, this.length, this.kind, this.params); } /** diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 30eede978..8de3cdcca 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -103,8 +103,13 @@ class NoteKindManager * @param noteKind Name of the note kind * @return Array */ - public static function getParams(noteKind:String):Array + public static function getParams(noteKind:Null):Array { + if (noteKind == null) + { + return []; + } + return noteKinds.get(noteKind)?.params ?? []; } } diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 22de29849..f7abfba89 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4737,7 +4737,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState else { // Create a note and place it in the chart. - var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace, noteParamsToPlace.clone()); + var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace, + ChartEditorState.cloneNoteParams(noteParamsToPlace)); performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL)); @@ -4897,7 +4898,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState if (gridGhostNote == null) throw "ERROR: Tried to handle cursor, but gridGhostNote is null! Check ChartEditorState.buildGrid()"; var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, noteKindToPlace, - noteParamsToPlace.clone()); + ChartEditorState.cloneNoteParams(noteParamsToPlace)); if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind || noteParamsToPlace != noteData.params) { @@ -5210,7 +5211,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState if (notesAtPos.length == 0 && !removeNoteInstead) { trace('Placing note. ${column}'); - var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace, noteParamsToPlace.clone()); + var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace, ChartEditorState.cloneNoteParams(noteParamsToPlace)); performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL)); currentLiveInputPlaceNoteData[column] = newNoteData; } @@ -6532,6 +6533,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } return input; } + + public static function cloneNoteParams(paramsToClone:Array):Array + { + var params:Array = []; + for (param in paramsToClone) + { + params.push(param.clone()); + } + return params; + } } /** diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index 027ffdf81..a81cac5c2 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -62,77 +62,30 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox trace('ChartEditorToolboxHandler.buildToolboxNoteDataLayout() - Note kind changed: $noteKind'); - var noteKindParams:Array = NoteKindManager.getParams(noteKind); - var noteParamData:Array = []; - for (noteKindParam in noteKindParams) - { - noteParamData.push(new NoteParamData(noteKindParam.name, noteKindParam.data.defaultValue)); - } - // Edit the note data to place. if (noteKind == '~CUSTOM~') { showCustom(); - clearNoteKindParams(); toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace; } else { hideCustom(); chartEditorState.noteKindToPlace = noteKind; - chartEditorState.noteParamsToPlace = noteParamData; toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace; - - clearNoteKindParams(); - for (param in noteKindParams) - { - var paramLabel:Label = new Label(); - paramLabel.value = param.description; - paramLabel.verticalAlign = "center"; - paramLabel.horizontalAlign = "right"; - - var paramStepper:NumberStepper = new NumberStepper(); - paramStepper.value = param.data.defaultValue; - paramStepper.percentWidth = 100; - paramStepper.step = param.data.step ?? 1; - - // this check should be unnecessary but for some reason - // even when these are null it will set it to 0 - if (param.data.min != null) - { - paramStepper.min = param.data.min; - } - if (param.data.max != null) - { - paramStepper.max = param.data.max; - } - if (param.data.precision != null) - { - paramStepper.precision = param.data.precision; - } - - addNoteKindParam(paramLabel, paramStepper); - } } + createNoteKindParams(noteKind); + if (!_initializing && chartEditorState.currentNoteSelection.length > 0) { - for (i in 0...toolboxNotesParams.length) - { - var toolboxComponent:Component = toolboxNotesParams[i].component; - toolboxComponent.onChange = function(event:UIEvent) { - for (note in chartEditorState.currentNoteSelection) - { - note.params[i].value = toolboxComponent.value; - } - } - } - for (note in chartEditorState.currentNoteSelection) { // Edit the note data of any selected notes. note.kind = chartEditorState.noteKindToPlace; - note.params = noteParamData.clone(); + trace(note.params); + note.params = ChartEditorState.cloneNoteParams(chartEditorState.noteParamsToPlace); + trace(note.params); // update note sprites for (noteSprite in chartEditorState.renderedNotes.members) @@ -187,6 +140,8 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox toolboxNotesNoteKind.value = ChartEditorDropdowns.lookupNoteKind(chartEditorState.noteKindToPlace); toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace; + + createNoteKindParams(chartEditorState.noteKindToPlace); } function showCustom():Void @@ -201,6 +156,82 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox toolboxNotesCustomKind.hidden = true; } + function createNoteKindParams(noteKind:Null):Void + { + clearNoteKindParams(); + + var setParamsToPlace:Bool = false; + if (!_initializing) + { + for (note in chartEditorState.currentNoteSelection) + { + if (note.kind == chartEditorState.noteKindToPlace) + { + chartEditorState.noteParamsToPlace = ChartEditorState.cloneNoteParams(note.params); + setParamsToPlace = true; + break; + } + } + } + + var noteKindParams:Array = NoteKindManager.getParams(noteKind); + + for (i in 0...noteKindParams.length) + { + var param:NoteKindParam = noteKindParams[i]; + + var paramLabel:Label = new Label(); + paramLabel.value = param.description; + paramLabel.verticalAlign = "center"; + paramLabel.horizontalAlign = "right"; + + var paramStepper:NumberStepper = new NumberStepper(); + paramStepper.value = (setParamsToPlace ? chartEditorState.noteParamsToPlace[i].value : param.data.defaultValue); + paramStepper.percentWidth = 100; + paramStepper.step = param.data.step ?? 1; + + // this check should be unnecessary but for some reason + // even when these are null it will set it to 0 + if (param.data.min != null) + { + paramStepper.min = param.data.min; + } + if (param.data.max != null) + { + paramStepper.max = param.data.max; + } + if (param.data.precision != null) + { + paramStepper.precision = param.data.precision; + } + + paramStepper.onChange = function(event:UIEvent) { + chartEditorState.noteParamsToPlace[i].value = paramStepper.value; + + for (note in chartEditorState.currentNoteSelection) + { + if (note.params[i].name == param.name) + { + note.params[i].value = paramStepper.value; + trace(note.params[i]); + } + } + } + + addNoteKindParam(paramLabel, paramStepper); + } + + if (!setParamsToPlace) + { + var noteParamData:Array = []; + for (param in noteKindParams) + { + noteParamData.push(new NoteParamData(param.name, param.data.defaultValue)); + } + chartEditorState.noteParamsToPlace = noteParamData; + } + } + function addNoteKindParam(label:Label, component:Component):Void { toolboxNotesParams.push({label: label, component: component}); @@ -210,6 +241,17 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox this.height = Math.max(DIALOG_HEIGHT, DIALOG_HEIGHT - 30 + toolboxNotesParams.length * 30); } + function clearNoteKindParams():Void + { + for (param in toolboxNotesParams) + { + toolboxNotesGrid.removeComponent(param.component); + toolboxNotesGrid.removeComponent(param.label); + } + toolboxNotesParams = []; + this.height = DIALOG_HEIGHT; + } + override function update(elapsed:Float):Void { super.update(elapsed); @@ -227,17 +269,6 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox } } - function clearNoteKindParams():Void - { - for (param in toolboxNotesParams) - { - toolboxNotesGrid.removeComponent(param.component); - toolboxNotesGrid.removeComponent(param.label); - } - toolboxNotesParams = []; - this.height = DIALOG_HEIGHT; - } - public static function build(chartEditorState:ChartEditorState):ChartEditorNoteDataToolbox { return new ChartEditorNoteDataToolbox(chartEditorState); From 492af8add4e575d7e648f67911d2fafb006c9219 Mon Sep 17 00:00:00 2001 From: lemz Date: Sun, 23 Jun 2024 15:25:53 +0200 Subject: [PATCH 31/38] String works now --- source/funkin/play/notes/notekind/NoteKind.hx | 4 +- .../toolboxes/ChartEditorNoteDataToolbox.hx | 72 ++++++++++++------- 2 files changed, 49 insertions(+), 27 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index a06670503..89c175e54 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -104,7 +104,7 @@ typedef NoteKindParamData = */ ?precision:Null, - defaultValue:Dynamic + ?defaultValue:Dynamic } /** @@ -115,5 +115,5 @@ typedef NoteKindParam = name:String, description:String, type:NoteKindParamType, - data:NoteKindParamData + ?data:NoteKindParamData } diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index a81cac5c2..264e62c5a 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -10,6 +10,7 @@ import haxe.ui.events.UIEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; import funkin.play.notes.notekind.NoteKindManager; import funkin.play.notes.notekind.NoteKind.NoteKindParam; +import funkin.play.notes.notekind.NoteKind.NoteKindParamType; import funkin.data.song.SongData.NoteParamData; /** @@ -83,9 +84,7 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox { // Edit the note data of any selected notes. note.kind = chartEditorState.noteKindToPlace; - trace(note.params); note.params = ChartEditorState.cloneNoteParams(chartEditorState.noteParamsToPlace); - trace(note.params); // update note sprites for (noteSprite in chartEditorState.renderedNotes.members) @@ -185,48 +184,71 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox paramLabel.verticalAlign = "center"; paramLabel.horizontalAlign = "right"; - var paramStepper:NumberStepper = new NumberStepper(); - paramStepper.value = (setParamsToPlace ? chartEditorState.noteParamsToPlace[i].value : param.data.defaultValue); - paramStepper.percentWidth = 100; - paramStepper.step = param.data.step ?? 1; + var paramComponent:Component = null; - // this check should be unnecessary but for some reason - // even when these are null it will set it to 0 - if (param.data.min != null) + final paramType:String = param.type; + switch (paramType) { - paramStepper.min = param.data.min; - } - if (param.data.max != null) - { - paramStepper.max = param.data.max; - } - if (param.data.precision != null) - { - paramStepper.precision = param.data.precision; + case NoteKindParamType.INT | NoteKindParamType.FLOAT: + var paramStepper:NumberStepper = new NumberStepper(); + paramStepper.value = (setParamsToPlace ? chartEditorState.noteParamsToPlace[i].value : param.data?.defaultValue) ?? 0.0; + paramStepper.percentWidth = 100; + paramStepper.step = param.data?.step ?? 1; + + // this check should be unnecessary but for some reason + // even when these are null it will set it to 0 + if (param.data?.min != null) + { + paramStepper.min = param.data.min; + } + if (param.data?.max != null) + { + paramStepper.max = param.data.max; + } + if (param.data?.precision != null) + { + paramStepper.precision = param.data.precision; + } + paramComponent = paramStepper; + + case NoteKindParamType.STRING: + var paramTextField:TextField = new TextField(); + paramTextField.value = (setParamsToPlace ? chartEditorState.noteParamsToPlace[i].value : param.data?.defaultValue) ?? ''; + paramTextField.percentWidth = 100; + paramComponent = paramTextField; } - paramStepper.onChange = function(event:UIEvent) { - chartEditorState.noteParamsToPlace[i].value = paramStepper.value; + if (paramComponent == null) + { + continue; + } + + paramComponent.onChange = function(event:UIEvent) { + chartEditorState.noteParamsToPlace[i].value = paramComponent.value; for (note in chartEditorState.currentNoteSelection) { + if (note.params.length != noteKindParams.length) + { + break; + } + if (note.params[i].name == param.name) { - note.params[i].value = paramStepper.value; - trace(note.params[i]); + note.params[i].value = paramComponent.value; } } } - addNoteKindParam(paramLabel, paramStepper); + addNoteKindParam(paramLabel, paramComponent); } if (!setParamsToPlace) { var noteParamData:Array = []; - for (param in noteKindParams) + for (i in 0...noteKindParams.length) { - noteParamData.push(new NoteParamData(param.name, param.data.defaultValue)); + noteParamData.push(new NoteParamData(noteKindParams[i].name, toolboxNotesParams[i].component.value)); } chartEditorState.noteParamsToPlace = noteParamData; } From f9bccb057a129443148e6031c907045c2ff8fb31 Mon Sep 17 00:00:00 2001 From: lemz Date: Mon, 24 Jun 2024 21:45:58 +0200 Subject: [PATCH 32/38] use suffixes instead of pixel boolean --- source/funkin/play/notes/Strumline.hx | 4 ++-- .../play/notes/notekind/NoteKindManager.hx | 23 +++++++++++-------- .../ui/debug/charting/ChartEditorState.hx | 17 +++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index 86b7a3ee1..5e76afa51 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -709,7 +709,7 @@ class Strumline extends FlxSpriteGroup if (noteSprite != null) { - var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind, this.noteStyle.isHoldNotePixel()) ?? this.noteStyle; + var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind, this.noteStyle.id) ?? this.noteStyle; noteSprite.setupNoteGraphic(noteKindStyle); noteSprite.direction = note.getDirection(); @@ -731,7 +731,7 @@ class Strumline extends FlxSpriteGroup if (holdNoteSprite != null) { - var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind, this.noteStyle.isHoldNotePixel()) ?? this.noteStyle; + var noteKindStyle:NoteStyle = NoteKindManager.getNoteStyle(note.kind, this.noteStyle.id) ?? this.noteStyle; holdNoteSprite.setupHoldNoteGraphic(noteKindStyle); holdNoteSprite.parentStrumline = this; diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 8de3cdcca..d97eefcf8 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -66,12 +66,12 @@ class NoteKindManager /** * Retrieve the note style from the given note kind * @param noteKind note kind name - * @param isPixel whether to use pixel style + * @param suffix Used for song note styles * @return NoteStyle */ - public static function getNoteStyle(noteKind:String, isPixel:Bool = false):Null + public static function getNoteStyle(noteKind:String, ?suffix:String):Null { - var noteStyleId:Null = getNoteStyleId(noteKind, isPixel); + var noteStyleId:Null = getNoteStyleId(noteKind, suffix); if (noteStyleId == null) { @@ -83,16 +83,21 @@ class NoteKindManager /** * Retrieve the note style id from the given note kind - * @param noteKind note kind name - * @param isPixel whether to use pixel style + * @param noteKind Note kind name + * @param suffix Used for song note styles * @return Null */ - public static function getNoteStyleId(noteKind:String, isPixel:Bool = false):Null + public static function getNoteStyleId(noteKind:String, ?suffix:String):Null { - var noteStyleId:Null = noteKinds.get(noteKind)?.noteStyleId; - if (isPixel && noteStyleId != null) + if (suffix == null) { - noteStyleId = NoteStyleRegistry.instance.hasEntry('$noteStyleId-pixel') ? '$noteStyleId-pixel' : noteStyleId; + suffix = ''; + } + + var noteStyleId:Null = noteKinds.get(noteKind)?.noteStyleId; + if (noteStyleId != null) + { + noteStyleId = NoteStyleRegistry.instance.hasEntry('$noteStyleId-$suffix') ? '$noteStyleId-$suffix' : noteStyleId; } return noteStyleId; diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index f7abfba89..d3ddb1bca 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -3591,7 +3591,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // The note sprite handles animation playback and positioning. noteSprite.noteData = noteData; - noteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; + noteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, currentSongNoteStyle) ?? currentSongNoteStyle; noteSprite.overrideStepTime = null; noteSprite.overrideData = null; @@ -3615,7 +3615,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState holdNoteSprite.setHeightDirectly(noteLengthPixels); - holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteSprite.noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteSprite.noteData.kind, currentSongNoteStyle) ?? currentSongNoteStyle; holdNoteSprite.updateHoldNotePosition(renderedHoldNotes); @@ -3681,7 +3681,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState holdNoteSprite.noteDirection = noteData.getDirection(); holdNoteSprite.setHeightDirectly(noteLengthPixels); - holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; + holdNoteSprite.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, currentSongNoteStyle) ?? currentSongNoteStyle; holdNoteSprite.updateHoldNotePosition(renderedHoldNotes); @@ -4580,7 +4580,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState gridGhostHoldNote.noteData = currentPlaceNoteData; gridGhostHoldNote.noteDirection = currentPlaceNoteData.getDirection(); gridGhostHoldNote.setHeightDirectly(dragLengthPixels, true); - gridGhostHoldNote.noteStyle = NoteKindManager.getNoteStyleId(currentPlaceNoteData.kind, isPixelStyle()) ?? currentSongNoteStyle; + gridGhostHoldNote.noteStyle = NoteKindManager.getNoteStyleId(currentPlaceNoteData.kind, currentSongNoteStyle) ?? currentSongNoteStyle; gridGhostHoldNote.updateHoldNotePosition(renderedHoldNotes); } else @@ -4905,7 +4905,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState noteData.kind = noteKindToPlace; noteData.params = noteParamsToPlace; noteData.data = cursorColumn; - gridGhostNote.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; + gridGhostNote.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, currentSongNoteStyle) ?? currentSongNoteStyle; gridGhostNote.playNoteAnimation(); } noteData.time = cursorSnappedMs; @@ -5297,7 +5297,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState ghostHold.visible = true; ghostHold.alpha = 0.6; ghostHold.setHeightDirectly(0); - ghostHold.noteStyle = NoteKindManager.getNoteStyleId(ghostHold.noteData.kind, isPixelStyle()) ?? currentSongNoteStyle; + ghostHold.noteStyle = NoteKindManager.getNoteStyleId(ghostHold.noteData.kind, currentSongNoteStyle) ?? currentSongNoteStyle; ghostHold.updateHoldNotePosition(renderedHoldNotes); } @@ -6423,11 +6423,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState return note != null && currentNoteSelection.indexOf(note) != -1; } - function isPixelStyle():Bool - { - return currentSongNoteStyle == 'pixel'; - } - override function destroy():Void { super.destroy(); From 4746c1da0eed756e2af8630d572ad9770a5185f1 Mon Sep 17 00:00:00 2001 From: lemz Date: Mon, 24 Jun 2024 21:48:09 +0200 Subject: [PATCH 33/38] checking empty suffix is stupid --- source/funkin/play/notes/notekind/NoteKindManager.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index d97eefcf8..3040c0a96 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -89,13 +89,13 @@ class NoteKindManager */ public static function getNoteStyleId(noteKind:String, ?suffix:String):Null { - if (suffix == null) + if (suffix == '') { - suffix = ''; + suffix = null; } var noteStyleId:Null = noteKinds.get(noteKind)?.noteStyleId; - if (noteStyleId != null) + if (noteStyleId != null && suffix != null) { noteStyleId = NoteStyleRegistry.instance.hasEntry('$noteStyleId-$suffix') ? '$noteStyleId-$suffix' : noteStyleId; } From 1fe44fa3686b33f91b99efdb00070e4c59fdee45 Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 29 Jun 2024 15:33:41 +0200 Subject: [PATCH 34/38] add from --- source/funkin/play/notes/notekind/NoteKind.hx | 2 +- .../ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/source/funkin/play/notes/notekind/NoteKind.hx b/source/funkin/play/notes/notekind/NoteKind.hx index 89c175e54..c1c6e815a 100644 --- a/source/funkin/play/notes/notekind/NoteKind.hx +++ b/source/funkin/play/notes/notekind/NoteKind.hx @@ -73,7 +73,7 @@ class NoteKind implements INoteScriptedClass * Abstract for setting the type of the `NoteKindParam` * This was supposed to be an enum but polymod kept being annoying */ -abstract NoteKindParamType(String) to String +abstract NoteKindParamType(String) from String to String { public static final STRING:String = 'String'; diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index 264e62c5a..ea46cf72a 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -186,8 +186,7 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox var paramComponent:Component = null; - final paramType:String = param.type; - switch (paramType) + switch (param.type) { case NoteKindParamType.INT | NoteKindParamType.FLOAT: var paramStepper:NumberStepper = new NumberStepper(); From f76309c91ec2cd0ca4bad6163b47fefa2e57228c Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 12 Jul 2024 04:13:20 -0400 Subject: [PATCH 35/38] Update rendering for custom note styles --- source/funkin/data/notestyle/NoteStyleData.hx | 8 ++++++++ source/funkin/play/notes/NoteSprite.hx | 16 +++++++++------- source/funkin/play/notes/Strumline.hx | 1 + source/funkin/play/notes/notestyle/NoteStyle.hx | 16 ++++++++++++++-- .../charting/components/ChartEditorNoteSprite.hx | 10 ++++++++-- .../toolboxes/ChartEditorNoteDataToolbox.hx | 2 +- .../debug/charting/util/ChartEditorDropdowns.hx | 6 +++--- 7 files changed, 44 insertions(+), 15 deletions(-) diff --git a/source/funkin/data/notestyle/NoteStyleData.hx b/source/funkin/data/notestyle/NoteStyleData.hx index 04fda67ca..fcdb3b4f9 100644 --- a/source/funkin/data/notestyle/NoteStyleData.hx +++ b/source/funkin/data/notestyle/NoteStyleData.hx @@ -109,6 +109,14 @@ typedef NoteStyleAssetData = @:optional var isPixel:Bool; + /** + * If true, animations will be played on the graphic. + * @default `false` to save performance. + */ + @:default(false) + @:optional + var animated:Bool; + /** * The structure of this data depends on the asset. */ diff --git a/source/funkin/play/notes/NoteSprite.hx b/source/funkin/play/notes/NoteSprite.hx index d8d471496..e8cacaa4d 100644 --- a/source/funkin/play/notes/NoteSprite.hx +++ b/source/funkin/play/notes/NoteSprite.hx @@ -91,7 +91,7 @@ class NoteSprite extends FunkinSprite { if (frames == null) return value; - animation.play(DIRECTION_COLORS[value] + 'Scroll'); + playNoteAnimation(value); this.direction = value; return this.direction; @@ -152,9 +152,6 @@ class NoteSprite extends FunkinSprite this.hsvShader = new HSVShader(); setupNoteGraphic(noteStyle); - - // Disables the update() function for performance. - this.active = false; } /** @@ -165,10 +162,10 @@ class NoteSprite extends FunkinSprite { noteStyle.buildNoteSprite(this); - setGraphicSize(Strumline.STRUMLINE_SIZE); - updateHitbox(); - this.shader = hsvShader; + + // `false` disables the update() function for performance. + this.active = noteStyle.isNoteAnimated(); } /** @@ -211,6 +208,11 @@ class NoteSprite extends FunkinSprite } #end + function playNoteAnimation(value:Int):Void + { + animation.play(DIRECTION_COLORS[value] + 'Scroll'); + } + public function desaturate():Void { this.hsvShader.saturation = 0.2; diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index 5e76afa51..1e5782ad2 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -717,6 +717,7 @@ class Strumline extends FlxSpriteGroup noteSprite.x = this.x; noteSprite.x += getXPos(DIRECTIONS[note.getDirection() % KEY_COUNT]); + noteSprite.x -= (noteSprite.width - Strumline.STRUMLINE_SIZE) / 2; // Center it noteSprite.x -= NUDGE; // noteSprite.x += INITIAL_OFFSET; noteSprite.y = -9999; diff --git a/source/funkin/play/notes/notestyle/NoteStyle.hx b/source/funkin/play/notes/notestyle/NoteStyle.hx index d0cc09f6a..3993cce52 100644 --- a/source/funkin/play/notes/notestyle/NoteStyle.hx +++ b/source/funkin/play/notes/notestyle/NoteStyle.hx @@ -89,12 +89,14 @@ class NoteStyle implements IRegistryEntry target.frames = atlas; - target.scale.x = _data.assets.note.scale; - target.scale.y = _data.assets.note.scale; target.antialiasing = !_data.assets.note.isPixel; // Apply the animations. buildNoteAnimations(target); + + // Set the scale. + target.setGraphicSize(Strumline.STRUMLINE_SIZE * getNoteScale()); + target.updateHitbox(); } var noteFrames:FlxAtlasFrames = null; @@ -156,6 +158,16 @@ class NoteStyle implements IRegistryEntry target.animation.addByPrefix('redScroll', rightData.prefix, rightData.frameRate, rightData.looped, rightData.flipX, rightData.flipY); } + public function isNoteAnimated():Bool + { + return _data.assets.note.animated; + } + + public function getNoteScale():Float + { + return _data.assets.note.scale; + } + function fetchNoteAnimationData(dir:NoteDirection):AnimationData { var result:Null = switch (dir) diff --git a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx index 009532401..5fd0c74aa 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx @@ -107,6 +107,12 @@ class ChartEditorNoteSprite extends FlxSprite var prefix:String = noteStyle.id.toTitleCase(); var frameCollection:FlxAtlasFrames = Paths.getSparrowAtlas(noteStyle.getNoteAssetPath(), noteStyle.getNoteAssetLibrary()); + if (frameCollection == null) + { + trace('Could not retrieve frame collection for ${noteStyle}: ${Paths.image(noteStyle.getNoteAssetPath(), noteStyle.getNoteAssetLibrary())}'); + FlxG.log.error('Could not retrieve frame collection for ${noteStyle}: ${Paths.image(noteStyle.getNoteAssetPath(), noteStyle.getNoteAssetLibrary())}'); + return; + } for (frame in frameCollection.frames) { // cloning the frame because else @@ -221,9 +227,9 @@ class ChartEditorNoteSprite extends FlxSprite switch (baseAnimationName) { case 'tap': - this.setGraphicSize(0, ChartEditorState.GRID_SIZE); + this.setGraphicSize(ChartEditorState.GRID_SIZE, 0); + this.updateHitbox(); } - this.updateHitbox(); var bruhStyle:NoteStyle = fetchNoteStyle(this.noteStyle); this.antialiasing = !bruhStyle._data?.assets?.note?.isPixel ?? true; diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx index ea46cf72a..12f7f7d63 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorNoteDataToolbox.hx @@ -283,7 +283,7 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox return; } - var heightToSet:Int = Std.int(Math.max(DIALOG_HEIGHT, toolboxNotesGrid.height + HEIGHT_OFFSET)) + MINIMIZE_FIX; + var heightToSet:Int = Std.int(Math.max(DIALOG_HEIGHT, (toolboxNotesGrid?.height ?? 50) + HEIGHT_OFFSET)) + MINIMIZE_FIX; if (this.height != heightToSet) { this.height = heightToSet; diff --git a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx index 6a426c391..21938b005 100644 --- a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx +++ b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx @@ -195,11 +195,11 @@ class ChartEditorDropdowns { dropDown.dataSource.clear(); - var returnValue:DropDownEntry = lookupNoteKind('~CUSTOM'); + var returnValue:DropDownEntry = lookupNoteKind(''); for (noteKindId in NOTE_KINDS.keys()) { - var noteKind:String = NOTE_KINDS.get(noteKindId) ?? 'Default'; + var noteKind:String = NOTE_KINDS.get(noteKindId) ?? 'Unknown'; var value:DropDownEntry = {id: noteKindId, text: noteKind}; if (startingKindId == noteKindId) returnValue = value; @@ -216,7 +216,7 @@ class ChartEditorDropdowns { if (noteKindId == null) return lookupNoteKind(''); if (!NOTE_KINDS.exists(noteKindId)) return {id: '~CUSTOM~', text: 'Custom'}; - return {id: noteKindId ?? '', text: NOTE_KINDS.get(noteKindId) ?? 'Default'}; + return {id: noteKindId ?? '', text: NOTE_KINDS.get(noteKindId) ?? 'Unknown'}; } /** From ace762413e42a211a92ad37544ec22f1c2f3da8d Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 12 Jul 2024 16:39:42 -0400 Subject: [PATCH 36/38] Fix an issue where display would break on invalid note styles. --- assets | 2 +- source/funkin/ui/debug/charting/ChartEditorState.hx | 4 +++- .../charting/components/ChartEditorHoldNoteSprite.hx | 3 ++- .../charting/components/ChartEditorNoteSprite.hx | 12 ++++++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/assets b/assets index 005c96f85..4af95a506 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 005c96f85f4304865acb196e7cc4d6d83f9d76d8 +Subproject commit 4af95a506fc62cd683422dfb9c599877b26c27db diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index d3ddb1bca..6f5979c90 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1408,7 +1408,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function get_currentSongNoteStyle():String { - if (currentSongMetadata.playData.noteStyle == null) + if (currentSongMetadata.playData.noteStyle == null + || currentSongMetadata.playData.noteStyle == '' + || currentSongMetadata.playData.noteStyle == 'item') { // Initialize to the default value if not set. currentSongMetadata.playData.noteStyle = Constants.DEFAULT_NOTE_STYLE; diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index b8d6ee22e..1e631f2cf 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -53,7 +53,8 @@ class ChartEditorHoldNoteSprite extends SustainTrail @:nullSafety(Off) function updateHoldNoteGraphic():Void { - var bruhStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle); + var bruhStyle:Null = NoteStyleRegistry.instance.fetchEntry(noteStyle); + if (bruhStyle == null) bruhStyle = NoteStyleRegistry.instance.fetchDefault(); setupHoldNoteGraphic(bruhStyle); } diff --git a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx index 5fd0c74aa..c8f40da62 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx @@ -97,7 +97,9 @@ class ChartEditorNoteSprite extends FlxSprite function fetchNoteStyle(noteStyleId:String):NoteStyle { - return NoteStyleRegistry.instance.fetchEntry(noteStyleId) ?? NoteStyleRegistry.instance.fetchDefault(); + var result = NoteStyleRegistry.instance.fetchEntry(noteStyleId); + if (result != null) return result; + return NoteStyleRegistry.instance.fetchDefault(); } @:access(funkin.play.notes.notestyle.NoteStyle) @@ -198,7 +200,12 @@ class ChartEditorNoteSprite extends FlxSprite function get_noteStyle():Null { - return this.noteStyle ?? this.parentState.currentSongNoteStyle; + if (this.noteStyle == null) + { + var result = this.parentState.currentSongNoteStyle; + return result; + } + return this.noteStyle; } function set_noteStyle(value:Null):Null @@ -218,6 +225,7 @@ class ChartEditorNoteSprite extends FlxSprite // Play the appropriate animation for the type, direction, and skin. var dirName:String = overrideData != null ? SongNoteData.buildDirectionName(overrideData) : this.noteData.getDirectionName(); + var noteStyleSuffix:String = this.noteStyle?.toTitleCase() ?? Constants.DEFAULT_NOTE_STYLE.toTitleCase(); var animationName:String = '${baseAnimationName}${dirName}${this.noteStyle.toTitleCase()}'; this.animation.play(animationName); From d4cbe74939425c5a86f0ad752e2620e560380e27 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 12 Jul 2024 21:40:46 -0400 Subject: [PATCH 37/38] Smaller fixes tied to note kinds --- source/funkin/data/song/importer/FNFLegacyImporter.hx | 2 ++ source/funkin/modding/PolymodHandler.hx | 2 ++ source/funkin/play/PlayState.hx | 6 +++--- source/funkin/play/character/BaseCharacter.hx | 6 ++++++ source/funkin/play/notes/notekind/NoteKindManager.hx | 1 + source/funkin/play/stage/Bopper.hx | 4 ++-- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/funkin/data/song/importer/FNFLegacyImporter.hx b/source/funkin/data/song/importer/FNFLegacyImporter.hx index acbb99342..96a1051cc 100644 --- a/source/funkin/data/song/importer/FNFLegacyImporter.hx +++ b/source/funkin/data/song/importer/FNFLegacyImporter.hx @@ -199,6 +199,8 @@ class FNFLegacyImporter { // Handle the dumb logic for mustHitSection. var noteData = note.data; + if (noteData < 0) continue; // Exclude Psych event notes. + if (noteData > (STRUMLINE_SIZE * 2)) noteData = noteData % (2 * STRUMLINE_SIZE); // Handle other engine event notes. // Flip notes if mustHitSection is FALSE (not true lol). if (!mustHitSection) diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index c352aa606..59c8707f7 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -7,6 +7,7 @@ import funkin.data.dialogue.speaker.SpeakerRegistry; import funkin.data.event.SongEventRegistry; import funkin.data.story.level.LevelRegistry; import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.notes.notekind.NoteKindManager; import funkin.data.song.SongRegistry; import funkin.data.freeplay.player.PlayerRegistry; import funkin.data.stage.StageRegistry; @@ -383,6 +384,7 @@ class PolymodHandler StageRegistry.instance.loadEntries(); CharacterDataParser.loadCharacterCache(); // TODO: Migrate characters to BaseRegistry. + NoteKindManager.loadScripts(); ModuleHandler.loadModuleCache(); } } diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index da343f43f..10546cdbd 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1166,6 +1166,9 @@ class PlayState extends MusicBeatSubState // super.dispatchEvent(event) dispatches event to module scripts. super.dispatchEvent(event); + // Dispatch event to note kind scripts + NoteKindManager.callEvent(event); + // Dispatch event to stage script. ScriptEventDispatcher.callEvent(currentStage, event); @@ -1177,9 +1180,6 @@ class PlayState extends MusicBeatSubState // Dispatch event to conversation script. ScriptEventDispatcher.callEvent(currentConversation, event); - - // Dispatch event to note kind scripts - NoteKindManager.callEvent(event); } /** diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 0dab2101a..432881164 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -521,6 +521,9 @@ class BaseCharacter extends Bopper { super.onNoteHit(event); + // If another script cancelled the event, don't do anything. + if (event.eventCanceled) return; + if (event.note.noteData.getMustHitNote() && characterType == BF) { // If the note is from the same strumline, play the sing animation. @@ -553,6 +556,9 @@ class BaseCharacter extends Bopper { super.onNoteMiss(event); + // If another script cancelled the event, don't do anything. + if (event.eventCanceled) return; + if (event.note.noteData.getMustHitNote() && characterType == BF) { // If the note is from the same strumline, play the sing animation. diff --git a/source/funkin/play/notes/notekind/NoteKindManager.hx b/source/funkin/play/notes/notekind/NoteKindManager.hx index 3040c0a96..e17e103d1 100644 --- a/source/funkin/play/notes/notekind/NoteKindManager.hx +++ b/source/funkin/play/notes/notekind/NoteKindManager.hx @@ -5,6 +5,7 @@ import funkin.modding.events.ScriptEvent; import funkin.ui.debug.charting.util.ChartEditorDropdowns; import funkin.data.notestyle.NoteStyleRegistry; import funkin.play.notes.notestyle.NoteStyle; +import funkin.play.notes.notekind.ScriptedNoteKind; import funkin.play.notes.notekind.NoteKind.NoteKindParam; class NoteKindManager diff --git a/source/funkin/play/stage/Bopper.hx b/source/funkin/play/stage/Bopper.hx index 87151de21..fa35b4e15 100644 --- a/source/funkin/play/stage/Bopper.hx +++ b/source/funkin/play/stage/Bopper.hx @@ -45,8 +45,8 @@ class Bopper extends StageProp implements IPlayStateScriptedClass public var idleSuffix(default, set):String = ''; /** - * If this bopper is rendered with pixel art, - * disable anti-aliasing and render at 6x scale. + * If this bopper is rendered with pixel art, disable anti-aliasing. + * @default `false` */ public var isPixel(default, set):Bool = false; From 9b8961d4b5c8e150a2c77d39d53566bed5fe6ea7 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 22 Jul 2024 22:20:51 -0400 Subject: [PATCH 38/38] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 4af95a506..aa1231e8c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4af95a506fc62cd683422dfb9c599877b26c27db +Subproject commit aa1231e8cf2990bb902eac3b37815c010fa9919a