From ba53957191c9f9d37562bcbc68ab0d86f596bb98 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 13 Jul 2023 20:26:56 -0400 Subject: [PATCH] Fixed an issue where dialogue scripts were not being reloaded --- source/funkin/InitState.hx | 36 +++++++++++++------ source/funkin/modding/PolymodHandler.hx | 17 ++++++--- .../dialogue/DialogueBoxDataParser.hx | 4 +-- .../play/cutscene/dialogue/ScriptedSpeaker.hx | 7 +++- .../cutscene/dialogue/SpeakerDataParser.hx | 4 +-- 5 files changed, 47 insertions(+), 21 deletions(-) diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index 97e451320..ce863bd0b 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -14,6 +14,16 @@ import funkin.util.macro.MacroUtil; import funkin.util.WindowUtil; import funkin.play.PlayStatePlaylist; import openfl.display.BitmapData; +import funkin.data.level.LevelRegistry; +import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.event.SongEventData.SongEventParser; +import funkin.play.cutscene.dialogue.ConversationDataParser; +import funkin.play.cutscene.dialogue.DialogueBoxDataParser; +import funkin.play.cutscene.dialogue.SpeakerDataParser; +import funkin.play.song.SongData.SongDataParser; +import funkin.play.stage.StageData.StageDataParser; +import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.modding.module.ModuleHandler; #if discord_rpc import Discord.DiscordClient; #end @@ -180,18 +190,22 @@ class InitState extends FlxTransitionableState // // GAME DATA PARSING // - funkin.data.level.LevelRegistry.instance.loadEntries(); - funkin.play.event.SongEventData.SongEventParser.loadEventCache(); - funkin.play.cutscene.dialogue.ConversationDataParser.loadConversationCache(); - funkin.play.cutscene.dialogue.DialogueBoxDataParser.loadDialogueBoxCache(); - funkin.play.cutscene.dialogue.SpeakerDataParser.loadSpeakerCache(); - funkin.play.song.SongData.SongDataParser.loadSongCache(); - funkin.play.stage.StageData.StageDataParser.loadStageCache(); - funkin.play.character.CharacterData.CharacterDataParser.loadCharacterCache(); - funkin.modding.module.ModuleHandler.buildModuleCallbacks(); - funkin.modding.module.ModuleHandler.loadModuleCache(); - funkin.modding.module.ModuleHandler.callOnCreate(); + // NOTE: Registries and data parsers must be imported and not referenced with fully qualified names, + // to ensure build macros work properly. + LevelRegistry.instance.loadEntries(); + NoteStyleRegistry.instance.loadEntries(); + SongEventParser.loadEventCache(); + ConversationDataParser.loadConversationCache(); + DialogueBoxDataParser.loadDialogueBoxCache(); + SpeakerDataParser.loadSpeakerCache(); + SongDataParser.loadSongCache(); + StageDataParser.loadStageCache(); + CharacterDataParser.loadCharacterCache(); + ModuleHandler.buildModuleCallbacks(); + ModuleHandler.loadModuleCache(); + + ModuleHandler.callOnCreate(); } /** diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index d90c1386d..bed63d1d8 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -10,6 +10,11 @@ import polymod.backends.PolymodAssets.PolymodAssetType; import polymod.format.ParseRules.TextFileFormat; import funkin.play.event.SongEventData.SongEventParser; import funkin.util.FileUtil; +import funkin.data.level.LevelRegistry; +import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.cutscene.dialogue.ConversationDataParser; +import funkin.play.cutscene.dialogue.DialogueBoxDataParser; +import funkin.play.cutscene.dialogue.SpeakerDataParser; class PolymodHandler { @@ -279,12 +284,14 @@ class PolymodHandler // TODO: Reload event callbacks - funkin.data.level.LevelRegistry.instance.loadEntries(); + // These MUST be imported at the top of the file and not referred to by fully qualified name, + // to ensure build macros work properly. + LevelRegistry.instance.loadEntries(); + NoteStyleRegistry.instance.loadEntries(); SongEventParser.loadEventCache(); - // TODO: Uncomment this once conversation data is implemented. - // ConversationDataParser.loadConversationCache(); - // DialogueBoxDataParser.loadDialogueBoxCache(); - // SpeakerDataParser.loadSpeakerCache(); + ConversationDataParser.loadConversationCache(); + DialogueBoxDataParser.loadDialogueBoxCache(); + SpeakerDataParser.loadSpeakerCache(); SongDataParser.loadSongCache(); StageDataParser.loadStageCache(); CharacterDataParser.loadCharacterCache(); diff --git a/source/funkin/play/cutscene/dialogue/DialogueBoxDataParser.hx b/source/funkin/play/cutscene/dialogue/DialogueBoxDataParser.hx index 7bac9cf38..cb00dd80d 100644 --- a/source/funkin/play/cutscene/dialogue/DialogueBoxDataParser.hx +++ b/source/funkin/play/cutscene/dialogue/DialogueBoxDataParser.hx @@ -21,7 +21,7 @@ class DialogueBoxDataParser /** * Parses and preloads the game's dialogueBox data and scripts when the game starts. - * + * * If you want to force dialogue boxes to be reloaded, you can just call this function again. */ public static function loadDialogueBoxCache():Void @@ -123,7 +123,7 @@ class DialogueBoxDataParser /** * Load a dialogueBox's JSON file, parse its data, and return it. - * + * * @param dialogueBoxId The dialogueBox to load. * @return The dialogueBox data, or null if validation failed. */ diff --git a/source/funkin/play/cutscene/dialogue/ScriptedSpeaker.hx b/source/funkin/play/cutscene/dialogue/ScriptedSpeaker.hx index 03846eb42..a244ff6f1 100644 --- a/source/funkin/play/cutscene/dialogue/ScriptedSpeaker.hx +++ b/source/funkin/play/cutscene/dialogue/ScriptedSpeaker.hx @@ -1,4 +1,9 @@ package funkin.play.cutscene.dialogue; +/** + * A script that can be tied to a Speaker. + * Create a scripted class that extends Speaker to use this. + * This allows you to customize how a specific conversation speaker appears. + */ @:hscriptClass -class ScriptedSpeaker extends Speaker implements polymod.hscript.HScriptedClass {} +class ScriptedSpeaker extends funkin.play.cutscene.dialogue.Speaker implements polymod.hscript.HScriptedClass {} diff --git a/source/funkin/play/cutscene/dialogue/SpeakerDataParser.hx b/source/funkin/play/cutscene/dialogue/SpeakerDataParser.hx index 62a8a105b..f7ddb099f 100644 --- a/source/funkin/play/cutscene/dialogue/SpeakerDataParser.hx +++ b/source/funkin/play/cutscene/dialogue/SpeakerDataParser.hx @@ -21,7 +21,7 @@ class SpeakerDataParser /** * Parses and preloads the game's speaker data and scripts when the game starts. - * + * * If you want to force speakers to be reloaded, you can just call this function again. */ public static function loadSpeakerCache():Void @@ -123,7 +123,7 @@ class SpeakerDataParser /** * Load a speaker's JSON file, parse its data, and return it. - * + * * @param speakerId The speaker to load. * @return The speaker data, or null if validation failed. */