diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index 4255593f7..ae754b780 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -1,5 +1,6 @@ package funkin.modding; +import polymod.fs.ZipFileSystem; import funkin.data.dialogue.conversation.ConversationRegistry; import funkin.data.dialogue.dialoguebox.DialogueBoxRegistry; import funkin.data.dialogue.speaker.SpeakerRegistry; @@ -54,6 +55,9 @@ class PolymodHandler public static var loadedModIds:Array = []; + // Use SysZipFileSystem on desktop and MemoryZipFilesystem on web. + static var modFileSystem:Null = null; + /** * If the mods folder doesn't exist, create it. */ @@ -115,6 +119,8 @@ class PolymodHandler buildImports(); + if (modFileSystem == null) modFileSystem = buildFileSystem(); + var loadedModList:Array = polymod.Polymod.init( { // Root directory for all mods. @@ -132,6 +138,8 @@ class PolymodHandler // A map telling Polymod what the asset type is for unfamiliar file extensions. // extensionMap: [], + customFilesystem: modFileSystem, + frameworkParams: buildFrameworkParams(), // List of filenames to ignore in mods. Use the default list to ignore the metadata file, etc. @@ -206,6 +214,16 @@ class PolymodHandler #end } + static function buildFileSystem():polymod.fs.ZipFileSystem + { + polymod.Polymod.onError = PolymodErrorHandler.onPolymodError; + return new ZipFileSystem( + { + modRoot: MOD_FOLDER, + autoScan: true + }); + } + static function buildImports():Void { // Add default imports for common classes. @@ -284,10 +302,14 @@ class PolymodHandler public static function getAllMods():Array { trace('Scanning the mods folder...'); + + if (modFileSystem == null) modFileSystem = buildFileSystem(); + var modMetadata:Array = Polymod.scan( { modRoot: MOD_FOLDER, apiVersionRule: API_VERSION, + fileSystem: modFileSystem, errorCallback: PolymodErrorHandler.onPolymodError }); trace('Found ${modMetadata.length} mods when scanning.');