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.

51 lines
2.0 KiB

  1. import { registerEffectIconHooks } from './effectIconHooks.js';
  2. import { registerArtSelectButtonHooks } from './artSelectButtonHooks.js';
  3. import { registerOverlayHooks } from './overlayHooks.js';
  4. import { registerEffectMappingHooks } from './effectMappingHooks.js';
  5. import { registerHUDHooks } from './hudHooks.js';
  6. import { registerUserMappingHooks } from './userMappingHooks.js';
  7. import { registerWildcardHooks } from './wildcardHooks.js';
  8. import { registerPopRandomizeHooks } from './popUpRandomizeHooks.js';
  9. import { TVA_CONFIG } from '../settings.js';
  10. export const REGISTERED_HOOKS = {};
  11. export function registerHook(feature_id, name, fn, { once = false } = {}) {
  12. if (!(feature_id in REGISTERED_HOOKS)) REGISTERED_HOOKS[feature_id] = {};
  13. if (name in REGISTERED_HOOKS[feature_id]) return;
  14. if (TVA_CONFIG.debug) console.info(`TVA | Registering Hook`, { feature_id, name, fn, once });
  15. const num = Hooks.on(name, fn, { once });
  16. REGISTERED_HOOKS[feature_id][name] = num;
  17. }
  18. export function unregisterHook(feature_id, name) {
  19. if (feature_id in REGISTERED_HOOKS && name in REGISTERED_HOOKS[feature_id]) {
  20. if (TVA_CONFIG.debug)
  21. console.info(`TVA | Un-Registering Hook`, {
  22. feature_id,
  23. name,
  24. id: REGISTERED_HOOKS[feature_id][name],
  25. });
  26. Hooks.off(name, REGISTERED_HOOKS[feature_id][name]);
  27. delete REGISTERED_HOOKS[feature_id][name];
  28. }
  29. }
  30. export function registerAllHooks() {
  31. // Hide effect icons
  32. registerEffectIconHooks();
  33. // Display overlays
  34. registerOverlayHooks();
  35. // Insert Art Select buttons and contextmenu listeners
  36. registerArtSelectButtonHooks();
  37. // Effect Mapping related listening for state changes and applying configurations
  38. registerEffectMappingHooks();
  39. // Display HUD buttons for Tokens and Tiles
  40. registerHUDHooks();
  41. // Default Wildcard image controls
  42. registerWildcardHooks();
  43. // User to Image mappings for Tile and Tokens
  44. registerUserMappingHooks();
  45. // Handle pop-ups and randomization on token/actor create
  46. registerPopRandomizeHooks();
  47. }