Add setting to add a global _doc reference (closes #4)
This commit is contained in:
parent
5573a5b674
commit
ee99ab15dd
3 changed files with 45 additions and 2 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
{
|
{
|
||||||
"OFT": {
|
"OFT": {
|
||||||
"setting": {
|
"setting": {
|
||||||
|
"addGlobalDocReferrer": {
|
||||||
|
"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."
|
||||||
|
},
|
||||||
"autoUnpauseOnLoad": {
|
"autoUnpauseOnLoad": {
|
||||||
"name": "Auto Unpause On Load",
|
"name": "Auto Unpause On Load",
|
||||||
"hint": "(v13+, GM-Only) Automatically unpauses the game when you load into the world. This will happen EVERY time you load into the world, including if you reload the website."
|
"hint": "(v13+, GM-Only) Automatically unpauses the game when you load into the world. This will happen EVERY time you load into the world, including if you reload the website."
|
||||||
|
|
@ -45,7 +49,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"apps": {
|
"apps": {
|
||||||
"no-settings-to-display": "No settings to display"
|
"no-settings-to-display": "No settings to display",
|
||||||
|
"make-global-reference": "Make Global Reference"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
import "./hooks/renderSettingsConfig.mjs";
|
import "./hooks/renderSettingsConfig.mjs";
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
import { addGlobalDocReferrer } from "./settings/addGlobalDocReferrer.mjs";
|
||||||
|
import { autoUnpauseOnLoad } from "./settings/autoUnpauseOnLoad.mjs";
|
||||||
import { chatSidebarBackground } from "./settings/chatSidebarBackground.mjs";
|
import { chatSidebarBackground } from "./settings/chatSidebarBackground.mjs";
|
||||||
import { hotbarButtonGap } from "./settings/hotbarButtonGap.mjs";
|
import { hotbarButtonGap } from "./settings/hotbarButtonGap.mjs";
|
||||||
import { hotbarButtonSize } from "./settings/hotbarButtonSize.mjs";
|
import { hotbarButtonSize } from "./settings/hotbarButtonSize.mjs";
|
||||||
|
|
@ -15,7 +17,6 @@ import { DevSettingsMenu } from "./apps/DevSettingsMenu.mjs";
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
import { __ID__ } from "./consts.mjs";
|
import { __ID__ } from "./consts.mjs";
|
||||||
import { autoUnpauseOnLoad } from "./settings/autoUnpauseOnLoad.mjs";
|
|
||||||
|
|
||||||
Hooks.on(`setup`, () => {
|
Hooks.on(`setup`, () => {
|
||||||
|
|
||||||
|
|
@ -26,6 +27,7 @@ Hooks.on(`setup`, () => {
|
||||||
restricted: false,
|
restricted: false,
|
||||||
type: DevSettingsMenu,
|
type: DevSettingsMenu,
|
||||||
});
|
});
|
||||||
|
addGlobalDocReferrer();
|
||||||
autoUnpauseOnLoad();
|
autoUnpauseOnLoad();
|
||||||
|
|
||||||
chatSidebarBackground();
|
chatSidebarBackground();
|
||||||
|
|
|
||||||
36
module/settings/addGlobalDocReferrer.mjs
Normal file
36
module/settings/addGlobalDocReferrer.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { __ID__ } from "../consts.mjs";
|
||||||
|
import { Logger } from "../utils/Logger.mjs";
|
||||||
|
import { registerDevSetting } from "../utils/DevSettings.mjs";
|
||||||
|
|
||||||
|
const key = `addGlobalDocReferrer`;
|
||||||
|
|
||||||
|
export function addGlobalDocReferrer() {
|
||||||
|
|
||||||
|
// #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,
|
||||||
|
});
|
||||||
|
// #endregion Registration
|
||||||
|
|
||||||
|
// #region Implementation
|
||||||
|
Hooks.on(`getHeaderControlsDocumentSheetV2`, (app, controls) => {
|
||||||
|
if (!game.settings.get(__ID__, key)) { return };
|
||||||
|
|
||||||
|
controls.push({
|
||||||
|
icon: `fa-solid fa-file`,
|
||||||
|
label: `OFT.apps.make-global-reference`,
|
||||||
|
onClick: () => {
|
||||||
|
globalThis._doc = app.document;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// #endregion Implementation
|
||||||
|
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue