SMAPI - Stardew Modding API

SMAPI - Stardew Modding API

971k Downloads

Allow nested mod folders

Pathoschild opened this issue ยท 3 comments

commented

SMAPI expects mods with this folder structure:

Stardew Valley/
   Mods/
      ExampleMod/
         ExampleMod.dll
         manifest.json

Players often unzip mods into a new folder, so they end up with a folder structure like this instead:

Stardew Valley/
   Mods/
      ExampleMod-1.0/
          ExampleMod/
             ExampleMod.dll
             manifest.json

Either:

  • navigate one folder down if the mod folder only contains a folder (which addresses the issue with minimal complication);
  • or recursively search for manifest.json files (which addresses the issue, but means SMAPI might load duplicates from backup or old folders).
commented

or recursively search for manifest.json files (which addresses the issue, but means SMAPI might load duplicates from backup or old folders).

Could loading these old/duplicate versions not be resolved by only loading mods with a manifest.json that for their UniqueID have the:

  • Highest Version.MajorVersion, or if equal:
  • Highest Version.MinorVersion, or if equal:
  • Highest Version.PatchVersion

Comparing the versions ensures you have the latest version, but does not take Version.Build into account. There's not a reliable way to compare two versions of this property, as it's a string not confined to any particular structure. I'd say the manifest.json's ctime is a good indicator of which build should take precedence, however, should this be the (edge) case. Of course, if the user removes manifest.json and re-adds it for the older build, it would load the old mod. But I feel this is such a rare occurrence that it shouldn't pose an issue.

Or, SMAPI could recursively go down empty folders until it hits a non-empty folder containing a manifest.json (and the associated EntryDll). But I can imagine this wouldn't work if there's e.g. a README in a folder.

What do you think?

commented

I think the first approach (loading mods recursively) will cause problems, since it's common to disable mods by moving them into an old or backups subfolder. It may also cause confusion when used with the Advanced Location Loader mod, which has its own sub-mod format using a manifest.json.

I like the second approach (skipping down empty folders). It fixes the issue of players mistakenly extracting into a sub-subfolder, without introducing new edge cases like the first approach. It's fine if it skips folders that have another file in them, since that's a different use case.

commented

Done in release/1.9. SMAPI now recursively delves into empty folders until it hits a non-empty folder per the above discussion.