Feature: External (mod-provided) data layers #1010
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds an API for other mods to register and implement their own data layers.
The API has a single
Register
method which takes anIDataLayer
. That, in turn, provides the legend data, colors, translations, update logic, etc.Externally-registered layers act just like internal ones; they show up in the GMCM and the UI widget as if they were normal layers.
There might be a few caveats or rough edges here; in particular:
ColorScheme
is entirely internal to Data Layers. Users of a mod that is basedIDataLayersApi
probably won't have anything set up in their color scheme for that mod. I'm not sure how useful it really is to bother with color schemes in this context, but if a user adds those keys to thecolors.json
then it should work normally.LegendEntry
has a convenient constructor that allows omitting the name if I18n key is used as ID. This doesn't work when going across the API boundary, because DataLayers only sees its own translations, whereas the registering mod would be providing a key for itself. This means mods have to provide layer names as well.There's an example consumer in 078a47d.