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
|
|
@ -1,45 +0,0 @@
|
|||
import { SettingStatusEnum, status } from "../utils/SettingStatus.mjs";
|
||||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { registerCategorySetting } from "../utils/SubMenuSettings.mjs";
|
||||
|
||||
const key = `hotbarButtonSize`;
|
||||
|
||||
export function hotbarButtonSize() {
|
||||
status[key] = SettingStatusEnum.Unknown;
|
||||
|
||||
const prevented = Hooks.call(`${__ID__}.preventSetting`, key);
|
||||
if (!prevented) {
|
||||
Logger.log(`Preventing setting "${key}" from being registered`);
|
||||
status[key] = SettingStatusEnum.Blocked;
|
||||
return;
|
||||
};
|
||||
|
||||
// #region Registration
|
||||
Logger.log(`Registering setting: ${key}`);
|
||||
document.body.classList.add(`${__ID__}-${key}`);
|
||||
registerCategorySetting(`hotbar`, __ID__, key, {
|
||||
name: `OFT.setting.${key}.name`,
|
||||
hint: `OFT.setting.${key}.hint`,
|
||||
scope: `user`,
|
||||
type: new foundry.data.fields.NumberField({
|
||||
min: 45,
|
||||
max: 75,
|
||||
step: 5,
|
||||
}),
|
||||
default: 60, // this is the value Foundry uses
|
||||
config: true,
|
||||
requiresReload: false,
|
||||
onChange: (newValue) => {
|
||||
document.body.style.setProperty(`--hotbar-size`, `${newValue}px`);
|
||||
},
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
const hotbarSize = game.settings.get(__ID__, key);
|
||||
document.body.style.setProperty(`--hotbar-size`, `${hotbarSize}px`);
|
||||
// #endregion Implementation
|
||||
|
||||
status[key] = SettingStatusEnum.Registered;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue