Add the very first dev-oriented setting and a DevSettingsConfig to manage it
This commit is contained in:
parent
28d0105397
commit
5573a5b674
6 changed files with 120 additions and 1 deletions
37
module/settings/autoUnpauseOnLoad.mjs
Normal file
37
module/settings/autoUnpauseOnLoad.mjs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { registerDevSetting } from "../utils/DevSettings.mjs";
|
||||
|
||||
const key = `autoUnpauseOnLoad`;
|
||||
|
||||
export function autoUnpauseOnLoad() {
|
||||
|
||||
const prevented = Hooks.call(`${__ID__}.preventSetting`, key);
|
||||
if (!prevented) {
|
||||
Logger.log(`Preventing setting "${key}" from being registered`);
|
||||
return;
|
||||
};
|
||||
|
||||
// #region Registration
|
||||
Logger.log(`Registering setting: ${key}`);
|
||||
registerDevSetting(__ID__, key, {
|
||||
name: `OFT.setting.${key}.name`,
|
||||
hint: `OFT.setting.${key}.hint`,
|
||||
scope: `client`,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
config: game.user.isGM,
|
||||
requiresReload: false,
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
Hooks.once(`ready`, () => {
|
||||
const autoUnpause = game.settings.get(__ID__, key);
|
||||
if (autoUnpause && game.paused) {
|
||||
Logger.debug(`setting:${key} | Unpausing the game`);
|
||||
game.togglePause(false, { broadcast: true });
|
||||
};
|
||||
});
|
||||
// #endregion Implementation
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue