Add support for basic mod dependencies
Pathoschild opened this issue ยท 6 comments
Let mods specify dependencies in their manifest.json
:
{
...,
"Dependencies": [
{
"UniqueID": "EntoaroxFramework"
},
{
"UniqueID": "SomeOtherMod"
}
]
}
If all mods listed as dependencies are available, load them before this mod; otherwise skip this mod with an error.
Split from #248.
The preliminary work is done (decoupling metadata loading from assembly loading, and adding dependencies to the manifest parsing). The main task now is sorting mods by dependency order, taking into account that mods will be able to specify before/after dependencies (#288).
In other words, given given arbitrary mod dependencies like this:
modA:
LoadBefore: [ modB, modC ]
LoadAfter: [ modD ]
modC:
LoadAfter: [ modE ]
LoadBefore: [ modB ]
We need an algorithm which correctly sorts those mods into D A E C B
, so every mod is loaded before any of the mods that need it. That algorithm needs to handle chains (e.g. C before B after A), and needs to properly detect cyclic dependencies and determine which mod to disable (ideally the one that has the least impact on the graph, but I'd settle for removing the last one loaded for now).
I'd suggest doing some refactoring of the code around this so that unit tests can be added. I tried adding unit tests but ran into to many changes I'd need to make.
What do you think about adding in an optional argument:
{
...,
"Dependencies": [
{
"UniqueID": "EntoaroxFramework",
"URL": "http://community.playstarbound.com/resources/entoarox-framework.4228/"
},
{
"UniqueID": "SomeOtherMod"
}
]
}
This would allow Mods to specify where to find their dependancies and in your error messages you can display this URL.
The implementation was released in SMAPI 1.13, but mod dependencies are currently disabled so we can test the refactoring that was needed before enabling the feature. Moved to the 1.14 milestone for release.
@miketweaver The ideal would be a centralised place to check instead. For example, you could have something like this:
"Dependencies": [
{
"UniqueID": "EntoaroxFramework",
"ModDropID": 4228
}
]
Then SMAPI would be able to fetch metadata from the ModDrop API, including the mod's name (which may not match the ID), author, and URL. But that's outside the scope of this ticket; feel free to create a separate ticket to discuss further.