Adds tweak to add a global apps reference (closes #36)
This commit is contained in:
parent
07121397f8
commit
bb670d7795
3 changed files with 46 additions and 0 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
{
|
{
|
||||||
"OFT": {
|
"OFT": {
|
||||||
"setting": {
|
"setting": {
|
||||||
|
"addGlobalAppsReference": {
|
||||||
|
"name": "Add Global Instances",
|
||||||
|
"hint": "(v13+) This adds a global variable named \"apps\" that allows you to access \"foundry.applications.instances\" with less typing."
|
||||||
|
},
|
||||||
"addGlobalDocReferrer": {
|
"addGlobalDocReferrer": {
|
||||||
"name": "Add Global \"_doc\"",
|
"name": "Add Global \"_doc\"",
|
||||||
"hint": "(v13+) This adds a header control to document sheets that sets the _doc globalThis variable. Until the header control is triggered, the \"_doc\" variable is undefined."
|
"hint": "(v13+) This adds a header control to document sheets that sets the _doc globalThis variable. Until the header control is triggered, the \"_doc\" variable is undefined."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
// Tweaks
|
// Tweaks
|
||||||
|
import { addGlobalAppsReference } from "../tweaks/addGlobalAppsReference.mjs";
|
||||||
import { addGlobalDocReferrer } from "../tweaks/addGlobalDocReferrer.mjs";
|
import { addGlobalDocReferrer } from "../tweaks/addGlobalDocReferrer.mjs";
|
||||||
import { autoUnpauseOnLoad } from "../tweaks/autoUnpauseOnLoad.mjs";
|
import { autoUnpauseOnLoad } from "../tweaks/autoUnpauseOnLoad.mjs";
|
||||||
import { chatImageLinks } from "../tweaks/chatImageLinks.mjs";
|
import { chatImageLinks } from "../tweaks/chatImageLinks.mjs";
|
||||||
|
|
@ -31,6 +32,7 @@ Hooks.on(`setup`, () => {
|
||||||
restricted: false,
|
restricted: false,
|
||||||
type: DevSettingsMenu,
|
type: DevSettingsMenu,
|
||||||
});
|
});
|
||||||
|
addGlobalAppsReference();
|
||||||
addGlobalDocReferrer();
|
addGlobalDocReferrer();
|
||||||
autoUnpauseOnLoad();
|
autoUnpauseOnLoad();
|
||||||
|
|
||||||
|
|
|
||||||
40
module/tweaks/addGlobalAppsReference.mjs
Normal file
40
module/tweaks/addGlobalAppsReference.mjs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
import { SettingStatusEnum, status } from "../utils/SettingStatus.mjs";
|
||||||
|
import { __ID__ } from "../consts.mjs";
|
||||||
|
import { Logger } from "../utils/Logger.mjs";
|
||||||
|
import { preventTweakRegistration } from "../utils/preRegisterTweak.mjs";
|
||||||
|
import { registerDevSetting } from "../utils/SubMenuSettings.mjs";
|
||||||
|
|
||||||
|
export const key = `addGlobalAppsReference`;
|
||||||
|
|
||||||
|
export function addGlobalAppsReference() {
|
||||||
|
status[key] = SettingStatusEnum.Unknown;
|
||||||
|
if (preventTweakRegistration(key)) { return };
|
||||||
|
|
||||||
|
// #region Registration
|
||||||
|
Logger.log(`Registering setting: ${key}`);
|
||||||
|
registerDevSetting(__ID__, key, {
|
||||||
|
name: `OFT.setting.${key}.name`,
|
||||||
|
hint: `OFT.setting.${key}.hint`,
|
||||||
|
scope: `user`,
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
config: true,
|
||||||
|
requiresReload: false,
|
||||||
|
onChange: (newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
globalThis.apps = foundry.applications.instances;
|
||||||
|
} else {
|
||||||
|
delete globalThis.apps;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// #endregion Registration
|
||||||
|
|
||||||
|
// #region Implementation
|
||||||
|
Hooks.on(`ready`, () => {
|
||||||
|
globalThis.apps = foundry.applications.instances;
|
||||||
|
});
|
||||||
|
// #endregion Implementation
|
||||||
|
|
||||||
|
status[key] = SettingStatusEnum.Registered;
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue