Add hotbar settings (reposition, button size/gap)
This commit is contained in:
parent
4dc7b8541f
commit
27c5fccba0
9 changed files with 177 additions and 8 deletions
39
module/settings/hotbarButtonGap.mjs
Normal file
39
module/settings/hotbarButtonGap.mjs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { __ID } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
|
||||
const key = `hotbarButtonGap`;
|
||||
|
||||
export function hotbarButtonGap() {
|
||||
|
||||
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}`);
|
||||
document.body.classList.add(`${__ID}-${key}`);
|
||||
game.settings.register(__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
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue