diff --git a/polymod/Polymod.hx b/polymod/Polymod.hx index ac8a4817..26f41023 100644 --- a/polymod/Polymod.hx +++ b/polymod/Polymod.hx @@ -918,6 +918,11 @@ class ModMetadata */ public var modPath:String; + /** + * The directory name of the mod. + */ + public var dirName:String; + /** * `metadata` provides an optional list of keys. * These can provide additional information about the mod, specific to your application. @@ -1021,6 +1026,7 @@ class ModMetadata } var m = new ModMetadata(); + m.id = JsonHelp.str(json, 'id'); m.title = JsonHelp.str(json, 'title'); m.description = JsonHelp.str(json, 'description'); m._author = JsonHelp.str(json, 'author'); diff --git a/polymod/fs/MemoryFileSystem.hx b/polymod/fs/MemoryFileSystem.hx index b445a8ff..efcc7429 100644 --- a/polymod/fs/MemoryFileSystem.hx +++ b/polymod/fs/MemoryFileSystem.hx @@ -188,9 +188,9 @@ class MemoryFileSystem implements PolymodFileSystem.IFileSystem return result; } - public function getMetadata(modId:String) + public function getMetadata(dirName:String) { - var modpath = Util.pathJoin(modRoot, modId); + var modpath = Util.pathJoin(modRoot, dirName); if (exists(modpath)) { var meta:ModMetadata = null; @@ -209,7 +209,8 @@ class MemoryFileSystem implements PolymodFileSystem.IFileSystem meta = ModMetadata.fromJsonStr(metaText); if (meta == null) return null; - meta.id = modId; + meta.id = meta.id == '' ? dirName : meta.id; + meta.dirName = dirName; meta.modPath = modpath; } @@ -227,7 +228,7 @@ class MemoryFileSystem implements PolymodFileSystem.IFileSystem } else { - Polymod.error(MISSING_MOD, 'Could not find mod directory: $modpath'); + Polymod.error(MISSING_MOD, 'Could not find mod directory: $dirName'); } return null; } diff --git a/polymod/fs/SysFileSystem.hx b/polymod/fs/SysFileSystem.hx index 47c15641..5fb13523 100644 --- a/polymod/fs/SysFileSystem.hx +++ b/polymod/fs/SysFileSystem.hx @@ -104,9 +104,9 @@ class SysFileSystem implements IFileSystem return result; } - public function getMetadata(modId:String) + public function getMetadata(dirName:String) { - var modPath = Util.pathJoin(modRoot, modId); + var modPath = Util.pathJoin(modRoot, dirName); if (exists(modPath)) { var meta:ModMetadata = null; @@ -127,7 +127,8 @@ class SysFileSystem implements IFileSystem if (meta == null) return null; - meta.id = modId; + meta.id = meta.id == '' ? dirName : meta.id; + meta.dirName = dirName; meta.modPath = modPath; if (!exists(iconFile)) @@ -144,7 +145,7 @@ class SysFileSystem implements IFileSystem } else { - Polymod.error(MISSING_MOD, 'Could not find mod directory: $modId'); + Polymod.error(MISSING_MOD, 'Could not find mod directory: $dirName'); } return null; }