All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

  1. import { TOKEN_HUD_VARIANTS } from '../../applications/tokenHUD.js';
  2. import { Reticle } from '../reticle.js';
  3. import { FEATURE_CONTROL, TVA_CONFIG } from '../settings.js';
  4. import { registerWrapper, unregisterWrapper } from './wrappers.js';
  5. const feature_id = 'HUD';
  6. export function registerHUDWrappers() {
  7. unregisterWrapper(feature_id, 'TokenHUD.prototype.clear');
  8. if (FEATURE_CONTROL[feature_id]) {
  9. registerWrapper(feature_id, 'TokenHUD.prototype.clear', _clear, 'MIXED');
  10. }
  11. }
  12. function _clear(wrapped, ...args) {
  13. _applyVariantFlags();
  14. // HUD should not close if we're in assisted overlay positioning mode
  15. if (Reticle.active && Reticle.mode === 'hud') return;
  16. return wrapped(...args);
  17. }
  18. async function _applyVariantFlags() {
  19. const { actor, variants } = TOKEN_HUD_VARIANTS;
  20. if (actor) {
  21. if (!variants?.length) {
  22. actor.unsetFlag('token-variants', 'variants');
  23. } else {
  24. actor.setFlag('token-variants', 'variants', variants);
  25. }
  26. }
  27. TOKEN_HUD_VARIANTS.actor = null;
  28. TOKEN_HUD_VARIANTS.variants = null;
  29. }