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
40
module/tweaks/hotbarButtonGap.mjs
Normal file
40
module/tweaks/hotbarButtonGap.mjs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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 { registerCategorySetting } from "../utils/SubMenuSettings.mjs";
|
||||
|
||||
const key = `hotbarButtonGap`;
|
||||
|
||||
export function hotbarButtonGap() {
|
||||
status[key] = SettingStatusEnum.Unknown;
|
||||
if (preventTweakRegistration(key)) { 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: 0,
|
||||
max: 16,
|
||||
step: 1,
|
||||
}),
|
||||
default: 8,
|
||||
config: true,
|
||||
requiresReload: false,
|
||||
onChange: (newValue) => {
|
||||
document.body.style.setProperty(`--hotbar-button-gap`, `${newValue}px`);
|
||||
},
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
const buttonGap = game.settings.get(__ID__, key);
|
||||
document.body.style.setProperty(`--hotbar-button-gap`, `${buttonGap}px`);
|
||||
// #endregion Implementation
|
||||
|
||||
status[key] = SettingStatusEnum.Registered;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue