Pathoschild / SMAPI

The modding API for Stardew Valley.
https://smapi.io/
GNU Lesser General Public License v3.0
1.72k stars 259 forks source link

Allow nested mod folders #208

Closed Pathoschild closed 7 years ago

Pathoschild commented 7 years ago

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:

Wicketd commented 7 years ago

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:

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?

Pathoschild commented 7 years ago

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.

Pathoschild commented 7 years ago

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