Jagusti / fvtt-wfrp4e-gmtoolkit

Utility module with tweaks, enhancements and macros to help GMs with game management when running Warhammer Fantasy Roleplay (4e) sessions in Foundry Virtual Tabletop.
MIT License
15 stars 9 forks source link

Improve usability of Toggle Compendium Pack Visibility macro #231

Open Jagusti opened 1 year ago

Jagusti commented 1 year ago

Context

What is the motivation or use case?

The Toggle Compendium Pack Visibility macro script can be manually adjusted to restrict to packs from specific sources and/or package types. This change would provide a user interface to make it easier to select or specify constraints and configurations.

From v11, it is also possible to fallback to a defined default ownership configuration, which may be used to quickly reset changes.

What do you expect to happen?

Additional context

This probably won't be backwards compatible prior to v11.

References

Spun out of #225

Jagusti commented 1 year ago

Add Toolkit option to check and offer offer to toggle visibility of newly installed modules on load

This might need a cunning / laborious hack, as there's no record of newly installed modules.

If instead I can intercept a save operation on the Module Management form app, ... (maybe in or around ModuleManagement._updateObjector SettingsConfig.reloadConfirm)

... then I can retrieve the checked list of modules using

ModuleManagement.prototype.getData().modules.filter(m => m.active)

... and compare it with the actually active list of modules using

game.modules.filter(m => m.active)

If there's a meaningful difference, I can set a temporary world flag which I check on reload to prompt the GM about toggling compendium visibility. Once confirmed (either way), I can delete the flag.

There may be some benefit to using the hasPacks property to determine a meaningful difference, as I only really care about those modules with compendia.

ModuleManagement.prototype.getData().modules.filter(m => m.active && m.hasPacks)