Repository navigation
feat: loader specific enabled handling - #2282
WilsontheWolf wants to merge 2 commits into
Conversation
| for(let modIndex in parsedYaml){ | ||
| const mod = new ManifestV2().fromJsObject(parsedYaml[modIndex]); | ||
| // Mod loaders don't support disabling. | ||
| if (!installer.isModLoader(mod)) { |
There was a problem hiding this comment.
I get a TS2339: Property 'isModLoader' does not exist on type 'ProfileInstallerProvider' error here
| mod, | ||
| } = args; | ||
| const info = await this.isDisabled(args, false) | ||
| if (!info) return console.warn("Told to enable a lovely mod (" + mod.getName() + "), but mod was not disabled?"); |
There was a problem hiding this comment.
This will fire on every package uninstall as well, IIRC. Not really necessary.
|
|
||
| /** | ||
| * Returns a boolean if a mod is disabled in the loader. Returns undefined if the loader doesn't support disabling. | ||
| * For loaders without a disabling mechanism, this function should always return false. | ||
| * @param mod | ||
| */ | ||
| public abstract isModLoaderDisabled(mod: ManifestV2, profile: ImmutableProfile): Promise<R2Error | boolean | undefined> ; |
There was a problem hiding this comment.
Both the docstring and the function name are confusing. Does this function return false or undefined? Clarify.
| } | ||
| } | ||
|
|
||
| async disable(args: InstallArgs) { |
There was a problem hiding this comment.
This implementation works except for disabled mods that existed before the user updated r2modman. Those disabled packages would get forcibly re-enabled, which isn't really what we want.
Off the top of my head, disabled packages should be detectable via:
- Does mods.yml say it is disabled?
- Is there a .lovelyignore or blacklist entry?
- Are the mod's files missing?
This whole part of r2modman is kinda confusing so if I don't make sense I'm sorry. It's late and I'm sleeeeeepy.
This adds the ability for PackageInstallers to control mod enabled/disabled states. This is done via the following methods:
Which allows a package installer to indicate whether a mod is enabled or disabled (or if r2mm should handle it,
undefined), if the method has been defined, and:which is used to get the value of the aformentiond isLoaderDisabled for a specific mod, handling loaders that don't define the method.
This is then used when querying the list of mods to force enable or disable a mod if isModLoaderDisabled returns true/false.
The
LovelyPluginInstallernow providesisLoaderDisabled, and it now opts to rely soley on lovely's built in disabling mechanims rather than r2mm's, which improves compatbility with mods that rely on this (for example, Steamodded's mod menu now shows disabled mods correctly, and they can be (dis/en)abled from there and sync to r2mm).When disabling a mod it adds a .lovelyignore, and when enabling it will handle both .lovelyignore and the blacklist correctly.
This might cause some issues if a user disables a mod in an old version of r2mm, and updates to this new version as the mechanism has been changed. I didn't really know how to solve this so I just didn't