-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfoundryvtt-devMode.mjs
76 lines (59 loc) · 2.47 KB
/
foundryvtt-devMode.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { DevMode } from './module/classes/DevMode.mjs';
import { DevModeConfig } from './module/classes/DevModeConfig.mjs';
import { DevModeSettings } from './module/classes/DevModeSettings.mjs';
import setupApplicationHeaderPrintButton from './module/hooks/app-header-buttons.mjs';
import setupDevModeAnchor from './module/hooks/dev-mode-anchor.mjs';
import { inspectSystemTemplate } from './module/hooks/inspect-template.mjs';
import { setupJSONDiff } from './module/hooks/json-changes.mjs';
import { _devModeDisplayUsabilityErrors } from './module/patches/displayUsabilityErrors.mjs';
import setupDisableTemplateCache from './module/patches/getTemplate.mjs';
import { libWrapper } from './module/shim.mjs';
import autoOpenDocuments from "./module/hooks/auto-open-documents.mjs";
Handlebars.registerHelper('dev-concat', (...args) => {
DevMode.log(false, args);
// Ignore the object appended by handlebars.
if (typeof args[args.length - 1] === 'object') {
args.pop();
}
return args.join('');
});
/* ------------------------------------ */
/* Initialize module */
/* ------------------------------------ */
Hooks.once('init', function () {
DevMode.log(true, `Initializing ${DevMode.MODULE_ID}`);
DevModeSettings.registerSettings();
DevMode.registerPackageDebugFlag(DevMode.MODULE_ID, 'boolean');
DevMode.setDebugOverrides();
DevMode.setCompatibilityWarnings();
game.modules.get(DevMode.MODULE_ID).api = DevMode.API;
// register any modules as they init
Hooks.callAll('devModeReady', DevMode.API);
// add :mage: button to the foundry logo
$('#logo').after(`<button type='button' id="dev-mode-button">🧙</button>`);
$('#dev-mode-button').on('click', () => {
const devModeConfig = new DevModeConfig();
devModeConfig.render(true);
});
libWrapper.register(
DevMode.MODULE_ID,
'Game.prototype._displayUsabilityErrors',
_devModeDisplayUsabilityErrors,
'MIXED',
);
if (game.settings.get(DevMode.MODULE_ID, DevMode.SETTINGS.disableTemplateCache)) {
setupDisableTemplateCache();
}
setupDevModeAnchor();
});
Hooks.on('ready', () => {
if (game.paused && game.settings.get(DevMode.MODULE_ID, DevMode.SETTINGS.alwaysUnpause)) {
game.togglePause(false);
}
setupJSONDiff();
inspectSystemTemplate();
setupApplicationHeaderPrintButton();
// If Vueport is enabled, it needs a little bit to be ready to render a sheet
if ( game.modules.get("vueport")?.active ) setTimeout(autoOpenDocuments, 1000);
else autoOpenDocuments();
});