40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
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;
|
|
};
|