Move the tweak prevention into a helper function and rename the module hooks w/ compatibility code
This commit is contained in:
parent
3d4376aa81
commit
9c8b6f37f9
20 changed files with 102 additions and 102 deletions
35
module/tweaks/preventUserConfigOpen.mjs
Normal file
35
module/tweaks/preventUserConfigOpen.mjs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { SettingStatusEnum, status } from "../utils/SettingStatus.mjs";
|
||||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { preventTweakRegistration } from "../utils/preRegisterTweak.mjs";
|
||||
|
||||
const key = `preventUserConfigOpen`;
|
||||
|
||||
export function preventUserConfigOpen() {
|
||||
status[key] = SettingStatusEnum.Unknown;
|
||||
if (preventTweakRegistration(key)) { return };
|
||||
|
||||
// #region Registration
|
||||
Logger.log(`Registering setting: ${key}`);
|
||||
game.settings.register(__ID__, key, {
|
||||
name: `OFT.setting.${key}.name`,
|
||||
hint: `OFT.setting.${key}.hint`,
|
||||
scope: `user`,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
config: !game.user.isGM,
|
||||
requiresReload: false,
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
Hooks.once(`renderUserConfig`, (app, element) => {
|
||||
if (!game.ready && game.settings.get(__ID__, key)) {
|
||||
element.style.display = `none`;
|
||||
app.close();
|
||||
};
|
||||
});
|
||||
// #endregion Implementation
|
||||
|
||||
status[key] = SettingStatusEnum.Registered;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue